// Path: src/main/java/org/seqdoop/hadoop_bam/util/BGZFCodec.java
// public class BGZFCodec extends GzipCodec implements SplittableCompressionCodec {
// 
//   public static final String DEFAULT_EXTENSION = ".bgz";
// 
//   @Override
//   public CompressionOutputStream createOutputStream(OutputStream out) throws IOException {
//     return new BGZFCompressionOutputStream(out);
//   }
// 
//   // compressors are not used, so ignore/return null
// 
//   @Override
//   public CompressionOutputStream createOutputStream(OutputStream out,
//       Compressor compressor) throws IOException {
//     return createOutputStream(out); // compressors are not used, so ignore
//   }
// 
//   @Override
//   public Class<? extends Compressor> getCompressorType() {
//     return null; // compressors are not used, so return null
//   }
// 
//   @Override
//   public Compressor createCompressor() {
//     return null; // compressors are not used, so return null
//   }
// 
//   @Override
//   public SplitCompressionInputStream createInputStream(InputStream seekableIn,
//       Decompressor decompressor, long start, long end, READ_MODE readMode) throws IOException {
//     BGZFSplitGuesser splitGuesser = new BGZFSplitGuesser(seekableIn);
//     long adjustedStart = splitGuesser.guessNextBGZFBlockStart(start, end);
//     ((Seekable)seekableIn).seek(adjustedStart);
//     return new BGZFSplitCompressionInputStream(seekableIn, adjustedStart, end);
//   }
// 
//   // fall back to GzipCodec for input streams without a start position
// 
//   @Override
//   public String getDefaultExtension() {
//     return DEFAULT_EXTENSION;
//   }
// }


