use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.
the class TargetCollectionUnitTest method testForEachExhaustiveRanges.
@Test(dataProvider = "targetDBData")
public void testForEachExhaustiveRanges(final TargetCollection<SimpleInterval> targetCollection) {
final int min = 0;
final int max = targetCollection.targetCount();
for (int i = min; i < max; i++) {
final SimpleInterval iInterval = targetCollection.target(i);
final String contig = iInterval.getContig();
final int start = (iInterval.getStart() + iInterval.getEnd()) >> 1;
for (int j = i; j < max; j++) {
final SimpleInterval jInterval = targetCollection.target(j);
if (!jInterval.getContig().equals(contig)) {
break;
}
final int end = (jInterval.getStart() + jInterval.getEnd() + 1) >> 1;
if (start > end) {
continue;
}
final SimpleInterval loc = TargetsToolsTestUtils.createInterval(contig, start, end);
final List<SimpleInterval> visited = new ArrayList<>(j - i + 1);
final int iFinal = i;
targetCollection.forEachTarget(loc, (idx, e) -> {
Assert.assertEquals(idx, iFinal + visited.size());
Assert.assertEquals(e, targetCollection.target(idx));
visited.add(e);
});
Assert.assertEquals(visited.size(), j - i + 1);
}
}
}
use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.
the class TargetCollectionUnitTest method testForEachSingleCallExactMatch.
@Test(dataProvider = "targetDBData")
public void testForEachSingleCallExactMatch(final TargetCollection<SimpleInterval> targetCollection) {
for (int i = 0; i < targetCollection.targetCount(); i++) {
final SimpleInterval simpleInterval = targetCollection.target(i);
final SimpleInterval loc = TargetsToolsTestUtils.createInterval(simpleInterval.getContig(), simpleInterval.getStart(), simpleInterval.getEnd());
final int expectedIdx = i;
final int[] totalCalls = new int[] { 0 };
targetCollection.forEachTarget(loc, (idx, target) -> {
Assert.assertEquals(target, simpleInterval);
Assert.assertEquals(idx, expectedIdx);
totalCalls[0]++;
});
Assert.assertEquals(totalCalls[0], 1);
}
}
use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.
the class TargetCollectionUnitTest method testTargetsByLocationExhaustiveZeroRanges.
@Test(dataProvider = "targetDBData")
public void testTargetsByLocationExhaustiveZeroRanges(final TargetCollection<SimpleInterval> targetCollection) {
final int min = 0;
final int max = targetCollection.targetCount();
for (int i = min; i < max - 1; i++) {
final SimpleInterval iInterval = targetCollection.target(i);
final SimpleInterval jInterval = targetCollection.target(i + 1);
if (!jInterval.getContig().equals(iInterval.getContig()))
continue;
final int start = iInterval.getEnd() + 1;
final int end = jInterval.getStart() - 1;
if (start < end)
continue;
final List<SimpleInterval> observed = targetCollection.targets(TargetsToolsTestUtils.createInterval(iInterval.getContig(), start, end));
Assert.assertEquals(observed.size(), 0);
}
}
use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.
the class TargetUnitTest method testGetEndWithInterval.
@Test()
public void testGetEndWithInterval() {
final Target subject = new Target("my-name", new SimpleInterval("1", 1, 2));
Assert.assertEquals(subject.getEnd(), 2);
}
use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.
the class TargetUnitTest method testConstructorWithInterval.
@Test()
public void testConstructorWithInterval() {
final Target subject1 = new Target("my-name", null);
Assert.assertEquals(subject1.getName(), "my-name");
Assert.assertNull(subject1.getInterval());
final Target subject2 = new Target("my-name", new SimpleInterval("1", 1, 2));
Assert.assertEquals(subject2.getName(), "my-name");
Assert.assertEquals(subject2.getInterval(), new SimpleInterval("1", 1, 2));
}
Aggregations