Fixes to mrl integration.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3573 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
hanna 2010-06-16 20:40:10 +00:00
parent b75ded61b8
commit 5972ad1199
1 changed files with 8 additions and 10 deletions

View File

@ -658,13 +658,13 @@ public class DownsamplingLocusIteratorByState extends LocusIterator {
int numReads = statesBySample.size(); int numReads = statesBySample.size();
if(numReads+newReads.size()<=targetCoverage || downsamplingMethod.type==DownsampleType.NONE || downsamplingMethod.type==DownsampleType.EXPERIMENTAL_NAIVE_DUPLICATE_ELIMINATOR) { if(numReads+newReads.size()<=targetCoverage || downsamplingMethod.type==DownsampleType.NONE || downsamplingMethod.type==DownsampleType.EXPERIMENTAL_NAIVE_DUPLICATE_ELIMINATOR) {
int readLimit = newReads.size(); long readLimit = aggregator.getNumReadsSeen();
boolean mrlViolation = false; boolean mrlViolation = false;
if(readLimit > maxReadsAtLocus-totalReadStates) { if(readLimit > maxReadsAtLocus-totalReadStates) {
readLimit = maxReadsAtLocus-totalReadStates; readLimit = maxReadsAtLocus-totalReadStates;
mrlViolation = true; mrlViolation = true;
} }
totalReadStates += addReadsToSample(statesBySample,newReads,readLimit,mrlViolation); addReadsToSample(statesBySample,newReads,readLimit,mrlViolation);
} }
else { else {
int[] counts = statesBySample.getCountsPerAlignmentStart(); int[] counts = statesBySample.getCountsPerAlignmentStart();
@ -701,7 +701,7 @@ public class DownsamplingLocusIteratorByState extends LocusIterator {
readOffset += counts[i]; readOffset += counts[i];
} }
statesBySample.purge(toPurge); statesBySample.purge(toPurge);
totalReadStates += addReadsToSample(statesBySample,newReads,targetCoverage-numReads,false); addReadsToSample(statesBySample,newReads,targetCoverage-numReads,false);
} }
} }
chainedReadSelector.reset(); chainedReadSelector.reset();
@ -712,11 +712,10 @@ public class DownsamplingLocusIteratorByState extends LocusIterator {
* @param readStates The list of read states to add this collection of reads. * @param readStates The list of read states to add this collection of reads.
* @param reads Reads to add. Selected reads will be pulled from this source. * @param reads Reads to add. Selected reads will be pulled from this source.
* @param maxReads Maximum number of reads to add. * @param maxReads Maximum number of reads to add.
* @return Total number of reads added.
*/ */
private int addReadsToSample(final PerSampleReadStateManager readStates, final Collection<SAMRecord> reads, final int maxReads, boolean atMaxReadsAtLocusLimit) { private void addReadsToSample(final PerSampleReadStateManager readStates, final Collection<SAMRecord> reads, final long maxReads, boolean atMaxReadsAtLocusLimit) {
if(reads.isEmpty()) if(reads.isEmpty())
return 0; return;
GenomeLoc location = null; GenomeLoc location = null;
@ -744,9 +743,7 @@ public class DownsamplingLocusIteratorByState extends LocusIterator {
if (location != null) if (location != null)
overflowTracker.exceeded(GenomeLocParser.createGenomeLoc(location.getContigIndex(),location.getStart(),rightMostEnd), overflowTracker.exceeded(GenomeLocParser.createGenomeLoc(location.getContigIndex(),location.getStart(),rightMostEnd),
readCount); totalReadStates);
return readCount;
} }
private class PerSampleReadStateManager implements Iterable<SAMRecordState> { private class PerSampleReadStateManager implements Iterable<SAMRecordState> {
@ -756,6 +753,7 @@ public class DownsamplingLocusIteratorByState extends LocusIterator {
public void addStatesAtNextAlignmentStart(Collection<SAMRecordState> states) { public void addStatesAtNextAlignmentStart(Collection<SAMRecordState> states) {
readStates.addAll(states); readStates.addAll(states);
readStateCounter.add(new Counter(states.size())); readStateCounter.add(new Counter(states.size()));
totalReadStates += states.size();
} }
public boolean isEmpty() { public boolean isEmpty() {
@ -926,7 +924,7 @@ class FirstNReadSelector implements ReadSelector {
} }
public void submitRead(SAMRecord read) { public void submitRead(SAMRecord read) {
if(readsSeen > readLimit) { if(readsSeen < readLimit) {
selectedReads.add(read); selectedReads.add(read);
if(chainedSelector != null) if(chainedSelector != null)
chainedSelector.submitRead(read); chainedSelector.submitRead(read);