Source:
protected int doWork() { try { IOUtil.assertFileIsReadable(INPUT); IOUtil.assertFileIsWritable(OUTPUT); if (WRITE_READS_FILES) writeReadsFile(INPUT); final SamReader samReader = SamReaderFactory.makeDefault().referenceSequence(REFERENCE_SEQUENCE).open(INPUT); final FilteringSamIterator filteringIterator; List<Object> tagList = TAG_VALUE.stream().map(T -> (Object) T).collect(Collectors.toList()); switch (FILTER) { case includeAligned: filteringIterator = new FilteringSamIterator(samReader.iterator(), new AlignedFilter(true), true); break; case excludeAligned: filteringIterator = new FilteringSamIterator(samReader.iterator(), new AlignedFilter(false), true); break; case includeReadList: filteringIterator = new FilteringSamIterator(samReader.iterator(), new ReadNameFilter(READ_LIST_FILE, true)); break; case excludeReadList: filteringIterator = new FilteringSamIterator(samReader.iterator(), new ReadNameFilter(READ_LIST_FILE, false)); break; case includeJavascript: filteringIterator = new FilteringSamIterator(samReader.iterator(), new JavascriptSamRecordFilter(JAVASCRIPT_FILE, samReader.getFileHeader())); break; case includePairedIntervals: filteringIterator = new FilteringSamIterator(samReader.iterator(), new IntervalKeepPairFilter(getIntervalList(INTERVAL_LIST))); break; case includeTagValues: filteringIterator = new FilteringSamIterator(samReader.iterator(), new TagFilter(TAG, tagList, true)); break; case excludeTagValues: filteringIterator = new FilteringSamIterator(samReader.iterator(), new TagFilter(TAG, tagList, false)); break; default: throw new UnsupportedOperationException(FILTER.name() + " has not been implemented!"); } filterReads(filteringIterator); IOUtil.assertFileIsReadable(OUTPUT); if (WRITE_READS_FILES) writeReadsFile(OUTPUT); return 0; } catch (Exception e) { log.error(e, "Failed to filter " + INPUT.getName()); if (OUTPUT.exists() && !OUTPUT.delete()) { log.warn("Failed to delete possibly incomplete output file:" + OUTPUT.getAbsolutePath()); } return 1; } }

Target:
protected int doWork() { try { IOUtil.assertFileIsReadable(INPUT); IOUtil.assertFileIsWritable(OUTPUT); if (WRITE_READS_FILES) writeReadsFile(INPUT); final SamReader samReader = SamReaderFactory.makeDefault().referenceSequence(REFERENCE_SEQUENCE).open(INPUT); final FilteringSamIterator filteringIterator; List<Object> tagList = (List) TAG_VALUE; switch (FILTER) { case includeAligned: filteringIterator = new FilteringSamIterator(samReader.iterator(), new AlignedFilter(true), true); break; case excludeAligned: filteringIterator = new FilteringSamIterator(samReader.iterator(), new AlignedFilter(false), true); break; case includeReadList: filteringIterator = new FilteringSamIterator(samReader.iterator(), new ReadNameFilter(READ_LIST_FILE, true)); break; case excludeReadList: filteringIterator = new FilteringSamIterator(samReader.iterator(), new ReadNameFilter(READ_LIST_FILE, false)); break; case includeJavascript: filteringIterator = new FilteringSamIterator(samReader.iterator(), new JavascriptSamRecordFilter(JAVASCRIPT_FILE, samReader.getFileHeader())); break; case includePairedIntervals: filteringIterator = new FilteringSamIterator(samReader.iterator(), new IntervalKeepPairFilter(getIntervalList(INTERVAL_LIST))); break; case includeTagValues: filteringIterator = new FilteringSamIterator(samReader.iterator(), new TagFilter(TAG, tagList, true)); break; case excludeTagValues: filteringIterator = new FilteringSamIterator(samReader.iterator(), new TagFilter(TAG, tagList, false)); break; default: throw new UnsupportedOperationException(FILTER.name() + " has not been implemented!"); } filterReads(filteringIterator); IOUtil.assertFileIsReadable(OUTPUT); if (WRITE_READS_FILES) writeReadsFile(OUTPUT); return 0; } catch (Exception e) { log.error(e, "Failed to filter " + INPUT.getName()); if (OUTPUT.exists() && !OUTPUT.delete()) { log.warn("Failed to delete possibly incomplete output file:" + OUTPUT.getAbsolutePath()); } return 1; } }