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]; } }