Penultimate step in exception system overhaul. UserError is now UserException. This class should be used for all communication with the USER for problems with their inputs. Engine now validates sequence dictionaries for compatibility, detecting not only lack of overlap but now inconsistent headers (b36 ref with v37 BAM, for example) as well as ref / bam order inconsistency. New -U option to allow users to tolerate dangerous seq dict issues. WalkerTest system now supports testing for exceptions (see email and wiki for docs). Tests for vcf and bam vs. ref incompatibility. Waiting on Tribble seq dict improvements to detect b36 VCF with b37 ref (currently cannot tell this is wrong.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4258 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
depristo 2010-09-12 14:02:43 +00:00
parent da2e879bbc
commit 40e6179911
110 changed files with 865 additions and 582 deletions

View File

@ -27,14 +27,12 @@ package net.sf.picard.reference;
import org.broadinstitute.sting.gatk.datasources.simpleDataSources.ReferenceDataSourceProgressListener;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import static net.sf.picard.reference.FastaSequenceIndexBuilder.Status.*;
import java.io.*;
import java.util.Iterator;
import net.sf.picard.reference.FastaSequenceIndex;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
/**
* Builds FastaSequenceIndex from fasta file.
@ -85,7 +83,7 @@ public class FastaSequenceIndexBuilder {
in = new DataInputStream(new BufferedInputStream(new FileInputStream(fastaFile)));
}
catch (Exception e) {
throw new UserError.CouldNotReadInputFile(fastaFile, "Could not read fasta file", e);
throw new UserException.CouldNotReadInputFile(fastaFile, "Could not read fasta file", e);
}
/*
@ -168,7 +166,7 @@ public class FastaSequenceIndexBuilder {
// validate base character
else {
if (!isValidBase(currentByte))
throw new UserError.MalformedFile(fastaFile, String.format("An invalid base was found in the contig: %s", contig));
throw new UserException.MalformedFile(fastaFile, String.format("An invalid base was found in the contig: %s", contig));
}
break;
@ -194,7 +192,7 @@ public class FastaSequenceIndexBuilder {
// error if next char is a valid base, end of contig otherwise
else if (basesThisLine != basesPerLine || bytesPerLine != bytesRead - endOfLastLine) {
if (isValidBase(nextByte) && nextByte != -1) {
throw new UserError.MalformedFile(fastaFile, String.format("An invalid line was found in the contig: %s", contig));
throw new UserException.MalformedFile(fastaFile, String.format("An invalid line was found in the contig: %s", contig));
}
else
finishReadingContig(sequenceIndex);
@ -206,7 +204,7 @@ public class FastaSequenceIndexBuilder {
// validate base character
else {
if (!isValidBase(currentByte))
throw new UserError.MalformedFile(fastaFile, String.format("An invalid base was found in the contig: %s", contig));
throw new UserException.MalformedFile(fastaFile, String.format("An invalid base was found in the contig: %s", contig));
}
break;
}
@ -214,7 +212,7 @@ public class FastaSequenceIndexBuilder {
return sequenceIndex;
}
catch (IOException e) {
throw new UserError.CouldNotReadInputFile(fastaFile, String.format("Could not read fasta file"), e);
throw new UserException.CouldNotReadInputFile(fastaFile, String.format("Could not read fasta file"), e);
}
catch (Exception e) {
throw new GATKException(e.getMessage(), e);
@ -273,7 +271,7 @@ public class FastaSequenceIndexBuilder {
out = new BufferedWriter(new FileWriter(faiFile));
}
catch (Exception e) {
throw new UserError.CouldNotCreateOutputFile(faiFile, e);
throw new UserException.CouldNotCreateOutputFile(faiFile, e);
}
try {
@ -284,7 +282,7 @@ public class FastaSequenceIndexBuilder {
out.close();
}
catch (Exception e) {
throw new UserError.CouldNotCreateOutputFile(faiFile, e);
throw new UserException.CouldNotCreateOutputFile(faiFile, e);
}
}

View File

@ -25,12 +25,12 @@
package org.broadinstitute.sting.commandline;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
/**
* Generic class for handling misc parsing exceptions.
*/
public class ArgumentException extends UserError {
public class ArgumentException extends UserException {
public ArgumentException( String message ) {
super( message );
}

View File

@ -26,13 +26,12 @@
package org.broadinstitute.sting.commandline;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.classloader.JVMUtils;
import org.broadinstitute.sting.gatk.walkers.Multiplex;
import org.broadinstitute.sting.gatk.walkers.Multiplexer;
import org.apache.log4j.Logger;
import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.lang.annotation.Annotation;
import java.lang.reflect.*;
@ -222,7 +221,7 @@ public abstract class ArgumentTypeDescriptor {
protected String getArgumentValue( ArgumentDefinition definition, ArgumentMatches matches ) {
Collection<String> argumentValues = getArgumentValues( definition, matches );
if( argumentValues.size() > 1 )
throw new UserError.CommandLineError("Multiple values associated with given definition, but this argument expects only one: " + definition.fullName);
throw new UserException.CommandLineException("Multiple values associated with given definition, but this argument expects only one: " + definition.fullName);
return argumentValues.size() > 0 ? argumentValues.iterator().next() : null;
}

View File

@ -26,14 +26,11 @@
package org.broadinstitute.sting.commandline;
import org.apache.log4j.*;
import org.broadinstitute.sting.gatk.phonehome.GATKRunReport;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.help.ApplicationDetails;
import org.broadinstitute.sting.utils.help.HelpFormatter;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.util.*;
public abstract class CommandLineProgram {
@ -253,12 +250,6 @@ public abstract class CommandLineProgram {
// Rethrow the exception to exit with an error.
throw e;
}
catch (Exception e) {
// we catch all exceptions here. if it makes it to this level, we're in trouble. Let's bail!
// TODO: what if the logger is the exception? hmm...
logger.fatal("\n");
throw e;
}
}
/**
@ -376,7 +367,7 @@ public abstract class CommandLineProgram {
System.exit(1);
}
public static void exitSystemWithUserError(UserError e) {
public static void exitSystemWithUserError(UserException e) {
errorPrintf("------------------------------------------------------------------------------------------%n");
errorPrintf("A USER ERROR has occurred. The invalid arguments or inputs must be corrected before the GATK can proceed%n");
errorPrintf("%n");

View File

@ -26,11 +26,10 @@
package org.broadinstitute.sting.commandline;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.collections.Pair;
import org.broadinstitute.sting.utils.classloader.JVMUtils;
import org.broadinstitute.sting.utils.Utils;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.help.ApplicationDetails;
import org.broadinstitute.sting.utils.help.HelpFormatter;
import org.apache.log4j.Logger;
@ -297,7 +296,7 @@ public class ParsingEngine {
if(definitions.size() < 1)
throw new GATKException("Internal error. Argument source creates no definitions.");
ArgumentDefinition definition = definitions.get(0);
throw new UserError.DeprecatedArgument(definition.fullName,definition.doc);
throw new UserException.DeprecatedArgument(definition.fullName,definition.doc);
}
/**

View File

@ -72,15 +72,16 @@ public abstract class CommandLineExecutable extends CommandLineProgram {
*/
protected int execute() throws Exception {
Walker<?,?> mWalker = GATKEngine.getWalkerByName(getAnalysisName());
Collection<SamRecordFilter> filters = GATKEngine.createFiltersForWalker(getArgumentCollection(),mWalker);
// load the arguments into the walker / filters.
loadArgumentsIntoObject(mWalker);
for (SamRecordFilter filter: filters)
loadArgumentsIntoObject(filter);
// set the analysis name in the argument collection
try {
Collection<SamRecordFilter> filters = GATKEngine.createFiltersForWalker(getArgumentCollection(),mWalker);
// load the arguments into the walker / filters.
loadArgumentsIntoObject(mWalker);
for (SamRecordFilter filter: filters)
loadArgumentsIntoObject(filter);
// set the analysis name in the argument collection
GATKResult = GATKEngine.execute(getArgumentCollection(), mWalker, filters);
generateGATKRunReport(mWalker);
} catch ( Exception e ) {

View File

@ -26,13 +26,12 @@
package org.broadinstitute.sting.gatk;
import org.broadinstitute.sting.gatk.arguments.GATKArgumentCollection;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.text.TextFormattingUtils;
import org.broadinstitute.sting.utils.help.ApplicationDetails;
import org.broadinstitute.sting.commandline.*;
import org.broadinstitute.sting.gatk.walkers.Walker;
import java.io.PrintStream;
import java.util.*;
/**
@ -92,7 +91,7 @@ public class CommandLineGATK extends CommandLineExecutable {
CommandLineGATK instance = new CommandLineGATK();
start(instance, argv);
System.exit(CommandLineProgram.result); // todo -- this is a painful hack
} catch (UserError e) {
} catch (UserException e) {
exitSystemWithUserError(e);
} catch (Exception e) {
exitSystemWithError(e);

View File

@ -1,7 +1,6 @@
package org.broadinstitute.sting.gatk;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
/**
* Describes the method for downsampling reads at a given locus.
@ -36,15 +35,15 @@ public class DownsamplingMethod {
// Can't leave toFraction and toCoverage null unless type is experimental naive duplicate eliminator.
if(type != DownsampleType.NONE && toFraction == null && toCoverage == null)
throw new UserError.CommandLineError("Must specify either toFraction or toCoverage when downsampling.");
throw new UserException.CommandLineException("Must specify either toFraction or toCoverage when downsampling.");
// Fraction and coverage cannot both be specified.
if(toFraction != null && toCoverage != null)
throw new UserError.CommandLineError("Downsampling coverage and fraction are both specified. Please choose only one.");
throw new UserException.CommandLineException("Downsampling coverage and fraction are both specified. Please choose only one.");
// Experimental by sample downsampling does not work with a fraction of reads.
if(type == DownsampleType.BY_SAMPLE && toFraction != null)
throw new UserError.CommandLineError("Cannot downsample to fraction with new EXPERIMENTAL_BY_SAMPLE method");
throw new UserException.CommandLineException("Cannot downsample to fraction with new EXPERIMENTAL_BY_SAMPLE method");
this.type = type;
this.toCoverage = toCoverage;

View File

@ -31,7 +31,7 @@ import net.sf.samtools.*;
import org.apache.log4j.Logger;
import org.broadinstitute.sting.gatk.arguments.GATKArgumentCollection;
import org.broadinstitute.sting.gatk.refdata.utils.helpers.DbSNPHelper;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.interval.IntervalMergingRule;
import org.broadinstitute.sting.utils.interval.IntervalUtils;
import org.broadinstitute.sting.gatk.arguments.ValidationExclusion;
@ -267,7 +267,7 @@ public class GenomeAnalysisEngine {
// check to make sure we have a rod of that name
if (!rodNames.containsKey(rodName))
throw new UserError.CommandLineError("--rodToIntervalTrackName (-BTI) was passed the name '"+rodName+"', which wasn't given as a ROD name in the -B option");
throw new UserException.CommandLineException("--rodToIntervalTrackName (-BTI) was passed the name '"+rodName+"', which wasn't given as a ROD name in the -B option");
for (String str : rodNames.keySet())
if (str.equals(rodName)) {
@ -400,7 +400,7 @@ public class GenomeAnalysisEngine {
// Temporarily require all walkers to have a reference, even if that reference is not conceptually necessary.
if ((my_walker instanceof ReadWalker || my_walker instanceof DuplicateWalker || my_walker instanceof ReadPairWalker) &&
argCollection.referenceFile == null) {
throw new UserError.CommandLineError("Read-based traversals require a reference file but none was given");
throw new UserException.CommandLineException("Read-based traversals require a reference file but none was given");
}
return MicroScheduler.create(this,my_walker,readsDataSource,referenceDataSource.getReference(),rodDataSources,argCollection.numberOfThreads);
@ -661,11 +661,6 @@ public class GenomeAnalysisEngine {
// Compile a set of sequence names that exist in the reference file.
SAMSequenceDictionary referenceDictionary = reference.getSequenceDictionary();
Set<String> referenceSequenceNames = new TreeSet<String>();
for (SAMSequenceRecord dictionaryEntry : referenceDictionary.getSequences())
referenceSequenceNames.add(dictionaryEntry.getSequenceName());
if (!reads.isEmpty()) {
// Compile a set of sequence names that exist in the BAM files.
SAMSequenceDictionary readsDictionary = reads.getHeader().getSequenceDictionary();
@ -681,7 +676,7 @@ public class GenomeAnalysisEngine {
}
// compare the reads to the reference
compareTwoDictionaries("reads", readsDictionary, readsSequenceNames, referenceDictionary, referenceSequenceNames);
SequenceDictionaryUtils.validateDictionaries(logger, "reads", readsDictionary, "reference", referenceDictionary);
}
// compare the tracks to the reference, if they have a sequence dictionary
@ -693,57 +688,15 @@ public class GenomeAnalysisEngine {
logger.info("Track " + track.getName() + " doesn't have a sequence dictionary built in, skipping dictionary validation");
continue;
}
Set<String> trackSequences = new TreeSet<String>();
for (SAMSequenceRecord dictionaryEntry : trackDict.getSequences())
trackSequences.add(dictionaryEntry.getSequenceName());
compareTwoDictionaries(track.getName(), trackDict, trackSequences, referenceDictionary, referenceSequenceNames);
SequenceDictionaryUtils.validateDictionaries(logger, track.getName(), trackDict, "reference", referenceDictionary);
}
}
/**
* compare two dictionaries, warning if one isn't a subset of the other, or erroring out if they have no overlap
* @param compareToName the name of the track or bam (used in the output to the user)
* @param comparedToDictionary the dictionary to compare to
* @param compareToSequenceNames the unique sequence names in the compared to dictionary
* @param referenceDictionary the reference dictionary
* @param referenceSequenceNames the reference unique sequence names
*/
private void compareTwoDictionaries(String compareToName, SAMSequenceDictionary comparedToDictionary, Set<String> compareToSequenceNames, SAMSequenceDictionary referenceDictionary, Set<String> referenceSequenceNames) {
// If there's no overlap between reads and reference, data will be bogus. Throw an exception.
Set<String> intersectingSequenceNames = new HashSet<String>(compareToSequenceNames);
intersectingSequenceNames.retainAll(referenceSequenceNames);
if (intersectingSequenceNames.size() == 0) {
StringBuilder error = new StringBuilder();
error.append("No overlap exists between sequence dictionary of the " + compareToName + " and the sequence dictionary of the reference. Perhaps you're using the wrong reference?\n");
error.append(System.getProperty("line.separator"));
error.append(String.format(compareToName + " contigs: %s%n", prettyPrintSequenceRecords(comparedToDictionary)));
error.append(String.format("Reference contigs: %s%n", prettyPrintSequenceRecords(referenceDictionary)));
logger.error(error.toString());
throw new UserError.IncompatibleSequenceDictionaries(referenceDictionary, comparedToDictionary, compareToName);
}
// If the two datasets are not equal and neither is a strict subset of the other, warn the user.
if (!compareToSequenceNames.equals(referenceSequenceNames) &&
!compareToSequenceNames.containsAll(referenceSequenceNames) &&
!referenceSequenceNames.containsAll(compareToSequenceNames)) {
StringBuilder warning = new StringBuilder();
warning.append("Limited overlap exists between sequence dictionary of the " + compareToName + " and the sequence dictionary of the reference. Perhaps you're using the wrong reference?\n");
warning.append(System.getProperty("line.separator"));
warning.append(String.format(compareToName + " contigs: %s%n", prettyPrintSequenceRecords(comparedToDictionary)));
warning.append(String.format("Reference contigs: %s%n", prettyPrintSequenceRecords(referenceDictionary)));
logger.warn(warning.toString());
}
}
private String prettyPrintSequenceRecords(SAMSequenceDictionary sequenceDictionary) {
String[] sequenceRecordNames = new String[sequenceDictionary.size()];
int sequenceRecordIndex = 0;
for (SAMSequenceRecord sequenceRecord : sequenceDictionary.getSequences())
sequenceRecordNames[sequenceRecordIndex++] = sequenceRecord.getSequenceName();
return Arrays.deepToString(sequenceRecordNames);
}
/**
* Convenience function that binds RODs using the old-style command line parser to the new style list for
@ -773,20 +726,20 @@ public class GenomeAnalysisEngine {
// sharding system; it's required with the new sharding system only for locus walkers.
if(readsDataSource != null && !readsDataSource.hasIndex() ) {
if(!exclusions.contains(ValidationExclusion.TYPE.ALLOW_UNINDEXED_BAM))
throw new UserError.CommandLineError("The GATK cannot currently process unindexed BAM files without the -U ALLOW_UNINDEXED_BAM");
throw new UserException.CommandLineException("The GATK cannot currently process unindexed BAM files without the -U ALLOW_UNINDEXED_BAM");
if(intervals != null && WalkerManager.getWalkerDataSource(walker) != DataSource.REFERENCE)
throw new UserError.CommandLineError("Cannot perform interval processing when walker is not driven by reference and no index is available.");
throw new UserException.CommandLineException("Cannot perform interval processing when walker is not driven by reference and no index is available.");
Shard.ShardType shardType;
if(walker instanceof LocusWalker) {
if (readsDataSource.getSortOrder() != SAMFileHeader.SortOrder.coordinate)
throw new UserError.MissortedBAM(SAMFileHeader.SortOrder.coordinate, "Locus walkers can only walk over coordinate-sorted data. Please resort your input BAM file(s).");
throw new UserException.MissortedBAM(SAMFileHeader.SortOrder.coordinate, "Locus walkers can only walk over coordinate-sorted data. Please resort your input BAM file(s).");
shardType = Shard.ShardType.LOCUS;
}
else if(walker instanceof ReadWalker || walker instanceof DuplicateWalker || walker instanceof ReadPairWalker)
shardType = Shard.ShardType.READ;
else
throw new UserError.CommandLineError("The GATK cannot currently process unindexed BAM files");
throw new UserException.CommandLineException("The GATK cannot currently process unindexed BAM files");
List<GenomeLoc> region;
if(intervals != null)
@ -810,7 +763,7 @@ public class GenomeAnalysisEngine {
if (intervals != null && !intervals.isEmpty()) {
if(!readsDataSource.isEmpty() && readsDataSource.getSortOrder() != SAMFileHeader.SortOrder.coordinate)
throw new UserError.MissortedBAM(SAMFileHeader.SortOrder.coordinate, "Locus walkers can only walk over coordinate-sorted data. Please resort your input BAM file(s).");
throw new UserException.MissortedBAM(SAMFileHeader.SortOrder.coordinate, "Locus walkers can only walk over coordinate-sorted data. Please resort your input BAM file(s).");
shardStrategy = ShardStrategyFactory.shatter(readsDataSource,
referenceDataSource.getReference(),
@ -844,9 +797,9 @@ public class GenomeAnalysisEngine {
}
} else if (walker instanceof ReadPairWalker) {
if(readsDataSource != null && readsDataSource.getSortOrder() != SAMFileHeader.SortOrder.queryname)
throw new UserError.MissortedBAM(SAMFileHeader.SortOrder.queryname, "Read pair walkers can only walk over query name-sorted data. Please resort your input BAM file.");
throw new UserException.MissortedBAM(SAMFileHeader.SortOrder.queryname, "Read pair walkers can only walk over query name-sorted data. Please resort your input BAM file.");
if(intervals != null && !intervals.isEmpty())
throw new UserError.CommandLineError("Pairs traversal cannot be used in conjunction with intervals.");
throw new UserException.CommandLineException("Pairs traversal cannot be used in conjunction with intervals.");
shardStrategy = ShardStrategyFactory.shatter(readsDataSource,
referenceDataSource.getReference(),
@ -996,7 +949,7 @@ public class GenomeAnalysisEngine {
unpackedReads.add(new SAMReaderID(new File(fileName),getTags(inputFile)));
}
catch( FileNotFoundException ex ) {
throw new UserError.CouldNotReadInputFile(inputFile, "Unable to find file while unpacking reads", ex);
throw new UserException.CouldNotReadInputFile(inputFile, "Unable to find file while unpacking reads", ex);
}
}
else if(inputFile.getName().toLowerCase().endsWith(".bam")) {
@ -1006,7 +959,7 @@ public class GenomeAnalysisEngine {
unpackedReads.add(new SAMReaderID(new File("/dev/stdin"),Collections.<String>emptyList()));
}
else {
throw new UserError.CommandLineError(String.format("The GATK reads argument (-I) supports only BAM files with the .bam extension and lists of BAM files " +
throw new UserException.CommandLineException(String.format("The GATK reads argument (-I) supports only BAM files with the .bam extension and lists of BAM files " +
"with the .list extension, but the file %s has neither extension. Please ensure that your BAM file or list " +
"of BAM files is in the correct format, update the extension, and try again.",inputFile.getName()));
}

View File

@ -40,6 +40,7 @@ public class ValidationExclusion {
ALLOW_EMPTY_INTERVAL_LIST, // allow the user to pass in an empty interval list
ALLOW_UNSET_BAM_SORT_ORDER, // assume that the bam is sorted, even if the SO (sort-order) flag is not set
NO_READ_ORDER_VERIFICATION, // do not validate that the reads are in order as we take them from the bam file
ALLOW_SEQ_DICT_INCOMPATIBILITY, // allow dangerous, but not fatal, sequence dictionary incompabilities
@EnumerationArgumentDefault // set the ALL value to the default value, so if they specify just -U, we get the ALL
ALL // do not check for all of the above conditions, DEFAULT
}

View File

@ -25,12 +25,9 @@
package org.broadinstitute.sting.gatk.contexts;
import net.sf.samtools.SAMRecord;
import net.sf.samtools.SAMReadGroupRecord;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.pileup.*;
import java.util.*;
@ -116,7 +113,7 @@ public class StratifiedAlignmentContext<RBP extends ReadBackedPileup> {
contexts.put(sampleName,new StratifiedAlignmentContext<RBP>(loc,pileupBySample));
else {
if(assumedSingleSample == null) {
throw new UserError.MalformedBam(pileupBySample.iterator().next().getRead(), "Missing read group for read");
throw new UserException.MalformedBam(pileupBySample.iterator().next().getRead(), "Missing read group for read");
}
contexts.put(assumedSingleSample,new StratifiedAlignmentContext<RBP>(loc,pileupBySample));
}

View File

@ -30,7 +30,7 @@ import org.broad.tribble.util.popgen.HardyWeinbergCalculation;
import org.broad.tribble.util.variantcontext.*;
import org.broadinstitute.sting.utils.*;
import org.broad.tribble.vcf.VCFConstants;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
public class VariantContextUtils {
final public static JexlEngine engine = new JexlEngine();
@ -113,7 +113,7 @@ public class VariantContextUtils {
throw new GATKException("BUG: neither names nor exps can be null: names " + Arrays.toString(names) + " exps=" + Arrays.toString(exps) );
if ( names.length != exps.length )
throw new UserError("Inconsistent number of provided filter names and expressions: names=" + Arrays.toString(names) + " exps=" + Arrays.toString(exps));
throw new UserException("Inconsistent number of provided filter names and expressions: names=" + Arrays.toString(names) + " exps=" + Arrays.toString(exps));
Map<String, String> map = new HashMap<String, String>();
for ( int i = 0; i < names.length; i++ ) { map.put(names[i], exps[i]); }
@ -149,7 +149,7 @@ public class VariantContextUtils {
Expression exp = engine.createExpression(expStr);
exps.add(new JexlVCMatchExp(name, exp));
} catch (Exception e) {
throw new UserError.BadArgumentValue(name, "Invalid expression used (" + expStr + "). Please see the JEXL docs for correct syntax.") ;
throw new UserException.BadArgumentValue(name, "Invalid expression used (" + expStr + "). Please see the JEXL docs for correct syntax.") ;
}
}
@ -433,7 +433,7 @@ public class VariantContextUtils {
for ( String name : vc.getSampleNames() ) {
//System.out.printf("Checking %s %b%n", name, names.contains(name));
if ( names.contains(name) )
throw new UserError("REQUIRE_UNIQUE sample names is true but duplicate names were discovered " + name);
throw new UserException("REQUIRE_UNIQUE sample names is true but duplicate names were discovered " + name);
}
names.addAll(vc.getSampleNames());
@ -642,7 +642,7 @@ public class VariantContextUtils {
private int getIndex(VariantContext vc) {
int i = priorityListOfVCs.indexOf(vc.getName());
if ( i == -1 ) throw new UserError.BadArgumentValue(Utils.join(",", priorityListOfVCs), "Priority list " + priorityListOfVCs + " doesn't contain variant context " + vc.getName());
if ( i == -1 ) throw new UserException.BadArgumentValue(Utils.join(",", priorityListOfVCs), "Priority list " + priorityListOfVCs + " doesn't contain variant context " + vc.getName());
return i;
}

View File

@ -27,11 +27,9 @@ import org.apache.commons.jexl2.JexlContext;
import org.apache.commons.jexl2.MapContext;
import org.broad.tribble.util.variantcontext.Genotype;
import org.broad.tribble.util.variantcontext.VariantContext;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.Utils;
import org.broad.tribble.vcf.VCFConstants;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.util.*;
@ -274,7 +272,7 @@ class JEXLMap implements Map<VariantContextUtils.JexlVCMatchExp, Boolean> {
try {
jexl.put (exp, (Boolean) exp.exp.evaluate(jContext));
} catch (Exception e) {
throw new UserError.CommandLineError(String.format("Invalid JEXL expression detected for %s with message %s", exp.name, e.getMessage()));
throw new UserException.CommandLineException(String.format("Invalid JEXL expression detected for %s with message %s", exp.name, e.getMessage()));
}
}

View File

@ -26,12 +26,11 @@
package org.broadinstitute.sting.gatk.datasources.simpleDataSources;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import net.sf.picard.reference.FastaSequenceIndexBuilder;
import net.sf.picard.sam.CreateSequenceDictionary;
import net.sf.picard.reference.IndexedFastaSequenceFile;
import net.sf.picard.reference.FastaSequenceIndex;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.file.FSLockWithShared;
import org.broadinstitute.sting.utils.file.FileSystemInabilityToLockException;
@ -172,7 +171,7 @@ public class ReferenceDataSource implements ReferenceDataSourceProgressListener
}
catch (Exception e) {
throw new UserError.CouldNotReadInputFile(fastaFile, e);
throw new UserException.CouldNotReadInputFile(fastaFile, e);
}
finally {
dictLock.unlock();

View File

@ -13,8 +13,7 @@ import org.broadinstitute.sting.gatk.walkers.ReadWalker;
import org.broadinstitute.sting.gatk.walkers.Walker;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.io.IOException;
import java.util.List;
@ -225,7 +224,7 @@ class ReferenceOrderedQueryDataPool extends ResourcePool<FeatureSource, Location
try {
resource.close();
} catch (IOException e) {
throw new UserError.CouldNotReadInputFile("Unable to close reader for rod named " + rod.getName(),e);
throw new UserException.CouldNotReadInputFile("Unable to close reader for rod named " + rod.getName(),e);
}
}
}

View File

@ -42,8 +42,7 @@ import org.broadinstitute.sting.gatk.ReadMetrics;
import org.broadinstitute.sting.gatk.arguments.ValidationExclusion;
import org.broadinstitute.sting.gatk.filters.CountingFilteringIterator;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.io.File;
import java.util.*;
@ -128,7 +127,7 @@ public class SAMDataSource implements SimpleDataSource {
// Validate that all input files are sorted in the same order.
if(this.sortOrder != null && this.sortOrder != sortOrder)
throw new UserError.MissortedBAM(String.format("Attempted to process mixed of files sorted as %s and %s.",this.sortOrder,sortOrder));
throw new UserException.MissortedBAM(String.format("Attempted to process mixed of files sorted as %s and %s.",this.sortOrder,sortOrder));
// Update the sort order.
this.sortOrder = sortOrder;

View File

@ -39,13 +39,11 @@ import org.broadinstitute.sting.gatk.iterators.NullSAMIterator;
import org.broadinstitute.sting.gatk.ReadProperties;
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
import org.broadinstitute.sting.gatk.ReadMetrics;
import org.broadinstitute.sting.utils.StingException;
import java.util.*;
import java.io.File;
import net.sf.picard.reference.IndexedFastaSequenceFile;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
/**
@ -86,14 +84,14 @@ public abstract class MicroScheduler {
public static MicroScheduler create(GenomeAnalysisEngine engine, Walker walker, SAMDataSource reads, IndexedFastaSequenceFile reference, Collection<ReferenceOrderedDataSource> rods, int nThreadsToUse) {
if (walker instanceof TreeReducible && nThreadsToUse > 1) {
if(walker.isReduceByInterval())
throw new UserError.BadArgumentValue("nt", String.format("The analysis %s aggregates results by interval. Due to a current limitation of the GATK, analyses of this type do not currently support parallel execution. Please run your analysis without the -nt option.", engine.getWalkerName(walker.getClass())));
throw new UserException.BadArgumentValue("nt", String.format("The analysis %s aggregates results by interval. Due to a current limitation of the GATK, analyses of this type do not currently support parallel execution. Please run your analysis without the -nt option.", engine.getWalkerName(walker.getClass())));
if(walker instanceof ReadWalker)
throw new UserError.BadArgumentValue("nt", String.format("The analysis %s is a read walker. Due to a current limitation of the GATK, analyses of this type do not currently support parallel execution. Please run your analysis without the -nt option.", engine.getWalkerName(walker.getClass())));
throw new UserException.BadArgumentValue("nt", String.format("The analysis %s is a read walker. Due to a current limitation of the GATK, analyses of this type do not currently support parallel execution. Please run your analysis without the -nt option.", engine.getWalkerName(walker.getClass())));
logger.info(String.format("Running the GATK in parallel mode with %d concurrent threads",nThreadsToUse));
return new HierarchicalMicroScheduler(engine, walker, reads, reference, rods, nThreadsToUse);
} else {
if(nThreadsToUse > 1)
throw new UserError.BadArgumentValue("nt", String.format("The analysis %s currently does not support parallel execution. Please run your analysis without the -nt option.", engine.getWalkerName(walker.getClass())));
throw new UserException.BadArgumentValue("nt", String.format("The analysis %s currently does not support parallel execution. Please run your analysis without the -nt option.", engine.getWalkerName(walker.getClass())));
return new LinearMicroScheduler(engine, walker, reads, reference, rods);
}
}

View File

@ -7,8 +7,7 @@ import net.sf.samtools.SAMReadGroupRecord;
import java.util.Set;
import java.util.HashSet;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
/**
* Created by IntelliJ IDEA.
@ -30,7 +29,7 @@ public class PlatformUnitFilter implements SamRecordFilter {
if ( pu_attr == null ) {
// no platform unit in the record, go get from read group
SAMReadGroupRecord rgr = samRecord.getReadGroup();
if ( rgr == null ) throw new UserError.MalformedBam(samRecord, "Read " + samRecord.getReadName() +" has NO associated read group record");
if ( rgr == null ) throw new UserException.MalformedBam(samRecord, "Read " + samRecord.getReadName() +" has NO associated read group record");
pu_attr = rgr.getAttribute("PU") ;
}
if ( pu_attr == null ) return false; // could not get PU, forget about the filtering...

View File

@ -25,9 +25,8 @@
package org.broadinstitute.sting.gatk.filters;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.text.XReadLines;
import org.broadinstitute.sting.utils.StingException;
import java.io.File;
import java.io.FileNotFoundException;
@ -76,7 +75,7 @@ public class PlatformUnitFilterHelper {
if ( EMPTYLINE_PATTERN.matcher(line).matches() ) continue; // skip empty lines
PlatformUnitFilter.addBlackListedLane(line); // PlatformUnitFilter will trim the line as needed
}
} catch ( FileNotFoundException e) { throw new UserError.CouldNotReadInputFile(f, e); } // this should NEVER happen
} catch ( FileNotFoundException e) { throw new UserException.CouldNotReadInputFile(f, e); } // this should NEVER happen
return;
}

View File

@ -33,8 +33,7 @@ import java.io.FileNotFoundException;
import net.sf.picard.filter.SamRecordFilter;
import net.sf.samtools.SAMRecord;
import net.sf.samtools.SAMReadGroupRecord;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.text.XReadLines;
/**
@ -94,7 +93,7 @@ public class ReadGroupBlackListFilter implements SamRecordFilter {
if (parentFile != null) {
message += ", " + parentFile.getAbsolutePath() + ":" + parentLineNum;
}
throw new UserError(message);
throw new UserException(message);
}
} else {
String[] filterEntry = filter.split(":", 2);
@ -111,7 +110,7 @@ public class ReadGroupBlackListFilter implements SamRecordFilter {
message += ", " + parentFile.getAbsolutePath() + ":" + parentLineNum;
}
message += ", format is <TAG>:<SUBSTRING>";
throw new UserError(message);
throw new UserException(message);
}
if (!filters.containsKey(filterEntry[0]))

View File

@ -29,8 +29,7 @@ import org.broadinstitute.sting.gatk.io.stubs.Stub;
import org.broadinstitute.sting.gatk.io.storage.StorageFactory;
import org.broadinstitute.sting.gatk.io.storage.Storage;
import org.broadinstitute.sting.gatk.executive.OutputMergeTask;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.util.*;
import java.io.File;
@ -122,7 +121,7 @@ public class ThreadLocalOutputTracker extends OutputTracker {
tempFile.deleteOnExit();
}
catch( IOException ex ) {
throw new UserError.BadTmpDir("Unable to create temporary file for stub: " + stub.getClass().getName() );
throw new UserException.BadTmpDir("Unable to create temporary file for stub: " + stub.getClass().getName() );
}
return tempFile;

View File

@ -26,10 +26,8 @@
package org.broadinstitute.sting.gatk.io.storage;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.gatk.io.stubs.OutputStreamStub;
import org.broadinstitute.sting.gatk.io.storage.Storage;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.io.*;
import java.nio.channels.FileChannel;
@ -74,7 +72,7 @@ public class OutputStreamStorage extends OutputStream implements Storage<OutputS
return new FileOutputStream( file );
}
catch(FileNotFoundException ex) {
throw new UserError.CouldNotCreateOutputFile(file, "Unable to open output stream for file", ex);
throw new UserException.CouldNotCreateOutputFile(file, "Unable to open output stream for file", ex);
}
}
@ -98,7 +96,7 @@ public class OutputStreamStorage extends OutputStream implements Storage<OutputS
outputStream.close();
}
catch( IOException ex ) {
throw new UserError.CouldNotCreateOutputFile(file, "Unable to close output stream", ex );
throw new UserException.CouldNotCreateOutputFile(file, "Unable to close output stream", ex );
}
}
@ -137,10 +135,10 @@ public class OutputStreamStorage extends OutputStream implements Storage<OutputS
file.delete();
}
catch( FileNotFoundException ex ) {
throw new UserError.CouldNotReadInputFile(file, "Unable to open input stream for file", ex);
throw new UserException.CouldNotReadInputFile(file, "Unable to open input stream for file", ex);
}
catch( IOException ex ) {
throw new UserError.CouldNotReadInputFile(file, "Unable to transfer contents of file", ex);
throw new UserException.CouldNotReadInputFile(file, "Unable to transfer contents of file", ex);
}
}
}

View File

@ -31,8 +31,7 @@ import net.sf.samtools.util.CloseableIterator;
import java.io.*;
import org.broadinstitute.sting.gatk.io.stubs.SAMFileWriterStub;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
/**
* Provides temporary storage for SAMFileWriters.
@ -73,7 +72,7 @@ public class SAMFileWriterStorage implements SAMFileWriter, Storage<SAMFileWrite
this.writer = factory.makeSAMWriter( stub.getFileHeader(), stub.isPresorted(), stub.getSAMOutputStream());
}
else
throw new UserError("Unable to write to SAM file; neither a target file nor a stream has been specified");
throw new UserException("Unable to write to SAM file; neither a target file nor a stream has been specified");
}
public SAMFileHeader getFileHeader() {

View File

@ -6,13 +6,12 @@ import org.broad.tribble.vcf.VCFHeaderLine;
import org.broad.tribble.util.variantcontext.VariantContext;
import org.broad.tribble.vcf.VCFWriter;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.gatk.io.stubs.VCFWriterStub;
import java.io.*;
import net.sf.samtools.util.BlockCompressedOutputStream;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
/**
* Provides temporary and permanent storage for genotypes in VCF format.
@ -41,7 +40,7 @@ public class VCFWriterStorage implements Storage<VCFWriterStorage>, VCFWriter {
stream = new PrintStream(file);
}
catch(IOException ex) {
throw new UserError.CouldNotCreateOutputFile(file, "Unable to open target output stream", ex);
throw new UserException.CouldNotCreateOutputFile(file, "Unable to open target output stream", ex);
}
}
else if ( stub.getOutputStream() != null ) {
@ -65,7 +64,7 @@ public class VCFWriterStorage implements Storage<VCFWriterStorage>, VCFWriter {
this.stream = new PrintStream(file);
}
catch(IOException ex) {
throw new UserError.CouldNotCreateOutputFile(file, "Unable to open target output stream",ex);
throw new UserException.CouldNotCreateOutputFile(file, "Unable to open target output stream",ex);
}
writer = new StandardVCFWriter(this.stream);
writer.writeHeader(stub.getVCFHeader());
@ -108,7 +107,7 @@ public class VCFWriterStorage implements Storage<VCFWriterStorage>, VCFWriter {
reader.close();
} catch (IOException e) {
throw new UserError.CouldNotReadInputFile(file, "Error reading file in VCFWriterStorage: ", e);
throw new UserException.CouldNotReadInputFile(file, "Error reading file in VCFWriterStorage: ", e);
}
}
}

View File

@ -28,14 +28,12 @@ import org.broadinstitute.sting.commandline.ArgumentTypeDescriptor;
import org.broadinstitute.sting.commandline.ArgumentSource;
import org.broadinstitute.sting.commandline.ArgumentMatches;
import org.broadinstitute.sting.commandline.ParsingEngine;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.sam.SAMFileReaderBuilder;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
import net.sf.samtools.SAMFileReader;
import java.io.File;
import java.io.OutputStream;
/**
* Describe how to parse SAMFileReaders.
@ -67,7 +65,7 @@ public class SAMFileReaderArgumentTypeDescriptor extends ArgumentTypeDescriptor
String readerFileName = getArgumentValue( createDefaultArgumentDefinition(source), matches );
if( readerFileName == null )
throw new UserError.CommandLineError("SAM file compression was supplied, but no associated writer was supplied with it.");
throw new UserException.CommandLineException("SAM file compression was supplied, but no associated writer was supplied with it.");
builder.setSAMFile(new File(readerFileName));

View File

@ -26,11 +26,10 @@
package org.broadinstitute.sting.gatk.io.stubs;
import org.broadinstitute.sting.commandline.*;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
import org.broadinstitute.sting.gatk.io.StingSAMFileWriter;
import net.sf.samtools.SAMFileWriter;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.lang.annotation.Annotation;
import java.util.List;
@ -98,7 +97,7 @@ public class SAMFileWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor
public Object parse( ParsingEngine parsingEngine, ArgumentSource source, Class type, ArgumentMatches matches ) {
String writerFileName = getArgumentValue( createBAMArgumentDefinition(source), matches );
if( writerFileName == null )
throw new UserError.CommandLineError("SAM file compression was supplied, but no associated writer was supplied with it.");
throw new UserException.CommandLineException("SAM file compression was supplied, but no associated writer was supplied with it.");
SAMFileWriterStub stub = new SAMFileWriterStub(engine, new File(writerFileName));

View File

@ -36,8 +36,7 @@ import org.broadinstitute.sting.gatk.io.OutputTracker;
import org.broadinstitute.sting.gatk.io.StingSAMFileWriter;
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
/**
* A stub for routing and management of SAM file reading and writing.
@ -175,7 +174,7 @@ public class SAMFileWriterStub implements Stub<SAMFileWriter>, StingSAMFileWrite
*/
public void setIndexOnTheFly( boolean indexOnTheFly ) {
if(writeStarted)
throw new UserError("Attempted to index a BAM on the fly of a file with alignments already in it.");
throw new UserException("Attempted to index a BAM on the fly of a file with alignments already in it.");
this.indexOnTheFly = indexOnTheFly;
}

View File

@ -34,7 +34,7 @@ import org.broadinstitute.sting.gatk.DownsamplingMethod;
import org.broadinstitute.sting.gatk.DownsampleType;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.pileup.*;
import java.util.*;
@ -198,7 +198,7 @@ public class LocusIteratorByState extends LocusIterator {
if ( generateExtendedEvents ) {
// we see insertions only once, when we step right onto them; the position on the read is scrolled
// past the insertion right after that
if ( eventDelayedFlag > 1 ) throw new UserError.MalformedBam(read, "Adjacent I/D events in read "+read.getReadName());
if ( eventDelayedFlag > 1 ) throw new UserException.MalformedBam(read, "Adjacent I/D events in read "+read.getReadName());
insertedBases = Arrays.copyOfRange(read.getReadBases(),readOffset+1,readOffset+1+curElement.getLength());
eventLength = curElement.getLength() ;
eventStart = readOffset;
@ -214,7 +214,7 @@ public class LocusIteratorByState extends LocusIterator {
if ( cigarElementCounter == 1) {
// generate an extended event only if we just stepped into the deletion (i.e. don't
// generate the event at every deleted position on the ref, that's what cigarElementCounter==1 is for!)
if ( eventDelayedFlag > 1 ) throw new UserError.MalformedBam(read, "Adjacent I/D events in read "+read.getReadName());
if ( eventDelayedFlag > 1 ) throw new UserException.MalformedBam(read, "Adjacent I/D events in read "+read.getReadName());
eventLength = curElement.getLength();
eventDelayedFlag = 2; // deletion on the ref causes an immediate return, so we have to delay by 1 only
eventStart = readOffset;
@ -546,7 +546,7 @@ public class LocusIteratorByState extends LocusIterator {
switch(this.downsamplingMethod.type) {
case BY_SAMPLE:
if(downsamplingMethod.toCoverage == null)
throw new UserError.BadArgumentValue("dcov", "Downsampling coverage (-dcov) must be specified when downsampling by sample");
throw new UserException.BadArgumentValue("dcov", "Downsampling coverage (-dcov) must be specified when downsampling by sample");
this.targetCoverage = downsamplingMethod.toCoverage;
break;
default:

View File

@ -27,17 +27,14 @@ package org.broadinstitute.sting.gatk.refdata;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.text.XReadLines;
import org.broadinstitute.sting.utils.Utils;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.gatk.iterators.PushbackIterator;
import java.util.Iterator;
import java.util.regex.Pattern;
import java.io.FileNotFoundException;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Constructor;
/**
@ -117,7 +114,7 @@ public class RODRecordIterator<ROD extends ReferenceOrderedDatum> implements Ite
try {
reader = new PushbackIterator<String>(new XReadLines(file));
} catch (FileNotFoundException e) {
throw new UserError.CouldNotReadInputFile(file, e);
throw new UserException.CouldNotReadInputFile(file, e);
}
this.file = file;
this.name = name;
@ -133,7 +130,7 @@ public class RODRecordIterator<ROD extends ReferenceOrderedDatum> implements Ite
try {
header = rod.initialize(file);
} catch (FileNotFoundException e) {
throw new UserError.CouldNotReadInputFile(file, "ROD "+type.getName() + " failed to initialize properly from file "+file);
throw new UserException.CouldNotReadInputFile(file, "ROD "+type.getName() + " failed to initialize properly from file "+file);
}
}
@ -197,7 +194,7 @@ public class RODRecordIterator<ROD extends ReferenceOrderedDatum> implements Ite
parsed_ok = n.parseLine(header,parts) ;
}
catch ( Exception e ) {
throw new UserError.MalformedFile(file, "Failed to parse ROD data ("+type.getName()+") from file "+ file + " at line #"+linenum+
throw new UserException.MalformedFile(file, "Failed to parse ROD data ("+type.getName()+") from file "+ file + " at line #"+linenum+
"\nOffending line: "+line+
"\nReason ("+e.getClass().getName()+")", e);
}

View File

@ -7,8 +7,7 @@ import org.broadinstitute.sting.gatk.refdata.utils.GATKFeature;
import org.broadinstitute.sting.gatk.refdata.utils.RODRecordList;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.util.*;
@ -108,7 +107,7 @@ public class RefMetaDataTracker {
Object obj = objects.get(0).getUnderlyingObject();
if (!(clazz.isAssignableFrom(obj.getClass())))
throw new UserError.CommandLineError("Unable to case track named " + name + " to type of " + clazz.toString()
throw new UserException.CommandLineException("Unable to case track named " + name + " to type of " + clazz.toString()
+ " it's of type " + obj.getClass());
return (T)obj;

View File

@ -1,8 +1,7 @@
package org.broadinstitute.sting.gatk.refdata;
import org.apache.log4j.Logger;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.io.*;
import java.lang.reflect.Method;
@ -42,7 +41,7 @@ public class ReferenceOrderedData<ROD extends ReferenceOrderedDatum> implements
try {
str = new BufferedReader(new FileReader(new File(filename)));
} catch (FileNotFoundException e) {
throw new UserError.CouldNotReadInputFile(new File(filename), "Unable to load the ROD input file", e);
throw new UserException.CouldNotReadInputFile(new File(filename), "Unable to load the ROD input file", e);
}
String line = "NO LINES READ IN";
try {
@ -51,7 +50,7 @@ public class ReferenceOrderedData<ROD extends ReferenceOrderedDatum> implements
else logger.warn("the following file line didn't parsing into a triplet -> " + line);
}
} catch (IOException e) {
throw new UserError.CouldNotReadInputFile(new File(filename), "Failed reading the input rod file; last line read was " + line, e);
throw new UserException.CouldNotReadInputFile(new File(filename), "Failed reading the input rod file; last line read was " + line, e);
}
}

View File

@ -8,8 +8,7 @@ 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.GenomeLocParser;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.util.Iterator;
import java.util.LinkedList;
@ -166,12 +165,12 @@ public class SeekableRODIterator implements LocationAwareSeekableRODIterator {
}
int that_contig = r.getLocation().getContigIndex();
if ( curr_contig > that_contig )
throw new UserError("LocationAwareSeekableRODIterator: contig " +r.getLocation().getContig() +
throw new UserException("LocationAwareSeekableRODIterator: contig " +r.getLocation().getContig() +
" occurs out of order in track " + r.getName() );
if ( curr_contig < that_contig ) break; // next record is on a higher contig, we do not need it yet...
if ( r.getLocation().getStart() < curr_position )
throw new UserError("LocationAwareSeekableRODIterator: track "+r.getName() +
throw new UserException("LocationAwareSeekableRODIterator: track "+r.getName() +
" is out of coordinate order on contig "+r.getLocation() + " compared to " + curr_contig + ":" + curr_position);
if ( r.getLocation().getStart() > curr_position ) break; // next record starts after the current position; we do not need it yet

View File

@ -6,12 +6,9 @@ import org.broad.tribble.TribbleException;
import org.broad.tribble.readers.LineReader;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.GenomeLocParser;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* the ref seq codec
@ -41,7 +38,7 @@ public class RefSeqCodec implements FeatureCodec {
feature.setTranscript_id(fields[1]);
if ( fields[3].length()==1 && fields[3].charAt(0)=='+') feature.setStrand(1);
else if ( fields[3].length()==1 && fields[3].charAt(0)=='-') feature.setStrand(-1);
else throw new UserError.MalformedFile("Expected strand symbol (+/-), found: "+fields[3]);
else throw new UserException.MalformedFile("Expected strand symbol (+/-), found: "+fields[3]);
feature.setTranscript_interval(GenomeLocParser.parseGenomeLoc(contig_name, Integer.parseInt(fields[4])+1, Integer.parseInt(fields[5])));

View File

@ -28,10 +28,8 @@ package org.broadinstitute.sting.gatk.refdata.tracks;
import org.broadinstitute.sting.gatk.refdata.tracks.builders.RMDTrackBuilder;
import org.broadinstitute.sting.gatk.refdata.utils.RMDTriplet;
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.classloader.PluginManager;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.io.File;
import java.util.*;
@ -177,7 +175,7 @@ public class RMDTrackManager extends PluginManager<RMDTrackBuilder> {
// create instances of each of the requested types
for (RMDTriplet trip : inputs) {
RMDTrackBuilder b = availableTrackBuilders.get(trip.getType().toUpperCase());
if (b == null) throw new UserError.CommandLineError("Unable to find track for " + trip.getType());
if (b == null) throw new UserException.CommandLineException("Unable to find track for " + trip.getType());
tracks.add(b.createInstanceOfTrack(availableTrackTypes.get(trip.getType().toUpperCase()), trip.getName(), new File(trip.getFile())));
}
return tracks;

View File

@ -32,8 +32,7 @@ import org.broadinstitute.sting.gatk.refdata.utils.FeatureToGATKFeatureIterator;
import org.broadinstitute.sting.gatk.refdata.utils.GATKFeature;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.io.File;
import java.io.IOException;
@ -82,7 +81,7 @@ public class TribbleTrack extends RMDTrack implements QueryableTrack {
try {
return new FeatureToGATKFeatureIterator(reader.iterator(),this.getName());
} catch (IOException e) {
throw new UserError.CouldNotReadInputFile(getFile(), "Unable to read from file", e);
throw new UserException.CouldNotReadInputFile(getFile(), "Unable to read from file", e);
}
}

View File

@ -30,10 +30,7 @@ import net.sf.samtools.SAMSequenceRecord;
import org.apache.log4j.Logger;
import org.broad.tribble.*;
import org.broad.tribble.index.Index;
import org.broad.tribble.index.IndexCreator;
import org.broad.tribble.index.IndexFactory;
import org.broad.tribble.index.interval.IntervalIndexCreator;
import org.broad.tribble.index.linear.LinearIndexCreator;
import org.broad.tribble.source.BasicFeatureSource;
import org.broad.tribble.util.LittleEndianOutputStream;
import org.broadinstitute.sting.gatk.refdata.tracks.TribbleTrack;
@ -42,8 +39,7 @@ import org.broadinstitute.sting.gatk.refdata.tracks.RMDTrackCreationException;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.collections.Pair;
import org.broadinstitute.sting.utils.classloader.PluginManager;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.file.FSLockWithShared;
import org.broadinstitute.sting.utils.file.FileSystemInabilityToLockException;
@ -104,7 +100,7 @@ public class TribbleRMDTrackBuilder extends PluginManager<FeatureCodec> implemen
public RMDTrack createInstanceOfTrack(Class targetClass, String name, File inputFile) throws RMDTrackCreationException {
// return a feature reader track
Pair<BasicFeatureSource, SAMSequenceDictionary> pair = createFeatureReader(targetClass, name, inputFile);
if (pair == null) throw new UserError.CouldNotReadInputFile(inputFile, "Unable to make the feature reader for input file");
if (pair == null) throw new UserException.CouldNotReadInputFile(inputFile, "Unable to make the feature reader for input file");
return new TribbleTrack(targetClass, name, inputFile, pair.first, pair.second, createCodec(targetClass, name));
}
@ -150,7 +146,7 @@ public class TribbleRMDTrackBuilder extends PluginManager<FeatureCodec> implemen
try {
return new Pair<BasicFeatureSource, SAMSequenceDictionary>(BasicFeatureSource.getFeatureSource(inputFile.getAbsolutePath(), createCodec(targetClass, name)),null);
} catch (IOException e) {
throw new UserError.CouldNotReadInputFile(inputFile, "Unable to create feature reader from file", e);
throw new UserException.CouldNotReadInputFile(inputFile, "Unable to create feature reader from file", e);
}
}
@ -183,9 +179,9 @@ public class TribbleRMDTrackBuilder extends PluginManager<FeatureCodec> implemen
createCodec(targetClass, name)),
sequenceSetToDictionary(index.getSequenceNames()));
} catch (FileNotFoundException e) {
throw new UserError.CouldNotReadInputFile(inputFile, "Unable to create reader with file", e);
throw new UserException.CouldNotReadInputFile(inputFile, "Unable to create reader with file", e);
} catch (IOException e) {
throw new UserError("Unable to make the index file for " + inputFile, e);
throw new UserException("Unable to make the index file for " + inputFile, e);
}
return reader;
}

View File

@ -2,8 +2,7 @@ package org.broadinstitute.sting.gatk.walkers.analyzeannotations;
import org.broad.tribble.util.variantcontext.VariantContext;
import org.broadinstitute.sting.utils.BaseUtils;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.io.File;
import java.util.*;
@ -113,7 +112,7 @@ public class AnnotationDataManager {
try {
output = new PrintStream(filename); // Create the intermediate data file for this annotation
} catch ( FileNotFoundException e ) {
throw new UserError.CouldNotCreateOutputFile(new File(filename), "Can't create intermediate output annotation data file. Does the output directory exist?", e);
throw new UserException.CouldNotCreateOutputFile(new File(filename), "Can't create intermediate output annotation data file. Does the output directory exist?", e);
}
// Output a header line
@ -164,7 +163,7 @@ public class AnnotationDataManager {
try {
Runtime.getRuntime().exec( rScriptCommandLine );
} catch ( IOException e ) {
throw new UserError.CannotExecuteRScript( rScriptCommandLine, e );
throw new UserException.CannotExecuteRScript( rScriptCommandLine, e );
}
}
}

View File

@ -50,9 +50,8 @@ import org.broadinstitute.sting.gatk.refdata.utils.helpers.DbSNPHelper;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.*;
import org.broadinstitute.sting.gatk.walkers.annotator.genomicannotator.*;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.classloader.PackageUtils;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
public class VariantAnnotatorEngine {
@ -106,7 +105,7 @@ public class VariantAnnotatorEngine {
if ( interfaceClass == null )
interfaceClass = classMap.get(group + "Annotation");
if ( interfaceClass == null )
throw new UserError.BadArgumentValue("group", "Class " + group + " is not found; please check that you have specified the class name correctly");
throw new UserException.BadArgumentValue("group", "Class " + group + " is not found; please check that you have specified the class name correctly");
classes.addAll(PackageUtils.getClassesImplementingInterface(interfaceClass));
}
// get the specific classes provided
@ -115,7 +114,7 @@ public class VariantAnnotatorEngine {
if ( annotationClass == null )
annotationClass = classMap.get(annotation + "Annotation");
if ( annotationClass == null )
throw new UserError.BadArgumentValue("annotation", "Class " + annotation + " is not found; please check that you have specified the class name correctly");
throw new UserException.BadArgumentValue("annotation", "Class " + annotation + " is not found; please check that you have specified the class name correctly");
classes.add(annotationClass);
}
}

View File

@ -40,8 +40,7 @@ import org.broadinstitute.sting.gatk.refdata.utils.GATKFeature;
import org.broadinstitute.sting.gatk.walkers.annotator.VariantAnnotatorEngine;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.utils.BaseUtils;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
/**
* This plugin for {@link VariantAnnotatorEngine} serves as the core
@ -135,7 +134,7 @@ public class GenomicAnnotation implements InfoFieldAnnotation {
//continue; //TODO If this site is monomorphic in the VC, and the current record specifies a particular alternate allele, skip this record. Right?
//} else
if(alternateAlleles.size() > 1) {
throw new UserError.MalformedFile("File associated with " + vc.getName() + " contains record [" + vc + "] contains " + alternateAlleles.size() + " alternate alleles. GenomicAnnotion currently only supports annotating 1 alternate allele.");
throw new UserException.MalformedFile("File associated with " + vc.getName() + " contains record [" + vc + "] contains " + alternateAlleles.size() + " alternate alleles. GenomicAnnotion currently only supports annotating 1 alternate allele.");
}
boolean positiveStrand = true; //if HAPLOTYPE_STRAND_COLUMN isn't specified, assume positive strand.
@ -145,7 +144,7 @@ public class GenomicAnnotation implements InfoFieldAnnotation {
if(hapStrandValue.equals("-") || hapStrandValue.equals("r")) {
positiveStrand = false;
} else if(!hapStrandValue.equals("+") && !hapStrandValue.equals("f")) {
throw new UserError.MalformedFile("Record (" + gatkFeature.getUnderlyingObject() + ") in " + name + " has an invalid value for " + HAPLOTYPE_STRAND_COLUMN + ". This value is: \"" + hapStrandValue + "\"");
throw new UserException.MalformedFile("Record (" + gatkFeature.getUnderlyingObject() + ") in " + name + " has an invalid value for " + HAPLOTYPE_STRAND_COLUMN + ". This value is: \"" + hapStrandValue + "\"");
}
}

View File

@ -46,8 +46,7 @@ import org.broadinstitute.sting.gatk.refdata.features.annotator.AnnotatorInputTa
import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.gatk.walkers.annotator.VariantAnnotatorEngine;
import org.broadinstitute.sting.utils.SampleUtils;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
/**
@ -107,7 +106,7 @@ public class GenomicAnnotator extends RodWalker<Integer, Integer> implements Tre
allFullyQualifiedColumnNames.add(bindingName + "." + columnName);
}
} catch(IOException e) {
throw new UserError.CouldNotReadInputFile(file, "Failed when attempting to read file header. ", e);
throw new UserException.CouldNotReadInputFile(file, "Failed when attempting to read file header. ", e);
}
}
@ -118,25 +117,25 @@ public class GenomicAnnotator extends RodWalker<Integer, Integer> implements Tre
//parse the tokens
final String[] arg = joinArg.split(",");
if(arg.length != 3) {
throw new UserError.BadArgumentValue("-J", "The following -J arg: \"" + joinArg + "\" must contain 3 comma-separated values. (ex: -J name,/path/to/file,name.columnName=name2.columnName2)");
throw new UserException.BadArgumentValue("-J", "The following -J arg: \"" + joinArg + "\" must contain 3 comma-separated values. (ex: -J name,/path/to/file,name.columnName=name2.columnName2)");
}
final String bindingName = arg[0];
final String filename = arg[1];
final String columnsToJoin = arg[2];
if(allBindingNames.contains(bindingName)) {
throw new UserError.BadArgumentValue("-J", "The name \"" + bindingName + "\" in the -J arg: \"" + joinArg + "\" has already been used in another binding.");
throw new UserException.BadArgumentValue("-J", "The name \"" + bindingName + "\" in the -J arg: \"" + joinArg + "\" has already been used in another binding.");
}
String[] splitOnEquals = columnsToJoin.split("=+");
if(splitOnEquals.length != 2) {
throw new UserError.BadArgumentValue("-J", "The -J arg: \"" + joinArg + "\" must specify the columns to join on. (ex: -J name,/path/to/file,name.columnName=name2.columnName2)");
throw new UserException.BadArgumentValue("-J", "The -J arg: \"" + joinArg + "\" must specify the columns to join on. (ex: -J name,/path/to/file,name.columnName=name2.columnName2)");
}
String[] splitOnDot1 = splitOnEquals[0].split("\\.");
String[] splitOnDot2 = splitOnEquals[1].split("\\.");
if(splitOnDot1.length != 2 || splitOnDot2.length != 2) {
throw new UserError.BadArgumentValue("-J", "The -J arg: \"" + joinArg + "\" must fully specify the columns to join on. (ex: -J name,/path/to/file,name.columnName=name2.columnName2)");
throw new UserException.BadArgumentValue("-J", "The -J arg: \"" + joinArg + "\" must fully specify the columns to join on. (ex: -J name,/path/to/file,name.columnName=name2.columnName2)");
}
final String bindingName1 = splitOnDot1[0];
@ -158,13 +157,13 @@ public class GenomicAnnotator extends RodWalker<Integer, Integer> implements Tre
externalBindingName = bindingName1;
externalColumnName = columnName1;
} else {
throw new UserError.BadArgumentValue("-J", "The name \"" + bindingName + "\" in the -J arg: \"" + joinArg + "\" must be specified in one the columns to join on. (ex: -J name,/path/to/file,name.columnName=name2.columnName2)");
throw new UserException.BadArgumentValue("-J", "The name \"" + bindingName + "\" in the -J arg: \"" + joinArg + "\" must be specified in one the columns to join on. (ex: -J name,/path/to/file,name.columnName=name2.columnName2)");
}
//validate externalColumnName
final String fullyQualifiedExternalColumnName = externalBindingName + '.' + externalColumnName;
if( !allFullyQualifiedColumnNames.contains(fullyQualifiedExternalColumnName) ) {
throw new UserError.BadArgumentValue("-J", "The -J arg: \"" + joinArg + "\" specifies an unknown column name: \"" + fullyQualifiedExternalColumnName + "\"");
throw new UserException.BadArgumentValue("-J", "The -J arg: \"" + joinArg + "\" specifies an unknown column name: \"" + fullyQualifiedExternalColumnName + "\"");
}
//read in the file contents into a JoinTable object
@ -182,7 +181,7 @@ public class GenomicAnnotator extends RodWalker<Integer, Integer> implements Tre
fullyQualifiedColumnNames.add(localBindingName + '.' + columnName);
}
if ( !found )
throw new UserError.BadArgumentValue("-J", "The -J arg: \"" + joinArg + "\" specifies an unknown column name: \"" + localColumnName + "\". It's not one of the column names in the header " + columnNames + " of the file: " + filename);
throw new UserException.BadArgumentValue("-J", "The -J arg: \"" + joinArg + "\" specifies an unknown column name: \"" + localColumnName + "\". It's not one of the column names in the header " + columnNames + " of the file: " + filename);
allFullyQualifiedColumnNames.addAll(fullyQualifiedColumnNames);
}
@ -195,7 +194,7 @@ public class GenomicAnnotator extends RodWalker<Integer, Integer> implements Tre
for ( String columnName : SELECT_COLUMNS ) {
if ( !allFullyQualifiedColumnNames.contains(columnName) )
throw new UserError.BadArgumentValue("-s", "The column name '" + columnName + "' provided to -s doesn't match any of the column names in any of the -B files. Here is the list of available column names: " + allFullyQualifiedColumnNames);
throw new UserException.BadArgumentValue("-s", "The column name '" + columnName + "' provided to -s doesn't match any of the column names in any of the -B files. Here is the list of available column names: " + allFullyQualifiedColumnNames);
}
//instantiate the VariantAnnotatorEngine

View File

@ -34,8 +34,7 @@ import java.util.HashMap;
import java.util.List;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
/**
* This is a container that holds all data corresponding to a single join table as specified by one -J arg (ex: -J bindingName1,/path/to/file,bindingName1.columnName=bindingName2.columnName2).
@ -112,7 +111,7 @@ public class JoinTable
}
if(localColumnNameIdx == -1) {
throw new UserError.BadArgumentValue("-J", "The -J arg specifies an unknown column name: \"" + localColumnName + "\". It's not one of the column names in the header " + columnNames + " of the file: " + filename);
throw new UserException.BadArgumentValue("-J", "The -J arg specifies an unknown column name: \"" + localColumnName + "\". It's not one of the column names in the header " + columnNames + " of the file: " + filename);
}
//read in all records and create a map entry for each
@ -127,7 +126,7 @@ public class JoinTable
}
catch(IOException e)
{
throw new UserError.CouldNotReadInputFile(new File(filename), "Unable to parse file", e);
throw new UserException.CouldNotReadInputFile(new File(filename), "Unable to parse file", e);
}
finally
{

View File

@ -32,9 +32,8 @@ import java.util.Collections;
import java.util.List;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.Utils;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
/**
* Used to parse files passed to the GenomicAnnotator via the -J arg.
@ -92,7 +91,7 @@ public class JoinTableParser
final ArrayList<String> values = Utils.split(line, DELIMITER, header.size());
if ( values.size() != header.size() ) {
throw new UserError.MalformedFile(String.format("Encountered a row with %d columns which is different from the number or columns in the header: %d\nHeader: " + header + "\nLine: " + values, values.size(), header.size()));
throw new UserException.MalformedFile(String.format("Encountered a row with %d columns which is different from the number or columns in the header: %d\nHeader: " + header + "\nLine: " + values, values.size(), header.size()));
}
return values;

View File

@ -45,8 +45,7 @@ import org.broadinstitute.sting.gatk.walkers.RodWalker;
import org.broadinstitute.sting.gatk.walkers.Window;
import org.broadinstitute.sting.utils.BaseUtils;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
/**
* Takes a table of transcripts (eg. UCSC refGene, knownGene, and CCDS tables) and generates the big table which contains
@ -174,12 +173,12 @@ public class TranscriptToGenomicInfo extends RodWalker<Integer, Integer> {
try {
header = AnnotatorInputTableCodec.readHeader(transcriptsDataSource.getReferenceOrderedData().getFile());
} catch(Exception e) {
throw new UserError.MalformedFile(transcriptsDataSource.getReferenceOrderedData().getFile(), "Failed when attempting to read header from file", e);
throw new UserException.MalformedFile(transcriptsDataSource.getReferenceOrderedData().getFile(), "Failed when attempting to read header from file", e);
}
for ( String columnName : GENE_NAME_COLUMNS ) {
if ( !header.contains(columnName) )
throw new UserError.CommandLineError("The column name '" + columnName + "' provided to -n doesn't match any of the column names in: " + transcriptsDataSource.getReferenceOrderedData().getFile());
throw new UserException.CommandLineException("The column name '" + columnName + "' provided to -n doesn't match any of the column names in: " + transcriptsDataSource.getReferenceOrderedData().getFile());
}
//init outputColumnNames list

View File

@ -41,8 +41,7 @@ import org.broadinstitute.sting.gatk.walkers.Requires;
import org.broadinstitute.sting.gatk.walkers.RodWalker;
import org.broadinstitute.sting.gatk.walkers.TreeReducible;
import org.broadinstitute.sting.gatk.walkers.Window;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
/**
@ -71,7 +70,7 @@ public class TranscriptToInfo extends RodWalker<Integer, Integer> implements Tre
private String[] GENE_NAME_COLUMNS = {};
public void initialize() {
throw new UserError.MissingWalker("TranscriptToInfo", "This walker is no longer supported. We are actively working on a bug-free replacement. We thank you for your patience at this time.");
throw new UserException.MissingWalker("TranscriptToInfo", "This walker is no longer supported. We are actively working on a bug-free replacement. We thank you for your patience at this time.");
}
public Integer reduceInit() { return 0; }

View File

@ -29,13 +29,11 @@ import org.broadinstitute.sting.gatk.walkers.By;
import org.broadinstitute.sting.gatk.walkers.DataSource;
import org.broadinstitute.sting.gatk.walkers.LocusWalker;
import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.pileup.PileupElement;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import java.util.EnumMap;
import java.util.Map;
import java.io.File;
import java.io.PrintStream;
import java.io.FileNotFoundException;
@ -92,7 +90,7 @@ public class CallableLociWalker extends LocusWalker<CallableLociWalker.CallableB
PrintStream summaryOut = new PrintStream(summaryFile);
summaryOut.close();
} catch (FileNotFoundException e) {
throw new UserError.CouldNotCreateOutputFile(summaryFile, e);
throw new UserException.CouldNotCreateOutputFile(summaryFile, e);
}
}
@ -220,7 +218,7 @@ public class CallableLociWalker extends LocusWalker<CallableLociWalker.CallableB
summaryOut.close();
} catch (FileNotFoundException e) {
throw new UserError.CouldNotCreateOutputFile(summaryFile, e);
throw new UserException.CouldNotCreateOutputFile(summaryFile, e);
}
}
}

View File

@ -26,13 +26,12 @@ import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.RodWalker;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.GenomeLocParser;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broad.tribble.bed.FullBEDFeature;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.util.*;
import java.io.PrintStream;
@ -95,7 +94,7 @@ public class CompareCallableLociWalker extends RodWalker<List<CallableLociWalker
//System.out.printf("tracker %s%n", tracker);
List<Object> bindings = tracker.getReferenceMetaData(track);
if ( bindings.size() != 1 || ! (bindings.get(0) instanceof FullBEDFeature)) {
throw new UserError.MalformedFile(String.format("%s track isn't a properly formated CallableBases object!", track));
throw new UserException.MalformedFile(String.format("%s track isn't a properly formated CallableBases object!", track));
}
FullBEDFeature bed = (FullBEDFeature)bindings.get(0);

View File

@ -5,8 +5,7 @@ import net.sf.samtools.SAMRecord;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.utils.BaseUtils;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.pileup.PileupElement;
import java.util.*;
@ -129,7 +128,7 @@ public class CoverageUtils {
SAMReadGroupRecord rg = r.getReadGroup();
if ( rg == null ) {
String msg = "Read "+r.getReadName()+" lacks read group information; Please associate all reads with read groups";
throw new UserError.MalformedBam(r, msg);
throw new UserException.MalformedBam(r, msg);
}
return rg;

View File

@ -40,7 +40,7 @@ import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.utils.collections.Pair;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.io.File;
import java.io.IOException;
@ -403,7 +403,7 @@ public class DepthOfCoverageWalker extends LocusWalker<Map<DoCOutputType.Partiti
try {
return new SeekableRODIterator(new FeatureToGATKFeatureIterator(refseq.iterator(),"refseq"));
} catch (IOException e) {
throw new UserError.CouldNotReadInputFile(refSeqGeneList, "Unable to open file", e);
throw new UserException.CouldNotReadInputFile(refSeqGeneList, "Unable to open file", e);
}
}
@ -613,7 +613,7 @@ public class DepthOfCoverageWalker extends LocusWalker<Map<DoCOutputType.Partiti
private PrintStream getCorrectStream(DoCOutputType.Partition partition, DoCOutputType.Aggregation aggregation, DoCOutputType.FileType fileType) {
DoCOutputType outputType = new DoCOutputType(partition,aggregation,fileType);
if(!out.containsKey(outputType))
throw new UserError.CommandLineError(String.format("Unable to find appropriate stream for partition = %s, aggregation = %s, file type = %s",partition,aggregation,fileType));
throw new UserException.CommandLineException(String.format("Unable to find appropriate stream for partition = %s, aggregation = %s, file type = %s",partition,aggregation,fileType));
return out.get(outputType);
}

View File

@ -45,11 +45,9 @@ import org.broadinstitute.sting.gatk.refdata.utils.RODRecordList;
import org.broadinstitute.sting.gatk.walkers.ReadFilters;
import org.broadinstitute.sting.gatk.walkers.ReadWalker;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
import org.broadinstitute.sting.gatk.datasources.simpleDataSources.ReferenceDataSource;
import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.sam.AlignmentUtils;
import org.broadinstitute.sting.utils.collections.CircularArray;
import org.broadinstitute.sting.utils.collections.PrimitivePair;
@ -211,7 +209,7 @@ public class IndelGenotyperV2Walker extends ReadWalker<Integer,Integer> {
normal_context = new WindowContext(0,WINDOW_SIZE);
if ( bedOutput != null && output_file != null ) {
throw new UserError.DeprecatedArgument("-O", "-O option is deprecated and -bed option replaces it; you can not use both at the same time");
throw new UserException.DeprecatedArgument("-O", "-O option is deprecated and -bed option replaces it; you can not use both at the same time");
}
if ( RefseqFileName != null ) {
@ -223,7 +221,7 @@ public class IndelGenotyperV2Walker extends ReadWalker<Integer,Integer> {
try {
refseqIterator = new SeekableRODIterator(new FeatureToGATKFeatureIterator(refseq.iterator(),"refseq"));
} catch (IOException e) {
throw new UserError.CouldNotReadInputFile(new File(RefseqFileName), "Write failed", e);
throw new UserException.CouldNotReadInputFile(new File(RefseqFileName), "Write failed", e);
}
}
@ -264,12 +262,12 @@ public class IndelGenotyperV2Walker extends ReadWalker<Integer,Integer> {
if ( bedOutput != null ) bedWriter = new FileWriter(bedOutput);
if ( output_file != null ) bedWriter = new FileWriter(output_file);
} catch (java.io.IOException e) {
throw new UserError.CouldNotReadInputFile(bedOutput, "Failed to open BED file for writing.", e);
throw new UserException.CouldNotReadInputFile(bedOutput, "Failed to open BED file for writing.", e);
}
try {
if ( verboseOutput != null ) verboseWriter = new FileWriter(verboseOutput);
} catch (java.io.IOException e) {
throw new UserError.CouldNotReadInputFile(verboseOutput, "Failed to open BED file for writing.", e);
throw new UserException.CouldNotReadInputFile(verboseOutput, "Failed to open BED file for writing.", e);
}
vcf_writer.writeHeader(new VCFHeader(getVCFHeaderInfo(), SampleUtils.getSAMFileSamples(getToolkit().getSAMFileHeader()))) ;
@ -299,7 +297,7 @@ public class IndelGenotyperV2Walker extends ReadWalker<Integer,Integer> {
// we just jumped onto a new contig
if ( DEBUG ) System.out.println("DEBUG>>> Moved to contig "+read.getReferenceName());
if ( read.getReferenceIndex() < currentContigIndex ) // paranoidal
throw new UserError.MissortedBAM(SAMFileHeader.SortOrder.coordinate, read, "Read "+read.getReadName()+": contig is out of order; input BAM file is unsorted");
throw new UserException.MissortedBAM(SAMFileHeader.SortOrder.coordinate, read, "Read "+read.getReadName()+": contig is out of order; input BAM file is unsorted");
// print remaining indels from the previous contig (if any);
if ( call_somatic ) emit_somatic(1000000000, true);
@ -327,7 +325,7 @@ public class IndelGenotyperV2Walker extends ReadWalker<Integer,Integer> {
// tumor_context are synchronized exactly (windows are always shifted together by emit_somatic), so it's safe
if ( read.getAlignmentStart() < currentPosition ) // oops, read out of order?
throw new UserError.MissortedBAM(SAMFileHeader.SortOrder.coordinate, read, "Read "+read.getReadName() +" out of order on the contig\n"+
throw new UserException.MissortedBAM(SAMFileHeader.SortOrder.coordinate, read, "Read "+read.getReadName() +" out of order on the contig\n"+
"Read starts at "+refName+":"+read.getAlignmentStart()+"; last read seen started at "+refName+":"+currentPosition
+"\nLast read was: "+lastRead.getReadName()+" RG="+lastRead.getAttribute("RG")+" at "+lastRead.getAlignmentStart()+"-"
+lastRead.getAlignmentEnd()+" cigar="+lastRead.getCigarString());
@ -382,7 +380,7 @@ public class IndelGenotyperV2Walker extends ReadWalker<Integer,Integer> {
// let's double check now that the read fits after the shift
if ( read.getAlignmentEnd() > normal_context.getStop()) {
// ooops, looks like the read does not fit into the window even after the latter was shifted!!
throw new UserError.MissortedBAM(SAMFileHeader.SortOrder.coordinate, read, "Read "+read.getReadName()+": out of coverage window bounds. Probably window is too small.\n"+
throw new UserException.MissortedBAM(SAMFileHeader.SortOrder.coordinate, read, "Read "+read.getReadName()+": out of coverage window bounds. Probably window is too small.\n"+
"Read length="+read.getReadLength()+"; cigar="+read.getCigarString()+"; start="+
read.getAlignmentStart()+"; end="+read.getAlignmentEnd()+
"; window start (after trying to accomodate the read)="+normal_context.getStart()+
@ -394,14 +392,14 @@ public class IndelGenotyperV2Walker extends ReadWalker<Integer,Integer> {
String rg = (String)read.getAttribute("RG");
if ( rg == null )
throw new UserError.MalformedBam(read, "Read "+read.getReadName()+" has no read group in merged stream. RG is required for somatic calls.");
throw new UserException.MalformedBam(read, "Read "+read.getReadName()+" has no read group in merged stream. RG is required for somatic calls.");
if ( normalReadGroups.contains(rg) ) {
normal_context.add(read,ref.getBases());
} else if ( tumorReadGroups.contains(rg) ) {
tumor_context.add(read,ref.getBases());
} else {
throw new UserError.MalformedBam(read, "Unrecognized read group in merged stream: "+rg);
throw new UserException.MalformedBam(read, "Unrecognized read group in merged stream: "+rg);
}
if ( tumor_context.getReads().size() > MAX_READ_NUMBER ) {
System.out.println("WARNING: a count of "+MAX_READ_NUMBER+" reads reached in a window "+
@ -503,7 +501,7 @@ public class IndelGenotyperV2Walker extends ReadWalker<Integer,Integer> {
verboseWriter.write(fullRecord.toString());
verboseWriter.write('\n');
} catch (IOException e) {
throw new UserError.CouldNotCreateOutputFile(verboseOutput, "Write failed", e);
throw new UserException.CouldNotCreateOutputFile(verboseOutput, "Write failed", e);
}
}
}
@ -663,7 +661,7 @@ public class IndelGenotyperV2Walker extends ReadWalker<Integer,Integer> {
verboseWriter.write(fullRecord + "\t"+ annotationString);
verboseWriter.write('\n');
} catch (IOException e) {
throw new UserError.CouldNotCreateOutputFile(verboseOutput, "Write failed", e);
throw new UserException.CouldNotCreateOutputFile(verboseOutput, "Write failed", e);
}
}
}
@ -1222,7 +1220,7 @@ public class IndelGenotyperV2Walker extends ReadWalker<Integer,Integer> {
try {
bed.write(message.toString()+"\n");
} catch (IOException e) {
throw new UserError.CouldNotCreateOutputFile(bedOutput, "Error encountered while writing into output BED file", e);
throw new UserException.CouldNotCreateOutputFile(bedOutput, "Error encountered while writing into output BED file", e);
}
}

View File

@ -31,7 +31,7 @@ import net.sf.samtools.util.SequenceUtil;
import net.sf.picard.reference.IndexedFastaSequenceFile;
import org.broad.tribble.util.variantcontext.VariantContext;
import org.broadinstitute.sting.commandline.*;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.interval.IntervalMergingRule;
import org.broadinstitute.sting.utils.interval.IntervalUtils;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
@ -334,7 +334,7 @@ public class IndelRealigner extends ReadWalker<Integer, Integer> {
currentInterval = intervals.hasNext() ? intervals.next() : null;
} while ( currentInterval != null && (readLoc == null || currentInterval.isBefore(readLoc)) );
} 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 UserException.MissortedFile(new File(intervalsFile), " *** Are you sure that your interval file is sorted? If not, you must use the --targetIntervalsAreNotSorted argument. ***", e);
}
@ -532,7 +532,7 @@ public class IndelRealigner extends ReadWalker<Integer, Integer> {
statsOutput.write("\n");
statsOutput.flush();
} catch (Exception e) {
throw new UserError.CouldNotCreateOutputFile("statsOutput", "Failed to write stats output file", e);
throw new UserException.CouldNotCreateOutputFile("statsOutput", "Failed to write stats output file", e);
}
}
} else {
@ -559,7 +559,7 @@ public class IndelRealigner extends ReadWalker<Integer, Integer> {
indelOutput.write(str.toString());
indelOutput.flush();
} catch (Exception e) {
throw new UserError.CouldNotCreateOutputFile("indelOutput", "Failed to write indel output file", e);
throw new UserException.CouldNotCreateOutputFile("indelOutput", "Failed to write indel output file", e);
}
}
if ( statsOutput != null ) {
@ -573,7 +573,7 @@ public class IndelRealigner extends ReadWalker<Integer, Integer> {
statsOutput.write("\n");
statsOutput.flush();
} catch (Exception e) {
throw new UserError.CouldNotCreateOutputFile("statsOutput", "Failed to write stats output file", e);
throw new UserException.CouldNotCreateOutputFile("statsOutput", "Failed to write stats output file", e);
}
}
@ -619,7 +619,7 @@ public class IndelRealigner extends ReadWalker<Integer, Integer> {
currentInterval.toString(), improvement));
statsOutput.flush();
} catch (Exception e) {
throw new UserError.CouldNotCreateOutputFile("statsOutput", "Failed to write stats output file", e);
throw new UserException.CouldNotCreateOutputFile("statsOutput", "Failed to write stats output file", e);
}
}
}
@ -1059,7 +1059,7 @@ public class IndelRealigner extends ReadWalker<Integer, Integer> {
snpsOutput.write(sb.toString());
snpsOutput.flush();
} catch (Exception e) {
throw new UserError.CouldNotCreateOutputFile("snpsOutput", "Failed to write SNPs output file", e);
throw new UserException.CouldNotCreateOutputFile("snpsOutput", "Failed to write SNPs output file", e);
}
}
return reduces;

View File

@ -33,13 +33,11 @@ import org.broadinstitute.sting.gatk.filters.ZeroMappingQualityReadFilter;
import org.broadinstitute.sting.gatk.filters.BadMateFilter;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.GenomeLocParser;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.pileup.ExtendedEventPileupElement;
import org.broadinstitute.sting.utils.pileup.PileupElement;
import org.broadinstitute.sting.utils.pileup.ReadBackedExtendedEventPileup;
@ -85,7 +83,7 @@ public class RealignerTargetCreator extends RodWalker<RealignerTargetCreator.Eve
public void initialize() {
if ( windowSize < 2 )
throw new UserError.BadArgumentValue("windowSize", "Window Size must be an integer greater than 1");
throw new UserException.BadArgumentValue("windowSize", "Window Size must be an integer greater than 1");
}
public Event map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {

View File

@ -31,9 +31,8 @@ import org.broadinstitute.sting.gatk.walkers.ReadWalker;
import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTracker;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.collections.PrimitivePair;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.sam.AlignmentUtils;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
@ -96,13 +95,13 @@ public class CycleQualityWalker extends ReadWalker<Integer,Integer> {
SAMReadGroupRecord rg = read.getReadGroup();
if ( rg == null ) throw new UserError.ReadMissingReadGroup(read);
if ( rg == null ) throw new UserException.ReadMissingReadGroup(read);
String lane = read.getReadGroup().getPlatformUnit();
String library = read.getReadGroup().getLibrary();
if ( lane == null ) throw new UserError.MalformedBam(read, "Read "+read.getReadName()+" has no platform unit information");
if ( library == null ) throw new UserError.MalformedBam(read, "Read "+read.getReadName()+" has no library information");
if ( lane == null ) throw new UserException.MalformedBam(read, "Read "+read.getReadName()+" has no platform unit information");
if ( library == null ) throw new UserException.MalformedBam(read, "Read "+read.getReadName()+" has no library information");
int end = 0;
@ -110,11 +109,11 @@ public class CycleQualityWalker extends ReadWalker<Integer,Integer> {
if ( read.getFirstOfPairFlag() ) {
if ( read.getSecondOfPairFlag() )
throw new UserError.MalformedBam(read, "Read "+read.getReadName()+" has conflicting first/second in pair attributes");
throw new UserException.MalformedBam(read, "Read "+read.getReadName()+" has conflicting first/second in pair attributes");
end = 1;
} else {
if ( ! read.getSecondOfPairFlag() )
throw new UserError.MalformedBam(read, "Read "+read.getReadName()+" has conflicting first/second in pair attributes");
throw new UserException.MalformedBam(read, "Read "+read.getReadName()+" has conflicting first/second in pair attributes");
end = 2;
}
}
@ -361,7 +360,7 @@ public class CycleQualityWalker extends ReadWalker<Integer,Integer> {
}
} catch (IOException ioe) {
throw new UserError.CouldNotCreateOutputFile(f, "Failed to write report", ioe);
throw new UserException.CouldNotCreateOutputFile(f, "Failed to write report", ioe);
}
}
@ -408,7 +407,7 @@ public class CycleQualityWalker extends ReadWalker<Integer,Integer> {
public void add(byte[] quals) {
if ( quals.length > cycleQualsAv.length )
throw new UserError("A read of length "+quals.length+" encountered, which exceeds specified maximum read length");
throw new UserException("A read of length "+quals.length+" encountered, which exceeds specified maximum read length");
if ( quals.length > maxL ) maxL = quals.length;
if ( quals.length < minL ) minL = quals.length;
readCount++;

View File

@ -27,10 +27,9 @@ import org.broadinstitute.sting.gatk.walkers.DataSource;
import org.broadinstitute.sting.gatk.walkers.ReadWalker;
import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTracker;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.Utils;
import org.broadinstitute.sting.utils.MathUtils;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.sam.AlignmentUtils;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
@ -77,7 +76,7 @@ public class ReadClippingStatsWalker extends ReadWalker<ReadClippingStatsWalker.
ReadClippingInfo info = new ReadClippingInfo();
info.rg = read.getReadGroup();
if ( info.rg == null ) throw new UserError.ReadMissingReadGroup(read);
if ( info.rg == null ) throw new UserException.ReadMissingReadGroup(read);
for ( CigarElement elt : read.getCigar().getCigarElements() ) {
if ( elt.getOperator() != CigarOperator.N )

View File

@ -33,7 +33,7 @@ import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.pileup.ReadBackedPileup;
import java.util.Arrays;
@ -59,7 +59,7 @@ public class ValidatingPileupWalker extends LocusWalker<Integer, ValidationStats
if ( truePileup == null ) {
out.printf("No truth pileup data available at %s%n", pileup.getPileupString(ref.getBaseAsChar()));
if ( ! CONTINUE_AFTER_AN_ERROR ) {
throw new UserError.CommandLineError(String.format("No pileup data available at %s given GATK's output of %s -- this walker requires samtools pileup data over all bases",
throw new UserException.CommandLineException(String.format("No pileup data available at %s given GATK's output of %s -- this walker requires samtools pileup data over all bases",
context.getLocation(), new String(pileup.getBases())));
}
} else {

View File

@ -39,7 +39,7 @@ import org.broadinstitute.sting.utils.collections.NestedHashMap;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.ArgumentCollection;
import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.pileup.PileupElement;
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
@ -188,7 +188,7 @@ public class CovariateCounterWalker extends LocusWalker<CovariateCounterWalker.C
}
}
if( !foundDBSNP && !RUN_WITHOUT_DBSNP ) {
throw new UserError.CommandLineError("This calculation is critically dependent on being able to skip over known variant sites. Please provide a dbSNP ROD or a VCF file containing known sites of genetic variation.");
throw new UserException.CommandLineException("This calculation is critically dependent on being able to skip over known variant sites. Please provide a dbSNP ROD or a VCF file containing known sites of genetic variation.");
}
// Initialize the requested covariates by parsing the -cov argument
@ -197,7 +197,7 @@ public class CovariateCounterWalker extends LocusWalker<CovariateCounterWalker.C
requestedCovariates.add( new ReadGroupCovariate() ); // Order is important here
requestedCovariates.add( new QualityScoreCovariate() );
} else {
throw new UserError.CommandLineError("There are more required covariates than expected. The instantiation list needs to be updated with the new required covariate and in the correct order.");
throw new UserException.CommandLineException("There are more required covariates than expected. The instantiation list needs to be updated with the new required covariate and in the correct order.");
}
// Next add the standard covariates if -standard was specified by the user
if( USE_STANDARD_COVARIATES ) {
@ -241,7 +241,7 @@ public class CovariateCounterWalker extends LocusWalker<CovariateCounterWalker.C
}
if( !foundClass ) {
throw new UserError.CommandLineError( "The requested covariate type (" + requestedCovariateString + ") isn't a valid covariate option. Use --list to see possible covariates." );
throw new UserException.CommandLineException( "The requested covariate type (" + requestedCovariateString + ") isn't a valid covariate option. Use --list to see possible covariates." );
}
}
}

View File

@ -3,9 +3,7 @@ package org.broadinstitute.sting.gatk.walkers.recalibration;
import net.sf.samtools.SAMRecord;
import org.broadinstitute.sting.utils.BaseUtils;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.Utils;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
/*
* Copyright (c) 2009 The Broad Institute
@ -53,7 +51,7 @@ public class CycleCovariate implements StandardCovariate {
RAC.DEFAULT_PLATFORM.contains( "454" ) || RAC.DEFAULT_PLATFORM.equalsIgnoreCase( "SOLID" ) || RAC.DEFAULT_PLATFORM.equalsIgnoreCase( "ABI_SOLID" ) ) {
// nothing to do
} else {
throw new UserError.CommandLineError("The requested default platform (" + RAC.DEFAULT_PLATFORM +") is not a recognized platform. Implemented options are illumina, 454, and solid");
throw new UserException.CommandLineException("The requested default platform (" + RAC.DEFAULT_PLATFORM +") is not a recognized platform. Implemented options are illumina, 454, and solid");
}
}
}

View File

@ -25,7 +25,7 @@
package org.broadinstitute.sting.gatk.walkers.recalibration;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
import org.broadinstitute.sting.utils.sam.AlignmentUtils;
import org.broadinstitute.sting.utils.*;
@ -234,7 +234,7 @@ public class RecalDataManager {
readGroup.setPlatform( RAC.DEFAULT_PLATFORM );
((GATKSAMRecord)read).setReadGroup( readGroup );
} else {
throw new UserError.MalformedBam(read, "The input .bam file contains reads with no read group. First observed at read with name = " + read.getReadName() +
throw new UserException.MalformedBam(read, "The input .bam file contains reads with no read group. First observed at read with name = " + read.getReadName() +
" Users must set both the default read group using the --default_read_group <String> argument and the default platform using the --default_platform <String> argument." );
}
}
@ -260,7 +260,7 @@ public class RecalDataManager {
}
readGroup.setPlatform( RAC.DEFAULT_PLATFORM );
} else {
throw new UserError.MalformedBam(read, "The input .bam file contains reads with no platform information. First observed at read with name = " + read.getReadName() +
throw new UserException.MalformedBam(read, "The input .bam file contains reads with no platform information. First observed at read with name = " + read.getReadName() +
" Users must set the default platform using the --default_platform <String> argument." );
}
}
@ -281,7 +281,7 @@ public class RecalDataManager {
if( attr instanceof String ) {
colorSpace = ((String)attr).getBytes();
} else {
throw new UserError.MalformedBam(read, String.format("Value encoded by %s in %s isn't a string!", RecalDataManager.COLOR_SPACE_ATTRIBUTE_TAG, read.getReadName()));
throw new UserException.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
@ -300,7 +300,7 @@ public class RecalDataManager {
read.setAttribute( RecalDataManager.COLOR_SPACE_INCONSISTENCY_TAG, inconsistency );
} else {
throw new UserError.MalformedBam(read, "Unable to find color space information in SOLiD read. First observed at read with name = " + read.getReadName() +
throw new UserException.MalformedBam(read, "Unable to find color space information in SOLiD read. First observed at read with name = " + read.getReadName() +
" Unfortunately this .bam file can not be recalibrated without color space information because of potential reference bias.");
}
}
@ -357,7 +357,7 @@ public class RecalDataManager {
}
} else {
throw new UserError.MalformedBam(read, "Unable to find color space information in SOLiD read. First observed at read with name = " + read.getReadName() +
throw new UserException.MalformedBam(read, "Unable to find color space information in SOLiD read. First observed at read with name = " + read.getReadName() +
" Unfortunately this .bam file can not be recalibrated without color space information because of potential reference bias.");
}
@ -382,7 +382,7 @@ public class RecalDataManager {
}
} else {
throw new UserError.MalformedBam(read, "Unable to find color space information in SOLiD read. First observed at read with name = " + read.getReadName() +
throw new UserException.MalformedBam(read, "Unable to find color space information in SOLiD read. First observed at read with name = " + read.getReadName() +
" Unfortunately this .bam file can not be recalibrated without color space information because of potential reference bias.");
}
}
@ -492,7 +492,7 @@ public class RecalDataManager {
}
read.setReadBases( readBases );
} else { // No color space quality tag in file
throw new UserError.MalformedBam(read, "REMOVE_REF_BIAS recal mode requires color space qualities but they can't be found for read: " + read.getReadName());
throw new UserException.MalformedBam(read, "REMOVE_REF_BIAS recal mode requires color space qualities but they can't be found for read: " + read.getReadName());
}
}
@ -513,7 +513,7 @@ public class RecalDataManager {
case '3':
return performColorThree( prevBase );
default:
throw new UserError.MalformedBam(read, "Unrecognized color space in SOLID read, color = " + (char)color +
throw new UserException.MalformedBam(read, "Unrecognized color space in SOLID read, color = " + (char)color +
" Unfortunately this bam file can not be recalibrated without full color space information because of potential reference bias.");
}
}

View File

@ -27,7 +27,6 @@ package org.broadinstitute.sting.gatk.walkers.recalibration;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.util.*;
import java.util.regex.Pattern;
@ -46,9 +45,8 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.utils.classloader.PackageUtils;
import org.broadinstitute.sting.utils.collections.NestedHashMap;
import org.broadinstitute.sting.utils.QualityUtils;
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.UserException;
import org.broadinstitute.sting.utils.text.TextFormattingUtils;
import org.broadinstitute.sting.utils.Utils;
import org.broadinstitute.sting.utils.text.XReadLines;
@ -181,7 +179,7 @@ public class TableRecalibrationWalker extends ReadWalker<SAMRecord, SAMFileWrite
// Read in the covariates that were used from the input file
else if( COVARIATE_PATTERN.matcher(line).matches() ) { // The line string is either specifying a covariate or is giving csv data
if( foundAllCovariates ) {
throw new UserError.MalformedFile( RECAL_FILE, "Malformed input recalibration file. Found covariate names intermingled with data in file: " + RECAL_FILE );
throw new UserException.MalformedFile( RECAL_FILE, "Malformed input recalibration file. Found covariate names intermingled with data in file: " + RECAL_FILE );
} else { // Found the covariate list in input file, loop through all of them and instantiate them
String[] vals = line.split(",");
for( int iii = 0; iii < vals.length - 3; iii++ ) { // There are n-3 covariates. The last three items are nObservations, nMismatch, and Qempirical
@ -200,7 +198,7 @@ public class TableRecalibrationWalker extends ReadWalker<SAMRecord, SAMFileWrite
}
if( !foundClass ) {
throw new UserError.MalformedFile(RECAL_FILE, "Malformed input recalibration file. The requested covariate type (" + (vals[iii] + "Covariate") + ") isn't a valid covariate option." );
throw new UserException.MalformedFile(RECAL_FILE, "Malformed input recalibration file. The requested covariate type (" + (vals[iii] + "Covariate") + ") isn't a valid covariate option." );
}
}
}
@ -211,7 +209,7 @@ public class TableRecalibrationWalker extends ReadWalker<SAMRecord, SAMFileWrite
// At this point all the covariates should have been found and initialized
if( requestedCovariates.size() < 2 ) {
throw new UserError.MalformedFile(RECAL_FILE, "Malformed input recalibration csv file. Covariate names can't be found in file: " + RECAL_FILE );
throw new UserException.MalformedFile(RECAL_FILE, "Malformed input recalibration csv file. Covariate names can't be found in file: " + RECAL_FILE );
}
final boolean createCollapsedTables = true;
@ -229,16 +227,16 @@ public class TableRecalibrationWalker extends ReadWalker<SAMRecord, SAMFileWrite
}
} catch ( FileNotFoundException e ) {
throw new UserError.CouldNotReadInputFile(RECAL_FILE, "Can not find input file", e);
throw new UserException.CouldNotReadInputFile(RECAL_FILE, "Can not find input file", e);
} catch ( NumberFormatException e ) {
throw new UserError.MalformedFile(RECAL_FILE, "Error parsing recalibration data at line " + lineNumber + ". Perhaps your table was generated by an older version of CovariateCounterWalker.");
throw new UserException.MalformedFile(RECAL_FILE, "Error parsing recalibration data at line " + lineNumber + ". Perhaps your table was generated by an older version of CovariateCounterWalker.");
}
logger.info( "...done!" );
if ( !sawEOF ) {
final String errorMessage = "No EOF marker was present in the recal covariates table; this could mean that the file is corrupted or was generated with an old version of the CountCovariates tool.";
if ( REQUIRE_EOF )
throw new UserError.MalformedFile(RECAL_FILE, errorMessage);
throw new UserException.MalformedFile(RECAL_FILE, errorMessage);
logger.warn(errorMessage);
}
@ -248,7 +246,7 @@ public class TableRecalibrationWalker extends ReadWalker<SAMRecord, SAMFileWrite
}
if( dataManager == null ) {
throw new UserError.MalformedFile(RECAL_FILE, "Can't initialize the data manager. Perhaps the recal csv file contains no data?");
throw new UserException.MalformedFile(RECAL_FILE, "Can't initialize the data manager. Perhaps the recal csv file contains no data?");
}
// Create the tables of empirical quality scores that will be used in the sequential calculation
@ -303,7 +301,7 @@ public class TableRecalibrationWalker extends ReadWalker<SAMRecord, SAMFileWrite
// Check if the data line is malformed, for example if the read group string contains a comma then it won't be parsed correctly
if( vals.length != requestedCovariates.size() + 3 ) { // +3 because of nObservations, nMismatch, and Qempirical
throw new UserError.MalformedFile(file, "Malformed input recalibration file. Found data line with too many fields: " + line +
throw new UserException.MalformedFile(file, "Malformed input recalibration file. Found data line with too many fields: " + line +
" --Perhaps the read group string contains a comma and isn't being parsed correctly.");
}

View File

@ -24,10 +24,9 @@
package org.broadinstitute.sting.gatk.walkers.recalibration;
import org.broadinstitute.sting.utils.StingException;
import net.sf.samtools.SAMRecord;
import net.sf.picard.util.IlluminaUtil;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
/**
* @author alecw@broadinstitute.org
@ -48,7 +47,7 @@ public class TileCovariate implements ExperimentalCovariate {
Integer tile = IlluminaUtil.getTileFromReadName(read.getReadName());
if (tile == null) {
if( exceptionWhenNoTile ) {
throw new UserError.MalformedBam(read, "Tile covariate specified but tile number not defined for read: " + read.getReadName() );
throw new UserException.MalformedBam(read, "Tile covariate specified but tile number not defined for read: " + read.getReadName() );
} else {
return -1;
}

View File

@ -9,9 +9,8 @@ import org.broadinstitute.sting.playground.utils.report.tags.Analysis;
import org.broadinstitute.sting.playground.utils.report.tags.DataPoint;
import org.broadinstitute.sting.playground.utils.report.utils.TableType;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import org.apache.log4j.Logger;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.util.*;
@ -402,7 +401,7 @@ class SampleStats implements TableType {
if ( concordanceStats.containsKey(sample) )
concordanceStats.get(sample)[truth.ordinal()][called.ordinal()]++;
else if ( called != Genotype.Type.NO_CALL )
throw new UserError.CommandLineError("Sample " + sample + " has not been seen in a previous eval; this analysis module assumes that all samples are present in each variant context");
throw new UserException.CommandLineException("Sample " + sample + " has not been seen in a previous eval; this analysis module assumes that all samples are present in each variant context");
}
/**

View File

@ -47,12 +47,11 @@ import org.broadinstitute.sting.playground.utils.report.templates.ReportFormat;
import org.broadinstitute.sting.playground.utils.report.utils.Node;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.classloader.PackageUtils;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.Utils;
import org.broadinstitute.sting.commandline.Argument;
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.UserException;
import org.broadinstitute.sting.utils.text.XReadLines;
import java.io.File;
@ -60,7 +59,6 @@ import java.io.FileNotFoundException;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
// todo -- evalations should support comment lines
@ -310,7 +308,7 @@ public class VariantEvalWalker extends RodWalker<Integer, Integer> {
}
ReportFormat.AcceptableOutputType type = (outputLocation == null) ? ReportFormat.AcceptableOutputType.STREAM : ReportFormat.AcceptableOutputType.FILE;
if (!VE2ReportFactory.isCompatibleWithOutputType(type,reportType))
throw new UserError.CommandLineError("The report format requested is not compatible with your output location. You specified a " + type + " output type which isn't an option for " + reportType);
throw new UserException.CommandLineException("The report format requested is not compatible with your output location. You specified a " + type + " output type which isn't an option for " + reportType);
if ( LIST )
listModulesAndExit();
@ -378,7 +376,7 @@ public class VariantEvalWalker extends RodWalker<Integer, Integer> {
for ( String line : new XReadLines(rsIDFile) ) {
String parts[] = line.split(" ");
if ( parts.length != 2 )
throw new UserError.MalformedFile(rsIDFile, "Invalid rsID / build pair at " + n + " line = " + line );
throw new UserException.MalformedFile(rsIDFile, "Invalid rsID / build pair at " + n + " line = " + line );
//System.out.printf("line %s %s %s%n", line, parts[0], parts[1]);
if ( Integer.valueOf(parts[1]) > maxRsIDBuild ) {
//System.out.printf("Excluding %s%n", line);
@ -390,7 +388,7 @@ public class VariantEvalWalker extends RodWalker<Integer, Integer> {
logger.info(String.format("Read %d rsIDs from rsID -> build file", n));
}
} catch (FileNotFoundException e) {
throw new UserError.CouldNotReadInputFile(rsIDFile, e);
throw new UserException.CouldNotReadInputFile(rsIDFile, e);
}
logger.info(String.format("Excluding %d of %d (%.2f%%) rsIDs found from builds > %d",
@ -425,7 +423,7 @@ public class VariantEvalWalker extends RodWalker<Integer, Integer> {
// get the specific classes provided
for ( String module : modulesToUse ) {
if ( !classMap.containsKey(module) )
throw new UserError.CommandLineError("Module " + module + " could not be found; please check that you have specified the class name correctly");
throw new UserException.CommandLineException("Module " + module + " could not be found; please check that you have specified the class name correctly");
evaluationClasses.add(classMap.get(module));
}
@ -672,7 +670,7 @@ public class VariantEvalWalker extends RodWalker<Integer, Integer> {
for ( String name : names ) {
Collection<VariantContext> contexts = tracker.getVariantContexts(ref, name, ALLOW_VARIANT_CONTEXT_TYPES, context.getLocation(), true, true);
if ( contexts.size() > 1 )
throw new UserError.CommandLineError("Found multiple variant contexts found in " + name + " at " + context.getLocation() + "; VariantEval assumes one variant per position");
throw new UserException.CommandLineException("Found multiple variant contexts found in " + name + " at " + context.getLocation() + "; VariantEval assumes one variant per position");
VariantContext vc = contexts.size() == 1 ? contexts.iterator().next() : null;

View File

@ -37,7 +37,7 @@ import org.broadinstitute.sting.gatk.walkers.RodWalker;
import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
import org.broadinstitute.sting.utils.text.XReadLines;
@ -128,7 +128,7 @@ public class ApplyVariantCuts extends RodWalker<Integer, Integer> {
return tranches;
} catch( FileNotFoundException e ) {
throw new UserError.CouldNotCreateOutputFile(f, e);
throw new UserException.CouldNotCreateOutputFile(f, e);
}
}
@ -156,7 +156,7 @@ public class ApplyVariantCuts extends RodWalker<Integer, Integer> {
firstLine = false;
}
} catch( FileNotFoundException e ) {
throw new UserError.CouldNotCreateOutputFile(TRANCHES_FILE, e);
throw new UserException.CouldNotCreateOutputFile(TRANCHES_FILE, e);
}
// setup the header fields

View File

@ -30,21 +30,14 @@ import org.broad.tribble.util.variantcontext.VariantContext;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContextUtils;
import org.broadinstitute.sting.gatk.datasources.simpleDataSources.ReferenceOrderedDataSource;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.refdata.tracks.RMDTrack;
import org.broadinstitute.sting.gatk.refdata.utils.helpers.DbSNPHelper;
import org.broadinstitute.sting.gatk.walkers.RodWalker;
import org.broadinstitute.sting.utils.BaseUtils;
import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.Utils;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.util.*;
@ -148,7 +141,7 @@ public class GenerateVariantClustersWalker extends RodWalker<ExpandingArrayList<
}
if(!foundDBSNP) {
throw new UserError.CommandLineError("dbSNP track is required. This calculation is critically dependent on being able to distinguish known and novel sites.");
throw new UserException.CommandLineException("dbSNP track is required. This calculation is critically dependent on being able to distinguish known and novel sites.");
}
}
@ -240,7 +233,7 @@ public class GenerateVariantClustersWalker extends RodWalker<ExpandingArrayList<
// theModel = new VariantNearestNeighborsModel( dataManager, TARGET_TITV, NUM_KNN );
// break;
default:
throw new UserError.BadArgumentValue("OPTIMIZATION_MODEL", "Variant Optimization Model is unrecognized. Implemented options are GAUSSIAN_MIXTURE_MODEL and K_NEAREST_NEIGHBORS" );
throw new UserException.BadArgumentValue("OPTIMIZATION_MODEL", "Variant Optimization Model is unrecognized. Implemented options are GAUSSIAN_MIXTURE_MODEL and K_NEAREST_NEIGHBORS" );
}
theModel.run( CLUSTER_FILE );

View File

@ -27,8 +27,7 @@ package org.broadinstitute.sting.gatk.walkers.variantrecalibration;
import org.apache.log4j.Logger;
import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.io.PrintStream;
@ -54,7 +53,7 @@ public class VariantDataManager {
numVariants = dataList.size();
data = dataList.toArray( new VariantDatum[numVariants] );
if( numVariants <= 0 ) {
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" );
throw new UserException.BadInput("There are zero variants with > 0 clustering weight! Please provide sets of known polymorphic loci to be used as training data using the dbsnp, hapmap, or 1kg rod bindings. Clustering weights can be specified using -weightDBSNP, -weightHapMap, and -weight1KG" );
}
if( _annotationKeys == null ) {
numAnnotations = 0;
@ -63,7 +62,7 @@ public class VariantDataManager {
} else {
numAnnotations = _annotationKeys.size();
if( numAnnotations <= 0 ) {
throw new UserError.BadInput("There are zero annotations. At least one annotation must be provided to use this walker!" );
throw new UserException.BadInput("There are zero annotations. At least one annotation must be provided to use this walker!" );
}
meanVector = new double[numAnnotations];
varianceVector = new double[numAnnotations];
@ -111,7 +110,7 @@ public class VariantDataManager {
}
isNormalized = true; // Each data point is now [ (x - mean) / standard deviation ]
if( foundZeroVarianceAnnotation ) {
throw new UserError.BadInput("Found annotations with zero variance. They must be excluded before proceeding.");
throw new UserException.BadInput("Found annotations with zero variance. They must be excluded before proceeding.");
}
}

View File

@ -31,8 +31,7 @@ import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContextUtils
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.MathUtils;
import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.text.XReadLines;
import Jama.*;
@ -132,11 +131,11 @@ public final class VariantGaussianMixtureModel extends VariantOptimizationModel
} else if( CLUSTER_PATTERN.matcher(line).matches() ) {
clusterLines.add(line);
} else {
throw new UserError.MalformedFile(clusterFile, "Could not parse line: " + line);
throw new UserException.MalformedFile(clusterFile, "Could not parse line: " + line);
}
}
} catch ( FileNotFoundException e ) {
throw new UserError.CouldNotReadInputFile(clusterFile, e);
throw new UserException.CouldNotReadInputFile(clusterFile, e);
}
dataManager = new VariantDataManager( annotationLines );
@ -430,7 +429,7 @@ public final class VariantGaussianMixtureModel extends VariantOptimizationModel
try {
value = Double.parseDouble( (String)vc.getAttribute( annotationKey ) );
} catch( NumberFormatException e ) {
throw new UserError.MalformedFile(vc.getName(), "No double value detected for annotation = " + annotationKey + " in variant at " + VariantContextUtils.getLocation(vc) + ", reported annotation value = " + vc.getAttribute( annotationKey ), e );
throw new UserException.MalformedFile(vc.getName(), "No double value detected for annotation = " + annotationKey + " in variant at " + VariantContextUtils.getLocation(vc) + ", reported annotation value = " + vc.getAttribute( annotationKey ), e );
}
}
return value;
@ -493,7 +492,7 @@ public final class VariantGaussianMixtureModel extends VariantOptimizationModel
try {
outputFile = new PrintStream( file );
} catch (FileNotFoundException e) {
throw new UserError.CouldNotCreateOutputFile( file, e );
throw new UserException.CouldNotCreateOutputFile( file, e );
}
outputFile.println("annotationValue,knownDist,novelDist");

View File

@ -35,18 +35,16 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContextUtils;
import org.broadinstitute.sting.gatk.datasources.simpleDataSources.ReferenceOrderedDataSource;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.refdata.tracks.RMDTrack;
import org.broadinstitute.sting.gatk.refdata.utils.helpers.DbSNPHelper;
import org.broadinstitute.sting.gatk.walkers.RodWalker;
import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintStream;
import java.util.*;
@ -144,7 +142,7 @@ public class VariantRecalibrator extends RodWalker<ExpandingArrayList<VariantDat
// theModel = new VariantNearestNeighborsModel( dataManager, TARGET_TITV, NUM_KNN );
// break;
default:
throw new UserError.BadArgumentValue("OPTIMIZATION_MODEL", "Variant Optimization Model is unrecognized. Implemented options are GAUSSIAN_MIXTURE_MODEL and K_NEAREST_NEIGHBORS" );
throw new UserException.BadArgumentValue("OPTIMIZATION_MODEL", "Variant Optimization Model is unrecognized. Implemented options are GAUSSIAN_MIXTURE_MODEL and K_NEAREST_NEIGHBORS" );
}
boolean foundDBSNP = false;
@ -167,7 +165,7 @@ public class VariantRecalibrator extends RodWalker<ExpandingArrayList<VariantDat
}
if(!foundDBSNP) {
throw new UserError.CommandLineError("dbSNP track is required. This calculation is critically dependent on being able to distinguish known and novel sites.");
throw new UserException.CommandLineException("dbSNP track is required. This calculation is critically dependent on being able to distinguish known and novel sites.");
}
// setup the header fields
@ -233,7 +231,7 @@ public class VariantRecalibrator extends RodWalker<ExpandingArrayList<VariantDat
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 ) {
throw new UserError.CommandLineError("Something is wrong with the prior that was entered by the user: Prior = " + totalPrior); // TODO - fix this up later
throw new UserException.CommandLineException("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 );
@ -286,7 +284,7 @@ public class VariantRecalibrator extends RodWalker<ExpandingArrayList<VariantDat
PrintStream reportDatFilePrintStream = new PrintStream(REPORT_DAT_FILE);
theModel.outputOptimizationCurve( dataManager.data, reportDatFilePrintStream, TRANCHES_FILE, DESIRED_NUM_VARIANTS, FDR_TRANCHES, QUAL_STEP );
} catch ( FileNotFoundException e ) {
throw new UserError.CouldNotCreateOutputFile(REPORT_DAT_FILE, e);
throw new UserException.CouldNotCreateOutputFile(REPORT_DAT_FILE, e);
}
// Execute Rscript command to plot the optimization curve

View File

@ -39,7 +39,7 @@ import org.broadinstitute.sting.gatk.walkers.annotator.VariantAnnotatorEngine;
import org.broadinstitute.sting.utils.SampleUtils;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
import java.util.*;
@ -107,7 +107,7 @@ public class CombineVariants extends RodWalker<Integer, Integer> {
Set<String> rodNames = SampleUtils.getRodNamesWithVCFHeader(getToolkit(), null);
if ( genotypeMergeOption == VariantContextUtils.GenotypeMergeType.PRIORITIZE && PRIORITY_STRING == null )
throw new UserError.MissingArgument("rod_priority_list", "Priority string must be provided if you want to prioritize genotypes");
throw new UserException.MissingArgument("rod_priority_list", "Priority string must be provided if you want to prioritize genotypes");
if ( genotypeMergeOption == VariantContextUtils.GenotypeMergeType.PRIORITIZE )
priority = new ArrayList<String>(Arrays.asList(PRIORITY_STRING.split(",")));
@ -115,10 +115,10 @@ public class CombineVariants extends RodWalker<Integer, Integer> {
priority = new ArrayList<String>(rodNames);
if ( rodNames.size() != priority.size() )
throw new UserError.BadArgumentValue("rod_priority_list", "The priority list must contain exactly one rod binding per ROD provided to the GATK: rodNames=" + rodNames + " priority=" + priority);
throw new UserException.BadArgumentValue("rod_priority_list", "The priority list must contain exactly one rod binding per ROD provided to the GATK: rodNames=" + rodNames + " priority=" + priority);
if ( ! rodNames.containsAll(priority) )
throw new UserError.BadArgumentValue("rod_priority_list", "Not all priority elements provided as input RODs: " + PRIORITY_STRING);
throw new UserException.BadArgumentValue("rod_priority_list", "Not all priority elements provided as input RODs: " + PRIORITY_STRING);
}
public Integer map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {

View File

@ -35,10 +35,9 @@ import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.AnnotationType
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.GenotypeAnnotation;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.classloader.PackageUtils;
import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.util.*;
@ -92,7 +91,7 @@ public class AnnotationByAlleleFrequencyWalker extends RodWalker<Integer, Integ
if ( interfaceClass == null )
interfaceClass = classMap.get(group + "Annotation");
if ( interfaceClass == null )
throw new UserError.BadArgumentValue("group", "Class " + group + " is not found; please check that you have specified the class name correctly");
throw new UserException.BadArgumentValue("group", "Class " + group + " is not found; please check that you have specified the class name correctly");
classes.addAll(PackageUtils.getClassesImplementingInterface(interfaceClass));
}
@ -102,7 +101,7 @@ public class AnnotationByAlleleFrequencyWalker extends RodWalker<Integer, Integ
if ( annotationClass == null )
annotationClass = classMap.get(annotation + "Annotation");
if ( annotationClass == null )
throw new UserError.BadArgumentValue("annotation", "Class " + annotation + " is not found; please check that you have specified the class name correctly");
throw new UserException.BadArgumentValue("annotation", "Class " + annotation + " is not found; please check that you have specified the class name correctly");
classes.add(annotationClass);
}

View File

@ -33,7 +33,7 @@ import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.pileup.ReadBackedPileup;
import java.io.File;
@ -87,7 +87,7 @@ public class BaseTransitionTableCalculatorJavaWalker extends LocusWalker<Set<Bas
public void initialize() {
if ( nPreviousBases > 3 || ( nPreviousReadBases > 3 && readBasesMustMatchRef ) ) {
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.");
throw new UserException.CommandLineException("You have opted to use a number of previous bases in excess of 3. In order to do this you must change the reference window size in the walker itself.");
}
UnifiedArgumentCollection uac = new UnifiedArgumentCollection();
uac.baseModel = BaseMismatchModel.THREE_STATE;
@ -151,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 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.";
throw new UserError.CommandLineError(errMsg+errMsg2+errMsg3);
throw new UserException.CommandLineException(errMsg+errMsg2+errMsg3);
}
return reduce(reduce1,reduce2);
}
@ -164,7 +164,7 @@ public class BaseTransitionTableCalculatorJavaWalker extends LocusWalker<Set<Bas
try {
output = new PrintStream(outFilePath);
} catch ( FileNotFoundException e ) {
throw new UserError.CouldNotCreateOutputFile(new File(outFilePath), e);
throw new UserException.CouldNotCreateOutputFile(new File(outFilePath), e);
}
}
output.print(createHeaderFromConditions());

View File

@ -31,7 +31,7 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.sam.AlignmentUtils;
import net.sf.samtools.SAMRecord;
@ -391,7 +391,7 @@ public class DSBWalkerV3 extends ReadWalker<Integer,Integer> {
} else if ( controlReadGroups.contains( read.getReadGroup().getReadGroupId() )) {
addControl(read);
} else {
throw new UserError.MalformedBam(read, "Read "+read + " belongs to unrecognized read group");
throw new UserException.MalformedBam(read, "Read "+read + " belongs to unrecognized read group");
}
return 1;
}

View File

@ -1,7 +1,5 @@
package org.broadinstitute.sting.oneoffprojects.walkers;
import net.sf.samtools.util.CloseableIterator;
import org.broad.tribble.FeatureIterator;
import org.broad.tribble.FeatureSource;
import org.broad.tribble.dbsnp.DbSNPCodec;
import org.broad.tribble.dbsnp.DbSNPFeature;
@ -16,11 +14,9 @@ import org.broadinstitute.sting.gatk.walkers.By;
import org.broadinstitute.sting.gatk.walkers.DataSource;
import org.broadinstitute.sting.gatk.walkers.LocusWalker;
import org.broadinstitute.sting.gatk.walkers.Requires;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintStream;
@ -69,7 +65,7 @@ public class DbSNPWindowCounter extends LocusWalker<Integer, Long> {
windowStart,
windowStop);
} catch (IOException e) {
throw new UserError.CouldNotReadInputFile(myDbSNPFile, e);
throw new UserException.CouldNotReadInputFile(myDbSNPFile, e);
}
// count the number of dbSNPs we've seen

View File

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

View File

@ -16,9 +16,8 @@ import org.broadinstitute.sting.gatk.walkers.Reference;
import org.broadinstitute.sting.gatk.walkers.RodWalker;
import org.broadinstitute.sting.gatk.walkers.Window;
import org.broadinstitute.sting.utils.SampleUtils;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
import java.io.PrintStream;
@ -46,7 +45,7 @@ public class IndelDBRateWalker extends RodWalker<OverlapTable,OverlapTabulator>
public void initialize() {
if ( indelWindow > 40 ) {
throw new UserError.CommandLineError("Indel windows have a maximum size of 40");
throw new UserException.CommandLineException("Indel windows have a maximum size of 40");
}
if ( outVCF != null ) {

View File

@ -30,8 +30,7 @@ import java.io.IOException;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.QualityUtils;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.pileup.ReadBackedPileup;
import org.broadinstitute.sting.utils.pileup.PileupElement;
import org.broadinstitute.sting.commandline.Argument;
@ -170,7 +169,7 @@ public class QualityScoreByStrandWalker extends LocusWalker<StrandedCounts,Stran
pairOut.close();
}
} catch ( IOException e ) {
throw new UserError.CouldNotCreateOutputFile(new File(pairOutput), e);
throw new UserException.CouldNotCreateOutputFile(new File(pairOutput), e);
}
}
}

View File

@ -32,10 +32,9 @@ import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.GenomeLocParser;
import org.broadinstitute.sting.utils.StingException;
import net.sf.samtools.SAMRecord;
import net.sf.samtools.SAMFileWriter;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.io.*;
@ -80,9 +79,9 @@ public class ReadQualityScoreWalker extends ReadWalker<SAMRecord, SAMFileWriter>
try {
inputReader = new BufferedReader( new FileReader ( inputQualityFile ) );
} catch ( FileNotFoundException e) {
throw new UserError.CouldNotReadInputFile(new File(inputQualityFile), e);
throw new UserException.CouldNotReadInputFile(new File(inputQualityFile), e);
} catch (IOException e) {
throw new UserError.CouldNotReadInputFile(new File(inputQualityFile), e);
throw new UserException.CouldNotReadInputFile(new File(inputQualityFile), e);
}
return outputBamFile;
}
@ -104,13 +103,13 @@ public class ReadQualityScoreWalker extends ReadWalker<SAMRecord, SAMFileWriter>
try {
if( line == null ) {
line = inputReader.readLine();
if( line == null ) { throw new UserError.MalformedFile(new File(inputQualityFile), "Input file is empty" ); }
if( line == null ) { throw new UserException.MalformedFile(new File(inputQualityFile), "Input file is empty" ); }
}
String[] halves = line.split( " ", 2 );
GenomeLoc curLoc = GenomeLocParser.parseGenomeLoc( halves[0] );
while( curLoc.isBefore( readLoc ) ) { // Loop until the beginning of the read
line = inputReader.readLine();
if( line == null ) { throw new UserError.MalformedFile(new File(inputQualityFile), "Input file doesn't encompass all reads. Can't find beginning of read: " + readLoc ); }
if( line == null ) { throw new UserException.MalformedFile(new File(inputQualityFile), "Input file doesn't encompass all reads. Can't find beginning of read: " + readLoc ); }
halves = line.split( " ", 2 );
curLoc = GenomeLocParser.parseGenomeLoc( halves[0] );
}
@ -123,7 +122,7 @@ public class ReadQualityScoreWalker extends ReadWalker<SAMRecord, SAMFileWriter>
sumNeighborhoodQuality += Float.parseFloat( halves[1] );
numLines++;
line = inputReader.readLine();
if( line == null ) { throw new UserError.MalformedFile(new File(inputQualityFile), "Input file doesn't encompass all reads. Can't find end of read: " + readLoc ); }
if( line == null ) { throw new UserException.MalformedFile(new File(inputQualityFile), "Input file doesn't encompass all reads. Can't find end of read: " + readLoc ); }
halves = line.split( " ", 2 );
curLoc = GenomeLocParser.parseGenomeLoc( halves[0] );
}
@ -133,9 +132,9 @@ public class ReadQualityScoreWalker extends ReadWalker<SAMRecord, SAMFileWriter>
line = savedLine;
} catch ( FileNotFoundException e ) {
throw new UserError.CouldNotReadInputFile(new File(inputQualityFile), e);
throw new UserException.CouldNotReadInputFile(new File(inputQualityFile), e);
} catch (IOException e ) {
throw new UserError.CouldNotReadInputFile(new File(inputQualityFile), e);
throw new UserException.CouldNotReadInputFile(new File(inputQualityFile), e);
}
meanNeighborhoodQuality = sumNeighborhoodQuality / ((float) numLines);

View File

@ -35,14 +35,13 @@ import org.broadinstitute.sting.alignment.Alignment;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.GenomeLocParser;
import net.sf.samtools.SAMRecord;
import net.sf.samtools.util.StringUtil;
import net.sf.picard.reference.ReferenceSequence;
import net.sf.picard.reference.IndexedFastaSequenceFile;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.io.File;
import java.io.FileInputStream;
@ -87,7 +86,7 @@ public class TestReadFishingWalker extends ReadWalker<Integer,Long> {
indelCallInputStream = new FileInputStream(indelCalls);
}
catch(IOException ex) {
throw new UserError.CouldNotReadInputFile(indelCalls, ex);
throw new UserException.CouldNotReadInputFile(indelCalls, ex);
}
Scanner indelCallReader = new Scanner(indelCallInputStream);

View File

@ -1,6 +1,5 @@
package org.broadinstitute.sting.gatk.walkers.varianteval;
import org.apache.log4j.Logger;
import org.broad.tribble.util.variantcontext.VariantContext;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
@ -9,12 +8,10 @@ import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.playground.utils.report.tags.Analysis;
import org.broadinstitute.sting.playground.utils.report.tags.DataPoint;
import org.broadinstitute.sting.playground.utils.report.utils.TableType;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.analysis.AminoAcid;
import org.broadinstitute.sting.utils.analysis.AminoAcidTable;
import org.broadinstitute.sting.utils.analysis.AminoAcidUtils;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
/*
* Copyright (c) 2010 The Broad Institute
@ -145,11 +142,11 @@ public class AminoAcidTransition extends VariantEvaluator {
infoValueSplit = parent.aminoAcidTransitionSplit;
useCodons = parent.aatUseCodons;
if ( infoKey == null ) {
throw new UserError.CommandLineError("No info-field key provided for amino acid tabulation. Please provide the appropriate key with -aatk.");
throw new UserException.CommandLineException("No info-field key provided for amino acid tabulation. Please provide the appropriate key with -aatk.");
}
if ( infoValueSplit == null ) {
throw new UserError.CommandLineError("No split string provided for amino acid tabulation. Please provide the split string with -aats");
throw new UserException.CommandLineException("No split string provided for amino acid tabulation. Please provide the split string with -aats");
}
}
}

View File

@ -2,8 +2,6 @@ package org.broadinstitute.sting.playground.examples;
import org.apache.log4j.BasicConfigurator;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.Serializer;

View File

@ -4,10 +4,9 @@ import org.broadinstitute.sting.gatk.walkers.ReadWalker;
import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTracker;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.utils.StingException;
import net.sf.samtools.SAMRecord;
import net.sf.samtools.SAMReadGroupRecord;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.util.*;
import java.io.File;
@ -79,7 +78,7 @@ public class MatePairLibrarySize extends ReadWalker<Integer, Integer> {
pw.close();
}
} catch (IOException e) {
throw new UserError.CouldNotCreateOutputFile(file, e);
throw new UserException.CouldNotCreateOutputFile(file, e);
}
}
}

View File

@ -36,7 +36,6 @@ import org.broad.tribble.FeatureSource;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedData;
import org.broadinstitute.sting.gatk.refdata.SeekableRODIterator;
import org.broadinstitute.sting.gatk.refdata.features.refseq.RefSeqCodec;
import org.broadinstitute.sting.gatk.refdata.features.refseq.RefSeqFeature;
@ -47,11 +46,10 @@ import org.broadinstitute.sting.gatk.walkers.DataSource;
import org.broadinstitute.sting.gatk.walkers.LocusWalker;
import org.broadinstitute.sting.gatk.walkers.TreeReducible;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.collections.Pair;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.io.File;
import java.io.IOException;
@ -121,7 +119,7 @@ public class HybSelPerformanceWalker extends LocusWalker<Integer, HybSelPerforma
try {
refseqIterator = new SeekableRODIterator(new FeatureToGATKFeatureIterator(refseq.iterator(), "refseq"));
} catch (IOException e) {
throw new UserError.CouldNotReadInputFile(REFSEQ_FILE, e);
throw new UserException.CouldNotReadInputFile(REFSEQ_FILE, e);
}
logger.info("Using RefSeq annotations from "+REFSEQ_FILE);

View File

@ -49,7 +49,7 @@ import net.sf.samtools.SAMRecord;
import org.broadinstitute.sting.gatk.iterators.PushbackIterator;
import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.sam.AlignmentUtils;
import org.broadinstitute.sting.utils.collections.Pair;
@ -103,7 +103,7 @@ public class GenomicMap implements Iterable<Map.Entry<String, Collection<GenomeL
while( ( line = reader.readLine() ) != null ) {
String[] halves = line.split("#",2);
if ( halves.length < 2 )
throw new UserError.MalformedFile(f, "Line: "+line+"\nin map file "+f+"\n does not contain contig name");
throw new UserException.MalformedFile(f, "Line: "+line+"\nin map file "+f+"\n does not contain contig name");
int p1 = 0;
for ( ; p1 < halves[1].length() && Character.isWhitespace(halves[1].charAt(p1) ); p1++ );
@ -113,13 +113,13 @@ public class GenomicMap implements Iterable<Map.Entry<String, Collection<GenomeL
// p2 is index of first whitespace after first word
if ( p1 == p2 )
throw new UserError.MalformedFile(f, "Line: "+line+"\n in map file "+f+"\nNo contig name found after '#'");
throw new UserException.MalformedFile(f, "Line: "+line+"\n in map file "+f+"\nNo contig name found after '#'");
String name = halves[1].substring(p1, p2);
String[] coord_parts = halves[0].split("\\s");
if ( coord_parts.length % 3 != 0 )
throw new UserError.MalformedFile(f, "Line: "+line+"\n in map file "+f+"\nNumber of coordinate fields is not a multiple of 3");
throw new UserException.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 );
@ -136,9 +136,9 @@ public class GenomicMap implements Iterable<Map.Entry<String, Collection<GenomeL
}
reader.close();
} catch ( FileNotFoundException e) {
throw new UserError.CouldNotReadInputFile(f, e);
throw new UserException.CouldNotReadInputFile(f, e);
} catch (IOException e) {
throw new UserError.CouldNotReadInputFile(f, e);
throw new UserException.CouldNotReadInputFile(f, e);
}
}
@ -188,9 +188,9 @@ public class GenomicMap implements Iterable<Map.Entry<String, Collection<GenomeL
}
reader.close();
} catch ( FileNotFoundException e) {
throw new UserError.CouldNotReadInputFile(f, e);
throw new UserException.CouldNotReadInputFile(f, e);
} catch (IOException e) {
throw new UserError.CouldNotReadInputFile(f, e);
throw new UserException.CouldNotReadInputFile(f, e);
}
}
@ -209,7 +209,7 @@ public class GenomicMap implements Iterable<Map.Entry<String, Collection<GenomeL
}
writer.close();
} catch (IOException e) {
throw new UserError.CouldNotCreateOutputFile(f, e);
throw new UserException.CouldNotCreateOutputFile(f, e);
}
}
@ -242,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):
Collection<GenomeLoc> segments = getContigMapping(r.getReferenceName());
if ( segments == null ) throw new UserError.MalformedBam(r, "Can not remap a record: unknown custom contig name "+r.getReferenceName());
if ( segments == null ) throw new UserException.MalformedBam(r, "Can not remap a record: unknown custom contig name "+r.getReferenceName());
// scroll the list of intervals until we find the interval that the alignment start falls into:
Pair<? extends Iterator<GenomeLoc>, Integer> p = seekForward(segments,customStart);
@ -316,7 +316,7 @@ public class GenomicMap implements Iterable<Map.Entry<String, Collection<GenomeL
if ( discardCrossContig ) {
// System.out.println("WARNING: ALIGNMENT DISCARDED: "+message);
return null;
} else throw new UserError.MalformedBam(r, message);
} else throw new UserException.MalformedBam(r, message);
}
gl = iter.next(); // advance to next segment
@ -324,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
if ( gl.getContigIndex() != r.getReferenceIndex() )
throw new UserError.MalformedBam(r, "Contig "+oldRefName+
throw new UserException.MalformedBam(r, "Contig "+oldRefName+
" has segments on different master contigs: currently unsupported");
if ( refPos < currStop + 1 )
throw new UserError.MalformedBam(r, "Contig "+oldRefName+
throw new UserException.MalformedBam(r, "Contig "+oldRefName+
" has segments that are out of order or strictly adjacent: currently unsupported");
if ( len > 0 && refPos > currStop + 1 ) {
// add "panning" N's w/respect to the master ref over the region between adjacent segments

View File

@ -1,8 +1,7 @@
package org.broadinstitute.sting.playground.utils.report.templates;
import org.broadinstitute.sting.playground.utils.report.utils.Node;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.io.File;
import java.io.FileNotFoundException;
@ -32,7 +31,7 @@ public class GrepFormat implements ReportFormat {
try {
stream = new PrintWriter(baseFile);
} catch (FileNotFoundException e) {
throw new UserError.CouldNotCreateOutputFile(baseFile, e);
throw new UserException.CouldNotCreateOutputFile(baseFile, e);
}
privateWrite(baseNode);
}

View File

@ -1,8 +1,7 @@
package org.broadinstitute.sting.playground.utils.report.templates;
import org.broadinstitute.sting.playground.utils.report.utils.Node;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.io.*;
import java.util.*;
@ -37,7 +36,7 @@ public abstract class TableBasedFormat implements ReportFormat {
* @param baseNode the root node
*/
public void write(Writer writeLocation, Node baseNode) {
if (splitFilesByAnalysis()) throw new UserError.CommandLineError("Unable to write output report, we require a file input for multi-file formats");
if (splitFilesByAnalysis()) throw new UserException.CommandLineException("Unable to write output report, we require a file input for multi-file formats");
// if there is only a single output file, create it
stream = new PrintWriter(writeLocation);
traverseAnalysisNodes(baseNode);
@ -229,7 +228,7 @@ public abstract class TableBasedFormat implements ReportFormat {
try {
stream = new PrintWriter(file);
} catch (FileNotFoundException e) {
throw new UserError.CouldNotCreateOutputFile(file, e);
throw new UserException.CouldNotCreateOutputFile(file, e);
}
}
}

View File

@ -1,7 +1,6 @@
package org.broadinstitute.sting.playground.utils.report.templates;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.io.IOException;
import java.io.Writer;
@ -104,7 +103,7 @@ class TextTable {
try {
writer.append("\n");
} catch (IOException e) {
throw new UserError.CouldNotCreateOutputFile(writer.toString(), "Unable to write to the Writer", e);
throw new UserException.CouldNotCreateOutputFile(writer.toString(), "Unable to write to the Writer", e);
}
}
@ -129,7 +128,7 @@ class TextTable {
if (y != rows.size() - 1)
writer.append(seperator);
} catch (IOException e) {
throw new UserError.CouldNotCreateOutputFile(writer.toString(), "Unable to write to the Writer", e);
throw new UserException.CouldNotCreateOutputFile(writer.toString(), "Unable to write to the Writer", e);
}
}

View File

@ -25,7 +25,7 @@
package org.broadinstitute.sting.utils;
/**
* Temp class to track split from Sting exception to UserError
* Temp class to track split from Sting exception to UserException
*/
public class GATKException extends StingException {
public GATKException(String msg) {

View File

@ -42,7 +42,7 @@ import org.apache.log4j.Logger;
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
import org.broadinstitute.sting.gatk.arguments.ValidationExclusion;
import org.broadinstitute.sting.utils.bed.BedParser;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.interval.IntervalMergingRule;
import org.broadinstitute.sting.utils.text.XReadLines;
@ -97,7 +97,7 @@ public class GenomeLocParser {
*/
public static int getContigIndex(final String contig, boolean exceptionOut) {
if (contigInfo.getSequenceIndex(contig) == -1 && exceptionOut)
throw new UserError.CommandLineError(String.format("Contig %s given as location, but this contig isn't present in the Fasta sequence dictionary", contig));
throw new UserException.CommandLineException(String.format("Contig %s given as location, but this contig isn't present in the Fasta sequence dictionary", contig));
return contigInfo.getSequenceIndex(contig);
}
@ -123,7 +123,7 @@ public class GenomeLocParser {
public static boolean setupRefContigOrdering(final SAMSequenceDictionary seqDict) {
if (seqDict == null) { // we couldn't load the reference dictionary
//logger.info("Failed to load reference dictionary, falling back to lexicographic order for contigs");
throw new UserError.CommandLineError("Failed to load reference dictionary");
throw new UserException.CommandLineException("Failed to load reference dictionary");
} else if (contigInfo == null) {
contigInfo = seqDict;
logger.debug(String.format("Prepared reference sequence contig dictionary"));
@ -193,13 +193,13 @@ public class GenomeLocParser {
stop = parsePosition(str.substring(dashIndex + 1));
}
} catch(Exception e) {
throw new UserError("Failed to parse Genome Location string: " + str, e);
throw new UserException("Failed to parse Genome Location string: " + str, e);
}
}
// is the contig valid?
if (!isContigValid(contig))
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?");
throw new UserException("Contig '" + contig + "' does not match any contig in the GATK sequence dictionary derived from the reference; are you sure you are using the correct reference fasta file?");
if (stop == Integer.MAX_VALUE && hasKnownContigOrdering())
// lookup the actually stop position!
@ -371,7 +371,7 @@ public class GenomeLocParser {
return ret.isEmpty() ? null : ret;
}
catch (IOException e2) {
throw new UserError.CouldNotReadInputFile(new File(file_name), e);
throw new UserException.CouldNotReadInputFile(new File(file_name), e);
}
}
}

View File

@ -0,0 +1,312 @@
/*
* 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;
import net.sf.samtools.SAMSequenceDictionary;
import net.sf.samtools.SAMSequenceRecord;
import org.apache.log4j.Logger;
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
import org.broadinstitute.sting.gatk.arguments.ValidationExclusion;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.util.*;
/**
* Created by IntelliJ IDEA.
* User: depristo
* Date: Sep 10, 2010
* Time: 1:56:24 PM
*
* A series of utility functions that enable the GATK to compare two sequence dictionaries -- from the reference,
* from BAMs, or from RODs -- for consistency. The system supports two basic modes: get an enum state that
* describes at a high level the consistency between two dictionaries, or a validateDictionaries that will
* blow up with a UserException if the dicts are too incompatible.
*
* Dictionaries are tested for contig name overlaps, consistency in ordering in these overlap set, and length,
* if available. Examines the Engine arguments to decided if the -U option to allow danger seq dict inconsistency
* is enabled before it blows up.
*/
public class SequenceDictionaryUtils {
public enum SequenceDictionaryCompatability {
IDENTICAL, // the dictionaries are identical
COMMON_SUBSET, // there exists a common subset of equivalent contigs
NO_COMMON_CONTIGS, // no overlap between dictionaries
UNEQUAL_COMMON_CONTIGS, // common subset has contigs that have the same name but aren't equivalent
NON_CANONICAL_HUMAN_ORDER, // human reference detected but the order of the contigs is non-standard (lexicographic, for examine)
OUT_OF_ORDER // the two dictionaries overlap but the contigs occur out of order w.r.t each other
}
/**
* @return Returns true if the engine is in tolerant mode and we'll let through dangerous but not fatal dictionary inconsistency
*/
public static boolean allowNonFatalIncompabilities() {
return GenomeAnalysisEngine.instance != null &&
( GenomeAnalysisEngine.instance.getArguments().unsafe == ValidationExclusion.TYPE.ALLOW_SEQ_DICT_INCOMPATIBILITY ||
GenomeAnalysisEngine.instance.getArguments().unsafe == ValidationExclusion.TYPE.ALL );
}
/**
* Testings for compatbility between dict1 and dict2. If the dictionaries are incompatible, then UserExceptions are
* thrown with detailed error messages. If the engine is in permissive mode, then logger.warnings of generated instead
*
* @param logger for warnings
* @param name1 name associated with dict1
* @param dict1 the sequence dictionary dict1
* @param name2 name associated with dict2
* @param dict2 the sequence dictionary dict2
*/
public static void validateDictionaries(Logger logger, String name1, SAMSequenceDictionary dict1, String name2, SAMSequenceDictionary dict2) {
switch ( compareDictionaries(dict1, dict2) ) {
case IDENTICAL:
return;
case COMMON_SUBSET:
return;
case NO_COMMON_CONTIGS:
throw new UserException.IncompatibleSequenceDictionaries("No overlapping contigs found", name1, dict1, name2, dict2);
case UNEQUAL_COMMON_CONTIGS: {
List<SAMSequenceRecord> x = findDisequalCommonContigs(getCommonContigsByName(dict1, dict2), dict1, dict2);
SAMSequenceRecord elt1 = x.get(0);
SAMSequenceRecord elt2 = x.get(1);
// todo -- replace with toString when SAMSequenceRecord has a nice toString routine
UserException ex = new UserException.IncompatibleSequenceDictionaries(String.format("Found contigs with the same name but different lengths:\n contig %s = %s / %d\n contig %s = %s / %d",
name1, elt1.getSequenceName(), elt1.getSequenceLength(),
name2, elt2.getSequenceName(), elt2.getSequenceLength()),
name1, dict1, name2, dict2);
if ( allowNonFatalIncompabilities() )
logger.warn(ex.getMessage());
else
throw ex;
break;
}
case NON_CANONICAL_HUMAN_ORDER:
UserException ex = new UserException.IncompatibleSequenceDictionaries("Human genome sequence provided in non-canonical ordering. For safety's sake the GATK requires contigs in karyotypic order: 1, 2, ..., 10, 11, ..., 20, 21, 22, X, Y with M either leading or trailing these contigs",
name1, dict1, name2, dict2);
if ( allowNonFatalIncompabilities() )
logger.warn(ex.getMessage());
else
throw ex;
case OUT_OF_ORDER:
throw new UserException.IncompatibleSequenceDictionaries("Order of contigs differences, which is unsafe", name1, dict1, name2, dict2);
default:
throw new GATKException("Unexpected SequenceDictionaryComparison type");
}
}
/**
* Workhorse routine that takes two dictionaries and returns their compatibility.
*
* @param dict1
* @param dict2
* @return
*/
public static SequenceDictionaryCompatability compareDictionaries(SAMSequenceDictionary dict1, SAMSequenceDictionary dict2) {
// If there's no overlap between reads and reference, data will be bogus. Throw an exception.
Set<String> commonContigs = getCommonContigsByName(dict1, dict2);
if (commonContigs.size() == 0)
return SequenceDictionaryCompatability.NO_COMMON_CONTIGS;
else if ( ! commonContigsAreEquivalent( commonContigs, dict1, dict2 ) )
return SequenceDictionaryCompatability.UNEQUAL_COMMON_CONTIGS;
else if ( nonCanonicalHumanContigOrder( commonContigs, dict1, dict2 ) )
return SequenceDictionaryCompatability.NON_CANONICAL_HUMAN_ORDER;
else if ( ! commonContigsAreInOrder( commonContigs, dict1, dict2 ) )
return SequenceDictionaryCompatability.OUT_OF_ORDER;
else if ( commonContigs.size() == dict1.size() && commonContigs.size() == dict2.size() )
return SequenceDictionaryCompatability.IDENTICAL;
else {
return SequenceDictionaryCompatability.COMMON_SUBSET;
}
}
/**
* Utility function that tests whether the commonContigs in both dicts are equivalent. Equivalece means
* that the seq records have the same length, if both are non-zero.
*
* @param commonContigs
* @param dict1
* @param dict2
* @return true if all of the common contigs are equivalent
*/
private static boolean commonContigsAreEquivalent(Set<String> commonContigs, SAMSequenceDictionary dict1, SAMSequenceDictionary dict2) {
return findDisequalCommonContigs(commonContigs, dict1, dict2) == null;
}
/**
* Returns a List(x,y) that contains two disequal sequence records among the common contigs in both dicts. Returns
* null if all common contigs are equivalent
*
* @param commonContigs
* @param dict1
* @param dict2
* @return
*/
private static List<SAMSequenceRecord> findDisequalCommonContigs(Set<String> commonContigs, SAMSequenceDictionary dict1, SAMSequenceDictionary dict2) {
for ( String name : commonContigs ) {
SAMSequenceRecord elt1 = dict1.getSequence(name);
SAMSequenceRecord elt2 = dict2.getSequence(name);
if ( ! SequenceRecordsAreEquivalent(elt1, elt2) )
return Arrays.asList(elt1,elt2);
}
return null;
}
/**
* Helper routine that returns two sequence records are equivalent, defined as having the same name and
* lengths, if both are non-zero
*
* @param me
* @param that
* @return
*/
private static boolean SequenceRecordsAreEquivalent(final SAMSequenceRecord me, final SAMSequenceRecord that) {
if (me == that) return true;
if (that == null) return false;
// I don't care if the indices are difference
//if (me.getSequenceIndex() != that.getSequenceIndex()) return false;
if (me.getSequenceLength() != 0 && that.getSequenceLength() != 0 && me.getSequenceLength() != that.getSequenceLength())
return false;
// todo -- reenable if we want to be really strict here
// if (me.getAttribute(SAMSequenceRecord.MD5_TAG) != null && that.getAttribute(SAMSequenceRecord.MD5_TAG) != null) {
// final BigInteger thisMd5 = new BigInteger((String)me.getAttribute(SAMSequenceRecord.MD5_TAG), 16);
// final BigInteger thatMd5 = new BigInteger((String)that.getAttribute(SAMSequenceRecord.MD5_TAG), 16);
// if (!thisMd5.equals(thatMd5)) {
// return false;
// }
// }
// else {
if (me.getSequenceName() != that.getSequenceName())
return false; // Compare using == since we intern() the Strings
// }
return true;
}
/**
* Placeholder for function that determines if the dicts come from the human genome that's been sorted in a
* non-canonical order. Returns just returns false (function not enabled).
*
* @param commonContigs
* @param dict1
* @param dict2
* @return
*/
private static boolean nonCanonicalHumanContigOrder(Set<String> commonContigs, SAMSequenceDictionary dict1, SAMSequenceDictionary dict2) {
// todo -- implement me if we decide to detect this case
return false;
}
/**
* Returns true if the common contigs in dict1 and dict2 are in the same order. This is accomplished by getting the
* common contigs in both dictionaries, sorting these according to their indices, and the walking through
* the sorted list to ensure that each ordered contig is equivalent
*
* @param commonContigs
* @param dict1
* @param dict2
* @return
*/
public static boolean commonContigsAreInOrder(Set<String> commonContigs, SAMSequenceDictionary dict1, SAMSequenceDictionary dict2) {
List<SAMSequenceRecord> list1 = sortSequenceListByIndex(getSequencesOfName(commonContigs, dict1));
List<SAMSequenceRecord> list2 = sortSequenceListByIndex(getSequencesOfName(commonContigs, dict2));
for ( int i = 0; i < list1.size(); i++ ) {
SAMSequenceRecord elt1 = list1.get(i);
SAMSequenceRecord elt2 = list2.get(i);
if ( ! elt1.getSequenceName().equals(elt2.getSequenceName()) )
return false;
}
return true;
}
/**
* Gets the subset of SAMSequenceRecords in commonContigs in dict
*
* @param commonContigs
* @param dict
* @return
*/
private static List<SAMSequenceRecord> getSequencesOfName(Set<String> commonContigs, SAMSequenceDictionary dict) {
List<SAMSequenceRecord> l = new ArrayList<SAMSequenceRecord>(commonContigs.size());
for ( String name : commonContigs ) {
l.add(dict.getSequence(name) );
}
return l;
}
// --------------------------------------------------------------------------------------------------------------
// Utilities for comparing the order of sequence records
// --------------------------------------------------------------------------------------------------------------
/**
* Compares sequence records by their order
*/
private static class CompareSequenceRecordsByIndex implements Comparator<SAMSequenceRecord> {
public int compare(SAMSequenceRecord x, SAMSequenceRecord y) {
return new Integer(x.getSequenceIndex()).compareTo(y.getSequenceIndex());
}
}
/**
* Returns a sorted list of SAMSequenceRecords sorted by their indices. Note that the
* list is modified in place, so the returned list is == to the unsorted list.
*
* @param unsorted
* @return
*/
private static List<SAMSequenceRecord> sortSequenceListByIndex(List<SAMSequenceRecord> unsorted) {
Collections.sort(unsorted, new CompareSequenceRecordsByIndex());
return unsorted;
}
/**
* Returns the set of contig names found in both dicts.
* @param dict1
* @param dict2
* @return
*/
public static Set<String> getCommonContigsByName(SAMSequenceDictionary dict1, SAMSequenceDictionary dict2) {
Set<String> intersectingSequenceNames = new HashSet<String>(getContigNames(dict1));
intersectingSequenceNames.retainAll(getContigNames(dict2));
return intersectingSequenceNames;
}
public static List<String> getContigNames(SAMSequenceDictionary dict) {
List<String> contigNames = new ArrayList<String>();
for (SAMSequenceRecord dictionaryEntry : dict.getSequences())
contigNames.add(dictionaryEntry.getSequenceName());
return contigNames;
}
}

View File

@ -1,8 +1,6 @@
package org.broadinstitute.sting.utils.bed;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.interval.IntervalMergingRule;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.GenomeLocParser;
@ -34,7 +32,7 @@ public class BedParser {
try {
mIn = new BufferedReader(new FileReader(fl));
} catch (FileNotFoundException e) {
throw new UserError.CouldNotReadInputFile(fl, e);
throw new UserException.CouldNotReadInputFile(fl, e);
}
mLocations = parseLocations();
}
@ -62,7 +60,7 @@ public class BedParser {
locArray.add(parseLocation(line));
}
} catch (IOException e) {
throw new UserError.MalformedFile("Unable to parse line in BED file.");
throw new UserException.MalformedFile("Unable to parse line in BED file.");
}
return locArray;
}
@ -83,7 +81,7 @@ public class BedParser {
start = Integer.valueOf(parts[1]) + TO_ONE_BASED_ADDITION;
stop = Integer.valueOf(parts[2]); // the ending point is an open interval
} catch (Exception e) {
throw new UserError.MalformedFile("Unable to process bed file line = " + line, e);
throw new UserException.MalformedFile("Unable to process bed file line = " + line, e);
}
// we currently drop the rest of the bed record, which can contain names, scores, etc

View File

@ -24,13 +24,6 @@
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;
/**
@ -40,7 +33,7 @@ import java.lang.reflect.InvocationTargetException;
* Date: Sep 3, 2010
* Time: 2:24:09 PM
*/
public class DynamicClassResolutionException extends UserError {
public class DynamicClassResolutionException extends UserException {
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()));

View File

@ -27,11 +27,11 @@ package org.broadinstitute.sting.utils.exceptions;
import net.sf.samtools.SAMFileHeader;
import net.sf.samtools.SAMRecord;
import net.sf.samtools.SAMSequenceDictionary;
import net.sf.samtools.SAMSequenceRecord;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
/**
* Represents the common user errors detected by Sting / GATK
@ -42,43 +42,43 @@ import java.lang.reflect.InvocationTargetException;
* Date: Sep 3, 2010
* Time: 2:24:09 PM
*/
public class UserError extends GATKException {
public UserError(String msg) { super(msg); }
public UserError(String msg, Throwable e) { super(msg, e); }
private UserError(Throwable e) { super("", e); } // cannot be called, private access
public class UserException extends GATKException {
public UserException(String msg) { super(msg); }
public UserException(String msg, Throwable e) { super(msg, e); }
private UserException(Throwable e) { super("", e); } // cannot be called, private access
public static class CommandLineError extends UserError {
public CommandLineError(String message) {
public static class CommandLineException extends UserException {
public CommandLineException(String message) {
super(String.format("Invalid command line: %s", message));
}
}
public static class BadInput extends UserError {
public static class BadInput extends UserException {
public BadInput(String message) {
super(String.format("Bad input: %s", message));
}
}
// todo -- fix up exception cause passing
public static class MissingArgument extends CommandLineError {
public static class MissingArgument extends CommandLineException {
public MissingArgument(String arg, String message) {
super(String.format("Argument %s was missing: %s", arg, message));
}
}
public static class BadArgumentValue extends CommandLineError {
public static class BadArgumentValue extends CommandLineException {
public BadArgumentValue(String arg, String message) {
super(String.format("Argument %s has a bad value: %s", arg, message));
}
}
public static class BadTmpDir extends UserError {
public static class BadTmpDir extends UserException {
public BadTmpDir(String message) {
super(String.format("Failure working with the tmp directory %s. Override with -Djava.io.tmpdir=X on the command line to a bigger/better file system. Exact error was %s", System.getProperties().get("java.io. tmpdir"), message));
}
}
public static class CouldNotReadInputFile extends UserError {
public static class CouldNotReadInputFile extends UserException {
public CouldNotReadInputFile(String message, Exception e) {
super(String.format("Couldn't read file because %s caused by %s", message, e.getMessage()));
}
@ -97,7 +97,7 @@ public class UserError extends GATKException {
}
public static class CouldNotCreateOutputFile extends UserError {
public static class CouldNotCreateOutputFile extends UserException {
public CouldNotCreateOutputFile(File file, String message, Exception e) {
super(String.format("Couldn't write file %s because %s with exception %s", file.getAbsolutePath(), message, e.getMessage()));
}
@ -111,7 +111,7 @@ public class UserError extends GATKException {
}
}
public static class MalformedBam extends UserError {
public static class MalformedBam extends UserException {
public MalformedBam(SAMRecord read, String message) {
super(String.format("SAM/BAM file %s is malformed: %s", read.getFileSource(), message));
}
@ -123,7 +123,7 @@ public class UserError extends GATKException {
}
}
public static class MissortedBAM extends UserError {
public static class MissortedBAM extends UserException {
public MissortedBAM(SAMFileHeader.SortOrder order, File file, SAMFileHeader header) {
super(String.format("Missorted Input SAM/BAM files: %s is must be sorted in %s order but order was: %s", file, order, header.getSortOrder()));
}
@ -142,13 +142,13 @@ public class UserError extends GATKException {
}
}
public static class MissortedFile extends UserError {
public static class MissortedFile extends UserException {
public MissortedFile(File file, String message, Exception e) {
super(String.format("Missorted Input file: %s is must be sorted in coordinate order. %s and got error %s", file, message, e.getMessage()));
}
}
public static class MalformedFile extends UserError {
public static class MalformedFile extends UserException {
public MalformedFile(String message) {
super(String.format("Unknown file is malformed: %s", message));
}
@ -170,27 +170,35 @@ public class UserError extends GATKException {
}
}
public static class CannotExecuteRScript extends UserError {
public static class CannotExecuteRScript extends UserException {
public CannotExecuteRScript(String message, Exception e) {
super(String.format("Unable to execute RScript command: " + message), e);
}
}
public static class DeprecatedArgument extends CommandLineError {
public static class DeprecatedArgument extends CommandLineException {
public DeprecatedArgument(String param, String doc) {
super(String.format("The parameter %s is deprecated. %s",param,doc));
}
}
public static class IncompatibleSequenceDictionaries extends UserError {
public IncompatibleSequenceDictionaries(SAMSequenceDictionary ref, SAMSequenceDictionary alt, String altName) {
// todo -- enumerate all elements in ref and alt
super(String.format("Incompatible input files: no overlap exists between contigs in " + altName + " and the reference."));
public static class IncompatibleSequenceDictionaries extends UserException {
public IncompatibleSequenceDictionaries(String message, String name1, SAMSequenceDictionary dict1, String name2, SAMSequenceDictionary dict2) {
super(String.format("Input files %s and %s have incompatible contigs: %s.\n %s contigs = %s\n %s contigs = %s",
name1, name2, message, name1, prettyPrintSequenceRecords(dict1), name2, prettyPrintSequenceRecords(dict2)));
}
private static String prettyPrintSequenceRecords(SAMSequenceDictionary sequenceDictionary) {
String[] sequenceRecordNames = new String[sequenceDictionary.size()];
int sequenceRecordIndex = 0;
for (SAMSequenceRecord sequenceRecord : sequenceDictionary.getSequences())
sequenceRecordNames[sequenceRecordIndex++] = sequenceRecord.getSequenceName();
return Arrays.deepToString(sequenceRecordNames);
}
}
public static class MissingWalker extends UserError {
public static class MissingWalker extends UserException {
public MissingWalker(String walkerName, String message) {
super(String.format("Walker %s is not available: %s", walkerName, message));
}

View File

@ -1,7 +1,6 @@
package org.broadinstitute.sting.utils.fastq;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.util.Iterator;
import java.util.zip.GZIPInputStream;
@ -24,7 +23,7 @@ public class FastqReader implements Iterator<FastqRecord>, Iterable<FastqRecord>
nextRecord = readNextRecord();
} catch (IOException e) {
throw new UserError.CouldNotReadInputFile(file, String.format("Error opening '%s'", fastqFile.getAbsolutePath()));
throw new UserException.CouldNotReadInputFile(file, String.format("Error opening '%s'", fastqFile.getAbsolutePath()));
}
}
@ -37,7 +36,7 @@ public class FastqReader implements Iterator<FastqRecord>, Iterable<FastqRecord>
return new FastqRecord(seqHeader, seqLine, qualHeader, qualLine);
} catch (IOException e) {
throw new UserError.CouldNotReadInputFile(fastqFile, e);
throw new UserException.CouldNotReadInputFile(fastqFile, e);
}
}
@ -53,7 +52,7 @@ public class FastqReader implements Iterator<FastqRecord>, Iterable<FastqRecord>
nextRecord = null;
}
} catch (IOException e) {
throw new UserError.CouldNotReadInputFile(fastqFile, e);
throw new UserException.CouldNotReadInputFile(fastqFile, e);
}
return rec;
@ -67,7 +66,7 @@ public class FastqReader implements Iterator<FastqRecord>, Iterable<FastqRecord>
try {
in.close();
} catch (IOException e) {
throw new UserError.CouldNotReadInputFile(fastqFile, e);
throw new UserException.CouldNotReadInputFile(fastqFile, e);
}
}
}

View File

@ -4,8 +4,7 @@ import net.sf.samtools.util.BinaryCodec;
import net.sf.samtools.util.BlockCompressedInputStream;
import net.sf.samtools.util.RuntimeEOFException;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.genotype.LikelihoodObject;
import java.io.DataInputStream;
@ -78,7 +77,7 @@ public class GLFReader implements Iterator<GLFRecord> {
try {
inputBinaryCodec = new BinaryCodec(new DataInputStream(new BlockCompressedInputStream(readFrom)));
} catch (IOException e) {
throw new UserError.CouldNotReadInputFile(myFile, e);
throw new UserException.CouldNotReadInputFile(myFile, e);
}
inputBinaryCodec.setInputFileName(readFrom.getName());
@ -86,7 +85,7 @@ public class GLFReader implements Iterator<GLFRecord> {
// first verify that it's a valid GLF
for (short s : glfMagic) {
if (inputBinaryCodec.readUByte() != s)
throw new UserError.MalformedFile(myFile, "Verification of GLF format failed: magic string doesn't match)");
throw new UserException.MalformedFile(myFile, "Verification of GLF format failed: magic string doesn't match)");
}
// get the header string
@ -177,7 +176,7 @@ public class GLFReader implements Iterator<GLFRecord> {
}
//nextRecord = null;
} else {
throw new UserError.MalformedFile(myFile, "Unknown GLF record type (type = " + recordType + ")");
throw new UserException.MalformedFile(myFile, "Unknown GLF record type (type = " + recordType + ")");
}
if (nextRecord != null) currentLocation = nextRecord.getPosition();
return ret;

View File

@ -26,8 +26,7 @@
package org.broadinstitute.sting.utils.interval;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.text.XReadLines;
import org.broadinstitute.sting.gatk.iterators.PushbackIterator;
import org.broadinstitute.sting.gatk.refdata.utils.StringToGenomeLocIteratorAdapter;
@ -71,7 +70,7 @@ public class IntervalFileMergingIterator implements Iterator<GenomeLoc> {
StringToGenomeLocIteratorAdapter.FORMAT.GATK ) ) ;
}
} catch ( FileNotFoundException e ) {
throw new UserError.CouldNotReadInputFile(f, e);
throw new UserException.CouldNotReadInputFile(f, e);
}
myRule = rule;
}
@ -94,7 +93,7 @@ public class IntervalFileMergingIterator implements Iterator<GenomeLoc> {
GenomeLoc next = it.next();
if ( next.isBefore(current)) {
throw new UserError.MalformedFile(myFile, "Interval "+next+" in the interval file is out of order.");
throw new UserException.MalformedFile(myFile, "Interval "+next+" in the interval file is out of order.");
}
if (current.overlapsP(next)) {

View File

@ -2,9 +2,8 @@ package org.broadinstitute.sting.utils.interval;
import org.broadinstitute.sting.utils.GenomeLocSortedSet;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.GenomeLocParser;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.util.LinkedList;
import java.util.List;
@ -40,7 +39,7 @@ public class IntervalUtils {
if (argument.equals("all")) {
if (argList.size() != 1) {
// throw error if '-L all' is not only interval - potentially conflicting commands
throw new UserError.CommandLineError(String.format("Conflicting arguments: Intervals given along with \"-L all\""));
throw new UserException.CommandLineException(String.format("Conflicting arguments: Intervals given along with \"-L all\""));
}
return null;
}
@ -54,7 +53,7 @@ public class IntervalUtils {
rawIntervals.addAll(GenomeLocParser.intervalFileToList(fileOrInterval));
}
catch (Exception e) {
throw new UserError.MalformedFile(fileOrInterval, "Interval file could not be parsed in either format.", e);
throw new UserException.MalformedFile(fileOrInterval, "Interval file could not be parsed in either format.", e);
}
}
@ -146,11 +145,11 @@ public class IntervalUtils {
if (file.exists())
return true;
else
throw new UserError.CouldNotReadInputFile(file, "The interval file does not exist.");
throw new UserException.CouldNotReadInputFile(file, "The interval file does not exist.");
}
if(file.exists())
throw new UserError.CouldNotReadInputFile(file, String.format("The interval file %s does not have one of " +
throw new UserException.CouldNotReadInputFile(file, String.format("The interval file %s does not have one of " +
"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 move or rename the file at location %s", str, str, file.getAbsolutePath()));

View File

@ -3,9 +3,8 @@ package org.broadinstitute.sting.utils.sam;
import java.util.*;
import net.sf.samtools.*;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
/**
* @author ebanks
@ -65,7 +64,7 @@ public class GATKSAMRecord extends SAMRecord {
// sanity check that the lengths of the base and quality strings are equal
if ( getBaseQualities().length != getReadLength() )
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()));
throw new UserException.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

@ -2,8 +2,7 @@ package org.broadinstitute.sting.utils.wiggle;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.exceptions.UserError;
import org.broadinstitute.sting.utils.exceptions.UserException;
import java.io.*;
@ -50,7 +49,7 @@ public class WiggleWriter {
try {
outputStream = new FileOutputStream(outputFile);
} catch ( FileNotFoundException e ) {
throw new UserError.CouldNotCreateOutputFile(outputFile, "Unable to create a wiggle file ", e);
throw new UserException.CouldNotCreateOutputFile(outputFile, "Unable to create a wiggle file ", e);
}
wWriter = new BufferedWriter(new OutputStreamWriter(outputStream));
@ -87,7 +86,7 @@ public class WiggleWriter {
w.flush();
// flush required so writing to output stream will work
} catch (IOException e) {
throw new UserError.CouldNotCreateOutputFile(myFile, String.format("Error writing the wiggle line %s", s), e);
throw new UserException.CouldNotCreateOutputFile(myFile, String.format("Error writing the wiggle line %s", s), e);
}
}
}

View File

@ -2,6 +2,7 @@ package org.broadinstitute.sting;
import org.apache.log4j.*;
import org.apache.log4j.spi.LoggingEvent;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import org.junit.*;
@ -45,6 +46,7 @@ public abstract class BaseTest {
protected static String hg18Reference = "/seq/references/Homo_sapiens_assembly18/v0/Homo_sapiens_assembly18.fasta";
protected static String hg19Reference = "/seq/references/Homo_sapiens_assembly19/v0/Homo_sapiens_assembly19.fasta";
protected static String b36KGReference = "/humgen/1kg/reference/human_b36_both.fasta";
protected static String b37KGReference = "/humgen/1kg/reference/human_g1k_v37.fasta";
protected static String GATKDataLocation = "/humgen/gsa-hpprojects/GATK/data/";
protected static String validationDataLocation = GATKDataLocation + "Validation_Data/";
protected static String evaluationDataLocation = GATKDataLocation + "Evaluation_Data/";
@ -140,13 +142,13 @@ public abstract class BaseTest {
try {
digest = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
throw new StingException("Unable to find MD5 digest");
throw new GATKException("Unable to find MD5 digest");
}
InputStream is;
try {
is = new FileInputStream(file);
} catch (FileNotFoundException e) {
throw new StingException("Unable to open file " + file);
throw new GATKException("Unable to open file " + file);
}
byte[] buffer = new byte[8192];
int read;
@ -160,14 +162,14 @@ public abstract class BaseTest {
}
catch (IOException e) {
throw new StingException("Unable to process file for MD5", e);
throw new GATKException("Unable to process file for MD5", e);
}
finally {
try {
is.close();
}
catch (IOException e) {
throw new StingException("Unable to close input stream for MD5 calculation", e);
throw new GATKException("Unable to close input stream for MD5 calculation", e);
}
}
}

View File

@ -28,6 +28,7 @@ package org.broadinstitute.sting;
import junit.framework.Assert;
import org.broadinstitute.sting.gatk.CommandLineExecutable;
import org.broadinstitute.sting.gatk.CommandLineGATK;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.collections.Pair;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.Utils;
@ -62,7 +63,7 @@ public class WalkerTest extends BaseTest {
if ( ! dir.exists() ) {
System.out.printf("##### Creating MD5 db %s%n", MD5_FILE_DB_SUBDIR);
if ( ! dir.mkdir() ) {
throw new StingException("Infrastructure failure: failed to create md5 directory " + MD5_FILE_DB_SUBDIR);
throw new GATKException("Infrastructure failure: failed to create md5 directory " + MD5_FILE_DB_SUBDIR);
}
}
}
@ -81,7 +82,7 @@ public class WalkerTest extends BaseTest {
try {
FileUtils.copyFile(resultsFile, dbFile);
} catch ( IOException e ) {
throw new StingException(e.getMessage());
throw new GATKException(e.getMessage());
}
} else {
System.out.printf("##### MD5 file is up to date: %s%n", dbFile.getPath());
@ -185,6 +186,7 @@ public class WalkerTest extends BaseTest {
int nOutputFiles = -1;
List<String> md5s = null;
List<String> exts = null;
Class expectedException = null;
protected Map<String, File> auxillaryFiles = new HashMap<String, File>();
@ -201,6 +203,21 @@ public class WalkerTest extends BaseTest {
this.exts = exts;
}
public WalkerTestSpec(String args, int nOutputFiles, Class expectedException) {
this.args = args;
this.nOutputFiles = nOutputFiles;
this.expectedException = expectedException;
}
public boolean expectsException() {
return expectedException != null;
}
public Class getExpectedException() {
if ( ! expectsException() ) throw new GATKException("Tried to get expection for walker test that doesn't expect one");
return expectedException;
}
public void addAuxFile(String expectededMD5sum, File outputfile) {
auxillaryFiles.put(expectededMD5sum, outputfile);
}
@ -223,16 +240,20 @@ public class WalkerTest extends BaseTest {
final String args = String.format(spec.args, tmpFiles.toArray());
System.out.println(Utils.dupString('-', 80));
List<String> md5s = new LinkedList<String>();
md5s.addAll(spec.md5s);
if ( spec.expectsException() ) {
// this branch handles the case were we are testing that a walker will fail as expected
return executeTest(name, null, tmpFiles, args, spec.getExpectedException());
} else {
List<String> md5s = new LinkedList<String>();
md5s.addAll(spec.md5s);
// check to see if they included any auxillary files, if so add them to the list
for (String md5 : spec.auxillaryFiles.keySet()) {
md5s.add(md5);
tmpFiles.add(spec.auxillaryFiles.get(md5));
// check to see if they included any auxillary files, if so add them to the list
for (String md5 : spec.auxillaryFiles.keySet()) {
md5s.add(md5);
tmpFiles.add(spec.auxillaryFiles.get(md5));
}
return executeTest(name, md5s, tmpFiles, args, null);
}
return executeTest(name, md5s, tmpFiles, args);
}
public File createTempFile(String name, String extension) {
@ -241,7 +262,7 @@ public class WalkerTest extends BaseTest {
fl.deleteOnExit();
return fl;
} catch (IOException ex) {
throw new StingException("Cannot create temp file: " + ex.getMessage(), ex);
throw new GATKException("Cannot create temp file: " + ex.getMessage(), ex);
}
}
@ -253,7 +274,7 @@ public class WalkerTest extends BaseTest {
* @param args the argument list
* @return a pair of file and string lists
*/
private Pair<List<File>, List<String>> executeTest(String name, List<String> md5s, List<File> tmpFiles, String args) {
private Pair<List<File>, List<String>> executeTest(String name, List<String> md5s, List<File> tmpFiles, String args, Class expectedException) {
CommandLineGATK instance = new CommandLineGATK();
String[] command;
@ -271,7 +292,6 @@ public class WalkerTest extends BaseTest {
cmd2[command.length + 1] = this.outputFileLocation.getAbsolutePath();
command = cmd2;
}
System.out.println(String.format("Executing test %s with GATK arguments: %s", name, Utils.join(" ",command)));
// add the logging level to each of the integration test commands
String[] cmd2 = Arrays.copyOf(command, command.length + 4);
@ -281,20 +301,47 @@ public class WalkerTest extends BaseTest {
cmd2[command.length+3] = ENABLE_REPORTING ? "STANDARD" : "NO_ET";
// run the executable
boolean gotAnException = false;
try {
System.out.println(String.format("Executing test %s with GATK arguments: %s", name, Utils.join(" ",cmd2)));
CommandLineExecutable.start(instance, cmd2);
} catch (Exception e) {
throw new RuntimeException(e);
gotAnException = true;
if ( expectedException != null ) {
// we expect an exception
System.out.println(String.format("Wanted exception %s, saw %s", expectedException, e.getClass()));
if ( expectedException.isInstance(e) ) {
// it's the type we expected
System.out.println(String.format(" => %s PASSED", name));
} else {
e.printStackTrace();
Assert.fail(String.format("Test %s expected exception %s but got %s instead",
name, expectedException, e.getClass()));
}
} else {
// we didn't expect an exception but we got one :-(
throw new RuntimeException(e);
}
}
// catch failures from the integration test
if (CommandLineExecutable.result != 0) {
throw new RuntimeException("Error running the GATK with arguments: " + args);
if ( expectedException != null ) {
if ( ! gotAnException )
// we expected an exception but didn't see it
Assert.fail(String.format("Test %s expected exception %s but none was thrown", name, expectedException.toString()));
return null;
} else {
if ( CommandLineExecutable.result != 0) {
throw new RuntimeException("Error running the GATK with arguments: " + args);
}
// clean up some memory
instance = null;
cmd2 = null;
// we need to check MD5s
return new Pair<List<File>, List<String>>(tmpFiles, assertMatchingMD5s(name, tmpFiles, md5s));
}
// clean up some memory
instance = null;
cmd2 = null;
return new Pair<List<File>, List<String>>(tmpFiles, assertMatchingMD5s(name, tmpFiles, md5s));
}
private static String[] escapeExpressions(String args, String delimiter) {

View File

@ -26,6 +26,7 @@
package org.broadinstitute.sting.commandline;
import org.broadinstitute.sting.BaseTest;
import org.broadinstitute.sting.utils.GATKException;
import org.broadinstitute.sting.utils.StingException;
import org.junit.Test;
import org.junit.Before;
@ -355,7 +356,7 @@ public class ParsingEngineUnitTest extends BaseTest {
parsingEngine.validate();
}
@Test(expected=StingException.class)
@Test(expected= GATKException.class)
public void duplicateLongNameTest() {
parsingEngine.addArgumentSource( DuplicateLongNameProvider.class );
}
@ -368,7 +369,7 @@ public class ParsingEngineUnitTest extends BaseTest {
public Integer bar;
}
@Test(expected=StingException.class)
@Test(expected=GATKException.class)
public void duplicateShortNameTest() {
parsingEngine.addArgumentSource( DuplicateShortNameProvider.class );
}
@ -593,7 +594,7 @@ public class ParsingEngineUnitTest extends BaseTest {
RequiredArgProvider rap = new RequiredArgProvider();
}
@Test(expected=StingException.class)
@Test(expected=GATKException.class)
public void multipleArgumentCollectionTest() {
parsingEngine.addArgumentSource( MultipleArgumentCollectionProvider.class );
}

View File

@ -1,5 +1,6 @@
package org.broadinstitute.sting.gatk.datasources.providers;
import org.broadinstitute.sting.utils.GATKException;
import org.junit.Before;
import org.junit.Assert;
import org.junit.Test;
@ -66,7 +67,7 @@ public class ShardDataProviderUnitTest extends BaseTest {
/**
* Try adding a view which conflicts with some other view that's already been registered.
*/
@Test(expected=StingException.class)
@Test(expected= GATKException.class)
public void testAddViewWithExistingConflict() {
View initial = new ConflictingTestView( provider );
View conflictsWithInitial = new TestView( provider );
@ -75,7 +76,7 @@ public class ShardDataProviderUnitTest extends BaseTest {
/**
* Try adding a view which has a conflict with a previously registered view.
*/
@Test(expected=StingException.class)
@Test(expected=GATKException.class)
public void testAddViewWithNewConflict() {
View conflictsWithInitial = new TestView( provider );
View initial = new ConflictingTestView( provider );

Some files were not shown because too many files have changed in this diff Show More