Search in sources :

Example 86 with DataProvider

use of org.testng.annotations.DataProvider in project gatk by broadinstitute.

the class SampleCollectionUnitTest method testSampleIndexByReadWithReadGroupWithoutSample.

@Test(dataProvider = "samFileHeaderData", dependsOnMethods = "testCreation")
public void testSampleIndexByReadWithReadGroupWithoutSample(final SAMFileHeader header) {
    final String readGroup = header.getReadGroups().stream().filter(rg -> rg.getSample() == null).map(SAMReadGroupRecord::getId).findFirst().orElse(null);
    if (readGroup == null)
        return;
    final SampleCollection sampleCollection = new SampleCollection(header);
    final GATKRead read = ArtificialReadUtils.createRandomRead(header, 100);
    if (sampleCollection.sampleCount() > 0) {
        read.setReadGroup(readGroup);
        Assert.assertEquals(sampleCollection.sampleIndexByRead(read), -1);
    }
}
Also used : java.util(java.util) SAMReadGroupRecord(htsjdk.samtools.SAMReadGroupRecord) ArtificialReadUtils(org.broadinstitute.hellbender.utils.read.ArtificialReadUtils) Assert(org.testng.Assert) DataProvider(org.testng.annotations.DataProvider) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) BeforeClass(org.testng.annotations.BeforeClass) Test(org.testng.annotations.Test) GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) SAMFileHeader(htsjdk.samtools.SAMFileHeader) Collectors(java.util.stream.Collectors) GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) SAMReadGroupRecord(htsjdk.samtools.SAMReadGroupRecord) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 87 with DataProvider

use of org.testng.annotations.DataProvider in project gatk by broadinstitute.

the class SampleCollectionUnitTest method testReadGroupIndexByReadWithReadGroupWithoutSample.

@Test(dataProvider = "samFileHeaderData", dependsOnMethods = "testCreation")
public void testReadGroupIndexByReadWithReadGroupWithoutSample(final SAMFileHeader header) {
    final String readGroup = header.getReadGroups().stream().filter(rg -> rg.getSample() == null).map(SAMReadGroupRecord::getId).findFirst().orElse(null);
    if (readGroup == null)
        return;
    final SampleCollection sampleCollection = new SampleCollection(header);
    final GATKRead read = ArtificialReadUtils.createRandomRead(header, 100);
    read.setReadGroup(readGroup);
    Assert.assertEquals(sampleCollection.readGroupIndexByRead(read), sampleCollection.readGroupIndexById(readGroup));
}
Also used : java.util(java.util) SAMReadGroupRecord(htsjdk.samtools.SAMReadGroupRecord) ArtificialReadUtils(org.broadinstitute.hellbender.utils.read.ArtificialReadUtils) Assert(org.testng.Assert) DataProvider(org.testng.annotations.DataProvider) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) BeforeClass(org.testng.annotations.BeforeClass) Test(org.testng.annotations.Test) GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) SAMFileHeader(htsjdk.samtools.SAMFileHeader) Collectors(java.util.stream.Collectors) GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) SAMReadGroupRecord(htsjdk.samtools.SAMReadGroupRecord) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 88 with DataProvider

use of org.testng.annotations.DataProvider in project gatk by broadinstitute.

the class GatherBamFilesIntegrationTest method gatherBAMTestData.

@DataProvider(name = "bamgathering")
public Object[][] gatherBAMTestData() {
    final File origBam = new File(TEST_DATA_DIR, "orig.bam");
    final List<File> splitBamsUnmappedLast = Arrays.asList(new File(TEST_DATA_DIR, "indchr1.bam"), new File(TEST_DATA_DIR, "indchr2.bam"), new File(TEST_DATA_DIR, "indchr3.bam"), new File(TEST_DATA_DIR, "indchr4.bam"), new File(TEST_DATA_DIR, "indchr5.bam"), new File(TEST_DATA_DIR, "indchr6.bam"), new File(TEST_DATA_DIR, "indchr7.bam"), new File(TEST_DATA_DIR, "indchr8.bam"), new File(TEST_DATA_DIR, "indUnknownChrom.bam"));
    final List<File> splitBamsUnmappedFirst = Arrays.asList(new File(TEST_DATA_DIR, "indUnknownChrom.bam"), new File(TEST_DATA_DIR, "indchr1.bam"), new File(TEST_DATA_DIR, "indchr2.bam"), new File(TEST_DATA_DIR, "indchr3.bam"), new File(TEST_DATA_DIR, "indchr4.bam"), new File(TEST_DATA_DIR, "indchr5.bam"), new File(TEST_DATA_DIR, "indchr6.bam"), new File(TEST_DATA_DIR, "indchr7.bam"), new File(TEST_DATA_DIR, "indchr8.bam"));
    final List<File> splitBamsUnmappedMissing = Arrays.asList(new File(TEST_DATA_DIR, "indchr1.bam"), new File(TEST_DATA_DIR, "indchr2.bam"), new File(TEST_DATA_DIR, "indchr3.bam"), new File(TEST_DATA_DIR, "indchr4.bam"), new File(TEST_DATA_DIR, "indchr5.bam"), new File(TEST_DATA_DIR, "indchr6.bam"), new File(TEST_DATA_DIR, "indchr7.bam"), new File(TEST_DATA_DIR, "indchr8.bam"));
    return new Object[][] { { splitBamsUnmappedLast, origBam, true, true }, { splitBamsUnmappedFirst, origBam, false, true }, { splitBamsUnmappedMissing, origBam, false, false } };
}
Also used : File(java.io.File) DataProvider(org.testng.annotations.DataProvider)

