Search in sources :

Example 1 with SimpleFeature

use of htsjdk.tribble.SimpleFeature in project gatk by broadinstitute.

the class IntervalUtilsUnitTest method lexicographicalOrderComparatorData.

@DataProvider(name = "lexicographicalOrderComparatorData")
public Object[][] lexicographicalOrderComparatorData() {
    final String[] CONTIG_NAMES = new String[] { "A", "AA", "B", "C", null };
    final int[] CONTIG_SIZES = new int[] { 200, 300, 400, 500, 600 };
    final int MIN_INTERVAL_SIZE = 1;
    final int MAX_INTERVAL_SIZE = 100;
    final Random rdn = new Random(1131312131);
    final int CASE_NUMBER = 100;
    final List<Object[]> result = new ArrayList<>(100);
    for (int i = 0; i < CASE_NUMBER; i++) {
        final int locatableCount = rdn.nextInt(100) + 1;
        final List<Locatable> locatables = new ArrayList<>(locatableCount);
        for (int j = 0; j < locatableCount; j++) {
            final int contigIdx = rdn.nextInt(CONTIG_NAMES.length);
            final String contig = CONTIG_NAMES[contigIdx];
            final boolean useSimpleInterval = contig == null ? false : rdn.nextBoolean();
            final int intervalSize = rdn.nextInt(MAX_INTERVAL_SIZE - MIN_INTERVAL_SIZE + 1) + MIN_INTERVAL_SIZE;
            final int start = rdn.nextInt(CONTIG_SIZES[contigIdx] - intervalSize) + 1;
            final int end = start + intervalSize - 1;
            final Locatable loc = useSimpleInterval ? new SimpleInterval(contig, start, end) : new SimpleFeature(contig, start, end);
            locatables.add(loc);
        }
        result.add(new Object[] { locatables });
    }
    return result.toArray(new Object[result.size()][]);
}
Also used : SimpleFeature(htsjdk.tribble.SimpleFeature) Locatable(htsjdk.samtools.util.Locatable) DataProvider(org.testng.annotations.DataProvider)

Example 2 with SimpleFeature

use of htsjdk.tribble.SimpleFeature in project gatk by broadinstitute.

the class GenomeLocParserUnitTest method testCreationFromFeature.

@Test
public void testCreationFromFeature() {
    final Feature feature = new SimpleFeature("1", 1, 5);
    final GenomeLoc loc = genomeLocParser.createGenomeLoc(feature);
    Assert.assertEquals(loc.getContig(), feature.getContig());
    Assert.assertEquals(loc.getStart(), feature.getStart());
    Assert.assertEquals(loc.getStop(), feature.getEnd());
}
Also used : SimpleFeature(htsjdk.tribble.SimpleFeature) Feature(htsjdk.tribble.Feature) SimpleFeature(htsjdk.tribble.SimpleFeature) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Aggregations

SimpleFeature (htsjdk.tribble.SimpleFeature)2 Locatable (htsjdk.samtools.util.Locatable)1 Feature (htsjdk.tribble.Feature)1 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)1 DataProvider (org.testng.annotations.DataProvider)1 Test (org.testng.annotations.Test)1