Fixed a bug in this code where it would eat reads that didn't start at the beginning of the provided interval. This should fix / help fix Kristian problem

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@453 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
aaron 2009-04-16 18:42:00 +00:00
parent 835f1067d8
commit 12e1f192c4
1 changed files with 15 additions and 14 deletions

View File

@ -1,18 +1,17 @@
package org.broadinstitute.sting.gatk.dataSources.providers;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.gatk.iterators.LocusIterator;
import org.broadinstitute.sting.gatk.iterators.LocusIteratorByHanger;
import org.broadinstitute.sting.gatk.LocusContext;
import org.broadinstitute.sting.gatk.traversals.TraversalStatistics;
import org.apache.log4j.Logger;
import net.sf.samtools.SAMRecord;
import java.util.Iterator;
import java.util.ArrayList;
import edu.mit.broad.picard.filter.FilteringIterator;
import edu.mit.broad.picard.filter.SamRecordFilter;
import net.sf.samtools.SAMRecord;
import org.apache.log4j.Logger;
import org.broadinstitute.sting.gatk.LocusContext;
import org.broadinstitute.sting.gatk.iterators.LocusIterator;
import org.broadinstitute.sting.gatk.iterators.LocusIteratorByHanger;
import org.broadinstitute.sting.gatk.traversals.TraversalStatistics;
import org.broadinstitute.sting.utils.GenomeLoc;
import java.util.ArrayList;
import java.util.Iterator;
/**
* Created by IntelliJ IDEA.
@ -27,7 +26,7 @@ public class LocusContextProvider {
// What's the last locus accessed? Used for sanity checking.
private GenomeLoc lastLoc = null;
private LocusIterator loci;
private LocusContext locus;
protected static Logger logger = Logger.getLogger(LocusContextProvider.class);
public LocusContextProvider( Iterator<SAMRecord> reads ) {
@ -60,9 +59,11 @@ public class LocusContextProvider {
if ( ! locusIter.hasNext() )
return null;
LocusContext locus = locusIter.next();
if (locus == null) {
locus = locusIter.next();
}
while ( ! target.containsP(locus.getLocation()) && locusIter.hasNext() ) {
while (target.isPast(locus.getLocation()) && locusIter.hasNext() ) {
logger.debug(String.format(" current locus is %s vs %s => %d", locus.getLocation(), target, locus.getLocation().compareTo(target)));
locus = locusIter.next();
}