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
This commit is contained in:
ebanks 2009-09-30 19:55:49 +00:00
parent 665951f9f0
commit 841d25cc44
3 changed files with 21 additions and 1 deletions

View File

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

View File

@ -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,

View File

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