ensembl-hive  2.7.0
Bio::EnsEMBL::Utils::Interval Class Reference

Public Member Functions

public Bio::EnsEMBL::Utils::Interval new ()
 
public Scalar start ()
 
public Scalar end ()
 
public Any data ()
 
public Boolean spans_origin ()
 
public Boolean is_empty ()
 
public Boolean is_point ()
 
public Boolean contains ()
 
public Boolean intersects ()
 
public Boolean is_right_of ()
 
public Boolean is_left_of ()
 

Detailed Description

Synopsis

# let's get an interval spanning 9e5 bp and associated it with some data
my $i1 = Bio::EnsEMBL::Utils::Interval->new(1e5, 1e6, { 'key1' => 'value1', 'key2' => 'value2' });
# and another one which overlaps with the previous,
# but with scalar associated data
my $i2 = Bio::EnsEMBL::Utils::Interval->new(2e5, 3e5, 'a string' );
warn "Empty interval(s)\n" if $i1->is_empty or $i2->is_empty;
warn "Point interval(s)\n" if $i1->is_point or $i2->is_point;
if ($i1->intersects($i2)) {
print "I1 and I2 overlap\n";
} else {
print "I1 and I2 do not overlap\n";
}
# If an interval is defined with a start > end, then it is assumed
# to be spanning the origin on a circular chromosome
my $i3 = Bio::EnsEMBL::Utilities::Interval->new(1e5, 1e2);
warn "Interval spans the origin" if $i3->spans_origin;
etc.

Description

A class representing an interval defined on a genomic region. Instances of this
class can store arbitrarily defined data. If created with start > end, then it
is assumed that this interval is on a circular chromosome spanning the origin.

Definition at line 41 of file Interval.pm.

Member Function Documentation

◆ contains()

public Boolean Bio::EnsEMBL::Utils::Interval::contains ( )
  Arg [1]     : scalar, the point coordinate 
  Description : Determines if the current instance contains the query point
  Returntype  : boolean
  Exceptions  : none
  Caller      : general
 
Code:
click to view

◆ data()

public Any Bio::EnsEMBL::Utils::Interval::data ( )
  Arg []      : none
  Description : Returns the data associated with the region
  Returntype  : Any
  Exceptions  : none
  Caller      : general
 
Code:
click to view

◆ end()

public Scalar Bio::EnsEMBL::Utils::Interval::end ( )
  Arg []      : none
  Description : Returns the end coordinate of the region
  Returntype  : scalar
  Exceptions  : none
  Caller      : general
 
Code:
click to view

◆ intersects()

public Boolean Bio::EnsEMBL::Utils::Interval::intersects ( )
  Arg [1]     : An instance of Bio::EnsEMBL::Utils::Interval
  Description : Determines if the the instance intersects the given interval
  Returntype  : boolean
  Exceptions  : none
  Caller      : general
 
Code:
click to view

◆ is_empty()

public Boolean Bio::EnsEMBL::Utils::Interval::is_empty ( )
  Arg []      : none
  Description : Returns whether or not the interval is empty
  Returntype  : boolean
  Exceptions  : none
  Caller      : general
 
Code:
click to view

◆ is_left_of()

public Boolean Bio::EnsEMBL::Utils::Interval::is_left_of ( )
  Arg [1]     : An instance of Bio::EnsEMBL::Utils::Interval or a scalar
  Description : Checks if this current interval is entirely to the left of a point
                or Interval.
                More formally, the method will return true, if for every point x from 
                the current interval the inequality x < point holds, where point
                is either a single scalar, or point is the start of another Interval.
                If spans_origin is true for either this Interval or an Interval
                passed in, then this method returns false
  Returntype  : boolean
  Exceptions  : none
  Caller      : general
 
Code:
click to view

◆ is_point()

public Boolean Bio::EnsEMBL::Utils::Interval::is_point ( )
  Arg []      : none
  Description : Determines if the current interval is a single point
  Returntype  : boolean
  Exceptions  : none
  Caller      : general
 
Code:
click to view

◆ is_right_of()

public Boolean Bio::EnsEMBL::Utils::Interval::is_right_of ( )
  Arg [1]     : An instance of Bio::EnsEMBL::Utils::Interval or a scalar
  Description : Checks if this current interval is entirely to the right of a point
                or Interval.
                More formally, the method will return true, if for every point x from 
                the current interval the inequality x > point holds, where point
                is either a single scalar, or point is the end of another Interval.
                If spans_origin is true for either this Interval or an Interval
                passed in, then this method returns false.
  Returntype  : boolean
  Exceptions  : none
  Caller      : general
 
Code:
click to view

◆ new()

public Bio::EnsEMBL::Utils::Interval Bio::EnsEMBL::Utils::Interval::new ( )
  Arg [1]     : scalar $start
                The start coordinate of the region
  Arg [2]     : scalar $end
                The end coordinate of the region
  Arg [3]     : (optional) $data
                The data associated with the interval, can be anything
  Example     :
my $i = Bio::EnsEMBL::Utils::Interval(1e2, 2e2, { 'key' => 'value' });
my $i2 = Bio::EnsEMBL::Utilities::Interval(1e5, 1e2);
$i->spans_origin # returns 0
$i2->spans_origin # returns 1
  Description : Constructor. Creates a new instance
  Returntype  : Bio::EnsEMBL::Utils::Interval
  Exceptions  : Throws an exception if start and end are not defined.
  Caller      : general
 
Code:
click to view

◆ spans_origin()

public Boolean Bio::EnsEMBL::Utils::Interval::spans_origin ( )
  Arg []      : none
  Description : Returns whether this interval was created spanning zero
                (more particularly: if the interval was instantiated with start > end)
  Returntype  : boolean
  Exceptions  : none
  Caller      : general
 
Code:
click to view

◆ start()

public Scalar Bio::EnsEMBL::Utils::Interval::start ( )
  Arg []      : none
  Description : Returns the start coordinate of the region
  Returntype  : scalar
  Exceptions  : none
  Caller      : general
 
Code:
click to view

The documentation for this class was generated from the following file:
Bio::EnsEMBL::Utils::Interval
Definition: Interval.pm:41
Bio::EnsEMBL::Utils::Interval::is_empty
public Boolean is_empty()
Bio::EnsEMBL::Utils::Interval::data
public Any data()
Bio::EnsEMBL::Utils::Interval::intersects
public Boolean intersects()
Bio::EnsEMBL::Utils::Interval::is_left_of
public Boolean is_left_of()
Bio::EnsEMBL::Utils::Interval::end
public Scalar end()
Bio::EnsEMBL::Utils::Interval::start
public Scalar start()
Bio::EnsEMBL::Utils::Interval::new
public Bio::EnsEMBL::Utils::Interval new()
Bio::EnsEMBL::Utils::Interval::is_right_of
public Boolean is_right_of()
Bio::EnsEMBL::Utils::Interval::contains
public Boolean contains()
Bio::EnsEMBL::Utils::Interval::spans_origin
public Boolean spans_origin()
Bio::EnsEMBL::Utils::Interval::is_point
public Boolean is_point()