Search in sources :

Example 1 with TestSupport

use of com.github.lindenb.jvarkit.tools.tests.TestSupport in project jvarkit by lindenb.

the class NoZeroVariationVCFTest method test01.

@Test
public void test01() throws IOException {
    final TestSupport support = new TestSupport();
    try {
        final Path inputFile = support.createTmpPath(".vcf");
        IOUtils.cat("##fileformat=VCFv4.2\n#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tS1\n", inputFile, false);
        final Path out = support.createTmpPath(".vcf");
        Assert.assertEquals(0, new NoZeroVariationVCF().instanceMain(new String[] { "-o", out.toString(), "-R", support.resource("rotavirus_rf.fa"), inputFile.toString() }));
        support.assertIsVcf(out);
    } finally {
        support.removeTmpFiles();
    }
}
Also used : Path(java.nio.file.Path) TestSupport(com.github.lindenb.jvarkit.tools.tests.TestSupport) AlsoTest(com.github.lindenb.jvarkit.tests.AlsoTest) Test(org.testng.annotations.Test) VCFUtilsTest(com.github.lindenb.jvarkit.util.vcf.VCFUtilsTest)

Example 2 with TestSupport

use of com.github.lindenb.jvarkit.tools.tests.TestSupport in project jvarkit by lindenb.

the class FixVcfMissingGenotypesTest method test01.

@Test
public void test01() throws Exception {
    final TestSupport support = new TestSupport();
    try {
        Path nocallvcffile = support.createTmpPath(".vcf");
        VCFReader r1 = VCFReaderFactory.makeDefault().open(Paths.get(support.resource("rotavirus_rf.vcf.gz")), false);
        final VariantContextWriter vcw = VCFUtils.createVariantContextWriter(nocallvcffile.toFile());
        vcw.writeHeader(r1.getHeader());
        r1.iterator().stream().forEach(V -> {
            VariantContextBuilder vcb = new VariantContextBuilder(V);
            vcb.genotypes(V.getGenotypes().stream().map(G -> GenotypeBuilder.createMissing(G.getSampleName(), 2)).collect(Collectors.toList()));
            vcw.add(vcb.make());
        });
        vcw.close();
        r1.close();
        final Path output = support.createTmpPath(".vcf");
        final FixVcfMissingGenotypes cmd = new FixVcfMissingGenotypes();
        Assert.assertEquals(0, cmd.instanceMain(new String[] { "-B", support.resource("S1.bam"), "-B", support.resource("S2.bam"), "-B", support.resource("S3.bam"), "-B", support.resource("S4.bam"), "-B", support.resource("S5.bam"), "-o", output.toString(), nocallvcffile.toString() }));
        support.assertIsVcf(output);
        Assert.assertFalse(support.variantStream(output).flatMap(V -> V.getGenotypes().stream()).noneMatch(G -> G.isHomRef()), "at least one GT should be 0/0");
    } finally {
        support.removeTmpFiles();
    }
}
Also used : Path(java.nio.file.Path) VCFUtils(com.github.lindenb.jvarkit.util.vcf.VCFUtils) GenotypeBuilder(htsjdk.variant.variantcontext.GenotypeBuilder) VCFReader(htsjdk.variant.vcf.VCFReader) Test(org.testng.annotations.Test) Collectors(java.util.stream.Collectors) Assert(org.testng.Assert) Paths(java.nio.file.Paths) AlsoTest(com.github.lindenb.jvarkit.tests.AlsoTest) VariantContextWriter(htsjdk.variant.variantcontext.writer.VariantContextWriter) TestSupport(com.github.lindenb.jvarkit.tools.tests.TestSupport) VCFReaderFactory(com.github.lindenb.jvarkit.variant.vcf.VCFReaderFactory) Path(java.nio.file.Path) VCFUtilsTest(com.github.lindenb.jvarkit.util.vcf.VCFUtilsTest) VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder) VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder) VCFReader(htsjdk.variant.vcf.VCFReader) TestSupport(com.github.lindenb.jvarkit.tools.tests.TestSupport) VariantContextWriter(htsjdk.variant.variantcontext.writer.VariantContextWriter) Test(org.testng.annotations.Test) AlsoTest(com.github.lindenb.jvarkit.tests.AlsoTest) VCFUtilsTest(com.github.lindenb.jvarkit.util.vcf.VCFUtilsTest)

Example 3 with TestSupport

use of com.github.lindenb.jvarkit.tools.tests.TestSupport in project jvarkit by lindenb.

the class VcfClusteredReadEdgeTest method test01.

