Better error message when bam file / list file with wrong extension is

supplied.


git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3483 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
hanna 2010-06-03 17:52:48 +00:00
parent 597b3744ab
commit 7d79848f40
1 changed files with 13 additions and 5 deletions

View File

@ -29,6 +29,7 @@ import org.broadinstitute.sting.gatk.arguments.GATKArgumentCollection;
import org.broadinstitute.sting.commandline.CommandLineProgram; import org.broadinstitute.sting.commandline.CommandLineProgram;
import org.broadinstitute.sting.commandline.ArgumentTypeDescriptor; import org.broadinstitute.sting.commandline.ArgumentTypeDescriptor;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.Utils;
import org.broadinstitute.sting.utils.text.XReadLines; import org.broadinstitute.sting.utils.text.XReadLines;
import org.broadinstitute.sting.gatk.walkers.Walker; import org.broadinstitute.sting.gatk.walkers.Walker;
import org.broadinstitute.sting.gatk.io.stubs.OutputStreamArgumentTypeDescriptor; import org.broadinstitute.sting.gatk.io.stubs.OutputStreamArgumentTypeDescriptor;
@ -159,21 +160,28 @@ public abstract class CommandLineExecutable extends CommandLineProgram {
* *
* @return * @return
*/ */
public static List<File> unpackList( List<File> inputFiles ) { private static List<File> unpackList( List<File> inputFiles ) {
List<File> unpackedReads = new ArrayList<File>(); List<File> unpackedReads = new ArrayList<File>();
for( File inputFile: inputFiles ) { for( File inputFile: inputFiles ) {
if (inputFile.getName().endsWith(".list") ) { if (inputFile.getName().toLowerCase().endsWith(".list") ) {
try { try {
for( String fileName : new XReadLines(inputFile) ) for(String fileName : new XReadLines(inputFile))
unpackedReads.add( new File(fileName) ); unpackedReads.addAll(Collections.singletonList(new File(fileName)));
} }
catch( FileNotFoundException ex ) { catch( FileNotFoundException ex ) {
throw new StingException("Unable to find file while unpacking reads", ex); throw new StingException("Unable to find file while unpacking reads", ex);
} }
} }
else else if(inputFile.getName().toLowerCase().endsWith(".bam")) {
unpackedReads.add( inputFile ); unpackedReads.add( inputFile );
}
else {
Utils.scareUser(String.format("The GATK reads argument (-I) supports only BAM files with the .bam extension and lists of BAM files " +
"with the .list extension, but the file %s has neither extension. Please ensure that your BAM file or list " +
"of BAM files is in the correct format, update the extension, and try again.",inputFile.getName()));
}
} }
return unpackedReads; return unpackedReads;
} }
} }