All exceptions thrown by the GATK have been reviewed and UserErrors replaced where appropriate. Shazam. Another check-in will remove the GATKException and restore the StingException.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4252 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
depristo 2010-09-10 15:25:30 +00:00
parent cf33614ddc
commit 8f1a32acae
98 changed files with 427 additions and 320 deletions

View File

@ -230,7 +230,7 @@ public class BWTFiles {
* Convert the given reference sequence into a form suitable for building into * Convert the given reference sequence into a form suitable for building into
* on-the-fly sequences. * on-the-fly sequences.
* @param referenceSequence The reference sequence to normalize. * @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) { private static void normalizeReferenceSequence(byte[] referenceSequence) {
StringUtil.toUpperCase(referenceSequence); StringUtil.toUpperCase(referenceSequence);

View File

@ -67,7 +67,7 @@ public class BWTReader {
} }
} }
catch( IOException ex ) { 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); return new BWT(inverseSA0, new Counts(count,true), sequenceBlocks);

View File

@ -28,6 +28,7 @@ package org.broadinstitute.sting.analyzecovariates;
import org.broadinstitute.sting.commandline.Input; import org.broadinstitute.sting.commandline.Input;
import org.broadinstitute.sting.gatk.walkers.recalibration.*; import org.broadinstitute.sting.gatk.walkers.recalibration.*;
import org.broadinstitute.sting.utils.classloader.PackageUtils; 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.utils.text.XReadLines;
import org.broadinstitute.sting.commandline.CommandLineProgram; import org.broadinstitute.sting.commandline.CommandLineProgram;
import org.broadinstitute.sting.commandline.Argument; import org.broadinstitute.sting.commandline.Argument;
@ -140,11 +141,8 @@ class AnalyzeCovariatesCLP extends CommandLineProgram {
try { try {
Covariate covariate = (Covariate)covClass.newInstance(); Covariate covariate = (Covariate)covClass.newInstance();
requestedCovariates.add( covariate ); requestedCovariates.add( covariate );
} catch (Exception e) {
} catch ( InstantiationException e ) { throw new DynamicClassResolutionException(covClass, 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()) );
} }
} }
} }

View File

@ -31,6 +31,7 @@ import org.broadinstitute.sting.utils.classloader.JVMUtils;
import org.broadinstitute.sting.gatk.walkers.Multiplex; import org.broadinstitute.sting.gatk.walkers.Multiplex;
import org.broadinstitute.sting.gatk.walkers.Multiplexer; import org.broadinstitute.sting.gatk.walkers.Multiplexer;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
import org.broadinstitute.sting.utils.exceptions.UserError; import org.broadinstitute.sting.utils.exceptions.UserError;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
@ -348,16 +349,13 @@ class SimpleArgumentTypeDescriptor extends ArgumentTypeDescriptor {
Constructor ctor = type.getConstructor(String.class); Constructor ctor = type.getConstructor(String.class);
result = ctor.newInstance(value); 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) { } 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)"); 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) { } catch (Exception e) {
throw new GATKException("constructFromString:InstantiationException: Failed conversion " + e.getMessage()); throw new DynamicClassResolutionException(String.class, e);
} }
// WARNING: Side effect! // WARNING: Side effect!
parsingEngine.addTags(result,tags); parsingEngine.addTags(result,tags);

View File

@ -101,7 +101,7 @@ public abstract class CommandLineExecutable extends CommandLineProgram {
*/ */
private void generateGATKRunReport(Walker<?,?> mWalker, Exception e) { private void generateGATKRunReport(Walker<?,?> mWalker, Exception e) {
if ( getArgumentCollection().phoneHomeType != GATKRunReport.PhoneHomeOption.NO_ET ) { 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 ) if ( getArgumentCollection().phoneHomeType == GATKRunReport.PhoneHomeOption.STDOUT )
report.postReport(System.out); report.postReport(System.out);
else else

View File

@ -68,7 +68,7 @@ public class AlignmentContext {
} }
public AlignmentContext(GenomeLoc loc, ReadBackedPileup basePileup, long skippedBases,boolean hasPileupBeenDownsampled ) { 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 ( 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"); if ( skippedBases < 0 ) throw new GATKException("BUG: skippedBases is -1 in Alignment context");

View File

@ -1,5 +1,6 @@
package org.broadinstitute.sting.gatk.datasources; package org.broadinstitute.sting.gatk.datasources;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; 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, * This exception is throw when we're unable to generate a data source,
* most likely due to an incomplete input source list * most likely due to an incomplete input source list
*/ */
public class DataSourceGenerationException extends StingException { public class DataSourceGenerationException extends GATKException {
public DataSourceGenerationException(String message) { public DataSourceGenerationException(String message) {
super(message); super(message);
} }

View File

@ -216,7 +216,7 @@ class ReferenceOrderedQueryDataPool extends ResourcePool<FeatureSource, Location
return new SeekableRODIterator(new FeatureToGATKFeatureIterator(resource.iterator(),rod.getName())); return new SeekableRODIterator(new FeatureToGATKFeatureIterator(resource.iterator(),rod.getName()));
} }
} catch (IOException e) { } catch (IOException e) {
throw new StingException("Unable to create iterator for rod named " + rod.getName(),e); throw new GATKException("Unable to create iterator for rod named " + rod.getName(),e);
} }
} }

View File

@ -1,5 +1,6 @@
package org.broadinstitute.sting.gatk.datasources.simpleDataSources; package org.broadinstitute.sting.gatk.datasources.simpleDataSources;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
/** /**
@ -28,7 +29,7 @@ import org.broadinstitute.sting.utils.StingException;
* <p/> * <p/>
* Generate this on a simple data source load exception * Generate this on a simple data source load exception
*/ */
public class SimpleDataSourceLoadException extends StingException { public class SimpleDataSourceLoadException extends GATKException {
public SimpleDataSourceLoadException(String msg) { public SimpleDataSourceLoadException(String msg) {
super(msg); super(msg);
} }

View File

@ -2,6 +2,7 @@ package org.broadinstitute.sting.gatk.datasources.simpleDataSources;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
@ -39,7 +40,7 @@ import org.broadinstitute.sting.utils.StingException;
* <p/> * <p/>
* an exception that get's thrown if we can't split up a data source appropriately * 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) { public SimpleDataSourceSplitException(String msg) {
super(msg); super(msg);
} }

View File

@ -98,7 +98,7 @@ public class OutputStreamStorage extends OutputStream implements Storage<OutputS
outputStream.close(); outputStream.close();
} }
catch( IOException ex ) { catch( IOException ex ) {
throw new StingException( "Unable to close output stream" ); throw new UserError.CouldNotCreateOutputFile(file, "Unable to close output stream", ex );
} }
} }

View File

@ -29,6 +29,7 @@ import org.broadinstitute.sting.commandline.*;
import org.broadinstitute.sting.utils.GATKException; import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine; import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.File; import java.io.File;
@ -116,15 +117,8 @@ public class OutputStreamArgumentTypeDescriptor extends ArgumentTypeDescriptor {
private Object createInstanceOfClass(Class type,OutputStream outputStream) { private Object createInstanceOfClass(Class type,OutputStream outputStream) {
try { try {
return getConstructorForClass(type).newInstance(outputStream); return getConstructorForClass(type).newInstance(outputStream);
} } catch (Exception e) {
catch( InstantiationException ex ) { throw new DynamicClassResolutionException(type, e);
throw new GATKException("Could not instantiate class with OutputStream constructor: " + type.getName());
}
catch( IllegalAccessException ex ) {
throw new GATKException("Could not access class with OutputStream constructor: " + type.getName());
}
catch( InvocationTargetException ex ) {
throw new GATKException("Could not invoke constructor for class with OutputStream constructor: " + type.getName());
} }
} }
} }

View File

@ -155,6 +155,7 @@ public class GATKRunReport {
public enum PhoneHomeOption { public enum PhoneHomeOption {
NO_ET, NO_ET,
STANDARD, STANDARD,
DEV,
STDOUT STDOUT
} }
@ -167,7 +168,10 @@ public class GATKRunReport {
* @param e the exception caused by running this walker, or null if we completed successfully * @param e the exception caused by running this walker, or null if we completed successfully
* @param engine the GAE we used to run the walker, so we can fetch runtime, args, etc * @param engine the GAE we used to run the walker, so we can fetch runtime, args, etc
*/ */
public GATKRunReport(Walker<?,?> 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(); mGATKHeader = CommandLineGATK.createApplicationHeader();
currentPath = System.getProperty("user.dir"); currentPath = System.getProperty("user.dir");

View File

@ -26,6 +26,7 @@
package org.broadinstitute.sting.gatk.refdata; package org.broadinstitute.sting.gatk.refdata;
import org.broadinstitute.sting.utils.GATKException; 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.exceptions.UserError;
import org.broadinstitute.sting.utils.text.XReadLines; import org.broadinstitute.sting.utils.text.XReadLines;
import org.broadinstitute.sting.utils.Utils; import org.broadinstitute.sting.utils.Utils;
@ -232,12 +233,8 @@ public class RODRecordIterator<ROD extends ReferenceOrderedDatum> implements Ite
private ROD instantiateROD(final String name) { private ROD instantiateROD(final String name) {
try { try {
return (ROD) named_constructor.newInstance(name); return (ROD) named_constructor.newInstance(name);
} catch (java.lang.InstantiationException e) { } catch (Exception e) {
throw new GATKException("Failed to instantiate ROD object of class "+type.getName()); throw new DynamicClassResolutionException(named_constructor.getDeclaringClass(), e);
} 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());
} }
} }

View File

@ -23,6 +23,7 @@
package org.broadinstitute.sting.gatk.refdata.tracks; package org.broadinstitute.sting.gatk.refdata.tracks;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; 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 * 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) { public RMDTrackCreationException(String msg) {
super(msg); super(msg);
} }

View File

@ -333,7 +333,7 @@ public class IndelRealigner extends ReadWalker<Integer, Integer> {
do { do {
currentInterval = intervals.hasNext() ? intervals.next() : null; currentInterval = intervals.hasNext() ? intervals.next() : null;
} while ( currentInterval != null && (readLoc == null || currentInterval.isBefore(readLoc)) ); } 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); 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);
} }

View File

@ -38,6 +38,7 @@ import org.broadinstitute.sting.utils.classloader.PackageUtils;
import org.broadinstitute.sting.utils.collections.NestedHashMap; import org.broadinstitute.sting.utils.collections.NestedHashMap;
import org.broadinstitute.sting.commandline.Argument; import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.ArgumentCollection; 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.exceptions.UserError;
import org.broadinstitute.sting.utils.pileup.PileupElement; import org.broadinstitute.sting.utils.pileup.PileupElement;
import org.broadinstitute.sting.utils.sam.GATKSAMRecord; import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
@ -213,10 +214,8 @@ public class CovariateCounterWalker extends LocusWalker<CovariateCounterWalker.C
try { try {
final Covariate covariate = (Covariate)covClass.newInstance(); final Covariate covariate = (Covariate)covClass.newInstance();
requestedCovariates.add( covariate ); requestedCovariates.add( covariate );
} catch ( InstantiationException e ) { } catch (Exception e) {
throw new UserError.CommandLineError( String.format("Can not instantiate covariate class '%s': must be concrete class.", covClass.getSimpleName()) ); throw new DynamicClassResolutionException(covClass, e);
} catch ( IllegalAccessException e ) {
throw new UserError.CommandLineError( String.format("Can not instantiate covariate class '%s': must have no-arg constructor.", covClass.getSimpleName()) );
} }
} }
} }
@ -234,10 +233,8 @@ public class CovariateCounterWalker extends LocusWalker<CovariateCounterWalker.C
// Now that we've found a matching class, try to instantiate it // Now that we've found a matching class, try to instantiate it
final Covariate covariate = (Covariate)covClass.newInstance(); final Covariate covariate = (Covariate)covClass.newInstance();
requestedCovariates.add( covariate ); requestedCovariates.add( covariate );
} catch ( InstantiationException e ) { } catch (Exception e) {
throw new UserError.CommandLineError( String.format("Can not instantiate covariate class '%s': must be concrete class.", covClass.getSimpleName()) ); throw new DynamicClassResolutionException(covClass, e);
} catch ( IllegalAccessException e ) {
throw new UserError.CommandLineError( String.format("Can not instantiate covariate class '%s': must have no-arg constructor.", covClass.getSimpleName()) );
} }
} }
} }

View File

@ -281,7 +281,7 @@ public class RecalDataManager {
if( attr instanceof String ) { if( attr instanceof String ) {
colorSpace = ((String)attr).getBytes(); colorSpace = ((String)attr).getBytes();
} else { } else {
throw new StingException(String.format("Value encoded by %s in %s isn't a string!", RecalDataManager.COLOR_SPACE_ATTRIBUTE_TAG, read.getReadName())); throw new UserError.MalformedBam(read, String.format("Value encoded by %s in %s isn't a string!", RecalDataManager.COLOR_SPACE_ATTRIBUTE_TAG, read.getReadName()));
} }
// Loop over the read and calculate first the inferred bases from the color and then check if it is consistent with the read // Loop over the read and calculate first the inferred bases from the color and then check if it is consistent with the read

View File

@ -47,6 +47,7 @@ import org.broadinstitute.sting.utils.classloader.PackageUtils;
import org.broadinstitute.sting.utils.collections.NestedHashMap; import org.broadinstitute.sting.utils.collections.NestedHashMap;
import org.broadinstitute.sting.utils.QualityUtils; import org.broadinstitute.sting.utils.QualityUtils;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
import org.broadinstitute.sting.utils.exceptions.UserError; import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.text.TextFormattingUtils; import org.broadinstitute.sting.utils.text.TextFormattingUtils;
import org.broadinstitute.sting.utils.Utils; import org.broadinstitute.sting.utils.Utils;
@ -191,12 +192,10 @@ public class TableRecalibrationWalker extends ReadWalker<SAMRecord, SAMFileWrite
try { try {
Covariate covariate = (Covariate)covClass.newInstance(); Covariate covariate = (Covariate)covClass.newInstance();
requestedCovariates.add( covariate ); requestedCovariates.add( covariate );
} catch (Exception e) {
} catch ( InstantiationException e ) { throw new DynamicClassResolutionException(covClass, e);
throw new UserError.CommandLineError( String.format("Can not instantiate covariate class '%s': must be concrete class.", covClass.getSimpleName()) );
} catch ( IllegalAccessException e ) {
throw new UserError.CommandLineError( String.format("Can not instantiate covariate class '%s': must have no-arg constructor.", covClass.getSimpleName()) );
} }
} }
} }

View File

@ -51,6 +51,7 @@ import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.Utils; import org.broadinstitute.sting.utils.Utils;
import org.broadinstitute.sting.commandline.Argument; import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output; import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
import org.broadinstitute.sting.utils.exceptions.UserError; import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.text.XReadLines; import org.broadinstitute.sting.utils.text.XReadLines;
@ -478,14 +479,8 @@ public class VariantEvalWalker extends RodWalker<Integer, Integer> {
Constructor constructor = c.getConstructor(argTypes); Constructor constructor = c.getConstructor(argTypes);
VariantEvaluator eval = (VariantEvaluator)constructor.newInstance(args); VariantEvaluator eval = (VariantEvaluator)constructor.newInstance(args);
evals.add(eval); evals.add(eval);
} catch (InstantiationException e) { } catch (Exception e) {
throw new StingException(String.format("Cannot instantiate class '%s': must be concrete class", c.getSimpleName())); throw new DynamicClassResolutionException(c, e);
} 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()));
} }
} }
@ -565,7 +560,7 @@ public class VariantEvalWalker extends RodWalker<Integer, Integer> {
if ( interesting != null ) interestingReasons.add(interesting); if ( interesting != null ) interestingReasons.add(interesting);
break; break;
default: default:
throw new StingException("BUG: Unexpected evaluation order " + evaluation); throw new GATKException("BUG: Unexpected evaluation order " + evaluation);
} }
} }
} }