import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterators;
import htsjdk.samtools.util.Interval;
import htsjdk.variant.vcf.VCFFileReader;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.mapreduce.*;
import htsjdk.variant.variantcontext.VariantContext;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.task.JobContextImpl;
import org.apache.hadoop.mapreduce.task.TaskAttemptContextImpl;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.seqdoop.hadoop_bam.util.BGZFCodec;
import org.seqdoop.hadoop_bam.util.BGZFEnhancedGzipCodec;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
        this.interval = interval;
    }

    @Parameterized.Parameters
    public static Collection<Object> data() {
        return Arrays.asList(new Object[][] {
            {"test.vcf", NUM_SPLITS.ANY, null},
            {"test.vcf.gz", NUM_SPLITS.EXACTLY_ONE, null},
            {"test.vcf.bgzf.gz", NUM_SPLITS.ANY, null},
            // BCF tests currently fail due to https://github.com/samtools/htsjdk/issues/507
//            {"test.uncompressed.bcf", NUM_SPLITS.ANY, null},
//            {"test.bgzf.bcf", NUM_SPLITS.ANY, null},
            {"HiSeq.10000.vcf", NUM_SPLITS.MORE_THAN_ONE, null},
            {"HiSeq.10000.vcf.gz", NUM_SPLITS.EXACTLY_ONE, null},
            {"HiSeq.10000.vcf.bgzf.gz", NUM_SPLITS.MORE_THAN_ONE, null},
            {"HiSeq.10000.vcf.bgzf.gz", NUM_SPLITS.EXACTLY_ONE,
                new Interval("chr1", 2700000, 2800000)}, // chosen to fall in one split
            {"HiSeq.10000.vcf.bgz", NUM_SPLITS.MORE_THAN_ONE, null},
            {"HiSeq.10000.vcf.bgz", NUM_SPLITS.EXACTLY_ONE,
                new Interval("chr1", 2700000, 2800000)} // chosen to fall in one split
        });
    }

    @Before
    public void setup() throws IOException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, InterruptedException, NoSuchFieldException {
        Configuration conf = new Configuration();
        String input_file = ClassLoader.getSystemClassLoader().getResource(filename).getFile();
        conf.set("hadoopbam.vcf.trust-exts", "true");
        conf.set("mapred.input.dir", "file://" + input_file);
        conf.setStrings("io.compression.codecs", BGZFEnhancedGzipCodec.class.getCanonicalName(),
// Path: src/main/java/org/seqdoop/hadoop_bam/util/BGZFCodec.java
// public class BGZFCodec extends GzipCodec implements SplittableCompressionCodec {
// 
//   public static final String DEFAULT_EXTENSION = ".bgz";
// 
//   @Override
//   public CompressionOutputStream createOutputStream(OutputStream out) throws IOException {
//     return new BGZFCompressionOutputStream(out);
//   }
// 
//   // compressors are not used, so ignore/return null
// 
//   @Override
//   public CompressionOutputStream createOutputStream(OutputStream out,
//       Compressor compressor) throws IOException {
//     return createOutputStream(out); // compressors are not used, so ignore
//   }
// 
//   @Override
//   public Class<? extends Compressor> getCompressorType() {
//     return null; // compressors are not used, so return null
//   }
// 
//   @Override
//   public Compressor createCompressor() {
//     return null; // compressors are not used, so return null
//   }
// 
//   @Override
//   public SplitCompressionInputStream createInputStream(InputStream seekableIn,
//       Decompressor decompressor, long start, long end, READ_MODE readMode) throws IOException {
//     BGZFSplitGuesser splitGuesser = new BGZFSplitGuesser(seekableIn);
//     long adjustedStart = splitGuesser.guessNextBGZFBlockStart(start, end);
//     ((Seekable)seekableIn).seek(adjustedStart);
//     return new BGZFSplitCompressionInputStream(seekableIn, adjustedStart, end);
//   }
// 
//   // fall back to GzipCodec for input streams without a start position
// 
//   @Override
//   public String getDefaultExtension() {
//     return DEFAULT_EXTENSION;
//   }
// }


// Path: src/test/java/org/seqdoop/hadoop_bam/TestVCFInputFormat.java
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterators;
import htsjdk.samtools.util.Interval;
import htsjdk.variant.vcf.VCFFileReader;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.mapreduce.*;
import htsjdk.variant.variantcontext.VariantContext;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.task.JobContextImpl;
import org.apache.hadoop.mapreduce.task.TaskAttemptContextImpl;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.seqdoop.hadoop_bam.util.BGZFCodec;
import org.seqdoop.hadoop_bam.util.BGZFEnhancedGzipCodec;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;

        this.interval = interval;
    }

    @Parameterized.Parameters
    public static Collection<Object> data() {
        return Arrays.asList(new Object[][] {
            {"test.vcf", NUM_SPLITS.ANY, null},
            {"test.vcf.gz", NUM_SPLITS.EXACTLY_ONE, null},
            {"test.vcf.bgzf.gz", NUM_SPLITS.ANY, null},
            // BCF tests currently fail due to https://github.com/samtools/htsjdk/issues/507
//            {"test.uncompressed.bcf", NUM_SPLITS.ANY, null},
//            {"test.bgzf.bcf", NUM_SPLITS.ANY, null},
            {"HiSeq.10000.vcf", NUM_SPLITS.MORE_THAN_ONE, null},
            {"HiSeq.10000.vcf.gz", NUM_SPLITS.EXACTLY_ONE, null},
            {"HiSeq.10000.vcf.bgzf.gz", NUM_SPLITS.MORE_THAN_ONE, null},
            {"HiSeq.10000.vcf.bgzf.gz", NUM_SPLITS.EXACTLY_ONE,
                new Interval("chr1", 2700000, 2800000)}, // chosen to fall in one split
            {"HiSeq.10000.vcf.bgz", NUM_SPLITS.MORE_THAN_ONE, null},
            {"HiSeq.10000.vcf.bgz", NUM_SPLITS.EXACTLY_ONE,
                new Interval("chr1", 2700000, 2800000)} // chosen to fall in one split
        });
    }

    @Before
    public void setup() throws IOException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, InterruptedException, NoSuchFieldException {
        Configuration conf = new Configuration();
        String input_file = ClassLoader.getSystemClassLoader().getResource(filename).getFile();
        conf.set("hadoopbam.vcf.trust-exts", "true");
        conf.set("mapred.input.dir", "file://" + input_file);
        conf.setStrings("io.compression.codecs", BGZFEnhancedGzipCodec.class.getCanonicalName(),
            BGZFCodec.class.getCanonicalName());