diff --git a/public/java/src/org/broadinstitute/sting/gatk/datasources/reference/ReferenceDataSource.java b/public/java/src/org/broadinstitute/sting/gatk/datasources/reference/ReferenceDataSource.java index cb70d2b88..79100e89a 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/datasources/reference/ReferenceDataSource.java +++ b/public/java/src/org/broadinstitute/sting/gatk/datasources/reference/ReferenceDataSource.java @@ -67,18 +67,20 @@ public class ReferenceDataSource { throw new UserException("The fasta file you specified (" + fastaFile.getAbsolutePath() + ") does not exist."); final boolean isGzipped = fastaFile.getAbsolutePath().endsWith(".gz"); + if ( isGzipped ) { + throw new UserException.CannotHandleGzippedRef(); + } final File indexFile = new File(fastaFile.getAbsolutePath() + ".fai"); // determine the name for the dict file - final String fastaExt = (fastaFile.getAbsolutePath().endsWith("fa") ? ".fa" : ".fasta" ) + (isGzipped ? ".gz" : ""); + final String fastaExt = fastaFile.getAbsolutePath().endsWith("fa") ? ".fa" : ".fasta"; final File dictFile = new File(fastaFile.getAbsolutePath().replace(fastaExt, ".dict")); /* * if index file does not exist, create it manually */ if (!indexFile.exists()) { - if ( isGzipped ) throw new UserException.CouldNotCreateReferenceFAIorDictForGzippedRef(fastaFile); logger.info(String.format("Index file %s does not exist. Trying to create it now.", indexFile.getAbsolutePath())); FSLockWithShared indexLock = new FSLockWithShared(indexFile,true); @@ -115,7 +117,6 @@ public class ReferenceDataSource { * This has been filed in trac as (PIC-370) Want programmatic interface to CreateSequenceDictionary */ if (!dictFile.exists()) { - if ( isGzipped ) throw new UserException.CouldNotCreateReferenceFAIorDictForGzippedRef(fastaFile); logger.info(String.format("Dict file %s does not exist. Trying to create it now.", dictFile.getAbsolutePath())); diff --git a/public/java/src/org/broadinstitute/sting/utils/exceptions/UserException.java b/public/java/src/org/broadinstitute/sting/utils/exceptions/UserException.java index 0c01539d4..1c461748e 100644 --- a/public/java/src/org/broadinstitute/sting/utils/exceptions/UserException.java +++ b/public/java/src/org/broadinstitute/sting/utils/exceptions/UserException.java @@ -393,15 +393,10 @@ public class UserException extends ReviewedStingException { } } - public static class CouldNotCreateReferenceFAIorDictForGzippedRef extends UserException { - public CouldNotCreateReferenceFAIorDictForGzippedRef(final File f) { - super("Although the GATK can process .gz reference sequences, it currently cannot create FAI " + - "or DICT files for them. In order to use the GATK with reference.fasta.gz you will need to " + - "create .dict and .fai files for reference.fasta.gz and name them reference.fasta.gz.fai and " + - "reference.dict. Potentially the easiest way to do this is to uncompress reference.fasta, " + - "run the GATK to create the .dict and .fai files, and copy them to the appropriate location. " + - "Sorry for the inconvenience."); - } + public static class CannotHandleGzippedRef extends UserException { + public CannotHandleGzippedRef() { + super("The GATK cannot process compressed (.gz) reference sequences. Please unzip the file and try again. Sorry for the inconvenience."); + } } public static class CouldNotCreateReferenceIndexFileBecauseOfLock extends UserException.CouldNotCreateReferenceIndexFile {