View File

@ -37,6 +37,7 @@ import org.broadinstitute.sting.gatk.walkers.RodWalker;
import org.broadinstitute.sting.utils.*; import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.utils.collections.ExpandingArrayList; import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
import org.broadinstitute.sting.commandline.Argument; 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.vcf.VCFUtils;
import org.broadinstitute.sting.utils.text.XReadLines; import org.broadinstitute.sting.utils.text.XReadLines;
@ -127,7 +128,7 @@ public class ApplyVariantCuts extends RodWalker<Integer, Integer> {
return tranches; return tranches;
} catch( FileNotFoundException e ) { } 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<Integer, Integer> {
firstLine = false; firstLine = false;
} }
} catch( FileNotFoundException e ) { } catch( FileNotFoundException e ) {
throw new StingException("Can not find input file: " + TRANCHES_FILE); throw new UserError.CouldNotCreateOutputFile(TRANCHES_FILE, e);
} }
// setup the header fields // setup the header fields

View File

@ -41,6 +41,7 @@ import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.Utils; import org.broadinstitute.sting.utils.Utils;
import org.broadinstitute.sting.commandline.Argument; import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.utils.exceptions.UserError;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -147,7 +148,7 @@ public class GenerateVariantClustersWalker extends RodWalker<ExpandingArrayList<
} }
if(!foundDBSNP) { if(!foundDBSNP) {
throw new StingException("dbSNP track is required. This calculation is critically dependent on being able to distinguish known and novel sites."); throw new UserError.CommandLineError("dbSNP track is required. This calculation is critically dependent on being able to distinguish known and novel sites.");
} }
} }
@ -239,7 +240,7 @@ public class GenerateVariantClustersWalker extends RodWalker<ExpandingArrayList<
// theModel = new VariantNearestNeighborsModel( dataManager, TARGET_TITV, NUM_KNN ); // theModel = new VariantNearestNeighborsModel( dataManager, TARGET_TITV, NUM_KNN );
// break; // break;
default: default:
throw new StingException( "Variant Optimization Model is unrecognized. Implemented options are GAUSSIAN_MIXTURE_MODEL and K_NEAREST_NEIGHBORS" ); throw new UserError.BadArgumentValue("OPTIMIZATION_MODEL", "Variant Optimization Model is unrecognized. Implemented options are GAUSSIAN_MIXTURE_MODEL and K_NEAREST_NEIGHBORS" );
} }
theModel.run( CLUSTER_FILE ); theModel.run( CLUSTER_FILE );

View File

@ -28,6 +28,7 @@ package org.broadinstitute.sting.gatk.walkers.variantrecalibration;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.broadinstitute.sting.utils.collections.ExpandingArrayList; import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import java.io.PrintStream; import java.io.PrintStream;
@ -53,7 +54,7 @@ public class VariantDataManager {
numVariants = dataList.size(); numVariants = dataList.size();
data = dataList.toArray( new VariantDatum[numVariants] ); data = dataList.toArray( new VariantDatum[numVariants] );
if( numVariants <= 0 ) { if( numVariants <= 0 ) {
throw new StingException( "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" ); 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 ) { if( _annotationKeys == null ) {
numAnnotations = 0; numAnnotations = 0;
@ -62,7 +63,7 @@ public class VariantDataManager {
} else { } else {
numAnnotations = _annotationKeys.size(); numAnnotations = _annotationKeys.size();
if( numAnnotations <= 0 ) { 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]; meanVector = new double[numAnnotations];
varianceVector = 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 ] isNormalized = true; // Each data point is now [ (x - mean) / standard deviation ]
if( foundZeroVarianceAnnotation ) { 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.");
} }
} }

View File

@ -28,9 +28,11 @@ package org.broadinstitute.sting.gatk.walkers.variantrecalibration;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.util.variantcontext.VariantContext;
import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContextUtils; 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.MathUtils;
import org.broadinstitute.sting.utils.collections.ExpandingArrayList; import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.text.XReadLines; import org.broadinstitute.sting.utils.text.XReadLines;
import Jama.*; import Jama.*;
@ -130,11 +132,11 @@ public final class VariantGaussianMixtureModel extends VariantOptimizationModel
} else if( CLUSTER_PATTERN.matcher(line).matches() ) { } else if( CLUSTER_PATTERN.matcher(line).matches() ) {
clusterLines.add(line); clusterLines.add(line);
} else { } else {
throw new StingException("Malformed input file: " + clusterFile); throw new UserError.MalformedFile(clusterFile, "Could not parse line: " + line);
} }
} }
} catch ( FileNotFoundException e ) { } catch ( FileNotFoundException e ) {
throw new StingException("Can not find input file: " + clusterFile); throw new UserError.CouldNotReadInputFile(clusterFile, e);
} }
dataManager = new VariantDataManager( annotationLines ); dataManager = new VariantDataManager( annotationLines );
@ -427,9 +429,8 @@ public final class VariantGaussianMixtureModel extends VariantOptimizationModel
} else { } else {
try { try {
value = Double.parseDouble( (String)vc.getAttribute( annotationKey ) ); value = Double.parseDouble( (String)vc.getAttribute( annotationKey ) );
} catch( Exception e ) { } catch( NumberFormatException e ) {
throw new StingException("No double value detected for annotation = " + annotationKey + 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 );
" in variant at " + VariantContextUtils.getLocation(vc) + ", reported annotation value = " + vc.getAttribute( annotationKey ) );
} }
} }
return value; return value;
@ -488,10 +489,11 @@ public final class VariantGaussianMixtureModel extends VariantOptimizationModel
int annIndex = 0; int annIndex = 0;
for( final String annotation : dataManager.annotationKeys ) { for( final String annotation : dataManager.annotationKeys ) {
PrintStream outputFile; PrintStream outputFile;
File file = new File(outputPrefix + "." + annotation + ".dat");
try { try {
outputFile = new PrintStream( outputPrefix + "." + annotation + ".dat" ); outputFile = new PrintStream( file );
} catch (Exception e) { } catch (FileNotFoundException e) {
throw new StingException( "Unable to create output file: " + outputPrefix + ".dat" ); throw new UserError.CouldNotCreateOutputFile( file, e );
} }
outputFile.println("annotationValue,knownDist,novelDist"); 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 desiredNumVariants, final Double[] FDRtranches, final double QUAL_STEP ) {
final int numVariants = data.length; final int numVariants = data.length;
@ -530,19 +532,7 @@ public final class VariantGaussianMixtureModel extends VariantOptimizationModel
markedVariant[iii] = false; markedVariant[iii] = false;
} }
PrintStream outputFile; tranchesOutputFile.println("FDRtranche,novelTITV,pCut,numNovel,filterName");
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 );
}
int numKnown = 0; int numKnown = 0;
int numNovel = 0; int numNovel = 0;
@ -552,7 +542,7 @@ public final class VariantGaussianMixtureModel extends VariantOptimizationModel
int numNovelTv = 0; int numNovelTv = 0;
boolean foundDesiredNumVariants = false; boolean foundDesiredNumVariants = false;
int jjj = 0; 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( double qCut = MAX_QUAL; qCut >= -0.001; qCut -= QUAL_STEP ) {
for( int iii = 0; iii < numVariants; iii++ ) { for( int iii = 0; iii < numVariants; iii++ ) {
if( !markedVariant[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))); logger.info("\t" + String.format("%.4f novel Ti/Tv ratio", ((double)numNovelTi) / ((double)numNovelTv)));
foundDesiredNumVariants = true; foundDesiredNumVariants = true;
} }
outputFile.println( qCut + "," + numKnown + "," + numNovel + "," + outputReportDatFile.println( qCut + "," + numKnown + "," + numNovel + "," +
( numKnownTi == 0 || numKnownTv == 0 ? "NaN" : ( ((double)numKnownTi) / ((double)numKnownTv) ) ) + "," + ( numKnownTi == 0 || numKnownTv == 0 ? "NaN" : ( ((double)numKnownTi) / ((double)numKnownTv) ) ) + "," +
( numNovelTi == 0 || numNovelTv == 0 ? "NaN" : ( ((double)numNovelTi) / ((double)numNovelTv) ) )); ( 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. " + 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."); "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]) ) { 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. " + 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."); "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) ) { if( Double.isNaN(prob) ) {
logger.warn("About to throw exception due to numerical instability. Try running with fewer annotations and then with fewer Gaussians. " + 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."); "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; sumProb += prob;
for( int jjj = 0; jjj < numAnnotations; jjj++ ) { for( int jjj = 0; jjj < numAnnotations; jjj++ ) {

View File

@ -41,6 +41,7 @@ import org.broadinstitute.sting.gatk.walkers.RodWalker;
import org.broadinstitute.sting.utils.*; import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.utils.collections.ExpandingArrayList; import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
import org.broadinstitute.sting.commandline.Argument; 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.vcf.VCFUtils;
import java.io.File; import java.io.File;
@ -143,7 +144,7 @@ public class VariantRecalibrator extends RodWalker<ExpandingArrayList<VariantDat
// theModel = new VariantNearestNeighborsModel( dataManager, TARGET_TITV, NUM_KNN ); // theModel = new VariantNearestNeighborsModel( dataManager, TARGET_TITV, NUM_KNN );
// break; // break;
default: default:
throw new StingException( "Variant Optimization Model is unrecognized. Implemented options are GAUSSIAN_MIXTURE_MODEL and K_NEAREST_NEIGHBORS" ); throw new UserError.BadArgumentValue("OPTIMIZATION_MODEL", "Variant Optimization Model is unrecognized. Implemented options are GAUSSIAN_MIXTURE_MODEL and K_NEAREST_NEIGHBORS" );
} }
boolean foundDBSNP = false; boolean foundDBSNP = false;
@ -166,7 +167,7 @@ public class VariantRecalibrator extends RodWalker<ExpandingArrayList<VariantDat
} }
if(!foundDBSNP) { if(!foundDBSNP) {
throw new StingException("dbSNP track is required. This calculation is critically dependent on being able to distinguish known and novel sites."); throw new UserError.CommandLineError("dbSNP track is required. This calculation is critically dependent on being able to distinguish known and novel sites.");
} }
// setup the header fields // setup the header fields
@ -232,7 +233,7 @@ public class VariantRecalibrator extends RodWalker<ExpandingArrayList<VariantDat
final double totalPrior = 1.0 - ((1.0 - acPrior) * (1.0 - knownPrior)); final double totalPrior = 1.0 - ((1.0 - acPrior) * (1.0 - knownPrior));
if( MathUtils.compareDoubles(totalPrior, 1.0, 1E-8) == 0 || MathUtils.compareDoubles(totalPrior, 0.0, 1E-8) == 0 ) { if( MathUtils.compareDoubles(totalPrior, 1.0, 1E-8) == 0 || MathUtils.compareDoubles(totalPrior, 0.0, 1E-8) == 0 ) {
throw new StingException("Something is wrong with the prior that was entered by the user: Prior = " + totalPrior); // TODO - fix this up later throw new UserError.CommandLineError("Something is wrong with the prior that was entered by the user: Prior = " + totalPrior); // TODO - fix this up later
} }
final double pVar = theModel.evaluateVariant( vc ); final double pVar = theModel.evaluateVariant( vc );
@ -285,7 +286,7 @@ public class VariantRecalibrator extends RodWalker<ExpandingArrayList<VariantDat
PrintStream reportDatFilePrintStream = new PrintStream(REPORT_DAT_FILE); PrintStream reportDatFilePrintStream = new PrintStream(REPORT_DAT_FILE);
theModel.outputOptimizationCurve( dataManager.data, reportDatFilePrintStream, TRANCHES_FILE, DESIRED_NUM_VARIANTS, FDR_TRANCHES, QUAL_STEP ); theModel.outputOptimizationCurve( dataManager.data, reportDatFilePrintStream, TRANCHES_FILE, DESIRED_NUM_VARIANTS, FDR_TRANCHES, QUAL_STEP );
} catch ( FileNotFoundException e ) { } catch ( FileNotFoundException e ) {
throw new StingException("Can't create report dat file: " + REPORT_DAT_FILE.getName()); throw new UserError.CouldNotCreateOutputFile(REPORT_DAT_FILE, e);
} }
// Execute Rscript command to plot the optimization curve // Execute Rscript command to plot the optimization curve

View File

@ -37,6 +37,8 @@ import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnot
import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.classloader.PackageUtils; import org.broadinstitute.sting.utils.classloader.PackageUtils;
import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import java.util.*; import java.util.*;
@ -90,7 +92,7 @@ public class AnnotationByAlleleFrequencyWalker extends RodWalker<Integer, Integ
if ( interfaceClass == null ) if ( interfaceClass == null )
interfaceClass = classMap.get(group + "Annotation"); interfaceClass = classMap.get(group + "Annotation");
if ( interfaceClass == null ) if ( interfaceClass == null )
throw new StingException("Class " + group + " is not found; please check that you have specified the class name correctly"); throw new UserError.BadArgumentValue("group", "Class " + group + " is not found; please check that you have specified the class name correctly");
classes.addAll(PackageUtils.getClassesImplementingInterface(interfaceClass)); classes.addAll(PackageUtils.getClassesImplementingInterface(interfaceClass));
} }
@ -100,7 +102,7 @@ public class AnnotationByAlleleFrequencyWalker extends RodWalker<Integer, Integ
if ( annotationClass == null ) if ( annotationClass == null )
annotationClass = classMap.get(annotation + "Annotation"); annotationClass = classMap.get(annotation + "Annotation");
if ( annotationClass == null ) if ( annotationClass == null )
throw new StingException("Class " + annotation + " is not found; please check that you have specified the class name correctly"); throw new UserError.BadArgumentValue("annotation", "Class " + annotation + " is not found; please check that you have specified the class name correctly");
classes.add(annotationClass); classes.add(annotationClass);
} }
@ -128,10 +130,8 @@ public class AnnotationByAlleleFrequencyWalker extends RodWalker<Integer, Integ
private static <T> T getInstance(Class<T> c) { private static <T> T getInstance(Class<T> c) {
try { try {
return c.newInstance(); return c.newInstance();
} catch (InstantiationException e) { } catch (Exception e) {
throw new StingException(String.format("Cannot instantiate annotation class '%s': must be concrete class", c.getSimpleName())); throw new DynamicClassResolutionException(c, e);
} catch (IllegalAccessException e) {
throw new StingException(String.format("Cannot instantiate annotation class '%s': must have no-arg constructor", c.getSimpleName()));
} }
} }

View File

