org.gersteinlab.act.data
Class Interval

java.lang.Object
  extended by org.gersteinlab.act.data.Interval
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Interval>

public class Interval
extends java.lang.Object
implements java.lang.Comparable<Interval>, java.io.Serializable

        This class defines an interval of genomic locations. Positions are
        0-based, and the intervals are left-closed, right-open. In other words,
        if a sequence contains n locations, the whole interval is represented as
        [0, n).
        

See Also:
Serialized Form

Field Summary
static char ANY_STRAND
          The official symbol to indicate that the strand is not important.
protected  java.util.Map<java.lang.String,java.lang.String> attributes
          Additional attributes of the interval.
protected  double doubleValue
          The double value of the interval.
protected  long end
          The ending position of the interval, 0-based, not included.
static char MINUS_STRAND
          The official symbol for the minus strand.
static char PLUS_STRAND
          The official symbol for the plus strand.
protected  long start
          The starting position of the interval, 0-based, included.
protected  char strand
          The strand of the interval.
 
Constructor Summary
Interval()
          Create a dummy interval.
Interval(java.lang.String chrIn, long startIn, long endIn)
          Create an interval.
Interval(java.lang.String chrIn, long startIn, long endIn, char strandIn)
          Create an interval.
 
Method Summary
 int backwardCompareTo(Interval intervalIn)
          Compare this interval with an input interval based on backward ordering.
 int compareTo(Interval intervalIn)
          Compare this interval with an input interval based on natural ordering.
 boolean equals(java.lang.Object o)
          Check if this interval is semantically equivalent to an input object.
 int forwardCompareTo(Interval intervalIn)
          Compare this interval with an input interval based on forward ordering.
 java.lang.String getAttribute(java.lang.String attrName)
          Get the value of an attribute.
 java.lang.String getChr()
          Get the chromosome of the interval.
 double getDoubleValue()
          Get the double value of the interval.
 long getEnd()
          Get the ending position of the interval.
 long getLength()
          Get the length of the interval.
 long getStart()
          Get the starting position of the interval.
 long getStrand()
          Get the strand of the interval.
 int hashCode()
          Get the hash code of this interval.
 boolean intersects(Interval intervalIn)
          Check if this interval intersects with an input interval.
 void setAttribute(java.lang.String attrName, java.lang.String attrValue)
          Set the value of an attribute.
 void setChr(java.lang.String chrIn)
          Set the chromosome of the interval.
 void setDoubleValue(double doubleValueIn)
          Set the double value of the interval.
 void setEnd(long endIn)
          Set the ending position of the interval.
 void setStart(long startIn)
          Set the starting position of the interval.
 void setStrand(char strandIn)
          Set the strand of the interval.
 java.lang.String toString()
          Get a string representation of the interval.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PLUS_STRAND

public static final char PLUS_STRAND
The official symbol for the plus strand.

See Also:
Constant Field Values

MINUS_STRAND

public static final char MINUS_STRAND
The official symbol for the minus strand.

See Also:
Constant Field Values

ANY_STRAND

public static final char ANY_STRAND
The official symbol to indicate that the strand is not important.

See Also:
Constant Field Values

start

protected long start
The starting position of the interval, 0-based, included.


end

protected long end
The ending position of the interval, 0-based, not included.


strand

protected char strand
The strand of the interval.


doubleValue

protected double doubleValue
The double value of the interval.


attributes

protected java.util.Map<java.lang.String,java.lang.String> attributes
Additional attributes of the interval.

Constructor Detail

Interval

public Interval()
Create a dummy interval.


Interval

public Interval(java.lang.String chrIn,
                long startIn,
                long endIn)
Create an interval.

Parameters:
chrIn - Chromosome of the interval
startIn - The starting position of the interval, 0-based, included
endIn - The ending position of the interval, 0-based, not included

Interval

public Interval(java.lang.String chrIn,
                long startIn,
                long endIn,
                char strandIn)
Create an interval.

Parameters:
chrIn - Chromosome of the interval
startIn - The starting position of the interval, 0-based, included
endIn - The ending position of the interval, 0-based, not included
strandIn - The strand
Method Detail

getChr

public java.lang.String getChr()
Get the chromosome of the interval.

Returns:
The chromosome

getStart

public long getStart()
Get the starting position of the interval.

Returns:
The starting position of the interval, 0-based, included

getEnd

public long getEnd()
Get the ending position of the interval.

Returns:
The ending position of the interval, 0-based, not included

getStrand

public long getStrand()
Get the strand of the interval.

Returns:
The strand

getDoubleValue

public double getDoubleValue()
Get the double value of the interval.

Returns:
The value

getAttribute

public java.lang.String getAttribute(java.lang.String attrName)
Get the value of an attribute.

Parameters:
attrName - Name of the attribute
Returns:
The value, null if not available

setChr

public void setChr(java.lang.String chrIn)
Set the chromosome of the interval.

Parameters:
chrIn - The chromosome of the interval

setStart

public void setStart(long startIn)
Set the starting position of the interval.

Parameters:
startIn - The starting position of the interval, 0-based, included

setEnd

public void setEnd(long endIn)
Set the ending position of the interval.

Parameters:
endIn - The ending position of the interval, 0-based, not included

setStrand

public void setStrand(char strandIn)
Set the strand of the interval.

Parameters:
strandIn - The strand

setDoubleValue

public void setDoubleValue(double doubleValueIn)
Set the double value of the interval.

Parameters:
doubleValueIn - The value

setAttribute

public void setAttribute(java.lang.String attrName,
                         java.lang.String attrValue)
Set the value of an attribute. If there was an old value, it will be overriden.

Parameters:
attrName - Name of the attribute
attrValue - Value of the attribute

getLength

public long getLength()
Get the length of the interval.

Returns:
The length

compareTo

public int compareTo(Interval intervalIn)
Compare this interval with an input interval based on natural ordering.

Specified by:
compareTo in interface java.lang.Comparable<Interval>
Parameters:
intervalIn - The input interval
Returns:
-1 if this interval should be ordered first
1 if this interval should be ordered second
0 if the two intervals have the same order

forwardCompareTo

public int forwardCompareTo(Interval intervalIn)
Compare this interval with an input interval based on forward ordering.

Parameters:
intervalIn - The input interval
Returns:
-1 if this interval should be ordered first
1 if this interval should be ordered second
0 if the two intervals have the same order

backwardCompareTo

public int backwardCompareTo(Interval intervalIn)
Compare this interval with an input interval based on backward ordering.

Parameters:
intervalIn - The input interval
Returns:
-1 if this interval should be ordered first
1 if this interval should be ordered second
0 if the two intervals have the same order

equals

public boolean equals(java.lang.Object o)
Check if this interval is semantically equivalent to an input object.

Overrides:
equals in class java.lang.Object
Parameters:
o - The input object
Returns:
Whether the objects are semantically equivalent

hashCode

public int hashCode()
Get the hash code of this interval.

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code

intersects

public boolean intersects(Interval intervalIn)
Check if this interval intersects with an input interval.

Parameters:
intervalIn - The input interval
Returns:
Whether the intervals intersect

toString

public java.lang.String toString()
Get a string representation of the interval.

Overrides:
toString in class java.lang.Object
Returns:
The string representation