use of org.broadinstitute.gatk.nativebindings.pairhmm.PairHMMNativeArguments in project gatk-protected by broadinstitute.
the class PairHMMLikelihoodCalculationEngineUnitTest method testComputeLikelihoods.
@Test
public void testComputeLikelihoods() {
final LikelihoodEngineArgumentCollection LEAC = new LikelihoodEngineArgumentCollection();
PairHMMLikelihoodCalculationEngine.writeLikelihoodsToFile = true;
final ReadLikelihoodCalculationEngine lce = new PairHMMLikelihoodCalculationEngine((byte) SAMUtils.MAX_PHRED_SCORE, new PairHMMNativeArguments(), PairHMM.Implementation.LOGLESS_CACHING, MathUtils.logToLog10(QualityUtils.qualToErrorProbLog10(LEAC.phredScaledGlobalReadMismappingRate)), PairHMMLikelihoodCalculationEngine.PCRErrorModel.CONSERVATIVE);
final Map<String, List<GATKRead>> perSampleReadList = new HashMap<>();
final int n = 10;
final GATKRead read1 = ArtificialReadUtils.createArtificialRead(TextCigarCodec.decode(n + "M"));
read1.setMappingQuality(60);
final String sample1 = "sample1";
perSampleReadList.put(sample1, Arrays.asList(read1));
final SampleList samples = new IndexedSampleList(sample1);
final AssemblyResultSet assemblyResultSet = new AssemblyResultSet();
final byte[] bases = Strings.repeat("A", n + 1).getBytes();
final Haplotype hap1 = new Haplotype(bases, true);
hap1.setGenomeLocation(read1);
assemblyResultSet.add(hap1);
final byte[] basesModified = bases;
//different bases
basesModified[5] = 'C';
final Haplotype hap2 = new Haplotype(basesModified, false);
//use same loc
hap2.setGenomeLocation(read1);
assemblyResultSet.add(hap2);
final ReadLikelihoods<Haplotype> likes = lce.computeReadLikelihoods(assemblyResultSet, samples, perSampleReadList);
final LikelihoodMatrix<Haplotype> mtx = likes.sampleMatrix(0);
Assert.assertEquals(mtx.numberOfAlleles(), 2);
Assert.assertEquals(mtx.numberOfReads(), 1);
final double v1 = mtx.get(0, 0);
final double v2 = mtx.get(1, 0);
Assert.assertTrue(v1 > v2, "matching haplotype should have a higher likelihood");
lce.close();
new File(PairHMMLikelihoodCalculationEngine.LIKELIHOODS_FILENAME).delete();
}
use of org.broadinstitute.gatk.nativebindings.pairhmm.PairHMMNativeArguments in project gatk by broadinstitute.
the class PairHMMLikelihoodCalculationEngineUnitTest method createPcrErrorModelTest.
@Test(dataProvider = "PcrErrorModelTestProvider", enabled = true)
public void createPcrErrorModelTest(final String repeat, final int repeatLength) {
final PairHMMLikelihoodCalculationEngine engine = new PairHMMLikelihoodCalculationEngine((byte) 0, new PairHMMNativeArguments(), PairHMM.Implementation.ORIGINAL, 0.0, PairHMMLikelihoodCalculationEngine.PCRErrorModel.CONSERVATIVE);
final String readString = Strings.repeat(repeat, repeatLength);
final byte[] insQuals = new byte[readString.length()];
final byte[] delQuals = new byte[readString.length()];
Arrays.fill(insQuals, (byte) PairHMMLikelihoodCalculationEngine.INITIAL_QSCORE);
Arrays.fill(delQuals, (byte) PairHMMLikelihoodCalculationEngine.INITIAL_QSCORE);
engine.applyPCRErrorModel(readString.getBytes(), insQuals, delQuals);
for (int i = 1; i < insQuals.length; i++) {
final int repeatLengthFromCovariate = PairHMMLikelihoodCalculationEngine.findTandemRepeatUnits(readString.getBytes(), i - 1).getRight();
final byte adjustedScore = PairHMMLikelihoodCalculationEngine.getErrorModelAdjustedQual(repeatLengthFromCovariate, 3.0);
Assert.assertEquals(insQuals[i - 1], adjustedScore);
Assert.assertEquals(delQuals[i - 1], adjustedScore);
}
}
use of org.broadinstitute.gatk.nativebindings.pairhmm.PairHMMNativeArguments in project gatk-protected by broadinstitute.
the class PairHMMNativeArgumentCollection method getPairHMMArgs.
public PairHMMNativeArguments getPairHMMArgs() {
final PairHMMNativeArguments args = new PairHMMNativeArguments();
args.maxNumberOfThreads = pairHmmNativeThreads;
args.useDoublePrecision = useDoublePrecision;
return args;
}
use of org.broadinstitute.gatk.nativebindings.pairhmm.PairHMMNativeArguments in project gatk by broadinstitute.
the class VectorPairHMMUnitTest method getHMMs.
// Return a list of supported VectorLoglessPairHMM implementations, skip the test if none are supported
private List<Pair<PairHMM, Boolean>> getHMMs() {
List<Pair<PairHMM, Boolean>> list = new ArrayList<>();
PairHMMNativeArguments args = new PairHMMNativeArguments();
args.useDoublePrecision = false;
args.maxNumberOfThreads = 1;
for (VectorLoglessPairHMM.Implementation imp : VectorLoglessPairHMM.Implementation.values()) {
boolean loaded = true;
PairHMM avxPairHMM = null;
try {
avxPairHMM = new VectorLoglessPairHMM(imp, args);
//avxPairHMM.doNotUseTristateCorrection();
} catch (UserException.HardwareFeatureException e) {
loaded = false;
}
final Pair<PairHMM, Boolean> hmm_load = new ImmutablePair<PairHMM, Boolean>(avxPairHMM, new Boolean(loaded));
list.add(hmm_load);
}
return list;
}
use of org.broadinstitute.gatk.nativebindings.pairhmm.PairHMMNativeArguments in project gatk-protected by broadinstitute.
the class PairHMMLikelihoodCalculationEngineUnitTest method createPcrErrorModelTest.
@Test(dataProvider = "PcrErrorModelTestProvider", enabled = true)
public void createPcrErrorModelTest(final String repeat, final int repeatLength) {
final PairHMMLikelihoodCalculationEngine engine = new PairHMMLikelihoodCalculationEngine((byte) 0, new PairHMMNativeArguments(), PairHMM.Implementation.ORIGINAL, 0.0, PairHMMLikelihoodCalculationEngine.PCRErrorModel.CONSERVATIVE);
final String readString = Strings.repeat(repeat, repeatLength);
final byte[] insQuals = new byte[readString.length()];
final byte[] delQuals = new byte[readString.length()];
Arrays.fill(insQuals, (byte) PairHMMLikelihoodCalculationEngine.INITIAL_QSCORE);
Arrays.fill(delQuals, (byte) PairHMMLikelihoodCalculationEngine.INITIAL_QSCORE);
engine.applyPCRErrorModel(readString.getBytes(), insQuals, delQuals);
for (int i = 1; i < insQuals.length; i++) {
final int repeatLengthFromCovariate = PairHMMLikelihoodCalculationEngine.findTandemRepeatUnits(readString.getBytes(), i - 1).getRight();
final byte adjustedScore = PairHMMLikelihoodCalculationEngine.getErrorModelAdjustedQual(repeatLengthFromCovariate, 3.0);
Assert.assertEquals(insQuals[i - 1], adjustedScore);
Assert.assertEquals(delQuals[i - 1], adjustedScore);
}
}
Aggregations