@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()); } }
@DataProvider(name = "trimmingData") public Iterator<Object[]> trimmingData() { final AssemblyRegion activeRegion = new AssemblyRegion( genomeLocParser.createGenomeLoc("1", 1000, 1100), genomeLocParser, 25, header); final int length = activeRegion.getExtendedSpan().size(); final RandomDNA rnd = new RandomDNA(13); // keep it prepoducible by fixing the seed to lucky 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(); }