Now implements TreeReducible

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2427 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
ebanks 2009-12-22 17:52:51 +00:00
parent 66eeb4a552
commit 03bf75e335
1 changed files with 5 additions and 10 deletions

View File

@ -48,7 +48,7 @@ import java.util.*;
*/ */
@Reference(window=@Window(start=-20,stop=20)) @Reference(window=@Window(start=-20,stop=20))
@ReadFilters({ZeroMappingQualityReadFilter.class,MappingQualityReadFilter.class,BadMateReadFilter.class}) @ReadFilters({ZeroMappingQualityReadFilter.class,MappingQualityReadFilter.class,BadMateReadFilter.class})
public class UnifiedGenotyper extends LocusWalker<Pair<VariationCall, List<Genotype>>, Integer> { public class UnifiedGenotyper extends LocusWalker<Pair<VariationCall, List<Genotype>>, Integer> implements TreeReducible<Integer> {
@ArgumentCollection private UnifiedArgumentCollection UAC = new UnifiedArgumentCollection(); @ArgumentCollection private UnifiedArgumentCollection UAC = new UnifiedArgumentCollection();
@ -62,8 +62,6 @@ public class UnifiedGenotyper extends LocusWalker<Pair<VariationCall, List<Genot
// samples in input // samples in input
private Set<String> samples; private Set<String> samples;
// keep track of some metrics about our calls
private CallMetrics callsMetrics;
/** Enable deletions in the pileup **/ /** Enable deletions in the pileup **/
public boolean includeReadsWithDeletionAtLoci() { return true; } public boolean includeReadsWithDeletionAtLoci() { return true; }
@ -144,8 +142,6 @@ public class UnifiedGenotyper extends LocusWalker<Pair<VariationCall, List<Genot
// initialize the header // initialize the header
GenotypeWriterFactory.writeHeader(writer, GenomeAnalysisEngine.instance.getSAMFileHeader(), samples, headerInfo); GenotypeWriterFactory.writeHeader(writer, GenomeAnalysisEngine.instance.getSAMFileHeader(), samples, headerInfo);
callsMetrics = new CallMetrics();
} }
private Set<VCFHeaderLine> getHeaderInfo() { private Set<VCFHeaderLine> getHeaderInfo() {
@ -254,22 +250,21 @@ public class UnifiedGenotyper extends LocusWalker<Pair<VariationCall, List<Genot
public Integer reduceInit() { return 0; } public Integer reduceInit() { return 0; }
public Integer treeReduce(Integer lhs, Integer rhs) {
return lhs + rhs;
}
public Integer reduce(Pair<VariationCall, List<Genotype>> value, Integer sum) { public Integer reduce(Pair<VariationCall, List<Genotype>> value, Integer sum) {
// can't call the locus because of no coverage // can't call the locus because of no coverage
if ( value == null ) if ( value == null )
return sum; return sum;
callsMetrics.nCalledBases++;
// can't make a confident variant call here // can't make a confident variant call here
if ( value.second == null || if ( value.second == null ||
(UAC.genotypeModel != GenotypeCalculationModel.Model.POOLED && value.second.size() == 0) ) { (UAC.genotypeModel != GenotypeCalculationModel.Model.POOLED && value.second.size() == 0) ) {
callsMetrics.nNonConfidentCalls++;
return sum; return sum;
} }
callsMetrics.nConfidentCalls++;
// if we have a single-sample call (single sample from PointEstimate model returns no VariationCall data) // if we have a single-sample call (single sample from PointEstimate model returns no VariationCall data)
if ( value.first == null || (!writer.supportsMultiSample() && samples.size() <= 1) ) { if ( value.first == null || (!writer.supportsMultiSample() && samples.size() <= 1) ) {
writer.addGenotypeCall(value.second.get(0)); writer.addGenotypeCall(value.second.get(0));