Added an argument to RR to allow polyploid consensus creation (by default it is turned off). This will eventually be replaced by the known SNPs track trigger.

This commit is contained in:
Eric Banks 2012-09-28 11:44:25 -04:00
parent e740977994
commit 2df5be702c
4 changed files with 36 additions and 19 deletions

View File

@ -54,11 +54,12 @@ public class MultiSampleCompressor implements Compressor {
final double minIndelProportionToTriggerVariant, final double minIndelProportionToTriggerVariant,
final int minBaseQual, final int minBaseQual,
final ReduceReads.DownsampleStrategy downsampleStrategy, final ReduceReads.DownsampleStrategy downsampleStrategy,
final int nContigs) { final int nContigs,
final boolean allowPolyploidReduction) {
for ( String name : SampleUtils.getSAMFileSamples(header) ) { for ( String name : SampleUtils.getSAMFileSamples(header) ) {
compressorsPerSample.put(name, compressorsPerSample.put(name,
new SingleSampleCompressor(contextSize, downsampleCoverage, new SingleSampleCompressor(contextSize, downsampleCoverage,
minMappingQuality, minAltProportionToTriggerVariant, minIndelProportionToTriggerVariant, minBaseQual, downsampleStrategy, nContigs)); minMappingQuality, minAltProportionToTriggerVariant, minIndelProportionToTriggerVariant, minBaseQual, downsampleStrategy, nContigs, allowPolyploidReduction));
} }
} }

View File