@ -33,8 +33,10 @@ import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.commandline.Argument; import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output; import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.*; import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.pileup.ReadBackedPileup; import org.broadinstitute.sting.utils.pileup.ReadBackedPileup;
import java.io.File;
import java.util.*; import java.util.*;
import java.io.PrintStream; import java.io.PrintStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
@ -85,7 +87,7 @@ public class BaseTransitionTableCalculatorJavaWalker extends LocusWalker<Set<Bas
public void initialize() { public void initialize() {
if ( nPreviousBases > 3 || ( nPreviousReadBases > 3 && readBasesMustMatchRef ) ) { if ( nPreviousBases > 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(); UnifiedArgumentCollection uac = new UnifiedArgumentCollection();
uac.baseModel = BaseMismatchModel.THREE_STATE; uac.baseModel = BaseMismatchModel.THREE_STATE;
@ -149,7 +151,7 @@ public class BaseTransitionTableCalculatorJavaWalker extends LocusWalker<Set<Bas
String errMsg = "Parallelization cannot be used with UsePreviousBases due to the fact that internal walker data specifies whether a previous reference base is usable or not."; String errMsg = "Parallelization cannot be used with UsePreviousBases due to the fact that internal walker data specifies whether a previous reference base is usable or not.";
String errMsg2 = " This can cause cause concurrency issues and unpredictable behavior when used with parallelization. Either do not specify -nt, or try a the conjunction of "; String errMsg2 = " This can cause cause concurrency issues and unpredictable behavior when used with parallelization. Either do not specify -nt, or try a the conjunction of ";
String errMsg3 = "--usePreviousReadBases and --forcePreviousReadBasesToMatchRef."; String errMsg3 = "--usePreviousReadBases and --forcePreviousReadBasesToMatchRef.";
throw new StingException(errMsg+errMsg2+errMsg3); throw new UserError.CommandLineError(errMsg+errMsg2+errMsg3);
} }
return reduce(reduce1,reduce2); return reduce(reduce1,reduce2);
} }
@ -162,7 +164,7 @@ public class BaseTransitionTableCalculatorJavaWalker extends LocusWalker<Set<Bas
try { try {
output = new PrintStream(outFilePath); output = new PrintStream(outFilePath);
} catch ( FileNotFoundException e ) { } catch ( FileNotFoundException e ) {
throw new StingException("File given as input to -of, "+outFilePath+" could not be opened.",e); throw new UserError.CouldNotCreateOutputFile(new File(outFilePath), e);
} }
} }
output.print(createHeaderFromConditions()); output.print(createHeaderFromConditions());

View File

@ -35,6 +35,7 @@ import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.RodWalker; import org.broadinstitute.sting.gatk.walkers.RodWalker;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
@ -156,7 +157,7 @@ public class BeagleOutputByDepthWalker extends RodWalker<Integer, Integer> {
else if (compGenotype.isHomVar()) else if (compGenotype.isHomVar())
hg = 2; hg = 2;
else else
throw new StingException("Bug! invalid genotype!"); throw new GATKException("Bug! invalid genotype!");
if (postbglGenotype.isNoCall()) if (postbglGenotype.isNoCall())
bg = -1; bg = -1;
@ -167,7 +168,7 @@ public class BeagleOutputByDepthWalker extends RodWalker<Integer, Integer> {
else if (postbglGenotype.isHomVar()) else if (postbglGenotype.isHomVar())
bg = 2; bg = 2;
else else
throw new StingException("Bug! invalid genotype!"); throw new GATKException("Bug! invalid genotype!");
if (prebglGenotype.isNoCall()) if (prebglGenotype.isNoCall())
@ -179,7 +180,7 @@ public class BeagleOutputByDepthWalker extends RodWalker<Integer, Integer> {
else if (prebglGenotype.isHomVar()) else if (prebglGenotype.isHomVar())
pg = 2; pg = 2;
else else
throw new StingException("Bug! invalid genotype!"); throw new GATKException("Bug! invalid genotype!");
outputWriter.format("%d %d %d %d\n",dp, hg, pg, bg); outputWriter.format("%d %d %d %d\n",dp, hg, pg, bg);

View File

@ -31,6 +31,7 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.commandline.Argument; import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output; import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.*; import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.sam.AlignmentUtils; import org.broadinstitute.sting.utils.sam.AlignmentUtils;
import net.sf.samtools.SAMRecord; import net.sf.samtools.SAMRecord;
@ -390,7 +391,7 @@ public class DSBWalkerV3 extends ReadWalker<Integer,Integer> {
} else if ( controlReadGroups.contains( read.getReadGroup().getReadGroupId() )) { } else if ( controlReadGroups.contains( read.getReadGroup().getReadGroupId() )) {
addControl(read); addControl(read);
} else { } 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; return 1;
} }

View File

@ -17,6 +17,7 @@ import org.broadinstitute.sting.gatk.walkers.DataSource;
import org.broadinstitute.sting.gatk.walkers.LocusWalker; import org.broadinstitute.sting.gatk.walkers.LocusWalker;
import org.broadinstitute.sting.gatk.walkers.Requires; import org.broadinstitute.sting.gatk.walkers.Requires;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
@ -68,7 +69,7 @@ public class DbSNPWindowCounter extends LocusWalker<Integer, Long> {
windowStart, windowStart,
windowStop); windowStop);
} catch (IOException e) { } 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 // count the number of dbSNPs we've seen

View File

@ -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.features.refseq.RefSeqFeature;
import org.broadinstitute.sting.gatk.refdata.utils.GATKFeature; import org.broadinstitute.sting.gatk.refdata.utils.GATKFeature;
import org.broadinstitute.sting.gatk.walkers.RodWalker; import org.broadinstitute.sting.gatk.walkers.RodWalker;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.GenomeLocParser; import org.broadinstitute.sting.utils.GenomeLocParser;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
@ -196,7 +197,7 @@ class IntervalInfoBuilder {
} }
} }
} else { } 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 { } else {

View File

@ -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.ReferenceContext;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.walkers.LocusWalker; 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.pileup.ReadBackedPileup;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.commandline.Argument; import org.broadinstitute.sting.commandline.Argument;
@ -71,7 +72,7 @@ public class DownsamplingValidationWalker extends LocusWalker<Integer,Long> {
int matchingReadsFound = 0; int matchingReadsFound = 0;
if(unsampledReadsStartingAtThisLocus.isEmpty()) { if(unsampledReadsStartingAtThisLocus.isEmpty()) {
if(!sampledReadsStartingAtThisLocus.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 { else {
boolean foundMatch = false; boolean foundMatch = false;
@ -86,10 +87,10 @@ public class DownsamplingValidationWalker extends LocusWalker<Integer,Long> {
} }
if(!foundMatch) 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) 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; return matchingReadsFound;

View File

@ -19,6 +19,7 @@ import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.GenomeLocParser; import org.broadinstitute.sting.utils.GenomeLocParser;
import org.broadinstitute.sting.utils.SampleUtils; import org.broadinstitute.sting.utils.SampleUtils;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.vcf.VCFUtils; import org.broadinstitute.sting.utils.vcf.VCFUtils;
import java.io.File; import java.io.File;
@ -42,7 +43,7 @@ public class IndelAnnotator extends RodWalker<Integer,Long> {
try { try {
refseqIterator = new SeekableRODIterator(new FeatureToGATKFeatureIterator(refseq.iterator(),"refseq")); refseqIterator = new SeekableRODIterator(new FeatureToGATKFeatureIterator(refseq.iterator(),"refseq"));
} catch (IOException e) { } 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); logger.info("Using RefSeq annotations from " + RefseqFileName);

View File

@ -18,6 +18,7 @@ import org.broadinstitute.sting.gatk.walkers.Window;
import org.broadinstitute.sting.utils.SampleUtils; import org.broadinstitute.sting.utils.SampleUtils;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.collections.ExpandingArrayList; import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.vcf.VCFUtils; import org.broadinstitute.sting.utils.vcf.VCFUtils;
import java.io.PrintStream; import java.io.PrintStream;
@ -45,7 +46,7 @@ public class IndelDBRateWalker extends RodWalker<OverlapTable,OverlapTabulator>
public void initialize() { public void initialize() {
if ( indelWindow > 40 ) { 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 ) { if ( outVCF != null ) {

View File

@ -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.UnifiedGenotyperEngine;
import org.broadinstitute.sting.gatk.walkers.genotyper.VariantCallContext; import org.broadinstitute.sting.gatk.walkers.genotyper.VariantCallContext;
import org.broadinstitute.sting.gatk.walkers.varianteval.MendelianViolationEvaluator; import org.broadinstitute.sting.gatk.walkers.varianteval.MendelianViolationEvaluator;
import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.utils.GenomeLocParser;
import org.broadinstitute.sting.utils.SampleUtils;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.collections.Pair; import org.broadinstitute.sting.utils.collections.Pair;
import org.broadinstitute.sting.utils.vcf.VCFUtils; import org.broadinstitute.sting.utils.vcf.VCFUtils;
import org.broadinstitute.sting.utils.pileup.PileupElement; import org.broadinstitute.sting.utils.pileup.PileupElement;
@ -422,7 +419,7 @@ public class MendelianViolationClassifier extends LocusWalker<MendelianViolation
} else if ( isOppositeHomozygote(varContext) ) { } else if ( isOppositeHomozygote(varContext) ) {
violation = assessOppositeHomozygote(varContext,tracker,reference,context); violation = assessOppositeHomozygote(varContext,tracker,reference,context);
} else { } else {
throw new StingException("Mendelian violation that is neither deNovo nor opposite homozygote. Should never see this."); throw new GATKException("Mendelian violation that is neither deNovo nor opposite homozygote. Should never see this.");
} }
} else { } else {
violation = new MendelianViolation(varContext,MendelianViolationType.NONE); violation = new MendelianViolation(varContext,MendelianViolationType.NONE);
@ -466,7 +463,7 @@ public class MendelianViolationClassifier extends LocusWalker<MendelianViolation
if ( ! trio.isFiltered() ) { if ( ! trio.isFiltered() ) {
Allele parental = trio.getGenotype(trioStructure.mom).getAllele(0); // guaranteed homozygous Allele parental = trio.getGenotype(trioStructure.mom).getAllele(0); // guaranteed homozygous
if ( parental.getBases().length < 1 ) { if ( parental.getBases().length < 1 ) {
throw new StingException("Parental bases have length zero at "+trio.toString()); throw new GATKException("Parental bases have length zero at "+trio.toString());
} }
Map<String,StratifiedAlignmentContext> splitContext = StratifiedAlignmentContext.splitContextBySample(context.getBasePileup()); Map<String,StratifiedAlignmentContext> splitContext = StratifiedAlignmentContext.splitContextBySample(context.getBasePileup());

View File

@ -25,9 +25,13 @@
package org.broadinstitute.sting.oneoffprojects.walkers; package org.broadinstitute.sting.oneoffprojects.walkers;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.QualityUtils; import org.broadinstitute.sting.utils.QualityUtils;
import org.broadinstitute.sting.utils.StingException; 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.ReadBackedPileup;
import org.broadinstitute.sting.utils.pileup.PileupElement; import org.broadinstitute.sting.utils.pileup.PileupElement;
import org.broadinstitute.sting.commandline.Argument; import org.broadinstitute.sting.commandline.Argument;
@ -166,7 +170,7 @@ public class QualityScoreByStrandWalker extends LocusWalker<StrandedCounts,Stran
pairOut.close(); pairOut.close();
} }
} catch ( IOException e ) { } catch ( IOException e ) {
throw new StingException("Outputfile could not be opened"); throw new UserError.CouldNotCreateOutputFile(new File(pairOutput), e);
} }
} }
} }
@ -207,7 +211,7 @@ class StrandedCounts {
public void updateReadPair( int fQual, int rQual, int fOff, int rOff ) { // hehe f Off public void updateReadPair( int fQual, int rQual, int fOff, int rOff ) { // hehe f Off
if ( rOff < 0 || fOff < 0 ) if ( rOff < 0 || fOff < 0 )
throw new StingException("Offset is negative. Should never happen."); throw new GATKException("Offset is negative. Should never happen.");
forwardCountsByOffset[fOff][fQual < 0 ? 0 : fQual > 40 ? 40 : fQual]++; forwardCountsByOffset[fOff][fQual < 0 ? 0 : fQual > 40 ? 40 : fQual]++;
reverseCountsByOffset[rOff][rQual < 0 ? 0 : rQual > 40 ? 40 : rQual]++; reverseCountsByOffset[rOff][rQual < 0 ? 0 : rQual > 40 ? 40 : rQual]++;
} }

View File

@ -35,6 +35,7 @@ import org.broadinstitute.sting.utils.GenomeLocParser;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import net.sf.samtools.SAMRecord; import net.sf.samtools.SAMRecord;
import net.sf.samtools.SAMFileWriter; import net.sf.samtools.SAMFileWriter;
import org.broadinstitute.sting.utils.exceptions.UserError;
import java.io.*; import java.io.*;
@ -79,9 +80,9 @@ public class ReadQualityScoreWalker extends ReadWalker<SAMRecord, SAMFileWriter>
try { try {
inputReader = new BufferedReader( new FileReader ( inputQualityFile ) ); inputReader = new BufferedReader( new FileReader ( inputQualityFile ) );
} catch ( FileNotFoundException e) { } catch ( FileNotFoundException e) {
throw new StingException("Could not find required input file: " + inputQualityFile); throw new UserError.CouldNotReadInputFile(new File(inputQualityFile), e);
} catch (IOException 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; return outputBamFile;
} }
@ -103,13 +104,13 @@ public class ReadQualityScoreWalker extends ReadWalker<SAMRecord, SAMFileWriter>
try { try {
if( line == null ) { if( line == null ) {
line = inputReader.readLine(); 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 ); String[] halves = line.split( " ", 2 );
GenomeLoc curLoc = GenomeLocParser.parseGenomeLoc( halves[0] ); GenomeLoc curLoc = GenomeLocParser.parseGenomeLoc( halves[0] );
while( curLoc.isBefore( readLoc ) ) { // Loop until the beginning of the read while( curLoc.isBefore( readLoc ) ) { // Loop until the beginning of the read
line = inputReader.readLine(); 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 ); halves = line.split( " ", 2 );
curLoc = GenomeLocParser.parseGenomeLoc( halves[0] ); curLoc = GenomeLocParser.parseGenomeLoc( halves[0] );
} }
@ -122,7 +123,7 @@ public class ReadQualityScoreWalker extends ReadWalker<SAMRecord, SAMFileWriter>
sumNeighborhoodQuality += Float.parseFloat( halves[1] ); sumNeighborhoodQuality += Float.parseFloat( halves[1] );
numLines++; numLines++;
line = inputReader.readLine(); 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 ); halves = line.split( " ", 2 );
curLoc = GenomeLocParser.parseGenomeLoc( halves[0] ); curLoc = GenomeLocParser.parseGenomeLoc( halves[0] );
} }
@ -132,9 +133,9 @@ public class ReadQualityScoreWalker extends ReadWalker<SAMRecord, SAMFileWriter>
line = savedLine; line = savedLine;
} catch ( FileNotFoundException e ) { } catch ( FileNotFoundException e ) {
throw new StingException( "Could not find required input file: " + inputQualityFile ); throw new UserError.CouldNotReadInputFile(new File(inputQualityFile), e);
} catch (IOException 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); meanNeighborhoodQuality = sumNeighborhoodQuality / ((float) numLines);

View File

