Commit d8707a99 authored by Andy Yates's avatar Andy Yates
Browse files

is_canonical() can lazy-load the value from the database when it is unset & a...

is_canonical() can lazy-load the value from the database when it is unset & a dbID and an adaptor is available.
parent 042d3fd4
......@@ -1074,6 +1074,29 @@ sub get_Interpro_by_transid {
return \@out;
}
=head2 is_Transcript_canonical()
Arg [1] : Bio::EnsEMBL::Transcript $transcript
The transcript to query with
Example : $tr_adaptor->is_Transcript_canonical($transcript);
Description : Returns a boolean if the given transcript is considered
canonical with respect to a gene
Returntype : Boolean
Exceptions : None
Caller : Bio::EnsEMBL::Transcript
Status : Beta
=cut
sub is_Transcript_canonical {
my ($self, $transcript) = @_;
return $self->dbc()->sql_helper()->execute_single_result(
-SQL => 'select count(*) from gene where canonical_transcript_id =?',
-PARAMS => [$transcript->dbID()]
);
}
=head2 remove
......
......@@ -666,12 +666,20 @@ sub display_xref {
sub is_canonical {
my ( $self, $value ) = @_;
#Shortcut call
return $self->{is_canonical} if defined $self->{is_canonical};
if ( defined($value) ) {
$self->{'is_canonical'} = ( $value != 0 );
$self->{is_canonical} = ( $value ? 1 : 0 );
}
else {
if(! defined $self->{is_canonical} && $self->dbID() && $self->adaptor()) {
$self->{is_canonical} = $self->adaptor()->is_Transcript_canonical($self);
}
}
return $self->{'is_canonical'};
return $self->{is_canonical};
}
=head2 translation
......
Markdown is supported
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