I've got this code for creating my .tbi index file: (inputFile is my .vcf File)
VCFFileReader vcfReader = new VCFFileReader(inputFile, false);
TabixIndexCreator creator = new TabixIndexCreator(new TabixFormat().VCF);
int I = 0;
for (VariantContext context : vcfReader) {
creator.addFeature(context, i);
i++;
}
vcfReader.close();
creator.finalizeIndex(i).writeBasedOnFeatureFile(inputFile);
After that I try to iterate throw my my .vcf file using next construction:
VCFFileReader vcfReader2 = new VCFFileReader(inputFile, new File(inputFile.getAbsolutePath() + ".tbi"));
CloseableIterator iter = vcfReader2.query("gi|448814763|ref|NC_000962.3|", 1, 5);
and iter.hasNext()
is false, though I've got this in my .vcf file.
Thanks
I have a similar problem. I have a .tbi file and I want to use it to access my vcf file. I have this code:
I don't know how to use
TabixIndex
andBlockCompressedInputStream
. Maybe the problem is that I don't understand what they are and what they do.