add experimental support for tabix files (for any of our Tribble rod types), as long as they end in .gz and can be read by the tabix reader.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3429 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
aaron 2010-05-25 04:44:46 +00:00
parent f7c9f131ea
commit f3e2aae570
1 changed files with 34 additions and 0 deletions

View File

@ -105,6 +105,40 @@ public class TribbleRMDTrackBuilder extends PluginManager<FeatureCodec> implemen
*/
public FeatureReader createFeatureReader(Class targetClass, File inputFile) {
FeatureReader reader = null;
if (inputFile.getAbsolutePath().endsWith(".gz"))
reader = createBasicFeatureReaderNoAssumedIndex(targetClass, inputFile);
else
reader = getLinearFeatureReader(targetClass, inputFile);
return reader;
}
/**
* create a feature reader, without assuming there exists an index. This code assumes the feature
* reader of the appropriate type will figure out what the right index type is, and determine if it
* exists.
*
* @param targetClass the codec class type
* @param inputFile the file to load
* @return a feature reader implementation
*/
private BasicFeatureReader createBasicFeatureReaderNoAssumedIndex(Class targetClass, File inputFile) {
// we might not know the index type, try loading with the default reader constructor
logger.debug("Attempting to blindly load " + inputFile);
try {
return new BasicFeatureReader(inputFile.getAbsolutePath(),this.createByType(targetClass));
} catch (IOException e) {
throw new StingException("Unable to create feature reader from file " + inputFile);
}
}
/**
* create a linear feature reader, where we create the index ahead of time
* @param targetClass the target class
* @param inputFile the tribble file to parse
* @return the input file as a FeatureReader
*/
private FeatureReader getLinearFeatureReader(Class targetClass, File inputFile) {
FeatureReader reader;
try {
Index index = loadIndex(inputFile, this.createByType(targetClass), true);
reader = new BasicFeatureReader(inputFile.getAbsolutePath(), index, this.createByType(targetClass));