3 See the NOTICE file distributed with
this work
for additional information
4 regarding copyright ownership.
6 Licensed under the Apache License, Version 2.0 (the
"License");
7 you may not use
this file except in compliance with the License.
8 You may obtain a copy of the License at
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an
"AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License
for the specific language governing permissions and
16 limitations under the License.
23 Please email comments or questions to the
public Ensembl
24 developers list at <http:
26 Questions may also be sent to the Ensembl help desk at
39 -START_EXON => $exon1,
48 # get start and end position in start/end exons
49 my $start = $translation->start;
50 my $end = $translation->end;
55 through the use of start_Exon/end_Exon, and start/end attributes.
60 package Bio::EnsEMBL::Translation;
62 use vars qw($AUTOLOAD @ISA);
68 use Scalar::Util qw(weaken);
77 Arg [-START_EXON] : The
Exon object in which the translation (
CDS) starts
78 Arg [-END_EXON] : The
Exon object in which the translation (
CDS) ends
79 Arg [-SEQ_START] : The offset in the start_Exon indicating the start
81 Arg [-SEQ_END] : The offset in the end_Exon indicating the end
83 Arg [-STABLE_ID] : The stable identifier
for this Translation
84 Arg [-VERSION] : The version of the stable identifier
85 Arg [-DBID] : The
internal identifier of
this Translation
86 Arg [-ADAPTOR] : The TranslationAdaptor
for this Translation
87 Arg [-SEQ] : Manually sets the peptide sequence of
this translation.
88 May be useful
if this translation is not stored in
90 Arg [-CREATED_DATE]: the date the translation was created
91 Arg [-MODIFIED_DATE]: the date the translation was modified
97 Description: Constructor. Creates a
new Translation object
108 my $class = ref($caller) || $caller;
110 my ( $start_exon, $end_exon, $seq_start, $seq_end,
111 $stable_id, $version, $dbID, $adaptor, $seq,
112 $created_date, $modified_date ) =
113 rearrange( [
"START_EXON",
"END_EXON",
"SEQ_START",
"SEQ_END",
114 "STABLE_ID",
"VERSION",
"DBID",
"ADAPTOR",
115 "SEQ",
"CREATED_DATE",
"MODIFIED_DATE" ], @_ );
118 if ( !defined($version) ) { $version = 1 }
121 'start_exon' => $start_exon,
122 'end_exon' => $end_exon,
124 'start' => $seq_start,
126 'stable_id' => $stable_id,
127 'version' => $version,
128 'created_date' => $created_date,
129 'modified_date' => $modified_date,
133 $self->adaptor($adaptor);
143 Description : Sets or retrieves the
transcript object associated
144 with
this translation
object.
145 Exceptions : Throws
if there is no adaptor or no dbID defined
for
146 the translation
object.
151 my ( $self, $transcript ) = @_;
153 if ( defined($transcript) ) {
154 assert_ref( $transcript,
'Bio::EnsEMBL::Transcript' );
156 $self->{
'transcript'} = $transcript;
158 weaken( $self->{
'transcript'} ); # Avoid circular references.
161 # Break connection to transcript.
162 delete( $self->{
'transcript'} );
163 } elsif ( !defined( $self->{
'transcript'} ) ) {
164 my $adaptor = $self->adaptor;
165 if ( !defined($adaptor) ) {
166 throw(
"Adaptor is not set for translation, "
167 .
"can not fetch its transcript." );
170 my $dbID = $self->{
'dbID'};
171 if ( !defined($dbID) ) {
172 throw(
"dbID is not set for translation, "
173 .
" can not fetch its transcript." );
176 $self->{
'transcript'} =
177 $adaptor->db()->get_TranscriptAdaptor()
178 ->fetch_by_translation_id($dbID);
180 # Do not weaken the reference if we had to get the transcript from the
181 # database. The user is probably working on translations directly,
182 # not going through transcripts.
183 #weaken( $self->{'transcript'} ); # Avoid circular references.
186 return $self->{
'transcript'};
192 Arg [1] : (optional)
int $start - start position to set
193 Example : $translation->start(17);
194 Description: Getter/setter
for the value of start, which is a position within
195 the
exon given by start_Exon.
197 If you need genomic coordinates, use the genomic_start()
211 $obj->{
'start'} = $value;
213 return $obj->{
'start'};
220 Arg [1] : (optional)
int $end - end position to set
221 Example : $translation->end(8);
222 Description: Getter/setter
for the value of end, which is a position within
223 the
exon given by end_Exon.
225 If you need genomic coordinates, use the genomic_end()
239 $self->{
'end'} = $value;
241 return $self->{
'end'};
249 Example : $translation->start_Exon($exon1);
250 Description: Getter/setter
for the value of start_Exon, which denotes the
251 exon at which translation starts (and within
this exon, at the
252 position indicated by start, see above).
254 Exceptions : thrown on wrong argument type
265 if( !ref $value || !$value->isa(
'Bio::EnsEMBL::Exon') ) {
266 throw(
"Got to have an Exon object, not a $value");
268 $self->{
'start_exon'} = $value;
270 return $self->{
'start_exon'};
277 Example : $translation->start_Exon($exon1);
278 Description: Getter/setter
for the value of end_Exon, which denotes the
279 exon at which translation ends (and within
this exon, at the
280 position indicated by end, see above).
282 Exceptions : thrown on wrong argument type
292 if( !ref $value || !$value->isa(
'Bio::EnsEMBL::Exon') ) {
293 throw(
"Got to have an Exon object, not a $value");
295 $self->{
'end_exon'} = $value;
298 return $self->{
'end_exon'};
304 The
transcript which
this is a translation of.
305 Example : $translation_cdna_start = $translation->cdna_start();
306 Description : Returns the start position of the translation in cDNA
308 If no
transcript is given, the method will use
309 TranscriptAdaptor->fetch_by_translation_id() to locate
311 Return type : Integer
312 Exceptions : Throws
if the given (optional) argument is not a
315 Status : At Risk (Under Development)
320 my ( $self, $transcript ) = @_;
322 if ( defined($transcript)
323 && ( !ref($transcript)
324 || !$transcript->isa(
'Bio::EnsEMBL::Transcript') ) )
326 throw(
"Argument is not a transcript");
329 if ( !exists( $self->{
'cdna_start'} ) ) {
330 if ( !defined($transcript) ) {
331 # We were not given a transcript, get the transcript out of
333 $transcript = $self->transcript();
336 $self->{
'cdna_start'} =
337 $self->start_Exon()->cdna_coding_start($transcript);
340 return $self->{
'cdna_start'};
346 The
transcript which
this is a translation of.
347 Example : $translation_cdna_end = $translation->cdna_end();
348 Description : Returns the end position of the translation in cDNA
350 If no
transcript is given, the method will use
351 TranscriptAdaptor->fetch_by_translation_id() to locate
353 Return type : Integer
354 Exceptions : Throws
if the given (optional) argument is not a
357 Status : At Risk (Under Development)
362 my ( $self, $transcript ) = @_;
364 if ( defined($transcript)
365 && ( !ref($transcript)
366 || !$transcript->isa(
'Bio::EnsEMBL::Transcript') ) )
368 throw(
"Argument is not a transcript");
371 if ( !exists( $self->{
'cdna_end'} ) ) {
372 if ( !defined($transcript) ) {
373 # We were not given a transcript, get the transcript out of
375 $transcript = $self->transcript();
378 $self->{
'cdna_end'} =
379 $self->end_Exon()->cdna_coding_end($transcript);
382 return $self->{
'cdna_end'};
388 Example : $translation_genomic_start =
389 $translation->genomic_start();
390 Description : Returns the start position of the translation in
391 genomic coordinates on the forward strand.
392 Return type : Integer
395 Status : At Risk (Under Development)
402 if ( !exists $self->{
'genomic_start'} ) {
403 if ( $self->start_Exon()->strand() >= 0 ) {
404 $self->{
'genomic_start'} =
405 $self->start_Exon()->start() + ( $self->start() - 1 );
407 $self->{
'genomic_start'} =
408 $self->end_Exon()->end() - ( $self->end() - 1 );
412 return $self->{
'genomic_start'};
418 Example : $translation_genomic_end = $translation->genomic_end();
419 Description : Returns the end position of the translation in genomic
420 coordinates on the forward strand.
421 Return type : Integer
424 Status : At Risk (Under Development)
431 if ( !exists $self->{
'genomic_end'} ) {
432 if ( $self->end_Exon()->strand() >= 0 ) {
433 $self->{
'genomic_end'} =
434 $self->end_Exon()->start() + ( $self->end() - 1 );
436 $self->{
'genomic_end'} =
437 $self->start_Exon()->end() - ( $self->start() - 1 );
441 return $self->{
'genomic_end'};
446 Arg [1] : (optional)
string $version - version to set
447 Example : $translation->version(2);
448 Description: Getter/setter
for attribute version
458 $self->{
'version'} = shift
if( @_ );
459 return $self->{
'version'};
465 Arg [1] : (optional)
string $stable_id - stable ID to set
466 Example : $translation->stable_id(
'ENSP0059890');
467 Description: Getter/setter
for attribute stable_id
477 $self->{
'stable_id'} = shift
if( @_ );
478 return $self->{
'stable_id'};
481 =head2 stable_id_version
483 Arg [1] : (optional) String - the stable ID with version to set
484 Example : $translation->stable_id(
"ENSP0059890.3");
485 Description: Getter/setter
for stable
id with version
for this translation.
493 sub stable_id_version {
495 if(my $stable_id = shift) {
496 # See if there's an embedded period, assume that's a
497 # version, might not work for some species but you
498 # should use ->stable_id() and version() if you're worried
500 my $vindex = rindex($stable_id,
'.');
501 # Set the stable_id and version pair depending on if
502 # we found a version delimiter in the stable_id
503 ($self->{stable_id}, $self->{version}) = ($vindex > 0 ?
504 (substr($stable_id,0,$vindex), substr($stable_id,$vindex+1)) :
507 return $self->{stable_id} . ($self->{version} ?
".$self->{version}" :
'');
512 Arg [1] : (optional)
string $created_date - created date to set
513 Example : $translation->created_date(
'2007-01-10 20:52:00');
514 Description: Getter/setter
for attribute created date
524 $self->{
'created_date'} = shift
if ( @_ );
525 return $self->{
'created_date'};
531 Arg [1] : (optional)
string $modified_date - modification date to set
532 Example : $translation->modified_date(
'2007-01-10 20:52:00');
533 Description: Getter/setter
for attribute modified date
543 $self->{
'modified_date'} = shift
if ( @_ );
544 return $self->{
'modified_date'};
551 Arg [1] : hashref $old_new_exon_map
552 a hash that maps old to
new exons
for a whole gene
553 Description: maps start end end
exon according to mapping table.
554 If an
exon is not mapped, just keep the old one.
557 Caller : Transcript->transform()
564 my $href_exons = shift;
566 my $start_exon = $self->start_Exon();
567 my $end_exon = $self->end_Exon();
569 if ( exists $href_exons->{$start_exon} ) {
570 $self->start_Exon($href_exons->{$start_exon});
572 # do nothing, the start exon wasnt mapped
575 if ( exists $href_exons->{$end_exon} ) {
576 $self->end_Exon($href_exons->{$end_exon});
578 # do nothing, the end exon wasnt mapped
583 =head2 get_all_DBEntries
585 Arg [1] : (optional) String, external database name,
586 SQL wildcard characters (_ and %) can be used to
589 Arg [2] : (optional) String, external_db type,
590 (
'ARRAY',
'ALT_TRANS',
'ALT_GENE',
'MISC',
'LIT',
'PRIMARY_DB_SYNONYM',
'ENSEMBL'),
591 SQL wildcard characters (_ and %) can be used to
594 Example : my @dbentries = @{ $translation->get_all_DBEntries() };
595 @dbentries = @{ $translation->get_all_DBEntries(
'Uniprot%') };
596 @dbentries = @{ $translation->get_all_DBEntries(
'%',
'ENSEMBL') };
598 Description: Retrieves DBEntries (xrefs)
for this translation.
600 This method will attempt to lazy-load DBEntries
601 from a database
if an adaptor is available and no
602 DBEntries are present on the translation (i.e. they
603 have not already been added or loaded).
607 Caller : TranslationAdaptor::store
612 sub get_all_DBEntries {
613 my ( $self, $ex_db_exp, $ex_db_type ) = @_;
615 my $cache_name =
'dbentries';
617 if ( defined($ex_db_exp) ) {
618 $cache_name .= $ex_db_exp;
621 if ( defined($ex_db_type) ) {
622 $cache_name .= $ex_db_type;
625 # if not cached, retrieve all of the xrefs for this translation
626 if ( !defined( $self->{$cache_name} ) && defined( $self->adaptor() ) )
628 $self->{$cache_name} =
629 $self->
adaptor()->
db()->get_DBEntryAdaptor()
630 ->fetch_all_by_Translation( $self, $ex_db_exp, $ex_db_type );
633 $self->{$cache_name} ||= [];
635 return $self->{$cache_name};
636 } ## end sub get_all_DBEntries
638 =head2 get_all_object_xrefs
640 Arg [1] : (optional) String, external database name
642 Arg [2] : (optional) String, external_db type
644 Example : @oxrefs = @{ $translation->get_all_object_xrefs() };
646 Description: Retrieves xrefs
for this translation.
648 This method will attempt to lazy-load xrefs from a
649 database
if an adaptor is available and no xrefs
650 are present on the translation (i.e. they have not
651 already been added or loaded).
653 NB: This method is an alias
for the
654 get_all_DBentries() method.
656 Return type: Listref of
Bio::
EnsEMBL::DBEntry objects
662 sub get_all_object_xrefs {
664 return $self->get_all_DBEntries(@_);
670 The dbEntry to be added
671 Example : $translation->add_DBEntry($xref);
672 Description: Associates a DBEntry with
this translation. Note that adding
673 DBEntries will prevent future lazy-loading of DBEntries
for this
674 translation (see get_all_DBEntries).
676 Exceptions : thrown on incorrect argument type
686 unless($dbe && ref($dbe) && $dbe->isa(
'Bio::EnsEMBL::DBEntry')) {
687 throw(
'Expected DBEntry argument');
690 $self->{
'dbentries'} ||= [];
691 push @{$self->{
'dbentries'}}, $dbe;
695 =head2 get_all_DBLinks
697 Arg [1] : String database name (optional)
698 SQL wildcard characters (_ and %) can be used to
701 Arg [2] : (optional) String, external database type, can be one of
702 (
'ARRAY',
'ALT_TRANS',
'ALT_GENE',
'MISC',
'LIT',
'PRIMARY_DB_SYNONYM',
'ENSEMBL'),
703 SQL wildcard characters (_ and %) can be used to
706 Example : my @dblinks = @{ $translation->get_all_DBLinks() };
707 @dblinks = @{ $translation->get_all_DBLinks(
'Uniprot%') };
708 @dblinks = @{ $translation->get_all_DBLinks(
'%',
'ENSEMBL') };
710 Description: This is here
for consistancy with the Transcript
711 and Gene classes. It is a synonym
for the
712 get_all_DBEntries() method.
714 Return type: Listref to
Bio::
EnsEMBL::DBEntry objects
721 sub get_all_DBLinks {
723 return $self->get_all_DBEntries(@_);
728 Arg [1] : String database name (optional)
729 SQL wildcard characters (_ and %) can be used to
732 Example : @xrefs = @{ $translation->get_all_xrefs() };
733 @xrefs = @{ $translation->get_all_xrefs(
'Uniprot%') };
735 Description: This method is here
for consistancy with the Gene
736 and Transcript classes. It is an alias
for the
737 get_all_DBLinks() method, which in turn directly
738 calls get_all_DBEntries().
740 Return type: Listref of
Bio::
EnsEMBL::DBEntry objects
748 return $self->get_all_DBLinks(@_);
751 =head2 get_all_ProteinFeatures
753 Arg [1] : (optional)
string $logic_name
754 The analysis logic_name of the features to retrieve. If not
755 specified, all features are retrieved instead.
756 If no logic_name is found, looking
for analysis db name instead.
757 Example : $features = $self->get_all_ProteinFeatures(
'PFam');
758 Description: Retrieves all ProteinFeatures associated with
this
759 Translation. If a logic_name is specified, only features with
760 that logic_name are returned. If no logic_name is provided all
761 associated protein_features are returned.
763 ProteinFeatures are lazy-loaded from the database unless they
764 added manually to the Translation or had already been loaded.
772 sub get_all_ProteinFeatures {
774 my $logic_name = shift;
776 my (%hash, %db_hash);
779 if(!$self->{
'protein_features'}) {
781 my $adaptor = $self->adaptor();
782 my $dbID = $self->dbID();
784 return []
if (!$adaptor || !$dbID);
786 $self->{
'protein_features'} = \%hash;
788 my $pfa = $adaptor->db()->get_ProteinFeatureAdaptor();
790 foreach my $f (@{$pfa->fetch_all_by_translation_id($dbID)}) {
791 my $analysis = $f->analysis();
793 $name = lc($f->analysis->logic_name());
794 $ana_db = lc($f->analysis->db());
795 $db_hash{$ana_db} = $name;
797 warning(
"ProteinFeature has no attached analysis\n");
801 push @{$hash{$name}}, $f;
805 # a specific type of protein feature was requested
806 if(defined($logic_name)) {
807 $logic_name = lc($logic_name);
808 if (!$hash{$logic_name} && $no_pf) {
809 $logic_name = $db_hash{$logic_name};
811 return $self->{
'protein_features'}->{$logic_name} || [];
816 # all protein features were requested
817 foreach my $type (keys %{$self->{
'protein_features'}}) {
818 push @features, @{$self->{
'protein_features'}->{$type}};
825 =head2 get_all_DomainFeatures
827 Example : @domain_feats = @{$translation->get_all_DomainFeatures};
828 Description: A convenience method which retrieves all protein features
829 that are considered to be
'Domain' features. Features which
830 are
'domain' features are those with analysis logic names:
831 'pfscan',
'scanprosite',
'superfamily',
'pfam',
'prints',
832 'smart',
'pirsf',
'tigrfam'.
835 Caller : webcode (protview)
840 sub get_all_DomainFeatures{
845 my @types = (
'pfscan', #profile (prosite or pfam motifs)
846 'scanprosite', #prosite
854 foreach my $type (@types) {
855 push @features, @{$self->get_all_ProteinFeatures($type)};
862 =head2 add_ProteinFeature
865 The ProteinFeature to be added
866 Example : $translation->add_ProteinFeature($pf);
867 Description: Associates a ProteinFeature with
this translation. Note that
868 adding ProteinFeatures will prevent future lazy-loading of
869 ProteinFeatures
for this translation (see
870 get_all_ProteinFeatures).
872 Exceptions : thrown on incorrect argument type
878 sub add_ProteinFeature {
882 unless ($pf && ref($pf) && $pf->isa(
'Bio::EnsEMBL::ProteinFeature')) {
883 throw(
'Expected ProteinFeature argument');
887 throw(
"ProteinFeature has no attached Analysis.") unless $analysis;
889 push @{ $self->{
'protein_features'}->{$analysis->
logic_name} }, $pf;
895 Example : print $translation->display_id();
896 Description: This method returns a
string that is considered to be
897 the
'display' identifier. For translations
this is (depending on
898 availability and in
this order) the stable Id, the dbID or an
902 Caller : web drawing code
909 return $self->{
'stable_id'} || $self->dbID ||
'';
915 Example : print
"Peptide length =", $translation->length();
916 Description: Retrieves the length of the peptide sequence (i.e. number of
917 amino acids) represented by
this Translation
object.
920 Caller : webcode (protview etc.)
927 my $seq = $self->seq();
929 return ($seq) ? CORE::length($seq) : 0;
935 Example : print $translation->seq();
936 Description: Retrieves a
string representation of the peptide sequence
937 of
this Translation. This retrieves the
transcript from the
938 database and gets its sequence, or retrieves the sequence which
939 was set via the constructor.
941 Exceptions : warning
if the sequence is not set and cannot be retrieved from
943 Caller : webcode (protview etc.)
949 my ( $self, $sequence ) = @_;
951 if ( defined($sequence) ) {
953 $self->{
'seq'} = $sequence;
955 } elsif ( !defined( $self->{
'seq'} ) ) {
957 my $transcript = $self->transcript();
959 my $canonical_translation = $transcript->translation();
961 if(!$canonical_translation) {
962 throw "Transcript does not have a canonical translation";
964 if ( defined( $canonical_translation->stable_id() )
965 && defined( $self->stable_id() ) )
969 ( $canonical_translation->stable_id() ne $self->stable_id() );
970 } elsif ( defined( $canonical_translation->dbID() )
971 && defined( $self->dbID() ) )
975 ( $canonical_translation->dbID() != $self->dbID() );
977 # Resort to using geomic start/end coordinates.
978 $is_alternative = ( ($canonical_translation->genomic_start() !=
979 $self->genomic_start() )
980 || ( $canonical_translation->genomic_end() !=
981 $self->genomic_end() ) );
984 if ($is_alternative) {
985 # To deal with non-canonical (alternative) translations, subsitute
986 # the canonical translation in the transcript with $self for a
989 $transcript->translation($self);
992 my $seq = $transcript->translate();
993 if ( defined($seq) ) {
994 $self->{
'seq'} = $seq->seq();
997 if ($is_alternative) {
998 # Reinstate the real canonical translation.
1000 $transcript->translation($canonical_translation);
1003 } ## end elsif ( !defined( $self->...))
1005 if ( !defined( $self->{
'seq'} ) ) {
1006 return ''; # Empty
string
1009 return $self->{
'seq'};
1014 =head2 get_all_Attributes
1016 Arg [1] : optional
string $attrib_code
1017 The code of the attribute type to retrieve values
for.
1018 Example : ($sc_attr) = @{$tl->get_all_Attributes(
'_selenocysteine')};
1019 @tl_attributes = @{$translation->get_all_Attributes()};
1020 Description: Gets a list of Attributes of
this translation.
1021 Optionally just get Attrubutes
for given code.
1022 Recognized attribute
"_selenocysteine"
1024 Exceptions : warning
if translation does not have attached adaptor and
1026 Caller : general, modify_translation
1031 sub get_all_Attributes {
1033 my $attrib_code = shift;
1035 if( ! exists $self->{
'attributes' } ) {
1036 if(!$self->adaptor() ) {
1037 # warning('Cannot get attributes without an adaptor.');
1041 my $aa = $self->adaptor->db->get_AttributeAdaptor();
1042 $self->{
'attributes'} = $aa->fetch_all_by_Translation( $self );
1045 if( defined $attrib_code ) {
1046 my @results = grep { uc($_->code()) eq uc($attrib_code) }
1047 @{$self->{
'attributes'}};
1050 return $self->{
'attributes'};
1055 =head2 add_Attributes
1059 Example : $translation->add_Attributes($selenocysteine_attribute);
1060 Description: Adds an Attribute to the Translation. Usefull to
1062 If you add an attribute before you retrieve any from database,
1063 lazy load will be disabled.
1065 Exceptions :
throw on incorrect arguments
1071 sub add_Attributes {
1075 if( ! exists $self->{
'attributes'} ) {
1076 $self->{
'attributes'} = [];
1079 for my $attrib ( @attribs ) {
1080 if( ! $attrib->isa(
"Bio::EnsEMBL::Attribute" )) {
1081 throw(
"Argument to add_Attribute must be a Bio::EnsEMBL::Attribute" );
1083 push( @{$self->{
'attributes'}}, $attrib );
1089 =head2 get_all_SeqEdits
1091 Arg [1] : ArrayRef $edits. Specify the name of the edits to fetch
1092 Example : my @seqeds = @{$translation->get_all_SeqEdits()};
1093 my @seqeds = @{$translation->get_all_SeqEdits(
'_selenocysteine')};
1094 Description: Retrieves all post transcriptional sequence modifications
for
1098 Caller : spliced_seq()
1103 sub get_all_SeqEdits {
1111 $edits ||= [
'initial_met',
'_selenocysteine',
'amino_acid_sub',
'_stop_codon_rt'];
1114 foreach my $edit(@{wrap_array($edits)}){
1115 $attribs = $self->get_all_Attributes($edit);
1117 # convert attributes to SeqEdit objects
1118 foreach my $a (@$attribs) {
1125 =head2 get_all_selenocysteine_SeqEdits
1127 Example : my @edits = @{$translation->get_all_selenocysteine_SeqEdits()};
1128 Description: Retrieves all post transcriptional sequence modifications related
1129 to selenocysteine PTMs
1135 sub get_all_selenocysteine_SeqEdits {
1137 return $self->get_all_SeqEdits([
'_selenocysteine']);
1140 =head2 get_all_stop_codon_SeqEdits
1142 Example : my @edits = @{$translation->get_all_stop_codon_SeqEdits()};
1143 Description: Retrieves all post transcriptional sequence modifications related
1144 to stop codon readthrough
1150 sub get_all_stop_codon_SeqEdits {
1152 return $self->get_all_SeqEdits([
'_stop_codon_rt']);
1155 =head2 modify_translation
1157 Arg [1] : Bio::Seq $peptide
1158 Example : my $seq = Bio::Seq->
new(-SEQ => $dna)->translate();
1159 $translation->modify_translation($seq);
1160 Description: Applies sequence edits such as selenocysteines to the Bio::Seq
1161 peptide thats passed in
1162 Returntype : Bio::Seq
1169 sub modify_translation {
1170 my ( $self, $seq ) = @_;
1172 my @seqeds = @{ $self->get_all_SeqEdits() };
1174 # Sort in reverse order to avoid complication of adjusting
1176 # HACK: The translation ENSP00000420939 somehow makes the next line
1177 # bomb out ($a or $b becomes undef) if the start() method
1178 # is used. I haven't been able to find out why. It has 10
1179 # Selenocysteine seqedits that looks correct.
1180 # /Andreas (release 59)
1181 @seqeds = sort { $b->{
'start'} <=> $a->{
'start'} } @seqeds;
1184 my $peptide = $seq->seq();
1185 foreach my $se (@seqeds) {
1186 $se->apply_edit( \$peptide );
1189 $seq->seq($peptide);
1196 Arg [1] : Boolean $load_xrefs
1197 Load (or don
't load) xrefs. Default is to load xrefs.
1198 Example : $translation->load();
1199 Description : The Ensembl API makes extensive use of
1200 lazy-loading. Under some circumstances (e.g.,
1201 when copying genes between databases), all data of
1202 an object needs to be fully loaded. This method
1203 loads the parts of the object that are usually
1210 my ( $self, $load_xrefs ) = @_;
1212 if ( !defined($load_xrefs) ) { $load_xrefs = 1 }
1217 $self->get_all_Attributes();
1218 $self->get_all_ProteinFeatures();
1221 $self->get_all_DBEntries();
1226 =head2 get_all_DASFactories
1228 Function : Retrieves a listref of registered DAS objects
1229 Returntype: Listref of DAS Objects
1232 Example : $dasref = $prot->get_all_DASFactories;
1237 sub get_all_DASFactories {
1239 return [ $self->adaptor()->db()->_each_DASFeatureFactory ];
1243 =head2 get_all_DAS_Features
1245 Example : $features = $prot->get_all_DAS_Features;
1246 Description: Retrieves a hash reference to a hash of DAS feature
1247 sets, keyed by the DNS, NOTE the values of this hash
1248 are an anonymous array containing:
1249 (1) a pointer to an array of features;
1250 (2) a pointer to the DAS stylesheet
1251 Returntype : hashref of Bio::SeqFeatures
1258 sub get_all_DAS_Features{
1261 my $db = $self->adaptor->db;
1262 my $GeneAdaptor = $db->get_GeneAdaptor;
1263 my $Gene = $GeneAdaptor->fetch_by_translation_stable_id($self->stable_id) || return;
1264 my $slice = $Gene->feature_Slice;
1266 return $self->SUPER::get_all_DAS_Features($slice);
1269 =head2 summary_as_hash
1271 Example : $translation_summary = $translation->summary_as_hash();
1272 Description : Retrieves a textual summary of this Translation.
1273 Not inherited from Feature.
1274 Returns : hashref of arrays of descriptive strings
1275 Status : Intended for internal use
1278 sub summary_as_hash {
1281 my $id = $self->display_id;
1282 if ($self->version) { $id .= "." . $self->version; }
1283 $summary{'id'} = $id;
1284 $summary{'protein_id
'} = $id;
1285 $summary{'genomic_start
'} = $self->genomic_start;
1286 $summary{'genomic_end
'} = $self->genomic_end;
1287 $summary{'length
'} = $self->length;
1288 my $transcript = $self->transcript;
1289 $summary{'Parent
'} = $transcript->display_id;