From 841d25cc4460806523ad7664e151b166cb8b83d6 Mon Sep 17 00:00:00 2001 From: ebanks Date: Wed, 30 Sep 2009 19:55:49 +0000 Subject: [PATCH] Added ability to set the priors after construction (and requiring a flushing of the likelihoods cache) git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1749 348d0f76-0448-11de-a6fe-93d51630548a --- ...iricalSubstitutionGenotypeLikelihoods.java | 2 ++ .../genotyper/GenotypeLikelihoods.java | 19 ++++++++++++++++++- .../ThreeStateErrorGenotypeLikelihoods.java | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/EmpiricalSubstitutionGenotypeLikelihoods.java b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/EmpiricalSubstitutionGenotypeLikelihoods.java index 2b681a440..ae9c0a5bc 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/EmpiricalSubstitutionGenotypeLikelihoods.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/EmpiricalSubstitutionGenotypeLikelihoods.java @@ -241,6 +241,8 @@ public class EmpiricalSubstitutionGenotypeLikelihoods extends GenotypeLikelihood return EMPIRICAL_CACHE[a][i][j][k][x]; } + protected void clearCache() { EMPIRICAL_CACHE = new GenotypeLikelihoods[EmpiricalSubstitutionGenotypeLikelihoods.SequencerPlatform.values().length][BaseUtils.BASES.length][QualityUtils.MAX_QUAL_SCORE][MAX_PLOIDY][2]; } + // ----------------------------------------------------------------------------------------------------------------- // diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/GenotypeLikelihoods.java b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/GenotypeLikelihoods.java index 7e7de302c..17a351396 100644 --- a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/GenotypeLikelihoods.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/GenotypeLikelihoods.java @@ -78,7 +78,12 @@ public abstract class GenotypeLikelihoods implements Cloneable { initialize(); } - public static GenotypeLikelihoods merge(GenotypeLikelihoods gl1, GenotypeLikelihoods gl2) { + public static GenotypeLikelihoods combineLikelihoods(GenotypeLikelihoods gl1, GenotypeLikelihoods gl2) { + if ( gl1 == null ) + return gl2; + if ( gl2 == null ) + return gl1; + // GL = GL_i + GL_j GenotypeLikelihoods gl; @@ -182,6 +187,14 @@ public abstract class GenotypeLikelihoods implements Cloneable { return priors.getPriors(); } + /** + * Sets the priors and clears the likelihoods cache. + */ + public void setPriors(DiploidGenotypePriors priors) { + this.priors = priors; + clearCache(); + } + /** * Returns the prior associated with DiploidGenotype g * @param g @@ -334,6 +347,10 @@ public abstract class GenotypeLikelihoods implements Cloneable { */ protected abstract GenotypeLikelihoods getSetCache( char observedBase, byte qualityScore, int ploidy, SAMRecord read, int offset, GenotypeLikelihoods val ); + /** + * Method for clearing the cache (in case we change the priors) + */ + protected abstract void clearCache(); protected GenotypeLikelihoods simpleGetSetCache( GenotypeLikelihoods[][][][] cache, char observedBase, byte qualityScore, int ploidy, diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/ThreeStateErrorGenotypeLikelihoods.java b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/ThreeStateErrorGenotypeLikelihoods.java index fde835d3d..bda9481b6 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/ThreeStateErrorGenotypeLikelihoods.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/ThreeStateErrorGenotypeLikelihoods.java @@ -40,4 +40,5 @@ public class ThreeStateErrorGenotypeLikelihoods extends GenotypeLikelihoods { SAMRecord read, int offset, GenotypeLikelihoods val ) { return simpleGetSetCache(THREE_STATE_CACHE, observedBase, qualityScore, ploidy, read, offset, val); } + protected void clearCache() { THREE_STATE_CACHE = new GenotypeLikelihoods[BaseUtils.BASES.length][QualityUtils.MAX_QUAL_SCORE][MAX_PLOIDY][2]; } }