this.intersect(that) method added to GenomeLoc (returns intersection of two intervals or dies if the locations do not overlap)

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3852 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
asivache 2010-07-22 16:00:30 +00:00
parent 3308d956f4
commit 485023ba8e
1 changed files with 11 additions and 1 deletions

View File

@ -172,6 +172,16 @@ public class GenomeLoc implements Comparable<GenomeLoc>, Cloneable, Serializable
Math.max( getStop(), that.getStop()) );
}
public GenomeLoc intersect( GenomeLoc that ) throws StingException {
if (!(this.overlapsP(that))) {
throw new StingException("GenomeLoc::intersect(): The two genome loc's need to overlap");
}
return new GenomeLoc(getContig(), this.contigIndex,
Math.max(getStart(), that.getStart()),
Math.min( getStop(), that.getStop()) );
}
public final boolean containsP(GenomeLoc that) {
return onSameContig(that) && getStart() <= that.getStart() && getStop() >= that.getStop();
}
@ -214,7 +224,7 @@ public class GenomeLoc implements Comparable<GenomeLoc>, Cloneable, Serializable
return ( comparison == 1 || ( comparison == 0 && this.getStart() > that.getStop() ));
}
/**
* Check to see whether two genomeLocs are equal.