@ -34,6 +34,7 @@ import org.broadinstitute.sting.alignment.bwa.c.BWACAligner;
import org.broadinstitute.sting.alignment.Alignment; import org.broadinstitute.sting.alignment.Alignment;
import org.broadinstitute.sting.commandline.Argument; import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output; import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.GenomeLocParser; import org.broadinstitute.sting.utils.GenomeLocParser;
@ -41,6 +42,7 @@ import net.sf.samtools.SAMRecord;
import net.sf.samtools.util.StringUtil; import net.sf.samtools.util.StringUtil;
import net.sf.picard.reference.ReferenceSequence; import net.sf.picard.reference.ReferenceSequence;
import net.sf.picard.reference.IndexedFastaSequenceFile; import net.sf.picard.reference.IndexedFastaSequenceFile;
import org.broadinstitute.sting.utils.exceptions.UserError;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -85,7 +87,7 @@ public class TestReadFishingWalker extends ReadWalker<Integer,Long> {
indelCallInputStream = new FileInputStream(indelCalls); indelCallInputStream = new FileInputStream(indelCalls);
} }
catch(IOException ex) { catch(IOException ex) {
throw new StingException("Unable to load indel calls."); throw new UserError.CouldNotReadInputFile(indelCalls, ex);
} }
Scanner indelCallReader = new Scanner(indelCallInputStream); Scanner indelCallReader = new Scanner(indelCallInputStream);
@ -127,7 +129,7 @@ public class TestReadFishingWalker extends ReadWalker<Integer,Long> {
System.arraycopy(referenceSequence.getBases(),eventStart,revisedReference,eventStart+eventLength,bufferWidth); System.arraycopy(referenceSequence.getBases(),eventStart,revisedReference,eventStart+eventLength,bufferWidth);
} }
else 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())); aligners.put(GenomeLocParser.createGenomeLoc(contig,start,stop),new BWACAligner(revisedReference,new BWAConfiguration()));
if(++numAlignersCreated % 100 == 0) if(++numAlignersCreated % 100 == 0)

View File

@ -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.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.refdata.tracks.RMDTrack; import org.broadinstitute.sting.gatk.refdata.tracks.RMDTrack;
import org.broadinstitute.sting.gatk.walkers.RodWalker; import org.broadinstitute.sting.gatk.walkers.RodWalker;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.vcf.VCFUtils; import org.broadinstitute.sting.utils.vcf.VCFUtils;
@ -95,7 +96,7 @@ public class VCF4WriterTestWalker extends RodWalker<Integer, Integer> {
out.printf("Read %d header lines%n", header.getMetaData().size()); out.printf("Read %d header lines%n", header.getMetaData().size());
} }
catch (FileNotFoundException e ) { catch (FileNotFoundException e ) {
throw new StingException(e.getMessage()); throw new GATKException(e.getMessage());
} }
final Set<String> vcfSamples = header.getGenotypeSamples(); final Set<String> vcfSamples = header.getGenotypeSamples();

View File

@ -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.Analysis;
import org.broadinstitute.sting.playground.utils.report.tags.DataPoint; import org.broadinstitute.sting.playground.utils.report.tags.DataPoint;
import org.broadinstitute.sting.playground.utils.report.utils.TableType; 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.StingException;
import org.broadinstitute.sting.utils.analysis.AminoAcid; import org.broadinstitute.sting.utils.analysis.AminoAcid;
import org.broadinstitute.sting.utils.analysis.AminoAcidTable; import org.broadinstitute.sting.utils.analysis.AminoAcidTable;
import org.broadinstitute.sting.utils.analysis.AminoAcidUtils; import org.broadinstitute.sting.utils.analysis.AminoAcidUtils;
import org.broadinstitute.sting.utils.exceptions.UserError;
/* /*
* Copyright (c) 2010 The Broad Institute * Copyright (c) 2010 The Broad Institute
@ -143,11 +145,11 @@ public class AminoAcidTransition extends VariantEvaluator {
infoValueSplit = parent.aminoAcidTransitionSplit; infoValueSplit = parent.aminoAcidTransitionSplit;
useCodons = parent.aatUseCodons; useCodons = parent.aatUseCodons;
if ( infoKey == null ) { 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 ) { 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");
} }
} }
} }

View File

@ -27,6 +27,7 @@ package org.broadinstitute.sting.playground.analyzeconcordance;
import org.broadinstitute.sting.commandline.CommandLineProgram; import org.broadinstitute.sting.commandline.CommandLineProgram;
import org.broadinstitute.sting.commandline.Argument; import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.text.XReadLines; import org.broadinstitute.sting.utils.text.XReadLines;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.Utils; import org.broadinstitute.sting.utils.Utils;
@ -91,11 +92,8 @@ public class AnalyzeConcordance extends CommandLineProgram {
logger.info("Generating html report..."); logger.info("Generating html report...");
generateHtmlReport(); generateHtmlReport();
logger.info("...Done!"); logger.info("...Done!");
} catch (StingException se) {
throw se;
} catch (Exception e) { } catch (Exception e) {
throw new StingException("Error analyzing concordance", e); throw new GATKException("Error analyzing concordance", e);
} }
return result; return result;
@ -105,7 +103,7 @@ public class AnalyzeConcordance extends CommandLineProgram {
// create the output directory where all the data tables and plots will go // create the output directory where all the data tables and plots will go
File outputDir = new File(this.outputDir); File outputDir = new File(this.outputDir);
if (!outputDir.exists() && !outputDir.mkdirs()) { if (!outputDir.exists() && !outputDir.mkdirs()) {
throw new StingException("Couldn't create directory: " + this.outputDir); throw new GATKException("Couldn't create directory: " + this.outputDir);
} }
} }

View File

@ -1,7 +1,9 @@
package org.broadinstitute.sting.playground.examples; package org.broadinstitute.sting.playground.examples;
import org.apache.log4j.BasicConfigurator; import org.apache.log4j.BasicConfigurator;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.simpleframework.xml.Element; import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root; import org.simpleframework.xml.Root;
import org.simpleframework.xml.Serializer; import org.simpleframework.xml.Serializer;
@ -121,7 +123,7 @@ public class SampleXmlMarshaller {
SampleXmlMarshaller example = serializer.read(SampleXmlMarshaller.class, source); SampleXmlMarshaller example = serializer.read(SampleXmlMarshaller.class, source);
return example; return example;
} catch (Exception e) { } 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);
} }
} }
} }

View File

@ -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.UnifiedGenotyperEngine;
import org.broadinstitute.sting.gatk.walkers.genotyper.VariantCallContext; import org.broadinstitute.sting.gatk.walkers.genotyper.VariantCallContext;
import org.broadinstitute.sting.utils.BaseUtils; import org.broadinstitute.sting.utils.BaseUtils;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.commandline.Argument; import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output; import org.broadinstitute.sting.commandline.Output;
@ -155,7 +156,7 @@ public class LocusMismatchWalker extends LocusWalker<String,Integer> implements
if ( g.isHomRef() ) return "HOM-REF"; if ( g.isHomRef() ) return "HOM-REF";
else if ( g.isHet() ) return "HET"; else if ( g.isHet() ) return "HET";
else if ( g.isHom() ) return "HOM-NONREF"; 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 ) { public boolean useRead( PileupElement e ) {

View File

@ -300,7 +300,7 @@ public class ReadBackedPhasingWalker extends RodWalker<PhasingStatsAndOutput, Ph
} }
} }
if (logger.isDebugEnabled() && (phasingSiteIndex == -1 || phasingSiteIndex == 0)) if (logger.isDebugEnabled() && (phasingSiteIndex == -1 || phasingSiteIndex == 0))
throw new StingException("Internal error: could NOT find vr and/or prevVr!"); throw new GATKException("Internal error: could NOT find vr and/or prevVr!");
if (sampleWindowVaList.size() > maxPhaseSites) { if (sampleWindowVaList.size() > 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)); 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<PhasingStatsAndOutput, Ph
public static void ensurePhasing(BialleleSNP curBiall, BialleleSNP prevBiall, Haplotype hap) { public static void ensurePhasing(BialleleSNP curBiall, BialleleSNP prevBiall, Haplotype hap) {
if (hap.size() < 2) if (hap.size() < 2)
throw new StingException("LOGICAL ERROR: Only considering haplotypes of length > 2!"); throw new GATKException("LOGICAL ERROR: Only considering haplotypes of length > 2!");
byte prevBase = hap.getBase(0); // The 1st base in the haplotype byte prevBase = hap.getBase(0); // The 1st base in the haplotype
byte curBase = hap.getBase(1); // The 2nd base in the haplotype byte curBase = hap.getBase(1); // The 2nd base in the haplotype
@ -745,7 +745,7 @@ public class ReadBackedPhasingWalker extends RodWalker<PhasingStatsAndOutput, Ph
private Haplotype complement(Haplotype hap) { private Haplotype complement(Haplotype hap) {
int numSites = bialleleSNPs.length; int numSites = bialleleSNPs.length;
if (hap.size() != numSites) if (hap.size() != numSites)
throw new StingException("INTERNAL ERROR: hap.size() != numSites"); throw new GATKException("INTERNAL ERROR: hap.size() != numSites");
// Take the other base at EACH position of the Haplotype: // Take the other base at EACH position of the Haplotype:
byte[] complementBases = new byte[numSites]; byte[] complementBases = new byte[numSites];
@ -953,7 +953,7 @@ class Haplotype extends BaseArray implements Cloneable {
public void updateBase(int index, Byte base) { public void updateBase(int index, Byte base) {
if (base == null) { if (base == null) {
throw new StingException("Internal error: CANNOT have null for a missing Haplotype base!"); throw new GATKException("Internal error: CANNOT have null for a missing Haplotype base!");
} }
super.updateBase(index, base); super.updateBase(index, base);
} }
@ -1053,7 +1053,7 @@ class Read extends BaseArray {
int sz = this.bases.length; int sz = this.bases.length;
if (sz != hap.bases.length) if (sz != hap.bases.length)
throw new StingException("Read and Haplotype should have same length to be compared!"); throw new GATKException("Read and Haplotype should have same length to be compared!");
for (int i = 0; i < sz; i++) { for (int i = 0; i < sz; i++) {
Byte thisBase = this.getBase(i); Byte thisBase = this.getBase(i);

View File

@ -7,6 +7,7 @@ import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import net.sf.samtools.SAMRecord; import net.sf.samtools.SAMRecord;
import net.sf.samtools.SAMReadGroupRecord; import net.sf.samtools.SAMReadGroupRecord;
import org.broadinstitute.sting.utils.exceptions.UserError;
import java.util.*; import java.util.*;
import java.io.File; import java.io.File;
@ -59,11 +60,12 @@ public class MatePairLibrarySize extends ReadWalker<Integer, Integer> {
String[] libraries = matePairSize.keySet().toArray(new String[1]); String[] libraries = matePairSize.keySet().toArray(new String[1]);
for (String library : libraries) { for (String library : libraries) {
File file = new File(String.format("%s/%s.pairdist", OUT_DIR.getAbsolutePath(), library));
try { try {
Integer[] sizes = matePairSize.get(library).keySet().toArray(new Integer[1]); Integer[] sizes = matePairSize.get(library).keySet().toArray(new Integer[1]);
if (sizes != null && sizes.length > 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); Arrays.sort(sizes);
pw.printf("%s\t%s%n", "insert", "frequency"); pw.printf("%s\t%s%n", "insert", "frequency");
@ -77,7 +79,7 @@ public class MatePairLibrarySize extends ReadWalker<Integer, Integer> {
pw.close(); pw.close();
} }
} catch (IOException e) { } catch (IOException e) {
throw new StingException("Unable to initialize output files."); throw new UserError.CouldNotCreateOutputFile(file, e);
} }
} }
} }

View File

@ -33,6 +33,7 @@ import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.By; import org.broadinstitute.sting.gatk.walkers.By;
import org.broadinstitute.sting.gatk.walkers.DataSource; import org.broadinstitute.sting.gatk.walkers.DataSource;
import org.broadinstitute.sting.gatk.walkers.LocusWalker; import org.broadinstitute.sting.gatk.walkers.LocusWalker;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.collections.Pair; import org.broadinstitute.sting.utils.collections.Pair;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
@ -90,7 +91,7 @@ public class CoverageAcrossBaitsWalker extends LocusWalker<Pair<Integer, Integer
IntervalRod intervalROD = tracker.lookup("interval",IntervalRod.class); IntervalRod intervalROD = tracker.lookup("interval",IntervalRod.class);
GenomeLoc interval = intervalROD == null ? null : intervalROD.getLocation(); GenomeLoc interval = intervalROD == null ? null : intervalROD.getLocation();
if (interval == null) { throw new StingException("No intervals at locus; should not happen"); } if (interval == null) { throw new GATKException("No intervals at locus; should not happen"); }
int offset = (int)(context.getPosition() - interval.getStart()); int offset = (int)(context.getPosition() - interval.getStart());
int depth[] = new int[2]; int depth[] = new int[2];

View File

@ -51,6 +51,7 @@ import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.collections.Pair; import org.broadinstitute.sting.utils.collections.Pair;
import org.broadinstitute.sting.commandline.Argument; import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output; import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.exceptions.UserError;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -120,7 +121,7 @@ public class HybSelPerformanceWalker extends LocusWalker<Integer, HybSelPerforma
try { try {
refseqIterator = new SeekableRODIterator(new FeatureToGATKFeatureIterator(refseq.iterator(), "refseq")); refseqIterator = new SeekableRODIterator(new FeatureToGATKFeatureIterator(refseq.iterator(), "refseq"));
} catch (IOException e) { } catch (IOException e) {
throw new StingException("Unable to open file " + REFSEQ_FILE, e); throw new UserError.CouldNotReadInputFile(REFSEQ_FILE, e);
} }
logger.info("Using RefSeq annotations from "+REFSEQ_FILE); logger.info("Using RefSeq annotations from "+REFSEQ_FILE);

View File

@ -25,6 +25,7 @@ package org.broadinstitute.sting.playground.gatk.walkers.phasing;
import org.broad.tribble.util.variantcontext.Allele; import org.broad.tribble.util.variantcontext.Allele;
import org.broad.tribble.util.variantcontext.Genotype; import org.broad.tribble.util.variantcontext.Genotype;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -35,7 +36,7 @@ public class Biallele {
public Biallele(Genotype gt) { public Biallele(Genotype gt) {
if (gt.getPloidy() != 2) if (gt.getPloidy() != 2)
throw new StingException("Biallele must have ploidy of 2!"); throw new GATKException("Biallele must have ploidy of 2!");
this.top = gt.getAllele(0); this.top = gt.getAllele(0);
this.bottom = gt.getAllele(1); this.bottom = gt.getAllele(1);

View File

@ -26,6 +26,7 @@ package org.broadinstitute.sting.playground.gatk.walkers.phasing;
import org.broad.tribble.util.variantcontext.Allele; import org.broad.tribble.util.variantcontext.Allele;
import org.broad.tribble.util.variantcontext.Genotype; import org.broad.tribble.util.variantcontext.Genotype;
import org.broadinstitute.sting.utils.BaseUtils; import org.broadinstitute.sting.utils.BaseUtils;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
public class BialleleSNP extends Biallele { public class BialleleSNP extends Biallele {
@ -34,9 +35,9 @@ public class BialleleSNP extends Biallele {
super(gt); super(gt);
if (getTopAllele().getBases().length != 1) if (getTopAllele().getBases().length != 1)
throw new StingException("LOGICAL ERROR: BialleleSNP may not contain non-SNP site!"); throw new GATKException("LOGICAL ERROR: BialleleSNP may not contain non-SNP site!");
if (getBottomAllele().getBases().length != 1) if (getBottomAllele().getBases().length != 1)
throw new StingException("LOGICAL ERROR: BialleleSNP may not contain non-SNP site!"); throw new GATKException("LOGICAL ERROR: BialleleSNP may not contain non-SNP site!");
} }
public byte getTopBase() { public byte getTopBase() {
@ -62,7 +63,7 @@ public class BialleleSNP extends Biallele {
else if (BaseUtils.basesAreEqual(base, botBase)) else if (BaseUtils.basesAreEqual(base, botBase))
return topBase; return topBase;
else else
throw new StingException("LOGICAL ERROR: base MUST match either TOP or BOTTOM!"); throw new GATKException("LOGICAL ERROR: base MUST match either TOP or BOTTOM!");
} }
public static byte getSingleBase(byte[] bases) { public static byte getSingleBase(byte[] bases) {

View File

@ -10,6 +10,7 @@ import org.broadinstitute.sting.gatk.datasources.simpleDataSources.ReferenceOrde
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.refdata.utils.GATKFeature; import org.broadinstitute.sting.gatk.refdata.utils.GATKFeature;
import org.broadinstitute.sting.gatk.walkers.*; import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import java.io.*; import java.io.*;
@ -49,7 +50,7 @@ public class RodSystemValidationWalker extends RodWalker<Integer,Integer> {
try { try {
digest = MessageDigest.getInstance("MD5"); digest = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
throw new StingException("Unable to find MD5 checksumer"); throw new GATKException("Unable to find MD5 checksumer");
} }
out.println("Header:"); out.println("Header:");
// enumerate the list of ROD's we've loaded // enumerate the list of ROD's we've loaded

View File

@ -49,6 +49,7 @@ import net.sf.samtools.SAMRecord;
import org.broadinstitute.sting.gatk.iterators.PushbackIterator; import org.broadinstitute.sting.gatk.iterators.PushbackIterator;
import org.broadinstitute.sting.utils.*; import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.sam.AlignmentUtils; import org.broadinstitute.sting.utils.sam.AlignmentUtils;
import org.broadinstitute.sting.utils.collections.Pair; import org.broadinstitute.sting.utils.collections.Pair;
@ -75,8 +76,8 @@ public class GenomicMap implements Iterable<Map.Entry<String, Collection<GenomeL
* @param c mapping of the custom contig sequence onto intervals on the master reference * @param c mapping of the custom contig sequence onto intervals on the master reference
*/ */
public void addCustomContig(String name, Collection<GenomeLoc> c) { public void addCustomContig(String name, Collection<GenomeLoc> c) {
if ( name == null ) throw new StingException("Custom contig name can not be null"); if ( name == null ) throw new GATKException("Custom contig name can not be null");
if ( map.containsKey(name)) throw new StingException("Custom contig "+name+" already exists"); if ( map.containsKey(name)) throw new GATKException("Custom contig "+name+" already exists");
map.put(name, c); map.put(name, c);
} }
@ -102,7 +103,7 @@ public class GenomicMap implements Iterable<Map.Entry<String, Collection<GenomeL
while( ( line = reader.readLine() ) != null ) { while( ( line = reader.readLine() ) != null ) {
String[] halves = line.split("#",2); String[] halves = line.split("#",2);
if ( halves.length < 2 ) if ( halves.length < 2 )
throw new StingException("Line: "+line+"\nin map file "+f+"\n does not contain contig name"); throw new UserError.MalformedFile(f, "Line: "+line+"\nin map file "+f+"\n does not contain contig name");
int p1 = 0; int p1 = 0;
for ( ; p1 < halves[1].length() && Character.isWhitespace(halves[1].charAt(p1) ); p1++ ); for ( ; p1 < halves[1].length() && Character.isWhitespace(halves[1].charAt(p1) ); p1++ );
@ -112,13 +113,13 @@ public class GenomicMap implements Iterable<Map.Entry<String, Collection<GenomeL
// p2 is index of first whitespace after first word // p2 is index of first whitespace after first word
if ( p1 == p2 ) if ( p1 == p2 )
throw new StingException("Line: "+line+"\n in map file "+f+"\nNo contig name found after '#'"); throw new UserError.MalformedFile(f, "Line: "+line+"\n in map file "+f+"\nNo contig name found after '#'");
String name = halves[1].substring(p1, p2); String name = halves[1].substring(p1, p2);
String[] coord_parts = halves[0].split("\\s"); String[] coord_parts = halves[0].split("\\s");
if ( coord_parts.length % 3 != 0 ) if ( coord_parts.length % 3 != 0 )
throw new StingException("Line: "+line+"\n in map file "+f+"\nNumber of coordinate fields is not a multiple of 3"); throw new UserError.MalformedFile(f, "Line: "+line+"\n in map file "+f+"\nNumber of coordinate fields is not a multiple of 3");
List<GenomeLoc> segments = new ArrayList<GenomeLoc>( coord_parts.length / 3 ); List<GenomeLoc> segments = new ArrayList<GenomeLoc>( coord_parts.length / 3 );
@ -135,9 +136,9 @@ public class GenomicMap implements Iterable<Map.Entry<String, Collection<GenomeL
} }
reader.close(); reader.close();
} catch ( FileNotFoundException e) { } catch ( FileNotFoundException e) {
throw new StingException("Can not find map file "+f); throw new UserError.CouldNotReadInputFile(f, e);
} catch (IOException e) { } catch (IOException e) {
throw new StingException("Failed while reading data from map file "+f); throw new UserError.CouldNotReadInputFile(f, e);
} }
} }
@ -182,14 +183,14 @@ public class GenomicMap implements Iterable<Map.Entry<String, Collection<GenomeL
p2 = p1; p2 = p1;
while ( p2 < line.length() && line.charAt(p2) != ',') p2++; // next comma or end-of-line while ( p2 < line.length() && line.charAt(p2) != ',') p2++; // next comma or end-of-line
} }
if ( segments.size() == 0 ) throw new StingException("Line "+line+" has no intervals specified"); if ( segments.size() == 0 ) throw new GATKException("Line "+line+" has no intervals specified");
addCustomContig(name, segments); addCustomContig(name, segments);
} }
reader.close(); reader.close();
} catch ( FileNotFoundException e) { } catch ( FileNotFoundException e) {
throw new StingException("Can not find map file "+f); throw new UserError.CouldNotReadInputFile(f, e);
} catch (IOException e) { } catch (IOException e) {
throw new StingException("Failed while reading data from map file "+f); throw new UserError.CouldNotReadInputFile(f, e);
} }
} }
@ -208,7 +209,7 @@ public class GenomicMap implements Iterable<Map.Entry<String, Collection<GenomeL
} }
writer.close(); writer.close();
} catch (IOException e) { } catch (IOException e) {
throw new StingException("Failed while writing data to map file "+f); throw new UserError.CouldNotCreateOutputFile(f, e);
} }
} }
@ -241,7 +242,7 @@ public class GenomicMap implements Iterable<Map.Entry<String, Collection<GenomeL
// get mapping from read's contig onto a "global" contig (as a list of intervals on the latter): // get mapping from read's contig onto a "global" contig (as a list of intervals on the latter):
Collection<GenomeLoc> segments = getContigMapping(r.getReferenceName()); Collection<GenomeLoc> 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: // scroll the list of intervals until we find the interval that the alignment start falls into:
Pair<? extends Iterator<GenomeLoc>, Integer> p = seekForward(segments,customStart); Pair<? extends Iterator<GenomeLoc>, Integer> p = seekForward(segments,customStart);
@ -277,7 +278,7 @@ public class GenomicMap implements Iterable<Map.Entry<String, Collection<GenomeL
case S: // soft clip case S: // soft clip
case H: // or hard clip - these are not included in getAlignmentStart, so pass them through case H: // or hard clip - these are not included in getAlignmentStart, so pass them through
if ( k != 0 && k != N-1 ) // paranoid if ( k != 0 && k != N-1 ) // paranoid
throw new StingException("Don't know what to do with S or N cigar element that is not at the either end of the cigar. Cigar: "+ throw new GATKException("Don't know what to do with S or N cigar element that is not at the either end of the cigar. Cigar: "+
r.getCigarString()); r.getCigarString());
case I: // insertions are passed through as well case I: // insertions are passed through as well
newCigar.add(new CigarElement(len,ce.getOperator())); newCigar.add(new CigarElement(len,ce.getOperator()));
@ -315,7 +316,7 @@ public class GenomicMap implements Iterable<Map.Entry<String, Collection<GenomeL
if ( discardCrossContig ) { if ( discardCrossContig ) {
// System.out.println("WARNING: ALIGNMENT DISCARDED: "+message); // System.out.println("WARNING: ALIGNMENT DISCARDED: "+message);
return null; return null;
} else throw new StingException(message); } else throw new UserError.MalformedBam(r, message);
} }
gl = iter.next(); // advance to next segment gl = iter.next(); // advance to next segment
@ -323,11 +324,11 @@ public class GenomicMap implements Iterable<Map.Entry<String, Collection<GenomeL
refPos = (int)gl.getStart(); // we jump to the start of next segment on the master ref refPos = (int)gl.getStart(); // we jump to the start of next segment on the master ref
if ( gl.getContigIndex() != r.getReferenceIndex() ) if ( gl.getContigIndex() != r.getReferenceIndex() )
throw new StingException("Contig "+oldRefName+ throw new UserError.MalformedBam(r, "Contig "+oldRefName+
" has segments on different master contigs: currently unsupported"); " has segments on different master contigs: currently unsupported");
if ( refPos < currStop + 1 ) if ( refPos < currStop + 1 )
throw new StingException("Contig "+oldRefName+ throw new UserError.MalformedBam(r, "Contig "+oldRefName+
" has segments that are out of order or strictly adjacent: currently unsupported"); " has segments that are out of order or strictly adjacent: currently unsupported");
if ( len > 0 && refPos > currStop + 1 ) { if ( len > 0 && refPos > currStop + 1 ) {
// add "panning" N's w/respect to the master ref over the region between adjacent segments // 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<Map.Entry<String, Collection<GenomeL
*/ */
private Pair<PushbackIterator<GenomeLoc>,Integer> seekForward(Collection<GenomeLoc> segments,int position) { private Pair<PushbackIterator<GenomeLoc>,Integer> seekForward(Collection<GenomeLoc> 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<GenomeLoc> iter = new PushbackIterator<GenomeLoc>(segments.iterator()); PushbackIterator<GenomeLoc> iter = new PushbackIterator<GenomeLoc>(segments.iterator());
@ -390,7 +391,7 @@ public class GenomicMap implements Iterable<Map.Entry<String, Collection<GenomeL
position -= length; position -= length;
} }
// if we get here, position is to the right of the last segment; not good. // if we get here, position is to the right of the last segment; not good.
throw new StingException("Position "+position + " is outside of custom contig boundaries"); throw new GATKException("Position "+position + " is outside of custom contig boundaries");
} }
private long contigLength(Collection<GenomeLoc> segments) { private long contigLength(Collection<GenomeLoc> segments) {

View File

@ -25,6 +25,7 @@
package org.broadinstitute.sting.playground.utils; package org.broadinstitute.sting.playground.utils;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.text.XReadLines; import org.broadinstitute.sting.utils.text.XReadLines;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -60,7 +61,7 @@ public class ProcessUtils {
return result; return result;
} catch (Exception e) { } catch (Exception e) {
throw new StingException("Error running command:" + command, e); throw new GATKException("Error running command:" + command, e);
} }
} }
} }

