Package htsjdk.samtools.util
Class Interval
java.lang.Object
htsjdk.samtools.util.Interval
- All Implemented Interfaces:
Locatable
,Feature
,NamedFeature
,Cloneable
,Comparable<Interval>
Represents a simple interval on a sequence. Coordinates are 1-based closed ended.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an interval with the suppliedLocatable
.Constructs an interval with the supplied sequence and start and end.Constructs an interval with the supplied sequence and start, end, strand and name. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns true if this interval overlaps the other interval, otherwise false.clone()
int
Sort based on sequence.compareTo, then start pos, then end pos with null objects coming lexically laststatic long
countBases
(Collection<Interval> intervals) Counts the total number of bases a collection of intervals.boolean
Equals method that agrees withcompareTo(Interval)
.boolean
equalsWithStrandAndName
(Object other) Equals method that also checks strand and nameGets the contig name for the contig this is mapped to.int
getEnd()
int
getIntersectionLength
(Interval other) getName()
Returns the name of the interval, possibly null.Deprecated.use getContig() insteadint
getStart()
Return theStrand
this interval is on.int
hashCode()
Returns a new Interval that represents the intersection between the two intervals.boolean
intersects
(Interval other) Returns true if this interval overlaps the other interval, otherwise false.boolean
Returns true if the interval is on the negative strand, otherwise false.boolean
Returns true if the interval is on the positive strand, otherwise false.int
length()
Gets the length of this interval.pad
(int left, int right) Returns a new interval that is padded by the amount of bases specified on either side.toString()
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface htsjdk.samtools.util.Locatable
contains, contigsMatch, getLengthOnReference, overlaps, withinDistanceOf
-
Constructor Details
-
Interval
Constructs an interval with the supplied sequence and start and end. If the end position is less than the start position an exception is thrown.- Parameters:
sequence
- the name of the sequencestart
- the start position of the interval on the sequenceend
- the end position of the interval on the sequence
-
Interval
Constructs an interval with the suppliedLocatable
. -
Interval
Constructs an interval with the supplied sequence and start, end, strand and name. If the end position is less than the start position an exception is thrown.- Parameters:
sequence
- the name of the sequencestart
- the start position of the interval on the sequenceend
- the end position of the interval on the sequencenegative
- true to indicate negative strand, false otherwisename
- the name (possibly null) of the interval
-
-
Method Details
-
getSequence
Deprecated.use getContig() insteadGets the name of the sequence on which the interval resides. This is a simple alias of getContig() -
isNegativeStrand
public boolean isNegativeStrand()Returns true if the interval is on the negative strand, otherwise false. -
isPositiveStrand
public boolean isPositiveStrand()Returns true if the interval is on the positive strand, otherwise false. -
getStrand
Return theStrand
this interval is on. -
getName
Returns the name of the interval, possibly null.- Specified by:
getName
in interfaceNamedFeature
-
intersects
Returns true if this interval overlaps the other interval, otherwise false. -
getIntersectionLength
-
intersect
Returns a new Interval that represents the intersection between the two intervals. -
abuts
Returns true if this interval overlaps the other interval, otherwise false. -
length
public int length()Gets the length of this interval. -
pad
Returns a new interval that is padded by the amount of bases specified on either side. -
countBases
Counts the total number of bases a collection of intervals. -
compareTo
Sort based on sequence.compareTo, then start pos, then end pos with null objects coming lexically last- Specified by:
compareTo
in interfaceComparable<Interval>
-
equals
Equals method that agrees withcompareTo(Interval)
. -
equalsWithStrandAndName
Equals method that also checks strand and name -
hashCode
public int hashCode() -
toString
-
clone
-
getContig
Description copied from interface:Locatable
Gets the contig name for the contig this is mapped to. May return null if there is no unique mapping. -
getStart
public int getStart() -
getEnd
public int getEnd()
-