From d3f2bc43613971d3d9c1adb65c451270cea571ce Mon Sep 17 00:00:00 2001 From: Eric Banks Date: Fri, 23 Mar 2012 13:51:00 -0400 Subject: [PATCH] Pre-allocate 10 alt alleles worth of PLs in the cache for efficiency. This effectively means that we never need to re-allocate the cache in the future because we can't ever really handle that many alt alleles. --- .../sting/utils/variantcontext/GenotypeLikelihoods.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/public/java/src/org/broadinstitute/sting/utils/variantcontext/GenotypeLikelihoods.java b/public/java/src/org/broadinstitute/sting/utils/variantcontext/GenotypeLikelihoods.java index ae3dff9ed..1f3aead07 100755 --- a/public/java/src/org/broadinstitute/sting/utils/variantcontext/GenotypeLikelihoods.java +++ b/public/java/src/org/broadinstitute/sting/utils/variantcontext/GenotypeLikelihoods.java @@ -222,7 +222,10 @@ public class GenotypeLikelihoods { /* * a cache of the PL index to the 2 alleles it represents over all possible numbers of alternate alleles */ - private static GenotypeLikelihoodsAllelePair[] PLIndexToAlleleIndex = new GenotypeLikelihoodsAllelePair[]{ new GenotypeLikelihoodsAllelePair(0, 0) }; + private static GenotypeLikelihoodsAllelePair[] PLIndexToAlleleIndex; + static { + calculatePLcache(65); // start with data for 10 alternate alleles + } private static void calculatePLcache(final int minIndex) { // how many alternate alleles do we need to calculate for? @@ -266,6 +269,7 @@ public class GenotypeLikelihoods { */ public static GenotypeLikelihoodsAllelePair getAllelePair(final int PLindex) { // make sure that we've cached enough data + // TODO -- this is not thread-safe! if ( PLindex >= PLIndexToAlleleIndex.length ) calculatePLcache(PLindex);