Search in sources :

Example 1 with EventMap

use of org.broadinstitute.hellbender.utils.haplotype.EventMap in project gatk-protected by broadinstitute.

the class HaplotypeCallerGenotypingEngineUnitTest method makeConstructPhaseSetMappingData.

@DataProvider(name = "ConstructPhaseSetMappingProvider")
public Object[][] makeConstructPhaseSetMappingData() {
    List<Object[]> tests = new ArrayList<Object[]>();
    final Allele ref = Allele.create("A", true);
    final Allele altC = Allele.create("C", false);
    final Allele altT = Allele.create("T", false);
    final VariantContext vc1 = new VariantContextBuilder().chr("20").start(1).stop(1).alleles(Arrays.asList(ref, altC)).make();
    final VariantContext vc2 = new VariantContextBuilder().chr("20").start(2).stop(2).alleles(Arrays.asList(ref, altC)).make();
    final VariantContext vc3 = new VariantContextBuilder().chr("20").start(3).stop(3).alleles(Arrays.asList(ref, altT)).make();
    final VariantContext vc4 = new VariantContextBuilder().chr("20").start(4).stop(4).alleles(Arrays.asList(ref, altC)).make();
    final List<VariantContext> calls = Arrays.asList(vc2, vc3, vc4);
    final Haplotype pos1 = new Haplotype("CAAAA".getBytes());
    pos1.setEventMap(new EventMap(Arrays.asList(vc1)));
    pos1.getEventMap().put(1, vc1);
    final Haplotype pos2 = new Haplotype("ACAAA".getBytes());
    pos2.setEventMap(new EventMap(Arrays.asList(vc2)));
    pos2.getEventMap().put(2, vc2);
    final Haplotype pos3 = new Haplotype("AACAA".getBytes());
    pos3.setEventMap(new EventMap(Arrays.asList(vc3)));
    pos3.getEventMap().put(3, vc3);
    final Haplotype pos4 = new Haplotype("AAACA".getBytes());
    pos4.setEventMap(new EventMap(Arrays.asList(vc4)));
    pos4.getEventMap().put(4, vc4);
    final Haplotype pos24 = new Haplotype("ACACA".getBytes());
    pos24.setEventMap(new EventMap(Arrays.asList(vc2, vc4)));
    pos24.getEventMap().put(2, vc2);
    pos24.getEventMap().put(4, vc4);
    final Haplotype pos34 = new Haplotype("AACCA".getBytes());
    pos34.setEventMap(new EventMap(Arrays.asList(vc3, vc4)));
    pos34.getEventMap().put(3, vc3);
    pos34.getEventMap().put(4, vc4);
    final Haplotype pos234 = new Haplotype("ACCCA".getBytes());
    pos234.setEventMap(new EventMap(Arrays.asList(vc2, vc3, vc4)));
    pos234.getEventMap().put(2, vc2);
    pos234.getEventMap().put(3, vc3);
    pos234.getEventMap().put(4, vc4);
    final Map<VariantContext, Set<Haplotype>> haplotypeMap = new HashMap<>();
    // test no phased variants #1
    final Set<Haplotype> haplotypes2 = new HashSet<>();
    haplotypes2.add(pos2);
    haplotypeMap.put(vc2, haplotypes2);
    tests.add(new Object[] { Arrays.asList(vc2), new HashMap<>(haplotypeMap), 2, 0, 0, 0, 0 });
    // test no phased variants #2
    final Set<Haplotype> haplotypes3 = new HashSet<>();
    haplotypes3.add(pos3);
    haplotypeMap.put(vc3, haplotypes3);
    tests.add(new Object[] { Arrays.asList(vc2, vc3), new HashMap<>(haplotypeMap), 3, 0, 0, 0, 0 });
    // test opposite phase
    tests.add(new Object[] { Arrays.asList(vc2, vc3), new HashMap<>(haplotypeMap), 2, 2, 1, 1, 1 });
    // test no phased variants #3
    final Set<Haplotype> haplotypes4 = new HashSet<>();
    haplotypes4.add(pos4);
    haplotypeMap.put(vc4, haplotypes4);
    tests.add(new Object[] { calls, new HashMap<>(haplotypeMap), 3, 0, 0, 0, 0 });
    // test mixture
    final Set<Haplotype> haplotypes24 = new HashSet<>();
    haplotypes24.add(pos24);
    haplotypeMap.put(vc2, haplotypes24);
    haplotypeMap.put(vc4, haplotypes24);
    tests.add(new Object[] { calls, new HashMap<>(haplotypeMap), 2, 3, 1, 2, 1 });
    // test 2 hets
    haplotypeMap.remove(vc3);
    tests.add(new Object[] { Arrays.asList(vc2, vc4), new HashMap<>(haplotypeMap), 1, 2, 1, 2, 0 });
    // test 2 with opposite phase
    final Set<Haplotype> haplotypes1 = new HashSet<>();
    haplotypes1.add(pos1);
    haplotypeMap.put(vc1, haplotypes1);
    tests.add(new Object[] { Arrays.asList(vc1, vc2, vc4), new HashMap<>(haplotypeMap), 2, 3, 1, 1, 2 });
    // test homs around a het
    final Set<Haplotype> haplotypes2hom = new HashSet<>();
    haplotypes2hom.add(pos24);
    haplotypes2hom.add(pos234);
    final Set<Haplotype> haplotypes4hom = new HashSet<>();
    haplotypes4hom.add(pos24);
    haplotypes4hom.add(pos234);
    final Set<Haplotype> haplotypes3het = new HashSet<>();
    haplotypes3het.add(pos234);
    haplotypeMap.put(vc2, haplotypes2hom);
    haplotypeMap.put(vc3, haplotypes3het);
    haplotypeMap.put(vc4, haplotypes4hom);
    tests.add(new Object[] { calls, new HashMap<>(haplotypeMap), 2, 3, 1, 3, 0 });
    // test hets around a hom
    final Set<Haplotype> haplotypes2het = new HashSet<>();
    haplotypes2het.add(pos234);
    final Set<Haplotype> haplotypes4het = new HashSet<>();
    haplotypes4het.add(pos234);
    final Set<Haplotype> haplotypes3hom = new HashSet<>();
    haplotypes3hom.add(pos3);
    haplotypes3hom.add(pos234);
    haplotypeMap.put(vc2, haplotypes2het);
    haplotypeMap.put(vc3, haplotypes3hom);
    haplotypeMap.put(vc4, haplotypes4het);
    tests.add(new Object[] { calls, new HashMap<>(haplotypeMap), 2, 3, 1, 3, 0 });
    // test no phased variants around a hom
    final Set<Haplotype> haplotypes2incomplete = new HashSet<>();
    haplotypes2incomplete.add(pos24);
    final Set<Haplotype> haplotypes3incomplete = new HashSet<>();
    haplotypes3incomplete.add(pos34);
    final Set<Haplotype> haplotypes4complete = new HashSet<>();
    haplotypes4complete.add(pos24);
    haplotypes4complete.add(pos34);
    haplotypes4complete.add(pos234);
    haplotypeMap.put(vc2, haplotypes2incomplete);
    haplotypeMap.put(vc3, haplotypes3incomplete);
    haplotypeMap.put(vc4, haplotypes4complete);
    tests.add(new Object[] { calls, new HashMap<>(haplotypeMap), 0, 0, 0, 0, 0 });
    return tests.toArray(new Object[][] {});
}
Also used : EventMap(org.broadinstitute.hellbender.utils.haplotype.EventMap) Haplotype(org.broadinstitute.hellbender.utils.haplotype.Haplotype) DataProvider(org.testng.annotations.DataProvider)

