Validates intervals against sequence dictionary header bounds.
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1900 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
54c61c663c
commit
2e552eb5a1
|
|
@ -343,8 +343,9 @@ public class GenomeLocParser {
|
|||
List<String> lines = reader.readLines();
|
||||
reader.close();
|
||||
String locStr = Utils.join(";", lines);
|
||||
logger.debug("locStr: " + locStr);
|
||||
ret = parseGenomeLocs(locStr);
|
||||
for(GenomeLoc locus: ret)
|
||||
verifyGenomeLocBounds(locus);
|
||||
return ret;
|
||||
} catch (Exception e2) {
|
||||
logger.error("Attempt to parse interval file in GATK format failed: " + e2.getMessage());
|
||||
|
|
@ -447,8 +448,9 @@ public class GenomeLocParser {
|
|||
|
||||
/**
|
||||
* verify the specified genome loc is valid, if it's not, throw an exception
|
||||
* Will not verify the location against contig bounds.
|
||||
*
|
||||
* @param toReturn teh genome loc we're about to return
|
||||
* @param toReturn the genome loc we're about to return
|
||||
*
|
||||
* @return the genome loc if it's valid, otherwise we throw an exception
|
||||
*/
|
||||
|
|
@ -470,6 +472,20 @@ public class GenomeLocParser {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the locus against the bounds of the contig.
|
||||
* @param locus Locus to verify.
|
||||
*/
|
||||
private static void verifyGenomeLocBounds(GenomeLoc locus) {
|
||||
verifyGenomeLoc(locus);
|
||||
|
||||
int contigSize = contigInfo.getSequence(locus.getContigIndex()).getSequenceLength();
|
||||
if(locus.getStart() > contigSize)
|
||||
throw new StingException(String.format("GenomeLoc is invalid: locus start %d is after the end of contig %s",locus.getStart(),locus.getContig()));
|
||||
if(locus.getStop() > contigSize)
|
||||
throw new StingException(String.format("GenomeLoc is invalid: locus stop %d is after the end of contig %s",locus.getStop(),locus.getContig()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Move this Genome loc to the next contig, with a start
|
||||
|
|
|
|||
Loading…
Reference in New Issue