From c25f84a01ca40d6cea6eb08cb466e9e60c779d9e Mon Sep 17 00:00:00 2001 From: hanna Date: Wed, 15 Jul 2009 14:41:37 +0000 Subject: [PATCH] Regression: we lost our hack to work around BAM files with index problems (affects BAM files created before 23 Apr 2009 and traversed by interval). Added the hack back in, along with a much more explicit comment about why its there. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1248 348d0f76-0448-11de-a6fe-93d51630548a --- .../simpleDataSources/ReadStreamPointer.java | 10 ++++- .../gatk/iterators/SeekableSamIteration.java | 21 --------- .../gatk/iterators/SeekableSamIterator.java | 43 ------------------- python/ValidateGATK.py | 2 +- 4 files changed, 9 insertions(+), 67 deletions(-) delete mode 100644 java/src/org/broadinstitute/sting/playground/gatk/iterators/SeekableSamIteration.java delete mode 100755 java/src/org/broadinstitute/sting/playground/gatk/iterators/SeekableSamIterator.java diff --git a/java/src/org/broadinstitute/sting/gatk/datasources/simpleDataSources/ReadStreamPointer.java b/java/src/org/broadinstitute/sting/gatk/datasources/simpleDataSources/ReadStreamPointer.java index 600a38234..fd2d57f4c 100644 --- a/java/src/org/broadinstitute/sting/gatk/datasources/simpleDataSources/ReadStreamPointer.java +++ b/java/src/org/broadinstitute/sting/gatk/datasources/simpleDataSources/ReadStreamPointer.java @@ -119,9 +119,13 @@ class MappedReadStreamPointer extends ReadStreamPointer { @Override public StingSAMIterator getReadsOverlapping( MappedStreamSegment segment ) { MergingSamRecordIterator2 mergingIterator = new MergingSamRecordIterator2( headerMerger, sourceInfo ); + + // The getStop() + 1 is a hack to work around an old bug in the way Picard created SAM files where queries + // over a given interval would occasionally not pick up the last read in that interval. mergingIterator.queryOverlapping( segment.locus.getContig(), (int)segment.locus.getStart(), - (int)segment.locus.getStop()); + (int)segment.locus.getStop()+1); + return StingSAMIteratorAdapter.adapt(sourceInfo,mergingIterator); } @@ -134,9 +138,11 @@ class MappedReadStreamPointer extends ReadStreamPointer { throw new StingException("Trying to access unmapped content from a mapped read stream pointer"); MappedStreamSegment mappedSegment = (MappedStreamSegment)segment; MergingSamRecordIterator2 mergingIterator = new MergingSamRecordIterator2( headerMerger, sourceInfo ); + // NOTE: explicitly not using the queryOverlapping hack above since, according to the above criteria, + // we'd only miss reads that are one base long when performing a contained query. mergingIterator.queryContained( mappedSegment.locus.getContig(), (int)mappedSegment.locus.getStart(), - (int)mappedSegment.locus.getStop()); + (int)mappedSegment.locus.getStop()+1); return StingSAMIteratorAdapter.adapt(sourceInfo,mergingIterator); } diff --git a/java/src/org/broadinstitute/sting/playground/gatk/iterators/SeekableSamIteration.java b/java/src/org/broadinstitute/sting/playground/gatk/iterators/SeekableSamIteration.java deleted file mode 100644 index fba934d02..000000000 --- a/java/src/org/broadinstitute/sting/playground/gatk/iterators/SeekableSamIteration.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.broadinstitute.sting.playground.gatk.iterators; - -import net.sf.samtools.SAMRecord; -import net.sf.samtools.SAMFileReader; -import net.sf.samtools.SAMRecordComparator; - -import java.util.Iterator; - -/** - * Created by IntelliJ IDEA. - * User: mdepristo - * Date: Mar 26, 2009 - * Time: 9:27:59 AM - * To change this template use File | Settings | File Templates. - */ -public interface SeekableSamIteration { - public boolean supportsSeeking(); - public void queryOverlapping( final String contig, final int start, final int stop ); - public void query(final String contig, final int start, final int stop, final boolean contained); - public void queryContained(final String contig, final int start, final int stop); -} diff --git a/java/src/org/broadinstitute/sting/playground/gatk/iterators/SeekableSamIterator.java b/java/src/org/broadinstitute/sting/playground/gatk/iterators/SeekableSamIterator.java deleted file mode 100755 index 54937dd8b..000000000 --- a/java/src/org/broadinstitute/sting/playground/gatk/iterators/SeekableSamIterator.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.broadinstitute.sting.playground.gatk.iterators; - -import net.sf.samtools.SAMRecord; -import net.sf.samtools.SAMFileReader; - -import java.util.Iterator; - -import org.broadinstitute.sting.playground.gatk.iterators.SeekableSamIteration; - -/** - * Created by IntelliJ IDEA. - * User: depristo - * Date: Feb 24, 2009 - * Time: 10:24:38 AM - * To change this template use File | Settings | File Templates. - */ -public class SeekableSamIterator implements Iterator, SeekableSamIteration { - protected Iterator it; - protected SAMFileReader reader; - - public SeekableSamIterator(Iterator it, SAMFileReader reader) { - this.it = it; - this.reader = reader; - } - - public boolean supportsSeeking() { return true; } - - public void queryOverlapping( final String contig, final int start, final int stop ) { - this.it = reader.queryOverlapping( contig, start, stop ); - } - - public void query(final String contig, final int start, final int stop, final boolean contained) { - this.it = reader.query( contig, start, stop, contained ); - } - - public void queryContained(final String contig, final int start, final int stop) { - this.it = reader.queryContained( contig, start, stop ); - } - - public boolean hasNext() { return it.hasNext(); } - public SAMRecord next() { return it.next(); } - public void remove () { it.remove(); } -} \ No newline at end of file diff --git a/python/ValidateGATK.py b/python/ValidateGATK.py index 9dcf77c7a..6dd4d1b7d 100755 --- a/python/ValidateGATK.py +++ b/python/ValidateGATK.py @@ -193,7 +193,7 @@ def main(): cmd = "java -ea -Xmx1024m -jar " + OPTIONS.gatkPath + " -T " + analysis + " -I " + subBAM + " -R " + ref + " -l INFO -S SILENT -U " + OPTIONS.extraArgs if isIntervalFile(region): - cmd += " --intervals_file " + region + cmd += " --intervals " + region cmd += " -B pileup,SAMPileup," + pileup print cmd