View File

@ -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.Analysis;
import org.broadinstitute.sting.playground.utils.report.tags.DataPoint; import org.broadinstitute.sting.playground.utils.report.tags.DataPoint;
import org.broadinstitute.sting.playground.utils.report.tags.Param; import org.broadinstitute.sting.playground.utils.report.tags.Param;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
@ -74,7 +75,7 @@ public class AnalysisModuleScanner {
/** scan the class and find all appropriate fields and tables */ /** scan the class and find all appropriate fields and tables */
public void scan() { public void scan() {
if (cls == null || !cls.isAnnotationPresent(Analysis.class)) 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"); "and must contain the @Analysis annotation, class " + cls + " was the input");
// get the annotation off of the class // get the annotation off of the class

View File

@ -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.templates.ReportFormat;
import org.broadinstitute.sting.playground.utils.report.utils.ComplexDataUtils; import org.broadinstitute.sting.playground.utils.report.utils.ComplexDataUtils;
import org.broadinstitute.sting.playground.utils.report.utils.Node; import org.broadinstitute.sting.playground.utils.report.utils.Node;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import java.io.*; import java.io.*;
@ -195,7 +196,7 @@ public class ReportMarshaller {
else else
node.addAllChildren(nodes); node.addAllChildren(nodes);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
throw new StingException("Unable to access field " + f); throw new GATKException("Unable to access field " + f);
} }
} }
} }

View File

@ -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.templates.*;
import org.broadinstitute.sting.playground.utils.report.utils.Node; import org.broadinstitute.sting.playground.utils.report.utils.Node;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
import java.io.*; import java.io.*;
import java.util.List; import java.util.List;
@ -84,13 +85,8 @@ public class VE2ReportFactory {
public static ReportFormat createByType(Class formatType) { public static ReportFormat createByType(Class formatType) {
try { try {
return ((Class<? extends ReportFormat>) formatType).newInstance(); return ((Class<? extends ReportFormat>) formatType).newInstance();
} } catch (Exception e) {
catch (InstantiationException ex) { throw new DynamicClassResolutionException(formatType, e);
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);
} }
} }
} }

View File

@ -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.playground.utils.report.utils.Node;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
@ -31,7 +32,7 @@ public class GrepFormat implements ReportFormat {
try { try {
stream = new PrintWriter(baseFile); stream = new PrintWriter(baseFile);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
throw new StingException("Unable to write to file " + baseFile, e); throw new UserError.CouldNotCreateOutputFile(baseFile, e);
} }
privateWrite(baseNode); privateWrite(baseNode);
} }

View File

@ -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.playground.utils.report.utils.Node;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
@ -36,7 +37,7 @@ public abstract class TableBasedFormat implements ReportFormat {
* @param baseNode the root node * @param baseNode the root node
*/ */
public void write(Writer writeLocation, Node baseNode) { 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 // if there is only a single output file, create it
stream = new PrintWriter(writeLocation); stream = new PrintWriter(writeLocation);
traverseAnalysisNodes(baseNode); traverseAnalysisNodes(baseNode);
@ -222,12 +223,13 @@ public abstract class TableBasedFormat implements ReportFormat {
*/ */
public void newStream(String analysisOrTableName) { public void newStream(String analysisOrTableName) {
String name = analysisOrTableName.replaceAll("\\s+","_").replaceAll("\\/","_slash_"); String name = analysisOrTableName.replaceAll("\\s+","_").replaceAll("\\/","_slash_");
File file = new File(this.baseLocation + "." + name + this.extension());
if (stream == null || splitFilesByAnalysis()) { if (stream == null || splitFilesByAnalysis()) {
if (stream != null) stream.close(); if (stream != null) stream.close();
try { try {
stream = new PrintWriter(this.baseLocation + "." + name + this.extension()); stream = new PrintWriter(file);
} catch (FileNotFoundException e) { } 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);
} }
} }
} }

View File

@ -1,6 +1,7 @@
package org.broadinstitute.sting.playground.utils.report.templates; package org.broadinstitute.sting.playground.utils.report.templates;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import java.io.IOException; import java.io.IOException;
import java.io.Writer; import java.io.Writer;
@ -103,7 +104,7 @@ class TextTable {
try { try {
writer.append("\n"); writer.append("\n");
} catch (IOException e) { } 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) if (y != rows.size() - 1)
writer.append(seperator); writer.append(seperator);
} catch (IOException e) { } 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);
} }
} }

View File

