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.
This commit is contained in:
parent
ff26f2bf68
commit
d3f2bc4361
|
|
@ -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
|
* 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) {
|
private static void calculatePLcache(final int minIndex) {
|
||||||
// how many alternate alleles do we need to calculate for?
|
// how many alternate alleles do we need to calculate for?
|
||||||
|
|
@ -266,6 +269,7 @@ public class GenotypeLikelihoods {
|
||||||
*/
|
*/
|
||||||
public static GenotypeLikelihoodsAllelePair getAllelePair(final int PLindex) {
|
public static GenotypeLikelihoodsAllelePair getAllelePair(final int PLindex) {
|
||||||
// make sure that we've cached enough data
|
// make sure that we've cached enough data
|
||||||
|
// TODO -- this is not thread-safe!
|
||||||
if ( PLindex >= PLIndexToAlleleIndex.length )
|
if ( PLindex >= PLIndexToAlleleIndex.length )
|
||||||
calculatePLcache(PLindex);
|
calculatePLcache(PLindex);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue