Skip to content

Commit

Permalink
Fixing up GATKtool edits
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardkw committed Aug 5, 2015
1 parent 01bea98 commit 568fad7
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/main/java/org/broadinstitute/hellbender/engine/GATKTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,28 @@ void initializeReference() {
* Package-private so that engine classes can access it, but concrete tool child classes cannot.
* May be overridden by traversals that require custom initialization of the reads data source.
*/
void initializeReads() throws UserException {
void initializeReads() {
SamReaderFactory factory = null;
if (hasReference()){
// pass in reference if available, because CRAM files need it
factory = SamReaderFactory.makeDefault().validationStringency(ValidationStringency.SILENT).referenceSequence(referenceArguments.getReferenceFile());
} else if (hasCramInput()) {
throw new UserException("A reference file is required when using CRAM files.");
}
reads = ! readArguments.getReadFiles().isEmpty() ? new ReadsDataSource(readArguments.getReadFiles(), factory) : null;
}

/**
* Helper method that simply returns a boolean regarding whether the input has CRAM files or not.
*/
private boolean hasCramInput() {
boolean hasCram = false;
for (File inputFile : readArguments.getReadFiles()) {
if (FilenameUtils.getExtension(inputFile.getName()).equals("cram")) {
if (FilenameUtils.getExtension(inputFile.getName()).equalsIgnoreCase("cram")) {
hasCram = true;
}
}
if (hasCram && ! hasReference()) {
throw new UserException("A reference file is required when using CRAM files.");
}
return hasCram;
}

/**
Expand Down

0 comments on commit 568fad7

Please sign in to comment.