Search in sources :

Example 91 with DataProvider

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

the class CollectAllelicCountsIntegrationTest method testData.

@DataProvider(name = "testData")
public Object[][] testData() throws IOException {
    //counts from IGV with minMQ = 30 and minBQ = 20
    final AllelicCountCollection normalCountsExpected = new AllelicCountCollection();
    normalCountsExpected.add(new AllelicCount(new SimpleInterval("1", 10736, 10736), 0, 0));
    normalCountsExpected.add(new AllelicCount(new SimpleInterval("1", 11522, 11522), 7, 4));
    normalCountsExpected.add(new AllelicCount(new SimpleInterval("1", 12098, 12098), 8, 6));
    normalCountsExpected.add(new AllelicCount(new SimpleInterval("1", 12444, 12444), 0, 18));
    normalCountsExpected.add(new AllelicCount(new SimpleInterval("1", 13059, 13059), 0, 8));
    normalCountsExpected.add(new AllelicCount(new SimpleInterval("1", 14630, 14630), 9, 8));
    normalCountsExpected.add(new AllelicCount(new SimpleInterval("1", 15204, 15204), 4, 4));
    normalCountsExpected.add(new AllelicCount(new SimpleInterval("2", 14689, 14689), 6, 9));
    normalCountsExpected.add(new AllelicCount(new SimpleInterval("2", 14982, 14982), 6, 5));
    normalCountsExpected.add(new AllelicCount(new SimpleInterval("2", 15110, 15110), 6, 0));
    normalCountsExpected.add(new AllelicCount(new SimpleInterval("2", 15629, 15629), 5, 3));
    final AllelicCountCollection tumorCountsExpected = new AllelicCountCollection();
    tumorCountsExpected.add(new AllelicCount(new SimpleInterval("1", 10736, 10736), 0, 0));
    tumorCountsExpected.add(new AllelicCount(new SimpleInterval("1", 11522, 11522), 7, 4));
    tumorCountsExpected.add(new AllelicCount(new SimpleInterval("1", 12098, 12098), 8, 6));
    tumorCountsExpected.add(new AllelicCount(new SimpleInterval("1", 12444, 12444), 0, 17));
    tumorCountsExpected.add(new AllelicCount(new SimpleInterval("1", 13059, 13059), 0, 8));
    tumorCountsExpected.add(new AllelicCount(new SimpleInterval("1", 14630, 14630), 9, 8));
    tumorCountsExpected.add(new AllelicCount(new SimpleInterval("1", 15204, 15204), 4, 3));
    tumorCountsExpected.add(new AllelicCount(new SimpleInterval("2", 14689, 14689), 6, 9));
    tumorCountsExpected.add(new AllelicCount(new SimpleInterval("2", 14982, 14982), 6, 5));
    tumorCountsExpected.add(new AllelicCount(new SimpleInterval("2", 15110, 15110), 6, 0));
    tumorCountsExpected.add(new AllelicCount(new SimpleInterval("2", 15629, 15629), 5, 3));
    return new Object[][] { { NORMAL_BAM_FILE, normalCountsExpected }, { TUMOR_BAM_FILE, tumorCountsExpected } };
}
Also used : AllelicCountCollection(org.broadinstitute.hellbender.tools.copynumber.allelic.alleliccount.AllelicCountCollection) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) AllelicCount(org.broadinstitute.hellbender.tools.copynumber.allelic.alleliccount.AllelicCount) DataProvider(org.testng.annotations.DataProvider)

Example 92 with DataProvider

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

the class HaplotypeCallerGenotypingEngineUnitTest method makeConstructPhaseSetMappingData.

