Check for empty BAM lists in command line input
This commit is contained in:
parent
7095a60c8e
commit
29bb3d4dc1
|
|
@ -497,19 +497,27 @@ public class GenomeAnalysisEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies that the supplied set of reads files mesh with what the walker says it requires,
|
* Verifies that the supplied set of reads files mesh with what the walker says it requires;
|
||||||
* and also makes sure that there were no duplicate SAM files specified on the command line.
|
* also makes sure that list of SAM files specified on the command line is not empty and contains
|
||||||
|
* no duplicates.
|
||||||
*/
|
*/
|
||||||
protected void validateSuppliedReads() {
|
protected void validateSuppliedReads() {
|
||||||
GATKArgumentCollection arguments = this.getArguments();
|
GATKArgumentCollection arguments = this.getArguments();
|
||||||
|
final Boolean samFilesArePresent = (arguments.samFiles != null && !arguments.samFiles.isEmpty());
|
||||||
|
|
||||||
// Check what the walker says is required against what was provided on the command line.
|
// Check what the walker says is required against what was provided on the command line.
|
||||||
if (WalkerManager.isRequired(walker, DataSource.READS) && (arguments.samFiles == null || arguments.samFiles.size() == 0))
|
if (WalkerManager.isRequired(walker, DataSource.READS) && !samFilesArePresent)
|
||||||
throw new ArgumentException("Walker requires reads but none were provided.");
|
throw new ArgumentException("Walker requires reads but none were provided.");
|
||||||
|
|
||||||
// Check what the walker says is allowed against what was provided on the command line.
|
// Check what the walker says is allowed against what was provided on the command line.
|
||||||
if ((arguments.samFiles != null && arguments.samFiles.size() > 0) && !WalkerManager.isAllowed(walker, DataSource.READS))
|
if (samFilesArePresent && !WalkerManager.isAllowed(walker, DataSource.READS))
|
||||||
throw new ArgumentException("Walker does not allow reads but reads were provided.");
|
throw new ArgumentException("Walker does not allow reads but reads were provided.");
|
||||||
|
|
||||||
|
//Make sure SAM list specified by the user (if necessary) is not empty
|
||||||
|
if(WalkerManager.isRequired(walker, DataSource.READS) && samFilesArePresent && samReaderIDs.isEmpty() ) {
|
||||||
|
throw new UserException("The list of input files does not contain any BAM files.");
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure no SAM files were specified multiple times by the user.
|
// Make sure no SAM files were specified multiple times by the user.
|
||||||
checkForDuplicateSamFiles();
|
checkForDuplicateSamFiles();
|
||||||
}
|
}
|
||||||
|
|
@ -535,6 +543,7 @@ public class GenomeAnalysisEngine {
|
||||||
throw new UserException("The following BAM files appear multiple times in the list of input files: " +
|
throw new UserException("The following BAM files appear multiple times in the list of input files: " +
|
||||||
duplicateSamFiles + " BAM files may be specified at most once.");
|
duplicateSamFiles + " BAM files may be specified at most once.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,11 @@ package org.broadinstitute.sting.gatk;
|
||||||
import org.broadinstitute.sting.BaseTest;
|
import org.broadinstitute.sting.BaseTest;
|
||||||
import org.broadinstitute.sting.commandline.ArgumentException;
|
import org.broadinstitute.sting.commandline.ArgumentException;
|
||||||
import org.broadinstitute.sting.commandline.Tags;
|
import org.broadinstitute.sting.commandline.Tags;
|
||||||
|
import org.broadinstitute.sting.gatk.arguments.GATKArgumentCollection;
|
||||||
import org.broadinstitute.sting.gatk.datasources.reads.SAMReaderID;
|
import org.broadinstitute.sting.gatk.datasources.reads.SAMReaderID;
|
||||||
import org.broadinstitute.sting.gatk.iterators.ReadTransformer;
|
import org.broadinstitute.sting.gatk.iterators.ReadTransformer;
|
||||||
import org.broadinstitute.sting.gatk.walkers.Walker;
|
import org.broadinstitute.sting.gatk.walkers.Walker;
|
||||||
|
import org.broadinstitute.sting.gatk.walkers.qc.CountReads;
|
||||||
import org.broadinstitute.sting.gatk.walkers.readutils.PrintReads;
|
import org.broadinstitute.sting.gatk.walkers.readutils.PrintReads;
|
||||||
import org.broadinstitute.sting.utils.GenomeLocParser;
|
import org.broadinstitute.sting.utils.GenomeLocParser;
|
||||||
import org.broadinstitute.sting.utils.GenomeLocSortedSet;
|
import org.broadinstitute.sting.utils.GenomeLocSortedSet;
|
||||||
|
|
@ -51,6 +53,23 @@ import java.util.*;
|
||||||
*/
|
*/
|
||||||
public class GenomeAnalysisEngineUnitTest extends BaseTest {
|
public class GenomeAnalysisEngineUnitTest extends BaseTest {
|
||||||
|
|
||||||
|
@Test(expectedExceptions=UserException.class)
|
||||||
|
public void testEmptySamFileListHandling() throws Exception {
|
||||||
|
GenomeAnalysisEngine testEngine = new GenomeAnalysisEngine();
|
||||||
|
testEngine.setWalker(new CountReads()); //generalizable to any walker requiring reads
|
||||||
|
|
||||||
|
//supply command line args so validateSuppliedReads() knows whether reads were passed in
|
||||||
|
GATKArgumentCollection testArgs = new GATKArgumentCollection();
|
||||||
|
testArgs.samFiles.add("empty.list");
|
||||||
|
testEngine.setArguments(testArgs);
|
||||||
|
|
||||||
|
//represents the empty list of samFiles read in from empty.list by CommandLineExecutable
|
||||||
|
Collection<SAMReaderID> samFiles = new ArrayList<SAMReaderID>();
|
||||||
|
|
||||||
|
testEngine.setSAMFileIDs(samFiles);
|
||||||
|
testEngine.validateSuppliedReads();
|
||||||
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions=UserException.class)
|
@Test(expectedExceptions=UserException.class)
|
||||||
public void testDuplicateSamFileHandlingSingleDuplicate() throws Exception {
|
public void testDuplicateSamFileHandlingSingleDuplicate() throws Exception {
|
||||||
GenomeAnalysisEngine testEngine = new GenomeAnalysisEngine();
|
GenomeAnalysisEngine testEngine = new GenomeAnalysisEngine();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue