Skip to content

Commit

Permalink
Don't allow the use of compressed (.gz) references in the GATK.
Browse files Browse the repository at this point in the history
  • Loading branch information
eitanbanks committed Mar 5, 2013
1 parent 7e1bfd6 commit 5e89f01
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Expand Up @@ -67,18 +67,20 @@ public ReferenceDataSource(File fastaFile) {
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);
Expand Down Expand Up @@ -115,7 +117,6 @@ public ReferenceDataSource(File fastaFile) {
* 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()));

Expand Down
Expand Up @@ -387,15 +387,10 @@ public CouldNotCreateReferenceIndexFile(File f, String message, Exception e) {
}
}

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 {
Expand Down

0 comments on commit 5e89f01

Please sign in to comment.