@ -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.io.stubs.SAMFileWriterArgumentTypeDescriptor;
import org.broadinstitute.sting.gatk.refdata.tracks.RMDTrackManager; import org.broadinstitute.sting.gatk.refdata.tracks.RMDTrackManager;
import org.broadinstitute.sting.gatk.walkers.Walker; import org.broadinstitute.sting.gatk.walkers.Walker;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import java.io.File; import java.io.File;
@ -94,7 +95,7 @@ public class GATKExtensionsGenerator extends CommandLineProgram {
protected int execute() { protected int execute() {
try { try {
if (!outputDirectory.isDirectory() && !outputDirectory.mkdirs()) 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()) { for (Class<? extends CommandLineProgram> clp: clpManager.getValues()) {

View File

@ -35,7 +35,7 @@ public class CardinalityCounter implements Iterator<int[]>, Iterable<int[]> {
public int[] next() { public int[] next() {
if (!hasNext()) if (!hasNext())
throw new StingException("CANNOT iterate past end!"); throw new GATKException("CANNOT iterate past end!");
// Copy the assignment to be returned: // Copy the assignment to be returned:
int[] nextList = new int[valList.length]; int[] nextList = new int[valList.length];

View File

@ -164,7 +164,7 @@ public class GenomeLoc implements Comparable<GenomeLoc>, Cloneable, Serializable
public GenomeLoc merge( GenomeLoc that ) throws GATKException { public GenomeLoc merge( GenomeLoc that ) throws GATKException {
if (!(this.contiguousP(that))) { 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, return new GenomeLoc(getContig(), this.contigIndex,
@ -174,7 +174,7 @@ public class GenomeLoc implements Comparable<GenomeLoc>, Cloneable, Serializable
public GenomeLoc intersect( GenomeLoc that ) throws GATKException { public GenomeLoc intersect( GenomeLoc that ) throws GATKException {
if (!(this.overlapsP(that))) { 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, return new GenomeLoc(getContig(), this.contigIndex,

View File

@ -193,13 +193,13 @@ public class GenomeLocParser {
stop = parsePosition(str.substring(dashIndex + 1)); stop = parsePosition(str.substring(dashIndex + 1));
} }
} catch(Exception e) { } 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? // is the contig valid?
if (!isContigValid(contig)) 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()) if (stop == Integer.MAX_VALUE && hasKnownContigOrdering())
// lookup the actually stop position! // lookup the actually stop position!
@ -319,13 +319,7 @@ public class GenomeLocParser {
*/ */
public static List<GenomeLoc> intervalFileToList(final String file_name) { public static List<GenomeLoc> intervalFileToList(final String file_name) {
// try to open file // try to open file
File inputFile = null; File inputFile = new File(file_name);
try {
inputFile = new File(file_name);
}
catch (Exception e) {
throw new StingException("Could not open file", e);
}
// check if file is empty // check if file is empty
if (inputFile.exists() && inputFile.length() < 1) { if (inputFile.exists() && inputFile.length() < 1) {
@ -377,7 +371,7 @@ public class GenomeLocParser {
return ret.isEmpty() ? null : ret; return ret.isEmpty() ? null : ret;
} }
catch (IOException e2) { 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) { public static GenomeLoc createGenomeLoc(int contigIndex, final long start, final long stop) {
checkSetup(); checkSetup();
if (start < 0) { if (start < 0) {
throw new StingException("Bad start position " + start); throw new GATKException("Bad start position " + start);
} }
if (stop < -1) { 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 } // a negative -1 indicates it's not a meaningful end position
@ -503,16 +497,16 @@ public class GenomeLocParser {
*/ */
private static GenomeLoc exceptionOnInvalidGenomeLoc(GenomeLoc toReturn) { private static GenomeLoc exceptionOnInvalidGenomeLoc(GenomeLoc toReturn) {
if (toReturn.getStart() < 0) { 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)) { 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) { 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()) { 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; return toReturn;
@ -533,11 +527,11 @@ public class GenomeLocParser {
private static void exceptionOnInvalidGenomeLocBounds(GenomeLoc locus) { private static void exceptionOnInvalidGenomeLocBounds(GenomeLoc locus) {
int contigSize = contigInfo.getSequence(locus.getContigIndex()).getSequenceLength(); int contigSize = contigInfo.getSequence(locus.getContigIndex()).getSequenceLength();
if(locus.getStart() > contigSize) 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) 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()) { 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; int index = -1;
if ((index = contigInfo.getSequenceIndex(contig)) < 0) { 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())); 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) { public static GenomeLoc setContigIndex(GenomeLoc loc, int contig) {
checkSetup(); checkSetup();
if ((contig >= GenomeLocParser.contigInfo.getSequences().size()) || (contig < 0)) { 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())); 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 */ /** check to make sure that we've setup the contig information */
private static void checkSetup() { private static void checkSetup() {
if (contigInfo == null) { 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");
} }
} }

View File

@ -109,7 +109,7 @@ public class GenomeLocSortedSet extends AbstractSet<GenomeLoc> {
} else { } else {
int loc = Collections.binarySearch(mArray,e); int loc = Collections.binarySearch(mArray,e);
if (loc >= 0) { 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 { } else {
mArray.add((loc+1) * -1,e); mArray.add((loc+1) * -1,e);
return true; return true;
@ -193,7 +193,7 @@ public class GenomeLocSortedSet extends AbstractSet<GenomeLoc> {
} else if ( e.getStop() < p.getStart() ) { } else if ( e.getStop() < p.getStart() ) {
toExclude.pop(); // p starts after e stops, e is done toExclude.pop(); // p starts after e stops, e is done
} else { } 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 ) if ( i++ % 10000 == 0 )

View File

@ -40,7 +40,7 @@ public class HeapSizeMonitor {
monitorThread.join(); monitorThread.join();
} }
catch(InterruptedException ex) { catch(InterruptedException ex) {
throw new StingException("Unable to connect to monitor thread"); throw new GATKException("Unable to connect to monitor thread");
} }
monitorThread = null; monitorThread = null;
} }
@ -72,7 +72,7 @@ public class HeapSizeMonitor {
Thread.sleep(monitorFrequencyMillis); Thread.sleep(monitorFrequencyMillis);
} }
catch(InterruptedException ex) { catch(InterruptedException ex) {
throw new StingException("Unable to continue monitoring heap consumption",ex); throw new GATKException("Unable to continue monitoring heap consumption",ex);
} }
} }
} }

View File

@ -17,7 +17,7 @@ package org.broadinstitute.sting.utils;
* bad sequence id out of bounds, etc. * 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. * Create a new MalformedGenomeLocException with the given message. Does not preserve the existing stack trace.
* @param message The message. * @param message The message.

View File

@ -112,7 +112,7 @@ public class PathUtils {
} }
if (dir.listFiles() == null) { 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.");
} }
} }

View File

@ -35,7 +35,7 @@ public class ReservoirDownsampler<T> {
*/ */
public ReservoirDownsampler(final int maxElements) { public ReservoirDownsampler(final int maxElements) {
if(maxElements < 0) 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<T>(maxElements); this.reservoir = new ArrayList<T>(maxElements);
this.maxElements = maxElements; this.maxElements = maxElements;
} }

View File

@ -185,7 +185,7 @@ public class WilcoxonRankSum {
U = n1 < n2 ? U1 : U2; U = n1 < n2 ? U1 : U2;
break; break;
default: default:
throw new StingException("Unexpected WILCOXON H0: " + h0); throw new GATKException("Unexpected WILCOXON H0: " + h0);
} }
// data is nA nB then // data is nA nB then
@ -232,7 +232,7 @@ public class WilcoxonRankSum {
pvalue = NORMAL.cdf(z); pvalue = NORMAL.cdf(z);
break; break;
default: default:
throw new StingException("Unexpected WILCOXON H0: " + h0); throw new GATKException("Unexpected WILCOXON H0: " + h0);
} }
return pvalue; return pvalue;

View File

@ -1,5 +1,6 @@
package org.broadinstitute.sting.utils.bed; 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.interval.IntervalMergingRule;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLoc;
@ -33,7 +34,7 @@ public class BedParser {
try { try {
mIn = new BufferedReader(new FileReader(fl)); mIn = new BufferedReader(new FileReader(fl));
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
throw new StingException("Unable to open the bed file = " + fl); throw new UserError.CouldNotReadInputFile(fl, e);
} }
mLocations = parseLocations(); mLocations = parseLocations();
} }
@ -61,7 +62,7 @@ public class BedParser {
locArray.add(parseLocation(line)); locArray.add(parseLocation(line));
} }
} catch (IOException e) { } 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; return locArray;
} }
@ -82,7 +83,7 @@ public class BedParser {
start = Integer.valueOf(parts[1]) + TO_ONE_BASED_ADDITION; start = Integer.valueOf(parts[1]) + TO_ONE_BASED_ADDITION;
stop = Integer.valueOf(parts[2]); // the ending point is an open interval stop = Integer.valueOf(parts[2]); // the ending point is an open interval
} catch (Exception e) { } 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 // we currently drop the rest of the bed record, which can contain names, scores, etc

View File

@ -25,6 +25,7 @@
package org.broadinstitute.sting.utils.classloader; package org.broadinstitute.sting.utils.classloader;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
@ -127,7 +128,7 @@ public class JVMUtils {
field.set(instance, value); field.set(instance, value);
} }
catch( IllegalAccessException ex ) { 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); return field.get(instance);
} }
catch( IllegalAccessException ex ) { 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()));
} }
} }

View File

@ -28,7 +28,9 @@ package org.broadinstitute.sting.utils.classloader;
import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.LoggerContext;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
import org.reflections.Reflections; import org.reflections.Reflections;
import org.reflections.scanners.SubTypesScanner; import org.reflections.scanners.SubTypesScanner;
import org.reflections.util.ClasspathHelper; import org.reflections.util.ClasspathHelper;
@ -95,10 +97,8 @@ public class PackageUtils {
public static <T> T getSimpleInstance(Class<T> c) { public static <T> T getSimpleInstance(Class<T> c) {
try { try {
return c.newInstance(); return c.newInstance();
} catch (InstantiationException e) { } catch (Exception e) {
throw new StingException(String.format("Cannot instantiate class '%s': must be concrete class", c.getSimpleName())); throw new DynamicClassResolutionException(c, e);
} catch (IllegalAccessException e) {
throw new StingException(String.format("Cannot instantiate class '%s': must have no-arg constructor", c.getSimpleName()));
} }
} }
@ -138,7 +138,7 @@ public class PackageUtils {
method.invoke(ClassLoader.getSystemClassLoader(), url); method.invoke(ClassLoader.getSystemClassLoader(), url);
resetReflections(); resetReflections();
} catch (Exception e) { } 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);
} }
} }

View File

@ -25,8 +25,10 @@
package org.broadinstitute.sting.utils.classloader; package org.broadinstitute.sting.utils.classloader;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.classloader.PackageUtils; import org.broadinstitute.sting.utils.classloader.PackageUtils;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -84,17 +86,13 @@ public abstract class PluginManager<PluginType> {
* @return The plugin object if found; null otherwise. * @return The plugin object if found; null otherwise.
*/ */
public PluginType createByName(String pluginName) { public PluginType createByName(String pluginName) {
Class<? extends PluginType> plugin = pluginsByName.get(pluginName);
try { try {
Class<? extends PluginType> plugin = pluginsByName.get(pluginName);
if( plugin == null ) 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(); return plugin.newInstance();
} } catch (Exception e) {
catch( InstantiationException ex ) { throw new DynamicClassResolutionException(plugin, e);
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);
} }
} }
@ -107,12 +105,8 @@ public abstract class PluginManager<PluginType> {
public PluginType createByType(Class pluginType) { public PluginType createByType(Class pluginType) {
try { try {
return ((Class<? extends PluginType>) pluginType).newInstance(); return ((Class<? extends PluginType>) pluginType).newInstance();
} } catch (Exception e) {
catch( InstantiationException ex ) { throw new DynamicClassResolutionException(pluginType, e);
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);
} }
} }

View File

@ -25,6 +25,7 @@
package org.broadinstitute.sting.utils.collections; package org.broadinstitute.sting.utils.collections;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
@ -69,7 +70,7 @@ public class CircularArray <T> {
/** Creates an array of fixed length */ /** Creates an array of fixed length */
public CircularArray(int 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]; data = new Object[length];
offset = 0; offset = 0;
} }
@ -150,7 +151,7 @@ public class CircularArray <T> {
/** Creates an array of fixed length */ /** Creates an array of fixed length */
public Int(int 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 data = new int[length]; // automaticaly initialized to zeros
offset = 0; offset = 0;
} }

View File

@ -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.LocationAwareSeekableRODIterator;
import org.broadinstitute.sting.gatk.refdata.utils.RODRecordList; 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.GenomeLoc;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
@ -42,10 +43,10 @@ public class MergingIterator implements Iterator<RODRecordList>, Iterable<RODRec
public Element(Iterator<RODRecordList> it) { public Element(Iterator<RODRecordList> it) {
if ( it instanceof LocationAwareSeekableRODIterator) { if ( it instanceof LocationAwareSeekableRODIterator) {
this.it = (LocationAwareSeekableRODIterator)it; this.it = (LocationAwareSeekableRODIterator)it;
if ( ! it.hasNext() ) throw new StingException("Iterator is empty"); if ( ! it.hasNext() ) throw new GATKException("Iterator is empty");
update(); update();
} else { } else {
throw new StingException("Iterator passed to MergingIterator is not LocationAwareSeekableRODIterator"); throw new GATKException("Iterator passed to MergingIterator is not LocationAwareSeekableRODIterator");
} }
} }

View File

@ -40,7 +40,7 @@ public class DupUtils {
try { try {
return (SAMRecord)read.clone(); return (SAMRecord)read.clone();
} catch ( CloneNotSupportedException e ) { } catch ( CloneNotSupportedException e ) {
throw new StingException("Unexpected Clone failure!"); throw new GATKException("Unexpected Clone failure!");
} }
} }

View File

@ -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";
}
}
}

View File

