@Test
public void basicIOTest() throws Exception {
String inputPath = TestUtils.DATA_DIR + "vcf/hc_mod.vcf";
TestUtils.createIndex(inputPath);
VariantTrack inputTrack = (VariantTrack) (new TrackLoader()).load(new ResourceLocator(inputPath), genome).get(0);
VCFEncoder encoder = new VCFEncoder();
Argument arg = new Argument(null, Argument.InputType.VARIANT_TRACK, null, null, null, null, false, null);
Map<Argument, Object> arguments = new HashMap(1);
arguments.put(arg, inputTrack);
encoder.setInputs(null, arguments, arg);
String chr = "chr20";
int start = 10499005;
int end = 10499500;
String outpath = TestUtils.TMP_OUTPUT_DIR + "hc_mod_out.vcf";
OutputStream outputStream = new FileOutputStream(outpath);
List<VCFVariant> infeatures = new ArrayList<VCFVariant>();
for (Feature feat : inputTrack.getFeatures(chr, start, end)) {
infeatures.add((VCFVariant) feat);
}
encoder.encodeAll(outputStream, infeatures.iterator());
TestUtils.createIndex(outpath);
VariantTrack outputTrack = (VariantTrack) (new TrackLoader()).load(new ResourceLocator(inputPath), genome).get(0);
VCFWriterTest.assertHeadersEquals((VCFHeader) inputTrack.getHeader(), (VCFHeader) outputTrack.getHeader());
int n = 0;
for (Feature var1 : inputTrack.getFeatures(chr, start, end)) {
VCFVariant var0 = infeatures.get(n++);
VCFWriterTest.assertVCFVariantsEqual(var0, (VCFVariant) var1);