/** * Initialize cache of allele anyploid indices * If initialized multiple times with the same ploidy, the alternate alleles from the last initialization will be used * * @param altAlleles number of alternate alleles * @param ploidy number of chromosomes * @throws IllegalArgumentException if altAlleles or ploidy <= 0 */ public static synchronized void initializeAnyploidPLIndexToAlleleIndices(final int altAlleles, final int ploidy) { if ( altAlleles <= 0 ) throw new IllegalArgumentException("Must have at least one alternate allele, not " + altAlleles ); if ( ploidy <= 0 ) throw new IllegalArgumentException("Ploidy must be at least 1, not " + ploidy); // create the allele indices for each PL index for a ploidy anyploidPloidyToPLIndexToAlleleIndices.put(ploidy, calculateAnyploidPLcache(altAlleles, ploidy)); }
/** * Initialize cache of allele anyploid indices * If initialized multiple times with the same ploidy, the alternate alleles from the last initialization will be used * * @param altAlleles number of alternate alleles * @param ploidy number of chromosomes * @throws IllegalArgumentException if altAlleles or ploidy <= 0 */ public static synchronized void initializeAnyploidPLIndexToAlleleIndices(final int altAlleles, final int ploidy) { if ( altAlleles <= 0 ) throw new IllegalArgumentException("Must have at least one alternate allele, not " + altAlleles ); if ( ploidy <= 0 ) throw new IllegalArgumentException("Ploidy must be at least 1, not " + ploidy); // create the allele indices for each PL index for a ploidy anyploidPloidyToPLIndexToAlleleIndices.put(ploidy, calculateAnyploidPLcache(altAlleles, ploidy)); }
@Test(dataProvider = "testCalculateAnyploidPLcacheData") public void testCalculateAnyploidPLcache(final int altAlleles, final int ploidy, final List<List<Integer>> expected) { List<List<Integer>> anyploidPLIndexToAlleleIndices = GenotypeLikelihoods.calculateAnyploidPLcache(altAlleles, ploidy); for ( int i=0; i < anyploidPLIndexToAlleleIndices.size(); i++ ) Assert.assertEquals(anyploidPLIndexToAlleleIndices.get(i), expected.get(i)); }