@ -27,9 +27,11 @@ package org.broadinstitute.sting.utils.exceptions;
import net.sf.samtools.SAMFileHeader; import net.sf.samtools.SAMFileHeader;
import net.sf.samtools.SAMRecord; import net.sf.samtools.SAMRecord;
import net.sf.samtools.SAMSequenceDictionary; import net.sf.samtools.SAMSequenceDictionary;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import java.io.File; import java.io.File;
import java.lang.reflect.InvocationTargetException;
/** /**
* Represents the common user errors detected by Sting / GATK * Represents the common user errors detected by Sting / GATK
@ -40,7 +42,7 @@ import java.io.File;
* Date: Sep 3, 2010 * Date: Sep 3, 2010
* Time: 2:24:09 PM * 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) { super(msg); }
public UserError(String msg, Throwable e) { super(msg, e); } public UserError(String msg, Throwable e) { super(msg, e); }
private UserError(Throwable e) { super("", e); } // cannot be called, private access 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 // todo -- fix up exception cause passing
public static class MissingArgument extends CommandLineError { public static class MissingArgument extends CommandLineError {
public MissingArgument(String arg, String message) { public MissingArgument(String arg, String message) {
@ -156,7 +164,11 @@ public class UserError extends StingException {
public MalformedFile(File f, String message, Exception e) { public MalformedFile(File f, String message, Exception e) {
super(String.format("File %s is malformed: %s caused by %s", f.getAbsolutePath(), message, e.getMessage())); 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 static class CannotExecuteRScript extends UserError {
public CannotExecuteRScript(String message, Exception e) { 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)); super(String.format("Walker %s is not available: %s", walkerName, message));
} }
} }
} }

View File

@ -1,5 +1,6 @@
package org.broadinstitute.sting.utils.fasta; package org.broadinstitute.sting.utils.fasta;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
@ -34,7 +35,7 @@ public class ArtificialFastaUtils {
try { try {
s = new PrintStream(new FileOutputStream(fileName)); s = new PrintStream(new FileOutputStream(fileName));
} catch (FileNotFoundException e) { } 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); generateFakeFasta(contigNames, contigSizes, pattern, s);
} }
@ -58,7 +59,7 @@ public class ArtificialFastaUtils {
*/ */
private static void generateFakeFasta(List<String> contigNames, List<Integer> contigSizes, BASE_PATTERN pattern, PrintStream s) { private static void generateFakeFasta(List<String> contigNames, List<Integer> contigSizes, BASE_PATTERN pattern, PrintStream s) {
if (contigNames.size() != contigSizes.size()) { 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++) { for (int x = 0; x < contigNames.size(); x++) {
ArtificialContig tig = new ArtificialContig(contigNames.get(x), contigSizes.get(x), pattern); ArtificialContig tig = new ArtificialContig(contigNames.get(x), contigSizes.get(x), pattern);
@ -122,7 +123,7 @@ class ArtificialContig {
case ALL_G: case ALL_G:
return "G"; return "G";
default: default:
throw new StingException("Unknown base pattern"); throw new GATKException("Unknown base pattern");
} }
} }

View File

@ -1,6 +1,7 @@
package org.broadinstitute.sting.utils.fastq; package org.broadinstitute.sting.utils.fastq;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import java.util.Iterator; import java.util.Iterator;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
@ -23,7 +24,7 @@ public class FastqReader implements Iterator<FastqRecord>, Iterable<FastqRecord>
nextRecord = readNextRecord(); nextRecord = readNextRecord();
} catch (IOException e) { } 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<FastqRecord>, Iterable<FastqRecord>
return new FastqRecord(seqHeader, seqLine, qualHeader, qualLine); return new FastqRecord(seqHeader, seqLine, qualHeader, qualLine);
} catch (IOException e) { } 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<FastqRecord>, Iterable<FastqRecord>
nextRecord = null; nextRecord = null;
} }
} catch (IOException e) { } catch (IOException e) {
throw new StingException("IO problem"); throw new UserError.CouldNotReadInputFile(fastqFile, e);
} }
return rec; return rec;
@ -66,7 +67,7 @@ public class FastqReader implements Iterator<FastqRecord>, Iterable<FastqRecord>
try { try {
in.close(); in.close();
} catch (IOException e) { } catch (IOException e) {
throw new UserError.CouldNotReadInputFile(fastqFile, e);
} }
} }
} }

View File

@ -1,6 +1,7 @@
package org.broadinstitute.sting.utils.file; package org.broadinstitute.sting.utils.file;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import java.io.File; import java.io.File;
@ -143,7 +144,7 @@ public class FSLockWithShared {
channel.close(); channel.close();
} }
catch (Exception e) { catch (Exception e) {
throw new StingException("An error occurred while unlocking file", e); throw new GATKException("An error occurred while unlocking file", e);
} }
} }
} }

View File

@ -3,6 +3,7 @@ package org.broadinstitute.sting.utils.genotype;
import edu.mit.broad.picard.genotype.DiploidGenotype; import edu.mit.broad.picard.genotype.DiploidGenotype;
import edu.mit.broad.picard.genotype.geli.GenotypeLikelihoods; import edu.mit.broad.picard.genotype.geli.GenotypeLikelihoods;
import net.sf.samtools.SAMFileHeader; import net.sf.samtools.SAMFileHeader;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import java.util.HashMap; import java.util.HashMap;
@ -234,15 +235,15 @@ public class LikelihoodObject {
switch (mLikelihoodType) { switch (mLikelihoodType) {
case NEGATIVE_LOG: case NEGATIVE_LOG:
if (score < 0) 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; break;
case LOG: case LOG:
if (score > 0) 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; break;
case RAW: case RAW:
if (score < 0 || score > 1) 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; break;
} }
} }

View File

@ -3,7 +3,9 @@ package org.broadinstitute.sting.utils.genotype.glf;
import net.sf.samtools.util.BinaryCodec; import net.sf.samtools.util.BinaryCodec;
import net.sf.samtools.util.BlockCompressedInputStream; import net.sf.samtools.util.BlockCompressedInputStream;
import net.sf.samtools.util.RuntimeEOFException; import net.sf.samtools.util.RuntimeEOFException;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.genotype.LikelihoodObject; import org.broadinstitute.sting.utils.genotype.LikelihoodObject;
import java.io.DataInputStream; import java.io.DataInputStream;
@ -63,23 +65,28 @@ public class GLFReader implements Iterator<GLFRecord> {
// we have this variable becuase there is no eof for glf's // we have this variable becuase there is no eof for glf's
private int lastRecordType = -1; private int lastRecordType = -1;
private File myFile;
/** /**
* create a glf reader * create a glf reader
* *
* @param readFrom the file to read from * @param readFrom the file to read from
*/ */
public GLFReader(File readFrom) { public GLFReader(File readFrom) {
myFile = readFrom;
try { try {
inputBinaryCodec = new BinaryCodec(new DataInputStream(new BlockCompressedInputStream(readFrom))); inputBinaryCodec = new BinaryCodec(new DataInputStream(new BlockCompressedInputStream(readFrom)));
} catch (IOException e) { } catch (IOException e) {
throw new StingException("Unable to open " + readFrom.getName(), e); throw new UserError.CouldNotReadInputFile(myFile, e);
} }
inputBinaryCodec.setInputFileName(readFrom.getName()); inputBinaryCodec.setInputFileName(readFrom.getName());
// first verify that it's a valid GLF // first verify that it's a valid GLF
for (short s : glfMagic) { for (short s : glfMagic) {
if (inputBinaryCodec.readUByte() != s) 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 // get the header string
@ -170,7 +177,7 @@ public class GLFReader implements Iterator<GLFRecord> {
} }
//nextRecord = null; //nextRecord = null;
} else { } 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(); if (nextRecord != null) currentLocation = nextRecord.getPosition();
return ret; return ret;
@ -219,7 +226,7 @@ public class GLFReader implements Iterator<GLFRecord> {
} }
public void remove() { public void remove() {
throw new StingException("GLFReader doesn't support remove()"); throw new GATKException("GLFReader doesn't support remove()");
} }
public void close() { public void close() {

View File

@ -1,6 +1,7 @@
package org.broadinstitute.sting.utils.genotype.glf; package org.broadinstitute.sting.utils.genotype.glf;
import net.sf.samtools.util.BinaryCodec; import net.sf.samtools.util.BinaryCodec;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
@ -251,7 +252,7 @@ public abstract class GLFRecord {
* @return the minimum value * @return the minimum value
*/ */
protected static double findMin(double vals[]) { 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]; double min = vals[0];
for (double d : vals) for (double d : vals)

View File

@ -25,6 +25,7 @@
package org.broadinstitute.sting.utils.help; package org.broadinstitute.sting.utils.help;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.classloader.JVMUtils; import org.broadinstitute.sting.utils.classloader.JVMUtils;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.commandline.CommandLineProgram; import org.broadinstitute.sting.commandline.CommandLineProgram;
@ -80,7 +81,7 @@ public class ApplicationDetails {
runningInstructions = JVMUtils.getLocationFor( application ).getName(); runningInstructions = JVMUtils.getLocationFor( application ).getName();
} }
catch( IOException ex ) { 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") ) if( runningInstructions.endsWith(".jar") )

View File

@ -31,6 +31,7 @@ import java.util.*;
import java.io.PrintStream; import java.io.PrintStream;
import java.io.IOException; import java.io.IOException;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.classloader.JVMUtils; import org.broadinstitute.sting.utils.classloader.JVMUtils;
import org.broadinstitute.sting.utils.Utils; import org.broadinstitute.sting.utils.Utils;
@ -181,7 +182,7 @@ public class ResourceBundleExtractorDoclet {
for(Tag tag: element.tags()) { for(Tag tag: element.tags()) {
if(tag.name().equals("@"+DisplayNameTaglet.NAME)) { if(tag.name().equals("@"+DisplayNameTaglet.NAME)) {
if(name != null) 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(); name = tag.text();
} }
else if(tag.name().equals("@"+VERSION_TAGLET_NAME)) else if(tag.name().equals("@"+VERSION_TAGLET_NAME))

View File

@ -24,6 +24,7 @@
package org.broadinstitute.sting.utils.instrumentation; package org.broadinstitute.sting.utils.instrumentation;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import java.lang.instrument.Instrumentation; import java.lang.instrument.Instrumentation;
@ -73,7 +74,7 @@ public class Sizeof {
*/ */
public static long getObjectSize(Object o) { public static long getObjectSize(Object o) {
if(!isEnabled()) 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); return instrumentation.getObjectSize(o);
} }
@ -84,7 +85,7 @@ public class Sizeof {
*/ */
public static long getObjectGraphSize(Object o) { public static long getObjectGraphSize(Object o) {
if(!isEnabled()) 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<Object,Object> objectsSeen = new IdentityHashMap<Object,Object>(); IdentityHashMap<Object,Object> objectsSeen = new IdentityHashMap<Object,Object>();
return getObjectGraphSize(o,objectsSeen); return getObjectGraphSize(o,objectsSeen);
} }
@ -134,7 +135,7 @@ public class Sizeof {
fieldValue = field.get(o); fieldValue = field.get(o);
} }
catch(IllegalAccessException ex) { catch(IllegalAccessException ex) {
throw new StingException("Unable to access field " + field.getName(),ex); throw new GATKException("Unable to access field " + field.getName(),ex);
} }
totalSize += getObjectGraphSize(fieldValue,objectsSeen); totalSize += getObjectGraphSize(fieldValue,objectsSeen);
} }

View File

@ -27,6 +27,7 @@ package org.broadinstitute.sting.utils.interval;
import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.text.XReadLines; import org.broadinstitute.sting.utils.text.XReadLines;
import org.broadinstitute.sting.gatk.iterators.PushbackIterator; import org.broadinstitute.sting.gatk.iterators.PushbackIterator;
import org.broadinstitute.sting.gatk.refdata.utils.StringToGenomeLocIteratorAdapter; import org.broadinstitute.sting.gatk.refdata.utils.StringToGenomeLocIteratorAdapter;
@ -52,11 +53,13 @@ import java.io.FileNotFoundException;
* iterator is a merging one). * iterator is a merging one).
*/ */
public class IntervalFileMergingIterator implements Iterator<GenomeLoc> { public class IntervalFileMergingIterator implements Iterator<GenomeLoc> {
private PushbackIterator<GenomeLoc> it ; private PushbackIterator<GenomeLoc> it ;
private IntervalMergingRule myRule; private IntervalMergingRule myRule;
private File myFile;
public IntervalFileMergingIterator(File f, IntervalMergingRule rule) { public IntervalFileMergingIterator(File f, IntervalMergingRule rule) {
myFile = f;
try { try {
XReadLines reader = new XReadLines(f); XReadLines reader = new XReadLines(f);
@ -68,7 +71,7 @@ public class IntervalFileMergingIterator implements Iterator<GenomeLoc> {
StringToGenomeLocIteratorAdapter.FORMAT.GATK ) ) ; StringToGenomeLocIteratorAdapter.FORMAT.GATK ) ) ;
} }
} catch ( FileNotFoundException e ) { } catch ( FileNotFoundException e ) {
throw new StingException("Can not open interval file "+f); throw new UserError.CouldNotReadInputFile(f, e);
} }
myRule = rule; myRule = rule;
} }
@ -91,7 +94,7 @@ public class IntervalFileMergingIterator implements Iterator<GenomeLoc> {
GenomeLoc next = it.next(); GenomeLoc next = it.next();
if ( next.isBefore(current)) { if ( next.isBefore(current)) {
throw new StingException("Interval "+next+" in the interval file is out of order."); throw new UserError.MalformedFile(myFile, "Interval "+next+" in the interval file is out of order.");
} }
if (current.overlapsP(next)) { if (current.overlapsP(next)) {

View File

@ -4,6 +4,7 @@ import org.broadinstitute.sting.utils.GenomeLocSortedSet;
import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.GenomeLocParser; import org.broadinstitute.sting.utils.GenomeLocParser;
import org.broadinstitute.sting.utils.exceptions.UserError;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -39,7 +40,7 @@ public class IntervalUtils {
if (argument.equals("all")) { if (argument.equals("all")) {
if (argList.size() != 1) { if (argList.size() != 1) {
// throw error if '-L all' is not only interval - potentially conflicting commands // throw error if '-L all' is not only interval - potentially conflicting commands
throw new StingException(String.format("Conflicting arguments: Intervals given along with \"-L all\"")); throw new UserError.CommandLineError(String.format("Conflicting arguments: Intervals given along with \"-L all\""));
} }
return null; return null;
} }
@ -53,9 +54,7 @@ public class IntervalUtils {
rawIntervals.addAll(GenomeLocParser.intervalFileToList(fileOrInterval)); rawIntervals.addAll(GenomeLocParser.intervalFileToList(fileOrInterval));
} }
catch (Exception e) { catch (Exception e) {
throw new StingException(String.format("Interval file %s could not be parsed in either format. " + throw new UserError.MalformedFile(fileOrInterval, "Interval file could not be parsed in either format.", e);
"The problem is:%n%s",
fileOrInterval, e.getMessage()), e);
} }
} }
@ -147,11 +146,11 @@ public class IntervalUtils {
if (file.exists()) if (file.exists())
return true; return true;
else else
throw new StingException(String.format("The interval file %s does not exist.", file.getAbsolutePath())); throw new UserError.CouldNotReadInputFile(file, "The interval file does not exist.");
} }
if(file.exists()) if(file.exists())
throw new StingException(String.format("The interval file %s does not have one of " + throw new UserError.CouldNotReadInputFile(file, String.format("The interval file %s does not have one of " +
"the supported extensions (.bed, .list, .picard, .interval_list, or .intervals). " + "the supported extensions (.bed, .list, .picard, .interval_list, or .intervals). " +
"Please rename your file with the appropriate extension. If %s is NOT supposed to be a file, " + "Please rename your file with the appropriate extension. If %s is NOT supposed to be a file, " +
"please move or rename the file at location %s", str, str, file.getAbsolutePath())); "please move or rename the file at location %s", str, str, file.getAbsolutePath()));

View File

@ -25,6 +25,7 @@
package org.broadinstitute.sting.utils.pileup; package org.broadinstitute.sting.utils.pileup;
import net.sf.samtools.SAMReadGroupRecord; import net.sf.samtools.SAMReadGroupRecord;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.BaseUtils; import org.broadinstitute.sting.utils.BaseUtils;
@ -83,8 +84,8 @@ public abstract class AbstractReadBackedPileup<RBP extends AbstractReadBackedPil
* *
*/ */
public AbstractReadBackedPileup(GenomeLoc loc, List<PE> pileup) { public AbstractReadBackedPileup(GenomeLoc loc, List<PE> pileup) {
if ( loc == null ) throw new StingException("Illegal null genomeloc in ReadBackedPileup"); if ( loc == null ) throw new GATKException("Illegal null genomeloc in ReadBackedPileup");
if ( pileup == null ) throw new StingException("Illegal null pileup in ReadBackedPileup"); if ( pileup == null ) throw new GATKException("Illegal null pileup in ReadBackedPileup");
this.loc = loc; this.loc = loc;
this.pileupElementTracker = new UnifiedPileupElementTracker<PE>(pileup); this.pileupElementTracker = new UnifiedPileupElementTracker<PE>(pileup);
@ -97,8 +98,8 @@ public abstract class AbstractReadBackedPileup<RBP extends AbstractReadBackedPil
* @param pileup * @param pileup
*/ */
public AbstractReadBackedPileup(GenomeLoc loc, List<PE> pileup, int size, int nDeletions, int nMQ0Reads) { public AbstractReadBackedPileup(GenomeLoc loc, List<PE> pileup, int size, int nDeletions, int nMQ0Reads) {
if ( loc == null ) throw new StingException("Illegal null genomeloc in UnifiedReadBackedPileup"); if ( loc == null ) throw new GATKException("Illegal null genomeloc in UnifiedReadBackedPileup");
if ( pileup == null ) throw new StingException("Illegal null pileup in UnifiedReadBackedPileup"); if ( pileup == null ) throw new GATKException("Illegal null pileup in UnifiedReadBackedPileup");
this.loc = loc; this.loc = loc;
this.pileupElementTracker = new UnifiedPileupElementTracker<PE>(pileup); this.pileupElementTracker = new UnifiedPileupElementTracker<PE>(pileup);
@ -159,9 +160,9 @@ public abstract class AbstractReadBackedPileup<RBP extends AbstractReadBackedPil
* @return * @return
*/ */
private PileupElementTracker<PE> readsOffsets2Pileup(List<SAMRecord> reads, List<Integer> offsets ) { private PileupElementTracker<PE> readsOffsets2Pileup(List<SAMRecord> reads, List<Integer> offsets ) {
if ( reads == null ) throw new StingException("Illegal null read list in UnifiedReadBackedPileup"); if ( reads == null ) throw new GATKException("Illegal null read list in UnifiedReadBackedPileup");
if ( offsets == null ) throw new StingException("Illegal null offsets list in UnifiedReadBackedPileup"); if ( offsets == null ) throw new GATKException("Illegal null offsets list in UnifiedReadBackedPileup");
if ( reads.size() != offsets.size() ) throw new StingException("Reads and offset lists have different sizes!"); if ( reads.size() != offsets.size() ) throw new GATKException("Reads and offset lists have different sizes!");
UnifiedPileupElementTracker<PE> pileup = new UnifiedPileupElementTracker<PE>(); UnifiedPileupElementTracker<PE> pileup = new UnifiedPileupElementTracker<PE>();
for ( int i = 0; i < reads.size(); i++ ) { for ( int i = 0; i < reads.size(); i++ ) {
@ -179,8 +180,8 @@ public abstract class AbstractReadBackedPileup<RBP extends AbstractReadBackedPil
* @return * @return
*/ */
private PileupElementTracker<PE> readsOffsets2Pileup(List<SAMRecord> reads, int offset ) { private PileupElementTracker<PE> readsOffsets2Pileup(List<SAMRecord> reads, int offset ) {
if ( reads == null ) throw new StingException("Illegal null read list in UnifiedReadBackedPileup"); if ( reads == null ) throw new GATKException("Illegal null read list in UnifiedReadBackedPileup");
if ( offset < 0 ) throw new StingException("Illegal offset < 0 UnifiedReadBackedPileup"); if ( offset < 0 ) throw new GATKException("Illegal offset < 0 UnifiedReadBackedPileup");
UnifiedPileupElementTracker<PE> pileup = new UnifiedPileupElementTracker<PE>(); UnifiedPileupElementTracker<PE> pileup = new UnifiedPileupElementTracker<PE>();
for ( int i = 0; i < reads.size(); i++ ) { for ( int i = 0; i < reads.size(); i++ ) {

View File

@ -23,6 +23,7 @@
*/ */
package org.broadinstitute.sting.utils.pileup; package org.broadinstitute.sting.utils.pileup;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.collections.Pair; import org.broadinstitute.sting.utils.collections.Pair;
@ -140,7 +141,7 @@ public class ReadBackedExtendedEventPileupImpl extends AbstractReadBackedPileup<
case INSERTION: v[i] = 'I'; break; case INSERTION: v[i] = 'I'; break;
case DELETION: v[i] = 'D'; break; case DELETION: v[i] = 'D'; break;
case NOEVENT: v[i] = '.'; break; case NOEVENT: v[i] = '.'; break;
default: throw new StingException("Unknown event type encountered: "+e.getType()); default: throw new GATKException("Unknown event type encountered: "+e.getType());
} }
i++; i++;
} }
@ -190,7 +191,7 @@ public class ReadBackedExtendedEventPileupImpl extends AbstractReadBackedPileup<
indel = getDeletionString(e.getEventLength(),refBases); indel = getDeletionString(e.getEventLength(),refBases);
break; break;
case NOEVENT: continue; case NOEVENT: continue;
default: throw new StingException("Unknown event type encountered: "+e.getType()); default: throw new GATKException("Unknown event type encountered: "+e.getType());
} }
cnt = events.get(indel); cnt = events.get(indel);

View File

@ -31,6 +31,7 @@ import net.sf.samtools.Cigar;
import net.sf.samtools.CigarElement; import net.sf.samtools.CigarElement;
import net.sf.samtools.util.StringUtil; import net.sf.samtools.util.StringUtil;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.pileup.*; import org.broadinstitute.sting.utils.pileup.*;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.Utils; import org.broadinstitute.sting.utils.Utils;
@ -146,7 +147,7 @@ public class AlignmentUtils {
case H: case H:
case P: case P:
break; break;
default: throw new StingException("The " + ce.getOperator() + " cigar element is not currently supported"); default: throw new GATKException("The " + ce.getOperator() + " cigar element is not currently supported");
} }
} }
@ -298,7 +299,7 @@ public class AlignmentUtils {
case P: case P:
break; break;
default: default:
throw new StingException( "Unsupported cigar operator: " + ce.getOperator() ); throw new GATKException( "Unsupported cigar operator: " + ce.getOperator() );
} }
} }
return alignment; return alignment;
@ -337,7 +338,7 @@ public class AlignmentUtils {
case P: case P:
break; break;
default: default:
throw new StingException( "Unsupported cigar operator: " + ce.getOperator() ); throw new GATKException( "Unsupported cigar operator: " + ce.getOperator() );
} }
} }
return alignment; return alignment;

