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::DBSQL::OntologyTermAdaptor

SYNOPSIS

my $goa =
  $registry->get_adaptor( 'Multi', 'Ontology', 'OntologyTerm' );

my $term = $goa->fetch_by_accession('GO:0010885');

my @children    = @{ $goa->fetch_all_by_parent_term($term) };
my @descendants = @{ $goa->fetch_all_by_ancestor_term($term) };

my @parents   = @{ $goa->fetch_all_by_child_term($term) };
my @ancestors = @{ $goa->fetch_all_by_descendant_term($term) };

my %ancestor_chart = %{ $goa->_fetch_ancestor_chart($term) };

DESCRIPTION

An abstract adaptor class for fetching ontology terms, creates Bio::EnsEMBL::OntologyTerm objects.

METHODS

fetch_all_by_name

Arg [1]       : String, name of term, or SQL pattern
Arg [2]       : (optional) String, name of ontology
Arg [3]       : (optional) Boolean, search through obsolete terms as well

Description   : Fetches ontology term(s) given a name, a synonym, or a
                SQL pattern like "%splice_site%"

Example       :

  my ($term) =
    @{ $ot_adaptor->fetch_by_name( 'DNA_binding_site', 'SO' ) };

  # Will find terms in both SO and GO:
  my @terms = @{ $ot_adaptor->fetch_by_name('%splice_site%') };

Return type   : listref of Bio::EnsEMBL::OntologyTerm

fetch_by_accession

Arg [1]       : String
Arg [2]       : (optional) Boolean, search through obsolete terms as well

Description   : Fetches an ontology term given an accession.

Example       :

  my $term = $ot_adaptor->fetch_by_accession('GO:0030326');

Return type   : Bio::EnsEMBL::OntologyTerm

fetch_by_alt_id

Arg [1]       : String

Description   : Fetches an ontology term given an alt_id.

Example       :

  my $term = $ot_adaptor->fetch_by_alt_id('GO:0019952');

Return type   : Bio::EnsEMBL::OntologyTerm

fetch_all_by_parent_term

Arg [1]       : Bio::EnsEMBL::OntologyTerm
                The term whose children terms should be fetched.

Description   : Given a parent ontology term, returns a list of
                its immediate children terms.

Example       :

  my @children =
    @{ $ot_adaptor->fetch_all_by_parent_term($term) };

Return type   : listref of Bio::EnsEMBL::OntologyTerm

fetch_all_by_ancestor_term

Arg [1]       : Bio::EnsEMBL::OntologyTerm
                The term whose descendant terms should be fetched.

Description   : Given a parent ontology term, returns a list of
                all its descendant terms, down to and including
                any leaf terms.  Relations of the type 'is_a' and
                'part_of' are followed.

Example       :

  my @descendants =
    @{ $ot_adaptor->fetch_all_by_ancestor_term($term) };

Return type   : listref of Bio::EnsEMBL::OntologyTerm

fetch_all_by_child_term

Arg [1]       : Bio::EnsEMBL::OntologyTerm
                The term whose parent terms should be fetched.

Description   : Given a child ontology term, returns a list of
                its immediate parent terms.

Example       :

  my @parents = @{ $ot_adaptor->fetch_all_by_child_term($term) };

Return type   : listref of Bio::EnsEMBL::OntologyTerm

fetch_all_by_descendant_term

Arg [1]       : Bio::EnsEMBL::OntologyTerm
                The term whose ancestor terms should be fetched.

Arg [2]       : (optional) String
                The subset within the ontolgy to which the query
                should be restricted.  The subset may be specified as
                a SQL pattern, e.g., "%goslim%" (but "goslim%" might
                not do what you expect), or as a specific subset name,
                e.g., "goslim_generic".

Arg [3]       : (optional) Boolean
                If true (non-zero), only return the closest
                term(s).  If this argument is true, and the
                previous argument is left undefined, this method
                will return the parent(s) of the given term.

Arg [4]       : (optional) Boolean
                If true we will allow the retrieval of terms whose distance
                to the current term is 0. If false then we will only return
                those which are above the current term in the ontology

Description   : Given a child ontology term, returns a list of
                all its ancestor terms, up to and including any
                root term.  Relations of the type 'is_a' and
                'part_of' are followed.  Optionally, only terms in
                a given subset of the ontology may be returned,
                and additionally one may ask to only get the
                closest term(s) to the given child term.

Example       :

  my @ancestors =
    @{ $ot_adaptor->fetch_all_by_descendant_term($term) };

Return type   : listref of Bio::EnsEMBL::OntologyTerm

_fetch_ancestor_chart

Arg [1]       : Bio::EnsEMBL::OntologyTerm
                The term whose ancestor terms should be fetched.

Description   : Given a child ontology term, returns a hash
                structure containing its ancestor terms, up to and
                including any root term.  Relations of the type
                'is_a' and 'part_of' are included.

Example       :

  my %chart = %{ $ot_adaptor->_fetch_ancestor_chart($term) };

Return type   : A reference to a hash structure like this:

  {
    'GO:XXXXXXX' => {
      'term' =>           # ref to Bio::EnsEMBL::OntologyTerm object
      'is_a'    => [...], # listref of Bio::EnsEMBL::OntologyTerm
      'part_of' => [...], # listref of Bio::EnsEMBL::OntologyTerm
    },
    'GO:YYYYYYY' => {
      # Similarly for all ancestors,
      # and including the query term itself.
    }
  }

fetch_all_alt_ids

Arg [1]       : String

Description   : Fetches all alt_ids for a given ontology term

Example       :

  my ($accessions) =
    @{ $ot_adaptor->fetch_all_alt_ids( 'GO:0000003' ) };

Return type   : listref of accessions

fetch_all_roots

Arg [1]       : (optional) String, name of ontology

Description   : Fetches all roots for all ontologies
                Optionally, can be restricted to a given ontology

Example       :

  my ($terms) =
    @{ $ot_adaptor->fetch_all_roots( 'SO' ) };

  # Will find terms in EFO, SO and GO:
  my @terms = @{ $ot_adaptor->fetch_all_roots() };

Return type   : listref of Bio::EnsEMBL::OntologyTerm