Example 89 with DataProvider

use of org.testng.annotations.DataProvider in project gatk by broadinstitute.

the class IntervalsSkipListOneContigUnitTest method intervals.

@DataProvider(name = "intervals")
public Object[][] intervals() {
    ArrayList<Locatable> input = Lists.newArrayList(new SimpleInterval("1", 10, 100));
    ArrayList<Locatable> empty = new ArrayList<>();
    ArrayList<Locatable> manyOverlapping = Lists.newArrayList(new SimpleInterval("1", 10, 100), // special case: multiple intervals starting at the same place
    new SimpleInterval("1", 20, 50), new SimpleInterval("1", 20, 50), new SimpleInterval("1", 20, 50));
    ArrayList<Locatable> mixInput = Lists.newArrayList(// ends before query interval
    new SimpleInterval("1", 10, 20), // ends in query interval
    new SimpleInterval("1", 10, 60), // equal to query interval
    new SimpleInterval("1", 30, 50), // covered by query interval
    new SimpleInterval("1", 40, 42), // ends after query interval
    new SimpleInterval("1", 45, 60), // starts after query interval
    new SimpleInterval("1", 60, 100));
    ArrayList<Locatable> mixExpected = Lists.newArrayList(// ends in query interval
    new SimpleInterval("1", 10, 60), // equal to query interval
    new SimpleInterval("1", 30, 50), // covered by query interval
    new SimpleInterval("1", 40, 42), // ends after query interval
    new SimpleInterval("1", 45, 60));
    // returns input single SimpleInterval, query range, expected SimpleInterval
    return new Object[][] { // single-point boundary cases
    new Object[] { input, new SimpleInterval("1", 10, 10), input }, new Object[] { input, new SimpleInterval("1", 100, 100), input }, new Object[] { input, new SimpleInterval("1", 9, 9), empty }, new Object[] { input, new SimpleInterval("1", 11, 11), input }, new Object[] { input, new SimpleInterval("1", 99, 99), input }, new Object[] { input, new SimpleInterval("1", 101, 101), empty }, // empty list boundary case
    new Object[] { empty, new SimpleInterval("1", 101, 101), empty }, // different contig
    new Object[] { empty, new SimpleInterval("2", 101, 101), empty }, // input exactly matches the query interval
    new Object[] { input, new SimpleInterval("1", 10, 100), input }, // multiple intervals in the same place (potential edge case for indexing)
    new Object[] { manyOverlapping, new SimpleInterval("1", 20, 20), manyOverlapping }, // input with multiple intervals
    new Object[] { mixInput, new SimpleInterval("1", 30, 50), mixExpected } };
}
Also used : ArrayList(java.util.ArrayList) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) Locatable(htsjdk.samtools.util.Locatable) DataProvider(org.testng.annotations.DataProvider)

Example 90 with DataProvider

use of org.testng.annotations.DataProvider in project gatk by broadinstitute.

the class HomRefBlockUnitTest method makeContiguousData.

@DataProvider(name = "ContiguousData")
public Object[][] makeContiguousData() {
    final List<Object[]> tests = new ArrayList<>();
    final VariantContext vc = getVariantContext();
    for (final String chrMod : Arrays.asList("", ".mismatch")) {
        for (final int offset : Arrays.asList(-10, -1, 0, 1, 10)) {
            final boolean equals = chrMod.isEmpty() && offset == 0;
            tests.add(new Object[] { vc.getContig() + chrMod, vc.getStart() + offset, equals });
        }
    }
    return tests.toArray(new Object[][] {});
}
Also used : ArrayList(java.util.ArrayList) VariantContext(htsjdk.variant.variantcontext.VariantContext) DataProvider(org.testng.annotations.DataProvider)

Aggregations

DataProvider (org.testng.annotations.DataProvider)391 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)99 ArrayList (java.util.ArrayList)93 Test (org.testng.annotations.Test)85 File (java.io.File)74 List (java.util.List)72 Assert (org.testng.Assert)67 URIDetails (com.linkedin.restli.internal.testutils.URIDetails)65 Collectors (java.util.stream.Collectors)61 HashMap (java.util.HashMap)57 IntStream (java.util.stream.IntStream)54 Random (java.util.Random)50 RealMatrix (org.apache.commons.math3.linear.RealMatrix)44 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)41 IOException (java.io.IOException)39 ByteString (com.linkedin.data.ByteString)37 Array2DRowRealMatrix (org.apache.commons.math3.linear.Array2DRowRealMatrix)34 Stream (java.util.stream.Stream)31 DoubleStream (java.util.stream.DoubleStream)29 HashSet (java.util.HashSet)28