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