Package beagleutil
Class ChromInterval
- java.lang.Object
-
- beagleutil.ChromInterval
-
- All Implemented Interfaces:
IntInterval,java.lang.Comparable<ChromInterval>
public final class ChromInterval extends java.lang.Object implements IntInterval, java.lang.Comparable<ChromInterval>
Class
Instances of classChromIntervalrepresents a chromosome interval whose end points are genome coordinates.ChromIntervalare immutable.
-
-
Constructor Summary
Constructors Constructor Description ChromInterval(java.lang.String chrom, int start, int end)Constructs a newChromIntervalinstance.ChromInterval(Marker start, Marker end)Constructs a newChromIntervalinstance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringchrom()Returns the chromosome identifier.intchromIndex()Returns the chromosome index.intcompareTo(ChromInterval o)Compares thisChromIntevalwith the specifiedChromIntervalinstance for order, and returns -1, 0, or 1 depending on whetherthisis less than, equal or greater than the specified instance.booleancontains(Marker marker)Returnstrueif the specified marker is in this chromosome interval and returnsfalseotherwise.booleanequals(java.lang.Object obj)Returnstrueif the specified object is aChromIntervalinstance representing the same interval of genome coordinates asthis, and returnsfalseotherwise.inthashCode()Returns a hash code value for the object.intinclEnd()Returns the last genome coordinate in this chromosome interval.static ChromIntervalmerge(ChromInterval a, ChromInterval b)Returns the union of the specified overlapping chromosome intervals.static booleanoverlap(ChromInterval a, ChromInterval b)Returnstrueif the specified chromosome intervals have non-empty intersection and returnsfalseotherwise.static ChromIntervalparse(java.lang.String str)Returns aChromIntervalinstance corresponding to the specified string, or returnsnullif the specified string does not represent a valid chromosome interval or if the specified string isnull.intstart()Returns the first genome coordinate in this chromosome interval.java.lang.StringtoString()Returns a string describingthis.
-
-
-
Constructor Detail
-
ChromInterval
public ChromInterval(Marker start, Marker end)
Constructs a newChromIntervalinstance.- Parameters:
start- the first marker in the interval.end- the last marker in the interval.- Throws:
java.lang.IllegalArgumentException- ifstart.chromIndex()!=end.chromIndex() || start.pos()<0 || start.pos()>end.pos().java.lang.NullPointerException- ifstart==null || end==null.
-
ChromInterval
public ChromInterval(java.lang.String chrom, int start, int end)Constructs a newChromIntervalinstance.- Parameters:
chrom- the chromosome,start- the first genome coordinate in the interval.end- the last genome coordinate in the interval.- Throws:
java.lang.IllegalArgumentException- ifstart>end || chrom.isEmpty()java.lang.NullPointerException- ifchrom==null
-
-
Method Detail
-
parse
public static ChromInterval parse(java.lang.String str)
Returns a
The string representation of the chromosome interval must have one of the following forms:ChromIntervalinstance corresponding to the specified string, or returnsnullif the specified string does not represent a valid chromosome interval or if the specified string isnull.
[chrom]:[start]-[end] [chrom] [chrom]: [chrom]:[start]- [chrom]:-[end]
where
[chrom]is a chromosome identifier, and[start]and[end]are integers satisfying[start]<=[end]. If the specified string does not contain a start position, thestart()method of the returnedChromIntervalinstance returnsInteger.MIN_VALUE. If no end position is specified, theend()method of the returnedChromIntervalinstance returnsInteger.MAX_VALUE.- Parameters:
str- a chromosome interval.- Returns:
- a
ChromIntervalinstance corresponding to the specified string, or returnsnullif the specified string does not represent a valid chromosome interval or if the specified string isnull.
-
chromIndex
public int chromIndex()
Returns the chromosome index. The chromosome index is equal toChromIds.indexOf(this.chrom()).- Returns:
- the chromosome index.
-
chrom
public java.lang.String chrom()
Returns the chromosome identifier.- Returns:
- the chromosome identifier.
-
start
public int start()
Returns the first genome coordinate in this chromosome interval.- Specified by:
startin interfaceIntInterval- Returns:
- the first genome coordinate in this chromosomet interval.
-
inclEnd
public int inclEnd()
Returns the last genome coordinate in this chromosome interval.- Specified by:
inclEndin interfaceIntInterval- Returns:
- the last genome coordinate in this chromosome interval.
-
compareTo
public int compareTo(ChromInterval o)
Compares this
ChromIntevalwith the specifiedChromIntervalinstance for order, and returns -1, 0, or 1 depending on whetherthisis less than, equal or greater than the specified instance.ChromIntervalobjects are ordered first bythis.chromIndex(), then bythis.start(), and finally bythis.end(). All fields are ordered in ascending order.- Specified by:
compareToin interfacejava.lang.Comparable<ChromInterval>- Parameters:
o- theChromIntervalto be compared withthis.- Returns:
- -1, 0, or 1 depending on whether
thisis less than, equal or greater than the specified instance.
-
hashCode
public int hashCode()
Returns a hash code value for the object.
The hash code is defined by the following calculation:
int hash = 7; hash = 67 * hash + this.chromIndex(); hash = 67 * hash + this.start(); hash = 67 * hash + this.end();- Overrides:
hashCodein classjava.lang.Object- Returns:
- a hash code value for the object.
-
equals
public boolean equals(java.lang.Object obj)
Returnstrueif the specified object is aChromIntervalinstance representing the same interval of genome coordinates asthis, and returnsfalseotherwise.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- the object to be compared withthisfor equality.- Returns:
trueif the specified object is aChromIntervalinstance representing the same interval of genome coordinates asthis, and returnsfalseotherwise.
-
toString
public java.lang.String toString()
Returns a string describingthis. This format of the returned string is unspecified and subject to change.- Overrides:
toStringin classjava.lang.Object- Returns:
- a string describing
this
-
contains
public boolean contains(Marker marker)
Returnstrueif the specified marker is in this chromosome interval and returnsfalseotherwise.- Parameters:
marker- a marker- Returns:
trueif the specified marker is in this chromosome interval- Throws:
java.lang.NullPointerException- ifmarker == null
-
overlap
public static boolean overlap(ChromInterval a, ChromInterval b)
Returnstrueif the specified chromosome intervals have non-empty intersection and returnsfalseotherwise.- Parameters:
a- a chromosome interval.b- a chromosome interval.- Returns:
trueif the specified chromosome intervals have non-empty intersection and returnsfalseotherwise.
-
merge
public static ChromInterval merge(ChromInterval a, ChromInterval b)
Returns the union of the specified overlapping chromosome intervals.- Parameters:
a- a chromosome interval.b- a chromosome interval.- Returns:
- the union of the specified overlapping chromosome intervals.
- Throws:
java.lang.IllegalArgumentException- ifChromInterval.overlap(a, b)==false.
-
-