@ -117,6 +117,12 @@ public class ReduceReads extends ReadWalker<LinkedList<GATKSAMRecord>, ReduceRea
@Argument(fullName = "minimum_tail_qualities", shortName = "mintail", doc = "", required = false) @Argument(fullName = "minimum_tail_qualities", shortName = "mintail", doc = "", required = false)
private byte minTailQuality = 2; private byte minTailQuality = 2;
/**
* Allow the experimental polyploid-based reduction capabilities of this tool
*/
@Argument(fullName = "allow_polyploid_reduction", shortName = "polyploid", doc = "", required = false)
private boolean USE_POLYPLOID_REDUCTION = false;
/** /**
* Do not simplify read (strip away all extra information of the read -- anything other than bases, quals * Do not simplify read (strip away all extra information of the read -- anything other than bases, quals
* and read group). * and read group).
@ -323,7 +329,7 @@ public class ReduceReads extends ReadWalker<LinkedList<GATKSAMRecord>, ReduceRea
*/ */
@Override @Override
public ReduceReadsStash reduceInit() { public ReduceReadsStash reduceInit() {
return new ReduceReadsStash(new MultiSampleCompressor(getToolkit().getSAMFileHeader(), contextSize, downsampleCoverage, minMappingQuality, minAltProportionToTriggerVariant, minIndelProportionToTriggerVariant, minBaseQual, downsampleStrategy, nContigs)); return new ReduceReadsStash(new MultiSampleCompressor(getToolkit().getSAMFileHeader(), contextSize, downsampleCoverage, minMappingQuality, minAltProportionToTriggerVariant, minIndelProportionToTriggerVariant, minBaseQual, downsampleStrategy, nContigs, USE_POLYPLOID_REDUCTION));
} }
/** /**

View File

@ -19,6 +19,7 @@ public class SingleSampleCompressor implements Compressor {
final private int minBaseQual; final private int minBaseQual;
final private ReduceReads.DownsampleStrategy downsampleStrategy; final private ReduceReads.DownsampleStrategy downsampleStrategy;
final private int nContigs; final private int nContigs;
final private boolean allowPolyploidReduction;
private SlidingWindow slidingWindow; private SlidingWindow slidingWindow;
private int slidingWindowCounter; private int slidingWindowCounter;
@ -31,7 +32,8 @@ public class SingleSampleCompressor implements Compressor {
final double minIndelProportionToTriggerVariant, final double minIndelProportionToTriggerVariant,
final int minBaseQual, final int minBaseQual,
final ReduceReads.DownsampleStrategy downsampleStrategy, final ReduceReads.DownsampleStrategy downsampleStrategy,
final int nContigs) { final int nContigs,
final boolean allowPolyploidReduction) {
this.contextSize = contextSize; this.contextSize = contextSize;
this.downsampleCoverage = downsampleCoverage; this.downsampleCoverage = downsampleCoverage;
this.minMappingQuality = minMappingQuality; this.minMappingQuality = minMappingQuality;
@ -41,6 +43,7 @@ public class SingleSampleCompressor implements Compressor {
this.minBaseQual = minBaseQual; this.minBaseQual = minBaseQual;
this.downsampleStrategy = downsampleStrategy; this.downsampleStrategy = downsampleStrategy;
this.nContigs = nContigs; this.nContigs = nContigs;
this.allowPolyploidReduction = allowPolyploidReduction;
} }
/** /**
@ -62,7 +65,7 @@ public class SingleSampleCompressor implements Compressor {
} }
if ( slidingWindow == null) { // this is the first read if ( slidingWindow == null) { // this is the first read
slidingWindow = new SlidingWindow(read.getReferenceName(), read.getReferenceIndex(), contextSize, read.getHeader(), read.getReadGroup(), slidingWindowCounter, minAltProportionToTriggerVariant, minIndelProportionToTriggerVariant, minBaseQual, minMappingQuality, downsampleCoverage, downsampleStrategy, read.hasBaseIndelQualities(), nContigs); slidingWindow = new SlidingWindow(read.getReferenceName(), read.getReferenceIndex(), contextSize, read.getHeader(), read.getReadGroup(), slidingWindowCounter, minAltProportionToTriggerVariant, minIndelProportionToTriggerVariant, minBaseQual, minMappingQuality, downsampleCoverage, downsampleStrategy, read.hasBaseIndelQualities(), nContigs, allowPolyploidReduction);
slidingWindowCounter++; slidingWindowCounter++;
} }

View File

@ -55,6 +55,8 @@ public class SlidingWindow {
private final int nContigs; private final int nContigs;
private boolean allowPolyploidReduction;
/** /**
* The types of synthetic reads to use in the finalizeAndAdd method * The types of synthetic reads to use in the finalizeAndAdd method
*/ */
@ -85,7 +87,7 @@ public class SlidingWindow {
} }
public SlidingWindow(String contig, int contigIndex, int contextSize, SAMFileHeader samHeader, GATKSAMReadGroupRecord readGroupAttribute, int windowNumber, final double minAltProportionToTriggerVariant, final double minIndelProportionToTriggerVariant, int minBaseQual, int minMappingQuality, int downsampleCoverage, final ReduceReads.DownsampleStrategy downsampleStrategy, boolean hasIndelQualities, int nContigs) { public SlidingWindow(String contig, int contigIndex, int contextSize, SAMFileHeader samHeader, GATKSAMReadGroupRecord readGroupAttribute, int windowNumber, final double minAltProportionToTriggerVariant, final double minIndelProportionToTriggerVariant, int minBaseQual, int minMappingQuality, int downsampleCoverage, final ReduceReads.DownsampleStrategy downsampleStrategy, boolean hasIndelQualities, int nContigs, boolean allowPolyploidReduction) {
this.contextSize = contextSize; this.contextSize = contextSize;
this.downsampleCoverage = downsampleCoverage; this.downsampleCoverage = downsampleCoverage;
@ -114,6 +116,8 @@ public class SlidingWindow {
this.downsampleStrategy = downsampleStrategy; this.downsampleStrategy = downsampleStrategy;
this.hasIndelQualities = hasIndelQualities; this.hasIndelQualities = hasIndelQualities;
this.nContigs = nContigs; this.nContigs = nContigs;
this.allowPolyploidReduction = allowPolyploidReduction;
} }
/** /**
@ -485,23 +489,26 @@ public class SlidingWindow {
boolean canCompress = true; boolean canCompress = true;
boolean foundEvent = false; boolean foundEvent = false;
Object[] header = windowHeader.toArray(); Object[] header = windowHeader.toArray();
for (int i = start; i<=stop; i++) {
nHaplotypes = ((HeaderElement) header[i]).getNumberOfHaplotypes(MIN_ALT_BASE_PROPORTION_TO_TRIGGER_VARIANT);
if (nHaplotypes > nContigs) {
canCompress = false;
break;
}
// guarantees that there is only 1 site in the variant region that needs more than one haplotype if ( allowPolyploidReduction ) { // foundEvent will remain false if we don't allow polyploid reduction
if (nHaplotypes > 1) { for (int i = start; i<=stop; i++) {
if (!foundEvent) { nHaplotypes = ((HeaderElement) header[i]).getNumberOfHaplotypes(MIN_ALT_BASE_PROPORTION_TO_TRIGGER_VARIANT);
foundEvent = true; if (nHaplotypes > nContigs) {
hetRefPosition = i;
}
else {
canCompress = false; canCompress = false;
break; break;
} }
// guarantees that there is only 1 site in the variant region that needs more than one haplotype
if (nHaplotypes > 1) {
if (!foundEvent) {
foundEvent = true;
hetRefPosition = i;
}
else {
canCompress = false;
break;
}
}
} }
} }