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();
}
}
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();
}
}
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();
}
}
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();
}
}
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();
}
}
Aggregations