コード例 #1
0
  @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 GenomeLoc originalLocation = original.getExtendedSpan();
    final int length = originalLocation.size();
    final GenomeLoc newLocation =
        originalLocation.setStop(
            originalLocation.setStart(originalLocation, originalLocation.getStart() + length / 2),
            originalLocation.getStop() - 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());
    }
  }
コード例 #2
0
  @Test
  public void testEmptyResultSet() {
    final AssemblyResultSet subject = new AssemblyResultSet();

    Assert.assertEquals(subject.getHaplotypeList().size(), 0);
    Assert.assertEquals(subject.getHaplotypeCount(), 0);
    Assert.assertEquals(subject.getReferenceHaplotype(), null);
    Assert.assertEquals(subject.getFullReferenceWithPadding(), null);
    Assert.assertEquals(subject.getPaddedReferenceLoc(), null);
    Assert.assertEquals(subject.getRegionForGenotyping(), null);
    Assert.assertEquals(subject.getUniqueReadThreadingGraph(10), null);
    Assert.assertFalse(subject.hasMultipleKmerSizes());
  }
コード例 #3
0
 @Test(dataProvider = "assemblyResults")
 public void testAddManyHaplotypes(
     final java.util.List<AssemblyResult> assemblyResults,
     final java.util.List<java.util.List<Haplotype>> haplotypes) {
   final AssemblyResultSet subject = new AssemblyResultSet();
   for (int i = 0; i < haplotypes.size(); i++) {
     final int haplotypeCountBefore = subject.getHaplotypeCount();
     final java.util.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());
   }
 }
コード例 #4
0
  @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);
  }