Moved hasPileupBeenDownsampled() based on Eric's request. Also eliminated
@Deprecated constructors from AlignmentContext. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4142 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
427a2f85e9
commit
de5ccfb0b1
|
|
@ -46,6 +46,7 @@ import java.util.*;
|
||||||
public class AlignmentContext {
|
public class AlignmentContext {
|
||||||
protected GenomeLoc loc = null;
|
protected GenomeLoc loc = null;
|
||||||
protected ReadBackedPileup basePileup = null;
|
protected ReadBackedPileup basePileup = null;
|
||||||
|
protected boolean hasPileupBeenDownsampled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of bases we've skipped over in the reference since the last map invocation.
|
* The number of bases we've skipped over in the reference since the last map invocation.
|
||||||
|
|
@ -53,40 +54,19 @@ public class AlignmentContext {
|
||||||
*/
|
*/
|
||||||
private long skippedBases = 0;
|
private long skippedBases = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* Default constructor for AlignmentContext object
|
|
||||||
* since private objects are already set to null we
|
|
||||||
* don't need to do anything
|
|
||||||
*/
|
|
||||||
public AlignmentContext() { /* private objects already set to null */ }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new AlignmentContext object
|
|
||||||
*
|
|
||||||
* @param loc
|
|
||||||
* @param reads
|
|
||||||
* @param offsets
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public AlignmentContext(GenomeLoc loc, List<SAMRecord> reads, List<Integer> offsets) {
|
|
||||||
this(loc, reads, offsets, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public AlignmentContext(GenomeLoc loc, List<SAMRecord> reads, List<Integer> offsets, long skippedBases ) {
|
|
||||||
if ( loc == null ) throw new StingException("BUG: GenomeLoc in Alignment context is null");
|
|
||||||
if ( skippedBases < 0 ) throw new StingException("BUG: skippedBases is -1 in Alignment context");
|
|
||||||
|
|
||||||
this.loc = loc;
|
|
||||||
this.basePileup = new ReadBackedPileupImpl(loc, reads, offsets);
|
|
||||||
this.skippedBases = skippedBases;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AlignmentContext(GenomeLoc loc, ReadBackedPileup basePileup) {
|
public AlignmentContext(GenomeLoc loc, ReadBackedPileup basePileup) {
|
||||||
this(loc, basePileup, 0);
|
this(loc, basePileup, 0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlignmentContext(GenomeLoc loc, ReadBackedPileup basePileup, long skippedBases ) {
|
public AlignmentContext(GenomeLoc loc, ReadBackedPileup basePileup, boolean hasPileupBeenDownsampled) {
|
||||||
|
this(loc, basePileup, 0, hasPileupBeenDownsampled);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AlignmentContext(GenomeLoc loc, ReadBackedPileup basePileup, long skippedBases) {
|
||||||
|
this(loc, basePileup, skippedBases, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AlignmentContext(GenomeLoc loc, ReadBackedPileup basePileup, long skippedBases,boolean hasPileupBeenDownsampled ) {
|
||||||
if ( loc == null ) throw new StingException("BUG: GenomeLoc in Alignment context is null");
|
if ( loc == null ) throw new StingException("BUG: GenomeLoc in Alignment context is null");
|
||||||
if ( basePileup == null ) throw new StingException("BUG: ReadBackedPileup in Alignment context is null");
|
if ( basePileup == null ) throw new StingException("BUG: ReadBackedPileup in Alignment context is null");
|
||||||
if ( skippedBases < 0 ) throw new StingException("BUG: skippedBases is -1 in Alignment context");
|
if ( skippedBases < 0 ) throw new StingException("BUG: skippedBases is -1 in Alignment context");
|
||||||
|
|
@ -94,6 +74,7 @@ public class AlignmentContext {
|
||||||
this.loc = loc;
|
this.loc = loc;
|
||||||
this.basePileup = basePileup;
|
this.basePileup = basePileup;
|
||||||
this.skippedBases = skippedBases;
|
this.skippedBases = skippedBases;
|
||||||
|
this.hasPileupBeenDownsampled = hasPileupBeenDownsampled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns base pileup over the current genomic location. Deprectated. Use getBasePileup() to make your intentions
|
/** Returns base pileup over the current genomic location. Deprectated. Use getBasePileup() to make your intentions
|
||||||
|
|
@ -136,6 +117,12 @@ public class AlignmentContext {
|
||||||
*/
|
*/
|
||||||
public boolean hasExtendedEventPileup() { return basePileup instanceof ReadBackedExtendedEventPileup; }
|
public boolean hasExtendedEventPileup() { return basePileup instanceof ReadBackedExtendedEventPileup; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if any reads have been filtered out of the pileup due to excess DoC.
|
||||||
|
* @return True if reads have been filtered out. False otherwise.
|
||||||
|
*/
|
||||||
|
public boolean hasPileupBeenDownsampled() { return hasPileupBeenDownsampled; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get all of the reads within this context
|
* get all of the reads within this context
|
||||||
*
|
*
|
||||||
|
|
@ -178,6 +165,7 @@ public class AlignmentContext {
|
||||||
|
|
||||||
public void downsampleToCoverage(int coverage) {
|
public void downsampleToCoverage(int coverage) {
|
||||||
basePileup = basePileup.getDownsampledPileup(coverage);
|
basePileup = basePileup.getDownsampledPileup(coverage);
|
||||||
|
hasPileupBeenDownsampled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import org.broadinstitute.sting.gatk.iterators.GenomeLocusIterator;
|
||||||
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
|
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
|
||||||
import org.broadinstitute.sting.utils.GenomeLoc;
|
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||||
import net.sf.samtools.SAMRecord;
|
import net.sf.samtools.SAMRecord;
|
||||||
|
import org.broadinstitute.sting.utils.pileup.ReadBackedPileupImpl;
|
||||||
/**
|
/**
|
||||||
* User: hanna
|
* User: hanna
|
||||||
* Date: May 13, 2009
|
* Date: May 13, 2009
|
||||||
|
|
@ -96,6 +97,6 @@ public class AllLocusView extends LocusView {
|
||||||
* @return empty context.
|
* @return empty context.
|
||||||
*/
|
*/
|
||||||
private AlignmentContext createEmptyLocus( GenomeLoc site ) {
|
private AlignmentContext createEmptyLocus( GenomeLoc site ) {
|
||||||
return new AlignmentContext(site, new ArrayList<SAMRecord>(), new ArrayList<Integer>());
|
return new AlignmentContext(site,new ReadBackedPileupImpl(site,new ArrayList<SAMRecord>(), new ArrayList<Integer>()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -358,10 +358,11 @@ public class LocusIteratorByState extends LocusIterator {
|
||||||
// are associated with the *previous* reference base
|
// are associated with the *previous* reference base
|
||||||
GenomeLoc loc = GenomeLocParser.incPos(our1stState.getLocation(),-1);
|
GenomeLoc loc = GenomeLocParser.incPos(our1stState.getLocation(),-1);
|
||||||
|
|
||||||
|
boolean hasBeenSampled = false;
|
||||||
for(String sampleName: sampleNames) {
|
for(String sampleName: sampleNames) {
|
||||||
Iterator<SAMRecordState> iterator = readStates.iteratorForSample(sampleName);
|
Iterator<SAMRecordState> iterator = readStates.iteratorForSample(sampleName);
|
||||||
ArrayList<ExtendedEventPileupElement> indelPile = new ArrayList<ExtendedEventPileupElement>(readStates.size());
|
ArrayList<ExtendedEventPileupElement> indelPile = new ArrayList<ExtendedEventPileupElement>(readStates.size());
|
||||||
boolean hasBeenSampled = loc.getStart() <= readStates.readStatesBySample.get(sampleName).getDownsamplingExtent();
|
hasBeenSampled |= loc.getStart() <= readStates.readStatesBySample.get(sampleName).getDownsamplingExtent();
|
||||||
|
|
||||||
size = 0;
|
size = 0;
|
||||||
nDeletions = 0;
|
nDeletions = 0;
|
||||||
|
|
@ -414,21 +415,22 @@ public class LocusIteratorByState extends LocusIterator {
|
||||||
nMQ0Reads++;
|
nMQ0Reads++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( indelPile.size() != 0 ) fullExtendedEventPileup.put(sampleName,new ReadBackedExtendedEventPileupImpl(loc,indelPile,size,maxDeletionLength,nInsertions,nDeletions,nMQ0Reads,hasBeenSampled));
|
if( indelPile.size() != 0 ) fullExtendedEventPileup.put(sampleName,new ReadBackedExtendedEventPileupImpl(loc,indelPile,size,maxDeletionLength,nInsertions,nDeletions,nMQ0Reads));
|
||||||
}
|
}
|
||||||
hasExtendedEvents = false; // we are done with extended events prior to current ref base
|
hasExtendedEvents = false; // we are done with extended events prior to current ref base
|
||||||
// System.out.println("Indel(s) at "+loc);
|
// System.out.println("Indel(s) at "+loc);
|
||||||
// for ( ExtendedEventPileupElement pe : indelPile ) { if ( pe.isIndel() ) System.out.println(" "+pe.toString()); }
|
// for ( ExtendedEventPileupElement pe : indelPile ) { if ( pe.isIndel() ) System.out.println(" "+pe.toString()); }
|
||||||
nextAlignmentContext = new AlignmentContext(loc, new ReadBackedExtendedEventPileupImpl(loc, fullExtendedEventPileup));
|
nextAlignmentContext = new AlignmentContext(loc, new ReadBackedExtendedEventPileupImpl(loc, fullExtendedEventPileup), hasBeenSampled);
|
||||||
} else {
|
} else {
|
||||||
GenomeLoc location = getLocation();
|
GenomeLoc location = getLocation();
|
||||||
Map<String,ReadBackedPileupImpl> fullPileup = new HashMap<String,ReadBackedPileupImpl>();
|
Map<String,ReadBackedPileupImpl> fullPileup = new HashMap<String,ReadBackedPileupImpl>();
|
||||||
|
|
||||||
// todo -- performance problem -- should be lazy, really
|
// todo -- performance problem -- should be lazy, really
|
||||||
|
boolean hasBeenSampled = false;
|
||||||
for(String sampleName: sampleNames) {
|
for(String sampleName: sampleNames) {
|
||||||
Iterator<SAMRecordState> iterator = readStates.iteratorForSample(sampleName);
|
Iterator<SAMRecordState> iterator = readStates.iteratorForSample(sampleName);
|
||||||
ArrayList<PileupElement> pile = new ArrayList<PileupElement>(readStates.size());
|
ArrayList<PileupElement> pile = new ArrayList<PileupElement>(readStates.size());
|
||||||
boolean hasBeenSampled = location.getStart() <= readStates.readStatesBySample.get(sampleName).getDownsamplingExtent();
|
hasBeenSampled |= location.getStart() <= readStates.readStatesBySample.get(sampleName).getDownsamplingExtent();
|
||||||
|
|
||||||
size = 0;
|
size = 0;
|
||||||
nDeletions = 0;
|
nDeletions = 0;
|
||||||
|
|
@ -458,12 +460,12 @@ public class LocusIteratorByState extends LocusIterator {
|
||||||
nMQ0Reads++;
|
nMQ0Reads++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( pile.size() != 0 ) fullPileup.put(sampleName,new ReadBackedPileupImpl(location,pile,size,nDeletions,nMQ0Reads,hasBeenSampled));
|
if( pile.size() != 0 ) fullPileup.put(sampleName,new ReadBackedPileupImpl(location,pile,size,nDeletions,nMQ0Reads));
|
||||||
}
|
}
|
||||||
|
|
||||||
updateReadStates(); // critical - must be called after we get the current state offsets and location
|
updateReadStates(); // critical - must be called after we get the current state offsets and location
|
||||||
// if we got reads with non-D/N over the current position, we are done
|
// if we got reads with non-D/N over the current position, we are done
|
||||||
if ( !fullPileup.isEmpty() ) nextAlignmentContext = new AlignmentContext(location, new ReadBackedPileupImpl(location,fullPileup));
|
if ( !fullPileup.isEmpty() ) nextAlignmentContext = new AlignmentContext(location, new ReadBackedPileupImpl(location,fullPileup),hasBeenSampled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,11 @@ import org.broadinstitute.sting.gatk.walkers.genotyper.UnifiedArgumentCollection
|
||||||
import org.broadinstitute.sting.gatk.walkers.genotyper.UnifiedGenotyperEngine;
|
import org.broadinstitute.sting.gatk.walkers.genotyper.UnifiedGenotyperEngine;
|
||||||
import org.broadinstitute.sting.utils.BaseUtils;
|
import org.broadinstitute.sting.utils.BaseUtils;
|
||||||
import org.broadinstitute.sting.utils.MathUtils;
|
import org.broadinstitute.sting.utils.MathUtils;
|
||||||
|
import org.broadinstitute.sting.utils.pileup.ReadBackedPileupImpl;
|
||||||
import org.broadinstitute.sting.commandline.Argument;
|
import org.broadinstitute.sting.commandline.Argument;
|
||||||
import org.broadinstitute.sting.commandline.Output;
|
import org.broadinstitute.sting.commandline.Output;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
@ -114,7 +116,7 @@ public class SnpCallRateByCoverageWalker extends LocusWalker<List<String>, Strin
|
||||||
List<SAMRecord> sub_reads = MathUtils.sliceListByIndices(subset_indices, reads);
|
List<SAMRecord> sub_reads = MathUtils.sliceListByIndices(subset_indices, reads);
|
||||||
List<Integer> sub_offsets = MathUtils.sliceListByIndices(subset_indices, offsets);
|
List<Integer> sub_offsets = MathUtils.sliceListByIndices(subset_indices, offsets);
|
||||||
|
|
||||||
AlignmentContext subContext = new AlignmentContext(context.getLocation(), sub_reads, sub_offsets);
|
AlignmentContext subContext = new AlignmentContext(context.getLocation(), new ReadBackedPileupImpl(context.getLocation(),sub_reads, sub_offsets));
|
||||||
|
|
||||||
VariantCallContext calls = UG.runGenotyper(tracker, ref, subContext);
|
VariantCallContext calls = UG.runGenotyper(tracker, ref, subContext);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,6 @@ public abstract class AbstractReadBackedPileup<RBP extends AbstractReadBackedPil
|
||||||
protected int size = 0; // cached value of the size of the pileup
|
protected int size = 0; // cached value of the size of the pileup
|
||||||
protected int nDeletions = 0; // cached value of the number of deletions
|
protected int nDeletions = 0; // cached value of the number of deletions
|
||||||
protected int nMQ0Reads = 0; // cached value of the number of MQ0 reads
|
protected int nMQ0Reads = 0; // cached value of the number of MQ0 reads
|
||||||
protected boolean hasPileupBeenDownsampled;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new version of a read backed pileup at loc, using the reads and their corresponding
|
* Create a new version of a read backed pileup at loc, using the reads and their corresponding
|
||||||
|
|
@ -96,7 +95,7 @@ public abstract class AbstractReadBackedPileup<RBP extends AbstractReadBackedPil
|
||||||
* @param loc
|
* @param loc
|
||||||
* @param pileup
|
* @param pileup
|
||||||
*/
|
*/
|
||||||
public AbstractReadBackedPileup(GenomeLoc loc, List<PE> pileup, int size, int nDeletions, int nMQ0Reads, boolean hasPileupBeenDownsampled ) {
|
public AbstractReadBackedPileup(GenomeLoc loc, List<PE> pileup, int size, int nDeletions, int nMQ0Reads) {
|
||||||
if ( loc == null ) throw new StingException("Illegal null genomeloc in UnifiedReadBackedPileup");
|
if ( loc == null ) throw new StingException("Illegal null genomeloc in UnifiedReadBackedPileup");
|
||||||
if ( pileup == null ) throw new StingException("Illegal null pileup in UnifiedReadBackedPileup");
|
if ( pileup == null ) throw new StingException("Illegal null pileup in UnifiedReadBackedPileup");
|
||||||
|
|
||||||
|
|
@ -105,7 +104,6 @@ public abstract class AbstractReadBackedPileup<RBP extends AbstractReadBackedPil
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.nDeletions = nDeletions;
|
this.nDeletions = nDeletions;
|
||||||
this.nMQ0Reads = nMQ0Reads;
|
this.nMQ0Reads = nMQ0Reads;
|
||||||
this.hasPileupBeenDownsampled = hasPileupBeenDownsampled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -150,7 +148,6 @@ public abstract class AbstractReadBackedPileup<RBP extends AbstractReadBackedPil
|
||||||
size += pileup.size();
|
size += pileup.size();
|
||||||
nDeletions += pileup.getNumberOfDeletions();
|
nDeletions += pileup.getNumberOfDeletions();
|
||||||
nMQ0Reads += pileup.getNumberOfMappingQualityZeroReads();
|
nMQ0Reads += pileup.getNumberOfMappingQualityZeroReads();
|
||||||
hasPileupBeenDownsampled |= pileup.hasPileupBeenDownsampled();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -675,11 +672,6 @@ public abstract class AbstractReadBackedPileup<RBP extends AbstractReadBackedPil
|
||||||
return loc;
|
return loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasPileupBeenDownsampled() {
|
|
||||||
return hasPileupBeenDownsampled;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Somewhat expensive routine that returns true if any base in the pileup has secondary bases annotated
|
* Somewhat expensive routine that returns true if any base in the pileup has secondary bases annotated
|
||||||
* @return
|
* @return
|
||||||
|
|
|
||||||
|
|
@ -34,10 +34,6 @@ import net.sf.samtools.SAMRecord;
|
||||||
public class ReadBackedExtendedEventPileupImpl extends AbstractReadBackedPileup<ReadBackedExtendedEventPileupImpl,ExtendedEventPileupElement> implements ReadBackedExtendedEventPileup {
|
public class ReadBackedExtendedEventPileupImpl extends AbstractReadBackedPileup<ReadBackedExtendedEventPileupImpl,ExtendedEventPileupElement> implements ReadBackedExtendedEventPileup {
|
||||||
private int nInsertions;
|
private int nInsertions;
|
||||||
private int maxDeletionLength; // cached value of the length of the longest deletion observed at the site
|
private int maxDeletionLength; // cached value of the length of the longest deletion observed at the site
|
||||||
/**
|
|
||||||
* True if this pileup has been downsampled due to excessive coverage depth. False otherwise.
|
|
||||||
*/
|
|
||||||
private boolean hasBeenDownsampled;
|
|
||||||
|
|
||||||
public ReadBackedExtendedEventPileupImpl(GenomeLoc loc, List<ExtendedEventPileupElement> pileupElements) {
|
public ReadBackedExtendedEventPileupImpl(GenomeLoc loc, List<ExtendedEventPileupElement> pileupElements) {
|
||||||
super(loc,pileupElements);
|
super(loc,pileupElements);
|
||||||
|
|
@ -53,8 +49,8 @@ public class ReadBackedExtendedEventPileupImpl extends AbstractReadBackedPileup<
|
||||||
* @param pileup
|
* @param pileup
|
||||||
*/
|
*/
|
||||||
public ReadBackedExtendedEventPileupImpl(GenomeLoc loc, List<ExtendedEventPileupElement> pileup, int size,
|
public ReadBackedExtendedEventPileupImpl(GenomeLoc loc, List<ExtendedEventPileupElement> pileup, int size,
|
||||||
int maxDeletionLength, int nInsertions, int nDeletions, int nMQ0Reads, boolean hasPileupBeenDownsampled ) {
|
int maxDeletionLength, int nInsertions, int nDeletions, int nMQ0Reads) {
|
||||||
super(loc,pileup,size,nDeletions,nMQ0Reads,hasPileupBeenDownsampled);
|
super(loc,pileup,size,nDeletions,nMQ0Reads);
|
||||||
this.maxDeletionLength = maxDeletionLength;
|
this.maxDeletionLength = maxDeletionLength;
|
||||||
this.nInsertions = nInsertions;
|
this.nInsertions = nInsertions;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -115,12 +115,6 @@ public interface ReadBackedPileup extends Iterable<PileupElement> {
|
||||||
*/
|
*/
|
||||||
public ReadBackedPileup getDownsampledPileup(int desiredCoverage);
|
public ReadBackedPileup getDownsampledPileup(int desiredCoverage);
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if any reads have been filtered out of the pileup due to excess DoC.
|
|
||||||
* @return True if reads have been filtered out. False otherwise.
|
|
||||||
*/
|
|
||||||
public boolean hasPileupBeenDownsampled();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a collection of all the read groups represented in this pileup.
|
* Gets a collection of all the read groups represented in this pileup.
|
||||||
* @return A collection of all the read group ids represented in this pileup.
|
* @return A collection of all the read group ids represented in this pileup.
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,8 @@ public class ReadBackedPileupImpl extends AbstractReadBackedPileup<ReadBackedPil
|
||||||
* @param loc
|
* @param loc
|
||||||
* @param pileup
|
* @param pileup
|
||||||
*/
|
*/
|
||||||
public ReadBackedPileupImpl(GenomeLoc loc, List<PileupElement> pileup, int size, int nDeletions, int nMQ0Reads, boolean hasPileupBeenDownsampled ) {
|
public ReadBackedPileupImpl(GenomeLoc loc, List<PileupElement> pileup, int size, int nDeletions, int nMQ0Reads) {
|
||||||
super(loc,pileup,size,nDeletions,nMQ0Reads,hasPileupBeenDownsampled);
|
super(loc,pileup,size,nDeletions,nMQ0Reads);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ReadBackedPileupImpl(GenomeLoc loc, PileupElementTracker<PileupElement> tracker) {
|
protected ReadBackedPileupImpl(GenomeLoc loc, PileupElementTracker<PileupElement> tracker) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue