From 7d79848f40b0c77bf2595e49ca34e72272413ee3 Mon Sep 17 00:00:00 2001 From: hanna Date: Thu, 3 Jun 2010 17:52:48 +0000 Subject: [PATCH] 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 --- .../sting/gatk/CommandLineExecutable.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/CommandLineExecutable.java b/java/src/org/broadinstitute/sting/gatk/CommandLineExecutable.java index dfe2528b8..341ea8214 100644 --- a/java/src/org/broadinstitute/sting/gatk/CommandLineExecutable.java +++ b/java/src/org/broadinstitute/sting/gatk/CommandLineExecutable.java @@ -29,6 +29,7 @@ import org.broadinstitute.sting.gatk.arguments.GATKArgumentCollection; import org.broadinstitute.sting.commandline.CommandLineProgram; import org.broadinstitute.sting.commandline.ArgumentTypeDescriptor; import org.broadinstitute.sting.utils.StingException; +import org.broadinstitute.sting.utils.Utils; import org.broadinstitute.sting.utils.text.XReadLines; import org.broadinstitute.sting.gatk.walkers.Walker; import org.broadinstitute.sting.gatk.io.stubs.OutputStreamArgumentTypeDescriptor; @@ -159,21 +160,28 @@ public abstract class CommandLineExecutable extends CommandLineProgram { * * @return */ - public static List unpackList( List inputFiles ) { + private static List unpackList( List inputFiles ) { List unpackedReads = new ArrayList(); for( File inputFile: inputFiles ) { - if (inputFile.getName().endsWith(".list") ) { + if (inputFile.getName().toLowerCase().endsWith(".list") ) { try { - for( String fileName : new XReadLines(inputFile) ) - unpackedReads.add( new File(fileName) ); + for(String fileName : new XReadLines(inputFile)) + unpackedReads.addAll(Collections.singletonList(new File(fileName))); } catch( FileNotFoundException ex ) { throw new StingException("Unable to find file while unpacking reads", ex); } } - else + else if(inputFile.getName().toLowerCase().endsWith(".bam")) { 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; } + }