diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/SingleSampleGenotyper.java b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/SingleSampleGenotyper.java index dbd58589a..937d48840 100644 --- a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/SingleSampleGenotyper.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/SingleSampleGenotyper.java @@ -7,6 +7,7 @@ import org.broadinstitute.sting.gatk.filters.ZeroMappingQualityReadFilter; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.LocusWalker; import org.broadinstitute.sting.gatk.walkers.ReadFilters; +import org.broadinstitute.sting.gatk.walkers.TreeReducible; import org.broadinstitute.sting.utils.BaseUtils; import org.broadinstitute.sting.utils.ReadBackedPileup; import org.broadinstitute.sting.utils.cmdLine.Argument; @@ -16,7 +17,7 @@ import org.broadinstitute.sting.utils.genotype.GenotypeWriterFactory; import java.io.File; @ReadFilters(ZeroMappingQualityReadFilter.class) -public class SingleSampleGenotyper extends LocusWalker { +public class SingleSampleGenotyper extends LocusWalker implements TreeReducible { // Control output settings @Argument(fullName = "variants_out", shortName = "varout", doc = "File to which variants should be written", required = false) public File VARIANTS_FILE = null; @@ -47,17 +48,16 @@ public class SingleSampleGenotyper extends LocusWalker= LOD_THRESHOLD) { sum.nConfidentCalls++; //System.out.printf("Call %s%n", call); - sum.writer.addGenotypeCall(call); + genotypeWriter.addGenotypeCall(call); } else sum.nNonConfidentCalls++; } return sum; } + /** + * Combine adjacent call results. + * + * @param lhs first set of partial call results from genotyper; guaranteed to have come from 'earlier' in genome. + * @param rhs second set of partial call results from genotyper; guaranteed to have come from 'later' in genome. + * + * @return combined call results. + */ + public CallResult treeReduce( CallResult lhs, CallResult rhs ) { + CallResult combined = new CallResult(); + combined.nCalledBases = lhs.nCalledBases + rhs.nCalledBases; + combined.nConfidentCalls = lhs.nConfidentCalls + rhs.nConfidentCalls; + combined.nNonConfidentCalls = lhs.nNonConfidentCalls + rhs.nNonConfidentCalls; + return combined; + } + /** Close the variant file. */ public void onTraversalDone(CallResult sum) { - sum.writer.close(); + // If the VARIANTS_FILE is null, the GATK is managing the output stream. Close the file. + if ( VARIANTS_FILE == null ) + genotypeWriter.close(); } }