Renamed AFCalc to AFCalculator for a better class naming
This commit is contained in:
parent
95b45443ae
commit
f6cb83d476
|
|
@ -59,8 +59,8 @@ import org.broadinstitute.gatk.engine.contexts.AlignmentContextUtils;
|
|||
import org.broadinstitute.gatk.engine.contexts.ReferenceContext;
|
||||
import org.broadinstitute.gatk.engine.refdata.RefMetaDataTracker;
|
||||
import org.broadinstitute.gatk.tools.walkers.annotator.VariantAnnotatorEngine;
|
||||
import org.broadinstitute.gatk.tools.walkers.genotyper.afcalc.AFCalc;
|
||||
import org.broadinstitute.gatk.tools.walkers.genotyper.afcalc.AFCalcResult;
|
||||
import org.broadinstitute.gatk.tools.walkers.genotyper.afcalc.AFCalculator;
|
||||
import org.broadinstitute.gatk.tools.walkers.genotyper.afcalc.AFCalculationResult;
|
||||
import org.broadinstitute.gatk.tools.walkers.genotyper.afcalc.AFCalculatorProvider;
|
||||
import org.broadinstitute.gatk.utils.GenomeLoc;
|
||||
import org.broadinstitute.gatk.utils.GenomeLocParser;
|
||||
|
|
@ -218,8 +218,8 @@ public abstract class GenotypingEngine<Config extends StandardCallerArgumentColl
|
|||
|
||||
final int defaultPloidy = configuration.genotypeArgs.samplePloidy;
|
||||
final int maxAltAlleles = configuration.genotypeArgs.MAX_ALTERNATE_ALLELES;
|
||||
final AFCalc afCalculator = afCalculatorProvider.getInstance(vc,defaultPloidy,maxAltAlleles);
|
||||
final AFCalcResult AFresult = afCalculator.getLog10PNonRef(vc, defaultPloidy,maxAltAlleles, getAlleleFrequencyPriors(vc,defaultPloidy,model));
|
||||
final AFCalculator afCalculator = afCalculatorProvider.getInstance(vc,defaultPloidy,maxAltAlleles);
|
||||
final AFCalculationResult AFresult = afCalculator.getLog10PNonRef(vc, defaultPloidy,maxAltAlleles, getAlleleFrequencyPriors(vc,defaultPloidy,model));
|
||||
|
||||
final OutputAlleleSubset outputAlternativeAlleles = calculateOutputAlleleSubset(AFresult);
|
||||
|
||||
|
|
@ -333,7 +333,7 @@ public abstract class GenotypingEngine<Config extends StandardCallerArgumentColl
|
|||
* @param afcr the exact model calcualtion result.
|
||||
* @return never {@code null}.
|
||||
*/
|
||||
private OutputAlleleSubset calculateOutputAlleleSubset(final AFCalcResult afcr) {
|
||||
private OutputAlleleSubset calculateOutputAlleleSubset(final AFCalculationResult afcr) {
|
||||
final List<Allele> alleles = afcr.getAllelesUsedInGenotyping();
|
||||
|
||||
final int alternativeAlleleCount = alleles.size() - 1;
|
||||
|
|
@ -635,7 +635,7 @@ public abstract class GenotypingEngine<Config extends StandardCallerArgumentColl
|
|||
|
||||
protected Map<String,Object> composeCallAttributes(final boolean inheritAttributesFromInputVC, final VariantContext vc,
|
||||
final AlignmentContext rawContext, final Map<String, AlignmentContext> stratifiedContexts, final RefMetaDataTracker tracker, final ReferenceContext refContext, final List<Integer> alleleCountsofMLE, final boolean bestGuessIsRef,
|
||||
final AFCalcResult AFresult, final List<Allele> allAllelesToUse, final GenotypesContext genotypes,
|
||||
final AFCalculationResult AFresult, final List<Allele> allAllelesToUse, final GenotypesContext genotypes,
|
||||
final GenotypeLikelihoodsCalculationModel.Model model, final Map<String, org.broadinstitute.gatk.utils.genotyper.PerReadAlleleLikelihoodMap> perReadAlleleLikelihoodMap) {
|
||||
final HashMap<String, Object> attributes = new HashMap<>();
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ import org.broadinstitute.gatk.engine.contexts.AlignmentContext;
|
|||
import org.broadinstitute.gatk.engine.contexts.AlignmentContextUtils;
|
||||
import org.broadinstitute.gatk.engine.contexts.ReferenceContext;
|
||||
import org.broadinstitute.gatk.engine.refdata.RefMetaDataTracker;
|
||||
import org.broadinstitute.gatk.tools.walkers.genotyper.afcalc.AFCalcResult;
|
||||
import org.broadinstitute.gatk.tools.walkers.genotyper.afcalc.AFCalculationResult;
|
||||
import org.broadinstitute.gatk.tools.walkers.genotyper.afcalc.AFCalculatorProvider;
|
||||
import org.broadinstitute.gatk.utils.BaseUtils;
|
||||
import org.broadinstitute.gatk.utils.GenomeLocParser;
|
||||
|
|
@ -359,7 +359,7 @@ public class UnifiedGenotypingEngine extends GenotypingEngine<UnifiedArgumentCol
|
|||
@Override
|
||||
protected Map<String,Object> composeCallAttributes(final boolean inheritAttributesFromInputVC, final VariantContext vc,
|
||||
final AlignmentContext rawContext, final Map<String, AlignmentContext> stratifiedContexts, final RefMetaDataTracker tracker, final ReferenceContext refContext, final List<Integer> alleleCountsofMLE, final boolean bestGuessIsRef,
|
||||
final AFCalcResult AFresult, final List<Allele> allAllelesToUse, final GenotypesContext genotypes,
|
||||
final AFCalculationResult AFresult, final List<Allele> allAllelesToUse, final GenotypesContext genotypes,
|
||||
final GenotypeLikelihoodsCalculationModel.Model model, final Map<String, org.broadinstitute.gatk.utils.genotyper.PerReadAlleleLikelihoodMap> perReadAlleleLikelihoodMap) {
|
||||
final Map<String,Object> result = super.composeCallAttributes(inheritAttributesFromInputVC, vc,rawContext,stratifiedContexts,tracker,refContext,alleleCountsofMLE,bestGuessIsRef,
|
||||
AFresult,allAllelesToUse,genotypes,model,perReadAlleleLikelihoodMap);
|
||||
|
|
@ -376,7 +376,7 @@ public class UnifiedGenotypingEngine extends GenotypingEngine<UnifiedArgumentCol
|
|||
|
||||
private double calculateSLOD(final Map<String, AlignmentContext> stratifiedContexts,
|
||||
final RefMetaDataTracker tracker,
|
||||
final ReferenceContext refContext, final AFCalcResult AFresult,
|
||||
final ReferenceContext refContext, final AFCalculationResult AFresult,
|
||||
final List<Allele> allAllelesToUse,
|
||||
final GenotypeLikelihoodsCalculationModel.Model model,
|
||||
final Map<String, PerReadAlleleLikelihoodMap> perReadAlleleLikelihoodMap) {
|
||||
|
|
@ -386,13 +386,13 @@ public class UnifiedGenotypingEngine extends GenotypingEngine<UnifiedArgumentCol
|
|||
//if ( DEBUG_SLOD ) System.out.println("overallLog10PofF=" + overallLog10PofF);
|
||||
|
||||
// the forward lod
|
||||
final AFCalcResult forwardAFresult = getDirectionalAfCalcResult(AlignmentContextUtils.ReadOrientation.FORWARD,stratifiedContexts, tracker, refContext, allAllelesToUse, model, perReadAlleleLikelihoodMap);
|
||||
final AFCalculationResult forwardAFresult = getDirectionalAfCalcResult(AlignmentContextUtils.ReadOrientation.FORWARD,stratifiedContexts, tracker, refContext, allAllelesToUse, model, perReadAlleleLikelihoodMap);
|
||||
final double forwardLog10PofNull = forwardAFresult.getLog10LikelihoodOfAFEq0();
|
||||
final double forwardLog10PofF = forwardAFresult.getLog10LikelihoodOfAFGT0();
|
||||
//if ( DEBUG_SLOD ) System.out.println("forwardLog10PofNull=" + forwardLog10PofNull + ", forwardLog10PofF=" + forwardLog10PofF);
|
||||
|
||||
// the reverse lod
|
||||
final AFCalcResult reverseAFresult = getDirectionalAfCalcResult(AlignmentContextUtils.ReadOrientation.REVERSE,stratifiedContexts, tracker, refContext, allAllelesToUse, model, perReadAlleleLikelihoodMap);
|
||||
final AFCalculationResult reverseAFresult = getDirectionalAfCalcResult(AlignmentContextUtils.ReadOrientation.REVERSE,stratifiedContexts, tracker, refContext, allAllelesToUse, model, perReadAlleleLikelihoodMap);
|
||||
final double reverseLog10PofNull = reverseAFresult.getLog10LikelihoodOfAFEq0();
|
||||
final double reverseLog10PofF = reverseAFresult.getLog10LikelihoodOfAFGT0();
|
||||
//if ( DEBUG_SLOD ) System.out.println("reverseLog10PofNull=" + reverseLog10PofNull + ", reverseLog10PofF=" + reverseLog10PofF);
|
||||
|
|
@ -409,7 +409,7 @@ public class UnifiedGenotypingEngine extends GenotypingEngine<UnifiedArgumentCol
|
|||
return strandScore;
|
||||
}
|
||||
|
||||
private AFCalcResult getDirectionalAfCalcResult(final AlignmentContextUtils.ReadOrientation orientation,
|
||||
private AFCalculationResult getDirectionalAfCalcResult(final AlignmentContextUtils.ReadOrientation orientation,
|
||||
final Map<String, AlignmentContext> stratifiedContexts,
|
||||
final RefMetaDataTracker tracker,
|
||||
final ReferenceContext refContext, List<Allele> allAllelesToUse,
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ import java.util.*;
|
|||
* Note that all of the values -- i.e. priors -- are checked now that they are meaningful, which means
|
||||
* that users of this code can rely on the values coming out of these functions.
|
||||
*/
|
||||
public class AFCalcResult {
|
||||
public class AFCalculationResult {
|
||||
private final static int AF0 = 0;
|
||||
private final static int AF1p = 1;
|
||||
private final static int LOG_10_ARRAY_SIZES = 2;
|
||||
|
|
@ -89,12 +89,12 @@ public class AFCalcResult {
|
|||
/**
|
||||
* Create a results object capability of storing results for calls with up to maxAltAlleles
|
||||
*/
|
||||
public AFCalcResult(final int[] alleleCountsOfMLE,
|
||||
final int nEvaluations,
|
||||
final List<Allele> allelesUsedInGenotyping,
|
||||
final double[] log10LikelihoodsOfAC,
|
||||
final double[] log10PriorsOfAC,
|
||||
final Map<Allele, Double> log10pRefByAllele) {
|
||||
public AFCalculationResult(final int[] alleleCountsOfMLE,
|
||||
final int nEvaluations,
|
||||
final List<Allele> allelesUsedInGenotyping,
|
||||
final double[] log10LikelihoodsOfAC,
|
||||
final double[] log10PriorsOfAC,
|
||||
final Map<Allele, Double> log10pRefByAllele) {
|
||||
if ( allelesUsedInGenotyping == null || allelesUsedInGenotyping.size() < 1 ) throw new IllegalArgumentException("allelesUsedInGenotyping must be non-null list of at least 1 value " + allelesUsedInGenotyping);
|
||||
if ( alleleCountsOfMLE == null ) throw new IllegalArgumentException("alleleCountsOfMLE cannot be null");
|
||||
if ( alleleCountsOfMLE.length != allelesUsedInGenotyping.size() - 1) throw new IllegalArgumentException("alleleCountsOfMLE.length " + alleleCountsOfMLE.length + " != allelesUsedInGenotyping.size() " + allelesUsedInGenotyping.size());
|
||||
|
|
@ -123,8 +123,8 @@ public class AFCalcResult {
|
|||
* @param log10PriorsOfAC
|
||||
* @return
|
||||
*/
|
||||
public AFCalcResult withNewPriors(final double[] log10PriorsOfAC) {
|
||||
return new AFCalcResult(alleleCountsOfMLE, nEvaluations, allelesUsedInGenotyping, log10LikelihoodsOfAC, log10PriorsOfAC, log10pRefByAllele);
|
||||
public AFCalculationResult withNewPriors(final double[] log10PriorsOfAC) {
|
||||
return new AFCalculationResult(alleleCountsOfMLE, nEvaluations, allelesUsedInGenotyping, log10LikelihoodsOfAC, log10PriorsOfAC, log10pRefByAllele);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -61,8 +61,8 @@ import java.util.List;
|
|||
/**
|
||||
* Generic interface for calculating the probability of alleles segregating given priors and genotype likelihoods
|
||||
*/
|
||||
public abstract class AFCalc implements Cloneable {
|
||||
private final static Logger defaultLogger = Logger.getLogger(AFCalc.class);
|
||||
public abstract class AFCalculator implements Cloneable {
|
||||
private final static Logger defaultLogger = Logger.getLogger(AFCalculator.class);
|
||||
|
||||
|
||||
protected Logger logger = defaultLogger;
|
||||
|
|
@ -80,7 +80,7 @@ public abstract class AFCalc implements Cloneable {
|
|||
* by its implementation class {@link AFCalculatorImplementation}
|
||||
* </p>
|
||||
*/
|
||||
protected AFCalc() {
|
||||
protected AFCalculator() {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -109,7 +109,7 @@ public abstract class AFCalc implements Cloneable {
|
|||
* @param log10AlleleFrequencyPriors a prior vector nSamples x 2 in length indicating the Pr(AF = i)
|
||||
* @return result (for programming convenience)
|
||||
*/
|
||||
public AFCalcResult getLog10PNonRef(final VariantContext vc, final int defaultPloidy, final int maximumAlternativeAlleles, final double[] log10AlleleFrequencyPriors) {
|
||||
public AFCalculationResult getLog10PNonRef(final VariantContext vc, final int defaultPloidy, final int maximumAlternativeAlleles, final double[] log10AlleleFrequencyPriors) {
|
||||
if ( vc == null ) throw new IllegalArgumentException("VariantContext cannot be null");
|
||||
if ( vc.getNAlleles() == 1 ) throw new IllegalArgumentException("VariantContext has only a single reference allele, but getLog10PNonRef requires at least one at all " + vc);
|
||||
if ( log10AlleleFrequencyPriors == null ) throw new IllegalArgumentException("priors vector cannot be null");
|
||||
|
|
@ -120,7 +120,7 @@ public abstract class AFCalc implements Cloneable {
|
|||
final VariantContext vcWorking = reduceScope(vc,defaultPloidy, maximumAlternativeAlleles);
|
||||
|
||||
callTimer.start();
|
||||
final AFCalcResult result = computeLog10PNonRef(vcWorking, defaultPloidy, log10AlleleFrequencyPriors, stateTracker);
|
||||
final AFCalculationResult result = computeLog10PNonRef(vcWorking, defaultPloidy, log10AlleleFrequencyPriors, stateTracker);
|
||||
final long nanoTime = callTimer.getElapsedTimeNano();
|
||||
|
||||
if ( exactCallLogger != null )
|
||||
|
|
@ -130,19 +130,19 @@ public abstract class AFCalc implements Cloneable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Convert the final state of the state tracker into our result as an AFCalcResult
|
||||
* Convert the final state of the state tracker into our result as an AFCalculationResult
|
||||
*
|
||||
* Assumes that stateTracker has been updated accordingly
|
||||
*
|
||||
* @param vcWorking the VariantContext we actually used as input to the calc model (after reduction)
|
||||
* @param log10AlleleFrequencyPriors the priors by AC vector
|
||||
* @return a AFCalcResult describing the result of this calculation
|
||||
* @return a AFCalculationResult describing the result of this calculation
|
||||
*/
|
||||
@Requires("stateTracker.getnEvaluations() >= 0")
|
||||
@Ensures("result != null")
|
||||
protected AFCalcResult getResultFromFinalState(final VariantContext vcWorking, final double[] log10AlleleFrequencyPriors, final StateTracker stateTracker) {
|
||||
protected AFCalculationResult getResultFromFinalState(final VariantContext vcWorking, final double[] log10AlleleFrequencyPriors, final StateTracker stateTracker) {
|
||||
stateTracker.setAllelesUsedInGenotyping(vcWorking.getAlleles());
|
||||
return stateTracker.toAFCalcResult(log10AlleleFrequencyPriors);
|
||||
return stateTracker.toAFCalculationResult(log10AlleleFrequencyPriors);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
@ -175,7 +175,7 @@ public abstract class AFCalc implements Cloneable {
|
|||
* @return a AFCalcResult object describing the results of this calculation
|
||||
*/
|
||||
@Requires({"vc != null", "log10AlleleFrequencyPriors != null", "vc.getNAlleles() > 1"})
|
||||
protected abstract AFCalcResult computeLog10PNonRef(final VariantContext vc, final int defaultPloidy,
|
||||
protected abstract AFCalculationResult computeLog10PNonRef(final VariantContext vc, final int defaultPloidy,
|
||||
final double[] log10AlleleFrequencyPriors, final StateTracker stateTracker);
|
||||
|
||||
/**
|
||||
|
|
@ -49,7 +49,7 @@ package org.broadinstitute.gatk.tools.walkers.genotyper.afcalc;
|
|||
/**
|
||||
* Factory to make AFCalculations
|
||||
*/
|
||||
public class AFCalcFactory {
|
||||
public class AFCalculatorFactory {
|
||||
|
||||
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ public class AFCalcFactory {
|
|||
* ploidy as this is a sign of a hidden diploid assumption which is bad.
|
||||
*/
|
||||
@Deprecated
|
||||
public static AFCalc createCalculatorForDiploidBiAllelicAnalysis() {
|
||||
public static AFCalculator createCalculatorForDiploidBiAllelicAnalysis() {
|
||||
return AFCalculatorImplementation.bestValue(2,1,null).newInstance();
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ public class AFCalcFactory {
|
|||
* @return an initialized AFCalc
|
||||
*/
|
||||
@Deprecated
|
||||
public static AFCalc createCalculatorForDiploidAnalysis() {
|
||||
public static AFCalculator createCalculatorForDiploidAnalysis() {
|
||||
return AFCalculatorImplementation.bestValue(2,AFCalculatorImplementation.UNBOUND_ALTERNATIVE_ALLELE_COUNT,null).newInstance();
|
||||
}
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ public class AFCalcFactory {
|
|||
*
|
||||
* @return an initialized AFCalc
|
||||
*/
|
||||
public static AFCalc createCalculator(final int nSamples, final int maxAltAlleles, final int ploidy) {
|
||||
public static AFCalculator createCalculator(final int nSamples, final int maxAltAlleles, final int ploidy) {
|
||||
return createCalculator(chooseBestImplementation(ploidy, maxAltAlleles), nSamples, maxAltAlleles, ploidy);
|
||||
}
|
||||
|
||||
|
|
@ -120,7 +120,7 @@ public class AFCalcFactory {
|
|||
*
|
||||
* @return an initialized AFCalc
|
||||
*/
|
||||
public static AFCalc createCalculator(final AFCalculatorImplementation implementation, final int nSamples, final int maxAltAlleles, final int ploidy) {
|
||||
public static AFCalculator createCalculator(final AFCalculatorImplementation implementation, final int nSamples, final int maxAltAlleles, final int ploidy) {
|
||||
if ( implementation == null ) throw new IllegalArgumentException("Calculation cannot be null");
|
||||
if ( nSamples < 0 ) throw new IllegalArgumentException("nSamples must be greater than zero " + nSamples);
|
||||
if ( maxAltAlleles < 1 ) throw new IllegalArgumentException("maxAltAlleles must be greater than zero " + maxAltAlleles);
|
||||
|
|
@ -60,16 +60,16 @@ import java.util.Map;
|
|||
public enum AFCalculatorImplementation {
|
||||
|
||||
/** default implementation */
|
||||
EXACT_INDEPENDENT(IndependentAllelesDiploidExactAFCalc.class, 2),
|
||||
EXACT_INDEPENDENT(IndependentAllelesDiploidExactAFCalculator.class, 2),
|
||||
|
||||
/** reference implementation of multi-allelic EXACT model. Extremely slow for many alternate alleles */
|
||||
EXACT_REFERENCE(ReferenceDiploidExactAFCalc.class, 2),
|
||||
EXACT_REFERENCE(ReferenceDiploidExactAFCalculator.class, 2),
|
||||
|
||||
/** original biallelic exact model, for testing only */
|
||||
EXACT_ORIGINAL(OriginalDiploidExactAFCalc.class, 2, 2),
|
||||
EXACT_ORIGINAL(OriginalDiploidExactAFCalculator.class, 2, 2),
|
||||
|
||||
/** implementation that supports any sample ploidy. Currently not available for the HaplotypeCaller */
|
||||
EXACT_GENERAL_PLOIDY(GeneralPloidyExactAFCalc.class);
|
||||
EXACT_GENERAL_PLOIDY(GeneralPloidyExactAFCalculator.class);
|
||||
|
||||
/**
|
||||
* Special max alt allele count indicating that this maximum is in fact unbound (can be anything).
|
||||
|
|
@ -81,12 +81,12 @@ public enum AFCalculatorImplementation {
|
|||
*/
|
||||
public final static int UNBOUND_PLOIDY = -1;
|
||||
|
||||
private static Map<Class<? extends AFCalc>,AFCalculatorImplementation> calculatorClassToValue = buildCalculatorClassToValueMap();
|
||||
private static Map<Class<? extends AFCalculator>,AFCalculatorImplementation> calculatorClassToValue = buildCalculatorClassToValueMap();
|
||||
|
||||
/**
|
||||
* Reference to the calculator class.
|
||||
*/
|
||||
public final Class<? extends AFCalc> calculatorClass;
|
||||
public final Class<? extends AFCalculator> calculatorClass;
|
||||
|
||||
/**
|
||||
* Maximum number of supported alternative alleles.
|
||||
|
|
@ -96,7 +96,7 @@ public enum AFCalculatorImplementation {
|
|||
/**
|
||||
* Reference to the constructor to instantiate a calculator for this implementation.
|
||||
*/
|
||||
protected final Constructor<? extends AFCalc> constructor;
|
||||
protected final Constructor<? extends AFCalculator> constructor;
|
||||
|
||||
/**
|
||||
* Supported ploidy.
|
||||
|
|
@ -117,7 +117,7 @@ public enum AFCalculatorImplementation {
|
|||
* @param requiredPloidy the required ploidy; zero or greater or {@link #UNBOUND_PLOIDY} to indicate that any ploidy is supported.
|
||||
* @param maxAltAlleles the maximum alternative alleles; zero or greater or {@link #UNBOUND_ALTERNATIVE_ALLELE_COUNT} to indicate that any maximum number of alternative alleles is supported.
|
||||
*/
|
||||
AFCalculatorImplementation(final Class<? extends AFCalc> clazz, final int requiredPloidy, final int maxAltAlleles) {
|
||||
AFCalculatorImplementation(final Class<? extends AFCalculator> clazz, final int requiredPloidy, final int maxAltAlleles) {
|
||||
calculatorClass = clazz;
|
||||
this.requiredPloidy = requiredPloidy;
|
||||
this.maxAltAlleles = maxAltAlleles;
|
||||
|
|
@ -128,7 +128,7 @@ public enum AFCalculatorImplementation {
|
|||
* Constructs a new instance leaving ploidy and max-allele count unbound.
|
||||
* @param clazz the calculator class that realizes this implementation.
|
||||
*/
|
||||
AFCalculatorImplementation(final Class<? extends AFCalc> clazz) {
|
||||
AFCalculatorImplementation(final Class<? extends AFCalculator> clazz) {
|
||||
this(clazz,UNBOUND_PLOIDY, UNBOUND_ALTERNATIVE_ALLELE_COUNT);
|
||||
}
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ public enum AFCalculatorImplementation {
|
|||
* @param clazz the calculator class that realizes this implementation.
|
||||
* @param requiredPloidy the required ploidy; zero or greater or {@link #UNBOUND_PLOIDY} to indicate that any ploidy is supported.
|
||||
*/
|
||||
AFCalculatorImplementation(final Class<? extends AFCalc> clazz, final int requiredPloidy) {
|
||||
AFCalculatorImplementation(final Class<? extends AFCalculator> clazz, final int requiredPloidy) {
|
||||
this(clazz,requiredPloidy,UNBOUND_PLOIDY);
|
||||
}
|
||||
|
||||
|
|
@ -156,11 +156,11 @@ public enum AFCalculatorImplementation {
|
|||
*
|
||||
* @param clazz target class. Assume not to be {@code null}.
|
||||
*/
|
||||
private Constructor<? extends AFCalc> findInstantiationConstructor(final Class<? extends AFCalc> clazz) {
|
||||
private Constructor<? extends AFCalculator> findInstantiationConstructor(final Class<? extends AFCalculator> clazz) {
|
||||
if (Modifier.isAbstract(clazz.getModifiers()))
|
||||
throw new IllegalStateException("AF calculator implementation class cannot be abstract");
|
||||
|
||||
final Constructor<? extends AFCalc> result;
|
||||
final Constructor<? extends AFCalculator> result;
|
||||
try {
|
||||
result = clazz.getDeclaredConstructor();
|
||||
} catch (final NoSuchMethodException e) {
|
||||
|
|
@ -179,7 +179,7 @@ public enum AFCalculatorImplementation {
|
|||
* @throws IllegalStateException if the instance could not be create due to some exception. The {@link Exception#getCause() cause} will hold a reference to the actual exception.
|
||||
* @return never {@code null}.
|
||||
*/
|
||||
public AFCalc newInstance() {
|
||||
public AFCalculator newInstance() {
|
||||
try {
|
||||
return constructor.newInstance();
|
||||
} catch (final Throwable e) {
|
||||
|
|
@ -216,7 +216,7 @@ public enum AFCalculatorImplementation {
|
|||
*
|
||||
* @return never {@code null}.
|
||||
*/
|
||||
public static AFCalculatorImplementation fromCalculatorClass(final Class<? extends AFCalc> clazz) {
|
||||
public static AFCalculatorImplementation fromCalculatorClass(final Class<? extends AFCalculator> clazz) {
|
||||
if (clazz == null)
|
||||
throw new IllegalArgumentException("input class cannot be null");
|
||||
final AFCalculatorImplementation result = calculatorClassToValue.get(clazz);
|
||||
|
|
@ -226,8 +226,8 @@ public enum AFCalculatorImplementation {
|
|||
}
|
||||
|
||||
// Initializes the content of the class to value map.
|
||||
private static Map<Class<? extends AFCalc>, AFCalculatorImplementation> buildCalculatorClassToValueMap() {
|
||||
final Map<Class<? extends AFCalc>,AFCalculatorImplementation> result = new HashMap<>(values().length);
|
||||
private static Map<Class<? extends AFCalculator>, AFCalculatorImplementation> buildCalculatorClassToValueMap() {
|
||||
final Map<Class<? extends AFCalculator>,AFCalculatorImplementation> result = new HashMap<>(values().length);
|
||||
for (final AFCalculatorImplementation value : values())
|
||||
if (result.put(value.calculatorClass,value) != null)
|
||||
throw new IllegalStateException("more than one value associated with class " + value.calculatorClass.getName());
|
||||
|
|
|
|||
|
|
@ -69,8 +69,8 @@ import java.util.*;
|
|||
* A simple GATK utility (i.e, runs from command-line) for assessing the performance of
|
||||
* the exact model
|
||||
*/
|
||||
public class AFCalcPerformanceTest {
|
||||
final static Logger logger = Logger.getLogger(AFCalcPerformanceTest.class);
|
||||
public class AFCalculatorPerformanceTest {
|
||||
final static Logger logger = Logger.getLogger(AFCalculatorPerformanceTest.class);
|
||||
|
||||
private static abstract class Analysis {
|
||||
final GATKReport report;
|
||||
|
|
@ -79,7 +79,7 @@ public class AFCalcPerformanceTest {
|
|||
report = GATKReport.newSimpleReport(name, columns);
|
||||
}
|
||||
|
||||
public abstract void run(final AFCalcTestBuilder testBuilder,
|
||||
public abstract void run(final AFCalculatorTestBuilder testBuilder,
|
||||
final List<Object> coreColumns);
|
||||
|
||||
public String getName() {
|
||||
|
|
@ -96,18 +96,18 @@ public class AFCalcPerformanceTest {
|
|||
super("AnalyzeByACAndPL", Utils.append(columns, "non.type.pls", "ac", "n.alt.seg", "other.ac"));
|
||||
}
|
||||
|
||||
public void run(final AFCalcTestBuilder testBuilder, final List<Object> coreValues) {
|
||||
public void run(final AFCalculatorTestBuilder testBuilder, final List<Object> coreValues) {
|
||||
final SimpleTimer timer = new SimpleTimer();
|
||||
|
||||
for ( final int nonTypePL : Arrays.asList(100) ) {
|
||||
final AFCalc calc = testBuilder.makeModel();
|
||||
final AFCalculator calc = testBuilder.makeModel();
|
||||
final double[] priors = testBuilder.makePriors();
|
||||
|
||||
for ( int[] ACs : makeACs(testBuilder.numAltAlleles, testBuilder.nSamples*2) ) {
|
||||
final VariantContext vc = testBuilder.makeACTest(ACs, 0, nonTypePL);
|
||||
|
||||
timer.start();
|
||||
final AFCalcResult resultTracker = calc.getLog10PNonRef(vc, HomoSapiensConstants.DEFAULT_PLOIDY, testBuilder.numAltAlleles, priors);
|
||||
final AFCalculationResult resultTracker = calc.getLog10PNonRef(vc, HomoSapiensConstants.DEFAULT_PLOIDY, testBuilder.numAltAlleles, priors);
|
||||
final long runtime = timer.getElapsedTimeNano();
|
||||
|
||||
int otherAC = 0;
|
||||
|
|
@ -155,11 +155,11 @@ public class AFCalcPerformanceTest {
|
|||
super("AnalyzeBySingletonPosition", Utils.append(columns, "non.type.pls", "position.of.singleton"));
|
||||
}
|
||||
|
||||
public void run(final AFCalcTestBuilder testBuilder, final List<Object> coreValues) {
|
||||
public void run(final AFCalculatorTestBuilder testBuilder, final List<Object> coreValues) {
|
||||
final SimpleTimer timer = new SimpleTimer();
|
||||
|
||||
for ( final int nonTypePL : Arrays.asList(100) ) {
|
||||
final AFCalc calc = testBuilder.makeModel();
|
||||
final AFCalculator calc = testBuilder.makeModel();
|
||||
final double[] priors = testBuilder.makePriors();
|
||||
|
||||
final int[] ac = new int[testBuilder.numAltAlleles];
|
||||
|
|
@ -173,7 +173,7 @@ public class AFCalcPerformanceTest {
|
|||
vcb.genotypes(genotypes);
|
||||
|
||||
timer.start();
|
||||
final AFCalcResult resultTracker = calc.getLog10PNonRef(vcb.make(), HomoSapiensConstants.DEFAULT_PLOIDY, testBuilder.numAltAlleles, priors);
|
||||
final AFCalculationResult resultTracker = calc.getLog10PNonRef(vcb.make(), HomoSapiensConstants.DEFAULT_PLOIDY, testBuilder.numAltAlleles, priors);
|
||||
final long runtime = timer.getElapsedTimeNano();
|
||||
|
||||
final List<Object> columns = new LinkedList<Object>(coreValues);
|
||||
|
|
@ -189,11 +189,11 @@ public class AFCalcPerformanceTest {
|
|||
super("AnalyzeByNonInformative", Utils.append(columns, "non.type.pls", "n.non.informative"));
|
||||
}
|
||||
|
||||
public void run(final AFCalcTestBuilder testBuilder, final List<Object> coreValues) {
|
||||
public void run(final AFCalculatorTestBuilder testBuilder, final List<Object> coreValues) {
|
||||
final SimpleTimer timer = new SimpleTimer();
|
||||
|
||||
for ( final int nonTypePL : Arrays.asList(100) ) {
|
||||
final AFCalc calc = testBuilder.makeModel();
|
||||
final AFCalculator calc = testBuilder.makeModel();
|
||||
final double[] priors = testBuilder.makePriors();
|
||||
|
||||
final int[] ac = new int[testBuilder.numAltAlleles];
|
||||
|
|
@ -203,7 +203,7 @@ public class AFCalcPerformanceTest {
|
|||
final VariantContext vc = testBuilder.makeACTest(ac, nNonInformative, nonTypePL);
|
||||
|
||||
timer.start();
|
||||
final AFCalcResult resultTracker = calc.getLog10PNonRef(vc, HomoSapiensConstants.DEFAULT_PLOIDY, testBuilder.numAltAlleles, priors);
|
||||
final AFCalculationResult resultTracker = calc.getLog10PNonRef(vc, HomoSapiensConstants.DEFAULT_PLOIDY, testBuilder.numAltAlleles, priors);
|
||||
final long runtime = timer.getElapsedTimeNano();
|
||||
|
||||
final List<Object> columns = new LinkedList<Object>(coreValues);
|
||||
|
|
@ -271,12 +271,12 @@ public class AFCalcPerformanceTest {
|
|||
final List<ExactCallLogger.ExactCall> loggedCalls = ExactCallLogger.readExactLog(reader, startsToUse, parser);
|
||||
|
||||
for ( final ExactCallLogger.ExactCall call : loggedCalls ) {
|
||||
final AFCalcTestBuilder testBuilder = new AFCalcTestBuilder(call.vc.getNSamples(), 1,
|
||||
final AFCalculatorTestBuilder testBuilder = new AFCalculatorTestBuilder(call.vc.getNSamples(), 1,
|
||||
AFCalculatorImplementation.EXACT_INDEPENDENT,
|
||||
AFCalcTestBuilder.PriorType.human);
|
||||
AFCalculatorTestBuilder.PriorType.human);
|
||||
logger.info(call);
|
||||
final SimpleTimer timer = new SimpleTimer().start();
|
||||
final AFCalcResult result = testBuilder.makeModel().getLog10PNonRef(call.vc, HomoSapiensConstants.DEFAULT_PLOIDY, testBuilder.numAltAlleles,testBuilder.makePriors());
|
||||
final AFCalculationResult result = testBuilder.makeModel().getLog10PNonRef(call.vc, HomoSapiensConstants.DEFAULT_PLOIDY, testBuilder.numAltAlleles,testBuilder.makePriors());
|
||||
final long newNanoTime = timer.getElapsedTimeNano();
|
||||
if ( call.originalCall.anyPolymorphic(-1) || result.anyPolymorphic(-1) ) {
|
||||
logger.info("**** ONE IS POLY");
|
||||
|
|
@ -299,14 +299,14 @@ public class AFCalcPerformanceTest {
|
|||
final int nSamples = Integer.valueOf(args[1]);
|
||||
final int ac = Integer.valueOf(args[2]);
|
||||
|
||||
final AFCalcTestBuilder testBuilder = new AFCalcTestBuilder(nSamples, 1,
|
||||
final AFCalculatorTestBuilder testBuilder = new AFCalculatorTestBuilder(nSamples, 1,
|
||||
AFCalculatorImplementation.EXACT_INDEPENDENT,
|
||||
AFCalcTestBuilder.PriorType.human);
|
||||
AFCalculatorTestBuilder.PriorType.human);
|
||||
|
||||
final VariantContext vc = testBuilder.makeACTest(new int[]{ac}, 0, 100);
|
||||
|
||||
final SimpleTimer timer = new SimpleTimer().start();
|
||||
final AFCalcResult resultTracker = testBuilder.makeModel().getLog10PNonRef(vc, HomoSapiensConstants.DEFAULT_PLOIDY, testBuilder.numAltAlleles, testBuilder.makePriors());
|
||||
final AFCalculationResult resultTracker = testBuilder.makeModel().getLog10PNonRef(vc, HomoSapiensConstants.DEFAULT_PLOIDY, testBuilder.numAltAlleles, testBuilder.makePriors());
|
||||
final long runtime = timer.getElapsedTimeNano();
|
||||
logger.info("result " + resultTracker.getLog10PosteriorOfAFGT0());
|
||||
logger.info("runtime " + runtime);
|
||||
|
|
@ -324,9 +324,9 @@ public class AFCalcPerformanceTest {
|
|||
new ModelParams(AFCalculatorImplementation.EXACT_INDEPENDENT, 10000, 1000));
|
||||
|
||||
final boolean ONLY_HUMAN_PRIORS = false;
|
||||
final List<AFCalcTestBuilder.PriorType> priorTypes = ONLY_HUMAN_PRIORS
|
||||
? Arrays.asList(AFCalcTestBuilder.PriorType.values())
|
||||
: Arrays.asList(AFCalcTestBuilder.PriorType.human);
|
||||
final List<AFCalculatorTestBuilder.PriorType> priorTypes = ONLY_HUMAN_PRIORS
|
||||
? Arrays.asList(AFCalculatorTestBuilder.PriorType.values())
|
||||
: Arrays.asList(AFCalculatorTestBuilder.PriorType.human);
|
||||
|
||||
final List<Analysis> analyzes = new ArrayList<Analysis>();
|
||||
analyzes.add(new AnalyzeByACAndPL(coreColumns));
|
||||
|
|
@ -338,9 +338,9 @@ public class AFCalcPerformanceTest {
|
|||
for ( final int nSamples : Arrays.asList(1, 10, 100, 1000, 10000) ) {
|
||||
for ( final ModelParams modelToRun : modelParams) {
|
||||
if ( modelToRun.meetsConstraints(nAltAlleles, nSamples) ) {
|
||||
for ( final AFCalcTestBuilder.PriorType priorType : priorTypes ) {
|
||||
final AFCalcTestBuilder testBuilder
|
||||
= new AFCalcTestBuilder(nSamples, nAltAlleles, modelToRun.modelType, priorType);
|
||||
for ( final AFCalculatorTestBuilder.PriorType priorType : priorTypes ) {
|
||||
final AFCalculatorTestBuilder testBuilder
|
||||
= new AFCalculatorTestBuilder(nSamples, nAltAlleles, modelToRun.modelType, priorType);
|
||||
|
||||
for ( final Analysis analysis : analyzes ) {
|
||||
logger.info(Utils.join("\t", Arrays.asList(iteration, nAltAlleles, nSamples, modelToRun.modelType, priorType, analysis.getName())));
|
||||
|
|
@ -65,7 +65,7 @@ public abstract class AFCalculatorProvider {
|
|||
* @param defaultPloidy the assumed ploidy in case that there is no a GT call present to determine it.
|
||||
* @return never {@code null}
|
||||
*/
|
||||
public AFCalc getInstance(final VariantContext variantContext, final int defaultPloidy, final int maximumAltAlleles) {
|
||||
public AFCalculator getInstance(final VariantContext variantContext, final int defaultPloidy, final int maximumAltAlleles) {
|
||||
if (variantContext == null)
|
||||
throw new IllegalArgumentException("variant context cannot be null");
|
||||
|
||||
|
|
@ -96,6 +96,6 @@ public abstract class AFCalculatorProvider {
|
|||
* @param maximumAltAlleles the allele count.
|
||||
* @return never {@code null}
|
||||
*/
|
||||
public abstract AFCalc getInstance(final int ploidy, final int maximumAltAlleles);
|
||||
public abstract AFCalculator getInstance(final int ploidy, final int maximumAltAlleles);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ import java.util.Arrays;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class AFCalcTestBuilder {
|
||||
public class AFCalculatorTestBuilder {
|
||||
final static Allele A = Allele.create("A", true);
|
||||
final static Allele C = Allele.create("C");
|
||||
final static Allele G = Allele.create("G");
|
||||
|
|
@ -74,8 +74,8 @@ public class AFCalcTestBuilder {
|
|||
final AFCalculatorImplementation modelType;
|
||||
final PriorType priorType;
|
||||
|
||||
public AFCalcTestBuilder(final int nSamples, final int numAltAlleles,
|
||||
final AFCalculatorImplementation modelType, final PriorType priorType) {
|
||||
public AFCalculatorTestBuilder(final int nSamples, final int numAltAlleles,
|
||||
final AFCalculatorImplementation modelType, final PriorType priorType) {
|
||||
this.nSamples = nSamples;
|
||||
this.numAltAlleles = numAltAlleles;
|
||||
this.modelType = modelType;
|
||||
|
|
@ -100,8 +100,8 @@ public class AFCalcTestBuilder {
|
|||
return nSamples;
|
||||
}
|
||||
|
||||
public AFCalc makeModel() {
|
||||
return AFCalcFactory.createCalculator(modelType, nSamples, getNumAltAlleles(), HomoSapiensConstants.DEFAULT_PLOIDY);
|
||||
public AFCalculator makeModel() {
|
||||
return AFCalculatorFactory.createCalculator(modelType, nSamples, getNumAltAlleles(), HomoSapiensConstants.DEFAULT_PLOIDY);
|
||||
}
|
||||
|
||||
public double[] makePriors() {
|
||||
|
|
@ -69,13 +69,13 @@ public abstract class ConcurrentAFCalculatorProvider extends AFCalculatorProvide
|
|||
}
|
||||
|
||||
@Override
|
||||
public AFCalc getInstance(final VariantContext vc, final int defaultPloidy, final int maxAltAlleleCount) {
|
||||
public AFCalculator getInstance(final VariantContext vc, final int defaultPloidy, final int maxAltAlleleCount) {
|
||||
return threadLocal.get().getInstance(vc,defaultPloidy,maxAltAlleleCount);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AFCalc getInstance(final int ploidy, final int maxAltAlleleCount) {
|
||||
public AFCalculator getInstance(final int ploidy, final int maxAltAlleleCount) {
|
||||
return threadLocal.get().getInstance(ploidy, maxAltAlleleCount);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,15 +55,15 @@ import htsjdk.variant.variantcontext.VariantContext;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
public abstract class DiploidExactAFCalc extends ExactAFCalc {
|
||||
public abstract class DiploidExactAFCalculator extends ExactAFCalculator {
|
||||
|
||||
private static final double LOG10_OF_2 = MathUtils.Log10Cache.get(2);
|
||||
|
||||
public DiploidExactAFCalc() {
|
||||
public DiploidExactAFCalculator() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AFCalcResult computeLog10PNonRef(final VariantContext vc, final int defaultPloidy,
|
||||
protected AFCalculationResult computeLog10PNonRef(final VariantContext vc, final int defaultPloidy,
|
||||
final double[] log10AlleleFrequencyPriors, final StateTracker stateTracker) {
|
||||
final int numAlternateAlleles = vc.getNAlleles() - 1;
|
||||
|
||||
|
|
@ -55,11 +55,11 @@ import java.util.*;
|
|||
/**
|
||||
* Uses the Exact calculation of Heng Li
|
||||
*/
|
||||
abstract class ExactAFCalc extends AFCalc {
|
||||
abstract class ExactAFCalculator extends AFCalculator {
|
||||
|
||||
protected static final int HOM_REF_INDEX = 0; // AA likelihoods are always first
|
||||
/**
|
||||
* Sorts {@link ExactAFCalc.LikelihoodSum} instances where those with higher likelihood are first.
|
||||
* Sorts {@link ExactAFCalculator.LikelihoodSum} instances where those with higher likelihood are first.
|
||||
*/
|
||||
protected static final Comparator<LikelihoodSum> LIKELIHOOD_SUM_COMPARATOR = new Comparator<LikelihoodSum>() {
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ abstract class ExactAFCalc extends AFCalc {
|
|||
}
|
||||
};
|
||||
/**
|
||||
* Sorts {@link ExactAFCalc.LikelihoodSum} instances where those with higher likelihood are first but make sure that
|
||||
* Sorts {@link ExactAFCalculator.LikelihoodSum} instances where those with higher likelihood are first but make sure that
|
||||
* NON_REF alleles are place are last.
|
||||
*/
|
||||
protected static final Comparator<LikelihoodSum> LIKELIHOOD_NON_REF_THEN_SUM_COMPARATOR = new Comparator<LikelihoodSum>() {
|
||||
|
|
@ -84,7 +84,7 @@ abstract class ExactAFCalc extends AFCalc {
|
|||
}
|
||||
};
|
||||
/**
|
||||
* Sorts {@link ExactAFCalc.LikelihoodSum} instances where those with lower alternative allele index are first regardless of
|
||||
* Sorts {@link ExactAFCalculator.LikelihoodSum} instances where those with lower alternative allele index are first regardless of
|
||||
* the likelihood sum.
|
||||
*/
|
||||
protected static final Comparator<LikelihoodSum> LIKELIHOOD_INDEX_COMPARATOR = new Comparator<LikelihoodSum>() {
|
||||
|
|
@ -94,7 +94,7 @@ abstract class ExactAFCalc extends AFCalc {
|
|||
}
|
||||
};
|
||||
|
||||
protected ExactAFCalc() {
|
||||
protected ExactAFCalculator() {
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -83,9 +83,9 @@ public class ExactCallLogger implements Cloneable {
|
|||
public static class ExactCall {
|
||||
final VariantContext vc;
|
||||
final long runtime;
|
||||
final AFCalcResult originalCall;
|
||||
final AFCalculationResult originalCall;
|
||||
|
||||
public ExactCall(VariantContext vc, final long runtime, final AFCalcResult originalCall) {
|
||||
public ExactCall(VariantContext vc, final long runtime, final AFCalculationResult originalCall) {
|
||||
this.vc = vc;
|
||||
this.runtime = runtime;
|
||||
this.originalCall = originalCall;
|
||||
|
|
@ -103,7 +103,7 @@ public class ExactCallLogger implements Cloneable {
|
|||
protected final void printCallInfo(final VariantContext vc,
|
||||
final double[] log10AlleleFrequencyPriors,
|
||||
final long runtimeNano,
|
||||
final AFCalcResult result) {
|
||||
final AFCalculationResult result) {
|
||||
printCallElement(vc, "type", "ignore", vc.getType());
|
||||
|
||||
int allelei = 0;
|
||||
|
|
@ -194,7 +194,7 @@ public class ExactCallLogger implements Cloneable {
|
|||
builder.chr(currentLoc.getContig()).start(currentLoc.getStart()).stop(stop);
|
||||
builder.genotypes(genotypes);
|
||||
final int[] mleInts = ArrayUtils.toPrimitive(mle.toArray(new Integer[]{}));
|
||||
final AFCalcResult result = new AFCalcResult(mleInts, 1, alleles, posteriors, priors, log10pRefByAllele);
|
||||
final AFCalculationResult result = new AFCalculationResult(mleInts, 1, alleles, posteriors, priors, log10pRefByAllele);
|
||||
calls.add(new ExactCall(builder.make(), runtimeNano, result));
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ import org.broadinstitute.gatk.engine.arguments.StandardCallerArgumentCollection
|
|||
*/
|
||||
public class FixedAFCalculatorProvider extends AFCalculatorProvider {
|
||||
|
||||
private final AFCalc singleton;
|
||||
private final AFCalculator singleton;
|
||||
|
||||
private final boolean verifyRequests;
|
||||
|
||||
|
|
@ -135,7 +135,7 @@ public class FixedAFCalculatorProvider extends AFCalculatorProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AFCalc getInstance(final VariantContext vc, final int defaultPloidy, final int maximumAlleleCount) {
|
||||
public AFCalculator getInstance(final VariantContext vc, final int defaultPloidy, final int maximumAlleleCount) {
|
||||
if (verifyRequests)
|
||||
// supers implementation will call eventually one of the other methods, so no need to verify anything here.
|
||||
return super.getInstance(vc,defaultPloidy,maximumAlleleCount);
|
||||
|
|
@ -143,7 +143,7 @@ public class FixedAFCalculatorProvider extends AFCalculatorProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AFCalc getInstance(final int ploidy, final int maxAltAlleleCount) {
|
||||
public AFCalculator getInstance(final int ploidy, final int maxAltAlleleCount) {
|
||||
if (verifyRequests) {
|
||||
if (this.ploidy != AFCalculatorImplementation.UNBOUND_PLOIDY && ploidy != this.ploidy)
|
||||
throw new IllegalStateException("non-supported ploidy");
|
||||
|
|
|
|||
|
|
@ -57,14 +57,14 @@ import org.broadinstitute.gatk.utils.variant.GATKVariantContextUtils;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
public class GeneralPloidyExactAFCalc extends ExactAFCalc {
|
||||
public class GeneralPloidyExactAFCalculator extends ExactAFCalculator {
|
||||
|
||||
static final int MAX_LENGTH_FOR_POOL_PL_LOGGING = 100; // if PL vectors longer than this # of elements, don't log them
|
||||
|
||||
|
||||
private final static boolean VERBOSE = false;
|
||||
|
||||
protected GeneralPloidyExactAFCalc() {
|
||||
protected GeneralPloidyExactAFCalculator() {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -73,7 +73,7 @@ public class GeneralPloidyExactAFCalc extends ExactAFCalc {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected AFCalcResult computeLog10PNonRef(final VariantContext vc, final int defaultPloidy, final double[] log10AlleleFrequencyPriors, final StateTracker stateTracker) {
|
||||
protected AFCalculationResult computeLog10PNonRef(final VariantContext vc, final int defaultPloidy, final double[] log10AlleleFrequencyPriors, final StateTracker stateTracker) {
|
||||
combineSinglePools(vc.getGenotypes(), defaultPloidy, vc.getNAlleles(), log10AlleleFrequencyPriors);
|
||||
return getResultFromFinalState(vc, log10AlleleFrequencyPriors, stateTracker);
|
||||
}
|
||||
|
|
@ -58,9 +58,9 @@ import org.broadinstitute.gatk.engine.arguments.GenotypeCalculationArgumentColle
|
|||
*/
|
||||
public class GeneralPloidyFailOverAFCalculatorProvider extends AFCalculatorProvider {
|
||||
|
||||
private final AFCalc preferred;
|
||||
private final AFCalculator preferred;
|
||||
private final AFCalculatorImplementation preferredImplementation;
|
||||
private final AFCalc failOver;
|
||||
private final AFCalculator failOver;
|
||||
|
||||
/**
|
||||
* Creates a new AF calculator provider given the genotyping arguments and logger reference.
|
||||
|
|
@ -86,7 +86,7 @@ public class GeneralPloidyFailOverAFCalculatorProvider extends AFCalculatorProvi
|
|||
* @return {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public AFCalc getInstance(final int ploidy, final int maximumAlternativeAlleles) {
|
||||
public AFCalculator getInstance(final int ploidy, final int maximumAlternativeAlleles) {
|
||||
return preferredImplementation.usableForParams(ploidy,maximumAlternativeAlleles) ? preferred : failOver;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ import java.util.*;
|
|||
* as P(D | AF_* == 0) = prod_i P (D | AF_i == 0), after applying the theta^i
|
||||
* prior for the ith least likely allele.
|
||||
*/
|
||||
public class IndependentAllelesDiploidExactAFCalc extends DiploidExactAFCalc {
|
||||
public class IndependentAllelesDiploidExactAFCalculator extends DiploidExactAFCalculator {
|
||||
|
||||
/**
|
||||
* The min. confidence of an allele to be included in the joint posterior.
|
||||
|
|
@ -121,9 +121,9 @@ import java.util.*;
|
|||
/**
|
||||
* Sorts AFCalcResults by their posteriors of AF > 0, so the
|
||||
*/
|
||||
private final static class CompareAFCalculatorResultsByPNonRef implements Comparator<AFCalcResult> {
|
||||
private final static class CompareAFCalculatorResultsByPNonRef implements Comparator<AFCalculationResult> {
|
||||
@Override
|
||||
public int compare(AFCalcResult o1, AFCalcResult o2) {
|
||||
public int compare(AFCalculationResult o1, AFCalculationResult o2) {
|
||||
return -1 * Double.compare(o1.getLog10PosteriorOfAFGT0(), o2.getLog10PosteriorOfAFGT0());
|
||||
}
|
||||
}
|
||||
|
|
@ -133,32 +133,32 @@ import java.util.*;
|
|||
/**
|
||||
* The AFCalc model we are using to do the bi-allelic computation
|
||||
*/
|
||||
final AFCalc biAlleleExactModel;
|
||||
final AFCalculator biAlleleExactModel;
|
||||
|
||||
protected IndependentAllelesDiploidExactAFCalc() {
|
||||
protected IndependentAllelesDiploidExactAFCalculator() {
|
||||
super();
|
||||
biAlleleExactModel = new ReferenceDiploidExactAFCalc();
|
||||
biAlleleExactModel = new ReferenceDiploidExactAFCalculator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Trivial subclass that helps with debugging by keeping track of the supporting information for this joint call
|
||||
*/
|
||||
private static class MyAFCalculationResult extends AFCalcResult {
|
||||
private static class MyAFCalculationResult extends AFCalculationResult {
|
||||
/**
|
||||
* List of the supporting bi-allelic AFCalcResults that went into making this multi-allelic joint call
|
||||
*/
|
||||
final List<AFCalcResult> supporting;
|
||||
final List<AFCalculationResult> supporting;
|
||||
|
||||
private MyAFCalculationResult(int[] alleleCountsOfMLE, int nEvaluations, List<Allele> allelesUsedInGenotyping, double[] log10LikelihoodsOfAC, double[] log10PriorsOfAC, Map<Allele, Double> log10pRefByAllele, List<AFCalcResult> supporting) {
|
||||
private MyAFCalculationResult(int[] alleleCountsOfMLE, int nEvaluations, List<Allele> allelesUsedInGenotyping, double[] log10LikelihoodsOfAC, double[] log10PriorsOfAC, Map<Allele, Double> log10pRefByAllele, List<AFCalculationResult> supporting) {
|
||||
super(alleleCountsOfMLE, nEvaluations, allelesUsedInGenotyping, log10LikelihoodsOfAC, log10PriorsOfAC, log10pRefByAllele);
|
||||
this.supporting = supporting;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AFCalcResult computeLog10PNonRef(final VariantContext vc, final int defaultPloidy,
|
||||
public AFCalculationResult computeLog10PNonRef(final VariantContext vc, final int defaultPloidy,
|
||||
final double[] log10AlleleFrequencyPriors, final StateTracker stateTracker) {
|
||||
final List<AFCalcResult> independentResultTrackers = computeAlleleIndependentExact(vc, defaultPloidy, log10AlleleFrequencyPriors);
|
||||
final List<AFCalculationResult> independentResultTrackers = computeAlleleIndependentExact(vc, defaultPloidy, log10AlleleFrequencyPriors);
|
||||
|
||||
if ( independentResultTrackers.size() == 0 )
|
||||
throw new IllegalStateException("Independent alleles model returned an empty list of results at VC " + vc);
|
||||
|
|
@ -168,7 +168,7 @@ import java.util.*;
|
|||
return independentResultTrackers.get(0);
|
||||
} else {
|
||||
// we are a multi-allelic, so we need to actually combine the results
|
||||
final List<AFCalcResult> withMultiAllelicPriors = applyMultiAllelicPriors(independentResultTrackers);
|
||||
final List<AFCalculationResult> withMultiAllelicPriors = applyMultiAllelicPriors(independentResultTrackers);
|
||||
return combineIndependentPNonRefs(vc, withMultiAllelicPriors);
|
||||
}
|
||||
}
|
||||
|
|
@ -183,12 +183,12 @@ import java.util.*;
|
|||
*/
|
||||
@Requires({"vc != null", "log10AlleleFrequencyPriors != null"})
|
||||
@Ensures("goodIndependentResult(vc, result)")
|
||||
protected final List<AFCalcResult> computeAlleleIndependentExact(final VariantContext vc, final int defaultPloidy,
|
||||
protected final List<AFCalculationResult> computeAlleleIndependentExact(final VariantContext vc, final int defaultPloidy,
|
||||
final double[] log10AlleleFrequencyPriors) {
|
||||
final List<AFCalcResult> results = new LinkedList<AFCalcResult>();
|
||||
final List<AFCalculationResult> results = new LinkedList<AFCalculationResult>();
|
||||
|
||||
for ( final VariantContext subvc : makeAlleleConditionalContexts(vc) ) {
|
||||
final AFCalcResult resultTracker = biAlleleExactModel.getLog10PNonRef(subvc, defaultPloidy, vc.getNAlleles() - 1, log10AlleleFrequencyPriors);
|
||||
final AFCalculationResult resultTracker = biAlleleExactModel.getLog10PNonRef(subvc, defaultPloidy, vc.getNAlleles() - 1, log10AlleleFrequencyPriors);
|
||||
results.add(resultTracker);
|
||||
}
|
||||
|
||||
|
|
@ -198,7 +198,7 @@ import java.util.*;
|
|||
/**
|
||||
* Helper function to ensure that the computeAlleleIndependentExact is returning reasonable results
|
||||
*/
|
||||
private static boolean goodIndependentResult(final VariantContext vc, final List<AFCalcResult> results) {
|
||||
private static boolean goodIndependentResult(final VariantContext vc, final List<AFCalculationResult> results) {
|
||||
if ( results.size() != vc.getNAlleles() - 1) return false;
|
||||
for ( int i = 0; i < results.size(); i++ ) {
|
||||
if ( results.get(i).getAllelesUsedInGenotyping().size() != 2 )
|
||||
|
|
@ -389,8 +389,8 @@ import java.util.*;
|
|||
return new GenotypeBuilder(original).PL(GLs).alleles(BIALLELIC_NOCALL).make();
|
||||
}
|
||||
|
||||
protected final List<AFCalcResult> applyMultiAllelicPriors(final List<AFCalcResult> conditionalPNonRefResults) {
|
||||
final ArrayList<AFCalcResult> sorted = new ArrayList<AFCalcResult>(conditionalPNonRefResults);
|
||||
protected final List<AFCalculationResult> applyMultiAllelicPriors(final List<AFCalculationResult> conditionalPNonRefResults) {
|
||||
final ArrayList<AFCalculationResult> sorted = new ArrayList<AFCalculationResult>(conditionalPNonRefResults);
|
||||
|
||||
// sort the results, so the most likely allele is first
|
||||
Collections.sort(sorted, compareAFCalcResultsByPNonRef);
|
||||
|
|
@ -426,8 +426,8 @@ import java.util.*;
|
|||
*
|
||||
* @param sortedResultsWithThetaNPriors the pNonRef result for each allele independently
|
||||
*/
|
||||
protected AFCalcResult combineIndependentPNonRefs(final VariantContext vc,
|
||||
final List<AFCalcResult> sortedResultsWithThetaNPriors) {
|
||||
protected AFCalculationResult combineIndependentPNonRefs(final VariantContext vc,
|
||||
final List<AFCalculationResult> sortedResultsWithThetaNPriors) {
|
||||
int nEvaluations = 0;
|
||||
final int nAltAlleles = sortedResultsWithThetaNPriors.size();
|
||||
final int[] alleleCountsOfMLE = new int[nAltAlleles];
|
||||
|
|
@ -439,7 +439,7 @@ import java.util.*;
|
|||
double log10PosteriorOfACGt0Sum = 0.0;
|
||||
|
||||
boolean anyPoly = false;
|
||||
for ( final AFCalcResult sortedResultWithThetaNPriors : sortedResultsWithThetaNPriors ) {
|
||||
for ( final AFCalculationResult sortedResultWithThetaNPriors : sortedResultsWithThetaNPriors ) {
|
||||
final Allele altAllele = sortedResultWithThetaNPriors.getAllelesUsedInGenotyping().get(1);
|
||||
final int altI = vc.getAlleles().indexOf(altAllele) - 1;
|
||||
|
||||
|
|
@ -58,12 +58,12 @@ import java.util.Map;
|
|||
/**
|
||||
* Original bi-allelic ~O(N) implementation. Kept here for posterity and reference
|
||||
*/
|
||||
class OriginalDiploidExactAFCalc extends DiploidExactAFCalc {
|
||||
protected OriginalDiploidExactAFCalc() {
|
||||
class OriginalDiploidExactAFCalculator extends DiploidExactAFCalculator {
|
||||
protected OriginalDiploidExactAFCalculator() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AFCalcResult computeLog10PNonRef(final VariantContext vc,
|
||||
protected AFCalculationResult computeLog10PNonRef(final VariantContext vc,
|
||||
@SuppressWarnings("unused")
|
||||
final int defaultPloidy,
|
||||
final double[] log10AlleleFrequencyPriors,
|
||||
|
|
@ -82,7 +82,7 @@ class OriginalDiploidExactAFCalc extends DiploidExactAFCalc {
|
|||
final double log10PRef = log10Posteriors[1] > log10Posteriors[0] ? MathUtils.LOG10_P_OF_ZERO : 0.0;
|
||||
final Map<Allele, Double> log10pRefByAllele = Collections.singletonMap(vc.getAlternateAllele(0), log10PRef);
|
||||
|
||||
return new AFCalcResult(new int[]{mleK}, 0, vc.getAlleles(),
|
||||
return new AFCalculationResult(new int[]{mleK}, 0, vc.getAlleles(),
|
||||
MathUtils.normalizeFromLog10(log10Likelihoods, true),
|
||||
MathUtils.normalizeFromLog10(log10Priors, true),
|
||||
log10pRefByAllele);
|
||||
|
|
@ -46,7 +46,7 @@
|
|||
|
||||
package org.broadinstitute.gatk.tools.walkers.genotyper.afcalc;
|
||||
|
||||
public class ReferenceDiploidExactAFCalc extends DiploidExactAFCalc {
|
||||
protected ReferenceDiploidExactAFCalc() {
|
||||
public class ReferenceDiploidExactAFCalculator extends DiploidExactAFCalculator {
|
||||
protected ReferenceDiploidExactAFCalculator() {
|
||||
}
|
||||
}
|
||||
|
|
@ -212,7 +212,7 @@ final class StateTracker {
|
|||
* @return an AFCalcResult summarizing the final results of this calculation
|
||||
*/
|
||||
@Requires("allelesUsedInGenotyping != null")
|
||||
protected AFCalcResult toAFCalcResult(final double[] log10PriorsByAC) {
|
||||
protected AFCalculationResult toAFCalculationResult(final double[] log10PriorsByAC) {
|
||||
final int [] subACOfMLE = Arrays.copyOf(alleleCountsOfMLE, allelesUsedInGenotyping.size() - 1);
|
||||
final double[] log10Likelihoods = MathUtils.normalizeFromLog10(new double[]{getLog10LikelihoodOfAFzero(), getLog10LikelihoodOfAFNotZero()}, true);
|
||||
final double[] log10Priors = MathUtils.normalizeFromLog10(new double[]{log10PriorsByAC[0], MathUtils.log10sumLog10(log10PriorsByAC, 1)}, true);
|
||||
|
|
@ -224,7 +224,7 @@ final class StateTracker {
|
|||
log10pRefByAllele.put(allele, log10PRef);
|
||||
}
|
||||
|
||||
return new AFCalcResult(subACOfMLE, nEvaluations, allelesUsedInGenotyping, log10Likelihoods, log10Priors, log10pRefByAllele);
|
||||
return new AFCalculationResult(subACOfMLE, nEvaluations, allelesUsedInGenotyping, log10Likelihoods, log10Priors, log10pRefByAllele);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -47,9 +47,9 @@
|
|||
package org.broadinstitute.gatk.tools.walkers.validation.validationsiteselector;
|
||||
|
||||
import htsjdk.variant.variantcontext.VariantContext;
|
||||
import org.broadinstitute.gatk.tools.walkers.genotyper.afcalc.AFCalc;
|
||||
import org.broadinstitute.gatk.tools.walkers.genotyper.afcalc.AFCalcFactory;
|
||||
import org.broadinstitute.gatk.tools.walkers.genotyper.afcalc.AFCalcResult;
|
||||
import org.broadinstitute.gatk.tools.walkers.genotyper.afcalc.AFCalculator;
|
||||
import org.broadinstitute.gatk.tools.walkers.genotyper.afcalc.AFCalculatorFactory;
|
||||
import org.broadinstitute.gatk.tools.walkers.genotyper.afcalc.AFCalculationResult;
|
||||
import org.broadinstitute.gatk.utils.variant.HomoSapiensConstants;
|
||||
|
||||
import java.util.TreeSet;
|
||||
|
|
@ -59,7 +59,7 @@ public class GLBasedSampleSelector extends SampleSelector {
|
|||
private static final int MAX_ALT_ALLELES = 4;
|
||||
double[] flatPriors = null;
|
||||
final double referenceLikelihood;
|
||||
AFCalc afCalculator;
|
||||
AFCalculator afCalculator;
|
||||
|
||||
public GLBasedSampleSelector(TreeSet<String> sm, double refLik) {
|
||||
super(sm);
|
||||
|
|
@ -80,9 +80,9 @@ public class GLBasedSampleSelector extends SampleSelector {
|
|||
// do we want to apply a prior? maybe user-spec?
|
||||
if ( flatPriors == null ) {
|
||||
flatPriors = new double[1+2*samples.size()];
|
||||
afCalculator = AFCalcFactory.createCalculator(samples.size(), MAX_ALT_ALLELES, HomoSapiensConstants.DEFAULT_PLOIDY);
|
||||
afCalculator = AFCalculatorFactory.createCalculator(samples.size(), MAX_ALT_ALLELES, HomoSapiensConstants.DEFAULT_PLOIDY);
|
||||
}
|
||||
final AFCalcResult result = afCalculator.getLog10PNonRef(subContext, HomoSapiensConstants.DEFAULT_PLOIDY, MAX_ALT_ALLELES, flatPriors);
|
||||
final AFCalculationResult result = afCalculator.getLog10PNonRef(subContext, HomoSapiensConstants.DEFAULT_PLOIDY, MAX_ALT_ALLELES, flatPriors);
|
||||
// do we want to let this qual go up or down?
|
||||
if ( result.getLog10LikelihoodOfAFEq0() < referenceLikelihood ) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ import org.testng.annotations.Test;
|
|||
import java.util.*;
|
||||
|
||||
|
||||
public class AFCalcUnitTest extends BaseTest {
|
||||
public class AFCalculationUnitTest extends BaseTest {
|
||||
static Allele A = Allele.create("A", true);
|
||||
static Allele C = Allele.create("C");
|
||||
static Allele G = Allele.create("G");
|
||||
|
|
@ -77,17 +77,17 @@ public class AFCalcUnitTest extends BaseTest {
|
|||
final private static boolean Guillermo_FIXME = false; // TODO -- can only be enabled when GdA fixes bug
|
||||
final private static boolean DEBUG_ONLY = false;
|
||||
|
||||
protected static List<AFCalc> createAFCalculators(final List<AFCalculatorImplementation> calcs, final int maxAltAlleles, final int ploidy) {
|
||||
final List<AFCalc> AFCalcs = new LinkedList<>();
|
||||
protected static List<AFCalculator> createAFCalculators(final List<AFCalculatorImplementation> calcs, final int maxAltAlleles, final int ploidy) {
|
||||
final List<AFCalculator> AFCalculators = new LinkedList<>();
|
||||
|
||||
for ( final AFCalculatorImplementation calc : calcs ) {
|
||||
if (calc.usableForParams(ploidy,maxAltAlleles))
|
||||
AFCalcs.add(calc.newInstance());
|
||||
AFCalculators.add(calc.newInstance());
|
||||
else
|
||||
throw new IllegalStateException("cannot use " + calc + " calculator instance with combination " + maxAltAlleles + " " + ploidy);
|
||||
}
|
||||
|
||||
return AFCalcs;
|
||||
return AFCalculators;
|
||||
}
|
||||
|
||||
@BeforeSuite
|
||||
|
|
@ -116,12 +116,12 @@ public class AFCalcUnitTest extends BaseTest {
|
|||
private class GetGLsTest extends TestDataProvider {
|
||||
GenotypesContext GLs;
|
||||
int numAltAlleles;
|
||||
final AFCalc calc;
|
||||
final AFCalculator calc;
|
||||
final int[] expectedACs;
|
||||
final double[] priors;
|
||||
final String priorName;
|
||||
|
||||
private GetGLsTest(final AFCalc calc, int numAltAlleles, List<Genotype> arg, final double[] priors, final String priorName) {
|
||||
private GetGLsTest(final AFCalculator calc, int numAltAlleles, List<Genotype> arg, final double[] priors, final String priorName) {
|
||||
super(GetGLsTest.class);
|
||||
GLs = GenotypesContext.create(new ArrayList<>(arg));
|
||||
this.numAltAlleles = numAltAlleles;
|
||||
|
|
@ -139,12 +139,12 @@ public class AFCalcUnitTest extends BaseTest {
|
|||
}
|
||||
}
|
||||
|
||||
public AFCalcResult execute() {
|
||||
public AFCalculationResult execute() {
|
||||
return getCalc().getLog10PNonRef(getVC(), HomoSapiensConstants.DEFAULT_PLOIDY, numAltAlleles, getPriors());
|
||||
}
|
||||
|
||||
public AFCalcResult executeRef() {
|
||||
final AFCalc ref = AFCalculatorImplementation.EXACT_REFERENCE.newInstance();
|
||||
public AFCalculationResult executeRef() {
|
||||
final AFCalculator ref = AFCalculatorImplementation.EXACT_REFERENCE.newInstance();
|
||||
return ref.getLog10PNonRef(getVC(), HomoSapiensConstants.DEFAULT_PLOIDY, numAltAlleles, getPriors());
|
||||
}
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ public class AFCalcUnitTest extends BaseTest {
|
|||
return priors;
|
||||
}
|
||||
|
||||
public AFCalc getCalc() {
|
||||
public AFCalculator getCalc() {
|
||||
return calc;
|
||||
}
|
||||
|
||||
|
|
@ -190,7 +190,7 @@ public class AFCalcUnitTest extends BaseTest {
|
|||
final List<Genotype> triAllelicSamples = Arrays.asList(AA2, AB2, BB2, AC2, BC2, CC2);
|
||||
|
||||
for ( final int nSamples : Arrays.asList(1, 2, 3, 4) ) {
|
||||
List<AFCalc> calcs = createAFCalculators(Arrays.asList(AFCalculatorImplementation.values()), MAX_ALT_ALLELES, PLOIDY);
|
||||
List<AFCalculator> calcs = createAFCalculators(Arrays.asList(AFCalculatorImplementation.values()), MAX_ALT_ALLELES, PLOIDY);
|
||||
|
||||
final int nPriorValues = 2*nSamples+1;
|
||||
final double[] flatPriors = MathUtils.normalizeFromLog10(new double[nPriorValues], true); // flat priors
|
||||
|
|
@ -198,7 +198,7 @@ public class AFCalcUnitTest extends BaseTest {
|
|||
UnifiedGenotypingEngine.computeAlleleFrequencyPriors(nPriorValues - 1, humanPriors, 0.001, new ArrayList<Double>());
|
||||
|
||||
for ( final double[] priors : Arrays.asList(flatPriors, humanPriors) ) { // , humanPriors) ) {
|
||||
for ( AFCalc model : calcs ) {
|
||||
for ( AFCalculator model : calcs ) {
|
||||
final String priorName = priors == humanPriors ? "human" : "flat";
|
||||
|
||||
// bi-allelic
|
||||
|
|
@ -207,7 +207,7 @@ public class AFCalcUnitTest extends BaseTest {
|
|||
new GetGLsTest(model, 1, genotypes, priors, priorName);
|
||||
|
||||
// tri-allelic
|
||||
if ( INCLUDE_TRIALLELIC && ( ! priorName.equals("human") || Guillermo_FIXME ) && ! ( model instanceof OriginalDiploidExactAFCalc) ) // || model != generalCalc ) )
|
||||
if ( INCLUDE_TRIALLELIC && ( ! priorName.equals("human") || Guillermo_FIXME ) && ! ( model instanceof OriginalDiploidExactAFCalculator) ) // || model != generalCalc ) )
|
||||
for ( List<Genotype> genotypes : Utils.makePermutations(triAllelicSamples, nSamples, true) )
|
||||
new GetGLsTest(model, 2, genotypes, priors, priorName);
|
||||
}
|
||||
|
|
@ -280,12 +280,12 @@ public class AFCalcUnitTest extends BaseTest {
|
|||
samples.addAll(Collections.nCopies(nNonInformative, testData.nonInformative));
|
||||
|
||||
final int nSamples = samples.size();
|
||||
List<AFCalc> calcs = createAFCalculators(Arrays.asList(AFCalculatorImplementation.values()), MAX_ALT_ALLELES, PLOIDY);
|
||||
List<AFCalculator> calcs = createAFCalculators(Arrays.asList(AFCalculatorImplementation.values()), MAX_ALT_ALLELES, PLOIDY);
|
||||
|
||||
final double[] priors = MathUtils.normalizeFromLog10(new double[2*nSamples+1], true); // flat priors
|
||||
|
||||
for ( AFCalc model : calcs ) {
|
||||
if ( testData.nAltAlleles > 1 && model instanceof OriginalDiploidExactAFCalc)
|
||||
for ( AFCalculator model : calcs ) {
|
||||
if ( testData.nAltAlleles > 1 && model instanceof OriginalDiploidExactAFCalculator)
|
||||
continue;
|
||||
|
||||
final GetGLsTest onlyInformative = new GetGLsTest(model, testData.nAltAlleles, testData.called, priors, "flat");
|
||||
|
|
@ -304,16 +304,16 @@ public class AFCalcUnitTest extends BaseTest {
|
|||
|
||||
@Test(enabled = true && ! DEBUG_ONLY, dataProvider = "GLsWithNonInformative", dependsOnMethods = {"testBiallelicGLs", "testTriallelicGLs"})
|
||||
public void testGLsWithNonInformative(GetGLsTest onlyInformative, GetGLsTest withNonInformative) {
|
||||
final AFCalcResult expected = onlyInformative.execute();
|
||||
final AFCalcResult actual = withNonInformative.execute();
|
||||
final AFCalculationResult expected = onlyInformative.execute();
|
||||
final AFCalculationResult actual = withNonInformative.execute();
|
||||
|
||||
testResultSimple(withNonInformative);
|
||||
compareAFCalcResults(actual, expected, onlyInformative.getCalc(), onlyInformative.numAltAlleles, true);
|
||||
}
|
||||
|
||||
private void testResultSimple(final GetGLsTest cfg) {
|
||||
final AFCalcResult refResultTracker = cfg.executeRef();
|
||||
final AFCalcResult resultTracker = cfg.execute();
|
||||
final AFCalculationResult refResultTracker = cfg.executeRef();
|
||||
final AFCalculationResult resultTracker = cfg.execute();
|
||||
try {
|
||||
compareAFCalcResults(resultTracker, refResultTracker, cfg.getCalc(), cfg.numAltAlleles, true);
|
||||
} catch (Throwable t) {
|
||||
|
|
@ -332,7 +332,7 @@ public class AFCalcUnitTest extends BaseTest {
|
|||
}
|
||||
}
|
||||
|
||||
private void compareAFCalcResults(final AFCalcResult actual, final AFCalcResult expected, final AFCalc calc, final int maxAltAlleles, final boolean onlyPosteriorsShouldBeEqual) {
|
||||
private void compareAFCalcResults(final AFCalculationResult actual, final AFCalculationResult expected, final AFCalculator calc, final int maxAltAlleles, final boolean onlyPosteriorsShouldBeEqual) {
|
||||
// note we cannot really test the multi-allelic case because we actually meaningfully differ among the models here
|
||||
final double TOLERANCE = maxAltAlleles > 1 ? 1000 : 0.1; // much tighter constraints on bi-allelic results
|
||||
|
||||
|
|
@ -359,23 +359,23 @@ public class AFCalcUnitTest extends BaseTest {
|
|||
}
|
||||
|
||||
@Test(enabled = true && ! DEBUG_ONLY, dataProvider = "Models")
|
||||
public void testLargeGLs(final ExactAFCalc calc) {
|
||||
public void testLargeGLs(final ExactAFCalculator calc) {
|
||||
final Genotype BB = makePL(Arrays.asList(C, C), 20000000, 20000000, 0);
|
||||
GetGLsTest cfg = new GetGLsTest(calc, 1, Arrays.asList(BB, BB, BB), FLAT_3SAMPLE_PRIORS, "flat");
|
||||
|
||||
final AFCalcResult resultTracker = cfg.execute();
|
||||
final AFCalculationResult resultTracker = cfg.execute();
|
||||
|
||||
int calculatedAlleleCount = resultTracker.getAlleleCountsOfMLE()[0];
|
||||
Assert.assertEquals(calculatedAlleleCount, 6);
|
||||
}
|
||||
|
||||
@Test(enabled = true && ! DEBUG_ONLY, dataProvider = "Models")
|
||||
public void testMismatchedGLs(final ExactAFCalc calc) {
|
||||
public void testMismatchedGLs(final ExactAFCalculator calc) {
|
||||
final Genotype AB = makePL(Arrays.asList(A, C), 2000, 0, 2000, 2000, 2000, 2000);
|
||||
final Genotype AC = makePL(Arrays.asList(A, G), 100, 100, 100, 0, 100, 100);
|
||||
GetGLsTest cfg = new GetGLsTest(calc, 2, Arrays.asList(AB, AC), FLAT_3SAMPLE_PRIORS, "flat");
|
||||
|
||||
final AFCalcResult resultTracker = cfg.execute();
|
||||
final AFCalculationResult resultTracker = cfg.execute();
|
||||
|
||||
Assert.assertEquals(resultTracker.getAlleleCountsOfMLE()[0], 1);
|
||||
Assert.assertEquals(resultTracker.getAlleleCountsOfMLE()[1], 1);
|
||||
|
|
@ -433,7 +433,7 @@ public class AFCalcUnitTest extends BaseTest {
|
|||
|
||||
final VariantContext vc2 = new VariantContextBuilder("x","1", 1, 1, Arrays.asList(A, C)).make();
|
||||
final VariantContext vc3 = new VariantContextBuilder("x","1", 1, 1, Arrays.asList(A, C, G)).make();
|
||||
final AFCalcTestBuilder.PriorType priorType = AFCalcTestBuilder.PriorType.flat;
|
||||
final AFCalculatorTestBuilder.PriorType priorType = AFCalculatorTestBuilder.PriorType.flat;
|
||||
|
||||
final double TOLERANCE = 0.5;
|
||||
|
||||
|
|
@ -474,18 +474,18 @@ public class AFCalcUnitTest extends BaseTest {
|
|||
@Test(enabled = true && ! DEBUG_ONLY, dataProvider = "PNonRef")
|
||||
private void testPNonRef(final VariantContext vcRoot,
|
||||
AFCalculatorImplementation modelType,
|
||||
AFCalcTestBuilder.PriorType priorType,
|
||||
AFCalculatorTestBuilder.PriorType priorType,
|
||||
final List<Genotype> genotypes,
|
||||
final double expectedPNonRef,
|
||||
final double tolerance,
|
||||
final int nNonInformative) {
|
||||
final AFCalcTestBuilder testBuilder
|
||||
= new AFCalcTestBuilder(1, vcRoot.getNAlleles()-1, modelType, priorType);
|
||||
final AFCalculatorTestBuilder testBuilder
|
||||
= new AFCalculatorTestBuilder(1, vcRoot.getNAlleles()-1, modelType, priorType);
|
||||
|
||||
final VariantContextBuilder vcb = new VariantContextBuilder(vcRoot);
|
||||
vcb.genotypes(genotypes);
|
||||
|
||||
final AFCalcResult resultTracker = testBuilder.makeModel().getLog10PNonRef(vcb.make(), PLOIDY, MAX_ALT_ALLELES, testBuilder.makePriors());
|
||||
final AFCalculationResult resultTracker = testBuilder.makeModel().getLog10PNonRef(vcb.make(), PLOIDY, MAX_ALT_ALLELES, testBuilder.makePriors());
|
||||
|
||||
Assert.assertEquals(resultTracker.getLog10PosteriorOfAFGT0(), Math.log10(expectedPNonRef), tolerance,
|
||||
"Actual pNonRef not within tolerance " + tolerance + " of expected");
|
||||
|
|
@ -563,14 +563,14 @@ public class AFCalcUnitTest extends BaseTest {
|
|||
@Test(enabled = true && ! DEBUG_ONLY, dataProvider = "PNonRefBiallelicSystematic")
|
||||
private void PNonRefBiallelicSystematic(AFCalculatorImplementation modelType, final List<Genotype> genotypes) {
|
||||
//logger.warn("Running " + modelType + " with " + genotypes);
|
||||
final AFCalcTestBuilder refBuilder = new AFCalcTestBuilder(genotypes.size(), 1, AFCalculatorImplementation.EXACT_REFERENCE, AFCalcTestBuilder.PriorType.human);
|
||||
final AFCalcTestBuilder testBuilder = new AFCalcTestBuilder(genotypes.size(), 1, modelType, AFCalcTestBuilder.PriorType.human);
|
||||
final AFCalculatorTestBuilder refBuilder = new AFCalculatorTestBuilder(genotypes.size(), 1, AFCalculatorImplementation.EXACT_REFERENCE, AFCalculatorTestBuilder.PriorType.human);
|
||||
final AFCalculatorTestBuilder testBuilder = new AFCalculatorTestBuilder(genotypes.size(), 1, modelType, AFCalculatorTestBuilder.PriorType.human);
|
||||
|
||||
final VariantContextBuilder vcb = new VariantContextBuilder("x", "1", 1, 1, Arrays.asList(A, C));
|
||||
vcb.genotypes(genotypes);
|
||||
|
||||
final AFCalcResult refResult = refBuilder.makeModel().getLog10PNonRef(vcb.make(), PLOIDY, MAX_ALT_ALLELES, testBuilder.makePriors());
|
||||
final AFCalcResult testResult = testBuilder.makeModel().getLog10PNonRef(vcb.make(), PLOIDY, MAX_ALT_ALLELES, testBuilder.makePriors());
|
||||
final AFCalculationResult refResult = refBuilder.makeModel().getLog10PNonRef(vcb.make(), PLOIDY, MAX_ALT_ALLELES, testBuilder.makePriors());
|
||||
final AFCalculationResult testResult = testBuilder.makeModel().getLog10PNonRef(vcb.make(), PLOIDY, MAX_ALT_ALLELES, testBuilder.makePriors());
|
||||
|
||||
final double tolerance = 1e-3;
|
||||
Assert.assertEquals(testResult.getLog10PosteriorOfAFGT0(), refResult.getLog10PosteriorOfAFGT0(), tolerance,
|
||||
|
|
@ -591,7 +591,7 @@ public class AFCalcUnitTest extends BaseTest {
|
|||
|
||||
for ( final AFCalculatorImplementation calc : AFCalculatorImplementation.values() ) {
|
||||
if ( calc.usableForParams(2, 4) )
|
||||
tests.add(new Object[]{AFCalcFactory.createCalculatorForDiploidAnalysis()});
|
||||
tests.add(new Object[]{AFCalculatorFactory.createCalculatorForDiploidAnalysis()});
|
||||
}
|
||||
|
||||
return tests.toArray(new Object[][]{});
|
||||
|
|
@ -599,7 +599,7 @@ public class AFCalcUnitTest extends BaseTest {
|
|||
|
||||
|
||||
@Test(enabled = true, dataProvider = "Models")
|
||||
public void testNoPrior(final AFCalc model) {
|
||||
public void testNoPrior(final AFCalculator model) {
|
||||
for ( int REF_PL = 10; REF_PL <= 20; REF_PL += 10 ) {
|
||||
final Genotype AB = makePL(Arrays.asList(A,C), REF_PL, 0, 10000);
|
||||
|
||||
|
|
@ -614,8 +614,8 @@ public class AFCalcUnitTest extends BaseTest {
|
|||
|
||||
GetGLsTest cfgFlatPrior = new GetGLsTest(model, 1, Arrays.asList(AB), flatPriors, "flatPrior");
|
||||
GetGLsTest cfgNoPrior = new GetGLsTest(model, 1, Arrays.asList(AB), flatPriors, "noPrior");
|
||||
final AFCalcResult resultTrackerFlat = cfgFlatPrior.execute();
|
||||
final AFCalcResult resultTrackerNoPrior = cfgNoPrior.execute();
|
||||
final AFCalculationResult resultTrackerFlat = cfgFlatPrior.execute();
|
||||
final AFCalculationResult resultTrackerNoPrior = cfgNoPrior.execute();
|
||||
|
||||
final double pRefWithNoPrior = AB.getLikelihoods().getAsVector()[0];
|
||||
final double pHetWithNoPrior = AB.getLikelihoods().getAsVector()[1] - Math.log10(0.5);
|
||||
|
|
@ -631,7 +631,7 @@ public class AFCalcUnitTest extends BaseTest {
|
|||
}
|
||||
|
||||
@Test(enabled = true && !DEBUG_ONLY, dataProvider = "Models")
|
||||
public void testBiallelicPriors(final AFCalc model) {
|
||||
public void testBiallelicPriors(final AFCalculator model) {
|
||||
|
||||
for ( int REF_PL = 10; REF_PL <= 20; REF_PL += 10 ) {
|
||||
final Genotype AB = makePL(Arrays.asList(A,C), REF_PL, 0, 10000);
|
||||
|
|
@ -642,7 +642,7 @@ public class AFCalcUnitTest extends BaseTest {
|
|||
final double[] priors = MathUtils.normalizeFromLog10(MathUtils.toLog10(new double[]{refPrior, nonRefPrior, nonRefPrior}), true);
|
||||
if ( ! Double.isInfinite(priors[1]) ) {
|
||||
GetGLsTest cfg = new GetGLsTest(model, 1, Arrays.asList(AB), priors, "pNonRef" + log10NonRefPrior);
|
||||
final AFCalcResult resultTracker = cfg.execute();
|
||||
final AFCalculationResult resultTracker = cfg.execute();
|
||||
final int actualAC = resultTracker.getAlleleCountsOfMLE()[0];
|
||||
|
||||
final double pRefWithPrior = AB.getLikelihoods().getAsVector()[0] + priors[0];
|
||||
|
|
@ -700,8 +700,8 @@ public class AFCalcUnitTest extends BaseTest {
|
|||
|
||||
// bi-allelic tests
|
||||
{
|
||||
final AFCalcTestBuilder testBuilder
|
||||
= new AFCalcTestBuilder(nSamples, 1, model, AFCalcTestBuilder.PriorType.human);
|
||||
final AFCalculatorTestBuilder testBuilder
|
||||
= new AFCalculatorTestBuilder(nSamples, 1, model, AFCalculatorTestBuilder.PriorType.human);
|
||||
final List<Integer> ACs = Arrays.asList(allele1AC);
|
||||
tests.add(new Object[]{testBuilder, ACs, nonTypePLs, Arrays.asList(poly1)});
|
||||
}
|
||||
|
|
@ -711,8 +711,8 @@ public class AFCalcUnitTest extends BaseTest {
|
|||
if ( nSamples < allele2AC || allele1AC + allele2AC > nSamples || nSamples > 100 || nSamples == 1)
|
||||
continue;
|
||||
|
||||
final AFCalcTestBuilder testBuilder
|
||||
= new AFCalcTestBuilder(nSamples, 2, model, AFCalcTestBuilder.PriorType.human);
|
||||
final AFCalculatorTestBuilder testBuilder
|
||||
= new AFCalculatorTestBuilder(nSamples, 2, model, AFCalculatorTestBuilder.PriorType.human);
|
||||
final List<Integer> ACs = Arrays.asList(allele1AC, allele2AC);
|
||||
final boolean poly2 = allele2AC > errorFreq && (nonTypePLs * allele2AC) > 90;
|
||||
tests.add(new Object[]{testBuilder, ACs, nonTypePLs, Arrays.asList(poly1, poly2)});
|
||||
|
|
@ -726,7 +726,7 @@ public class AFCalcUnitTest extends BaseTest {
|
|||
}
|
||||
|
||||
@Test(enabled = true && ! DEBUG_ONLY, dataProvider = "polyTestProvider")
|
||||
public void testCallingGeneral(final AFCalcTestBuilder testBuilder, final List<Integer> ACs, final int nonTypePL, final List<Boolean> expectedPoly ) {
|
||||
public void testCallingGeneral(final AFCalculatorTestBuilder testBuilder, final List<Integer> ACs, final int nonTypePL, final List<Boolean> expectedPoly ) {
|
||||
testCalling(testBuilder, ACs, nonTypePL, expectedPoly);
|
||||
}
|
||||
|
||||
|
|
@ -749,8 +749,8 @@ public class AFCalcUnitTest extends BaseTest {
|
|||
final double acSum = MathUtils.sum(ACs);
|
||||
for ( final int nSamples : Arrays.asList(1, 10, 100) ) {
|
||||
if ( nSamples < acSum ) continue;
|
||||
final AFCalcTestBuilder testBuilder
|
||||
= new AFCalcTestBuilder(nSamples, nAlleles, model, AFCalcTestBuilder.PriorType.human);
|
||||
final AFCalculatorTestBuilder testBuilder
|
||||
= new AFCalculatorTestBuilder(nSamples, nAlleles, model, AFCalculatorTestBuilder.PriorType.human);
|
||||
tests.add(new Object[]{testBuilder, ACs, nonTypePLs, isPoly});
|
||||
}
|
||||
}
|
||||
|
|
@ -760,15 +760,15 @@ public class AFCalcUnitTest extends BaseTest {
|
|||
}
|
||||
|
||||
@Test(enabled = true && ! DEBUG_ONLY, dataProvider = "polyTestProviderLotsOfAlleles")
|
||||
public void testCallingLotsOfAlleles(final AFCalcTestBuilder testBuilder, final List<Integer> ACs, final int nonTypePL, final List<Boolean> expectedPoly ) {
|
||||
public void testCallingLotsOfAlleles(final AFCalculatorTestBuilder testBuilder, final List<Integer> ACs, final int nonTypePL, final List<Boolean> expectedPoly ) {
|
||||
testCalling(testBuilder, ACs, nonTypePL, expectedPoly);
|
||||
}
|
||||
|
||||
private void testCalling(final AFCalcTestBuilder testBuilder, final List<Integer> ACs, final int nonTypePL, final List<Boolean> expectedPoly) {
|
||||
final AFCalc calc = testBuilder.makeModel();
|
||||
private void testCalling(final AFCalculatorTestBuilder testBuilder, final List<Integer> ACs, final int nonTypePL, final List<Boolean> expectedPoly) {
|
||||
final AFCalculator calc = testBuilder.makeModel();
|
||||
final double[] priors = testBuilder.makePriors();
|
||||
final VariantContext vc = testBuilder.makeACTest(ACs, 0, nonTypePL);
|
||||
final AFCalcResult result = calc.getLog10PNonRef(vc, PLOIDY, testBuilder.numAltAlleles, priors);
|
||||
final AFCalculationResult result = calc.getLog10PNonRef(vc, PLOIDY, testBuilder.numAltAlleles, priors);
|
||||
|
||||
boolean anyPoly = false;
|
||||
for ( final boolean onePoly : expectedPoly ) anyPoly = anyPoly || onePoly;
|
||||
|
|
@ -61,7 +61,7 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class AFCalcPerformanceUnitTest extends BaseTest {
|
||||
public class AFCalculatorPerformanceUnitTest extends BaseTest {
|
||||
@DataProvider(name = "ScalingTests")
|
||||
public Object[][] makepolyTestProviderLotsOfAlleles() {
|
||||
List<Object[]> tests = new ArrayList<Object[]>();
|
||||
|
|
@ -86,8 +86,8 @@ public class AFCalcPerformanceUnitTest extends BaseTest {
|
|||
for ( final AFCalculatorImplementation model : models ) {
|
||||
for ( final List<Integer> ACs : Utils.makePermutations(alleleCounts, nAltAlleles, true) ) {
|
||||
if ( MathUtils.sum(ACs) < nSamples * 2 ) {
|
||||
final AFCalcTestBuilder testBuilder
|
||||
= new AFCalcTestBuilder(nSamples, nAltAlleles, model, AFCalcTestBuilder.PriorType.human);
|
||||
final AFCalculatorTestBuilder testBuilder
|
||||
= new AFCalculatorTestBuilder(nSamples, nAltAlleles, model, AFCalculatorTestBuilder.PriorType.human);
|
||||
tests.add(new Object[]{testBuilder, ACs, nonTypePLs});
|
||||
}
|
||||
}
|
||||
|
|
@ -99,7 +99,7 @@ public class AFCalcPerformanceUnitTest extends BaseTest {
|
|||
return tests.toArray(new Object[][]{});
|
||||
}
|
||||
|
||||
private Pair<Integer, Integer> estNumberOfEvaluations(final AFCalcTestBuilder testBuilder, final VariantContext vc, final int nonTypePL) {
|
||||
private Pair<Integer, Integer> estNumberOfEvaluations(final AFCalculatorTestBuilder testBuilder, final VariantContext vc, final int nonTypePL) {
|
||||
final int evalOverhead = 2; // 2
|
||||
final int maxEvalsPerSamplePerAC = 3;
|
||||
|
||||
|
|
@ -115,11 +115,11 @@ public class AFCalcPerformanceUnitTest extends BaseTest {
|
|||
}
|
||||
|
||||
@Test(dataProvider = "ScalingTests")
|
||||
private void testScaling(final AFCalcTestBuilder testBuilder, final List<Integer> ACs, final int nonTypePL) {
|
||||
final AFCalc calc = testBuilder.makeModel();
|
||||
private void testScaling(final AFCalculatorTestBuilder testBuilder, final List<Integer> ACs, final int nonTypePL) {
|
||||
final AFCalculator calc = testBuilder.makeModel();
|
||||
final double[] priors = testBuilder.makePriors();
|
||||
final VariantContext vc = testBuilder.makeACTest(ACs, 0, nonTypePL);
|
||||
final AFCalcResult result = calc.getLog10PNonRef(vc, HomoSapiensConstants.DEFAULT_PLOIDY, testBuilder.numAltAlleles, priors);
|
||||
final AFCalculationResult result = calc.getLog10PNonRef(vc, HomoSapiensConstants.DEFAULT_PLOIDY, testBuilder.numAltAlleles, priors);
|
||||
final Pair<Integer, Integer> expectedNEvaluation = estNumberOfEvaluations(testBuilder, vc, nonTypePL);
|
||||
final int minEvals = expectedNEvaluation.getFirst();
|
||||
final int maxEvals = expectedNEvaluation.getSecond();
|
||||
|
|
@ -57,7 +57,7 @@ import org.testng.annotations.Test;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
public class AFCalcResultUnitTest extends BaseTest {
|
||||
public class AFCalculatorResultUnitTest extends BaseTest {
|
||||
private static class MyTest {
|
||||
final double[] Ls, expectedPosteriors;
|
||||
|
||||
|
|
@ -115,7 +115,7 @@ public class AFCalcResultUnitTest extends BaseTest {
|
|||
|
||||
@Test(enabled = true, dataProvider = "TestComputePosteriors")
|
||||
private void testComputingPosteriors(final MyTest data) {
|
||||
final AFCalcResult result = new AFCalcResult(new int[]{0}, 1, alleles, data.Ls, log10Even, Collections.singletonMap(C, -1.0));
|
||||
final AFCalculationResult result = new AFCalculationResult(new int[]{0}, 1, alleles, data.Ls, log10Even, Collections.singletonMap(C, -1.0));
|
||||
|
||||
Assert.assertEquals(result.getLog10PosteriorOfAFEq0(), data.expectedPosteriors[0], 1e-3, "AF = 0 not expected");
|
||||
Assert.assertEquals(result.getLog10PosteriorOfAFGT0(), data.expectedPosteriors[1], 1e-3, "AF > 0 not expected");
|
||||
|
|
@ -145,8 +145,8 @@ public class AFCalcResultUnitTest extends BaseTest {
|
|||
return tests.toArray(new Object[][]{});
|
||||
}
|
||||
|
||||
private AFCalcResult makePolymorphicTestData(final double pNonRef) {
|
||||
return new AFCalcResult(
|
||||
private AFCalculationResult makePolymorphicTestData(final double pNonRef) {
|
||||
return new AFCalculationResult(
|
||||
new int[]{0},
|
||||
1,
|
||||
alleles,
|
||||
|
|
@ -157,7 +157,7 @@ public class AFCalcResultUnitTest extends BaseTest {
|
|||
|
||||
@Test(enabled = true, dataProvider = "TestIsPolymorphic")
|
||||
private void testIsPolymorphic(final double pNonRef, final double pThreshold, final boolean shouldBePoly) {
|
||||
final AFCalcResult result = makePolymorphicTestData(pNonRef);
|
||||
final AFCalculationResult result = makePolymorphicTestData(pNonRef);
|
||||
final boolean actualIsPoly = result.isPolymorphic(C, Math.log10(1 - pThreshold));
|
||||
Assert.assertEquals(actualIsPoly, shouldBePoly,
|
||||
"isPolymorphic with pNonRef " + pNonRef + " and threshold " + pThreshold + " returned "
|
||||
|
|
@ -166,7 +166,7 @@ public class AFCalcResultUnitTest extends BaseTest {
|
|||
|
||||
@Test(enabled = true, dataProvider = "TestIsPolymorphic")
|
||||
private void testIsPolymorphicQual(final double pNonRef, final double pThreshold, final boolean shouldBePoly) {
|
||||
final AFCalcResult result = makePolymorphicTestData(pNonRef);
|
||||
final AFCalculationResult result = makePolymorphicTestData(pNonRef);
|
||||
final double qual = QualityUtils.phredScaleCorrectRate(pThreshold);
|
||||
final boolean actualIsPoly = result.isPolymorphicPhredScaledQual(C, qual);
|
||||
Assert.assertEquals(actualIsPoly, shouldBePoly,
|
||||
|
|
@ -97,7 +97,7 @@ public class FixedAFCalculatorProviderUnitTest {
|
|||
genotypeArgs.samplePloidy = ploidy;
|
||||
genotypeArgs.MAX_ALTERNATE_ALLELES = maxAltAlleles;
|
||||
final AFCalculatorProvider provider = FixedAFCalculatorProvider.createThreadSafeProvider(toolkit,callerArgs,null);
|
||||
final Hashtable<Thread,AFCalc> perThreadProvider = new Hashtable(cpuThreadCount * dataThreadCount);
|
||||
final Hashtable<Thread,AFCalculator> perThreadProvider = new Hashtable(cpuThreadCount * dataThreadCount);
|
||||
final List<Thread> threads = new ArrayList<>();
|
||||
// execute different threads.
|
||||
for (int i = 0; i < cpuThreadCount; i++)
|
||||
|
|
@ -121,7 +121,7 @@ public class FixedAFCalculatorProviderUnitTest {
|
|||
Assert.fail();
|
||||
}
|
||||
// check that each thread gave a different calculator.
|
||||
final Set<AFCalc> calculators = new HashSet<>(perThreadProvider.values());
|
||||
final Set<AFCalculator> calculators = new HashSet<>(perThreadProvider.values());
|
||||
Assert.assertEquals(calculators.size(),threads.size());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ public class GeneralPloidyAFCalculationModelUnitTest extends BaseTest {
|
|||
final int len = GeneralPloidyGenotypeLikelihoods.getNumLikelihoodElements(1 + cfg.numAltAlleles, cfg.ploidy * cfg.GLs.size());
|
||||
double[] priors = new double[len]; // flat priors
|
||||
|
||||
final GeneralPloidyExactAFCalc calc = new GeneralPloidyExactAFCalc();
|
||||
final GeneralPloidyExactAFCalculator calc = new GeneralPloidyExactAFCalculator();
|
||||
calc.combineSinglePools(cfg.GLs, cfg.ploidy,cfg.numAltAlleles + 1, priors);
|
||||
int nameIndex = 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public class GeneralPloidyFailOverAFCalculatorProviderUnitTest {
|
|||
|
||||
final GeneralPloidyFailOverAFCalculatorProvider provider = new GeneralPloidyFailOverAFCalculatorProvider(args,null);
|
||||
|
||||
final AFCalc calculator = provider.getInstance(ploidy,maxAltAlleles);
|
||||
final AFCalculator calculator = provider.getInstance(ploidy,maxAltAlleles);
|
||||
Assert.assertNotNull(calculator);
|
||||
final AFCalculatorImplementation implementation = AFCalculatorImplementation.fromCalculatorClass(calculator.getClass());
|
||||
Assert.assertTrue(implementation.usableForParams(ploidy,maxAltAlleles));
|
||||
|
|
@ -78,7 +78,7 @@ public class GeneralPloidyFailOverAFCalculatorProviderUnitTest {
|
|||
if (implementation.usableForParams(PLOIDIES[i],MAX_ALT_ALLELES[j]))
|
||||
Assert.assertSame(provider.getInstance(PLOIDIES[i],MAX_ALT_ALLELES[j]),calculator);
|
||||
else {
|
||||
final AFCalc failOver = provider.getInstance(PLOIDIES[i],MAX_ALT_ALLELES[j]);
|
||||
final AFCalculator failOver = provider.getInstance(PLOIDIES[i],MAX_ALT_ALLELES[j]);
|
||||
Assert.assertNotNull(failOver);
|
||||
final AFCalculatorImplementation failOverImplementation = AFCalculatorImplementation.fromCalculatorClass(failOver.getClass());
|
||||
Assert.assertTrue(failOverImplementation.usableForParams(PLOIDIES[i],MAX_ALT_ALLELES[j]));
|
||||
|
|
@ -99,7 +99,7 @@ public class GeneralPloidyFailOverAFCalculatorProviderUnitTest {
|
|||
genotypeArgs.samplePloidy = ploidy;
|
||||
genotypeArgs.MAX_ALTERNATE_ALLELES = maxAltAlleles;
|
||||
final AFCalculatorProvider provider = GeneralPloidyFailOverAFCalculatorProvider.createThreadSafeProvider(toolkit,genotypeArgs,null);
|
||||
final Hashtable<Thread,AFCalc> perThreadProvider = new Hashtable(cpuThreadCount * dataThreadCount);
|
||||
final Hashtable<Thread,AFCalculator> perThreadProvider = new Hashtable(cpuThreadCount * dataThreadCount);
|
||||
final List<Thread> threads = new ArrayList<>();
|
||||
// execute different threads.
|
||||
for (int i = 0; i < cpuThreadCount; i++)
|
||||
|
|
@ -123,7 +123,7 @@ public class GeneralPloidyFailOverAFCalculatorProviderUnitTest {
|
|||
Assert.fail();
|
||||
}
|
||||
// check that each thread gave a different calculator.
|
||||
final Set<AFCalc> calculators = new HashSet<>(perThreadProvider.values());
|
||||
final Set<AFCalculator> calculators = new HashSet<>(perThreadProvider.values());
|
||||
Assert.assertEquals(calculators.size(),threads.size());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ import java.util.*;
|
|||
|
||||
|
||||
// SEE private/R/pls.R if you want the truth output for these tests
|
||||
public class IndependentAllelesDiploidExactAFCalcUnitTest extends BaseTest {
|
||||
public class IndependentAllelesDiploidExactAFCalculatorUnitTest extends BaseTest {
|
||||
@DataProvider(name = "TestCombineGLs")
|
||||
public Object[][] makeTestCombineGLs() {
|
||||
List<Object[]> tests = new ArrayList<Object[]>();
|
||||
|
|
@ -102,12 +102,12 @@ public class IndependentAllelesDiploidExactAFCalcUnitTest extends BaseTest {
|
|||
}
|
||||
|
||||
private Genotype makePL(final int ... PLs) {
|
||||
return AFCalcUnitTest.makePL(Arrays.asList(Allele.NO_CALL, Allele.NO_CALL), PLs);
|
||||
return AFCalculationUnitTest.makePL(Arrays.asList(Allele.NO_CALL, Allele.NO_CALL), PLs);
|
||||
}
|
||||
|
||||
@Test(enabled = true, dataProvider = "TestCombineGLs")
|
||||
public void testCombineGLsPrecise(final int altIndex, final int nAlts, final Genotype testg, final Genotype expected) {
|
||||
final IndependentAllelesDiploidExactAFCalc calc = (IndependentAllelesDiploidExactAFCalc) AFCalculatorImplementation.EXACT_INDEPENDENT.newInstance();
|
||||
final IndependentAllelesDiploidExactAFCalculator calc = (IndependentAllelesDiploidExactAFCalculator) AFCalculatorImplementation.EXACT_INDEPENDENT.newInstance();
|
||||
final Genotype combined = calc.combineGLsPrecise(testg, altIndex, nAlts);
|
||||
|
||||
Assert.assertEquals(combined.getPL(), expected.getPL(),
|
||||
|
|
@ -116,7 +116,7 @@ public class IndependentAllelesDiploidExactAFCalcUnitTest extends BaseTest {
|
|||
|
||||
@Test(enabled = true, dataProvider = "TestCombineGLs")
|
||||
public void testCombinePrecise(final int altIndex, final int nAlts, final Genotype testg, final Genotype expected) {
|
||||
final IndependentAllelesDiploidExactAFCalc calc = (IndependentAllelesDiploidExactAFCalc) AFCalculatorImplementation.EXACT_INDEPENDENT.newInstance();
|
||||
final IndependentAllelesDiploidExactAFCalculator calc = (IndependentAllelesDiploidExactAFCalculator) AFCalculatorImplementation.EXACT_INDEPENDENT.newInstance();
|
||||
final Genotype combined = calc.combineGLsPrecise(testg, altIndex, nAlts);
|
||||
|
||||
Assert.assertEquals(combined.getPL(), expected.getPL(),
|
||||
|
|
@ -156,7 +156,7 @@ public class IndependentAllelesDiploidExactAFCalcUnitTest extends BaseTest {
|
|||
|
||||
@Test(enabled = true, dataProvider = "TestMakeAlleleConditionalContexts")
|
||||
private void testMakeAlleleConditionalContexts(final VariantContext vc, final List<VariantContext> expectedVCs) {
|
||||
final IndependentAllelesDiploidExactAFCalc calc = (IndependentAllelesDiploidExactAFCalc) AFCalculatorImplementation.EXACT_INDEPENDENT.newInstance();
|
||||
final IndependentAllelesDiploidExactAFCalculator calc = (IndependentAllelesDiploidExactAFCalculator) AFCalculatorImplementation.EXACT_INDEPENDENT.newInstance();
|
||||
final List<VariantContext> biAllelicVCs = calc.makeAlleleConditionalContexts(vc);
|
||||
|
||||
Assert.assertEquals(biAllelicVCs.size(), expectedVCs.size());
|
||||
|
|
@ -197,24 +197,24 @@ public class IndependentAllelesDiploidExactAFCalcUnitTest extends BaseTest {
|
|||
|
||||
final double log10pNonRef = Math.log10(1-pRef);
|
||||
|
||||
final List<AFCalcResult> originalPriors = new LinkedList<AFCalcResult>();
|
||||
final List<AFCalculationResult> originalPriors = new LinkedList<AFCalculationResult>();
|
||||
final List<Double> pNonRefN = new LinkedList<Double>();
|
||||
for ( int i = 0; i < log10LAlleles.size(); i++ ) {
|
||||
final double log10LAllele1 = log10LAlleles.get(i);
|
||||
final double[] L1 = MathUtils.normalizeFromLog10(new double[]{log10LAllele1, 0.0}, true);
|
||||
final AFCalcResult result1 = new AFCalcResult(new int[]{1}, 1, Arrays.asList(A, C), L1, rawPriors, Collections.singletonMap(C, -10000.0));
|
||||
final AFCalculationResult result1 = new AFCalculationResult(new int[]{1}, 1, Arrays.asList(A, C), L1, rawPriors, Collections.singletonMap(C, -10000.0));
|
||||
originalPriors.add(result1);
|
||||
pNonRefN.add(log10pNonRef*(i+1));
|
||||
}
|
||||
|
||||
final IndependentAllelesDiploidExactAFCalc calc = (IndependentAllelesDiploidExactAFCalc) AFCalculatorImplementation.EXACT_INDEPENDENT.newInstance();
|
||||
final List<AFCalcResult> thetaNPriors = calc.applyMultiAllelicPriors(originalPriors);
|
||||
final IndependentAllelesDiploidExactAFCalculator calc = (IndependentAllelesDiploidExactAFCalculator) AFCalculatorImplementation.EXACT_INDEPENDENT.newInstance();
|
||||
final List<AFCalculationResult> thetaNPriors = calc.applyMultiAllelicPriors(originalPriors);
|
||||
|
||||
double prevPosterior = 0.0;
|
||||
for ( int i = 0; i < log10LAlleles.size(); i++ ) {
|
||||
final AFCalcResult thetaN = thetaNPriors.get(i);
|
||||
AFCalcResult orig = null;
|
||||
for ( final AFCalcResult x : originalPriors )
|
||||
final AFCalculationResult thetaN = thetaNPriors.get(i);
|
||||
AFCalculationResult orig = null;
|
||||
for ( final AFCalculationResult x : originalPriors )
|
||||
if ( x.getAllelesUsedInGenotyping().equals(thetaN.getAllelesUsedInGenotyping()))
|
||||
orig = x;
|
||||
|
||||
Loading…
Reference in New Issue