IOUtil.assertFileIsWritable(OUTPUT);
if (WRITE_READS_FILES) writeReadsFile(INPUT);
switch (FILTER) {
case includeAligned:
filterReads(new FilteringIterator(new SAMFileReader(INPUT).iterator(),
new AlignedFilter(true), true));
break;
case excludeAligned:
filterReads(new FilteringIterator(new SAMFileReader(INPUT).iterator(),
new AlignedFilter(false), true));
break;
case includeReadList:
filterReads(new FilteringIterator(new SAMFileReader(INPUT).iterator(),
new ReadNameFilter(READ_LIST_FILE, true)));
break;
case excludeReadList:
filterReads(new FilteringIterator(new SAMFileReader(INPUT).iterator(),
new ReadNameFilter(READ_LIST_FILE, false)));
break;
default:
throw new UnsupportedOperationException(FILTER.name() + " has not been implemented!");
}