Example 2 with EventMap

use of org.broadinstitute.hellbender.utils.haplotype.EventMap in project gatk by broadinstitute.

the class HaplotypeCallerGenotypingEngineUnitTest method makeConstructPhaseSetMappingData.

@DataProvider(name = "ConstructPhaseSetMappingProvider")
public Object[][] makeConstructPhaseSetMappingData() {
    List<Object[]> tests = new ArrayList<Object[]>();
    final Allele ref = Allele.create("A", true);
    final Allele altC = Allele.create("C", false);
    final Allele altT = Allele.create("T", false);
    final VariantContext vc1 = new VariantContextBuilder().chr("20").start(1).stop(1).alleles(Arrays.asList(ref, altC)).make();
    final VariantContext vc2 = new VariantContextBuilder().chr("20").start(2).stop(2).alleles(Arrays.asList(ref, altC)).make();
    final VariantContext vc3 = new VariantContextBuilder().chr("20").start(3).stop(3).alleles(Arrays.asList(ref, altT)).make();
    final VariantContext vc4 = new VariantContextBuilder().chr("20").start(4).stop(4).alleles(Arrays.asList(ref, altC)).make();
    final List<VariantContext> calls = Arrays.asList(vc2, vc3, vc4);
    final Haplotype pos1 = new Haplotype("CAAAA".getBytes());
    pos1.setEventMap(new EventMap(Arrays.asList(vc1)));
    pos1.getEventMap().put(1, vc1);
    final Haplotype pos2 = new Haplotype("ACAAA".getBytes());
    pos2.setEventMap(new EventMap(Arrays.asList(vc2)));
    pos2.getEventMap().put(2, vc2);
    final Haplotype pos3 = new Haplotype("AACAA".getBytes());
    pos3.setEventMap(new EventMap(Arrays.asList(vc3)));
    pos3.getEventMap().put(3, vc3);
    final Haplotype pos4 = new Haplotype("AAACA".getBytes());
    pos4.setEventMap(new EventMap(Arrays.asList(vc4)));
    pos4.getEventMap().put(4, vc4);
    final Haplotype pos24 = new Haplotype("ACACA".getBytes());
    pos24.setEventMap(new EventMap(Arrays.asList(vc2, vc4)));
    pos24.getEventMap().put(2, vc2);
    pos24.getEventMap().put(4, vc4);
    final Haplotype pos34 = new Haplotype("AACCA".getBytes());
    pos34.setEventMap(new EventMap(Arrays.asList(vc3, vc4)));
    pos34.getEventMap().put(3, vc3);
    pos34.getEventMap().put(4, vc4);
    final Haplotype pos234 = new Haplotype("ACCCA".getBytes());
    pos234.setEventMap(new EventMap(Arrays.asList(vc2, vc3, vc4)));
    pos234.getEventMap().put(2, vc2);
    pos234.getEventMap().put(3, vc3);
    pos234.getEventMap().put(4, vc4);
    final Map<VariantContext, Set<Haplotype>> haplotypeMap = new HashMap<>();
    // test no phased variants #1
    final Set<Haplotype> haplotypes2 = new HashSet<>();
    haplotypes2.add(pos2);
    haplotypeMap.put(vc2, haplotypes2);
    tests.add(new Object[] { Arrays.asList(vc2), new HashMap<>(haplotypeMap), 2, 0, 0, 0, 0 });
    // test no phased variants #2
    final Set<Haplotype> haplotypes3 = new HashSet<>();
    haplotypes3.add(pos3);
    haplotypeMap.put(vc3, haplotypes3);
    tests.add(new Object[] { Arrays.asList(vc2, vc3), new HashMap<>(haplotypeMap), 3, 0, 0, 0, 0 });
    // test opposite phase
    tests.add(new Object[] { Arrays.asList(vc2, vc3), new HashMap<>(haplotypeMap), 2, 2, 1, 1, 1 });
    // test no phased variants #3
    final Set<Haplotype> haplotypes4 = new HashSet<>();
    haplotypes4.add(pos4);
    haplotypeMap.put(vc4, haplotypes4);
    tests.add(new Object[] { calls, new HashMap<>(haplotypeMap), 3, 0, 0, 0, 0 });
    // test mixture
    final Set<Haplotype> haplotypes24 = new HashSet<>();
    haplotypes24.add(pos24);
    haplotypeMap.put(vc2, haplotypes24);
    haplotypeMap.put(vc4, haplotypes24);
    tests.add(new Object[] { calls, new HashMap<>(haplotypeMap), 2, 3, 1, 2, 1 });
    // test 2 hets
    haplotypeMap.remove(vc3);
    tests.add(new Object[] { Arrays.asList(vc2, vc4), new HashMap<>(haplotypeMap), 1, 2, 1, 2, 0 });
    // test 2 with opposite phase
    final Set<Haplotype> haplotypes1 = new HashSet<>();
    haplotypes1.add(pos1);
    haplotypeMap.put(vc1, haplotypes1);
    tests.add(new Object[] { Arrays.asList(vc1, vc2, vc4), new HashMap<>(haplotypeMap), 2, 3, 1, 1, 2 });
    // test homs around a het
    final Set<Haplotype> haplotypes2hom = new HashSet<>();
    haplotypes2hom.add(pos24);
    haplotypes2hom.add(pos234);
    final Set<Haplotype> haplotypes4hom = new HashSet<>();
    haplotypes4hom.add(pos24);
    haplotypes4hom.add(pos234);
    final Set<Haplotype> haplotypes3het = new HashSet<>();
    haplotypes3het.add(pos234);
    haplotypeMap.put(vc2, haplotypes2hom);
    haplotypeMap.put(vc3, haplotypes3het);
    haplotypeMap.put(vc4, haplotypes4hom);
    tests.add(new Object[] { calls, new HashMap<>(haplotypeMap), 2, 3, 1, 3, 0 });
    // test hets around a hom
    final Set<Haplotype> haplotypes2het = new HashSet<>();
    haplotypes2het.add(pos234);
    final Set<Haplotype> haplotypes4het = new HashSet<>();
    haplotypes4het.add(pos234);
    final Set<Haplotype> haplotypes3hom = new HashSet<>();
    haplotypes3hom.add(pos3);
    haplotypes3hom.add(pos234);
    haplotypeMap.put(vc2, haplotypes2het);
    haplotypeMap.put(vc3, haplotypes3hom);
    haplotypeMap.put(vc4, haplotypes4het);
    tests.add(new Object[] { calls, new HashMap<>(haplotypeMap), 2, 3, 1, 3, 0 });
    // test no phased variants around a hom
    final Set<Haplotype> haplotypes2incomplete = new HashSet<>();
    haplotypes2incomplete.add(pos24);
    final Set<Haplotype> haplotypes3incomplete = new HashSet<>();
    haplotypes3incomplete.add(pos34);
    final Set<Haplotype> haplotypes4complete = new HashSet<>();
    haplotypes4complete.add(pos24);
    haplotypes4complete.add(pos34);
    haplotypes4complete.add(pos234);
    haplotypeMap.put(vc2, haplotypes2incomplete);
    haplotypeMap.put(vc3, haplotypes3incomplete);
    haplotypeMap.put(vc4, haplotypes4complete);
    tests.add(new Object[] { calls, new HashMap<>(haplotypeMap), 0, 0, 0, 0, 0 });
    return tests.toArray(new Object[][] {});
}
Also used : EventMap(org.broadinstitute.hellbender.utils.haplotype.EventMap) Haplotype(org.broadinstitute.hellbender.utils.haplotype.Haplotype) DataProvider(org.testng.annotations.DataProvider)

