public final class Range extends Object implements Serializable, Comparable<Range>
from > to), to represent reverse complement sub-sequence of a nucleotide sequence.
Main contract: upper limit (with biggest value) is always exclusive, and lower is always inclusive.
| Modifier and Type | Field and Description |
|---|---|
static Comparator<Range> |
COMPARATOR_BY_FROM |
| Constructor and Description |
|---|
Range(int from,
int to) |
Range(int lower,
int upper,
boolean reversed) |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Range o) |
boolean |
contains(int position)
Returns
true if range contains provided position. |
boolean |
contains(Range other)
Returns
true if range contains other range. |
boolean |
containsBoundary(int position) |
int[] |
convertBoundariesToRelativePosition(int... absolutePositions) |
int |
convertBoundaryToAbsolutePosition(int relativePosition)
Converts relative boundary position to absolute position
|
int |
convertBoundaryToRelativePosition(int absolutePosition)
Returns relative boundary position inside this range.
|
int[] |
convertPointsToRelativePosition(int... absolutePositions) |
int |
convertPointToAbsolutePosition(int relativePosition)
Converts relative point position to absolute position
|
int |
convertPointToRelativePosition(int absolutePosition)
Returns relative point position inside this range.
|
boolean |
equals(Object o) |
Range |
expand(int offset) |
Range |
expand(int leftOffset,
int rightOffset) |
Range |
getAbsoluteRangeFor(Range relativeRange)
Reverse operation for
getRelativeRangeOf(Range). |
int |
getFrom()
Returns from value.
|
int |
getLower()
Returns lower (with least value) bound of this range.
|
Range |
getRelativeRangeOf(Range absoluteRange) |
int |
getTo()
Returns to value.
|
int |
getUpper()
Returns upper (with biggest value) bound of this range.
|
int |
hashCode() |
boolean |
hasSameDirection(Range other)
Returns true if two ranges has the same direction.
|
Range |
intersection(Range other)
Returns intersection range with
other range. |
Range |
intersectionWithTouch(Range other)
Returns intersection range with
other range. |
boolean |
intersectsWith(Range other)
Returns
true if range intersects with other range. |
boolean |
intersectsWithOrTouches(Range other)
Returns
true if range intersects with or touches other range. |
Range |
inverse()
Returns reversed range.
|
boolean |
isEmpty()
Returns true if
length() == 0. |
boolean |
isReverse()
Returns true if this range is reversed.
|
int |
length()
Returns the length of this range.
|
Range |
move(int offset)
Returns range moved using provided offset (e.g.
|
Range |
reverse()
Return reversed range.
|
int |
sig()
Return +1 if this range is normal and -1 if it is reversed
|
String |
toString() |
Range |
tryMerge(Range other)
Returns union range with
other range. |
List<Range> |
without(Range range)
Subtract provided range and return list of ranges contained in current range and not intersecting with other
range.
|
public static final Comparator<Range> COMPARATOR_BY_FROM
public Range(int lower,
int upper,
boolean reversed)
public Range(int from,
int to)
public Range expand(int offset)
public Range expand(int leftOffset, int rightOffset)
public boolean isEmpty()
length() == 0.length() == 0.public int length()
public boolean isReverse()
public int sig()
public Range reverse()
public boolean hasSameDirection(Range other)
other - other range to compare withpublic int getFrom()
public int getTo()
public int getUpper()
public int getLower()
public Range inverse()
public boolean contains(int position)
true if range contains provided position.position - positiontrue if range contains provided positionpublic boolean containsBoundary(int position)
public boolean contains(Range other)
true if range contains other range.other - other rangetrue if range contains other rangepublic boolean intersectsWith(Range other)
true if range intersects with other range.other - other rangetrue if range intersects with other rangepublic boolean intersectsWithOrTouches(Range other)
true if range intersects with or touches other range.other - other rangetrue if range intersects with or touches other rangepublic Range intersection(Range other)
other range.other - other rangeother range or null if ranges not intersectspublic Range intersectionWithTouch(Range other)
other range.other - other rangeother range or null if ranges not intersectspublic Range tryMerge(Range other)
other range.other - other rangeother range or null if ranges not intersects ot touchespublic Range move(int offset)
offset - offset, can be negativepublic int convertPointToRelativePosition(int absolutePosition)
absolutePosition - absolute point position (in the same coordinates as this range boundaries)public int convertBoundaryToRelativePosition(int absolutePosition)
absolutePosition - absolute boundary position (in the same coordinates as this range boundaries)public List<Range> without(Range range)
range - range to subtractpublic int[] convertBoundariesToRelativePosition(int... absolutePositions)
public int[] convertPointsToRelativePosition(int... absolutePositions)
public int convertPointToAbsolutePosition(int relativePosition)
relativePosition - relative point positionpublic int convertBoundaryToAbsolutePosition(int relativePosition)
relativePosition - relative boundary positionpublic Range getAbsoluteRangeFor(Range relativeRange)
getRelativeRangeOf(Range).
A.getAbsoluteRangeFor(A.getRelativeRangeOf(B)) == BrelativeRange - range defined relative to this rangepublic int compareTo(Range o)
compareTo in interface Comparable<Range>Copyright © 2018. All rights reserved.