diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/variantrecalling/HaplotypeBasedVariantRecaller.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/variantrecalling/HaplotypeBasedVariantRecaller.java index 6e02a782a15..33108ec5968 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/variantrecalling/HaplotypeBasedVariantRecaller.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/variantrecalling/HaplotypeBasedVariantRecaller.java @@ -135,11 +135,11 @@ public void traverse() { } // get reads overlapping haplotypes - final Map> readsByReader = readsReader.getReads(haplotypeSpan, vcLoc); + final Map> readsByReader = readsReader.getReads(haplotypeSpan, vcLoc); final List variants = new LinkedList<>(Arrays.asList(vc)); if ( logger.isDebugEnabled() ) { int readCount = 0; - for ( Collection reads : readsByReader.values() ) + for ( Collection reads : readsByReader.values() ) readCount += reads.size(); logger.debug(String.format("vcLoc %s, haplotypeSpan: %s, %d haplotypes, %d reads", vcLoc.toString(), haplotypeSpan.toString(), processedHaplotypes.size(), readCount, variants.size())); @@ -150,16 +150,16 @@ public void traverse() { final List>> genotypeLikelihoodsList = new LinkedList<>(); final List assemblyResultList = new LinkedList<>(); final List readsHeaderList = new LinkedList<>(); - for ( Map.Entry> entry : readsByReader.entrySet() ) { + for ( Map.Entry> entry : readsByReader.entrySet() ) { final AssemblyResultSet assemblyResult = new AssemblyResultSet(); processedHaplotypes.forEach(haplotype -> assemblyResult.add(haplotype)); final Map> perSampleReadList = new LinkedHashMap<>(); final SamReader samReader = entry.getKey(); - final Collection reads = entry.getValue(); + final Collection reads = entry.getValue(); List gtakReads = new LinkedList<>(); - reads.forEach(flowBasedRead -> gtakReads.add(flowBasedRead)); + reads.forEach(read -> gtakReads.add(read)); perSampleReadList.put(sampleNames[0], gtakReads); AssemblyRegion regionForGenotyping = new AssemblyRegion(haplotypeSpan, 0, samReader.getFileHeader()); assemblyResult.setPaddedReferenceLoc(haplotypeSpan); diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/variantrecalling/TrimmedReadsReader.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/variantrecalling/TrimmedReadsReader.java index 23f47eec203..94600f97ea1 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/variantrecalling/TrimmedReadsReader.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/variantrecalling/TrimmedReadsReader.java @@ -26,8 +26,6 @@ public class TrimmedReadsReader { private final List samReaders = new LinkedList<>(); private CountingReadFilter readFilter; - private final Map readGroupMaxClass = new LinkedHashMap<>(); - private final Map readGroupFlowOrder = new LinkedHashMap<>(); private final FlowBasedArgumentCollection fbArgs = new FlowBasedArgumentCollection(); public TrimmedReadsReader(final List readsFiles, final Path referencePath, final int cloudPrefetchBuffer) { @@ -44,11 +42,12 @@ public SAMSequenceDictionary getSamSequenceDictionary(final SamReader samReader) return ((samReader != null) ? samReader : samReaders.get(0)).getFileHeader().getSequenceDictionary(); } - public Map> getReads(final Locatable span, final Locatable vcLoc) { - final Map> readsByReader = new LinkedHashMap<>(); + public Map> getReads(final Locatable span, final Locatable vcLoc) { + + final Map> readsByReader = new LinkedHashMap<>(); for ( SamReader samReader : samReaders ) { - final List reads = new LinkedList<>(); + final List reads = new LinkedList<>(); final SAMRecordIterator iter = samReader.query(span.getContig(), span.getStart(), span.getEnd(), false); while (iter.hasNext()) { @@ -72,7 +71,10 @@ public Map> getReads(final Locatable span, gatkRead = ReadClipper.hardClipToRegion(gatkRead, span.getStart(), span.getEnd()); if (gatkRead.isUnmapped() || gatkRead.getCigar().isEmpty()) continue; - + if (!FlowBasedReadUtils.isFlowPlatform(samReader.getFileHeader(), gatkRead)){ + reads.add(gatkRead); + continue; + } // convert to a flow based read FlowBasedReadUtils.ReadGroupInfo rgInfo = FlowBasedReadUtils.getReadGroupInfo(samReader.getFileHeader(), gatkRead); final FlowBasedRead fbr = new FlowBasedRead(gatkRead, rgInfo.flowOrder, rgInfo.maxClass, fbArgs); diff --git a/src/test/java/org/broadinstitute/hellbender/tools/walkers/variantrecalling/TrimmedReadsReaderUnitTest.java b/src/test/java/org/broadinstitute/hellbender/tools/walkers/variantrecalling/TrimmedReadsReaderUnitTest.java index e3d05340523..6552b2e0908 100644 --- a/src/test/java/org/broadinstitute/hellbender/tools/walkers/variantrecalling/TrimmedReadsReaderUnitTest.java +++ b/src/test/java/org/broadinstitute/hellbender/tools/walkers/variantrecalling/TrimmedReadsReaderUnitTest.java @@ -5,6 +5,7 @@ import org.broadinstitute.hellbender.GATKBaseTest; import org.broadinstitute.hellbender.utils.SimpleInterval; import org.broadinstitute.hellbender.utils.read.FlowBasedRead; +import org.broadinstitute.hellbender.utils.read.GATKRead; import org.testng.Assert; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -68,10 +69,10 @@ public void testBasic(final BamSource bamSources[], final Locatable span, final Assert.assertNotNull(reader.getHeader(null)); // reads - Map> reads = reader.getReads(span, vcLoc); + Map> reads = reader.getReads(span, vcLoc); Assert.assertEquals(reads.size(), bamSources.length); int bamSourceIndex = 0; - for ( Map.Entry> entry : reads.entrySet() ) { + for ( Map.Entry> entry : reads.entrySet() ) { final BamSource bamSource = bamSources[bamSourceIndex++]; @@ -83,8 +84,8 @@ public void testBasic(final BamSource bamSources[], final Locatable span, final Assert.assertEquals(entry.getValue().size(), bamSource.readCount); // verify first and last - FlowBasedRead firstRead = entry.getValue().iterator().next(); - FlowBasedRead lastRead = entry.getValue().stream().reduce((prev, next) -> next).orElse(null); + FlowBasedRead firstRead = (FlowBasedRead) entry.getValue().iterator().next(); + FlowBasedRead lastRead = (FlowBasedRead) entry.getValue().stream().reduce((prev, next) -> next).orElse(null); Assert.assertEquals(firstRead.getName(), bamSource.firstReadName); Assert.assertEquals(lastRead.getName(), bamSource.lastReadName); }