diff --git a/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/variantutils/SelectVariantsIntegrationTest.java b/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/variantutils/SelectVariantsIntegrationTest.java index 21b069343..a8a479e2e 100644 --- a/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/variantutils/SelectVariantsIntegrationTest.java +++ b/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/variantutils/SelectVariantsIntegrationTest.java @@ -428,4 +428,64 @@ public class SelectVariantsIntegrationTest extends WalkerTest { ); executeTest(String.format("testUnusedAlleleTrimming: (%s,%s)", new File(vcf).getName(), extraArgs), spec); } + + /** + * Test with an empty VCF file + */ + @Test + public void testEmptyVcfException(){ + String testfile = privateTestDir + "reallyEmpty.vcf"; + + WalkerTestSpec spec = new WalkerTestSpec( + "-T SelectVariants" + + " -R " + b36KGReference + + " -V " + testfile + + " -o %s --no_cmdline_in_header", + 1, + UserException.CommandLineException.class + ); + spec.disableShadowBCF(); + + executeTest("testEmptyVcfException--" + testfile, spec); + } + + /** + * Test with a VCF file that is not a file + */ + @Test + public void testNotFileVcfException(){ + String testfile = privateTestDir; + + WalkerTestSpec spec = new WalkerTestSpec( + "-T SelectVariants" + + " -R " + b36KGReference + + " -V " + testfile + + " -o %s --no_cmdline_in_header", + 1, + UserException.CouldNotReadInputFile.class + ); + spec.disableShadowBCF(); + + executeTest("testNotFileVcfException--" + testfile, spec); + } + + /** + * Test with a VCF file that does not exist + */ + @Test + public void testMissingVcfException(){ + String testfile = "test.vcf"; + + WalkerTestSpec spec = new WalkerTestSpec( + "-T SelectVariants" + + " -R " + b36KGReference + + " -V " + testfile + + " -o %s --no_cmdline_in_header", + 1, + UserException.CouldNotReadInputFile.class + ); + spec.disableShadowBCF(); + + executeTest("testMissingVcfException--" + testfile, spec); + } } diff --git a/public/gatk-utils/src/main/java/org/broadinstitute/gatk/utils/commandline/ArgumentTypeDescriptor.java b/public/gatk-utils/src/main/java/org/broadinstitute/gatk/utils/commandline/ArgumentTypeDescriptor.java index a1052261e..944858f55 100644 --- a/public/gatk-utils/src/main/java/org/broadinstitute/gatk/utils/commandline/ArgumentTypeDescriptor.java +++ b/public/gatk-utils/src/main/java/org/broadinstitute/gatk/utils/commandline/ArgumentTypeDescriptor.java @@ -26,13 +26,13 @@ package org.broadinstitute.gatk.utils.commandline; import htsjdk.tribble.AbstractFeatureReader; -import org.apache.log4j.Logger; import htsjdk.tribble.Feature; -import org.broadinstitute.gatk.utils.refdata.tracks.FeatureManager; +import org.apache.log4j.Logger; import org.broadinstitute.gatk.utils.classloader.JVMUtils; import org.broadinstitute.gatk.utils.exceptions.DynamicClassResolutionException; import org.broadinstitute.gatk.utils.exceptions.ReviewedGATKException; import org.broadinstitute.gatk.utils.exceptions.UserException; +import org.broadinstitute.gatk.utils.refdata.tracks.FeatureManager; import org.broadinstitute.gatk.utils.text.XReadLines; import java.io.File; @@ -396,13 +396,13 @@ public abstract class ArgumentTypeDescriptor { } if ( ! file.exists() ) { - throw new UserException.CouldNotReadInputFile(file, "file does not exist"); + throw new UserException.CouldNotReadInputFile(file, "file \'"+ file + "\' does not exist"); } else if ( ! file.canRead() || ! file.isFile() ) { - throw new UserException.CouldNotReadInputFile(file, "file could not be read"); + throw new UserException.CouldNotReadInputFile(file, "file \'"+ file + "\' could not be read"); } else { throw new UserException.CommandLineException( - String.format("No tribble type was provided on the command line and the type of the file could not be determined dynamically. " + - "Please add an explicit type tag :NAME listing the correct type from among the supported types:%n%s", + String.format("No tribble type was provided on the command line and the type of the file \'"+ file + "\' could not be determined dynamically. " + + "Please add an explicit type tag :NAME listing the correct type from among the supported types:%n%s", manager.userFriendlyListOfAvailableFeatures(parameterType))); } }