From e29e8e52b9be731a065c67cf255f116be7715e7d Mon Sep 17 00:00:00 2001 From: hanna Date: Wed, 23 Dec 2009 00:48:06 +0000 Subject: [PATCH] Multithreading support for the unified genotyper. Tests on a 10Mbase region on pilot 1 show a 6.8x improvement when running 8 ways parallel. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2430 348d0f76-0448-11de-a6fe-93d51630548a --- .../EmpiricalSubstitutionProbabilities.java | 12 +++--- .../walkers/genotyper/UnifiedGenotyper.java | 37 ++++++++++--------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/EmpiricalSubstitutionProbabilities.java b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/EmpiricalSubstitutionProbabilities.java index f7e56c7de..4045e2ed4 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/EmpiricalSubstitutionProbabilities.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/EmpiricalSubstitutionProbabilities.java @@ -48,17 +48,17 @@ public class EmpiricalSubstitutionProbabilities extends FourBaseProbabilities { } } - private static SAMRecord lastReadForPL = null; - private static SequencerPlatform plOfLastRead = null; + private static ThreadLocal lastReadForPL = new ThreadLocal(); + private static ThreadLocal plOfLastRead = new ThreadLocal(); public static SequencerPlatform getReadSequencerPlatform( SAMRecord read ) { - if ( lastReadForPL != read ) { - lastReadForPL = read; + if ( lastReadForPL.get() != read ) { + lastReadForPL.set(read); SAMReadGroupRecord readGroup = read.getReadGroup(); final String platformName = readGroup == null ? null : readGroup.getPlatform(); - plOfLastRead = standardizeSequencerPlatform(platformName); + plOfLastRead.set(standardizeSequencerPlatform(platformName)); } - return plOfLastRead; + return plOfLastRead.get(); } public int getReadSequencerPlatformIndex( SAMRecord read ) { diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java index 232d67dcb..626ff2f65 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java @@ -57,7 +57,7 @@ public class UnifiedGenotyper extends LocusWalker gcm = new ThreadLocal(); // samples in input private Set samples; @@ -75,7 +75,7 @@ public class UnifiedGenotyper extends LocusWalker> map(RefMetaDataTracker tracker, ReferenceContext refContext, AlignmentContext rawContext) { + GenotypeWriterFactory.GENOTYPE_FORMAT format = GenotypeWriterFactory.GENOTYPE_FORMAT.VCF; + if(writer != null) { + if(writer instanceof VCFGenotypeWriter) + format = GenotypeWriterFactory.GENOTYPE_FORMAT.VCF; + else if(writer instanceof GLFGenotypeWriter) + format = GenotypeWriterFactory.GENOTYPE_FORMAT.GLF; + else if(writer instanceof GeliGenotypeWriter) + format = GenotypeWriterFactory.GENOTYPE_FORMAT.GELI; + else + throw new StingException("Unsupported genotype format: " + writer.getClass().getName()); + } + + if(gcm.get() == null) + gcm.set(GenotypeCalculationModelFactory.makeGenotypeCalculation(samples, logger, UAC, format)); + char ref = Character.toUpperCase(refContext.getBase()); if ( !BaseUtils.isRegularBase(ref) ) return null; @@ -218,7 +219,7 @@ public class UnifiedGenotyper extends LocusWalker> call = gcm.calculateGenotype(tracker, ref, rawContext.getLocation(), stratifiedContexts, priors); + Pair> call = gcm.get().calculateGenotype(tracker, ref, rawContext.getLocation(), stratifiedContexts, priors); // annotate the call, if possible if ( call != null && call.first != null && call.first instanceof ArbitraryFieldsBacked ) { @@ -280,7 +281,7 @@ public class UnifiedGenotyper extends LocusWalker