View File

@ -10,6 +10,7 @@ import java.io.ByteArrayInputStream;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.*; import java.util.*;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.GenomeLocParser; import org.broadinstitute.sting.utils.GenomeLocParser;
@ -93,7 +94,7 @@ public class ArtificialSAMFileReader extends SAMFileReader {
return new ByteArrayInputStream(byteArray); return new ByteArrayInputStream(byteArray);
} }
catch( UnsupportedEncodingException ex ) { catch( UnsupportedEncodingException ex ) {
throw new StingException("Unable to build empty input stream",ex); throw new GATKException("Unable to build empty input stream",ex);
} }
} }
} }

View File

@ -6,6 +6,7 @@ import net.sf.samtools.SAMRecord;
import java.util.List; import java.util.List;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
@ -126,7 +127,7 @@ public class ArtificialSAMQueryIterator extends ArtificialSAMIterator {
// sanity check that we have an actual matching read next // sanity check that we have an actual matching read next
SAMRecord rec = this.peek(); SAMRecord rec = this.peek();
if (rec == null) { if (rec == null) {
throw new StingException("The next read doesn't match"); throw new GATKException("The next read doesn't match");
} }
// set the seeked variable to true // set the seeked variable to true
seeked = true; seeked = true;
@ -165,7 +166,7 @@ public class ArtificialSAMQueryIterator extends ArtificialSAMIterator {
super.next(); super.next();
} }
if (!super.hasNext()) { if (!super.hasNext()) {
throw new StingException("Unable to find the target chromosome"); throw new GATKException("Unable to find the target chromosome");
} }
while (super.hasNext() && this.peek().getAlignmentStart() < start) { while (super.hasNext() && this.peek().getAlignmentStart() < start) {
super.next(); super.next();
@ -173,7 +174,7 @@ public class ArtificialSAMQueryIterator extends ArtificialSAMIterator {
// sanity check that we have an actual matching read next // sanity check that we have an actual matching read next
SAMRecord rec = this.peek(); SAMRecord rec = this.peek();
if (!matches(rec)) { if (!matches(rec)) {
throw new StingException("The next read doesn't match"); throw new GATKException("The next read doesn't match");
} }
// set the seeked variable to true // set the seeked variable to true
seeked = true; seeked = true;

View File

@ -2,6 +2,7 @@ package org.broadinstitute.sting.utils.sam;
import net.sf.samtools.*; import net.sf.samtools.*;
import org.broadinstitute.sting.gatk.iterators.StingSAMIterator; import org.broadinstitute.sting.gatk.iterators.StingSAMIterator;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import java.io.File; import java.io.File;
@ -115,7 +116,7 @@ public class ArtificialSAMUtils {
*/ */
public static SAMFileHeader createEnumeratedReadGroups( SAMFileHeader header, List<String> readGroupIDs, List<String> sampleNames ) { public static SAMFileHeader createEnumeratedReadGroups( SAMFileHeader header, List<String> readGroupIDs, List<String> sampleNames ) {
if (readGroupIDs.size() != sampleNames.size()) { if (readGroupIDs.size() != sampleNames.size()) {
throw new StingException("read group count and sample name count must be the same"); throw new GATKException("read group count and sample name count must be the same");
} }
List<SAMReadGroupRecord> readGroups = new ArrayList<SAMReadGroupRecord>(); List<SAMReadGroupRecord> readGroups = new ArrayList<SAMReadGroupRecord>();
@ -145,7 +146,7 @@ public class ArtificialSAMUtils {
public static SAMRecord createArtificialRead( SAMFileHeader header, String name, int refIndex, int alignmentStart, int length ) { public static SAMRecord createArtificialRead( SAMFileHeader header, String name, int refIndex, int alignmentStart, int length ) {
if( (refIndex == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX && alignmentStart != SAMRecord.NO_ALIGNMENT_START) || if( (refIndex == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX && alignmentStart != SAMRecord.NO_ALIGNMENT_START) ||
(refIndex != SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX && alignmentStart == SAMRecord.NO_ALIGNMENT_START) ) (refIndex != SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX && alignmentStart == SAMRecord.NO_ALIGNMENT_START) )
throw new StingException("Invalid alignment start for artificial read, start = " + alignmentStart); throw new GATKException("Invalid alignment start for artificial read, start = " + alignmentStart);
SAMRecord record = new SAMRecord(header); SAMRecord record = new SAMRecord(header);
record.setReadName(name); record.setReadName(name);
record.setReferenceIndex(refIndex); record.setReferenceIndex(refIndex);
@ -183,7 +184,7 @@ public class ArtificialSAMUtils {
*/ */
public static SAMRecord createArtificialRead( SAMFileHeader header, String name, int refIndex, int alignmentStart, byte[] bases, byte[] qual ) { public static SAMRecord createArtificialRead( SAMFileHeader header, String name, int refIndex, int alignmentStart, byte[] bases, byte[] qual ) {
if (bases.length != qual.length) { if (bases.length != qual.length) {
throw new StingException("Passed in read string is different length then the quality array"); throw new GATKException("Passed in read string is different length then the quality array");
} }
SAMRecord rec = createArtificialRead(header, name, refIndex, alignmentStart, bases.length); SAMRecord rec = createArtificialRead(header, name, refIndex, alignmentStart, bases.length);
rec.setReadBases(bases); rec.setReadBases(bases);

View File

@ -5,6 +5,7 @@ import java.util.*;
import net.sf.samtools.*; import net.sf.samtools.*;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine; import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
import org.broadinstitute.sting.utils.exceptions.UserError;
/** /**
* @author ebanks * @author ebanks
@ -64,7 +65,7 @@ public class GATKSAMRecord extends SAMRecord {
// sanity check that the lengths of the base and quality strings are equal // sanity check that the lengths of the base and quality strings are equal
if ( getBaseQualities().length != getReadLength() ) if ( getBaseQualities().length != getReadLength() )
throw new StingException(String.format("Error: the number of base qualities does not match the number of bases in %s (and the GATK does not currently support '*' for the quals)", mRecord.getReadName())); throw new UserError.MalformedBam(this, String.format("Error: the number of base qualities does not match the number of bases in %s (and the GATK does not currently support '*' for the quals)", mRecord.getReadName()));
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -29,6 +29,7 @@ import net.sf.samtools.SAMFileReader;
import java.io.File; import java.io.File;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
/** /**
@ -72,9 +73,9 @@ public class SAMFileReaderBuilder {
*/ */
public SAMFileReader build() { public SAMFileReader build() {
if( samFile == null ) if( samFile == null )
throw new StingException( "Filename for output sam file must be supplied."); throw new GATKException( "Filename for output sam file must be supplied.");
if( validationStringency == null ) if( validationStringency == null )
throw new StingException( "Header for output sam file must be supplied."); throw new GATKException( "Header for output sam file must be supplied.");
SAMFileReader reader = new SAMFileReader( samFile ); SAMFileReader reader = new SAMFileReader( samFile );
reader.setValidationStringency( validationStringency ); reader.setValidationStringency( validationStringency );

View File

@ -26,6 +26,7 @@
package org.broadinstitute.sting.utils.text; package org.broadinstitute.sting.utils.text;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import java.util.*; import java.util.*;
@ -110,7 +111,7 @@ public class TextFormattingUtils {
bundle = new PropertyResourceBundle(new StringReader("")); bundle = new PropertyResourceBundle(new StringReader(""));
} }
catch(IOException ioe) { catch(IOException ioe) {
throw new StingException("No resource bundle found, and unable to create an empty placeholder.",ioe); throw new GATKException("No resource bundle found, and unable to create an empty placeholder.",ioe);
} }
} }
return bundle; return bundle;

View File

@ -1,7 +1,9 @@
package org.broadinstitute.sting.utils.wiggle; package org.broadinstitute.sting.utils.wiggle;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import java.io.*; import java.io.*;
@ -40,12 +42,15 @@ public class WiggleWriter {
private StepType type = StepType.variable; private StepType type = StepType.variable;
// the type of step for the wiggle file, todo -- allow this to change // the type of step for the wiggle file, todo -- allow this to change
private String myFile = "unknown";
public WiggleWriter(File outputFile) { public WiggleWriter(File outputFile) {
myFile = outputFile.getAbsolutePath();
FileOutputStream outputStream; FileOutputStream outputStream;
try { try {
outputStream = new FileOutputStream(outputFile); outputStream = new FileOutputStream(outputFile);
} catch ( FileNotFoundException e ) { } catch ( FileNotFoundException e ) {
throw new StingException("Unable to create a wiggle file at location: %s"+outputFile.getAbsolutePath(),e); throw new UserError.CouldNotCreateOutputFile(outputFile, "Unable to create a wiggle file ", e);
} }
wWriter = new BufferedWriter(new OutputStreamWriter(outputStream)); wWriter = new BufferedWriter(new OutputStreamWriter(outputStream));
@ -72,7 +77,7 @@ public class WiggleWriter {
write(wWriter,String.format("%d\t%s",loc.getStart(),dataPoint.toString())); write(wWriter,String.format("%d\t%s",loc.getStart(),dataPoint.toString()));
} else { } else {
// todo -- maybe allow this to open a new file for the new chromosome? // todo -- maybe allow this to open a new file for the new chromosome?
throw new StingException("Attempting to write multiple contigs into wiggle file, first contig was "+firstLoc.getContig()+" most recent "+loc.getContig()); throw new GATKException("Attempting to write multiple contigs into wiggle file, first contig was "+firstLoc.getContig()+" most recent "+loc.getContig());
} }
} }
@ -82,7 +87,7 @@ public class WiggleWriter {
w.flush(); w.flush();
// flush required so writing to output stream will work // flush required so writing to output stream will work
} catch (IOException e) { } catch (IOException e) {
throw new StingException(String.format("Error writing the wiggle line %s",s),e); throw new UserError.CouldNotCreateOutputFile(myFile, String.format("Error writing the wiggle line %s", s), e);
} }
} }
} }