Fix off-by-one error in original implementation of read sharding. Tested by

awking output of BamToFastq vs. samtools until the outputs matched exactly.


git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2945 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
hanna 2010-03-06 18:52:53 +00:00
parent 1ef1091f7c
commit ee2ec7ced9
4 changed files with 6 additions and 14 deletions

View File

@ -148,7 +148,7 @@ class MappedReadStreamPointer extends ReadStreamPointer {
// over a given interval would occasionally not pick up the last read in that interval.
mergingIterator.queryOverlapping( mappedSegment.locus.getContig(),
(int)mappedSegment.locus.getStart(),
(int)mappedSegment.locus.getStop()+ PlusOneFixIterator.PLUS_ONE_FIX_CONSTANT);
(int)mappedSegment.locus.getStop()+1);
return StingSAMIteratorAdapter.adapt(sourceInfo,mergingIterator);
}

View File

@ -15,14 +15,6 @@ import org.broadinstitute.sting.gatk.Reads;
* Time: 10:41:02 PM
*/
public class PlusOneFixIterator implements StingSAMIterator {
/**
* this holds the value that we use to correct our query overlapping calls with,
* but more importantly it ties the ReadStreamPointer code to this so we don't loose
* track of this adjustment across the code.
*/
public static final Integer PLUS_ONE_FIX_CONSTANT = 1;
/**
* our interval region
*/
@ -86,7 +78,7 @@ public class PlusOneFixIterator implements StingSAMIterator {
SAMRecord ret = mNextRecord;
while (mIterator.hasNext()) {
mNextRecord = mIterator.next();
if (!(mNextRecord.getAlignmentStart() > (mInterval.getStop() - PLUS_ONE_FIX_CONSTANT))) return ret;
if (!(mNextRecord.getAlignmentStart() > mInterval.getStop())) return ret;
}
mNextRecord = null;
return ret;

View File

@ -51,11 +51,11 @@ public class PlusOneFixIteratorTest extends BaseTest {
public void testReadAtEndOfInterval() {
int countOfReads = 0;
SAMFileReader reader = new SAMFileReader(bam, true);
final int size = 1108664;
final int size = 1108663;
reader.setValidationStringency(SAMFileReader.ValidationStringency.LENIENT);
GenomeLoc last = GenomeLocParser.createGenomeLoc("chr1", 1, size);
Iterator<SAMRecord> i = new PlusOneFixIterator(last, StingSAMIteratorAdapter.adapt(null, reader.queryOverlapping("chr1", 1, size)));
Iterator<SAMRecord> i = new PlusOneFixIterator(last, StingSAMIteratorAdapter.adapt(null, reader.queryOverlapping("chr1", 1, 1108663)));
//Iterator<SAMRecord> i = reader.queryOverlapping("chr1", 1, size);
while (i.hasNext()) {
SAMRecord rec = i.next();

View File

@ -12,13 +12,13 @@ public class BamToFastqIntegrationTest extends WalkerTest {
WalkerTestSpec spec1 = new WalkerTestSpec(
"-T BamToFastq -R " + oneKGLocation + "reference/human_b36_both.fasta -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,100-10,000,500;1:10,100,000-10,101,000;1:10,900,000-10,900,001 -o %s",
1,
Arrays.asList("2ec2ff5ac405099bf48186d2c7e5fabd"));
Arrays.asList("49431d567524d6fd32a569504b25f212"));
executeTest("testBamToFasta", spec1);
WalkerTestSpec spec2 = new WalkerTestSpec(
"-T BamToFastq -reverse -R " + oneKGLocation + "reference/human_b36_both.fasta -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,100-10,000,500;1:10,100,000-10,101,000;1:10,900,000-10,900,001 -o %s",
1,
Arrays.asList("5a79484da43925b0e0461be28fdad07c"));
Arrays.asList("f3a4a39d36270136c12bb1315fdb7dff"));
executeTest("testBamToFastaReverse", spec2);
}
}