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
This commit is contained in:
hanna 2009-07-15 14:41:37 +00:00
parent 1798aff01b
commit c25f84a01c
4 changed files with 9 additions and 67 deletions

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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<SAMRecord>, SeekableSamIteration {
protected Iterator<SAMRecord> it;
protected SAMFileReader reader;
public SeekableSamIterator(Iterator<SAMRecord> 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(); }
}

View File

@ -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