Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ensembl
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
ensembl
Commits
e556941c
Commit
e556941c
authored
11 years ago
by
Alessandro Vullo
Browse files
Options
Downloads
Patches
Plain Diff
Basic mapper from Ensembl feature object to sequence ontology term.
parent
7bed968e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/Bio/EnsEMBL/Utils/SequenceOntologyMapper.pm
+166
-0
166 additions, 0 deletions
modules/Bio/EnsEMBL/Utils/SequenceOntologyMapper.pm
with
166 additions
and
0 deletions
modules/Bio/EnsEMBL/Utils/SequenceOntologyMapper.pm
0 → 100644
+
166
−
0
View file @
e556941c
=pod
=head1 LICENSE
Copyright (c) 1999-2013 The European Bioinformatics Institute and
Genome Research Limited. All rights reserved.
This software is distributed under a modified Apache license.
For license details, please see
http://www.ensembl.org/info/about/code_licence.html
=head1 NAME
SequenceOntologyMapper - Translates EnsEMBL objects into Sequence Ontology terms
=head1 SYNOPSIS
use Bio::EnsEMBL::Utils::SequenceOntologyMapper
my $ontology_adaptor = $registry->get_adaptor( 'Multi', 'Ontology', 'OntologyTerm' );
my $mapper = SequenceOntologyMapper->new($ontology_adaptor);
print $mapper->translate($feature);
=head1 DESCRIPTION
BiotypeMapper provides a series of nearest matches between EnsEMBL biotypes and
the Sequence Ontology (http://www.sequenceontology.org). In addition, biotypes
are members of groupings, such as "short non-coding". This allows one to
conveniently select all the biotypes of a certain kind.
SO Mappings are imperfect due to the inexact correspondance of biotypes to
several SO terms. The a best guess has been chosen in each case.
Reverse mappings from SO to biotype are vague, due to many-to-one relationships.
In this case a list of possible terms is given.
=cut
package
Bio::EnsEMBL::Utils::
BiotypeMapper
;
use
strict
;
use
warnings
;
use
Bio::EnsEMBL::Utils::
Cache
;
use
Bio::EnsEMBL::Utils::
Exception
;
=head1 METHODS
=head2 new
Constructor
Arg [1] : OntologyTermAdaptor from the EnsEMBL registry
Returntype : Bio::EnsEMBL::SequenceOntologyMapper
Exceptions : If no ontology term adaptor is given
=cut
sub
new
{
my
$class
=
shift
;
my
$self
=
{
ontology_adaptor
=>
shift
||
throw
"
No ontology term adaptor specified
",
feat_to_acc
=>
{
'
Bio::EnsEMBL::Feature
'
=>
'
SO:0000001
',
# region
'
Bio::EnsEMBL::Gene
'
=>
'
SO:0000704
',
# gene
'
Bio::EnsEMBL::Transcript
'
=>
'
SO:0000673
',
# transcript
'
Bio::EnsEMBL::Exon
'
=>
'
SO:0000147
',
# exon
'
Bio::EnsEMBL::Slice
'
=>
'
SO:0000001
',
# region
'
Bio::EnsEMBL::SimpleFeature
'
=>
'
SO:0001411
',
# biological_region
'
Bio::EnsEMBL::MiscFeature
'
=>
'
SO:0001411
',
# biological_region
'
Bio::EnsEMBL::RepeatFeature
'
=>
'
SO:0000657
',
# repeat region
'
Bio::EnsEMBL::Variation::VariationFeature
'
=>
'
SO:0001060
',
# sequence variant
'
Bio::EnsEMBL::Variation::StructuralVariationFeature
'
=>
'
SO:0001537
',
# structural variant
'
Bio::EnsEMBL::Compara::ConstrainedElement
'
=>
'
SO:0001009
',
# DNA_constraint_sequence ????
'
Bio::EnsEMBL::Funcgen::RegulatoryFeature
'
=>
'
SO:0005836
',
# regulatory_region
}
};
$self
->
{
ontology_adaptor
}
->
isa
('
Bio::EnsEMBL::DBSQL::OntologyTermAdaptor
')
or
throw
"
Argument is not an OntologyTermAdaptor object
";
tie
my
%cache
,
'
Bio::EnsEMBL::Utils::Cache
',
100
;
$self
->
{
cache
}
=
\
%cache
;
bless
$self
,
$class
;
return
$self
;
}
=head2 translate
Arg [0] : Bio::EnsEMBL::Feature, subclass or related Storable
Description: Translates a Feature type into an SO term
Returntype : String; the SO term
Exceptions : if argument is not an instance of Bio::EnsEMBL::Feature
or if cannot translate
=cut
sub
translate
{
my
$self
=
shift
;
my
$feature
=
shift
;
my
$so_accession
;
my
$so_name
;
my
$ref
=
ref
(
$feature
);
$feature
->
isa
('
Bio::EnsEMBL::Feature
')
or
throw
"
Need an instance of Bio::EnsEMBL::Feature
";
my
$mapping
=
$self
->
{
feat_to_acc
};
if
(
exists
$mapping
->
{
$ref
})
{
$so_accession
=
$mapping
->
{
$ref
};
}
elsif
(
$feature
->
can
('
SO_term
'))
{
$so_accession
=
$feature
->
SO_term
();
}
else
{
$so_accession
=
$mapping
->
{'
Bio::EnsEMBL::Feature
'};
}
if
(
$so_accession
)
{
$so_name
=
$self
->
_fetch_SO_name_by_accession
(
$so_accession
);
}
else
{
#
# WARNING
#
# There doesn't seem to be a class_SO_term method in class
# BaseVariationFeature or its ancestors
#
$so_name
=
$feature
->
class_SO_term
()
if
$feature
->
isa
('
Bio::EnsEMBL::Variation::BaseVariationFeature
');
}
throw
sprintf
"
%s: sequence ontology mapping not found
",
$ref
unless
$so_name
;
return
$so_name
;
}
=head1 PRIVATE METHODS
=head2 _fetch_SO_name_by_accession
Arg [0] : Sequence Ontology accession
Description: Returns the name linked to the given accession. These are
internally cached for speed.
Returntype : String; the name of the given accession
Exceptions : None
=cut
sub
_fetch_SO_name_by_accession
{
my
(
$self
,
$so_accession
)
=
@_
;
my
$so_name
=
$self
->
{
cache
}
->
{
$so_accession
};
if
(
!
$so_name
)
{
my
$so_term
=
$self
->
{'
ontology_adaptor
'}
->
fetch_by_accession
(
$so_accession
);
$so_name
=
$so_term
->
name
();
$self
->
{
cache
}
->
{
$so_accession
}
=
$so_name
;
}
return
$so_name
;
}
1
;
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment