Bio-EnsEMBL
view release on metacpan or search on metacpan
lib/Bio/EnsEMBL/RNAProduct.pm view on Meta::CPAN
=head2 start_Exon
Arg [1] : (optional) Bio::EnsEMBL::Exon || undef - start exon to assign
Example : $rnaproduct->start_Exon($exon1);
Description: Getter/setter for the value of start_Exon, which denotes the
exon at which RNAProduct starts.
Returntype : Bio::EnsEMBL::Exon
Exceptions : thrown on wrong argument type
Caller : general
Status : Stable
=cut
sub start_Exon {
my ($self, $exon) = @_;
if (defined($exon)) {
# Normal setter
assert_ref($exon, 'Bio::EnsEMBL::Exon');
$self->{'start_exon'} = $exon;
}
elsif (@_ > 1) {
# User has explicitly passed undef. Break connection to exon.
delete( $self->{'start_exon'} );
}
return $self->{'start_exon'};
}
=head2 summary_as_hash
Example : $rnaproduct_summary = $rnaproduct->summary_as_hash();
Description : Retrieves a textual summary of this RNAProduct.
Not inherited from Feature.
Returns : hashref of arrays of descriptive strings
Status : Intended for internal use
=cut
sub summary_as_hash {
my $self = shift;
my %summary;
my $id = $self->display_id;
if ($self->version) {
$id .= "." . $self->version;
}
$summary{'id'} = $id;
$summary{'rnaproduct_id'} = $id;
$summary{'genomic_start'} = $self->genomic_start;
$summary{'genomic_end'} = $self->genomic_end;
$summary{'length'} = $self->length;
my $transcript = $self->transcript;
$summary{'Parent'} = $transcript->display_id;
return \%summary;
}
=head2 synchronise_attributes
Example : $rnaproduct->synchronise_attributes();
Description : Some RNAProduct attributes, e.g. stem-loop arm in case
of MicroRNA, use a local cache of their value for
convenience. Unless the corresponding setters update both
the cache value and the attribute (which would defeat
the convenience thing), we have to make sure the former
get propagated to the latter before storing the object
in the database:
- if no corresponding attribute exists, create one;
- if there is one, update its value.
Class-specific maps of attributes to synchronise are
provided by
RNAProductTypeMapper::class_attribute_cache_map() .
Returntype : none
Exceptions : throws if the object contains multiple attributes with the
given code and the choice which one to update is
ambiguous.
Caller : RNAProductAdaptor
Status : At Risk (In Development)
=cut
sub synchronise_attributes {
my ($self) = @_;
my $attribute_cache_map = Bio::EnsEMBL::Utils::RNAProductTypeMapper::mapper()
->class_attribute_cache_map(ref($self));
while (my ($cache_key, $attr_code) = each %{$attribute_cache_map}) {
my $existing_attributes = $self->get_all_Attributes($attr_code);
my $n_existing_attrs = scalar @{$existing_attributes};
if ($n_existing_attrs > 0) {
# At the moment we do not support multiple occurrences of target
# attributes at all
if ($n_existing_attrs > 1) {
throw("Object has multiple '$attr_code' attributes and we do not know"
. " which one to update");
}
else {
$existing_attributes->[0]->value($self->{$cache_key});
}
}
else {
# No corresponding attribute exists, most likely because we are
# dealing with a newly created object which has never been pushed
# to the database.
$self->add_Attributes(Bio::EnsEMBL::Attribute->new(
-CODE => $attr_code,
-VALUE => $self->{$cache_key},
));
}
}
return;
}
=head2 transcript
Arg [1] : Transcript object (optional)
Description : Sets or retrieves the transcript object associated
with this RNAProduct object.
Exceptions : Throws if there is no adaptor or no dbID defined for
the RNAProduct object.
Returntype : Bio::EnsEMBL::Transcript
=cut
sub transcript {
my ($self, $transcript) = @_;
if (defined($transcript)) {
# Normal setter
assert_ref($transcript, 'Bio::EnsEMBL::Transcript');
$self->{'transcript'} = $transcript;
weaken($self->{'transcript'}); # Avoid circular references.
} elsif (@_ > 1) {
# User has explicitly passed undef. Break connection to transcript.
delete( $self->{'transcript'} );
( run in 1.602 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )