Skip to content
Snippets Groups Projects
Commit 08c23bda authored by Glenn Proctor's avatar Glenn Proctor
Browse files

Modifed get_all_DBLinks to sort xrefs by priority (desc), external db name...

Modifed get_all_DBLinks to sort xrefs by priority (desc), external db name (asc), display_id (asc) before returning them.
parent 086aff75
No related branches found
No related tags found
No related merge requests found
......@@ -154,7 +154,8 @@ sub new {
If you only want to retrieve the DBEntries associated with the
transcript then you should use the get_all_DBEntries call
instead.
Returntype : list reference to Bio::EnsEMBL::DBEntry objects
Returntype : list reference to Bio::EnsEMBL::DBEntry objects, sorted by
priority (desc), external db name (asc), display_id (asc)
Exceptions : none
Caller : general
......@@ -170,6 +171,8 @@ sub get_all_DBLinks {
my $transl = $self->translation();
push @links, @{$transl->get_all_DBEntries} if($transl);
@links = sort {_compare_xrefs()} @links;
return \@links;
}
......@@ -1973,6 +1976,40 @@ sub fetch_all_regulatory_features {
}
=head2 _compare_xrefs
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()) {
return $b->priority() <=> $a->priority();
} 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
return $a->display_id() cmp $b->display_id();
}
}
}
###########################
# DEPRECATED METHODS FOLLOW
###########################
......
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