A nicer error (UserException now) for malformed genome locs
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5465 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
b45afe5ba8
commit
6281c1db6f
|
|
@ -448,11 +448,11 @@ public class GenomeLocParser {
|
||||||
private void exceptionOnInvalidGenomeLocBounds(GenomeLoc locus) {
|
private void exceptionOnInvalidGenomeLocBounds(GenomeLoc locus) {
|
||||||
int contigSize = contigInfo.getSequence(locus.getContigIndex()).getSequenceLength();
|
int contigSize = contigInfo.getSequence(locus.getContigIndex()).getSequenceLength();
|
||||||
if(locus.getStart() > contigSize)
|
if(locus.getStart() > contigSize)
|
||||||
throw new ReviewedStingException(String.format("GenomeLoc is invalid: locus start %d is after the end of contig %s",locus.getStart(),locus.getContig()));
|
throw new UserException.MalformedGenomeLoc("GenomeLoc is invalid: locus start is after the end of contig",locus);
|
||||||
if(locus.getStop() > contigSize)
|
if(locus.getStop() > contigSize)
|
||||||
throw new ReviewedStingException(String.format("GenomeLoc is invalid: locus stop %d is after the end of contig %s",locus.getStop(),locus.getContig()));
|
throw new UserException.MalformedGenomeLoc("GenomeLoc is invalid: locus stop is after the end of contig",locus);
|
||||||
if (locus.getStart() > locus.getStop()) {
|
if (locus.getStart() > locus.getStop()) {
|
||||||
throw new ReviewedStingException("Parameters to GenomeLocParser are incorrect: the start position is greater than the end position");
|
throw new UserException.MalformedGenomeLoc("Parameters to GenomeLocParser are incorrect: the start position is greater than the end position", locus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import net.sf.samtools.SAMSequenceDictionary;
|
||||||
import net.sf.samtools.SAMSequenceRecord;
|
import net.sf.samtools.SAMSequenceRecord;
|
||||||
import org.broad.tribble.util.variantcontext.VariantContext;
|
import org.broad.tribble.util.variantcontext.VariantContext;
|
||||||
import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContextUtils;
|
import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContextUtils;
|
||||||
|
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
@ -54,6 +55,12 @@ public class UserException extends ReviewedStingException {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class MalformedGenomeLoc extends UserException {
|
||||||
|
public MalformedGenomeLoc(String message, GenomeLoc loc) {
|
||||||
|
super(String.format("Badly formed genome loc: %s: %s", message, loc));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class BadInput extends UserException {
|
public static class BadInput extends UserException {
|
||||||
public BadInput(String message) {
|
public BadInput(String message) {
|
||||||
super(String.format("Bad input: %s", message));
|
super(String.format("Bad input: %s", message));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue