Search in sources :

Example 1 with ReadThreadingGraph

use of org.broadinstitute.hellbender.tools.walkers.haplotypecaller.readthreading.ReadThreadingGraph in project gatk by broadinstitute.

the class AssemblyRegionTestDataSet method assemblyResultSet.

public AssemblyResultSet assemblyResultSet() {
    if (assemblyResultSet == null) {
        final ReadThreadingGraph rtg = new ReadThreadingGraph(kmerSize);
        rtg.addSequence("anonymous", getReference().getBytes(), true);
        for (final String haplotype : haplotypesStrings()) {
            rtg.addSequence("anonymous", haplotype.getBytes(), false);
        }
        rtg.buildGraphIfNecessary();
        if (rtg.hasCycles())
            throw new RuntimeException("there is cycles in the reference with kmer size " + kmerSize + ". Don't use this size for the benchmark or change the reference");
        List<Haplotype> haplotypeList = haplotypeList();
        assemblyResultSet = new AssemblyResultSet();
        final AssemblyResult ar = new AssemblyResult((haplotypeList.size() > 1 ? AssemblyResult.Status.ASSEMBLED_SOME_VARIATION : AssemblyResult.Status.JUST_ASSEMBLED_REFERENCE), rtg.toSequenceGraph(), rtg);
        for (final Haplotype h : haplotypeList) assemblyResultSet.add(h, ar);
    }
    return assemblyResultSet;
}
Also used : ReadThreadingGraph(org.broadinstitute.hellbender.tools.walkers.haplotypecaller.readthreading.ReadThreadingGraph) Haplotype(org.broadinstitute.hellbender.utils.haplotype.Haplotype)

Example 2 with ReadThreadingGraph

use of org.broadinstitute.hellbender.tools.walkers.haplotypecaller.readthreading.ReadThreadingGraph 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();
}
Also used : ReadThreadingGraph(org.broadinstitute.hellbender.tools.walkers.haplotypecaller.readthreading.ReadThreadingGraph) TestingReadThreadingGraph(org.broadinstitute.hellbender.tools.walkers.haplotypecaller.readthreading.TestingReadThreadingGraph) SeqGraph(org.broadinstitute.hellbender.tools.walkers.haplotypecaller.graphs.SeqGraph) RandomDNA(org.broadinstitute.hellbender.utils.RandomDNA) AssemblyRegion(org.broadinstitute.hellbender.engine.AssemblyRegion) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) Haplotype(org.broadinstitute.hellbender.utils.haplotype.Haplotype) DataProvider(org.testng.annotations.DataProvider)

Example 3 with ReadThreadingGraph

use of org.broadinstitute.hellbender.tools.walkers.haplotypecaller.readthreading.ReadThreadingGraph 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();
}
Also used : ReadThreadingGraph(org.broadinstitute.hellbender.tools.walkers.haplotypecaller.readthreading.ReadThreadingGraph) TestingReadThreadingGraph(org.broadinstitute.hellbender.tools.walkers.haplotypecaller.readthreading.TestingReadThreadingGraph) TestingReadThreadingGraph(org.broadinstitute.hellbender.tools.walkers.haplotypecaller.readthreading.TestingReadThreadingGraph) Haplotype(org.broadinstitute.hellbender.utils.haplotype.Haplotype) DataProvider(org.testng.annotations.DataProvider)

Example 4 with ReadThreadingGraph

use of org.broadinstitute.hellbender.tools.walkers.haplotypecaller.readthreading.ReadThreadingGraph in project gatk-protected by broadinstitute.

the class AssemblyRegionTestDataSet method assemblyResultSet.

public AssemblyResultSet assemblyResultSet() {
    if (assemblyResultSet == null) {
        final ReadThreadingGraph rtg = new ReadThreadingGraph(kmerSize);
        rtg.addSequence("anonymous", getReference().getBytes(), true);
        for (final String haplotype : haplotypesStrings()) {
            rtg.addSequence("anonymous", haplotype.getBytes(), false);
        }
        rtg.buildGraphIfNecessary();
        if (rtg.hasCycles())
            throw new RuntimeException("there is cycles in the reference with kmer size " + kmerSize + ". Don't use this size for the benchmark or change the reference");
        List<Haplotype> haplotypeList = haplotypeList();
        assemblyResultSet = new AssemblyResultSet();
        final AssemblyResult ar = new AssemblyResult((haplotypeList.size() > 1 ? AssemblyResult.Status.ASSEMBLED_SOME_VARIATION : AssemblyResult.Status.JUST_ASSEMBLED_REFERENCE), rtg.toSequenceGraph(), rtg);
        for (final Haplotype h : haplotypeList) assemblyResultSet.add(h, ar);
    }
    return assemblyResultSet;
}
Also used : ReadThreadingGraph(org.broadinstitute.hellbender.tools.walkers.haplotypecaller.readthreading.ReadThreadingGraph) Haplotype(org.broadinstitute.hellbender.utils.haplotype.Haplotype)

Example 5 with ReadThreadingGraph

use of org.broadinstitute.hellbender.tools.walkers.haplotypecaller.readthreading.ReadThreadingGraph in project gatk-protected 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();
}
Also used : ReadThreadingGraph(org.broadinstitute.hellbender.tools.walkers.haplotypecaller.readthreading.ReadThreadingGraph) TestingReadThreadingGraph(org.broadinstitute.hellbender.tools.walkers.haplotypecaller.readthreading.TestingReadThreadingGraph) TestingReadThreadingGraph(org.broadinstitute.hellbender.tools.walkers.haplotypecaller.readthreading.TestingReadThreadingGraph) Haplotype(org.broadinstitute.hellbender.utils.haplotype.Haplotype) DataProvider(org.testng.annotations.DataProvider)

Aggregations

ReadThreadingGraph (org.broadinstitute.hellbender.tools.walkers.haplotypecaller.readthreading.ReadThreadingGraph)6 Haplotype (org.broadinstitute.hellbender.utils.haplotype.Haplotype)6 TestingReadThreadingGraph (org.broadinstitute.hellbender.tools.walkers.haplotypecaller.readthreading.TestingReadThreadingGraph)4 DataProvider (org.testng.annotations.DataProvider)4 AssemblyRegion (org.broadinstitute.hellbender.engine.AssemblyRegion)2 SeqGraph (org.broadinstitute.hellbender.tools.walkers.haplotypecaller.graphs.SeqGraph)2 RandomDNA (org.broadinstitute.hellbender.utils.RandomDNA)2 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)2