use of org.broadinstitute.hellbender.utils.haplotype.Haplotype in project gatk by broadinstitute.
the class ReferenceConfidenceModelUnitTest method testRefConfidencePartialReads.
@Test
public void testRefConfidencePartialReads() {
final PloidyModel ploidyModel = new HomogeneousPloidyModel(samples, 2);
final IndependentSampleGenotypesModel genotypingModel = new IndependentSampleGenotypesModel();
final String ref = "ACGTAACCGGTT";
for (int readLen = 3; readLen < ref.length(); readLen++) {
for (int start = 0; start < ref.length() - readLen; start++) {
final RefConfData data = new RefConfData(ref, 0);
final List<Haplotype> haplotypes = Arrays.asList(data.getRefHap());
final List<VariantContext> calls = Collections.emptyList();
data.getActiveRegion().add(data.makeRead(start, readLen));
final ReadLikelihoods<Haplotype> likelihoods = createDummyStratifiedReadMap(data.getRefHap(), samples, data.getActiveRegion());
final List<Integer> expectedDPs = new ArrayList<>(Collections.nCopies(data.getActiveRegion().getSpan().size(), 0));
for (int i = start; i < readLen + start; i++) expectedDPs.set(i, 1);
final List<VariantContext> contexts = model.calculateRefConfidence(data.getRefHap(), haplotypes, data.getPaddedRefLoc(), data.getActiveRegion(), likelihoods, ploidyModel, calls);
checkReferenceModelResult(data, contexts, expectedDPs, calls);
}
}
}
use of org.broadinstitute.hellbender.utils.haplotype.Haplotype in project gatk by broadinstitute.
the class KBestHaplotypeFinderUnitTest method testScore.
@Test
public void testScore() {
final SeqGraph g = new SeqGraph(3);
final SeqVertex v1 = new SeqVertex("A");
final SeqVertex v2 = new SeqVertex("C");
final SeqVertex v3 = new SeqVertex("G");
final SeqVertex v4 = new SeqVertex("T");
final SeqVertex v5 = new SeqVertex("A");
//source
g.addVertex(v1);
g.addVertex(v2);
g.addVertex(v3);
g.addVertex(v4);
g.addVertex(v5);
g.addEdge(v1, v2);
g.addEdge(v2, v3);
g.addEdge(v2, v4);
g.addEdge(v2, v5);
final KBestHaplotypeFinder finder = new KBestHaplotypeFinder(g);
Assert.assertEquals(finder.sources.size(), 1);
Assert.assertEquals(finder.sinks.size(), 3);
final double score = finder.score("ACG".getBytes());
Assert.assertEquals(score, -0.47712125471966244);
final double scoreH = finder.score(new Haplotype("ACG".getBytes()));
Assert.assertEquals(scoreH, -0.47712125471966244);
}
use of org.broadinstitute.hellbender.utils.haplotype.Haplotype in project gatk-protected by broadinstitute.
the class AssemblyBasedCallerGenotypingEngine method createAlleleMapper.
protected static Map<Allele, List<Haplotype>> createAlleleMapper(final List<VariantContext> eventsAtThisLoc, final VariantContext mergedVC, final int loc, final List<Haplotype> haplotypes) {
Utils.validateArg(haplotypes.size() > eventsAtThisLoc.size(), "expected haplotypes.size() >= eventsAtThisLoc.size() + 1");
final Map<Allele, List<Haplotype>> result = new LinkedHashMap<>();
final Allele ref = mergedVC.getReference();
result.put(ref, new ArrayList<>());
//Note: we can't use the alleles implied by eventsAtThisLoc because they are not yet merged to a common reference
//For example, a homopolymer AAAAA reference with a single and double deletion would yield (i) AA* A and (ii) AAA* A
//in eventsAtThisLoc, when in mergedVC it would yield AAA* AA A
mergedVC.getAlternateAlleles().stream().filter(a -> !a.isSymbolic()).forEach(a -> result.put(a, new ArrayList<>()));
for (final Haplotype h : haplotypes) {
final VariantContext haplotypeVC = h.getEventMap().get(loc);
if (haplotypeVC == null) {
//no events --> this haplotype supports the reference at this locus
result.get(ref).add(h);
} else {
//TODO: that's not good enough
for (int n = 0; n < eventsAtThisLoc.size(); n++) {
if (haplotypeVC.hasSameAllelesAs(eventsAtThisLoc.get(n))) {
result.get(mergedVC.getAlternateAllele(n)).add(h);
break;
}
}
}
}
return result;
}
Aggregations