Package htsjdk.samtools.util
Class Interval
- java.lang.Object
-
- htsjdk.samtools.util.Interval
-
- All Implemented Interfaces:
Locatable,Cloneable,Comparable<Interval>
public class Interval extends Object implements Comparable<Interval>, Cloneable, Locatable
Represents a simple interval on a sequence. Coordinates are 1-based closed ended.
-
-
Constructor Summary
Constructors Constructor Description Interval(Locatable locatable)Constructs an interval with the suppliedLocatable.Interval(String sequence, int start, int end)Constructs an interval with the supplied sequence and start and end.Interval(String sequence, int start, int end, boolean negative, String name)Constructs an interval with the supplied sequence and start, end, strand and name.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanabuts(Interval other)Returns true if this interval overlaps the other interval, otherwise false.Intervalclone()intcompareTo(Interval that)Sort based on sequence.compareTo, then start pos, then end pos with null objects coming lexically laststatic longcountBases(Collection<Interval> intervals)Counts the total number of bases a collection of intervals.booleanequals(Object other)Equals method that agrees withcompareTo(Interval).StringgetContig()Gets the contig name for the contig this is mapped to.intgetEnd()intgetIntersectionLength(Interval other)StringgetName()Returns the name of the interval, possibly null.StringgetSequence()Deprecated.use getContig() insteadintgetStart()inthashCode()Intervalintersect(Interval that)Returns a new Interval that represents the intersection between the two intervals.booleanintersects(Interval other)Returns true if this interval overlaps the other interval, otherwise false.booleanisNegativeStrand()Returns true if the interval is on the negative strand, otherwise false.booleanisPositiveStrand()Returns true if the interval is on the positive strand, otherwise false.intlength()Gets the length of this interval.Intervalpad(int left, int right)Returns a new interval that is padded by the amount of bases specified on either side.StringtoString()-
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 Detail
-
Interval
public Interval(String sequence, int start, int end)
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
public Interval(String sequence, int start, int end, boolean negative, String name)
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 Detail
-
getSequence
@Deprecated public String 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.
-
getName
public String getName()
Returns the name of the interval, possibly null.
-
intersects
public boolean intersects(Interval other)
Returns true if this interval overlaps the other interval, otherwise false.
-
getIntersectionLength
public int getIntersectionLength(Interval other)
-
intersect
public Interval intersect(Interval that)
Returns a new Interval that represents the intersection between the two intervals.
-
abuts
public boolean abuts(Interval other)
Returns true if this interval overlaps the other interval, otherwise false.
-
length
public int length()
Gets the length of this interval.
-
pad
public Interval pad(int left, int right)
Returns a new interval that is padded by the amount of bases specified on either side.
-
countBases
public static long countBases(Collection<Interval> intervals)
Counts the total number of bases a collection of intervals.
-
compareTo
public int compareTo(Interval that)
Sort based on sequence.compareTo, then start pos, then end pos with null objects coming lexically last- Specified by:
compareToin interfaceComparable<Interval>
-
equals
public boolean equals(Object other)
Equals method that agrees withcompareTo(Interval).
-
getContig
public String getContig()
Description copied from interface:LocatableGets the contig name for the contig this is mapped to. May return null if there is no unique mapping.
-
getStart
public int getStart()
-
-