diff --git a/java/src/org/broadinstitute/sting/alignment/bwa/BWTFiles.java b/java/src/org/broadinstitute/sting/alignment/bwa/BWTFiles.java
index e015a192b..43d0b6ca3 100644
--- a/java/src/org/broadinstitute/sting/alignment/bwa/BWTFiles.java
+++ b/java/src/org/broadinstitute/sting/alignment/bwa/BWTFiles.java
@@ -230,7 +230,7 @@ public class BWTFiles {
* Convert the given reference sequence into a form suitable for building into
* on-the-fly sequences.
* @param referenceSequence The reference sequence to normalize.
- * @throws StingException if normalized sequence cannot be generated.
+ * @throws GATKException if normalized sequence cannot be generated.
*/
private static void normalizeReferenceSequence(byte[] referenceSequence) {
StringUtil.toUpperCase(referenceSequence);
diff --git a/java/src/org/broadinstitute/sting/alignment/reference/bwt/BWTReader.java b/java/src/org/broadinstitute/sting/alignment/reference/bwt/BWTReader.java
index 97bdd21b8..7c4119295 100644
--- a/java/src/org/broadinstitute/sting/alignment/reference/bwt/BWTReader.java
+++ b/java/src/org/broadinstitute/sting/alignment/reference/bwt/BWTReader.java
@@ -67,7 +67,7 @@ public class BWTReader {
}
}
catch( IOException ex ) {
- throw new StingException("Unable to read BWT from input stream.", ex);
+ throw new GATKException("Unable to read BWT from input stream.", ex);
}
return new BWT(inverseSA0, new Counts(count,true), sequenceBlocks);
diff --git a/java/src/org/broadinstitute/sting/analyzecovariates/AnalyzeCovariates.java b/java/src/org/broadinstitute/sting/analyzecovariates/AnalyzeCovariates.java
index 54ea8b47a..41abd092c 100755
--- a/java/src/org/broadinstitute/sting/analyzecovariates/AnalyzeCovariates.java
+++ b/java/src/org/broadinstitute/sting/analyzecovariates/AnalyzeCovariates.java
@@ -28,6 +28,7 @@ package org.broadinstitute.sting.analyzecovariates;
import org.broadinstitute.sting.commandline.Input;
import org.broadinstitute.sting.gatk.walkers.recalibration.*;
import org.broadinstitute.sting.utils.classloader.PackageUtils;
+import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
import org.broadinstitute.sting.utils.text.XReadLines;
import org.broadinstitute.sting.commandline.CommandLineProgram;
import org.broadinstitute.sting.commandline.Argument;
@@ -140,11 +141,8 @@ class AnalyzeCovariatesCLP extends CommandLineProgram {
try {
Covariate covariate = (Covariate)covClass.newInstance();
requestedCovariates.add( covariate );
-
- } catch ( InstantiationException e ) {
- throw new RuntimeException( String.format("Can not instantiate covariate class '%s': must be concrete class.", covClass.getSimpleName()) );
- } catch ( IllegalAccessException e ) {
- throw new RuntimeException( String.format("Can not instantiate covariate class '%s': must have no-arg constructor.", covClass.getSimpleName()) );
+ } catch (Exception e) {
+ throw new DynamicClassResolutionException(covClass, e);
}
}
}
diff --git a/java/src/org/broadinstitute/sting/commandline/ArgumentTypeDescriptor.java b/java/src/org/broadinstitute/sting/commandline/ArgumentTypeDescriptor.java
index 663168242..4323190d4 100644
--- a/java/src/org/broadinstitute/sting/commandline/ArgumentTypeDescriptor.java
+++ b/java/src/org/broadinstitute/sting/commandline/ArgumentTypeDescriptor.java
@@ -31,6 +31,7 @@ import org.broadinstitute.sting.utils.classloader.JVMUtils;
import org.broadinstitute.sting.gatk.walkers.Multiplex;
import org.broadinstitute.sting.gatk.walkers.Multiplexer;
import org.apache.log4j.Logger;
+import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import java.lang.annotation.Annotation;
@@ -348,16 +349,13 @@ class SimpleArgumentTypeDescriptor extends ArgumentTypeDescriptor {
Constructor ctor = type.getConstructor(String.class);
result = ctor.newInstance(value);
}
- }
- catch (NoSuchMethodException e) {
- throw new GATKException("constructFromString:NoSuchMethodException: Failed conversion " + e.getMessage());
- } catch (IllegalAccessException e) {
- throw new GATKException("constructFromString:IllegalAccessException: Failed conversion " + e.getMessage());
} catch (InvocationTargetException e) {
throw new GATKException("constructFromString:InvocationTargetException: Failed conversion - this is most likely caused by using an incorrect data type (e.g. a double when an int is required)");
- } catch (InstantiationException e) {
- throw new GATKException("constructFromString:InstantiationException: Failed conversion " + e.getMessage());
+ } catch (Exception e) {
+ throw new DynamicClassResolutionException(String.class, e);
}
+
+
// WARNING: Side effect!
parsingEngine.addTags(result,tags);
diff --git a/java/src/org/broadinstitute/sting/gatk/CommandLineExecutable.java b/java/src/org/broadinstitute/sting/gatk/CommandLineExecutable.java
index 1beff2b69..672a1ca1a 100644
--- a/java/src/org/broadinstitute/sting/gatk/CommandLineExecutable.java
+++ b/java/src/org/broadinstitute/sting/gatk/CommandLineExecutable.java
@@ -101,7 +101,7 @@ public abstract class CommandLineExecutable extends CommandLineProgram {
*/
private void generateGATKRunReport(Walker,?> mWalker, Exception e) {
if ( getArgumentCollection().phoneHomeType != GATKRunReport.PhoneHomeOption.NO_ET ) {
- GATKRunReport report = new GATKRunReport(mWalker, e, GATKEngine);
+ GATKRunReport report = new GATKRunReport(mWalker, e, GATKEngine, getArgumentCollection().phoneHomeType );
if ( getArgumentCollection().phoneHomeType == GATKRunReport.PhoneHomeOption.STDOUT )
report.postReport(System.out);
else
diff --git a/java/src/org/broadinstitute/sting/gatk/contexts/AlignmentContext.java b/java/src/org/broadinstitute/sting/gatk/contexts/AlignmentContext.java
index 238c5fe23..8005dc64e 100755
--- a/java/src/org/broadinstitute/sting/gatk/contexts/AlignmentContext.java
+++ b/java/src/org/broadinstitute/sting/gatk/contexts/AlignmentContext.java
@@ -68,7 +68,7 @@ public class AlignmentContext {
}
public AlignmentContext(GenomeLoc loc, ReadBackedPileup basePileup, long skippedBases,boolean hasPileupBeenDownsampled ) {
- if ( loc == null ) throw new StingException("BUG: GenomeLoc in Alignment context is null");
+ if ( loc == null ) throw new GATKException("BUG: GenomeLoc in Alignment context is null");
if ( basePileup == null ) throw new GATKException("BUG: ReadBackedPileup in Alignment context is null");
if ( skippedBases < 0 ) throw new GATKException("BUG: skippedBases is -1 in Alignment context");
diff --git a/java/src/org/broadinstitute/sting/gatk/datasources/DataSourceGenerationException.java b/java/src/org/broadinstitute/sting/gatk/datasources/DataSourceGenerationException.java
index e18347d67..a6933918b 100644
--- a/java/src/org/broadinstitute/sting/gatk/datasources/DataSourceGenerationException.java
+++ b/java/src/org/broadinstitute/sting/gatk/datasources/DataSourceGenerationException.java
@@ -1,5 +1,6 @@
package org.broadinstitute.sting.gatk.datasources;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
/**
@@ -20,7 +21,7 @@ import org.broadinstitute.sting.utils.StingException;
* This exception is throw when we're unable to generate a data source,
* most likely due to an incomplete input source list
*/
-public class DataSourceGenerationException extends StingException {
+public class DataSourceGenerationException extends GATKException {
public DataSourceGenerationException(String message) {
super(message);
}
diff --git a/java/src/org/broadinstitute/sting/gatk/datasources/simpleDataSources/ReferenceOrderedDataSource.java b/java/src/org/broadinstitute/sting/gatk/datasources/simpleDataSources/ReferenceOrderedDataSource.java
index bcacf761f..c57cb670a 100755
--- a/java/src/org/broadinstitute/sting/gatk/datasources/simpleDataSources/ReferenceOrderedDataSource.java
+++ b/java/src/org/broadinstitute/sting/gatk/datasources/simpleDataSources/ReferenceOrderedDataSource.java
@@ -216,7 +216,7 @@ class ReferenceOrderedQueryDataPool extends ResourcePool
* Generate this on a simple data source load exception
*/
-public class SimpleDataSourceLoadException extends StingException {
+public class SimpleDataSourceLoadException extends GATKException {
public SimpleDataSourceLoadException(String msg) {
super(msg);
}
diff --git a/java/src/org/broadinstitute/sting/gatk/datasources/simpleDataSources/SimpleDataSourceSplitException.java b/java/src/org/broadinstitute/sting/gatk/datasources/simpleDataSources/SimpleDataSourceSplitException.java
index 79fbea0f6..819fa04c4 100644
--- a/java/src/org/broadinstitute/sting/gatk/datasources/simpleDataSources/SimpleDataSourceSplitException.java
+++ b/java/src/org/broadinstitute/sting/gatk/datasources/simpleDataSources/SimpleDataSourceSplitException.java
@@ -2,6 +2,7 @@ package org.broadinstitute.sting.gatk.datasources.simpleDataSources;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
@@ -39,7 +40,7 @@ import org.broadinstitute.sting.utils.StingException;
*
* an exception that get's thrown if we can't split up a data source appropriately
*/
-public class SimpleDataSourceSplitException extends StingException {
+public class SimpleDataSourceSplitException extends GATKException {
public SimpleDataSourceSplitException(String msg) {
super(msg);
}
diff --git a/java/src/org/broadinstitute/sting/gatk/io/storage/OutputStreamStorage.java b/java/src/org/broadinstitute/sting/gatk/io/storage/OutputStreamStorage.java
index 918f029f8..d8be881fe 100644
--- a/java/src/org/broadinstitute/sting/gatk/io/storage/OutputStreamStorage.java
+++ b/java/src/org/broadinstitute/sting/gatk/io/storage/OutputStreamStorage.java
@@ -98,7 +98,7 @@ public class OutputStreamStorage extends OutputStream implements Storage walker, Exception e, GenomeAnalysisEngine engine) {
+ public GATKRunReport(Walker,?> walker, Exception e, GenomeAnalysisEngine engine, PhoneHomeOption type) {
+ if ( type == PhoneHomeOption.NO_ET )
+ throw new GATKException("Trying to create a run report when type is NO_ET!");
+
mGATKHeader = CommandLineGATK.createApplicationHeader();
currentPath = System.getProperty("user.dir");
diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/RODRecordIterator.java b/java/src/org/broadinstitute/sting/gatk/refdata/RODRecordIterator.java
index f0b88afb9..acb8273c4 100644
--- a/java/src/org/broadinstitute/sting/gatk/refdata/RODRecordIterator.java
+++ b/java/src/org/broadinstitute/sting/gatk/refdata/RODRecordIterator.java
@@ -26,6 +26,7 @@
package org.broadinstitute.sting.gatk.refdata;
import org.broadinstitute.sting.utils.GATKException;
+import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.text.XReadLines;
import org.broadinstitute.sting.utils.Utils;
@@ -232,12 +233,8 @@ public class RODRecordIterator implements Ite
private ROD instantiateROD(final String name) {
try {
return (ROD) named_constructor.newInstance(name);
- } catch (java.lang.InstantiationException e) {
- throw new GATKException("Failed to instantiate ROD object of class "+type.getName());
- } catch (java.lang.IllegalAccessException e) {
- throw new GATKException("Access violation attempt while instantiating ROD object of class "+type.getName());
- } catch (InvocationTargetException e) {
- throw new GATKException("InvocationTargetException: Failed to instantiate ROD object of class "+type.getName());
+ } catch (Exception e) {
+ throw new DynamicClassResolutionException(named_constructor.getDeclaringClass(), e);
}
}
diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/tracks/RMDTrackCreationException.java b/java/src/org/broadinstitute/sting/gatk/refdata/tracks/RMDTrackCreationException.java
index 3dc0fb9bb..0b29f10c3 100644
--- a/java/src/org/broadinstitute/sting/gatk/refdata/tracks/RMDTrackCreationException.java
+++ b/java/src/org/broadinstitute/sting/gatk/refdata/tracks/RMDTrackCreationException.java
@@ -23,6 +23,7 @@
package org.broadinstitute.sting.gatk.refdata.tracks;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
@@ -34,7 +35,7 @@ import org.broadinstitute.sting.utils.StingException;
*
* if we fail for some reason to make a track, throw this exception
*/
-public class RMDTrackCreationException extends StingException {
+public class RMDTrackCreationException extends GATKException {
public RMDTrackCreationException(String msg) {
super(msg);
}
diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/indels/IndelRealigner.java b/java/src/org/broadinstitute/sting/gatk/walkers/indels/IndelRealigner.java
index e61d7f847..d3ba2d9b5 100755
--- a/java/src/org/broadinstitute/sting/gatk/walkers/indels/IndelRealigner.java
+++ b/java/src/org/broadinstitute/sting/gatk/walkers/indels/IndelRealigner.java
@@ -333,7 +333,7 @@ public class IndelRealigner extends ReadWalker {
do {
currentInterval = intervals.hasNext() ? intervals.next() : null;
} while ( currentInterval != null && (readLoc == null || currentInterval.isBefore(readLoc)) );
- } catch (StingException e) {
+ } catch (GATKException e) {
throw new UserError.MissortedFile(new File(intervalsFile), " *** Are you sure that your interval file is sorted? If not, you must use the --targetIntervalsAreNotSorted argument. ***", e);
}
diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/recalibration/CovariateCounterWalker.java b/java/src/org/broadinstitute/sting/gatk/walkers/recalibration/CovariateCounterWalker.java
index dc21aaad8..7a0b26bf4 100755
--- a/java/src/org/broadinstitute/sting/gatk/walkers/recalibration/CovariateCounterWalker.java
+++ b/java/src/org/broadinstitute/sting/gatk/walkers/recalibration/CovariateCounterWalker.java
@@ -38,6 +38,7 @@ import org.broadinstitute.sting.utils.classloader.PackageUtils;
import org.broadinstitute.sting.utils.collections.NestedHashMap;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.ArgumentCollection;
+import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.pileup.PileupElement;
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
@@ -213,10 +214,8 @@ public class CovariateCounterWalker extends LocusWalker {
Constructor constructor = c.getConstructor(argTypes);
VariantEvaluator eval = (VariantEvaluator)constructor.newInstance(args);
evals.add(eval);
- } catch (InstantiationException e) {
- throw new StingException(String.format("Cannot instantiate class '%s': must be concrete class", c.getSimpleName()));
- } catch (NoSuchMethodException e) {
- throw new StingException(String.format("Cannot find expected constructor for class '%s': must have constructor accepting a single VariantEval2Walker object", c.getSimpleName()));
- } catch (IllegalAccessException e) {
- throw new StingException(String.format("Cannot instantiate class '%s' (Illegal Access):", c.getSimpleName()));
- } catch (InvocationTargetException e) {
- throw new StingException(String.format("Cannot instantiate class '%s' (Invocation): %s", c.getSimpleName(), e.getMessage()));
+ } catch (Exception e) {
+ throw new DynamicClassResolutionException(c, e);
}
}
@@ -565,7 +560,7 @@ public class VariantEvalWalker extends RodWalker {
if ( interesting != null ) interestingReasons.add(interesting);
break;
default:
- throw new StingException("BUG: Unexpected evaluation order " + evaluation);
+ throw new GATKException("BUG: Unexpected evaluation order " + evaluation);
}
}
}
diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/ApplyVariantCuts.java b/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/ApplyVariantCuts.java
index b77369096..7eaf9247f 100755
--- a/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/ApplyVariantCuts.java
+++ b/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/ApplyVariantCuts.java
@@ -37,6 +37,7 @@ import org.broadinstitute.sting.gatk.walkers.RodWalker;
import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
import org.broadinstitute.sting.commandline.Argument;
+import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
import org.broadinstitute.sting.utils.text.XReadLines;
@@ -127,7 +128,7 @@ public class ApplyVariantCuts extends RodWalker {
return tranches;
} catch( FileNotFoundException e ) {
- throw new StingException("Can not find input file: " + f);
+ throw new UserError.CouldNotCreateOutputFile(f, e);
}
}
@@ -155,7 +156,7 @@ public class ApplyVariantCuts extends RodWalker {
firstLine = false;
}
} catch( FileNotFoundException e ) {
- throw new StingException("Can not find input file: " + TRANCHES_FILE);
+ throw new UserError.CouldNotCreateOutputFile(TRANCHES_FILE, e);
}
// setup the header fields
diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/GenerateVariantClustersWalker.java b/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/GenerateVariantClustersWalker.java
index beb1ec05d..e7acd71e4 100755
--- a/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/GenerateVariantClustersWalker.java
+++ b/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/GenerateVariantClustersWalker.java
@@ -41,6 +41,7 @@ import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.Utils;
import org.broadinstitute.sting.commandline.Argument;
+import org.broadinstitute.sting.utils.exceptions.UserError;
import java.io.File;
import java.io.IOException;
@@ -147,7 +148,7 @@ public class GenerateVariantClustersWalker extends RodWalker 0 clustering weight! Please provide sets of known polymorphic loci to be used as training data using the dbsnp, hapmap, or 1kg rod bindings. Clustering weights can be specified using -weightDBSNP, -weightHapMap, and -weight1KG" );
+ throw new UserError.BadInput("There are zero variants with > 0 clustering weight! Please provide sets of known polymorphic loci to be used as training data using the dbsnp, hapmap, or 1kg rod bindings. Clustering weights can be specified using -weightDBSNP, -weightHapMap, and -weight1KG" );
}
if( _annotationKeys == null ) {
numAnnotations = 0;
@@ -62,7 +63,7 @@ public class VariantDataManager {
} else {
numAnnotations = _annotationKeys.size();
if( numAnnotations <= 0 ) {
- throw new StingException( "There are zero annotations!" );
+ throw new UserError.BadInput("There are zero annotations. At least one annotation must be provided to use this walker!" );
}
meanVector = new double[numAnnotations];
varianceVector = new double[numAnnotations];
@@ -110,7 +111,7 @@ public class VariantDataManager {
}
isNormalized = true; // Each data point is now [ (x - mean) / standard deviation ]
if( foundZeroVarianceAnnotation ) {
- throw new StingException("Found annotations with zero variance. They must be excluded before proceeding.");
+ throw new UserError.BadInput("Found annotations with zero variance. They must be excluded before proceeding.");
}
}
diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantGaussianMixtureModel.java b/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantGaussianMixtureModel.java
index d9cdbd243..71fea9455 100755
--- a/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantGaussianMixtureModel.java
+++ b/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantGaussianMixtureModel.java
@@ -28,9 +28,11 @@ package org.broadinstitute.sting.gatk.walkers.variantrecalibration;
import org.apache.log4j.Logger;
import org.broad.tribble.util.variantcontext.VariantContext;
import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContextUtils;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.MathUtils;
import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
import org.broadinstitute.sting.utils.StingException;
+import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.text.XReadLines;
import Jama.*;
@@ -130,11 +132,11 @@ public final class VariantGaussianMixtureModel extends VariantOptimizationModel
} else if( CLUSTER_PATTERN.matcher(line).matches() ) {
clusterLines.add(line);
} else {
- throw new StingException("Malformed input file: " + clusterFile);
+ throw new UserError.MalformedFile(clusterFile, "Could not parse line: " + line);
}
}
} catch ( FileNotFoundException e ) {
- throw new StingException("Can not find input file: " + clusterFile);
+ throw new UserError.CouldNotReadInputFile(clusterFile, e);
}
dataManager = new VariantDataManager( annotationLines );
@@ -427,9 +429,8 @@ public final class VariantGaussianMixtureModel extends VariantOptimizationModel
} else {
try {
value = Double.parseDouble( (String)vc.getAttribute( annotationKey ) );
- } catch( Exception e ) {
- throw new StingException("No double value detected for annotation = " + annotationKey +
- " in variant at " + VariantContextUtils.getLocation(vc) + ", reported annotation value = " + vc.getAttribute( annotationKey ) );
+ } catch( NumberFormatException e ) {
+ throw new UserError.MalformedFile(vc.getName(), "No double value detected for annotation = " + annotationKey + " in variant at " + VariantContextUtils.getLocation(vc) + ", reported annotation value = " + vc.getAttribute( annotationKey ), e );
}
}
return value;
@@ -488,10 +489,11 @@ public final class VariantGaussianMixtureModel extends VariantOptimizationModel
int annIndex = 0;
for( final String annotation : dataManager.annotationKeys ) {
PrintStream outputFile;
+ File file = new File(outputPrefix + "." + annotation + ".dat");
try {
- outputFile = new PrintStream( outputPrefix + "." + annotation + ".dat" );
- } catch (Exception e) {
- throw new StingException( "Unable to create output file: " + outputPrefix + ".dat" );
+ outputFile = new PrintStream( file );
+ } catch (FileNotFoundException e) {
+ throw new UserError.CouldNotCreateOutputFile( file, e );
}
outputFile.println("annotationValue,knownDist,novelDist");
@@ -506,7 +508,7 @@ public final class VariantGaussianMixtureModel extends VariantOptimizationModel
}
}
- public final void outputOptimizationCurve( final VariantDatum[] data, final PrintStream outputReportDatFile, final PrintStream outputTranchesFile,
+ public final void outputOptimizationCurve( final VariantDatum[] data, final PrintStream outputReportDatFile, final PrintStream tranchesOutputFile,
final int desiredNumVariants, final Double[] FDRtranches, final double QUAL_STEP ) {
final int numVariants = data.length;
@@ -530,19 +532,7 @@ public final class VariantGaussianMixtureModel extends VariantOptimizationModel
markedVariant[iii] = false;
}
- PrintStream outputFile;
- try {
- outputFile = new PrintStream( outputReportDatFile );
- } catch (Exception e) {
- throw new StingException( "Unable to create output file: " + outputReportDatFile );
- }
- PrintStream tranchesOutputFile;
- try {
- tranchesOutputFile = new PrintStream( outputTranchesFile );
- tranchesOutputFile.println("FDRtranche,novelTITV,pCut,numNovel,filterName");
- } catch (Exception e) {
- throw new StingException( "Unable to create output file: " + outputTranchesFile );
- }
+ tranchesOutputFile.println("FDRtranche,novelTITV,pCut,numNovel,filterName");
int numKnown = 0;
int numNovel = 0;
@@ -552,7 +542,7 @@ public final class VariantGaussianMixtureModel extends VariantOptimizationModel
int numNovelTv = 0;
boolean foundDesiredNumVariants = false;
int jjj = 0;
- outputFile.println("pCut,numKnown,numNovel,knownTITV,novelTITV");
+ outputReportDatFile.println("pCut,numKnown,numNovel,knownTITV,novelTITV");
for( double qCut = MAX_QUAL; qCut >= -0.001; qCut -= QUAL_STEP ) {
for( int iii = 0; iii < numVariants; iii++ ) {
if( !markedVariant[iii] ) {
@@ -584,7 +574,7 @@ public final class VariantGaussianMixtureModel extends VariantOptimizationModel
logger.info("\t" + String.format("%.4f novel Ti/Tv ratio", ((double)numNovelTi) / ((double)numNovelTv)));
foundDesiredNumVariants = true;
}
- outputFile.println( qCut + "," + numKnown + "," + numNovel + "," +
+ outputReportDatFile.println( qCut + "," + numKnown + "," + numNovel + "," +
( numKnownTi == 0 || numKnownTv == 0 ? "NaN" : ( ((double)numKnownTi) / ((double)numKnownTv) ) ) + "," +
( numNovelTi == 0 || numNovelTv == 0 ? "NaN" : ( ((double)numNovelTi) / ((double)numNovelTv) ) ));
@@ -710,7 +700,7 @@ public final class VariantGaussianMixtureModel extends VariantOptimizationModel
logger.warn("About to throw exception due to numerical instability. Try running with fewer annotations and then with fewer Gaussians. " +
"It is best to only use the annotations which appear to be Gaussianly distributed for this Gaussian mixture model.");
- throw new StingException("Numerical Instability! Found NaN after performing log10: " + pVarInClusterLog10[kkk] + ", cluster = " + kkk + ", variant index = " + iii);
+ throw new GATKException("Numerical Instability! Found NaN after performing log10: " + pVarInClusterLog10[kkk] + ", cluster = " + kkk + ", variant index = " + iii);
}
}
@@ -720,7 +710,7 @@ public final class VariantGaussianMixtureModel extends VariantOptimizationModel
if( Double.isNaN(pVarInCluster[kkk][iii]) ) {
logger.warn("About to throw exception due to numerical instability. Try running with fewer annotations and then with fewer Gaussians. " +
"It is best to only use the annotations which appear to be Gaussianly distributed for this Gaussian mixture model.");
- throw new StingException("Numerical Instability! Found NaN after rescaling log10 values: " + pVarInCluster[kkk][iii] + ", cluster = " + kkk + ", variant index = " + iii);
+ throw new GATKException("Numerical Instability! Found NaN after rescaling log10 values: " + pVarInCluster[kkk][iii] + ", cluster = " + kkk + ", variant index = " + iii);
}
}
}
@@ -786,7 +776,7 @@ public final class VariantGaussianMixtureModel extends VariantOptimizationModel
if( Double.isNaN(prob) ) {
logger.warn("About to throw exception due to numerical instability. Try running with fewer annotations and then with fewer Gaussians. " +
"It is best to only use the annotations which appear to be Gaussianly distributed for this Gaussian mixture model.");
- throw new StingException("Numerical Instability! Found NaN in M-step: " + pVarInCluster[kkk][iii] + ", cluster = " + kkk + ", variant index = " + iii);
+ throw new GATKException("Numerical Instability! Found NaN in M-step: " + pVarInCluster[kkk][iii] + ", cluster = " + kkk + ", variant index = " + iii);
}
sumProb += prob;
for( int jjj = 0; jjj < numAnnotations; jjj++ ) {
diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantRecalibrator.java b/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantRecalibrator.java
index 32e7c42a2..ae7bbf644 100755
--- a/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantRecalibrator.java
+++ b/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantRecalibrator.java
@@ -41,6 +41,7 @@ import org.broadinstitute.sting.gatk.walkers.RodWalker;
import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
import org.broadinstitute.sting.commandline.Argument;
+import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
import java.io.File;
@@ -143,7 +144,7 @@ public class VariantRecalibrator extends RodWalker T getInstance(Class c) {
try {
return c.newInstance();
- } catch (InstantiationException e) {
- throw new StingException(String.format("Cannot instantiate annotation class '%s': must be concrete class", c.getSimpleName()));
- } catch (IllegalAccessException e) {
- throw new StingException(String.format("Cannot instantiate annotation class '%s': must have no-arg constructor", c.getSimpleName()));
+ } catch (Exception e) {
+ throw new DynamicClassResolutionException(c, e);
}
}
diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/BaseTransitionTableCalculatorJavaWalker.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/BaseTransitionTableCalculatorJavaWalker.java
index 56abdce19..abde9a450 100644
--- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/BaseTransitionTableCalculatorJavaWalker.java
+++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/BaseTransitionTableCalculatorJavaWalker.java
@@ -33,8 +33,10 @@ import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.*;
+import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.pileup.ReadBackedPileup;
+import java.io.File;
import java.util.*;
import java.io.PrintStream;
import java.io.FileNotFoundException;
@@ -85,7 +87,7 @@ public class BaseTransitionTableCalculatorJavaWalker extends LocusWalker 3 || ( nPreviousReadBases > 3 && readBasesMustMatchRef ) ) {
- throw new StingException("You have opted to use a number of previous bases in excess of 3. In order to do this you must change the reference window size in the walker itself.");
+ throw new UserError.CommandLineError("You have opted to use a number of previous bases in excess of 3. In order to do this you must change the reference window size in the walker itself.");
}
UnifiedArgumentCollection uac = new UnifiedArgumentCollection();
uac.baseModel = BaseMismatchModel.THREE_STATE;
@@ -149,7 +151,7 @@ public class BaseTransitionTableCalculatorJavaWalker extends LocusWalker {
else if (compGenotype.isHomVar())
hg = 2;
else
- throw new StingException("Bug! invalid genotype!");
+ throw new GATKException("Bug! invalid genotype!");
if (postbglGenotype.isNoCall())
bg = -1;
@@ -167,7 +168,7 @@ public class BeagleOutputByDepthWalker extends RodWalker {
else if (postbglGenotype.isHomVar())
bg = 2;
else
- throw new StingException("Bug! invalid genotype!");
+ throw new GATKException("Bug! invalid genotype!");
if (prebglGenotype.isNoCall())
@@ -179,7 +180,7 @@ public class BeagleOutputByDepthWalker extends RodWalker {
else if (prebglGenotype.isHomVar())
pg = 2;
else
- throw new StingException("Bug! invalid genotype!");
+ throw new GATKException("Bug! invalid genotype!");
outputWriter.format("%d %d %d %d\n",dp, hg, pg, bg);
diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/DSBWalkerV3.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/DSBWalkerV3.java
index 2b165ce39..f6919a0c2 100644
--- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/DSBWalkerV3.java
+++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/DSBWalkerV3.java
@@ -31,6 +31,7 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.*;
+import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.sam.AlignmentUtils;
import net.sf.samtools.SAMRecord;
@@ -390,7 +391,7 @@ public class DSBWalkerV3 extends ReadWalker {
} else if ( controlReadGroups.contains( read.getReadGroup().getReadGroupId() )) {
addControl(read);
} else {
- throw new StingException("Read "+read + " belongs to unrecognized read group");
+ throw new UserError.MalformedBam(read, "Read "+read + " belongs to unrecognized read group");
}
return 1;
}
diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/DbSNPWindowCounter.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/DbSNPWindowCounter.java
index 0269ad09a..e07227d29 100644
--- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/DbSNPWindowCounter.java
+++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/DbSNPWindowCounter.java
@@ -17,6 +17,7 @@ import org.broadinstitute.sting.gatk.walkers.DataSource;
import org.broadinstitute.sting.gatk.walkers.LocusWalker;
import org.broadinstitute.sting.gatk.walkers.Requires;
import org.broadinstitute.sting.utils.StingException;
+import org.broadinstitute.sting.utils.exceptions.UserError;
import java.io.File;
import java.io.FileNotFoundException;
@@ -68,7 +69,7 @@ public class DbSNPWindowCounter extends LocusWalker {
windowStart,
windowStop);
} catch (IOException e) {
- throw new StingException("Unable to query dbSNP track due to IO Exception",e);
+ throw new UserError.CouldNotReadInputFile(myDbSNPFile, e);
}
// count the number of dbSNPs we've seen
diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/DesignFileGeneratorWalker.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/DesignFileGeneratorWalker.java
index f7bab10c2..72ac5ff7f 100644
--- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/DesignFileGeneratorWalker.java
+++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/DesignFileGeneratorWalker.java
@@ -7,6 +7,7 @@ import org.broadinstitute.sting.gatk.refdata.*;
import org.broadinstitute.sting.gatk.refdata.features.refseq.RefSeqFeature;
import org.broadinstitute.sting.gatk.refdata.utils.GATKFeature;
import org.broadinstitute.sting.gatk.walkers.RodWalker;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.GenomeLocParser;
import org.broadinstitute.sting.utils.StingException;
@@ -196,7 +197,7 @@ class IntervalInfoBuilder {
}
}
} else {
- throw new StingException("Attempting to update an IntervalInfoBuilder twice with the same (non-TCGA) gene: "+gene);
+ throw new GATKException("Attempting to update an IntervalInfoBuilder twice with the same (non-TCGA) gene: "+gene);
}
} else {
diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/DownsamplingValidationWalker.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/DownsamplingValidationWalker.java
index 50c5b2afd..ac154bca4 100644
--- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/DownsamplingValidationWalker.java
+++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/DownsamplingValidationWalker.java
@@ -29,6 +29,7 @@ import org.broadinstitute.sting.gatk.refdata.features.samread.SAMReadFeature;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.walkers.LocusWalker;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.pileup.ReadBackedPileup;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.commandline.Argument;
@@ -71,7 +72,7 @@ public class DownsamplingValidationWalker extends LocusWalker {
int matchingReadsFound = 0;
if(unsampledReadsStartingAtThisLocus.isEmpty()) {
if(!sampledReadsStartingAtThisLocus.isEmpty())
- throw new StingException("Downsampler hallucinated a read starting at locus "+ref.getLocus());
+ throw new GATKException("Downsampler hallucinated a read starting at locus "+ref.getLocus());
}
else {
boolean foundMatch = false;
@@ -86,10 +87,10 @@ public class DownsamplingValidationWalker extends LocusWalker {
}
if(!foundMatch)
- throw new StingException("Downsampler failed to include any read starting at locus "+ref.getLocus());
+ throw new GATKException("Downsampler failed to include any read starting at locus "+ref.getLocus());
if(matchingReadsFound > maxExpectedNumberOfReads)
- throw new StingException("Downsampler found too many reads starting at locus "+ref.getLocus());
+ throw new GATKException("Downsampler found too many reads starting at locus "+ref.getLocus());
}
return matchingReadsFound;
diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/IndelAnnotator.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/IndelAnnotator.java
index 2475b13ca..eda664699 100644
--- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/IndelAnnotator.java
+++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/IndelAnnotator.java
@@ -19,6 +19,7 @@ import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.GenomeLocParser;
import org.broadinstitute.sting.utils.SampleUtils;
import org.broadinstitute.sting.utils.StingException;
+import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
import java.io.File;
@@ -42,7 +43,7 @@ public class IndelAnnotator extends RodWalker {
try {
refseqIterator = new SeekableRODIterator(new FeatureToGATKFeatureIterator(refseq.iterator(),"refseq"));
} catch (IOException e) {
- throw new StingException("Unable to open file " + RefseqFileName, e);
+ throw new UserError.CouldNotReadInputFile(RefseqFileName, e);
}
logger.info("Using RefSeq annotations from " + RefseqFileName);
diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/IndelDBRateWalker.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/IndelDBRateWalker.java
index 8964fb038..9852130f4 100644
--- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/IndelDBRateWalker.java
+++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/IndelDBRateWalker.java
@@ -18,6 +18,7 @@ import org.broadinstitute.sting.gatk.walkers.Window;
import org.broadinstitute.sting.utils.SampleUtils;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
+import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
import java.io.PrintStream;
@@ -45,7 +46,7 @@ public class IndelDBRateWalker extends RodWalker
public void initialize() {
if ( indelWindow > 40 ) {
- throw new StingException("Indel windows have a maximum size of 40");
+ throw new UserError.CommandLineError("Indel windows have a maximum size of 40");
}
if ( outVCF != null ) {
diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/MendelianViolationClassifier.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/MendelianViolationClassifier.java
index 49ab321d3..b45f4e9a6 100644
--- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/MendelianViolationClassifier.java
+++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/MendelianViolationClassifier.java
@@ -19,10 +19,7 @@ import org.broadinstitute.sting.gatk.walkers.genotyper.UnifiedArgumentCollection
import org.broadinstitute.sting.gatk.walkers.genotyper.UnifiedGenotyperEngine;
import org.broadinstitute.sting.gatk.walkers.genotyper.VariantCallContext;
import org.broadinstitute.sting.gatk.walkers.varianteval.MendelianViolationEvaluator;
-import org.broadinstitute.sting.utils.GenomeLoc;
-import org.broadinstitute.sting.utils.GenomeLocParser;
-import org.broadinstitute.sting.utils.SampleUtils;
-import org.broadinstitute.sting.utils.StingException;
+import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.utils.collections.Pair;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
import org.broadinstitute.sting.utils.pileup.PileupElement;
@@ -422,7 +419,7 @@ public class MendelianViolationClassifier extends LocusWalker splitContext = StratifiedAlignmentContext.splitContextBySample(context.getBasePileup());
diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/QualityScoreByStrandWalker.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/QualityScoreByStrandWalker.java
index 01dfcfeb1..3f519f1c3 100644
--- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/QualityScoreByStrandWalker.java
+++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/QualityScoreByStrandWalker.java
@@ -25,9 +25,13 @@
package org.broadinstitute.sting.oneoffprojects.walkers;
+import java.io.File;
import java.io.IOException;
+
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.QualityUtils;
import org.broadinstitute.sting.utils.StingException;
+import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.pileup.ReadBackedPileup;
import org.broadinstitute.sting.utils.pileup.PileupElement;
import org.broadinstitute.sting.commandline.Argument;
@@ -166,7 +170,7 @@ public class QualityScoreByStrandWalker extends LocusWalker 40 ? 40 : fQual]++;
reverseCountsByOffset[rOff][rQual < 0 ? 0 : rQual > 40 ? 40 : rQual]++;
}
diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/ReadQualityScoreWalker.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/ReadQualityScoreWalker.java
index 001cba3e3..3033025ff 100755
--- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/ReadQualityScoreWalker.java
+++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/ReadQualityScoreWalker.java
@@ -35,6 +35,7 @@ import org.broadinstitute.sting.utils.GenomeLocParser;
import org.broadinstitute.sting.utils.StingException;
import net.sf.samtools.SAMRecord;
import net.sf.samtools.SAMFileWriter;
+import org.broadinstitute.sting.utils.exceptions.UserError;
import java.io.*;
@@ -79,9 +80,9 @@ public class ReadQualityScoreWalker extends ReadWalker
try {
inputReader = new BufferedReader( new FileReader ( inputQualityFile ) );
} catch ( FileNotFoundException e) {
- throw new StingException("Could not find required input file: " + inputQualityFile);
+ throw new UserError.CouldNotReadInputFile(new File(inputQualityFile), e);
} catch (IOException e) {
- throw new StingException("Failed while reading data from input file: " + inputQualityFile);
+ throw new UserError.CouldNotReadInputFile(new File(inputQualityFile), e);
}
return outputBamFile;
}
@@ -103,13 +104,13 @@ public class ReadQualityScoreWalker extends ReadWalker
try {
if( line == null ) {
line = inputReader.readLine();
- if( line == null ) { throw new StingException( "Input file is empty: " + inputQualityFile ); }
+ if( line == null ) { throw new UserError.MalformedFile(new File(inputQualityFile), "Input file is empty" ); }
}
String[] halves = line.split( " ", 2 );
GenomeLoc curLoc = GenomeLocParser.parseGenomeLoc( halves[0] );
while( curLoc.isBefore( readLoc ) ) { // Loop until the beginning of the read
line = inputReader.readLine();
- if( line == null ) { throw new StingException( "Input file doesn't encompass all reads. Can't find beginning of read: " + readLoc ); }
+ if( line == null ) { throw new UserError.MalformedFile(new File(inputQualityFile), "Input file doesn't encompass all reads. Can't find beginning of read: " + readLoc ); }
halves = line.split( " ", 2 );
curLoc = GenomeLocParser.parseGenomeLoc( halves[0] );
}
@@ -122,7 +123,7 @@ public class ReadQualityScoreWalker extends ReadWalker
sumNeighborhoodQuality += Float.parseFloat( halves[1] );
numLines++;
line = inputReader.readLine();
- if( line == null ) { throw new StingException( "Input file doesn't encompass all reads. Can't find end of read: " + readLoc ); }
+ if( line == null ) { throw new UserError.MalformedFile(new File(inputQualityFile), "Input file doesn't encompass all reads. Can't find end of read: " + readLoc ); }
halves = line.split( " ", 2 );
curLoc = GenomeLocParser.parseGenomeLoc( halves[0] );
}
@@ -132,9 +133,9 @@ public class ReadQualityScoreWalker extends ReadWalker
line = savedLine;
} catch ( FileNotFoundException e ) {
- throw new StingException( "Could not find required input file: " + inputQualityFile );
+ throw new UserError.CouldNotReadInputFile(new File(inputQualityFile), e);
} catch (IOException e ) {
- throw new StingException( "Failed while reading data from input file: " + inputQualityFile + " Also, " + e.getMessage() );
+ throw new UserError.CouldNotReadInputFile(new File(inputQualityFile), e);
}
meanNeighborhoodQuality = sumNeighborhoodQuality / ((float) numLines);
diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/TestReadFishingWalker.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/TestReadFishingWalker.java
index e4ea1e9f6..1e3a0acb1 100644
--- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/TestReadFishingWalker.java
+++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/TestReadFishingWalker.java
@@ -34,6 +34,7 @@ import org.broadinstitute.sting.alignment.bwa.c.BWACAligner;
import org.broadinstitute.sting.alignment.Alignment;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.GenomeLocParser;
@@ -41,6 +42,7 @@ import net.sf.samtools.SAMRecord;
import net.sf.samtools.util.StringUtil;
import net.sf.picard.reference.ReferenceSequence;
import net.sf.picard.reference.IndexedFastaSequenceFile;
+import org.broadinstitute.sting.utils.exceptions.UserError;
import java.io.File;
import java.io.FileInputStream;
@@ -85,7 +87,7 @@ public class TestReadFishingWalker extends ReadWalker {
indelCallInputStream = new FileInputStream(indelCalls);
}
catch(IOException ex) {
- throw new StingException("Unable to load indel calls.");
+ throw new UserError.CouldNotReadInputFile(indelCalls, ex);
}
Scanner indelCallReader = new Scanner(indelCallInputStream);
@@ -127,7 +129,7 @@ public class TestReadFishingWalker extends ReadWalker {
System.arraycopy(referenceSequence.getBases(),eventStart,revisedReference,eventStart+eventLength,bufferWidth);
}
else
- throw new StingException("Invalid indel type: " + type);
+ throw new GATKException("Invalid indel type: " + type);
aligners.put(GenomeLocParser.createGenomeLoc(contig,start,stop),new BWACAligner(revisedReference,new BWAConfiguration()));
if(++numAlignersCreated % 100 == 0)
diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/VCF4WriterTestWalker.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/VCF4WriterTestWalker.java
index 4acfc5c7c..1e9fc2bdc 100755
--- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/VCF4WriterTestWalker.java
+++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/VCF4WriterTestWalker.java
@@ -11,6 +11,7 @@ import org.broadinstitute.sting.gatk.datasources.simpleDataSources.ReferenceOrde
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.refdata.tracks.RMDTrack;
import org.broadinstitute.sting.gatk.walkers.RodWalker;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
@@ -95,7 +96,7 @@ public class VCF4WriterTestWalker extends RodWalker {
out.printf("Read %d header lines%n", header.getMetaData().size());
}
catch (FileNotFoundException e ) {
- throw new StingException(e.getMessage());
+ throw new GATKException(e.getMessage());
}
final Set vcfSamples = header.getGenotypeSamples();
diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/varianteval/AminoAcidTransition.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/varianteval/AminoAcidTransition.java
index effae28c0..e42fb6b02 100755
--- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/varianteval/AminoAcidTransition.java
+++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/varianteval/AminoAcidTransition.java
@@ -9,10 +9,12 @@ import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.playground.utils.report.tags.Analysis;
import org.broadinstitute.sting.playground.utils.report.tags.DataPoint;
import org.broadinstitute.sting.playground.utils.report.utils.TableType;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.analysis.AminoAcid;
import org.broadinstitute.sting.utils.analysis.AminoAcidTable;
import org.broadinstitute.sting.utils.analysis.AminoAcidUtils;
+import org.broadinstitute.sting.utils.exceptions.UserError;
/*
* Copyright (c) 2010 The Broad Institute
@@ -143,11 +145,11 @@ public class AminoAcidTransition extends VariantEvaluator {
infoValueSplit = parent.aminoAcidTransitionSplit;
useCodons = parent.aatUseCodons;
if ( infoKey == null ) {
- throw new StingException("No info-field key provided for amino acid tabulation. Please provide the appropriate key with -aatk.");
+ throw new UserError.CommandLineError("No info-field key provided for amino acid tabulation. Please provide the appropriate key with -aatk.");
}
if ( infoValueSplit == null ) {
- throw new StingException("No split string provided for amino acid tabulation. Please provide the split string with -aats");
+ throw new UserError.CommandLineError("No split string provided for amino acid tabulation. Please provide the split string with -aats");
}
}
}
diff --git a/java/src/org/broadinstitute/sting/playground/analyzeconcordance/AnalyzeConcordance.java b/java/src/org/broadinstitute/sting/playground/analyzeconcordance/AnalyzeConcordance.java
index a384c9084..350f37228 100644
--- a/java/src/org/broadinstitute/sting/playground/analyzeconcordance/AnalyzeConcordance.java
+++ b/java/src/org/broadinstitute/sting/playground/analyzeconcordance/AnalyzeConcordance.java
@@ -27,6 +27,7 @@ package org.broadinstitute.sting.playground.analyzeconcordance;
import org.broadinstitute.sting.commandline.CommandLineProgram;
import org.broadinstitute.sting.commandline.Argument;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.text.XReadLines;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.Utils;
@@ -91,11 +92,8 @@ public class AnalyzeConcordance extends CommandLineProgram {
logger.info("Generating html report...");
generateHtmlReport();
logger.info("...Done!");
-
- } catch (StingException se) {
- throw se;
} catch (Exception e) {
- throw new StingException("Error analyzing concordance", e);
+ throw new GATKException("Error analyzing concordance", e);
}
return result;
@@ -105,7 +103,7 @@ public class AnalyzeConcordance extends CommandLineProgram {
// create the output directory where all the data tables and plots will go
File outputDir = new File(this.outputDir);
if (!outputDir.exists() && !outputDir.mkdirs()) {
- throw new StingException("Couldn't create directory: " + this.outputDir);
+ throw new GATKException("Couldn't create directory: " + this.outputDir);
}
}
diff --git a/java/src/org/broadinstitute/sting/playground/examples/SampleXmlMarshaller.java b/java/src/org/broadinstitute/sting/playground/examples/SampleXmlMarshaller.java
index ae3a968e1..57a43011b 100755
--- a/java/src/org/broadinstitute/sting/playground/examples/SampleXmlMarshaller.java
+++ b/java/src/org/broadinstitute/sting/playground/examples/SampleXmlMarshaller.java
@@ -1,7 +1,9 @@
package org.broadinstitute.sting.playground.examples;
import org.apache.log4j.BasicConfigurator;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
+import org.broadinstitute.sting.utils.exceptions.UserError;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.Serializer;
@@ -121,7 +123,7 @@ public class SampleXmlMarshaller {
SampleXmlMarshaller example = serializer.read(SampleXmlMarshaller.class, source);
return example;
} catch (Exception e) {
- throw new StingException("Failed to marshal the data to file " + filename,e);
+ throw new GATKException("Failed to marshal the data to file " + filename,e);
}
}
}
diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/LocusMismatchWalker.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/LocusMismatchWalker.java
index 3c3bdeafd..fd6fbe4c5 100755
--- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/LocusMismatchWalker.java
+++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/LocusMismatchWalker.java
@@ -39,6 +39,7 @@ import org.broadinstitute.sting.gatk.walkers.genotyper.UnifiedArgumentCollection
import org.broadinstitute.sting.gatk.walkers.genotyper.UnifiedGenotyperEngine;
import org.broadinstitute.sting.gatk.walkers.genotyper.VariantCallContext;
import org.broadinstitute.sting.utils.BaseUtils;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
@@ -155,7 +156,7 @@ public class LocusMismatchWalker extends LocusWalker implements
if ( g.isHomRef() ) return "HOM-REF";
else if ( g.isHet() ) return "HET";
else if ( g.isHom() ) return "HOM-NONREF";
- else throw new StingException("Unexpected genotype in getGenotypeClass " + g);
+ else throw new GATKException("Unexpected genotype in getGenotypeClass " + g);
}
public boolean useRead( PileupElement e ) {
diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/ReadBackedPhasingWalker.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/ReadBackedPhasingWalker.java
index 22f74199e..2da7acf06 100755
--- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/ReadBackedPhasingWalker.java
+++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/ReadBackedPhasingWalker.java
@@ -300,7 +300,7 @@ public class ReadBackedPhasingWalker extends RodWalker maxPhaseSites) {
logger.warn("Trying to phase sample " + samp + " at locus " + VariantContextUtils.getLocation(vc) + " within a window of " + cacheWindow + " bases yields " + sampleWindowVaList.size() + " heterozygous sites to phase:\n" + toStringVRL(sampleWindowVaList));
@@ -432,7 +432,7 @@ public class ReadBackedPhasingWalker extends RodWalker 2!");
+ throw new GATKException("LOGICAL ERROR: Only considering haplotypes of length > 2!");
byte prevBase = hap.getBase(0); // The 1st base in the haplotype
byte curBase = hap.getBase(1); // The 2nd base in the haplotype
@@ -745,7 +745,7 @@ public class ReadBackedPhasingWalker extends RodWalker {
String[] libraries = matePairSize.keySet().toArray(new String[1]);
for (String library : libraries) {
+ File file = new File(String.format("%s/%s.pairdist", OUT_DIR.getAbsolutePath(), library));
try {
Integer[] sizes = matePairSize.get(library).keySet().toArray(new Integer[1]);
if (sizes != null && sizes.length > 1) {
- PrintWriter pw = new PrintWriter(String.format("%s/%s.pairdist", OUT_DIR.getAbsolutePath(), library));
+ PrintWriter pw = new PrintWriter(file);
Arrays.sort(sizes);
pw.printf("%s\t%s%n", "insert", "frequency");
@@ -77,7 +79,7 @@ public class MatePairLibrarySize extends ReadWalker {
pw.close();
}
} catch (IOException e) {
- throw new StingException("Unable to initialize output files.");
+ throw new UserError.CouldNotCreateOutputFile(file, e);
}
}
}
diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/hybridselection/CoverageAcrossBaitsWalker.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/hybridselection/CoverageAcrossBaitsWalker.java
index 8e5aaf591..4619b33e5 100755
--- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/hybridselection/CoverageAcrossBaitsWalker.java
+++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/hybridselection/CoverageAcrossBaitsWalker.java
@@ -33,6 +33,7 @@ import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.By;
import org.broadinstitute.sting.gatk.walkers.DataSource;
import org.broadinstitute.sting.gatk.walkers.LocusWalker;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.collections.Pair;
import org.broadinstitute.sting.utils.StingException;
@@ -90,7 +91,7 @@ public class CoverageAcrossBaitsWalker extends LocusWalker {
try {
digest = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
- throw new StingException("Unable to find MD5 checksumer");
+ throw new GATKException("Unable to find MD5 checksumer");
}
out.println("Header:");
// enumerate the list of ROD's we've loaded
diff --git a/java/src/org/broadinstitute/sting/playground/utils/GenomicMap.java b/java/src/org/broadinstitute/sting/playground/utils/GenomicMap.java
index 8b2b8df08..436e0fc22 100644
--- a/java/src/org/broadinstitute/sting/playground/utils/GenomicMap.java
+++ b/java/src/org/broadinstitute/sting/playground/utils/GenomicMap.java
@@ -49,6 +49,7 @@ import net.sf.samtools.SAMRecord;
import org.broadinstitute.sting.gatk.iterators.PushbackIterator;
import org.broadinstitute.sting.utils.*;
+import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.sam.AlignmentUtils;
import org.broadinstitute.sting.utils.collections.Pair;
@@ -75,8 +76,8 @@ public class GenomicMap implements Iterable c) {
- if ( name == null ) throw new StingException("Custom contig name can not be null");
- if ( map.containsKey(name)) throw new StingException("Custom contig "+name+" already exists");
+ if ( name == null ) throw new GATKException("Custom contig name can not be null");
+ if ( map.containsKey(name)) throw new GATKException("Custom contig "+name+" already exists");
map.put(name, c);
}
@@ -102,7 +103,7 @@ public class GenomicMap implements Iterable segments = new ArrayList( coord_parts.length / 3 );
@@ -135,9 +136,9 @@ public class GenomicMap implements Iterable segments = getContigMapping(r.getReferenceName());
- if ( segments == null ) throw new StingException("Can not remap a record: unknown custom contig name "+r.getReferenceName());
+ if ( segments == null ) throw new UserError.MalformedBam(r, "Can not remap a record: unknown custom contig name "+r.getReferenceName());
// scroll the list of intervals until we find the interval that the alignment start falls into:
Pair extends Iterator, Integer> p = seekForward(segments,customStart);
@@ -277,7 +278,7 @@ public class GenomicMap implements Iterable 0 && refPos > currStop + 1 ) {
// add "panning" N's w/respect to the master ref over the region between adjacent segments
@@ -375,7 +376,7 @@ public class GenomicMap implements Iterable,Integer> seekForward(Collection segments,int position) {
- if ( position < 1 ) throw new StingException("Position "+position + " is outside of custom contig boundaries");
+ if ( position < 1 ) throw new GATKException("Position "+position + " is outside of custom contig boundaries");
PushbackIterator iter = new PushbackIterator(segments.iterator());
@@ -390,7 +391,7 @@ public class GenomicMap implements Iterable segments) {
diff --git a/java/src/org/broadinstitute/sting/playground/utils/ProcessUtils.java b/java/src/org/broadinstitute/sting/playground/utils/ProcessUtils.java
index c42330407..166d6ece7 100644
--- a/java/src/org/broadinstitute/sting/playground/utils/ProcessUtils.java
+++ b/java/src/org/broadinstitute/sting/playground/utils/ProcessUtils.java
@@ -25,6 +25,7 @@
package org.broadinstitute.sting.playground.utils;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.text.XReadLines;
import org.broadinstitute.sting.utils.StingException;
import org.apache.log4j.Logger;
@@ -60,7 +61,7 @@ public class ProcessUtils {
return result;
} catch (Exception e) {
- throw new StingException("Error running command:" + command, e);
+ throw new GATKException("Error running command:" + command, e);
}
}
}
diff --git a/java/src/org/broadinstitute/sting/playground/utils/report/AnalysisModuleScanner.java b/java/src/org/broadinstitute/sting/playground/utils/report/AnalysisModuleScanner.java
index 2d6fced05..fde4f31b3 100644
--- a/java/src/org/broadinstitute/sting/playground/utils/report/AnalysisModuleScanner.java
+++ b/java/src/org/broadinstitute/sting/playground/utils/report/AnalysisModuleScanner.java
@@ -26,6 +26,7 @@ package org.broadinstitute.sting.playground.utils.report;
import org.broadinstitute.sting.playground.utils.report.tags.Analysis;
import org.broadinstitute.sting.playground.utils.report.tags.DataPoint;
import org.broadinstitute.sting.playground.utils.report.tags.Param;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import java.lang.annotation.Annotation;
@@ -74,7 +75,7 @@ public class AnalysisModuleScanner {
/** scan the class and find all appropriate fields and tables */
public void scan() {
if (cls == null || !cls.isAnnotationPresent(Analysis.class))
- throw new StingException("The class passed in cannot be null, " + "" +
+ throw new GATKException("The class passed in cannot be null, " + "" +
"and must contain the @Analysis annotation, class " + cls + " was the input");
// get the annotation off of the class
diff --git a/java/src/org/broadinstitute/sting/playground/utils/report/ReportMarshaller.java b/java/src/org/broadinstitute/sting/playground/utils/report/ReportMarshaller.java
index de872109a..9904db5ac 100644
--- a/java/src/org/broadinstitute/sting/playground/utils/report/ReportMarshaller.java
+++ b/java/src/org/broadinstitute/sting/playground/utils/report/ReportMarshaller.java
@@ -27,6 +27,7 @@ package org.broadinstitute.sting.playground.utils.report;
import org.broadinstitute.sting.playground.utils.report.templates.ReportFormat;
import org.broadinstitute.sting.playground.utils.report.utils.ComplexDataUtils;
import org.broadinstitute.sting.playground.utils.report.utils.Node;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import java.io.*;
@@ -195,7 +196,7 @@ public class ReportMarshaller {
else
node.addAllChildren(nodes);
} catch (IllegalAccessException e) {
- throw new StingException("Unable to access field " + f);
+ throw new GATKException("Unable to access field " + f);
}
}
}
diff --git a/java/src/org/broadinstitute/sting/playground/utils/report/VE2ReportFactory.java b/java/src/org/broadinstitute/sting/playground/utils/report/VE2ReportFactory.java
index f16e37195..b72bce656 100644
--- a/java/src/org/broadinstitute/sting/playground/utils/report/VE2ReportFactory.java
+++ b/java/src/org/broadinstitute/sting/playground/utils/report/VE2ReportFactory.java
@@ -3,6 +3,7 @@ package org.broadinstitute.sting.playground.utils.report;
import org.broadinstitute.sting.playground.utils.report.templates.*;
import org.broadinstitute.sting.playground.utils.report.utils.Node;
import org.broadinstitute.sting.utils.StingException;
+import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
import java.io.*;
import java.util.List;
@@ -84,13 +85,8 @@ public class VE2ReportFactory {
public static ReportFormat createByType(Class formatType) {
try {
return ((Class extends ReportFormat>) formatType).newInstance();
- }
- catch (InstantiationException ex) {
- throw new StingException(String.format("Unable to instantiate %s", formatType), ex);
- }
- catch (IllegalAccessException ex) {
- throw new StingException(String.format("Unable to access %s", formatType), ex);
+ } catch (Exception e) {
+ throw new DynamicClassResolutionException(formatType, e);
}
}
-
}
diff --git a/java/src/org/broadinstitute/sting/playground/utils/report/templates/GrepFormat.java b/java/src/org/broadinstitute/sting/playground/utils/report/templates/GrepFormat.java
index a85f8fcde..966cc1087 100644
--- a/java/src/org/broadinstitute/sting/playground/utils/report/templates/GrepFormat.java
+++ b/java/src/org/broadinstitute/sting/playground/utils/report/templates/GrepFormat.java
@@ -2,6 +2,7 @@ package org.broadinstitute.sting.playground.utils.report.templates;
import org.broadinstitute.sting.playground.utils.report.utils.Node;
import org.broadinstitute.sting.utils.StingException;
+import org.broadinstitute.sting.utils.exceptions.UserError;
import java.io.File;
import java.io.FileNotFoundException;
@@ -31,7 +32,7 @@ public class GrepFormat implements ReportFormat {
try {
stream = new PrintWriter(baseFile);
} catch (FileNotFoundException e) {
- throw new StingException("Unable to write to file " + baseFile, e);
+ throw new UserError.CouldNotCreateOutputFile(baseFile, e);
}
privateWrite(baseNode);
}
diff --git a/java/src/org/broadinstitute/sting/playground/utils/report/templates/TableBasedFormat.java b/java/src/org/broadinstitute/sting/playground/utils/report/templates/TableBasedFormat.java
index c94c5a706..e1922eae7 100644
--- a/java/src/org/broadinstitute/sting/playground/utils/report/templates/TableBasedFormat.java
+++ b/java/src/org/broadinstitute/sting/playground/utils/report/templates/TableBasedFormat.java
@@ -2,6 +2,7 @@ package org.broadinstitute.sting.playground.utils.report.templates;
import org.broadinstitute.sting.playground.utils.report.utils.Node;
import org.broadinstitute.sting.utils.StingException;
+import org.broadinstitute.sting.utils.exceptions.UserError;
import java.io.*;
import java.util.*;
@@ -36,7 +37,7 @@ public abstract class TableBasedFormat implements ReportFormat {
* @param baseNode the root node
*/
public void write(Writer writeLocation, Node baseNode) {
- if (splitFilesByAnalysis()) throw new StingException("Unable to write output report, we require a file input for multi-file formats");
+ if (splitFilesByAnalysis()) throw new UserError.CommandLineError("Unable to write output report, we require a file input for multi-file formats");
// if there is only a single output file, create it
stream = new PrintWriter(writeLocation);
traverseAnalysisNodes(baseNode);
@@ -222,12 +223,13 @@ public abstract class TableBasedFormat implements ReportFormat {
*/
public void newStream(String analysisOrTableName) {
String name = analysisOrTableName.replaceAll("\\s+","_").replaceAll("\\/","_slash_");
+ File file = new File(this.baseLocation + "." + name + this.extension());
if (stream == null || splitFilesByAnalysis()) {
if (stream != null) stream.close();
try {
- stream = new PrintWriter(this.baseLocation + "." + name + this.extension());
+ stream = new PrintWriter(file);
} catch (FileNotFoundException e) {
- throw new StingException("Unable to create Report file at location " + this.baseLocation + "." + name + this.extension(), e);
+ throw new UserError.CouldNotCreateOutputFile(file, e);
}
}
}
diff --git a/java/src/org/broadinstitute/sting/playground/utils/report/templates/TextTable.java b/java/src/org/broadinstitute/sting/playground/utils/report/templates/TextTable.java
index 72b8250ba..b03e41b86 100644
--- a/java/src/org/broadinstitute/sting/playground/utils/report/templates/TextTable.java
+++ b/java/src/org/broadinstitute/sting/playground/utils/report/templates/TextTable.java
@@ -1,6 +1,7 @@
package org.broadinstitute.sting.playground.utils.report.templates;
import org.broadinstitute.sting.utils.StingException;
+import org.broadinstitute.sting.utils.exceptions.UserError;
import java.io.IOException;
import java.io.Writer;
@@ -103,7 +104,7 @@ class TextTable {
try {
writer.append("\n");
} catch (IOException e) {
- throw new StingException("Unable to write to the Writer");
+ throw new UserError.CouldNotCreateOutputFile(writer.toString(), "Unable to write to the Writer", e);
}
}
@@ -128,7 +129,7 @@ class TextTable {
if (y != rows.size() - 1)
writer.append(seperator);
} catch (IOException e) {
- throw new StingException("Unable to write to the Writer");
+ throw new UserError.CouldNotCreateOutputFile(writer.toString(), "Unable to write to the Writer", e);
}
}
diff --git a/java/src/org/broadinstitute/sting/queue/extensions/gatk/GATKExtensionsGenerator.java b/java/src/org/broadinstitute/sting/queue/extensions/gatk/GATKExtensionsGenerator.java
index 553156e47..6adb4d371 100644
--- a/java/src/org/broadinstitute/sting/queue/extensions/gatk/GATKExtensionsGenerator.java
+++ b/java/src/org/broadinstitute/sting/queue/extensions/gatk/GATKExtensionsGenerator.java
@@ -39,6 +39,7 @@ import org.broadinstitute.sting.gatk.io.stubs.SAMFileReaderArgumentTypeDescripto
import org.broadinstitute.sting.gatk.io.stubs.SAMFileWriterArgumentTypeDescriptor;
import org.broadinstitute.sting.gatk.refdata.tracks.RMDTrackManager;
import org.broadinstitute.sting.gatk.walkers.Walker;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import java.io.File;
@@ -94,7 +95,7 @@ public class GATKExtensionsGenerator extends CommandLineProgram {
protected int execute() {
try {
if (!outputDirectory.isDirectory() && !outputDirectory.mkdirs())
- throw new StingException("Unable to create output directory: " + outputDirectory);
+ throw new GATKException("Unable to create output directory: " + outputDirectory);
for (Class extends CommandLineProgram> clp: clpManager.getValues()) {
diff --git a/java/src/org/broadinstitute/sting/utils/CardinalityCounter.java b/java/src/org/broadinstitute/sting/utils/CardinalityCounter.java
index 13ba4699f..d0bdca3d0 100644
--- a/java/src/org/broadinstitute/sting/utils/CardinalityCounter.java
+++ b/java/src/org/broadinstitute/sting/utils/CardinalityCounter.java
@@ -35,7 +35,7 @@ public class CardinalityCounter implements Iterator, Iterable {
public int[] next() {
if (!hasNext())
- throw new StingException("CANNOT iterate past end!");
+ throw new GATKException("CANNOT iterate past end!");
// Copy the assignment to be returned:
int[] nextList = new int[valList.length];
diff --git a/java/src/org/broadinstitute/sting/utils/GenomeLoc.java b/java/src/org/broadinstitute/sting/utils/GenomeLoc.java
index dc1988fd1..caa396bf0 100644
--- a/java/src/org/broadinstitute/sting/utils/GenomeLoc.java
+++ b/java/src/org/broadinstitute/sting/utils/GenomeLoc.java
@@ -164,7 +164,7 @@ public class GenomeLoc implements Comparable, Cloneable, Serializable
public GenomeLoc merge( GenomeLoc that ) throws GATKException {
if (!(this.contiguousP(that))) {
- throw new StingException("The two genome loc's need to be contigous");
+ throw new GATKException("The two genome loc's need to be contigous");
}
return new GenomeLoc(getContig(), this.contigIndex,
@@ -174,7 +174,7 @@ public class GenomeLoc implements Comparable, Cloneable, Serializable
public GenomeLoc intersect( GenomeLoc that ) throws GATKException {
if (!(this.overlapsP(that))) {
- throw new StingException("GenomeLoc::intersect(): The two genome loc's need to overlap");
+ throw new GATKException("GenomeLoc::intersect(): The two genome loc's need to overlap");
}
return new GenomeLoc(getContig(), this.contigIndex,
diff --git a/java/src/org/broadinstitute/sting/utils/GenomeLocParser.java b/java/src/org/broadinstitute/sting/utils/GenomeLocParser.java
index f23feef96..f385decec 100644
--- a/java/src/org/broadinstitute/sting/utils/GenomeLocParser.java
+++ b/java/src/org/broadinstitute/sting/utils/GenomeLocParser.java
@@ -193,13 +193,13 @@ public class GenomeLocParser {
stop = parsePosition(str.substring(dashIndex + 1));
}
} catch(Exception e) {
- throw new StingException("Failed to parse Genome Location string: " + str, e);
+ throw new UserError("Failed to parse Genome Location string: " + str, e);
}
}
// is the contig valid?
if (!isContigValid(contig))
- throw new StingException("Contig '" + contig + "' does not match any contig in the GATK sequence dictionary derived from the reference; are you sure you are using the correct reference fasta file?");
+ throw new UserError("Contig '" + contig + "' does not match any contig in the GATK sequence dictionary derived from the reference; are you sure you are using the correct reference fasta file?");
if (stop == Integer.MAX_VALUE && hasKnownContigOrdering())
// lookup the actually stop position!
@@ -319,13 +319,7 @@ public class GenomeLocParser {
*/
public static List intervalFileToList(final String file_name) {
// try to open file
- File inputFile = null;
- try {
- inputFile = new File(file_name);
- }
- catch (Exception e) {
- throw new StingException("Could not open file", e);
- }
+ File inputFile = new File(file_name);
// check if file is empty
if (inputFile.exists() && inputFile.length() < 1) {
@@ -377,7 +371,7 @@ public class GenomeLocParser {
return ret.isEmpty() ? null : ret;
}
catch (IOException e2) {
- throw new StingException("An I/O error occurred while reading the interval file.", e);
+ throw new UserError.CouldNotReadInputFile(new File(file_name), e);
}
}
}
@@ -433,10 +427,10 @@ public class GenomeLocParser {
public static GenomeLoc createGenomeLoc(int contigIndex, final long start, final long stop) {
checkSetup();
if (start < 0) {
- throw new StingException("Bad start position " + start);
+ throw new GATKException("Bad start position " + start);
}
if (stop < -1) {
- throw new StingException("Bad stop position " + stop);
+ throw new GATKException("Bad stop position " + stop);
} // a negative -1 indicates it's not a meaningful end position
@@ -503,16 +497,16 @@ public class GenomeLocParser {
*/
private static GenomeLoc exceptionOnInvalidGenomeLoc(GenomeLoc toReturn) {
if (toReturn.getStart() < 0) {
- throw new StingException("Parameters to GenomeLocParser are incorrect: the start position is less than 0");
+ throw new GATKException("Parameters to GenomeLocParser are incorrect: the start position is less than 0");
}
if ((toReturn.getStop() != -1) && (toReturn.getStop() < 0)) {
- throw new StingException("Parameters to GenomeLocParser are incorrect: the stop position is less than 0");
+ throw new GATKException("Parameters to GenomeLocParser are incorrect: the stop position is less than 0");
}
if (toReturn.getContigIndex() < 0) {
- throw new StingException("Parameters to GenomeLocParser are incorrect: the contig index is less than 0");
+ throw new GATKException("Parameters to GenomeLocParser are incorrect: the contig index is less than 0");
}
if (toReturn.getContigIndex() >= contigInfo.getSequences().size()) {
- throw new StingException("Parameters to GenomeLocParser are incorrect: the contig index is greater then the stored sequence count");
+ throw new GATKException("Parameters to GenomeLocParser are incorrect: the contig index is greater then the stored sequence count");
}
return toReturn;
@@ -533,11 +527,11 @@ public class GenomeLocParser {
private static void exceptionOnInvalidGenomeLocBounds(GenomeLoc locus) {
int contigSize = contigInfo.getSequence(locus.getContigIndex()).getSequenceLength();
if(locus.getStart() > contigSize)
- throw new StingException(String.format("GenomeLoc is invalid: locus start %d is after the end of contig %s",locus.getStart(),locus.getContig()));
+ throw new GATKException(String.format("GenomeLoc is invalid: locus start %d is after the end of contig %s",locus.getStart(),locus.getContig()));
if(locus.getStop() > contigSize)
- throw new StingException(String.format("GenomeLoc is invalid: locus stop %d is after the end of contig %s",locus.getStop(),locus.getContig()));
+ throw new GATKException(String.format("GenomeLoc is invalid: locus stop %d is after the end of contig %s",locus.getStop(),locus.getContig()));
if (locus.getStart() > locus.getStop()) {
- throw new StingException("Parameters to GenomeLocParser are incorrect: the start position is greater than the end position");
+ throw new GATKException("Parameters to GenomeLocParser are incorrect: the start position is greater than the end position");
}
}
@@ -629,7 +623,7 @@ public class GenomeLocParser {
int index = -1;
if ((index = contigInfo.getSequenceIndex(contig)) < 0) {
- throw new StingException("Contig name ( " + contig + " ) not in the set sequence dictionary.");
+ throw new GATKException("Contig name ( " + contig + " ) not in the set sequence dictionary.");
}
return exceptionOnInvalidGenomeLoc(new GenomeLoc(contig, index, loc.start, loc.getStop()));
}
@@ -642,7 +636,7 @@ public class GenomeLocParser {
public static GenomeLoc setContigIndex(GenomeLoc loc, int contig) {
checkSetup();
if ((contig >= GenomeLocParser.contigInfo.getSequences().size()) || (contig < 0)) {
- throw new StingException("Contig index ( " + contig + " ) is not in the sequence dictionary set.");
+ throw new GATKException("Contig index ( " + contig + " ) is not in the sequence dictionary set.");
}
return exceptionOnInvalidGenomeLoc(new GenomeLoc(GenomeLocParser.contigInfo.getSequence(contig).getSequenceName(), contig, loc.start, loc.getStop()));
}
@@ -715,7 +709,7 @@ public class GenomeLocParser {
/** check to make sure that we've setup the contig information */
private static void checkSetup() {
if (contigInfo == null) {
- throw new StingException("The GenomeLocParser hasn't been setup with a contig sequence yet");
+ throw new GATKException("The GenomeLocParser hasn't been setup with a contig sequence yet");
}
}
diff --git a/java/src/org/broadinstitute/sting/utils/GenomeLocSortedSet.java b/java/src/org/broadinstitute/sting/utils/GenomeLocSortedSet.java
index e34be715d..5c4c4bb1c 100755
--- a/java/src/org/broadinstitute/sting/utils/GenomeLocSortedSet.java
+++ b/java/src/org/broadinstitute/sting/utils/GenomeLocSortedSet.java
@@ -109,7 +109,7 @@ public class GenomeLocSortedSet extends AbstractSet {
} else {
int loc = Collections.binarySearch(mArray,e);
if (loc >= 0) {
- throw new StingException("Genome Loc Sorted Set already contains the GenomicLoc " + e.toString());
+ throw new GATKException("Genome Loc Sorted Set already contains the GenomicLoc " + e.toString());
} else {
mArray.add((loc+1) * -1,e);
return true;
@@ -193,7 +193,7 @@ public class GenomeLocSortedSet extends AbstractSet {
} else if ( e.getStop() < p.getStart() ) {
toExclude.pop(); // p starts after e stops, e is done
} else {
- throw new StingException("BUG: unexpected condition: p=" + p + ", e=" + e);
+ throw new GATKException("BUG: unexpected condition: p=" + p + ", e=" + e);
}
if ( i++ % 10000 == 0 )
diff --git a/java/src/org/broadinstitute/sting/utils/HeapSizeMonitor.java b/java/src/org/broadinstitute/sting/utils/HeapSizeMonitor.java
index 07211d67a..de0c27886 100644
--- a/java/src/org/broadinstitute/sting/utils/HeapSizeMonitor.java
+++ b/java/src/org/broadinstitute/sting/utils/HeapSizeMonitor.java
@@ -40,7 +40,7 @@ public class HeapSizeMonitor {
monitorThread.join();
}
catch(InterruptedException ex) {
- throw new StingException("Unable to connect to monitor thread");
+ throw new GATKException("Unable to connect to monitor thread");
}
monitorThread = null;
}
@@ -72,7 +72,7 @@ public class HeapSizeMonitor {
Thread.sleep(monitorFrequencyMillis);
}
catch(InterruptedException ex) {
- throw new StingException("Unable to continue monitoring heap consumption",ex);
+ throw new GATKException("Unable to continue monitoring heap consumption",ex);
}
}
}
diff --git a/java/src/org/broadinstitute/sting/utils/MalformedGenomeLocException.java b/java/src/org/broadinstitute/sting/utils/MalformedGenomeLocException.java
index 91c74f905..d79359633 100644
--- a/java/src/org/broadinstitute/sting/utils/MalformedGenomeLocException.java
+++ b/java/src/org/broadinstitute/sting/utils/MalformedGenomeLocException.java
@@ -17,7 +17,7 @@ package org.broadinstitute.sting.utils;
* bad sequence id out of bounds, etc.
*/
-public class MalformedGenomeLocException extends StingException {
+public class MalformedGenomeLocException extends GATKException {
/**
* Create a new MalformedGenomeLocException with the given message. Does not preserve the existing stack trace.
* @param message The message.
diff --git a/java/src/org/broadinstitute/sting/utils/PathUtils.java b/java/src/org/broadinstitute/sting/utils/PathUtils.java
index d4cd26c7f..c543a29d5 100755
--- a/java/src/org/broadinstitute/sting/utils/PathUtils.java
+++ b/java/src/org/broadinstitute/sting/utils/PathUtils.java
@@ -112,7 +112,7 @@ public class PathUtils {
}
if (dir.listFiles() == null) {
- throw new StingException("The volume '" + dir.getAbsolutePath() + "' could not be accessed.");
+ throw new GATKException("The volume '" + dir.getAbsolutePath() + "' could not be accessed.");
}
}
diff --git a/java/src/org/broadinstitute/sting/utils/ReservoirDownsampler.java b/java/src/org/broadinstitute/sting/utils/ReservoirDownsampler.java
index 8dd2085bb..8ced0508c 100644
--- a/java/src/org/broadinstitute/sting/utils/ReservoirDownsampler.java
+++ b/java/src/org/broadinstitute/sting/utils/ReservoirDownsampler.java
@@ -35,7 +35,7 @@ public class ReservoirDownsampler {
*/
public ReservoirDownsampler(final int maxElements) {
if(maxElements < 0)
- throw new StingException("Unable to work with an negative size collection of elements");
+ throw new GATKException("Unable to work with an negative size collection of elements");
this.reservoir = new ArrayList(maxElements);
this.maxElements = maxElements;
}
diff --git a/java/src/org/broadinstitute/sting/utils/WilcoxonRankSum.java b/java/src/org/broadinstitute/sting/utils/WilcoxonRankSum.java
index 314fec7e8..a88eaee09 100755
--- a/java/src/org/broadinstitute/sting/utils/WilcoxonRankSum.java
+++ b/java/src/org/broadinstitute/sting/utils/WilcoxonRankSum.java
@@ -185,7 +185,7 @@ public class WilcoxonRankSum {
U = n1 < n2 ? U1 : U2;
break;
default:
- throw new StingException("Unexpected WILCOXON H0: " + h0);
+ throw new GATKException("Unexpected WILCOXON H0: " + h0);
}
// data is nA nB then
@@ -232,7 +232,7 @@ public class WilcoxonRankSum {
pvalue = NORMAL.cdf(z);
break;
default:
- throw new StingException("Unexpected WILCOXON H0: " + h0);
+ throw new GATKException("Unexpected WILCOXON H0: " + h0);
}
return pvalue;
diff --git a/java/src/org/broadinstitute/sting/utils/bed/BedParser.java b/java/src/org/broadinstitute/sting/utils/bed/BedParser.java
index 97683242a..3c599b0fe 100644
--- a/java/src/org/broadinstitute/sting/utils/bed/BedParser.java
+++ b/java/src/org/broadinstitute/sting/utils/bed/BedParser.java
@@ -1,5 +1,6 @@
package org.broadinstitute.sting.utils.bed;
+import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.interval.IntervalMergingRule;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.GenomeLoc;
@@ -33,7 +34,7 @@ public class BedParser {
try {
mIn = new BufferedReader(new FileReader(fl));
} catch (FileNotFoundException e) {
- throw new StingException("Unable to open the bed file = " + fl);
+ throw new UserError.CouldNotReadInputFile(fl, e);
}
mLocations = parseLocations();
}
@@ -61,7 +62,7 @@ public class BedParser {
locArray.add(parseLocation(line));
}
} catch (IOException e) {
- throw new StingException("Unable to parse line in BED file.");
+ throw new UserError.MalformedFile("Unable to parse line in BED file.");
}
return locArray;
}
@@ -82,7 +83,7 @@ public class BedParser {
start = Integer.valueOf(parts[1]) + TO_ONE_BASED_ADDITION;
stop = Integer.valueOf(parts[2]); // the ending point is an open interval
} catch (Exception e) {
- throw new StingException("Unable to process bed file line = " + line);
+ throw new UserError.MalformedFile("Unable to process bed file line = " + line, e);
}
// we currently drop the rest of the bed record, which can contain names, scores, etc
diff --git a/java/src/org/broadinstitute/sting/utils/classloader/JVMUtils.java b/java/src/org/broadinstitute/sting/utils/classloader/JVMUtils.java
index fde50238f..62dc3f237 100755
--- a/java/src/org/broadinstitute/sting/utils/classloader/JVMUtils.java
+++ b/java/src/org/broadinstitute/sting/utils/classloader/JVMUtils.java
@@ -25,6 +25,7 @@
package org.broadinstitute.sting.utils.classloader;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import java.lang.reflect.Modifier;
@@ -127,7 +128,7 @@ public class JVMUtils {
field.set(instance, value);
}
catch( IllegalAccessException ex ) {
- throw new StingException(String.format("Could not set %s in instance %s to %s",field.getName(),instance.getClass().getName(),value.toString()));
+ throw new GATKException(String.format("Could not set %s in instance %s to %s",field.getName(),instance.getClass().getName(),value.toString()));
}
}
@@ -143,7 +144,7 @@ public class JVMUtils {
return field.get(instance);
}
catch( IllegalAccessException ex ) {
- throw new StingException(String.format("Could not retrieve %s in instance %s",field.getName(),instance.getClass().getName()));
+ throw new GATKException(String.format("Could not retrieve %s in instance %s",field.getName(),instance.getClass().getName()));
}
}
diff --git a/java/src/org/broadinstitute/sting/utils/classloader/PackageUtils.java b/java/src/org/broadinstitute/sting/utils/classloader/PackageUtils.java
index ce02d4f36..0997f560e 100755
--- a/java/src/org/broadinstitute/sting/utils/classloader/PackageUtils.java
+++ b/java/src/org/broadinstitute/sting/utils/classloader/PackageUtils.java
@@ -28,7 +28,9 @@ package org.broadinstitute.sting.utils.classloader;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
+import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
import org.reflections.Reflections;
import org.reflections.scanners.SubTypesScanner;
import org.reflections.util.ClasspathHelper;
@@ -95,10 +97,8 @@ public class PackageUtils {
public static T getSimpleInstance(Class c) {
try {
return c.newInstance();
- } catch (InstantiationException e) {
- throw new StingException(String.format("Cannot instantiate class '%s': must be concrete class", c.getSimpleName()));
- } catch (IllegalAccessException e) {
- throw new StingException(String.format("Cannot instantiate class '%s': must have no-arg constructor", c.getSimpleName()));
+ } catch (Exception e) {
+ throw new DynamicClassResolutionException(c, e);
}
}
@@ -138,7 +138,7 @@ public class PackageUtils {
method.invoke(ClassLoader.getSystemClassLoader(), url);
resetReflections();
} catch (Exception e) {
- throw new StingException("Error adding url to the current classloader.", e);
+ throw new GATKException("Error adding url to the current classloader.", e);
}
}
diff --git a/java/src/org/broadinstitute/sting/utils/classloader/PluginManager.java b/java/src/org/broadinstitute/sting/utils/classloader/PluginManager.java
index 86b431b2d..69bc5fd8d 100644
--- a/java/src/org/broadinstitute/sting/utils/classloader/PluginManager.java
+++ b/java/src/org/broadinstitute/sting/utils/classloader/PluginManager.java
@@ -25,8 +25,10 @@
package org.broadinstitute.sting.utils.classloader;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.classloader.PackageUtils;
import org.broadinstitute.sting.utils.StingException;
+import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
import java.util.HashMap;
import java.util.List;
@@ -84,17 +86,13 @@ public abstract class PluginManager {
* @return The plugin object if found; null otherwise.
*/
public PluginType createByName(String pluginName) {
+ Class extends PluginType> plugin = pluginsByName.get(pluginName);
try {
- Class extends PluginType> plugin = pluginsByName.get(pluginName);
if( plugin == null )
- throw new StingException(String.format("Could not find %s with name: %s", pluginCategory,pluginName));
+ throw new GATKException(String.format("Could not find %s with name: %s", pluginCategory,pluginName));
return plugin.newInstance();
- }
- catch( InstantiationException ex ) {
- throw new StingException(String.format("Unable to instantiate %s %s",pluginCategory,pluginName), ex);
- }
- catch( IllegalAccessException ex ) {
- throw new StingException(String.format("Unable to access %s %s",pluginCategory,pluginName), ex);
+ } catch (Exception e) {
+ throw new DynamicClassResolutionException(plugin, e);
}
}
@@ -107,12 +105,8 @@ public abstract class PluginManager {
public PluginType createByType(Class pluginType) {
try {
return ((Class extends PluginType>) pluginType).newInstance();
- }
- catch( InstantiationException ex ) {
- throw new StingException(String.format("Unable to instantiate %s",pluginCategory), ex);
- }
- catch( IllegalAccessException ex ) {
- throw new StingException(String.format("Unable to access %s",pluginCategory), ex);
+ } catch (Exception e) {
+ throw new DynamicClassResolutionException(pluginType, e);
}
}
diff --git a/java/src/org/broadinstitute/sting/utils/collections/CircularArray.java b/java/src/org/broadinstitute/sting/utils/collections/CircularArray.java
index 11d540c49..6272d1873 100644
--- a/java/src/org/broadinstitute/sting/utils/collections/CircularArray.java
+++ b/java/src/org/broadinstitute/sting/utils/collections/CircularArray.java
@@ -25,6 +25,7 @@
package org.broadinstitute.sting.utils.collections;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
@@ -69,7 +70,7 @@ public class CircularArray {
/** Creates an array of fixed length */
public CircularArray(int length) {
- if ( length <= 0 ) throw new StingException("CircularArray length must be positive. Passed: "+length);
+ if ( length <= 0 ) throw new GATKException("CircularArray length must be positive. Passed: "+length);
data = new Object[length];
offset = 0;
}
@@ -150,7 +151,7 @@ public class CircularArray {
/** Creates an array of fixed length */
public Int(int length) {
- if ( length <= 0 ) throw new StingException("CircularArray length must be positive. Passed: "+length);
+ if ( length <= 0 ) throw new GATKException("CircularArray length must be positive. Passed: "+length);
data = new int[length]; // automaticaly initialized to zeros
offset = 0;
}
diff --git a/java/src/org/broadinstitute/sting/utils/collections/MergingIterator.java b/java/src/org/broadinstitute/sting/utils/collections/MergingIterator.java
index 1ca4593ed..e2b57b94b 100644
--- a/java/src/org/broadinstitute/sting/utils/collections/MergingIterator.java
+++ b/java/src/org/broadinstitute/sting/utils/collections/MergingIterator.java
@@ -27,6 +27,7 @@ package org.broadinstitute.sting.utils.collections;
import org.broadinstitute.sting.gatk.refdata.utils.LocationAwareSeekableRODIterator;
import org.broadinstitute.sting.gatk.refdata.utils.RODRecordList;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.StingException;
@@ -42,10 +43,10 @@ public class MergingIterator implements Iterator, Iterable it) {
if ( it instanceof LocationAwareSeekableRODIterator) {
this.it = (LocationAwareSeekableRODIterator)it;
- if ( ! it.hasNext() ) throw new StingException("Iterator is empty");
+ if ( ! it.hasNext() ) throw new GATKException("Iterator is empty");
update();
} else {
- throw new StingException("Iterator passed to MergingIterator is not LocationAwareSeekableRODIterator");
+ throw new GATKException("Iterator passed to MergingIterator is not LocationAwareSeekableRODIterator");
}
}
diff --git a/java/src/org/broadinstitute/sting/utils/duplicates/DupUtils.java b/java/src/org/broadinstitute/sting/utils/duplicates/DupUtils.java
index 85e131c1c..4403597b5 100644
--- a/java/src/org/broadinstitute/sting/utils/duplicates/DupUtils.java
+++ b/java/src/org/broadinstitute/sting/utils/duplicates/DupUtils.java
@@ -40,7 +40,7 @@ public class DupUtils {
try {
return (SAMRecord)read.clone();
} catch ( CloneNotSupportedException e ) {
- throw new StingException("Unexpected Clone failure!");
+ throw new GATKException("Unexpected Clone failure!");
}
}
diff --git a/java/src/org/broadinstitute/sting/utils/exceptions/DynamicClassResolutionException.java b/java/src/org/broadinstitute/sting/utils/exceptions/DynamicClassResolutionException.java
new file mode 100755
index 000000000..f973c00b0
--- /dev/null
+++ b/java/src/org/broadinstitute/sting/utils/exceptions/DynamicClassResolutionException.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2010, The Broad Institute
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+package org.broadinstitute.sting.utils.exceptions;
+
+import net.sf.samtools.SAMFileHeader;
+import net.sf.samtools.SAMRecord;
+import net.sf.samtools.SAMSequenceDictionary;
+import org.broadinstitute.sting.utils.GATKException;
+import org.broadinstitute.sting.utils.StingException;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * Class for handling common failures of dynamic class resolution
+ *
+ * User: depristo
+ * Date: Sep 3, 2010
+ * Time: 2:24:09 PM
+ */
+public class DynamicClassResolutionException extends UserError {
+ public DynamicClassResolutionException(Class c, Exception ex) {
+ super(String.format("Could not create module %s because %s caused by exception %s",
+ c.getSimpleName(), moreInfo(ex), ex.getMessage()));
+ }
+
+ private static String moreInfo(Exception ex) {
+ try {
+ throw ex;
+ } catch (InstantiationException e) {
+ return "BUG: cannot instantiate class: must be concrete class";
+ } catch (NoSuchMethodException e) {
+ return "BUG: Cannot find expected constructor for class";
+ } catch (IllegalAccessException e) {
+ return "Cannot instantiate class (Illegal Access)";
+ } catch (InvocationTargetException e) {
+ return "Cannot instantiate class (Invocation failure)";
+ } catch ( Exception e ) {
+ return "A general exception occurred";
+ }
+ }
+}
diff --git a/java/src/org/broadinstitute/sting/utils/exceptions/UserError.java b/java/src/org/broadinstitute/sting/utils/exceptions/UserError.java
index 5679c9c2b..e957a1d84 100644
--- a/java/src/org/broadinstitute/sting/utils/exceptions/UserError.java
+++ b/java/src/org/broadinstitute/sting/utils/exceptions/UserError.java
@@ -27,9 +27,11 @@ package org.broadinstitute.sting.utils.exceptions;
import net.sf.samtools.SAMFileHeader;
import net.sf.samtools.SAMRecord;
import net.sf.samtools.SAMSequenceDictionary;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import java.io.File;
+import java.lang.reflect.InvocationTargetException;
/**
* Represents the common user errors detected by Sting / GATK
@@ -40,7 +42,7 @@ import java.io.File;
* Date: Sep 3, 2010
* Time: 2:24:09 PM
*/
-public class UserError extends StingException {
+public class UserError extends GATKException {
public UserError(String msg) { super(msg); }
public UserError(String msg, Throwable e) { super(msg, e); }
private UserError(Throwable e) { super("", e); } // cannot be called, private access
@@ -51,6 +53,12 @@ public class UserError extends StingException {
}
}
+ public static class BadInput extends UserError {
+ public BadInput(String message) {
+ super(String.format("Bad input: %s", message));
+ }
+ }
+
// todo -- fix up exception cause passing
public static class MissingArgument extends CommandLineError {
public MissingArgument(String arg, String message) {
@@ -156,7 +164,11 @@ public class UserError extends StingException {
public MalformedFile(File f, String message, Exception e) {
super(String.format("File %s is malformed: %s caused by %s", f.getAbsolutePath(), message, e.getMessage()));
}
- }
+
+ public MalformedFile(String name, String message, Exception e) {
+ super(String.format("File associated with name %s is malformed: %s caused by %s", name, message, e.getMessage()));
+ }
+ }
public static class CannotExecuteRScript extends UserError {
public CannotExecuteRScript(String message, Exception e) {
@@ -183,5 +195,4 @@ public class UserError extends StingException {
super(String.format("Walker %s is not available: %s", walkerName, message));
}
}
-
}
diff --git a/java/src/org/broadinstitute/sting/utils/fasta/ArtificialFastaUtils.java b/java/src/org/broadinstitute/sting/utils/fasta/ArtificialFastaUtils.java
index c99723277..dd340a61b 100644
--- a/java/src/org/broadinstitute/sting/utils/fasta/ArtificialFastaUtils.java
+++ b/java/src/org/broadinstitute/sting/utils/fasta/ArtificialFastaUtils.java
@@ -1,5 +1,6 @@
package org.broadinstitute.sting.utils.fasta;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import java.io.FileNotFoundException;
@@ -34,7 +35,7 @@ public class ArtificialFastaUtils {
try {
s = new PrintStream(new FileOutputStream(fileName));
} catch (FileNotFoundException e) {
- throw new StingException("Filename " + fileName + " passed to the ArtificialFastaUtils generated a FileNotFound exception", e);
+ throw new GATKException("Filename " + fileName + " passed to the ArtificialFastaUtils generated a FileNotFound exception", e);
}
generateFakeFasta(contigNames, contigSizes, pattern, s);
}
@@ -58,7 +59,7 @@ public class ArtificialFastaUtils {
*/
private static void generateFakeFasta(List contigNames, List contigSizes, BASE_PATTERN pattern, PrintStream s) {
if (contigNames.size() != contigSizes.size()) {
- throw new StingException("ArtificialContig name and size arrays are not equal sizes");
+ throw new GATKException("ArtificialContig name and size arrays are not equal sizes");
}
for (int x = 0; x < contigNames.size(); x++) {
ArtificialContig tig = new ArtificialContig(contigNames.get(x), contigSizes.get(x), pattern);
@@ -122,7 +123,7 @@ class ArtificialContig {
case ALL_G:
return "G";
default:
- throw new StingException("Unknown base pattern");
+ throw new GATKException("Unknown base pattern");
}
}
diff --git a/java/src/org/broadinstitute/sting/utils/fastq/FastqReader.java b/java/src/org/broadinstitute/sting/utils/fastq/FastqReader.java
index 2dabbdbe8..876a08aee 100755
--- a/java/src/org/broadinstitute/sting/utils/fastq/FastqReader.java
+++ b/java/src/org/broadinstitute/sting/utils/fastq/FastqReader.java
@@ -1,6 +1,7 @@
package org.broadinstitute.sting.utils.fastq;
import org.broadinstitute.sting.utils.StingException;
+import org.broadinstitute.sting.utils.exceptions.UserError;
import java.util.Iterator;
import java.util.zip.GZIPInputStream;
@@ -23,7 +24,7 @@ public class FastqReader implements Iterator, Iterable
nextRecord = readNextRecord();
} catch (IOException e) {
- throw new StingException(String.format("Error opening '%s'", fastqFile.getAbsolutePath()));
+ throw new UserError.CouldNotReadInputFile(file, String.format("Error opening '%s'", fastqFile.getAbsolutePath()));
}
}
@@ -36,7 +37,7 @@ public class FastqReader implements Iterator, Iterable
return new FastqRecord(seqHeader, seqLine, qualHeader, qualLine);
} catch (IOException e) {
- throw new StingException(String.format("Error reading '%s'", fastqFile.getAbsolutePath()));
+ throw new UserError.CouldNotReadInputFile(fastqFile, e);
}
}
@@ -52,7 +53,7 @@ public class FastqReader implements Iterator, Iterable
nextRecord = null;
}
} catch (IOException e) {
- throw new StingException("IO problem");
+ throw new UserError.CouldNotReadInputFile(fastqFile, e);
}
return rec;
@@ -66,7 +67,7 @@ public class FastqReader implements Iterator, Iterable
try {
in.close();
} catch (IOException e) {
-
+ throw new UserError.CouldNotReadInputFile(fastqFile, e);
}
}
}
diff --git a/java/src/org/broadinstitute/sting/utils/file/FSLockWithShared.java b/java/src/org/broadinstitute/sting/utils/file/FSLockWithShared.java
index 91e4a78c1..851c2c714 100644
--- a/java/src/org/broadinstitute/sting/utils/file/FSLockWithShared.java
+++ b/java/src/org/broadinstitute/sting/utils/file/FSLockWithShared.java
@@ -1,6 +1,7 @@
package org.broadinstitute.sting.utils.file;
import org.apache.log4j.Logger;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import java.io.File;
@@ -143,7 +144,7 @@ public class FSLockWithShared {
channel.close();
}
catch (Exception e) {
- throw new StingException("An error occurred while unlocking file", e);
+ throw new GATKException("An error occurred while unlocking file", e);
}
}
}
diff --git a/java/src/org/broadinstitute/sting/utils/genotype/LikelihoodObject.java b/java/src/org/broadinstitute/sting/utils/genotype/LikelihoodObject.java
index abe910b41..7a5c51b61 100755
--- a/java/src/org/broadinstitute/sting/utils/genotype/LikelihoodObject.java
+++ b/java/src/org/broadinstitute/sting/utils/genotype/LikelihoodObject.java
@@ -3,6 +3,7 @@ package org.broadinstitute.sting.utils.genotype;
import edu.mit.broad.picard.genotype.DiploidGenotype;
import edu.mit.broad.picard.genotype.geli.GenotypeLikelihoods;
import net.sf.samtools.SAMFileHeader;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import java.util.HashMap;
@@ -234,15 +235,15 @@ public class LikelihoodObject {
switch (mLikelihoodType) {
case NEGATIVE_LOG:
if (score < 0)
- throw new StingException("Likelikhood score of " + score + " is invalid, for NEGATIVE_LOG it must be greater than or equal to 0");
+ throw new GATKException("Likelikhood score of " + score + " is invalid, for NEGATIVE_LOG it must be greater than or equal to 0");
break;
case LOG:
if (score > 0)
- throw new StingException("Likelikhood score of " + score + " is invalid, for LOG it must be less than or equal to 0");
+ throw new GATKException("Likelikhood score of " + score + " is invalid, for LOG it must be less than or equal to 0");
break;
case RAW:
if (score < 0 || score > 1)
- throw new StingException("Likelikhood score of " + score + " is invalid, for RAW it must be [0,1]");
+ throw new GATKException("Likelikhood score of " + score + " is invalid, for RAW it must be [0,1]");
break;
}
}
diff --git a/java/src/org/broadinstitute/sting/utils/genotype/glf/GLFReader.java b/java/src/org/broadinstitute/sting/utils/genotype/glf/GLFReader.java
index 44239d9d2..0951afb09 100644
--- a/java/src/org/broadinstitute/sting/utils/genotype/glf/GLFReader.java
+++ b/java/src/org/broadinstitute/sting/utils/genotype/glf/GLFReader.java
@@ -3,7 +3,9 @@ package org.broadinstitute.sting.utils.genotype.glf;
import net.sf.samtools.util.BinaryCodec;
import net.sf.samtools.util.BlockCompressedInputStream;
import net.sf.samtools.util.RuntimeEOFException;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
+import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.genotype.LikelihoodObject;
import java.io.DataInputStream;
@@ -63,23 +65,28 @@ public class GLFReader implements Iterator {
// we have this variable becuase there is no eof for glf's
private int lastRecordType = -1;
+ private File myFile;
+
/**
* create a glf reader
*
* @param readFrom the file to read from
*/
public GLFReader(File readFrom) {
+ myFile = readFrom;
+
try {
inputBinaryCodec = new BinaryCodec(new DataInputStream(new BlockCompressedInputStream(readFrom)));
} catch (IOException e) {
- throw new StingException("Unable to open " + readFrom.getName(), e);
+ throw new UserError.CouldNotReadInputFile(myFile, e);
}
+
inputBinaryCodec.setInputFileName(readFrom.getName());
// first verify that it's a valid GLF
for (short s : glfMagic) {
if (inputBinaryCodec.readUByte() != s)
- throw new StingException("Verification of GLF format failed: magic string doesn't match)");
+ throw new UserError.MalformedFile(myFile, "Verification of GLF format failed: magic string doesn't match)");
}
// get the header string
@@ -170,7 +177,7 @@ public class GLFReader implements Iterator {
}
//nextRecord = null;
} else {
- throw new StingException("Unkonwn GLF record type (type = " + recordType + ")");
+ throw new UserError.MalformedFile(myFile, "Unknown GLF record type (type = " + recordType + ")");
}
if (nextRecord != null) currentLocation = nextRecord.getPosition();
return ret;
@@ -219,7 +226,7 @@ public class GLFReader implements Iterator {
}
public void remove() {
- throw new StingException("GLFReader doesn't support remove()");
+ throw new GATKException("GLFReader doesn't support remove()");
}
public void close() {
diff --git a/java/src/org/broadinstitute/sting/utils/genotype/glf/GLFRecord.java b/java/src/org/broadinstitute/sting/utils/genotype/glf/GLFRecord.java
index a460d897e..bc289536d 100755
--- a/java/src/org/broadinstitute/sting/utils/genotype/glf/GLFRecord.java
+++ b/java/src/org/broadinstitute/sting/utils/genotype/glf/GLFRecord.java
@@ -1,6 +1,7 @@
package org.broadinstitute.sting.utils.genotype.glf;
import net.sf.samtools.util.BinaryCodec;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
@@ -251,7 +252,7 @@ public abstract class GLFRecord {
* @return the minimum value
*/
protected static double findMin(double vals[]) {
- if (vals.length < 1) throw new StingException("findMin: an array of size < 1 was passed in");
+ if (vals.length < 1) throw new GATKException("findMin: an array of size < 1 was passed in");
double min = vals[0];
for (double d : vals)
diff --git a/java/src/org/broadinstitute/sting/utils/help/ApplicationDetails.java b/java/src/org/broadinstitute/sting/utils/help/ApplicationDetails.java
index 5f794583d..bfce3f197 100644
--- a/java/src/org/broadinstitute/sting/utils/help/ApplicationDetails.java
+++ b/java/src/org/broadinstitute/sting/utils/help/ApplicationDetails.java
@@ -25,6 +25,7 @@
package org.broadinstitute.sting.utils.help;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.classloader.JVMUtils;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.commandline.CommandLineProgram;
@@ -80,7 +81,7 @@ public class ApplicationDetails {
runningInstructions = JVMUtils.getLocationFor( application ).getName();
}
catch( IOException ex ) {
- throw new StingException("Unable to determine running instructions", ex);
+ throw new GATKException("Unable to determine running instructions", ex);
}
if( runningInstructions.endsWith(".jar") )
diff --git a/java/src/org/broadinstitute/sting/utils/help/ResourceBundleExtractorDoclet.java b/java/src/org/broadinstitute/sting/utils/help/ResourceBundleExtractorDoclet.java
index ec9166660..4874f6205 100644
--- a/java/src/org/broadinstitute/sting/utils/help/ResourceBundleExtractorDoclet.java
+++ b/java/src/org/broadinstitute/sting/utils/help/ResourceBundleExtractorDoclet.java
@@ -31,6 +31,7 @@ import java.util.*;
import java.io.PrintStream;
import java.io.IOException;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.classloader.JVMUtils;
import org.broadinstitute.sting.utils.Utils;
@@ -181,7 +182,7 @@ public class ResourceBundleExtractorDoclet {
for(Tag tag: element.tags()) {
if(tag.name().equals("@"+DisplayNameTaglet.NAME)) {
if(name != null)
- throw new StingException("Only one display name tag can be used per package / walker.");
+ throw new GATKException("Only one display name tag can be used per package / walker.");
name = tag.text();
}
else if(tag.name().equals("@"+VERSION_TAGLET_NAME))
diff --git a/java/src/org/broadinstitute/sting/utils/instrumentation/Sizeof.java b/java/src/org/broadinstitute/sting/utils/instrumentation/Sizeof.java
index 12311f391..c1dbf1018 100644
--- a/java/src/org/broadinstitute/sting/utils/instrumentation/Sizeof.java
+++ b/java/src/org/broadinstitute/sting/utils/instrumentation/Sizeof.java
@@ -24,6 +24,7 @@
package org.broadinstitute.sting.utils.instrumentation;
+import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import java.lang.instrument.Instrumentation;
@@ -73,7 +74,7 @@ public class Sizeof {
*/
public static long getObjectSize(Object o) {
if(!isEnabled())
- throw new StingException("Sizeof operator is currently disabled! To enable, review the documentation in Sizeof.java");
+ throw new GATKException("Sizeof operator is currently disabled! To enable, review the documentation in Sizeof.java");
return instrumentation.getObjectSize(o);
}
@@ -84,7 +85,7 @@ public class Sizeof {
*/
public static long getObjectGraphSize(Object o) {
if(!isEnabled())
- throw new StingException("Sizeof operator is currently disabled! To enable, review the documentation in Sizeof.java");
+ throw new GATKException("Sizeof operator is currently disabled! To enable, review the documentation in Sizeof.java");
IdentityHashMap