Skip to content
Snippets Groups Projects
Commit f307b41e authored by Andreas Kusalananda Kähäri's avatar Andreas Kusalananda Kähäri
Browse files

Update get_all_DBEntries() and get_all_DBLinks().

Add the following proxy methods:

* get_all_object_xrefs()    alias for get_all_DBEntries()
* get_all_xrefs()           alias for get_all_DBLinks()

These have no documentation as of yet.
parent c44c70b2
No related branches found
No related tags found
No related merge requests found
......@@ -635,17 +635,23 @@ sub add_DBEntry {
=head2 get_all_DBEntries
Arg [1] : (optional) string external database name
Arg [2] : (optional) string external_db type
Example : @dbentries = @{ $gene->get_all_DBEntries };
Description: Retrieves DBEntries (xrefs) for this gene. This does _not_
include DBEntries that are associated with the transcripts and
corresponding translations of this gene (see get_all_DBLinks).
This method will attempt to lazy-load DBEntries from a
database if an adaptor is available and no DBEntries are present
on the gene (i.e. they have not already been added or loaded).
Returntype : Listref of Bio::EnsEMBL::DBEntry objects
Arg [1] : (optional) String, external database name
Arg [2] : (optional) String, external_db type
Example : @dbentries = @{ $gene->get_all_DBEntries() };
Description: Retrieves DBEntries (xrefs) for this gene. This does
*not* include DBEntries that are associated with the
transcripts and corresponding translations of this
gene (see get_all_DBLinks()).
This method will attempt to lazy-load DBEntries
from a database if an adaptor is available and no
DBEntries are present on the gene (i.e. they have not
already been added or loaded).
Return type: Listref of Bio::EnsEMBL::DBEntry objects
Exceptions : none
Caller : get_all_DBLinks, GeneAdaptor::store
Status : Stable
......@@ -655,7 +661,7 @@ sub add_DBEntry {
sub get_all_DBEntries {
my ( $self, $db_name_exp, $ex_db_type ) = @_;
my $cache_name = "dbentries";
my $cache_name = 'dbentries';
if ( defined($db_name_exp) ) {
$cache_name .= $db_name_exp;
......@@ -669,8 +675,8 @@ sub get_all_DBEntries {
if ( !defined( $self->{$cache_name} ) && defined( $self->adaptor() ) )
{
$self->{$cache_name} =
$self->adaptor->db->get_DBEntryAdaptor->fetch_all_by_Gene( $self,
$db_name_exp, $ex_db_type );
$self->adaptor()->db()->get_DBEntryAdaptor()
->fetch_all_by_Gene( $self, $db_name_exp, $ex_db_type );
}
$self->{$cache_name} ||= [];
......@@ -678,26 +684,37 @@ sub get_all_DBEntries {
return $self->{$cache_name};
} ## end sub get_all_DBEntries
sub get_all_object_xrefs {
my $self = shift;
return $self->get_all_DBEntries(@_);
}
=head2 get_all_DBLinks
Example : @dblinks = @{ $gene->get_all_DBLinks };
: @dblinks = @{ $gene->get_all_DBLinks("Uniprot%") };
Arg [1] : <optional> database name. SQL wildcard characters (_ and %) can be used to
Arg [1] : String database name (optional)
SQL wildcard characters (_ and %) can be used to
specify patterns.
Description: Retrieves _all_ related DBEntries for this gene. This includes
all DBEntries that are associated with the transcripts and
corresponding translations of this gene.
If you only want to retrieve the DBEntries associated with the
gene (and not the transcript and translations) then you should
use the get_all_DBEntries call instead.
Note: Each entry may be listed more than once. No uniqueness checks are done.
Also if you put in an incorrect external database name no checks are done
to see if this exists, you will just get an empty list.
Returntype : Listref of Bio::EnsEMBL::DBEntry objects
Example : @dblinks = @{ $gene->get_all_DBLinks() };
@dblinks = @{ $gene->get_all_DBLinks('Uniprot%') };
Description: Retrieves *all* related DBEntries for this gene. This
includes all DBEntries that are associated with the
transcripts and corresponding translations of this
gene.
If you only want to retrieve the DBEntries
associated with the gene (and not the transcript
and translations) then you should use the
get_all_DBEntries() call instead.
Note: Each entry may be listed more than once. No
uniqueness checks are done. Also if you put in an
incorrect external database name no checks are done
to see if this exists, you will just get an empty
list.
Return type: Listref of Bio::EnsEMBL::DBEntry objects
Exceptions : none
Caller : general
Status : Stable
......@@ -705,23 +722,25 @@ sub get_all_DBEntries {
=cut
sub get_all_DBLinks {
my $self = shift;
my $db_name_exp = shift;
my $ex_db_type = shift;
my @links = @{$self->get_all_DBEntries($db_name_exp, $ex_db_type)};
my ( $self, $db_name_exp, $ex_db_type ) = @_;
# add all of the transcript and translation xrefs to the return list
foreach my $transc (@{$self->get_all_Transcripts}) {
push @links, @{$transc->get_all_DBEntries($db_name_exp, $ex_db_type)};
my @links =
@{ $self->get_all_DBEntries( $db_name_exp, $ex_db_type ) };
my $transl = $transc->translation();
push @links, @{$transl->get_all_DBEntries($db_name_exp, $ex_db_type)} if($transl);
}
# Add all of the transcript and translation xrefs to the return list.
foreach my $transcript ( @{ $self->get_all_Transcripts() } ) {
push( @links,
@{$transcript->get_all_DBLinks( $db_name_exp, $ex_db_type ) }
);
}
return \@links;
return \@links;
}
sub get_all_xrefs {
my $self = shift;
return $self->get_all_DBLinks(@_);
}
=head2 get_all_Exons
......
......@@ -181,18 +181,28 @@ sub new {
=head2 get_all_DBLinks
Arg [1] : (optional) String, external database name
Arg [2] : (optional) String, external database type
Arg [1] : String database name (optional)
SQL wildcard characters (_ and %) can be used to
specify patterns.
Example : my @dblinks = @{ $transcript->get_all_DBLinks() };
Description: Retrieves _all_ related DBEntries for this transcript.
This includes all DBEntries that are associated with the
corresponding translation.
If you only want to retrieve the DBEntries associated with the
transcript then you should use the get_all_DBEntries call
instead.
Returntype : Listref of Bio::EnsEMBL::DBEntry objects, sorted by
priority (desc), external db name (asc), display_id (asc)
my @dblinks = @{ $transcript->get_all_DBLinks('Uniprot%') };
Description: Retrieves *all* related DBEntries for this
transcript. This includes all DBEntries that are
associated with the corresponding translation.
If you only want to retrieve the DBEntries associated
with the transcript (and not the translation) then
you should use the get_all_DBEntries() call instead.
Note: Each entry may be listed more than once. No
uniqueness checks are done. Also if you put in an
incorrect external database name no checks are done
to see if this exists, you will just get an empty
list.
Return type: Listref of Bio::EnsEMBL::DBEntry objects
Exceptions : none
Caller : general
Status : Stable
......@@ -200,17 +210,16 @@ sub new {
=cut
sub get_all_DBLinks {
my ( $self, $ex_db_exp, $ex_db_type ) = @_;
my @links;
my ( $self, $db_name_exp, $ex_db_type ) = @_;
push( @links,
@{ $self->get_all_DBEntries( $ex_db_exp, $ex_db_type ) } );
my @links =
@{ $self->get_all_DBEntries( $db_name_exp, $ex_db_type ) };
# Add all of the transcript and translation xrefs to the return list.
my $translation = $self->translation();
if ( defined($translation) ) {
push( @links,
@{$translation->get_all_DBEntries( $ex_db_exp, $ex_db_type ) }
@{$translation->get_all_DBEntries( $db_name_exp, $ex_db_type ) }
);
}
......@@ -219,20 +228,28 @@ sub get_all_DBLinks {
return \@links;
}
sub get_all_xrefs {
my $self = shift;
return $self->get_all_DBLinks(@_);
}
=head2 get_all_DBEntries
Arg [1] : (optional) String, external database name
Arg [2] : (optional) String, external database type
Example : my @dbentries = @{ $gene->get_all_DBEntries() };
Description: Retrieves DBEntries (xrefs) for this transcript.
This does _not_ include the corresponding translations
DBEntries (see get_all_DBLinks).
This method will attempt to lazy-load DBEntries from a
database if an adaptor is available and no DBEntries are present
on the transcript (i.e. they have not already been added or
loaded).
Description: Retrieves DBEntries (xrefs) for this transcript.
This does *not* include the corresponding
translations DBEntries (see get_all_DBLinks()).
This method will attempt to lazy-load DBEntries
from a database if an adaptor is available and no
DBEntries are present on the transcript (i.e. they
have not already been added or loaded).
Returntype : Listref of Bio::EnsEMBL::DBEntry objects
Exceptions : none
Caller : get_all_DBLinks, TranscriptAdaptor::store
......@@ -243,27 +260,33 @@ sub get_all_DBLinks {
sub get_all_DBEntries {
my ( $self, $ex_db_exp, $ex_db_type ) = @_;
my $cache_name = "dbentries";
my $cache_name = 'dbentries';
if ( defined($ex_db_exp) ) {
$cache_name .= $ex_db_exp;
}
if ( defined($ex_db_type) ) {
$cache_name .= $ex_db_type;
}
# if not cached, retrieve all of the xrefs for this gene
if ( !defined $self->{$cache_name} && $self->adaptor() ) {
# if not cached, retrieve all of the xrefs for this transcript
if ( !defined( $self->{$cache_name} ) && defined( $self->adaptor() ) )
{
$self->{$cache_name} =
$self->adaptor->db->get_DBEntryAdaptor->fetch_all_by_Transcript(
$self, $ex_db_exp, $ex_db_type );
$self->adaptor()->db()->get_DBEntryAdaptor()
->fetch_all_by_Transcript( $self, $ex_db_exp, $ex_db_type );
}
$self->{$cache_name} ||= [];
return $self->{$cache_name};
}
} ## end sub get_all_DBEntries
sub get_all_object_xrefs {
my $self = shift;
return $self->get_all_DBEntries(@_);
}
=head2 add_DBEntry
......@@ -2448,19 +2471,21 @@ sub get_all_DAS_Features {
=head2 _compare_xrefs
Description: compare xrefs based on priority (descending), then name (ascending),
then display_label (ascending)
Description: compare xrefs based on priority (descending), then
name (ascending), then display_label (ascending)
=cut
sub _compare_xrefs {
# compare on priority first (descending)
if ($a->priority() != $b->priority()) {
if ( $a->priority() != $b->priority() ) {
return $b->priority() <=> $a->priority();
} else { # equal priorities, compare on external_db name
if ($a->dbname() ne $b->dbname()) {
} else {
# equal priorities, compare on external_db name
if ( $a->dbname() ne $b->dbname() ) {
return $a->dbname() cmp $b->dbname();
} else { # equal priorities and names, compare on display_label
} else {
# equal priorities and names, compare on display_label
return $a->display_id() cmp $b->display_id();
}
}
......
......@@ -556,50 +556,56 @@ sub transform {
=head2 get_all_DBEntries
Arg [1] : (optional) $ex_db_exp - external db name
Example : @dbentries = @{$translation->get_all_DBEntries()};
Description: Retrieves DBEntries (xrefs) for this translation.
This method will attempt to lazy-load DBEntries from a
database if an adaptor is available and no DBEntries are present
on the translation (i.e. they have not already been added or
loaded).
Returntype : list reference to Bio::EnsEMBL::DBEntry objects
Arg [1] : (optional) String, external database name
Arg [2] : (optional) String, external_db type
Example : @dbentries = @{ $translation->get_all_DBEntries() };
Description: Retrieves DBEntries (xrefs) for this translation.
This method will attempt to lazy-load DBEntries
from a database if an adaptor is available and no
DBEntries are present on the translation (i.e. they
have not already been added or loaded).
Returntype : Listref to Bio::EnsEMBL::DBEntry objects
Exceptions : none
Caller : get_all_DBLinks, TranslationAdaptor::store
Caller : TranslationAdaptor::store
Status : Stable
=cut
sub get_all_DBEntries {
my $self = shift;
my $ex_db_exp = shift;
my $ex_db_type = shift;
my ( $self, $ex_db_exp, $ex_db_type ) = @_;
my $cache_name = "dbentries";
my $cache_name = 'dbentries';
if(defined($ex_db_exp)){
if ( defined($ex_db_exp) ) {
$cache_name .= $ex_db_exp;
}
if(defined($ex_db_type)){
if ( defined($ex_db_type) ) {
$cache_name .= $ex_db_type;
}
# if not cached, retrieve all of the xrefs for this gene
if(!defined $self->{$cache_name}) {
my $adaptor = $self->adaptor();
my $dbID = $self->dbID();
return [] if(!$adaptor || !$dbID);
# if not cached, retrieve all of the xrefs for this translation
if ( !defined( $self->{$cache_name} ) && defined( $self->adaptor() ) )
{
$self->{$cache_name} =
$self->adaptor->db->get_DBEntryAdaptor->fetch_all_by_Translation($self, $ex_db_exp, $ex_db_type);
$self->adaptor()->db()->get_DBEntryAdaptor()
->fetch_all_by_Translation( $self, $ex_db_exp, $ex_db_type );
}
$self->{$cache_name} ||= [];
return $self->{$cache_name};
}
} ## end sub get_all_DBEntries
sub get_all_object_xrefs {
my $self = shift;
return $self->get_all_DBEntries(@_);
}
=head2 add_DBEntry
......@@ -631,11 +637,18 @@ sub add_DBEntry {
=head2 get_all_DBLinks
Arg [1] : see get_all_DBEntries
Example : see get_all_DBEntries
Description: This is here for consistancy with the Transcript and Gene
classes. It is a synonym for the get_all_DBEntries method.
Returntype : see get_all_DBEntries
Arg [1] : String database name (optional)
SQL wildcard characters (_ and %) can be used to
specify patterns.
Example : my @dblinks = @{ $translation->get_all_DBLinks() };
my @dblinks = @{ $translation->get_all_DBLinks('Uniprot%') };
Description: This is here for consistancy with the Transcript
and Gene classes. It is a synonym for the
get_all_DBEntries() method.
Return type: Listref to Bio::EnsEMBL::DBEntry objects
Exceptions : none
Caller : general
Status : Stable
......@@ -647,6 +660,10 @@ sub get_all_DBLinks {
return $self->get_all_DBEntries(@_);
}
sub get_all_xrefs {
my $self = shift;
return $self->get_all_DBLinks(@_);
}
=head2 get_all_ProteinFeatures
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment