* If the file path ends in ".tbi" or ".csi", or appending one of
* these extensions gives a valid file path, open as indexed, else as
* unindexed.
*
* @param f
* @throws IOException
*/
public VCFReader(String filePath) throws IOException
{
indexed = false;
if (filePath.endsWith(TBI_EXTENSION)
|| filePath.endsWith(CSI_EXTENSION))
{
indexed = true;
filePath = filePath.substring(0, filePath.length() - 4);
}
else if (new File(filePath + TBI_EXTENSION).exists())
{
indexed = true;
}
else if (new File(filePath + CSI_EXTENSION).exists())
{
indexed = true;
}
/*
* we pass the name of the unindexed file to htsjdk,
* with a flag to assert whether it is indexed
*/
File file = new File(filePath);
if (file.exists())
{
reader = new VCFFileReader(file, indexed);
}
else
{
Console.error("File not found: " + filePath);
}
}
@Override
public void close() throws IOException
{
if (reader != null)
{
reader.close();
}
}
/**
* Returns an iterator over VCF variants in the file. The client should call
* close() on the iterator when finished with it.
*/
@Override
public CloseableIterator
* Client code should call close() on the iterator when finished with it.
*
* @param chrom
* the chromosome to query
* @param start
* query interval start
* @param end
* query interval end
* @return
*/
public CloseableIterator