Example 3 with EventMap

use of org.broadinstitute.hellbender.utils.haplotype.EventMap in project gatk by broadinstitute.

the class HaplotypeCallerGenotypingEngineUnitTest method makeCreateHaplotypeMappingData.

@DataProvider(name = "CreateHaplotypeMappingProvider")
public Object[][] makeCreateHaplotypeMappingData() {
    List<Object[]> tests = new ArrayList<Object[]>();
    final Set<Haplotype> haplotypes = new HashSet<>();
    final Allele ref = Allele.create("A", true);
    final Allele altC = Allele.create("C", false);
    final Allele altT = Allele.create("T", false);
    final Haplotype AtoC1 = new Haplotype("AACAA".getBytes());
    final VariantContext vc1 = new VariantContextBuilder().chr("20").start(3).stop(3).alleles(Arrays.asList(ref, altC)).make();
    AtoC1.setEventMap(new EventMap(Arrays.asList(vc1)));
    AtoC1.getEventMap().put(3, vc1);
    haplotypes.add(AtoC1);
    final Haplotype AtoC2 = new Haplotype("AAACA".getBytes());
    final VariantContext vc2 = new VariantContextBuilder().chr("20").start(4).stop(4).alleles(Arrays.asList(ref, altT)).make();
    AtoC2.setEventMap(new EventMap(Arrays.asList(vc2)));
    AtoC2.getEventMap().put(4, vc2);
    haplotypes.add(AtoC2);
    tests.add(new Object[] { vc1, haplotypes, AtoC1 });
    tests.add(new Object[] { vc2, haplotypes, AtoC2 });
    tests.add(new Object[] { new VariantContextBuilder().chr("20").start(1).stop(1).alleles(Arrays.asList(ref, altT)).make(), haplotypes, null });
    return tests.toArray(new Object[][] {});
}
Also used : Haplotype(org.broadinstitute.hellbender.utils.haplotype.Haplotype) EventMap(org.broadinstitute.hellbender.utils.haplotype.EventMap) DataProvider(org.testng.annotations.DataProvider)