@DataProvider(name = "ConstructPhaseSetMappingProvider")
public Object[][] makeConstructPhaseSetMappingData() {
    List<Object[]> tests = new ArrayList<Object[]>();
    final Allele ref = Allele.create("A", true);
    final Allele altC = Allele.create("C", false);
    final Allele altT = Allele.create("T", false);
    final VariantContext vc1 = new VariantContextBuilder().chr("20").start(1).stop(1).alleles(Arrays.asList(ref, altC)).make();
    final VariantContext vc2 = new VariantContextBuilder().chr("20").start(2).stop(2).alleles(Arrays.asList(ref, altC)).make();
    final VariantContext vc3 = new VariantContextBuilder().chr("20").start(3).stop(3).alleles(Arrays.asList(ref, altT)).make();
    final VariantContext vc4 = new VariantContextBuilder().chr("20").start(4).stop(4).alleles(Arrays.asList(ref, altC)).make();
    final List<VariantContext> calls = Arrays.asList(vc2, vc3, vc4);
    final Haplotype pos1 = new Haplotype("CAAAA".getBytes());
    pos1.setEventMap(new EventMap(Arrays.asList(vc1)));
    pos1.getEventMap().put(1, vc1);
    final Haplotype pos2 = new Haplotype("ACAAA".getBytes());
    pos2.setEventMap(new EventMap(Arrays.asList(vc2)));
    pos2.getEventMap().put(2, vc2);
    final Haplotype pos3 = new Haplotype("AACAA".getBytes());
    pos3.setEventMap(new EventMap(Arrays.asList(vc3)));
    pos3.getEventMap().put(3, vc3);
    final Haplotype pos4 = new Haplotype("AAACA".getBytes());
    pos4.setEventMap(new EventMap(Arrays.asList(vc4)));
    pos4.getEventMap().put(4, vc4);
    final Haplotype pos24 = new Haplotype("ACACA".getBytes());
    pos24.setEventMap(new EventMap(Arrays.asList(vc2, vc4)));
    pos24.getEventMap().put(2, vc2);
    pos24.getEventMap().put(4, vc4);
    final Haplotype pos34 = new Haplotype("AACCA".getBytes());
    pos34.setEventMap(new EventMap(Arrays.asList(vc3, vc4)));
    pos34.getEventMap().put(3, vc3);
    pos34.getEventMap().put(4, vc4);
    final Haplotype pos234 = new Haplotype("ACCCA".getBytes());
    pos234.setEventMap(new EventMap(Arrays.asList(vc2, vc3, vc4)));
    pos234.getEventMap().put(2, vc2);
    pos234.getEventMap().put(3, vc3);
    pos234.getEventMap().put(4, vc4);
    final Map<VariantContext, Set<Haplotype>> haplotypeMap = new HashMap<>();
    // test no phased variants #1
    final Set<Haplotype> haplotypes2 = new HashSet<>();
    haplotypes2.add(pos2);
    haplotypeMap.put(vc2, haplotypes2);
    tests.add(new Object[] { Arrays.asList(vc2), new HashMap<>(haplotypeMap), 2, 0, 0, 0, 0 });
    // test no phased variants #2
    final Set<Haplotype> haplotypes3 = new HashSet<>();
    haplotypes3.add(pos3);
    haplotypeMap.put(vc3, haplotypes3);
    tests.add(new Object[] { Arrays.asList(vc2, vc3), new HashMap<>(haplotypeMap), 3, 0, 0, 0, 0 });
    // test opposite phase
    tests.add(new Object[] { Arrays.asList(vc2, vc3), new HashMap<>(haplotypeMap), 2, 2, 1, 1, 1 });
    // test no phased variants #3
    final Set<Haplotype> haplotypes4 = new HashSet<>();
    haplotypes4.add(pos4);
    haplotypeMap.put(vc4, haplotypes4);
    tests.add(new Object[] { calls, new HashMap<>(haplotypeMap), 3, 0, 0, 0, 0 });
    // test mixture
    final Set<Haplotype> haplotypes24 = new HashSet<>();
    haplotypes24.add(pos24);
    haplotypeMap.put(vc2, haplotypes24);
    haplotypeMap.put(vc4, haplotypes24);
    tests.add(new Object[] { calls, new HashMap<>(haplotypeMap), 2, 3, 1, 2, 1 });
    // test 2 hets
    haplotypeMap.remove(vc3);
    tests.add(new Object[] { Arrays.asList(vc2, vc4), new HashMap<>(haplotypeMap), 1, 2, 1, 2, 0 });
    // test 2 with opposite phase
    final Set<Haplotype> haplotypes1 = new HashSet<>();
    haplotypes1.add(pos1);
    haplotypeMap.put(vc1, haplotypes1);
    tests.add(new Object[] { Arrays.asList(vc1, vc2, vc4), new HashMap<>(haplotypeMap), 2, 3, 1, 1, 2 });
    // test homs around a het
    final Set<Haplotype> haplotypes2hom = new HashSet<>();
    haplotypes2hom.add(pos24);
    haplotypes2hom.add(pos234);
    final Set<Haplotype> haplotypes4hom = new HashSet<>();
    haplotypes4hom.add(pos24);
    haplotypes4hom.add(pos234);
    final Set<Haplotype> haplotypes3het = new HashSet<>();
    haplotypes3het.add(pos234);
    haplotypeMap.put(vc2, haplotypes2hom);
    haplotypeMap.put(vc3, haplotypes3het);
    haplotypeMap.put(vc4, haplotypes4hom);
    tests.add(new Object[] { calls, new HashMap<>(haplotypeMap), 2, 3, 1, 3, 0 });
    // test hets around a hom
    final Set<Haplotype> haplotypes2het = new HashSet<>();
    haplotypes2het.add(pos234);
    final Set<Haplotype> haplotypes4het = new HashSet<>();
    haplotypes4het.add(pos234);
    final Set<Haplotype> haplotypes3hom = new HashSet<>();
    haplotypes3hom.add(pos3);
    haplotypes3hom.add(pos234);
    haplotypeMap.put(vc2, haplotypes2het);
    haplotypeMap.put(vc3, haplotypes3hom);
    haplotypeMap.put(vc4, haplotypes4het);
    tests.add(new Object[] { calls, new HashMap<>(haplotypeMap), 2, 3, 1, 3, 0 });
    // test no phased variants around a hom
    final Set<Haplotype> haplotypes2incomplete = new HashSet<>();
    haplotypes2incomplete.add(pos24);
    final Set<Haplotype> haplotypes3incomplete = new HashSet<>();
    haplotypes3incomplete.add(pos34);
    final Set<Haplotype> haplotypes4complete = new HashSet<>();
    haplotypes4complete.add(pos24);
    haplotypes4complete.add(pos34);
    haplotypes4complete.add(pos234);
    haplotypeMap.put(vc2, haplotypes2incomplete);
    haplotypeMap.put(vc3, haplotypes3incomplete);
    haplotypeMap.put(vc4, haplotypes4complete);
    tests.add(new Object[] { calls, new HashMap<>(haplotypeMap), 0, 0, 0, 0, 0 });
    return tests.toArray(new Object[][] {});
}
Also used : EventMap(org.broadinstitute.hellbender.utils.haplotype.EventMap) Haplotype(org.broadinstitute.hellbender.utils.haplotype.Haplotype) DataProvider(org.testng.annotations.DataProvider)

