Search in sources :

Example 1 with ProgressReportingDelegatingCodec

use of org.broadinstitute.hellbender.utils.codecs.ProgressReportingDelegatingCodec 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();
}
Also used : ProgressReportingDelegatingCodec(org.broadinstitute.hellbender.utils.codecs.ProgressReportingDelegatingCodec) Index(htsjdk.tribble.index.Index) TabixIndex(htsjdk.tribble.index.tabix.TabixIndex) IOException(java.io.IOException) UserException(org.broadinstitute.hellbender.exceptions.UserException) File(java.io.File)

Aggregations

Index (htsjdk.tribble.index.Index)1 TabixIndex (htsjdk.tribble.index.tabix.TabixIndex)1 File (java.io.File)1 IOException (java.io.IOException)1 UserException (org.broadinstitute.hellbender.exceptions.UserException)1 ProgressReportingDelegatingCodec (org.broadinstitute.hellbender.utils.codecs.ProgressReportingDelegatingCodec)1