use of org.broadinstitute.hellbender.utils.haplotype.Haplotype in project gatk 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 by broadinstitute.
the class AssemblyResultSetUnitTest method testAddManyHaplotypes.
@Test(dataProvider = "assemblyResults")
public void testAddManyHaplotypes(final List<AssemblyResult> assemblyResults, final List<List<Haplotype>> haplotypes) {
final AssemblyResultSet subject = new AssemblyResultSet();
for (int i = 0; i < haplotypes.size(); i++) {
final int haplotypeCountBefore = subject.getHaplotypeCount();
final List<Haplotype> haplos = haplotypes.get(i);
final AssemblyResult ar = assemblyResults.get(i);
for (final Haplotype h : haplos) {
Assert.assertTrue(subject.add(h, ar));
Assert.assertFalse(subject.add(h, ar));
if (h.isReference())
Assert.assertEquals(subject.getReferenceHaplotype(), h);
}
final int haplotypeCountAfter = subject.getHaplotypeCount();
Assert.assertEquals(haplos.size(), haplotypeCountAfter - haplotypeCountBefore);
Assert.assertTrue(subject.getMaximumKmerSize() >= ar.getKmerSize());
Assert.assertTrue(subject.getMinimumKmerSize() <= ar.getKmerSize());
Assert.assertEquals(subject.getUniqueReadThreadingGraph(ar.getKmerSize()), ar.getThreadingGraph());
}
}
use of org.broadinstitute.hellbender.utils.haplotype.Haplotype in project gatk by broadinstitute.
the class AssemblyResultSetUnitTest method trimmingData.
@DataProvider(name = "trimmingData")
public Iterator<Object[]> trimmingData() {
final AssemblyRegion activeRegion = new AssemblyRegion(new SimpleInterval("1", 1000, 1100), 25, header);
final int length = activeRegion.getExtendedSpan().size();
// keep it prepoducible by fixing the seed to lucky 13.
final RandomDNA rnd = new RandomDNA(13);
final AssemblyRegionTestDataSet actd = new AssemblyRegionTestDataSet(10, new String(rnd.nextBases(length)), new String[] { "Civar:*1T*" }, new String[0], new byte[0], new byte[0], new byte[0]);
final List<Haplotype> haplotypes = actd.haplotypeList();
for (final Haplotype h : haplotypes) h.setGenomeLocation(activeRegion.getExtendedSpan());
final ReadThreadingGraph rtg = new ReadThreadingGraph(10);
for (final Haplotype h : haplotypes) rtg.addSequence("seq-" + Math.abs(h.hashCode()), h.getBases(), h.isReference());
final SeqGraph seqGraph = rtg.toSequenceGraph();
final AssemblyResult ar = new AssemblyResult(AssemblyResult.Status.ASSEMBLED_SOME_VARIATION, seqGraph, rtg);
final Map<Haplotype, AssemblyResult> result = new HashMap<>();
for (final Haplotype h : haplotypes) result.put(h, ar);
return Collections.singleton(new Object[] { result, activeRegion }).iterator();
}
use of org.broadinstitute.hellbender.utils.haplotype.Haplotype in project gatk by broadinstitute.
the class AssemblyResultSetUnitTest method assemblyResults.
@DataProvider(name = "assemblyResults")
public Iterator<Object[]> assemblyResults() {
final int size = THREE_KS_GRAPH_AND_HAPLOTYPES.length * (1 + TEN_KS_GRAPH_AND_HAPLOTYPES.length);
final Object[][] result = new Object[size][];
for (int i = 0; i < THREE_KS_GRAPH_AND_HAPLOTYPES.length; i++) {
final ReadThreadingGraph rtg = new TestingReadThreadingGraph((String) THREE_KS_GRAPH_AND_HAPLOTYPES[i][0]);
final AssemblyResult ar = new AssemblyResult(AssemblyResult.Status.ASSEMBLED_SOME_VARIATION, rtg.toSequenceGraph(), rtg);
final Object[] haplotypeStrings = (Object[]) THREE_KS_GRAPH_AND_HAPLOTYPES[i][1];
final Haplotype[] haplotypes = new Haplotype[haplotypeStrings.length];
for (int j = 0; j < haplotypeStrings.length; j++) {
haplotypes[j] = new Haplotype(((String) haplotypeStrings[j]).getBytes(), j == 0);
haplotypes[j].setGenomeLocation(genomeLocParser.createGenomeLoc("1", 1, haplotypes[j].length() + 1));
}
result[i] = new Object[] { Collections.singletonList(ar), Arrays.asList(Arrays.asList(haplotypes)) };
for (int j = 0; j < TEN_KS_GRAPH_AND_HAPLOTYPES.length; j++) {
final ReadThreadingGraph rtg10 = new TestingReadThreadingGraph((String) TEN_KS_GRAPH_AND_HAPLOTYPES[j][0]);
final AssemblyResult ar10 = new AssemblyResult(AssemblyResult.Status.ASSEMBLED_SOME_VARIATION, rtg10.toSequenceGraph(), rtg10);
final Object[] haplotypeStrings10 = (Object[]) TEN_KS_GRAPH_AND_HAPLOTYPES[j][1];
final Haplotype[] haplotype10 = new Haplotype[haplotypeStrings10.length];
for (int k = 0; k < haplotypeStrings10.length; k++) {
haplotype10[k] = new Haplotype(((String) haplotypeStrings10[k]).getBytes(), false);
haplotype10[k].setGenomeLocation(genomeLocParser.createGenomeLoc("1", 1, haplotype10[k].length() + 1));
}
result[THREE_KS_GRAPH_AND_HAPLOTYPES.length + i * TEN_KS_GRAPH_AND_HAPLOTYPES.length + j] = new Object[] { Arrays.asList(ar, ar10), Arrays.asList(Arrays.asList(haplotypes), Arrays.asList(haplotype10)) };
}
}
return Arrays.asList(result).iterator();
}
use of org.broadinstitute.hellbender.utils.haplotype.Haplotype in project gatk by broadinstitute.
the class HaplotypeSizeAndBaseComparatorUnitTest method testComparison.
@Test
public void testComparison() {
// desired ordering is by size first, subordered by lexacographic relationship between bases
final List<String> rawStrings = Arrays.asList("A", "C", "AC", "CC", "CT", "AAT", "ACT", "GAT", "ACGT");
final List<String> lexStrings = new ArrayList<>(rawStrings);
for (final List<String> seqs : Utils.makePermutations(lexStrings, lexStrings.size(), false)) {
final List<Haplotype> haps = new ArrayList<>(seqs.size());
for (final String seq : seqs) {
haps.add(new Haplotype(seq.getBytes(), false));
}
Collections.sort(haps, Haplotype.SIZE_AND_BASE_ORDER);
for (int i = 0; i < lexStrings.size(); i++) Assert.assertEquals(haps.get(i).getBaseString(), lexStrings.get(i), "Failed sort " + haps + " expected " + lexStrings);
}
}
Aggregations