Example 93 with DataProvider

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

the class HDF5PCACoveragePoNCreationUtilsUnitTest method testSubtractMedianOfMedians.

@Test(dataProvider = "readCountOnlyData")
public void testSubtractMedianOfMedians(final ReadCountCollection readCounts) {
    final RealMatrix counts = readCounts.counts();
    final Median median = new Median();
    final double[] columnMedians = IntStream.range(0, counts.getColumnDimension()).mapToDouble(i -> median.evaluate(counts.getColumn(i))).toArray();
    final double center = median.evaluate(columnMedians);
    final double[][] expected = new double[counts.getRowDimension()][];
    for (int i = 0; i < expected.length; i++) {
        expected[i] = counts.getRow(i).clone();
        for (int j = 0; j < expected[i].length; j++) {
            expected[i][j] -= center;
        }
    }
    HDF5PCACoveragePoNCreationUtils.subtractMedianOfMedians(readCounts, NULL_LOGGER);
    final RealMatrix newCounts = readCounts.counts();
    Assert.assertEquals(newCounts.getColumnDimension(), expected[0].length);
    Assert.assertEquals(newCounts.getRowDimension(), expected.length);
    for (int i = 0; i < expected.length; i++) {
        for (int j = 0; j < expected[i].length; j++) {
            Assert.assertEquals(newCounts.getEntry(i, j), expected[i][j], 0.000001);
        }
    }
}
Also used : IntStream(java.util.stream.IntStream) SVD(org.broadinstitute.hellbender.utils.svd.SVD) DataProvider(org.testng.annotations.DataProvider) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) JavaSparkContext(org.apache.spark.api.java.JavaSparkContext) Level(org.apache.logging.log4j.Level) MatrixSummaryUtils(org.broadinstitute.hellbender.utils.MatrixSummaryUtils) Test(org.testng.annotations.Test) Random(java.util.Random) OptionalInt(java.util.OptionalInt) ParamUtils(org.broadinstitute.hellbender.utils.param.ParamUtils) ArrayList(java.util.ArrayList) Mean(org.apache.commons.math3.stat.descriptive.moment.Mean) Pair(org.apache.commons.lang3.tuple.Pair) Message(org.apache.logging.log4j.message.Message) Assert(org.testng.Assert) Median(org.apache.commons.math3.stat.descriptive.rank.Median) HDF5File(org.broadinstitute.hdf5.HDF5File) Marker(org.apache.logging.log4j.Marker) AbstractLogger(org.apache.logging.log4j.spi.AbstractLogger) Array2DRowRealMatrix(org.apache.commons.math3.linear.Array2DRowRealMatrix) IOUtils(org.broadinstitute.hellbender.utils.io.IOUtils) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) Collectors(java.util.stream.Collectors) File(java.io.File) DoubleStream(java.util.stream.DoubleStream) List(java.util.List) Percentile(org.apache.commons.math3.stat.descriptive.rank.Percentile) Logger(org.apache.logging.log4j.Logger) ReadCountCollection(org.broadinstitute.hellbender.tools.exome.ReadCountCollection) Stream(java.util.stream.Stream) Target(org.broadinstitute.hellbender.tools.exome.Target) SVDFactory(org.broadinstitute.hellbender.utils.svd.SVDFactory) RealMatrix(org.apache.commons.math3.linear.RealMatrix) SparkContextFactory(org.broadinstitute.hellbender.engine.spark.SparkContextFactory) PoNTestUtils(org.broadinstitute.hellbender.tools.pon.PoNTestUtils) Array2DRowRealMatrix(org.apache.commons.math3.linear.Array2DRowRealMatrix) RealMatrix(org.apache.commons.math3.linear.RealMatrix) Median(org.apache.commons.math3.stat.descriptive.rank.Median) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 94 with DataProvider

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

