From 8a503c86b6ff0147b0396899f3548fe73d2e0471 Mon Sep 17 00:00:00 2001 From: hanna Date: Mon, 5 Oct 2009 18:56:16 +0000 Subject: [PATCH] Code supporting SSG proof-of-concept shared memory parallelism. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1765 348d0f76-0448-11de-a6fe-93d51630548a --- .../genotyper/SingleSampleGenotyper.java | 44 +++++++++++++------ 1 file changed, 31 insertions(+), 13 deletions(-) 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(); } }