Package beagleutil
Class ChromInterval
java.lang.Object
beagleutil.ChromInterval
- All Implemented Interfaces:
IntInterval
,Comparable<ChromInterval>
Class ChromInterval
represents a chromosome interval whose
end points are genome coordinates.
ChromInterval
are immutable.-
Constructor Summary
ConstructorsConstructorDescriptionChromInterval
(String chrom, int start, int end) Constructs a newChromInterval
instance.ChromInterval
(Marker start, Marker end) Constructs a newChromInterval
instance. -
Method Summary
Modifier and TypeMethodDescriptionchrom()
Returns the chromosome identifier.int
Returns the chromosome index.int
Compares thisChromInteval
with the specifiedChromInterval
instance for order, and returns -1, 0, or 1 depending on whetherthis
is less than, equal or greater than the specified instance.boolean
Returnstrue
if the specified marker is in this chromosome interval and returnsfalse
otherwise.boolean
Returnstrue
if the specified object is aChromInterval
instance representing the same interval of genome coordinates asthis
, and returnsfalse
otherwise.int
hashCode()
Returns a hash code value for the object.int
inclEnd()
Returns the last genome coordinate in this chromosome interval.static ChromInterval
merge
(ChromInterval a, ChromInterval b) Returns the union of the specified overlapping chromosome intervals.static boolean
Returnstrue
if the specified chromosome intervals have non-empty intersection and returnsfalse
otherwise.static ChromInterval
Returns aChromInterval
instance corresponding to the specified string, or returnsnull
if the specified string does not represent a valid chromosome interval or if the specified string isnull
.int
start()
Returns the first genome coordinate in this chromosome interval.toString()
Returns a string describingthis
.
-
Constructor Details
-
ChromInterval
Constructs a newChromInterval
instance.- Parameters:
start
- the first marker in the interval.end
- the last marker in the interval.- Throws:
IllegalArgumentException
- ifstart.chromIndex()!=end.chromIndex() || start.pos()<0 || start.pos()>end.pos()
.NullPointerException
- ifstart==null || end==null
.
-
ChromInterval
Constructs a newChromInterval
instance.- Parameters:
chrom
- the chromosome,start
- the first genome coordinate in the interval.end
- the last genome coordinate in the interval.- Throws:
IllegalArgumentException
- ifstart>end || chrom.isEmpty()
NullPointerException
- ifchrom==null
-
-
Method Details
-
parse
Returns a
The string representation of the chromosome interval must have one of the following forms:ChromInterval
instance corresponding to the specified string, or returnsnull
if 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 returnedChromInterval
instance returnsInteger.MIN_VALUE
. If no end position is specified, theend()
method of the returnedChromInterval
instance returnsInteger.MAX_VALUE
.- Parameters:
str
- a chromosome interval.- Returns:
- a
ChromInterval
instance corresponding to the specified string, or returnsnull
if 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
Returns the chromosome identifier.- Returns:
- the chromosome identifier.
-
start
public int start()Returns the first genome coordinate in this chromosome interval.- Specified by:
start
in 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:
inclEnd
in interfaceIntInterval
- Returns:
- the last genome coordinate in this chromosome interval.
-
compareTo
Compares this
ChromInteval
with the specifiedChromInterval
instance for order, and returns -1, 0, or 1 depending on whetherthis
is less than, equal or greater than the specified instance.ChromInterval
objects are ordered first bythis.chromIndex()
, then bythis.start()
, and finally bythis.end()
. All fields are ordered in ascending order.- Specified by:
compareTo
in interfaceComparable<ChromInterval>
- Parameters:
o
- theChromInterval
to be compared withthis
.- Returns:
- -1, 0, or 1 depending on whether
this
is 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();
-
equals
Returnstrue
if the specified object is aChromInterval
instance representing the same interval of genome coordinates asthis
, and returnsfalse
otherwise. -
toString
Returns a string describingthis
. This format of the returned string is unspecified and subject to change. -
contains
Returnstrue
if the specified marker is in this chromosome interval and returnsfalse
otherwise.- Parameters:
marker
- a marker- Returns:
true
if the specified marker is in this chromosome interval- Throws:
NullPointerException
- ifmarker == null
-
overlap
Returnstrue
if the specified chromosome intervals have non-empty intersection and returnsfalse
otherwise.- Parameters:
a
- a chromosome interval.b
- a chromosome interval.- Returns:
true
if the specified chromosome intervals have non-empty intersection and returnsfalse
otherwise.
-
merge
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:
IllegalArgumentException
- ifChromInterval.overlap(a, b)==false
.
-