the class HDF5PCACoveragePoNCreationUtilsUnitTest method simpleEigensampleData.

@DataProvider(name = "singleEigensample")
public Object[][] simpleEigensampleData() {
    final List<Object[]> result = new ArrayList<>();
    final int NUM_TARGETS = 10;
    final int NUM_SAMPLES = 5;
    final List<Target> targets = IntStream.range(0, NUM_TARGETS).boxed().map(i -> new Target("target_" + i, new SimpleInterval("1", 100 * i + 1, 100 * i + 5))).collect(Collectors.toList());
    final List<String> columnNames = IntStream.range(0, NUM_SAMPLES).boxed().map(i -> "sample_" + i).collect(Collectors.toList());
    double[][] countsArray = new double[NUM_TARGETS][NUM_SAMPLES];
    final RealMatrix counts = new Array2DRowRealMatrix(countsArray);
    // All row data is the same (0,1,2,3,4...)
    final double[] rowData = IntStream.range(0, NUM_SAMPLES).boxed().mapToDouble(i -> i).toArray();
    for (int i = 0; i < NUM_TARGETS; i++) {
        counts.setRow(i, rowData);
    }
    new ReadCountCollection(targets, columnNames, counts);
    result.add(new Object[] { new ReadCountCollection(targets, columnNames, counts) });
    return result.toArray(new Object[result.size()][]);
}
Also used : IntStream(java.util.stream.IntStream) SVD(org.broadinstitute.hellbender.utils.svd.SVD) DataProvider(org.testng.annotations.DataProvider) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) JavaSparkContext(org.apache.spark.api.java.JavaSparkContext) Level(org.apache.logging.log4j.Level) MatrixSummaryUtils(org.broadinstitute.hellbender.utils.MatrixSummaryUtils) Test(org.testng.annotations.Test) Random(java.util.Random) OptionalInt(java.util.OptionalInt) ParamUtils(org.broadinstitute.hellbender.utils.param.ParamUtils) ArrayList(java.util.ArrayList) Mean(org.apache.commons.math3.stat.descriptive.moment.Mean) Pair(org.apache.commons.lang3.tuple.Pair) Message(org.apache.logging.log4j.message.Message) Assert(org.testng.Assert) Median(org.apache.commons.math3.stat.descriptive.rank.Median) HDF5File(org.broadinstitute.hdf5.HDF5File) Marker(org.apache.logging.log4j.Marker) AbstractLogger(org.apache.logging.log4j.spi.AbstractLogger) Array2DRowRealMatrix(org.apache.commons.math3.linear.Array2DRowRealMatrix) IOUtils(org.broadinstitute.hellbender.utils.io.IOUtils) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) Collectors(java.util.stream.Collectors) File(java.io.File) DoubleStream(java.util.stream.DoubleStream) List(java.util.List) Percentile(org.apache.commons.math3.stat.descriptive.rank.Percentile) Logger(org.apache.logging.log4j.Logger) ReadCountCollection(org.broadinstitute.hellbender.tools.exome.ReadCountCollection) Stream(java.util.stream.Stream) Target(org.broadinstitute.hellbender.tools.exome.Target) SVDFactory(org.broadinstitute.hellbender.utils.svd.SVDFactory) RealMatrix(org.apache.commons.math3.linear.RealMatrix) SparkContextFactory(org.broadinstitute.hellbender.engine.spark.SparkContextFactory) PoNTestUtils(org.broadinstitute.hellbender.tools.pon.PoNTestUtils) ReadCountCollection(org.broadinstitute.hellbender.tools.exome.ReadCountCollection) ArrayList(java.util.ArrayList) Target(org.broadinstitute.hellbender.tools.exome.Target) Array2DRowRealMatrix(org.apache.commons.math3.linear.Array2DRowRealMatrix) RealMatrix(org.apache.commons.math3.linear.RealMatrix) Array2DRowRealMatrix(org.apache.commons.math3.linear.Array2DRowRealMatrix) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) DataProvider(org.testng.annotations.DataProvider)

