use of htsjdk.tribble.index.Index in project gatk by broadinstitute.
the class IndexUtilsUnitTest method testLoadIndex.
@Test(dataProvider = "okFeatureFiles")
public void testLoadIndex(final File featureFile) throws Exception {
final Index index = IndexUtils.loadTribbleIndex(featureFile);
Assert.assertNotNull(index);
}
use of htsjdk.tribble.index.Index in project gatk by broadinstitute.
the class IndexUtilsUnitTest method testFailLoadTabixIndex.
@Test(dataProvider = "failTabixIndexFiles")
public void testFailLoadTabixIndex(final File featureFile) throws Exception {
final Index index = IndexUtils.loadTabixIndex(featureFile);
Assert.assertNull(index);
}
use of htsjdk.tribble.index.Index in project gatk by broadinstitute.
the class IndexFeatureFile method doWork.
@Override
protected Object doWork() {
if (!featureFile.canRead()) {
throw new UserException.CouldNotReadInputFile(featureFile);
}
// Get the right codec for the file to be indexed. This call will throw an appropriate exception
// if featureFile is not in a supported format or is unreadable.
final FeatureCodec<? extends Feature, ?> codec = new ProgressReportingDelegatingCodec<>(FeatureManager.getCodecForFile(featureFile), ProgressMeter.DEFAULT_SECONDS_BETWEEN_UPDATES);
final Index index = createAppropriateIndexInMemory(codec);
final File indexFile = determineFileName(index);
try {
index.write(indexFile);
} catch (final IOException e) {
throw new UserException.CouldNotCreateOutputFile("Could not write index to file " + indexFile.getAbsolutePath(), e);
}
logger.info("Successfully wrote index to " + indexFile.getAbsolutePath());
return indexFile.getAbsolutePath();
}
use of htsjdk.tribble.index.Index in project gatk by broadinstitute.
the class IndexUtils method loadIndex.
/**
* Loads and returns the index of the feature file or null if there is no index.
* First it tries to load the tribble index and then to load the tabix index.
*/
public static Index loadIndex(final File featureFile) {
Utils.nonNull(featureFile);
final Index tribbleIndex = loadTribbleIndex(featureFile);
if (tribbleIndex != null) {
return tribbleIndex;
}
final Index tabixIndex = loadTabixIndex(featureFile);
if (tabixIndex != null) {
return tabixIndex;
}
return null;
}
use of htsjdk.tribble.index.Index in project gatk by broadinstitute.
the class IndexUtils method loadTribbleIndex.
/**
* Load a Tribble .idx index from disk, checking for out of date indexes and old versions
* @return an Index, or null if we're unable to load
*/
public static Index loadTribbleIndex(final File featureFile) {
Utils.nonNull(featureFile);
final File indexFile = Tribble.indexFile(featureFile);
if (!indexFile.canRead()) {
return null;
}
logger.debug("Loading Tribble index from disk for file " + featureFile);
try {
final Index index = IndexFactory.loadIndex(indexFile.getAbsolutePath());
checkIndexVersionAndModificationTime(featureFile, indexFile, index);
return index;
} catch (final RuntimeException e) {
return null;
}
}
Aggregations