use of org.broadinstitute.hellbender.utils.haplotype.Haplotype in project gatk by broadinstitute.
the class AssemblyResultSetUnitTest method testAddReferenceHaplotype.
@Test
public void testAddReferenceHaplotype() {
final Haplotype ref = new Haplotype("ACGT".getBytes(), true);
ref.setGenomeLocation(genomeLocParser.createGenomeLoc("1", 1, ref.length() + 1));
final AssemblyResultSet subject = new AssemblyResultSet();
Assert.assertTrue(subject.add(ref));
Assert.assertFalse(subject.add(ref));
Assert.assertEquals(subject.getReferenceHaplotype(), ref);
Assert.assertEquals(subject.getHaplotypeCount(), 1);
Assert.assertEquals(subject.getHaplotypeList().size(), 1);
}
use of org.broadinstitute.hellbender.utils.haplotype.Haplotype in project gatk by broadinstitute.
the class AssemblyRegionTestDataSet method haplotypeList.
public List<Haplotype> haplotypeList() {
if (haplotypeList == null) {
final List<Haplotype> result = new ArrayList<>(haplotypeCigars.length);
final String reference = this.reference;
for (final String cigar : haplotypeCigars) {
if (cigar.matches("^Civar:.*$")) {
stringRepresentation = cigar.substring(6);
result.addAll(expandAllHaplotypeCombinations(cigar.substring(6), reference));
} else if (cigar.matches("^.*\\d+.*$")) {
result.add(cigarToHaplotype(reference, cigar, 0, true));
} else {
final Haplotype h = new Haplotype(cigar.getBytes());
h.setGenomeLocation(genomeLocParser.createGenomeLoc("chr1", 1, reference.length()));
result.add(h);
}
}
haplotypeList = result;
}
return haplotypeList;
}
use of org.broadinstitute.hellbender.utils.haplotype.Haplotype in project gatk-protected by broadinstitute.
the class ReferenceConfidenceModelUnitTest method testRefConfidenceWithCalls.
@Test
public void testRefConfidenceWithCalls() {
final RefConfData xxxdata = new RefConfData("ACGTAACCGGTT", 0);
final int start = xxxdata.getStart();
final int stop = xxxdata.getEnd();
final PloidyModel ploidyModel = new HomogeneousPloidyModel(samples, 2);
final IndependentSampleGenotypesModel genotypingModel = new IndependentSampleGenotypesModel();
for (int nReads = 0; nReads < 2; nReads++) {
final VariantContext vcStart = GATKVariantContextUtils.makeFromAlleles("test", "chr1", start, Arrays.asList("A", "C"));
final VariantContext vcEnd = GATKVariantContextUtils.makeFromAlleles("test", "chr1", stop, Arrays.asList("A", "C"));
final VariantContext vcMiddle = GATKVariantContextUtils.makeFromAlleles("test", "chr1", start + 2, Arrays.asList("A", "C"));
final VariantContext vcDel = GATKVariantContextUtils.makeFromAlleles("test", "chr1", start + 4, Arrays.asList("AAC", "A"));
final VariantContext vcIns = GATKVariantContextUtils.makeFromAlleles("test", "chr1", start + 8, Arrays.asList("G", "GCG"));
final List<VariantContext> allCalls = Arrays.asList(vcStart, vcEnd, vcMiddle, vcDel, vcIns);
for (int n = 1; n <= allCalls.size(); n++) {
for (final List<VariantContext> calls : Utils.makePermutations(allCalls, n, false)) {
final RefConfData data = new RefConfData("ACGTAACCGGTT", 0);
final List<Haplotype> haplotypes = Arrays.asList(data.getRefHap());
for (int i = 0; i < nReads; i++) {
data.getActiveRegion().add(data.makeRead(0, data.getRefLength()));
}
final ReadLikelihoods<Haplotype> likelihoods = createDummyStratifiedReadMap(data.getRefHap(), samples, data.getActiveRegion());
final List<Integer> expectedDPs = Collections.nCopies(data.getActiveRegion().getSpan().size(), nReads);
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-protected by broadinstitute.
the class ReadThreadingAssemblerUnitTest method testSimpleAssembly.
@Test(dataProvider = "SimpleAssemblyTestData")
public void testSimpleAssembly(final String name, final ReadThreadingAssembler assembler, final SimpleInterval loc, final String ref, final String alt) {
final byte[] refBases = ref.getBytes();
final byte[] altBases = alt.getBytes();
final List<GATKRead> reads = new LinkedList<>();
for (int i = 0; i < 20; i++) {
final byte[] bases = altBases.clone();
final byte[] quals = Utils.dupBytes((byte) 30, altBases.length);
final String cigar = altBases.length + "M";
final GATKRead read = ArtificialReadUtils.createArtificialRead(header, loc.getContig(), loc.getContig(), loc.getStart(), bases, quals, cigar);
reads.add(read);
}
final Haplotype refHaplotype = new Haplotype(refBases, true);
final Haplotype altHaplotype = new Haplotype(altBases, false);
final List<Haplotype> haplotypes = assemble(assembler, refBases, loc, reads);
Assert.assertTrue(haplotypes.size() > 0, "Failed to find ref haplotype");
Assert.assertEquals(haplotypes.get(0), refHaplotype);
Assert.assertEquals(haplotypes.size(), 2, "Failed to find single alt haplotype");
Assert.assertEquals(haplotypes.get(1), altHaplotype);
}
use of org.broadinstitute.hellbender.utils.haplotype.Haplotype in project gatk-protected 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);
}
Aggregations