Skip to content
Snippets Groups Projects
Commit 2f75e83f authored by Alistair Rust's avatar Alistair Rust
Browse files

Refactored versions of external name and external db which now uses the

relevant_xref_id columns.
parent 8c54544e
No related branches found
No related tags found
No related merge requests found
...@@ -901,6 +901,85 @@ sub deleteObj { ...@@ -901,6 +901,85 @@ sub deleteObj {
#flush the cache #flush the cache
%{$self->{'_slice_gene_cache'}} = (); %{$self->{'_slice_gene_cache'}} = ();
} }
=head2 get_external_name
Arg [1] : int $dbID
the database identifier of the gene whose external name is
sought
Example : $external_name = $gene_adaptor->get_external_name(42);
Description: Retrieves the external name for a gene. This is implemented
by joining across the xref and gene tables, using the
relevant_xref_id column.
Returntype : string
Exceptions : thrown if $dbId arg is not defined
Caller : general
=cut
sub get_external_name {
my ($self, $dbID) = @_;
if( !defined $dbID ) {
$self->throw("Must call with a dbID");
}
my $sth = $self->prepare("SELECT x.display_label
FROM gene g,
xref x
WHERE g.gene_id = ?
AND g.relevant_xref_id = x.xref_id
");
$sth->execute($dbID);
my ($xref) = $sth->fetchrow_array();
if( !defined $xref ) {
return undef;
}
return $xref;
}
=head2 get_external_dbname
Arg [1] : int $dbID
the database identifier of the gene for which the name of
external db from which its external name is derived.
Example : $external_dbname = $gene_adaptor->get_external_dbname(42);
Description: Retrieves the external db name for a gene from which its external
name is derived.. This is implemented by joining across the xref,
gene and external_db tables, using the relevant_xref_id column.
Returntype : string
Exceptions : thrown if $dbId arg is not defined
Caller : general
=cut
sub get_external_dbname {
my ($self, $dbID) = @_;
if( !defined $dbID ) {
$self->throw("Must call with a dbID");
}
my $sth = $self->prepare("SELECT e.db_name
FROM gene g,
xref x,
external_db e
WHERE g.gene_id = ?
AND g.relevant_xref_id = x.xref_id
AND x.external_db_id = e.external_db_id
");
$sth->execute($dbID);
my ($db_name) = $sth->fetchrow_array();
if( !defined $db_name ) {
return undef;
}
return $db_name;
}
......
...@@ -380,11 +380,7 @@ sub dbID { ...@@ -380,11 +380,7 @@ sub dbID {
Arg [1] : string $external_name Arg [1] : string $external_name
Example : none Example : none
Description: get/set for attribute external_name. It initially calculates Description: get/set for attribute external_name.
the longest transcript for the gene in question and then
delegates the call to the external_name method on Transcript.
Species dependant searching is handled by this method on
Transcript.
Returntype : string Returntype : string
Exceptions : none Exceptions : none
Caller : general Caller : general
...@@ -392,6 +388,18 @@ sub dbID { ...@@ -392,6 +388,18 @@ sub dbID {
=cut =cut
sub external_name { sub external_name {
my ($self, $ext_name) = @_;
if(defined $ext_name) {
$self->{'_ext_name'} = $ext_name;
}
if( exists $self->{'_ext_name'} ) {
return $self->{'_ext_name'};
}
$self->{'_ext_name'} = $self->adaptor->get_external_name($self->dbID);
return $self->{'_ext_name'};
} }
...@@ -401,11 +409,7 @@ sub external_name { ...@@ -401,11 +409,7 @@ sub external_name {
Arg [1] : string $external_db Arg [1] : string $external_db
Example : none Example : none
Description: get/set for attribute external_db. The db is the one that Description: get/set for attribute external_db. The db is the one that
belongs to the external_name. It initially calculates belongs to the external_name.
the longest transcript for the gene in question and then
delegates the call to the external_db method on Transcript.
Species dependant searching is handled by this method on
Transcript.
Returntype : string Returntype : string
Exceptions : none Exceptions : none
Caller : general Caller : general
...@@ -413,7 +417,18 @@ sub external_name { ...@@ -413,7 +417,18 @@ sub external_name {
=cut =cut
sub external_db { sub external_db {
my ($self, $arg ) = @_; my ($self, $ext_dbname) = @_;
if(defined $ext_dbname) {
$self->{'_ext_dbname'} = $ext_dbname;
}
if( exists $self->{'_ext_dbname'} ) {
return $self->{'_ext_dbname'};
}
$self->{'_ext_dbname'} = $self->adaptor->get_external_dbname($self->dbID);
return $self->{'_ext_dbname'};
} }
......
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