Package beagleutil

Class ChromInterval

java.lang.Object
beagleutil.ChromInterval
All Implemented Interfaces:
IntInterval, Comparable<ChromInterval>

public final class ChromInterval extends Object implements IntInterval, Comparable<ChromInterval>

Class ChromInterval represents a chromosome interval whose end points are genome coordinates.

Instances of class ChromInterval are immutable.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ChromInterval(String chrom, int start, int end)
    Constructs a new ChromInterval instance.
    Constructs a new ChromInterval instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the chromosome identifier.
    int
    Returns the chromosome index.
    int
    Compares this ChromInteval with the specified ChromInterval instance for order, and returns -1, 0, or 1 depending on whether this is less than, equal or greater than the specified instance.
    boolean
    contains(Marker marker)
    Returns true if the specified marker is in this chromosome interval and returns false otherwise.
    boolean
    Returns true if the specified object is a ChromInterval instance representing the same interval of genome coordinates as this, and returns false otherwise.
    int
    Returns a hash code value for the object.
    int
    Returns the last genome coordinate in this chromosome interval.
    Returns the union of the specified overlapping chromosome intervals.
    static boolean
    Returns true if the specified chromosome intervals have non-empty intersection and returns false otherwise.
    Returns a ChromInterval instance corresponding to the specified string, or returns null if the specified string does not represent a valid chromosome interval or if the specified string is null.
    int
    Returns the first genome coordinate in this chromosome interval.
    Returns a string describing this.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ChromInterval

      public ChromInterval(Marker start, Marker end)
      Constructs a new ChromInterval instance.
      Parameters:
      start - the first marker in the interval.
      end - the last marker in the interval.
      Throws:
      IllegalArgumentException - if start.chromIndex()!=end.chromIndex() || start.pos()<0 || start.pos()>end.pos().
      NullPointerException - if start==null || end==null.
    • ChromInterval

      public ChromInterval(String chrom, int start, int end)
      Constructs a new ChromInterval instance.
      Parameters:
      chrom - the chromosome,
      start - the first genome coordinate in the interval.
      end - the last genome coordinate in the interval.
      Throws:
      IllegalArgumentException - if start>end || chrom.isEmpty()
      NullPointerException - if chrom==null
  • Method Details

    • parse

      public static ChromInterval parse(String str)

      Returns a ChromInterval instance corresponding to the specified string, or returns null if the specified string does not represent a valid chromosome interval or if the specified string is null.

      The string representation of the chromosome interval must have one of the following forms:
       [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, the start() method of the returned ChromInterval instance returns Integer.MIN_VALUE. If no end position is specified, the end() method of the returned ChromInterval instance returns Integer.MAX_VALUE.
      Parameters:
      str - a chromosome interval.
      Returns:
      a ChromInterval instance corresponding to the specified string, or returns null if the specified string does not represent a valid chromosome interval or if the specified string is null.
    • chromIndex

      public int chromIndex()
      Returns the chromosome index. The chromosome index is equal to ChromIds.indexOf(this.chrom()).
      Returns:
      the chromosome index.
    • chrom

      public String 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 interface IntInterval
      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 interface IntInterval
      Returns:
      the last genome coordinate in this chromosome interval.
    • compareTo

      public int compareTo(ChromInterval o)

      Compares this ChromInteval with the specified ChromInterval instance for order, and returns -1, 0, or 1 depending on whether this is less than, equal or greater than the specified instance.

      ChromInterval objects are ordered first by this.chromIndex(), then by this.start(), and finally by this.end(). All fields are ordered in ascending order.
      Specified by:
      compareTo in interface Comparable<ChromInterval>
      Parameters:
      o - the ChromInterval to be compared with this.
      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();
       
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for the object.
    • equals

      public boolean equals(Object obj)
      Returns true if the specified object is a ChromInterval instance representing the same interval of genome coordinates as this, and returns false otherwise.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to be compared with this for equality.
      Returns:
      true if the specified object is a ChromInterval instance representing the same interval of genome coordinates as this, and returns false otherwise.
    • toString

      public String toString()
      Returns a string describing this. This format of the returned string is unspecified and subject to change.
      Overrides:
      toString in class Object
      Returns:
      a string describing this
    • contains

      public boolean contains(Marker marker)
      Returns true if the specified marker is in this chromosome interval and returns false otherwise.
      Parameters:
      marker - a marker
      Returns:
      true if the specified marker is in this chromosome interval
      Throws:
      NullPointerException - if marker == null
    • overlap

      public static boolean overlap(ChromInterval a, ChromInterval b)
      Returns true if the specified chromosome intervals have non-empty intersection and returns false otherwise.
      Parameters:
      a - a chromosome interval.
      b - a chromosome interval.
      Returns:
      true if the specified chromosome intervals have non-empty intersection and returns false otherwise.
    • merge

      public static ChromInterval merge(ChromInterval a, ChromInterval b)
      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 - if ChromInterval.overlap(a, b)==false.