Bio-EnsEMBL
view release on metacpan or search on metacpan
lib/Bio/EnsEMBL/RNAProduct.pm view on Meta::CPAN
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=cut
=head1 CONTACT
Please email comments or questions to the public Ensembl
developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.
Questions may also be sent to the Ensembl help desk at
<http://www.ensembl.org/Help/Contact>.
=cut
=head1 NAME
Bio::EnsEMBL::RNAProduct - A class representing the mature RNA product
of a transcript
=head1 DESCRIPTION
Objects of this class represent mature RNA products of
transcripts. Examples of such products include MicroRNA (miRNA),
circular RNA (circRNA) or piwi-interacting RNA (piRNA), and they
commonly play a role in gene expression.
=head1 SYNOPSIS
my $rnaproduct = Bio::EnsEMBL::RNAProduct->new(
-SEQ_START => 36,
-SEQ_END => 58
);
# Stable-ID setter
$rnaproduct->stable_id('ENSS00090210');
# Get start and end position in the precursor transcript
my $start = $rnaproduct->start();
my $end = $rnaproduct->end();
=cut
package Bio::EnsEMBL::RNAProduct;
$Bio::EnsEMBL::RNAProduct::VERSION = '114.0.0';
use vars qw($AUTOLOAD);
use strict;
use warnings;
use Bio::EnsEMBL::Utils::Exception qw(throw warning );
use Bio::EnsEMBL::Utils::Argument qw( rearrange );
use Bio::EnsEMBL::Utils::RNAProductTypeMapper;
use Bio::EnsEMBL::Utils::Scalar qw( assert_ref wrap_array );
use Scalar::Util qw(weaken);
use Bio::EnsEMBL::Storable;
use parent qw(Bio::EnsEMBL::Storable);
=head2 new
Arg [-SEQ_START] : The offset in the Transcript indicating the start
position of the product sequence.
Arg [-SEQ_END] : The offset in the Transcript indicating the end
position of the product sequence.
Arg [-START_EXON] : The Exon object in which the RNAProduct starts
Arg [-END_EXON] : The Exon object in which the RNAProduct ends
Arg [-STABLE_ID] : The stable identifier for this RNAPRoduct
Arg [-VERSION] : The version of the stable identifier
Arg [-DBID] : The internal identifier of this RNAProduct
Arg [-ADAPTOR] : The RNAProductAdaptor for this RNAProduct
Arg [-SEQ] : Manually sets the nucleotide sequence of this
RNAProduct. May be useful if this RNAProduct is not
stored in a database.
Arg [-CREATED_DATE] : the date the RNAProduct was created
Arg [-MODIFIED_DATE]: the date the RNAProduct was modified
Example : my $rp = Bio::EnsEMBL::RNAProduct->new(
-SEQ_START => 36,
-SEQ_END => 58
);
Description: Constructor. Creates a new RNAProduct object
Returntype : Bio::EnsEMBL::RNAProduct
Exceptions : none
Caller : general
Status : In Development
=cut
# perlcritic doesn't know about rearrange(), silence it
sub new { ## no critic (Subroutines::RequireArgUnpacking)
my $caller = shift;
my $class = ref($caller) || $caller;
my $type_code = Bio::EnsEMBL::Utils::RNAProductTypeMapper::mapper()
->class_to_type_code($class);
my ($seq_start, $seq_end, $start_exon, $end_exon, $stable_id, $version, $dbID,
$adaptor, $seq, $created_date, $modified_date ) =
rearrange(["SEQ_START", "SEQ_END", "START_EXON", "END_EXON",
"STABLE_ID", "VERSION", "DBID", "ADAPTOR", "SEQ",
"CREATED_DATE", "MODIFIED_DATE"], @_);
# For consistency between stable_id() and stable_id_version()
$stable_id //= '';
# Default version
$version //= 1;
my $self = bless {
'start' => $seq_start,
'end' => $seq_end,
'start_exon' => $start_exon,
lib/Bio/EnsEMBL/RNAProduct.pm view on Meta::CPAN
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'} );
} elsif (!defined($self->{'transcript'})) {
my $adaptor = $self->{'adaptor'};
if (!defined($adaptor)) {
throw("Adaptor not set for RNAProduct, cannot fetch its transcript");
}
my $dbID = $self->{'dbID'};
if (!defined($dbID)) {
throw("dbID not set for RNAProduct, cannot fetch its transcript.");
}
$self->{'transcript'} =
$adaptor->db()->get_TranscriptAdaptor()
->fetch_by_rnaproduct_id($dbID);
# Do not weaken the reference if we had to get the transcript from the
# database. The user is probably working on RNA products directly,
# not going through transcripts.
}
return $self->{'transcript'};
}
=head2 type_code
Example : my $rp_type_code = $rnaproduct->type_code();
Description: Getter for the RNAProduct type (e.g. miRNA, circRNA, ...).
The type is expressed as human-readable code.
This is somewhat redundant because similar information can
be obtained simply by looking at the class of the object,
indeed type_code is not meant to be modified independently
of the class. However, there are certain use cases when the
latter are more convenient than the former.
Returntype : string
Exceptions : none
Caller : ?
Status : In Development
=cut
sub type_code {
my $self = shift;
return $self->{'type_code'};
}
=head2 version
Arg [1] : (optional) string $version - version to set
Example : $rnaproduct->version(2);
Description: Getter/setter for attribute version
Returntype : string
Exceptions : none
Caller : general
Status : Stable
=cut
sub version {
my $self = shift;
if ( @_ ) {
$self->{'version'} = shift;
}
return $self->{'version'};
}
1;
( run in 1.639 second using v1.01-cache-2.11-cpan-97f6503c9c8 )