Bio-EnsEMBL

 view release on metacpan or  search on metacpan

lib/Bio/EnsEMBL/RNAProduct.pm  view on Meta::CPAN

=head1 LICENSE

See the NOTICE file distributed with this work for additional information
regarding copyright ownership.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     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);

lib/Bio/EnsEMBL/RNAProduct.pm  view on Meta::CPAN

                  simply an alias for start().
    Return type : Integer
    Caller      : General
    Status      : Stable

=cut

sub cdna_start {
  my $self = shift;

  return $self->start();
}


=head2 created_date

  Arg [1]    : (optional) string $created_date - created date to set
  Example    : $rnaproduct->created_date('2007-01-10 20:52:00');
  Description: Getter/setter for attribute created_date
  Returntype : string
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub created_date {
  my $self = shift;
  if ( @_ ) {
    $self->{'created_date'} = shift;
  }
  return $self->{'created_date'};
}


=head2 display_id

  Example    : print $rnaproduct->display_id();
  Description: This method returns a string that is considered to be
               the 'display' identifier. For RNAProducts this is (depending on
               availability and in this order) the stable ID, the dbID or an
               empty string.
  Returntype : string
  Exceptions : none
  Caller     : web drawing code
  Status     : Stable

=cut

sub display_id {
  my $self = shift;
  return $self->stable_id() || $self->dbID() || '';
}


=head2 end

  Arg [1]    : (optional) int $end - end position to set
  Example    : $rnaproduct->end(39);
  Description: Getter/setter for the value of end, which is a position within
               the precursor Transcript.
  Returntype : int
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub end {
  my $self = shift;
  if ( @_ ) {
    $self->{'end'} = shift;
  }
  return $self->{'end'};
}


=head2 end_Exon

  Arg [1]    : (optional) Bio::EnsEMBL::Exon || undef - start exon to assign
  Example    : $rnaproduct->end_Exon($exon1);
  Description: Getter/setter for the value of end_Exon, which denotes the
               exon at which RNAProduct ends.
  Returntype : Bio::EnsEMBL::Exon
  Exceptions : thrown on wrong argument type
  Caller     : general
  Status     : Stable

=cut

sub end_Exon {
  my ($self, $exon) = @_;

  if (defined($exon)) {

    # Normal setter
    assert_ref($exon, 'Bio::EnsEMBL::Exon');
    $self->{'end_exon'} = $exon;

  }
  elsif (@_ > 1) {
    # User has explicitly passed undef. Break connection to exon.
    delete( $self->{'end_exon'} );
  }

  return $self->{'end_exon'};
}


=head2 genomic_end

    Args        : None
    Example     : $rnaproduct_genomic_end = $rnaproduct->genomic_end();
    Description : Returns the end position of the RNAProduct in genomic
                  coordinates on the forward strand.
    Return type : Integer
    Exceptions  : None
    Caller      : General
    Status      : Stable

=cut

lib/Bio/EnsEMBL/RNAProduct.pm  view on Meta::CPAN

  Example    : $rnaproduct->stable_id('ENSS00090210');
  Description: Getter/setter for attribute stable_id.
               Unlike stable_id_version(), setting a new stable ID does NOT
               reset the version number.
  Returntype : string
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub stable_id {
  my $self = shift;
  if ( @_ ) {
    $self->{'stable_id'} = shift;
  }
  return $self->{'stable_id'};
}


=head2 stable_id_version

  Arg [1]    : (optional) String - the stable ID with version to set
  Example    : $rnaproduct->stable_id("ENSS0059890.3");
  Description: Getter/setter for stable id with version for this RNAProduct.
               If the input string omits the version part, the version gets reset
               to undef; use stable_id() if you want to avoid this.
  Returntype : String
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub stable_id_version {
  my $self = shift;

  if (my $stable_id = shift) {
    # If there is at least one embedded period assume everything
    # beyond the last one is the version number. This may not work for
    # some species, if you are worried about ambiguity use stable_id() +
    # version() explicitly.
    my $vindex = rindex($stable_id, '.');
    ($self->{stable_id},
     $self->{version}) = ($vindex > 0 ?
                          (substr($stable_id, 0, $vindex),
                           substr($stable_id, $vindex + 1)) :
                          $stable_id, undef
                         );
  }

  return $self->{stable_id} . ($self->{version} ? ".$self->{version}" : '');
}


=head2 start

  Arg [1]    : (optional) int $start - start position to set
  Example    : $rnaproduct->start(17);
  Description: Getter/setter for the value of start, which is a position within
               the precursor Transcript.
  Returntype : int
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub start {
  my $self = shift;
  if ( @_ ) {
    $self->{'start'} = shift;
  }
  return $self->{'start'};
}


=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;



( run in 2.176 seconds using v1.01-cache-2.11-cpan-5837b0d9d2c )