use of htsjdk.samtools.SAMSequenceDictionaryCodec in project jvarkit by lindenb.
the class VcfSetSequenceDictionaryTest method test01.
@Test(dataProvider = "all-vcf-files")
public void test01(final String inputFile) throws IOException {
final SAMSequenceDictionary dict = SAMSequenceDictionaryExtractor.extractDictionary(new File(inputFile));
if (dict == null || dict.isEmpty())
return;
final File dictF = super.createTmpFile(".dict");
final BufferedWriter bw = Files.newBufferedWriter(dictF.toPath());
final SAMSequenceDictionaryCodec codec = new SAMSequenceDictionaryCodec(bw);
codec.encode(new SAMSequenceDictionary(dict.getSequences().stream().map(S -> new SAMSequenceRecord(S.getSequenceName().startsWith("chr") ? S.getSequenceName().substring(3) : "chr" + S.getSequenceName(), S.getSequenceLength())).collect(Collectors.toList())));
bw.flush();
bw.close();
final File output = super.createTmpFile(".vcf");
Assert.assertEquals(0, new VcfSetSequenceDictionary().instanceMain(new String[] { "-o", output.getPath(), "-R", dictF.getPath(), inputFile }));
assertIsVcf(output);
}
Aggregations