Example 4 with EventMap

use of org.broadinstitute.hellbender.utils.haplotype.EventMap in project gatk-protected by broadinstitute.

the class HaplotypeCallerGenotypingEngineUnitTest method makeCreateHaplotypeMappingData.

@DataProvider(name = "CreateHaplotypeMappingProvider")
public Object[][] makeCreateHaplotypeMappingData() {
    List<Object[]> tests = new ArrayList<Object[]>();
    final Set<Haplotype> haplotypes = new HashSet<>();
    final Allele ref = Allele.create("A", true);
    final Allele altC = Allele.create("C", false);
    final Allele altT = Allele.create("T", false);
    final Haplotype AtoC1 = new Haplotype("AACAA".getBytes());
    final VariantContext vc1 = new VariantContextBuilder().chr("20").start(3).stop(3).alleles(Arrays.asList(ref, altC)).make();
    AtoC1.setEventMap(new EventMap(Arrays.asList(vc1)));
    AtoC1.getEventMap().put(3, vc1);
    haplotypes.add(AtoC1);
    final Haplotype AtoC2 = new Haplotype("AAACA".getBytes());
    final VariantContext vc2 = new VariantContextBuilder().chr("20").start(4).stop(4).alleles(Arrays.asList(ref, altT)).make();
    AtoC2.setEventMap(new EventMap(Arrays.asList(vc2)));
    AtoC2.getEventMap().put(4, vc2);
    haplotypes.add(AtoC2);
    tests.add(new Object[] { vc1, haplotypes, AtoC1 });
    tests.add(new Object[] { vc2, haplotypes, AtoC2 });
    tests.add(new Object[] { new VariantContextBuilder().chr("20").start(1).stop(1).alleles(Arrays.asList(ref, altT)).make(), haplotypes, null });
    return tests.toArray(new Object[][] {});
}
Also used : Haplotype(org.broadinstitute.hellbender.utils.haplotype.Haplotype) EventMap(org.broadinstitute.hellbender.utils.haplotype.EventMap) DataProvider(org.testng.annotations.DataProvider)

Aggregations

EventMap (org.broadinstitute.hellbender.utils.haplotype.EventMap)4 Haplotype (org.broadinstitute.hellbender.utils.haplotype.Haplotype)4 DataProvider (org.testng.annotations.DataProvider)4