The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

LICENSE

Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute Copyright [2016-2024] EMBL-European Bioinformatics Institute

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

CONTACT

  Please email comments or questions to the public Ensembl
  developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.

  Questions may also be sent to the Ensembl help desk at
  <http://www.ensembl.org/Help/Contact>.

NAME

Bio::EnsEMBL::Utils::Tree::Interval::Immutable

SYNOPSIS

  # define a set of intervals to be added to the tree
  my $intervals = [ Bio::EnsEMBL::Utils::Interval->new(121626874, 122092717),
                    Bio::EnsEMBL::Utils::Interval->new(121637917, 121658918),
                    Bio::EnsEMBL::Utils::Interval->new(122096077, 124088369) ];

  # initialise the tree with the above intervals
  my $tree = Bio::EnsEMBL::Utils::Tree::Interval::Immutable->new($intervals);

  # point query
  my $results = $tree->query(121779004);
  if (scalar @$results) {
    print "Intervals contain 121779004\n";
  }

  # same query, but use interval query
  my $results = $tree->query(121779004, 121779004);
  if (scalar @$results) {
    print "Found containing interval: [", $result->[0]->start, ', ', $result->[0]->end, "\n";
  }

DESCRIPTION

An implementation of an immutable interval tree. Immutable means the tree is initialised with a fixed set of intervals at creation time. Intervals cannot be added to or removed from the tree during its life cycle.

Implementation heavily inspired by https://github.com/tylerkahn/intervaltree-python

This implementation does not support Intervals having a start > end - i.e. intervals spanning the origin of a circular chromosome.

METHODS

new

  Arg [1]     : Arrayref of Bio::EnsEMBL::Utils::Interval instances
  Example     : my $tree = Bio::EnsEMBL::Utils::Tree::Immutable([ $i1, $i2, $i3 ]);
  Description : Constructor. Creates a new immutable tree instance
  Returntype  : Bio::EnsEMBL::Utils::Tree::Interval::Immutable
  Exceptions  : none
  Caller      : general

root

  Arg []      : none
  Example     : my $root = $tree->root();
  Description : Return the tree top node
  Returntype  : Bio::EnsEMBL::Utils::Tree::Interval::Immutable::Node
  Exceptions  : none
  Caller      : general

query

  Arg [1]     : scalar, $start
                Where the query interval begins
  Arg [2]     : (optional) scalar, $end
                Where the query interval ends
  Example     : my $results = $tree->query(121626874, 122092717);
  Description : Query the tree if its intervals overlap the interval whose start
                and end points are specified by the argument list.
                If end is not specified, it is assumed to be the same as start
                so effectively making a point query.
  Returntype  : An arrayref of Bio::EnsEMBL::Utils::Interval instances
  Exceptions  : none
  Caller      : general