Merged bug fix from Stable into Unstable

This commit is contained in:
Eric Banks 2013-03-05 13:28:46 -05:00
commit 2be57fbcfb
2 changed files with 8 additions and 12 deletions

View File

@ -67,18 +67,20 @@ public class ReferenceDataSource {
throw new UserException("The fasta file you specified (" + fastaFile.getAbsolutePath() + ") does not exist."); throw new UserException("The fasta file you specified (" + fastaFile.getAbsolutePath() + ") does not exist.");
final boolean isGzipped = fastaFile.getAbsolutePath().endsWith(".gz"); final boolean isGzipped = fastaFile.getAbsolutePath().endsWith(".gz");
if ( isGzipped ) {
throw new UserException.CannotHandleGzippedRef();
}
final File indexFile = new File(fastaFile.getAbsolutePath() + ".fai"); final File indexFile = new File(fastaFile.getAbsolutePath() + ".fai");
// determine the name for the dict file // 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")); final File dictFile = new File(fastaFile.getAbsolutePath().replace(fastaExt, ".dict"));
/* /*
* if index file does not exist, create it manually * if index file does not exist, create it manually
*/ */
if (!indexFile.exists()) { 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())); logger.info(String.format("Index file %s does not exist. Trying to create it now.", indexFile.getAbsolutePath()));
FSLockWithShared indexLock = new FSLockWithShared(indexFile,true); 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 * This has been filed in trac as (PIC-370) Want programmatic interface to CreateSequenceDictionary
*/ */
if (!dictFile.exists()) { 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())); logger.info(String.format("Dict file %s does not exist. Trying to create it now.", dictFile.getAbsolutePath()));

View File

@ -393,15 +393,10 @@ public class UserException extends ReviewedStingException {
} }
} }
public static class CouldNotCreateReferenceFAIorDictForGzippedRef extends UserException { public static class CannotHandleGzippedRef extends UserException {
public CouldNotCreateReferenceFAIorDictForGzippedRef(final File f) { public CannotHandleGzippedRef() {
super("Although the GATK can process .gz reference sequences, it currently cannot create FAI " + super("The GATK cannot process compressed (.gz) reference sequences. Please unzip the file and try again. Sorry for the inconvenience.");
"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 CouldNotCreateReferenceIndexFileBecauseOfLock extends UserException.CouldNotCreateReferenceIndexFile { public static class CouldNotCreateReferenceIndexFileBecauseOfLock extends UserException.CouldNotCreateReferenceIndexFile {