use of org.broadinstitute.hellbender.utils.haplotype.Haplotype in project gatk by broadinstitute.
the class AssemblyResultSetUnitTest method testTrimTo.
@Test(dataProvider = "trimmingData")
public void testTrimTo(final Map<Haplotype, AssemblyResult> haplotypesAndResultSets, final AssemblyRegion original) {
final AssemblyResultSet subject = new AssemblyResultSet();
for (final Map.Entry<Haplotype, AssemblyResult> entry : haplotypesAndResultSets.entrySet()) subject.add(entry.getKey(), entry.getValue());
subject.setRegionForGenotyping(original);
final SimpleInterval originalLocation = original.getExtendedSpan();
final int length = originalLocation.size();
final SimpleInterval newLocation = new SimpleInterval(originalLocation.getContig(), originalLocation.getStart() + length / 2, originalLocation.getEnd() - length / 2);
final AssemblyRegion newRegion = original.trim(newLocation);
final Map<Haplotype, Haplotype> originalHaplotypesByTrimmed = new HashMap<>(haplotypesAndResultSets.size());
for (final Haplotype h : haplotypesAndResultSets.keySet()) originalHaplotypesByTrimmed.put(h.trim(newRegion.getExtendedSpan()), h);
final AssemblyResultSet trimmed = subject.trimTo(newRegion);
Assert.assertFalse(subject.wasTrimmed());
Assert.assertTrue(trimmed.wasTrimmed());
for (final Haplotype h : trimmed.getHaplotypeList()) {
Assert.assertEquals(h.getGenomeLocation(), newLocation);
Assert.assertEquals(h.getBases().length, newLocation.size());
}
}
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);
}
Aggregations