@Test
public void test01() throws Exception {
    final TestSupport support = new TestSupport();
    try {
        final Path output = support.createTmpPath(".vcf");
        Assert.assertEquals(new VcfClusteredReadEdge().instanceMain(new String[] { "-B", support.resource("S1.bam"), "-B", support.resource("S2.bam"), "-B", support.resource("S3.bam"), "-B", support.resource("S4.bam"), "-B", support.resource("S5.bam"), "-o", output.toString(), support.resource("rotavirus_rf.vcf.gz") }), 0);
        support.assertIsVcf(output);
    } finally {
        support.removeTmpFiles();
    }
}
Also used : Path(java.nio.file.Path) TestSupport(com.github.lindenb.jvarkit.tools.tests.TestSupport) AlsoTest(com.github.lindenb.jvarkit.tests.AlsoTest) Test(org.testng.annotations.Test) VCFUtilsTest(com.github.lindenb.jvarkit.util.vcf.VCFUtilsTest)

Example 4 with TestSupport

use of com.github.lindenb.jvarkit.tools.tests.TestSupport in project jvarkit by lindenb.

the class Biostar77828Test method test01.

@Test
public void test01() throws IOException {
    final TestSupport support = new TestSupport();
    try {
        Path bed = support.createTmpPath(".bed");
        PrintWriter pw = new PrintWriter(Files.newBufferedWriter(bed));
        for (int i = 0; i < 1000; i++) {
            int L = 1 + support.random.nextInt(1000);
            int p = support.random.nextInt(100000);
            pw.println("chr" + (i % 10) + "\t" + p + "\t" + (p + L));
        }
        pw.flush();
        pw.close();
        support.assertIsBed(bed);
        Path out = support.createTmpPath(".txt");
        Assert.assertEquals(new Biostar77828().instanceMain(new String[] { "-o", out.toString(), "--iter", "1000", bed.toString() }), 0);
        support.assertIsNotEmpty(out);
    } finally {
        support.removeTmpFiles();
    }
}
Also used : Path(java.nio.file.Path) TestSupport(com.github.lindenb.jvarkit.tools.tests.TestSupport) PrintWriter(java.io.PrintWriter) AlsoTest(com.github.lindenb.jvarkit.tests.AlsoTest) Test(org.testng.annotations.Test) LauncherTest(com.github.lindenb.jvarkit.util.jcommander.LauncherTest)

Example 5 with TestSupport

use of com.github.lindenb.jvarkit.tools.tests.TestSupport in project jvarkit by lindenb.

the class SamReadLengthDistributionTest method test01.

@Test(dataProvider = "src01")
public void test01(final String partition) throws IOException {
    final TestSupport support = new TestSupport();
    try {
        final Path out = support.createTmpPath(".txt");
        Assert.assertEquals(new SamReadLengthDistribution().instanceMain(new String[] { "-o", out.toString(), "--groupby", partition, support.resource("S1.bam"), support.resource("S2.bam"), support.resource("S3.bam"), support.resource("S4.bam"), support.resource("S5.bam") }), 0);
        support.assertTsvTableIsConsitent(out, null);
    } finally {
        support.removeTmpFiles();
    }
}
Also used : Path(java.nio.file.Path) TestSupport(com.github.lindenb.jvarkit.tools.tests.TestSupport) Test(org.testng.annotations.Test)

Aggregations

TestSupport (com.github.lindenb.jvarkit.tools.tests.TestSupport)6 Path (java.nio.file.Path)6 Test (org.testng.annotations.Test)6 AlsoTest (com.github.lindenb.jvarkit.tests.AlsoTest)5 VCFUtilsTest (com.github.lindenb.jvarkit.util.vcf.VCFUtilsTest)3 LauncherTest (com.github.lindenb.jvarkit.util.jcommander.LauncherTest)2 VCFUtils (com.github.lindenb.jvarkit.util.vcf.VCFUtils)1 VCFReaderFactory (com.github.lindenb.jvarkit.variant.vcf.VCFReaderFactory)1 GenotypeBuilder (htsjdk.variant.variantcontext.GenotypeBuilder)1 VariantContextBuilder (htsjdk.variant.variantcontext.VariantContextBuilder)1 VariantContextWriter (htsjdk.variant.variantcontext.writer.VariantContextWriter)1 VCFReader (htsjdk.variant.vcf.VCFReader)1 PrintWriter (java.io.PrintWriter)1 Paths (java.nio.file.Paths)1 Collectors (java.util.stream.Collectors)1 Assert (org.testng.Assert)1