Example 95 with DataProvider

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

the class AssemblyResultSetUnitTest method assemblyResults.

@DataProvider(name = "assemblyResults")
public Iterator<Object[]> assemblyResults() {
    final int size = THREE_KS_GRAPH_AND_HAPLOTYPES.length * (1 + TEN_KS_GRAPH_AND_HAPLOTYPES.length);
    final Object[][] result = new Object[size][];
    for (int i = 0; i < THREE_KS_GRAPH_AND_HAPLOTYPES.length; i++) {
        final ReadThreadingGraph rtg = new TestingReadThreadingGraph((String) THREE_KS_GRAPH_AND_HAPLOTYPES[i][0]);
        final AssemblyResult ar = new AssemblyResult(AssemblyResult.Status.ASSEMBLED_SOME_VARIATION, rtg.toSequenceGraph(), rtg);
        final Object[] haplotypeStrings = (Object[]) THREE_KS_GRAPH_AND_HAPLOTYPES[i][1];
        final Haplotype[] haplotypes = new Haplotype[haplotypeStrings.length];
        for (int j = 0; j < haplotypeStrings.length; j++) {
            haplotypes[j] = new Haplotype(((String) haplotypeStrings[j]).getBytes(), j == 0);
            haplotypes[j].setGenomeLocation(genomeLocParser.createGenomeLoc("1", 1, haplotypes[j].length() + 1));
        }
        result[i] = new Object[] { Collections.singletonList(ar), Arrays.asList(Arrays.asList(haplotypes)) };
        for (int j = 0; j < TEN_KS_GRAPH_AND_HAPLOTYPES.length; j++) {
            final ReadThreadingGraph rtg10 = new TestingReadThreadingGraph((String) TEN_KS_GRAPH_AND_HAPLOTYPES[j][0]);
            final AssemblyResult ar10 = new AssemblyResult(AssemblyResult.Status.ASSEMBLED_SOME_VARIATION, rtg10.toSequenceGraph(), rtg10);
            final Object[] haplotypeStrings10 = (Object[]) TEN_KS_GRAPH_AND_HAPLOTYPES[j][1];
            final Haplotype[] haplotype10 = new Haplotype[haplotypeStrings10.length];
            for (int k = 0; k < haplotypeStrings10.length; k++) {
                haplotype10[k] = new Haplotype(((String) haplotypeStrings10[k]).getBytes(), false);
                haplotype10[k].setGenomeLocation(genomeLocParser.createGenomeLoc("1", 1, haplotype10[k].length() + 1));
            }
            result[THREE_KS_GRAPH_AND_HAPLOTYPES.length + i * TEN_KS_GRAPH_AND_HAPLOTYPES.length + j] = new Object[] { Arrays.asList(ar, ar10), Arrays.asList(Arrays.asList(haplotypes), Arrays.asList(haplotype10)) };
        }
    }
    return Arrays.asList(result).iterator();
}
Also used : ReadThreadingGraph(org.broadinstitute.hellbender.tools.walkers.haplotypecaller.readthreading.ReadThreadingGraph) TestingReadThreadingGraph(org.broadinstitute.hellbender.tools.walkers.haplotypecaller.readthreading.TestingReadThreadingGraph) TestingReadThreadingGraph(org.broadinstitute.hellbender.tools.walkers.haplotypecaller.readthreading.TestingReadThreadingGraph) Haplotype(org.broadinstitute.hellbender.utils.haplotype.Haplotype) 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