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
44 # Returns an array of Exon objects
45 my @exons = @{ $tran->get_all_Exons() };
47 # Returns the peptide translation of the exons as a Bio::Seq
48 if ( $tran->translation() ) {
49 my $pep = $tran->translate();
51 print
"Transcript ", $tran->stable_id(),
" is non-coding\n";
57 consists of a set of Exons and (possibly) a Translation which defines the
58 coding and non-coding regions of the exons.
62 package Bio::EnsEMBL::Transcript;
81 use constant SEQUENCE_ONTOLOGY => {
92 string - the stable identifier of
this transcript
94 int - the version of the stable identifier of
this transcript
95 Arg [-EXTERNAL_NAME] :
96 string - the external database name associated with
this transcript
98 string - the name of the database the external name is from
99 Arg [-EXTERNAL_STATUS]:
100 string - the status of the external identifier
103 to label
this transcript when it is displayed.
106 Arg [-MODIFIED_DATE]:
107 string - the date the
transcript was last modified
109 string - the transcripts description
111 string - the biotype e.g.
"protein_coding"
113 Boolean - specifies
if this is the current version of the
transcript
115 string - the
transcript source, e.g.
"ensembl"
118 Description: Constructor. Instantiates a Transcript
object.
120 Exceptions :
throw on bad arguments
129 my $class = ref($proto) || $proto;
131 my $self = $class->SUPER::new(@_);
134 $exons, $stable_id, $version,
135 $external_name, $external_db, $external_status,
136 $display_xref, $created_date, $modified_date,
137 $description, $biotype, $confidence,
138 $external_db_name, $is_current,
143 $exons, $stable_id, $version,
144 $external_name, $external_db, $external_status,
145 $display_xref, $created_date, $modified_date,
146 $description, $biotype, $confidence,
147 $external_db_name, $is_current,
151 'EXONS',
'STABLE_ID',
152 'VERSION',
'EXTERNAL_NAME',
153 'EXTERNAL_DB',
'EXTERNAL_STATUS',
154 'DISPLAY_XREF',
'CREATED_DATE',
155 'MODIFIED_DATE',
'DESCRIPTION',
156 'BIOTYPE',
'CONFIDENCE',
158 'IS_CURRENT',
'SOURCE'
164 $self->{
'_trans_exon_array'} = $exons;
165 $self->recalculate_coordinates();
168 $self->stable_id($stable_id);
169 $self->{
'created_date'} = $created_date;
170 $self->{
'modified_date'} = $modified_date;
171 $self->external_name($external_name)
if ( defined $external_name );
172 $self->external_db($external_db)
if ( defined $external_db );
173 $self->external_status($external_status)
174 if ( defined $external_status );
175 $self->display_xref($display_xref)
if ( defined $display_xref );
176 $self->edits_enabled(1);
178 $self->description($description);
180 $self->{
'biotype'} = $biotype;
182 $self->source($source);
185 if ( !defined($version) ) { $version = 1 }
186 $self->{
'version'} = $version;
189 $is_current = 1 unless ( defined($is_current) );
190 $self->{
'is_current'} = $is_current;
195 =head2 get_all_DBLinks
197 Arg [1] : String database name (optional)
198 SQL wildcard characters (_ and %) can be used to
201 Arg [2] : (optional) String, external database type, can be one of
202 (
'ARRAY',
'ALT_TRANS',
'ALT_GENE',
'MISC',
'LIT',
'PRIMARY_DB_SYNONYM',
'ENSEMBL'),
203 SQL wildcard characters (_ and %) can be used to
206 Example : my @dblinks = @{ $transcript->get_all_DBLinks() };
207 @dblinks = @{ $transcript->get_all_DBLinks(
'Uniprot%') };}
208 @dblinks = @{ $transcript->get_all_DBLinks(
'%',
'ENSEMBL') };
210 Description: Retrieves *all* related DBEntries
for this
211 transcript. This includes all DBEntries that are
212 associated with the corresponding translation.
214 If you only want to retrieve the DBEntries associated
215 with the
transcript (and not the translation) then
216 you should use the get_all_DBEntries() call instead.
218 Note: Each entry may be listed more than once. No
219 uniqueness checks are done. Also if you put in an
220 incorrect external database name no checks are done
221 to see if this exists, you will just get an empty
224 Return type: Listref of
Bio::
EnsEMBL::DBEntry objects
231 sub get_all_DBLinks {
232 my ( $self, $db_name_exp, $ex_db_type ) = @_;
235 @{ $self->get_all_DBEntries( $db_name_exp, $ex_db_type ) };
237 # Add all of the transcript and translation xrefs to the return list.
238 my $translation = $self->translation();
239 if ( defined($translation) ) {
241 @{$translation->get_all_DBEntries( $db_name_exp, $ex_db_type ) }
245 @links = sort { _compare_xrefs() } @links;
252 Arg [1] : String database name (optional)
253 SQL wildcard characters (_ and %) can be used to
256 Example : @xrefs = @{ $transcript->get_all_xrefs() };
257 @xrefs = @{ $transcript->get_all_xrefs(
'Uniprot%') };
259 Description: Retrieves *all* related xrefs
for this transcript.
260 This includes all xrefs that are associated with the
263 If you want to retrieve the xrefs associated with
264 only the
transcript (and not the translation) then
265 you should use the get_all_object_xrefs() method
268 Note: Each entry may be listed more than once. No
269 uniqueness checks are done. Also if you put in an
270 incorrect external database name no checks are done
271 to see if this exists, you will just get an empty
274 NB: This method is an alias for the
275 get_all_DBLinks() method.
277 Return type: Listref of
Bio::
EnsEMBL::DBEntry objects
285 return $self->get_all_DBLinks(@_);
288 =head2 get_all_DBEntries
290 Arg [1] : (optional) String, external database name,
291 SQL wildcard characters (_ and %) can be used to
294 Arg [2] : (optional) String, external database type, can be one of
295 (
'ARRAY',
'ALT_TRANS',
'ALT_GENE',
'MISC',
'LIT',
'PRIMARY_DB_SYNONYM',
'ENSEMBL'),
296 SQL wildcard characters (_ and %) can be used to
299 Example : my @dbentries = @{ $transcript->get_all_DBEntries() };
300 @dbentries = @{ $transcript->get_all_DBEntries(
'Uniprot%') };}
301 @dbentries = @{ $transcript->get_all_DBEntries(
'%',
'ENSEMBL') };}
303 Description: Retrieves DBEntries (xrefs)
for this transcript.
304 This does *not* include the corresponding
305 translations DBEntries (see get_all_DBLinks()).
307 This method will attempt to lazy-load DBEntries
308 from a database
if an adaptor is available and no
309 DBEntries are present on the
transcript (i.e. they
310 have not already been added or loaded).
314 Caller : get_all_DBLinks, TranscriptAdaptor::store
319 sub get_all_DBEntries {
320 my ( $self, $ex_db_exp, $ex_db_type ) = @_;
322 my $cache_name =
'dbentries';
324 if ( defined($ex_db_exp) ) {
325 $cache_name .= $ex_db_exp;
328 if ( defined($ex_db_type) ) {
329 $cache_name .= $ex_db_type;
332 # if not cached, retrieve all of the xrefs for this transcript
333 if ( !defined( $self->{$cache_name} ) && defined( $self->adaptor() ) )
335 $self->{$cache_name} =
336 $self->
adaptor()->
db()->get_DBEntryAdaptor()
337 ->fetch_all_by_Transcript( $self, $ex_db_exp, $ex_db_type );
340 $self->{$cache_name} ||= [];
342 return $self->{$cache_name};
343 } ## end sub get_all_DBEntries
345 =head2 get_all_object_xrefs
347 Arg [1] : (optional) String, external database name
349 Arg [2] : (optional) String, external_db type
351 Example : @oxrefs = @{ $transcript->get_all_object_xrefs() };
353 Description: Retrieves xrefs
for this transcript. This does
354 *not* include xrefs that are associated with the
355 corresponding translations of
this transcript (see
358 This method will attempt to lazy-load xrefs from a
359 database
if an adaptor is available and no xrefs are
360 present on the
transcript (i.e. they have not already
361 been added or loaded).
363 NB: This method is an alias
for the
364 get_all_DBentries() method.
366 Return type: Listref of
Bio::
EnsEMBL::DBEntry objects
372 sub get_all_object_xrefs {
374 return $self->get_all_DBEntries(@_);
380 The dbEntry to be added
381 Example : my $dbe = Bio::EnsEMBL::DBEntery->
new(...);
382 $transcript->add_DBEntry($dbe);
383 Description: Associates a DBEntry with
this transcript. Note that adding
384 DBEntries will prevent future lazy-loading of DBEntries
for this
385 gene (see get_all_DBEntries).
387 Exceptions : thrown on incorrect argument type
397 unless($dbe && ref($dbe) && $dbe->isa(
'Bio::EnsEMBL::DBEntry')) {
398 throw(
'Expected DBEntry argument');
401 $self->{
'dbentries'} ||= [];
402 push @{$self->{
'dbentries'}}, $dbe;
406 =head2 get_all_supporting_features
408 Example : my @evidence = @{ $transcript->get_all_supporting_features };
409 Description: Retrieves any supporting features added manually by
410 calls to add_supporting_features.
418 sub get_all_supporting_features {
421 if( !exists $self->{_supporting_evidence} ) {
423 my $tsfa = $self->
adaptor->
db->get_TranscriptSupportingFeatureAdaptor();
424 $self->{_supporting_evidence} = $tsfa->fetch_all_by_Transcript($self);
428 return $self->{_supporting_evidence} || [];
432 =head2 add_supporting_features
435 The supporting features to add
436 Example : $transcript->add_supporting_features(@features);
437 Description: Adds a list of supporting features to
this Transcript.
438 The added features can be retieved by
439 get_all_supporting_features().
441 Exceptions :
throw if any of the features are not FeaturePairs
442 throw if any of the features are not in the same coordinate
443 system as the Transcript
449 sub add_supporting_features {
450 my ($self, @features) = @_;
452 return unless @features;
454 $self->{_supporting_evidence} ||= [];
456 # check whether this feature object has been added already
457 FEATURE:
foreach my $feature (@features) {
459 if (!defined($feature) || ref($feature) eq
"ARRAY") {
460 throw(
"Element in transcript supporting features array is undefined or is an ARRAY for " . $self->dbID);
462 if (!$feature || !$feature->isa(
"Bio::EnsEMBL::FeaturePair")) {
463 print
"feature = " . $feature .
"\n";
464 throw(
"Supporting feat [$feature] not a " .
465 "Bio::EnsEMBL::FeaturePair");
468 if ((defined $self->slice() && defined $feature->slice())&&
469 ( $self->slice()->name() ne $feature->slice()->name())){
470 throw(
"Supporting feat not in same coord system as transcript\n" .
471 "transcript is attached to [".$self->slice()->name().
"]\n" .
472 "feat is attached to [".$feature->slice()->name().
"]");
475 foreach my $added_feature ( @{ $self->{_supporting_evidence} } ){
477 if ( $feature == $added_feature ){
478 #this feature has already been added
483 #no duplicate was found, add the feature
484 push(@{$self->{_supporting_evidence}}, $feature);
489 =head2 flush_supporting_features
491 Example : $transcript->flush_supporting_features;
492 Description : Removes all supporting evidence from the
transcript.
493 Return type : (Empty) listref
500 sub flush_supporting_features {
502 $self->{
'_supporting_evidence'} = [];
508 Arg [1] : (optional) String - name of external db to set
509 Example : $transcript->external_db(
'HGNC');
510 Description: Getter/setter
for attribute external_db. The db is the one that
511 belongs to the external_name.
520 my ( $self, $ext_dbname ) = @_;
522 if(defined $ext_dbname) {
523 return ( $self->{
'external_db'} = $ext_dbname );
526 if( exists $self->{
'external_db'} ) {
527 return $self->{
'external_db'};
530 my $display_xref = $self->display_xref();
532 if( defined $display_xref ) {
533 return $display_xref->dbname()
540 =head2 external_status
542 Arg [1] : (optional) String - status of the external db
543 Example : $transcript->external_status(
'KNOWNXREF');
544 Description: Getter/setter
for attribute external_status. The status of
545 the external db of the one that belongs to the external_name.
553 sub external_status {
554 my ( $self, $ext_status ) = @_;
556 if(defined $ext_status) {
557 return ( $self->{
'external_status'} = $ext_status );
560 if( exists $self->{
'external_status'} ) {
561 return $self->{
'external_status'};
564 my $display_xref = $self->display_xref();
566 if( defined $display_xref ) {
567 return $display_xref->status()
576 Arg [1] : (optional) String - the external name to set
577 Example : $transcript->external_name(
'BRCA2-001');
578 Description: Getter/setter
for attribute external_name.
579 Returntype : String or undef
587 my ($self, $ext_name) = @_;
589 if(defined $ext_name) {
590 return ( $self->{
'external_name'} = $ext_name );
593 if( exists $self->{
'external_name'} ) {
594 return $self->{
'external_name'};
597 my $display_xref = $self->display_xref();
599 if( defined $display_xref ) {
600 return $display_xref->display_id()
608 Arg [1] : (optional) String - the source to set
609 Example : $transcript->source(
'ensembl');
610 Description: Getter/setter
for attribute source
620 $self->{
'source'} = shift
if( @_ );
621 return ( $self->{
'source'} ||
"ensembl" );
627 Example : $transcript->display_xref($db_entry);
628 Description: Getter/setter
for display_xref
for this transcript.
638 $self->{
'display_xref'} = shift
if(@_);
639 return $self->{
'display_xref'};
644 Args [1] : (optional) Boolean is_canonical
646 Example :
if ($transcript->is_canonical()) { ... }
648 Description : Returns
true (non-zero)
if the
transcript is the
649 canonical
transcript of its gene,
false (0)
if not. If the code
650 returns an undefined it is because its state is not currently
651 known. Internally the code will consult the database
for this
652 value
if it is unknown and the
transcript has a dbID and an
655 Return type : Boolean
662 my ( $self, $value ) = @_;
665 return $self->{is_canonical}
if defined $self->{is_canonical};
667 if ( defined($value) ) {
668 $self->{is_canonical} = ( $value ? 1 : 0 );
671 if(! defined $self->{is_canonical} && $self->dbID() && $self->adaptor()) {
672 $self->{is_canonical} = $self->adaptor()->is_Transcript_canonical($self);
676 return $self->{is_canonical};
682 Example :
if ( $transcript->translation() ) {
683 print( $transcript->translation()->stable_id(),
"\n" );
685 print(
"Pseudogene\n");
687 Description: Getter/setter
for the Translation
object which
688 defines the CDS (and as a result the peptide encoded
689 by)
this transcript. This
function will
return
690 undef
if this transcript is a pseudogene, i.e. a
691 non-translating
transcript such as an ncRNA. This
692 is the accepted method of determining whether a
702 my ( $self, $translation ) = @_;
704 if ( defined($translation) ) {
705 assert_ref( $translation,
'Bio::EnsEMBL::Translation' );
707 $self->{
'translation'} = $translation;
708 $translation->transcript($self);
710 $self->{
'cdna_coding_start'} = undef;
711 $self->{
'cdna_coding_end'} = undef;
713 $self->{
'coding_region_start'} = undef;
714 $self->{
'coding_region_end'} = undef;
716 $self->{
'transcript_mapper'} = undef;
719 if ( defined( $self->{
'translation'} ) ) {
720 # Removing existing translation
722 $self->{
'translation'}->transcript(undef);
723 delete( $self->{
'translation'} );
725 $self->{
'cdna_coding_start'} = undef;
726 $self->{
'cdna_coding_end'} = undef;
728 $self->{
'coding_region_start'} = undef;
729 $self->{
'coding_region_end'} = undef;
731 $self->{
'transcript_mapper'} = undef;
733 } elsif ( !exists( $self->{
'translation'} )
734 && defined( $self->adaptor() ) )
736 $self->{
'translation'} =
737 $self->adaptor()->db()->get_TranslationAdaptor()
738 ->fetch_by_Transcript($self);
741 return $self->{
'translation'};
742 } ## end sub translation
744 =head2 get_all_alternative_translations
749 my @alt_translations =
750 @{ $transcript->get_all_alternative_translations() };
752 Description: Fetches all alternative translations defined
for this
753 transcript. The canonical translation is not returned.
762 sub get_all_alternative_translations {
765 if ( !exists( $self->{
'alternative_translations'} )
766 && defined( $self->adaptor() ) )
768 my $pa = $self->
adaptor()->
db()->get_TranslationAdaptor();
770 @{ $pa->fetch_all_alternative_by_Transcript($self) };
772 $self->{
'alternative_translations'} = \@translations;
775 return $self->{
'alternative_translations'};
778 =head2 add_alternative_translation
783 $transcript->add_alternative_translation($translation);
785 Description: Adds an alternative translation to
this transcript.
793 sub add_alternative_translation {
794 my ( $self, $translation ) = @_;
796 if ( !( defined($translation)
798 && $translation->isa(
'Bio::EnsEMBL::Translation') ) )
800 throw(
"Bio::EnsEMBL::Translation argument expected.");
803 # Load the existsing alternative translations from the database if
804 # they haven't already been loaded.
805 $self->get_all_alternative_translations();
807 push( @{ $self->{
'alternative_translations'} }, $translation );
812 Args : soft_mask (opt)
813 if specified, will
return a sequence where UTR regions are lowercased
814 Description: Retrieves all Exon sequences and concats them together.
815 No phase padding magic is done, even
if phases
do not align.
824 my ( $self, $soft_mask ) = @_;
827 for my $ex ( @{$self->get_all_Exons()} ) {
828 my $seq = $ex->seq();
830 warning(
"Could not obtain seq for exon. Transcript sequence may not " .
832 $seq_string .=
'N' x $ex->length();
834 my $exon_seq = $seq->seq();
837 if (!defined ($ex->coding_region_start($self))) {
838 $exon_seq = lc($exon_seq);
841 if ($ex->coding_region_start($self) > $ex->start()) {
842 my $forward_length = $ex->coding_region_start($self) - $ex->start();
843 my $reverse_length = $ex->end() - $ex->coding_region_start($self);
844 if ($ex->strand == 1) {
845 $exon_seq = lc (substr($exon_seq, 0, $forward_length)) . substr($exon_seq, $forward_length);
847 $exon_seq = substr($exon_seq, 0, $reverse_length+1) . lc(substr($exon_seq, $reverse_length+1));
851 if ($ex->coding_region_end($self) < $ex->end()) {
852 my $forward_length = $ex->coding_region_end($self) - $ex->start();
853 my $reverse_length = $ex->end() - $ex->coding_region_end($self);
854 if ($ex->strand == 1) {
855 $exon_seq = substr($exon_seq, 0, $forward_length+1) . lc(substr($exon_seq, $forward_length+1));
857 $exon_seq = lc(substr($exon_seq, 0, $reverse_length)) . substr($exon_seq, $reverse_length);
861 $seq_string .= $exon_seq;
865 # apply post transcriptional edits
866 if($self->edits_enabled()) {
867 my @seqeds = @{$self->get_all_SeqEdits()};
869 # sort edits in reverse order to remove complication of
870 # adjusting downstream edits
871 @seqeds = sort {$b->start() <=> $a->start()} @seqeds;
873 foreach my $se (@seqeds) {
874 $se->apply_edit(\$seq_string);
882 =head2 translateable_seq
885 Example : print $transcript->translateable_seq(),
"\n";
886 Description: Returns a sequence
string which is the the translateable part
887 of the transcripts sequence. This is formed by splicing all
888 Exon sequences together and apply all defined RNA edits.
889 Then the coding part of the sequence is extracted and returned.
890 The code will not support monkey exons any more. If you want to
891 have non phase matching exons, defined appropriate _rna_edit
894 An empty
string is returned
if this transcript is a pseudogene
895 (i.e. is non-translateable).
903 sub translateable_seq {
906 if ( !$self->translation() ) {
910 my $mrna = $self->spliced_seq();
912 my $start = $self->cdna_coding_start();
913 my $end = $self->cdna_coding_end();
915 $mrna = substr( $mrna, $start - 1, $end - $start + 1 );
917 my $start_phase = $self->translation->start_Exon->phase();
918 if( $start_phase > 0 ) {
919 $mrna =
"N"x$start_phase . $mrna;
921 if( ! $start || ! $end ) {
929 =head2 cdna_coding_start
931 Arg [1] : (optional) $value
932 Example : $relative_coding_start = $transcript->cdna_coding_start;
933 Description: Retrieves the position of the coding start of
this transcript
934 in cdna coordinates (relative to the start of the 5prime end of
935 the
transcript, excluding introns, including utrs).
937 This will
return undef
if this is a pseudogene (i.e. a
941 Caller : five_prime_utr, get_all_snps, general
946 sub cdna_coding_start {
950 $self->{
'cdna_coding_start'} = shift;
953 if(!defined $self->{
'cdna_coding_start'} && defined $self->translation){
954 # calc coding start relative from the start of translation (in cdna coords)
957 my @exons = @{$self->get_all_Exons};
960 while($exon = shift @exons) {
961 if($exon == $self->translation->start_Exon) {
962 #add the utr portion of the start exon
963 $start += $self->translation->start;
966 #add the entire length of this non-coding exon
967 $start += $exon->length;
971 # adjust cdna coords if sequence edits are enabled
972 if($self->edits_enabled()) {
973 my @seqeds = @{$self->get_all_SeqEdits()};
974 if (scalar @seqeds) {
975 my $transl_start = $self->get_all_Attributes(
'_transl_start');
976 if (@{$transl_start}) {
977 $start = $transl_start->[0]->value;
979 # sort in reverse order to avoid adjustment of downstream edits
980 @seqeds = sort {$b->start() <=> $a->start()} @seqeds;
982 foreach my $se (@seqeds) {
983 # use less than start so that start of CDS can be extended
984 if($se->start() < $start) {
985 $start += $se->length_diff();
992 $self->{
'cdna_coding_start'} = $start;
995 return $self->{
'cdna_coding_start'};
999 =head2 cdna_coding_end
1001 Arg [1] : (optional) $value
1002 Example : $cdna_coding_end = $transcript->cdna_coding_end;
1003 Description: Retrieves the end of the coding region of
this transcript in
1004 cdna coordinates (relative to the five prime end of the
1005 transcript, excluding introns, including utrs).
1007 This will
return undef
if this transcript is a pseudogene
1008 (i.e. a
transcript with no translation and therefor no CDS).
1016 sub cdna_coding_end {
1020 $self->{
'cdna_coding_end'} = shift;
1023 if(!defined $self->{
'cdna_coding_end'} && defined $self->translation) {
1024 my @exons = @{$self->get_all_Exons};
1027 while(my $exon = shift @exons) {
1028 if($exon == $self->translation->end_Exon) {
1029 # add coding portion of the final coding exon
1030 $end += $self->translation->end;
1034 $end += $exon->length;
1038 # adjust cdna coords if sequence edits are enabled
1039 if($self->edits_enabled()) {
1040 my @seqeds = @{$self->get_all_SeqEdits()};
1041 if (scalar @seqeds) {
1042 my $transl_end = $self->get_all_Attributes(
'_transl_end');
1043 if (@{$transl_end}) {
1044 $end = $transl_end->[0]->value;
1046 # sort in reverse order to avoid adjustment of downstream edits
1047 @seqeds = sort {$b->start() <=> $a->start()} @seqeds;
1049 foreach my $se (@seqeds) {
1050 # use less than or equal to end+1 so end of the CDS can be extended
1051 if($se->start() <= $end + 1) {
1052 $end += $se->length_diff();
1059 $self->{
'cdna_coding_end'} = $end;
1062 return $self->{
'cdna_coding_end'};
1066 =head2 coding_region_start
1068 Arg [1] : (optional) $value
1069 Example : $coding_region_start = $transcript->coding_region_start
1070 Description: Retrieves the start of the coding region of
this transcript
1071 in genomic coordinates (i.e. in either slice or contig coords).
1072 By convention, the coding_region_start is always lower than
1073 the value returned by the coding_end method.
1074 The value returned by
this function is NOT the biological
1075 coding start since on the reverse strand the biological coding
1076 start would be the higher genomic value.
1078 This
function will
return undef
if this is a pseudogene
1087 sub coding_region_start {
1088 my ($self, $value) = @_;
1090 if( defined $value ) {
1091 $self->{
'coding_region_start'} = $value;
1092 } elsif(!defined $self->{
'coding_region_start'} &&
1093 defined $self->translation) {
1094 #calculate the coding start from the translation
1096 my $strand = $self->translation()->start_Exon->strand();
1097 if( $strand == 1 ) {
1098 $start = $self->translation()->start_Exon->start();
1099 $start += ( $self->translation()->start() - 1 );
1101 $start = $self->translation()->end_Exon->end();
1102 $start -= ( $self->translation()->end() - 1 );
1104 $self->{
'coding_region_start'} = $start;
1107 return $self->{
'coding_region_start'};
1111 =head2 coding_region_end
1113 Arg [1] : (optional) $value
1114 Example : $coding_region_end = $transcript->coding_region_end
1115 Description: Retrieves the end of the coding region of
this transcript
1116 in genomic coordinates (i.e. in either slice or contig coords).
1117 By convention, the coding_region_end is always higher than the
1118 value returned by the coding_region_start method.
1119 The value returned by
this function is NOT the biological
1120 coding end since on the reverse strand the biological coding
1121 end would be the lower genomic value.
1123 This
function will
return undef
if this is a pseudogene
1132 sub coding_region_end {
1133 my ($self, $value ) = @_;
1138 if( defined $value ) {
1139 $self->{
'coding_region_end'} = $value;
1140 } elsif( ! defined $self->{
'coding_region_end'}
1141 && defined $self->translation() ) {
1142 $strand = $self->translation()->start_Exon->strand();
1143 if( $strand == 1 ) {
1144 $end = $self->translation()->end_Exon->start();
1145 $end += ( $self->translation()->end() - 1 );
1147 $end = $self->translation()->start_Exon->end();
1148 $end -= ( $self->translation()->start() - 1 );
1150 $self->{
'coding_region_end'} = $end;
1153 return $self->{
'coding_region_end'};
1157 =head2 edits_enabled
1159 Arg [1] : (optional)
boolean $newval
1160 Example : $transcript->edits_enabled(1);
1161 Description: Enables/Disables the application of SeqEdits to
this transcript.
1162 Edits are enabled by
default, and affect the cdna/mrna
1163 sequences coordinates and the resultant translation.
1164 Returntype :
boolean - the current value of the edits
1166 Caller : general, cdna_coding_start, cdna_coding_end, length
1172 my ( $self, $boolean ) = @_;
1174 if ( defined($boolean) ) {
1175 $self->{
'edits_enabled'} = $boolean;
1177 # flush cached values that will be different with/without edits
1178 $self->{
'cdna_coding_start'} = undef;
1179 $self->{
'cdna_coding_end'} = undef;
1180 $self->{
'transcript_mapper'} = undef;
1183 return $self->{
'edits_enabled'};
1187 =head2 get_all_SeqEdits
1190 Example : my @seqeds = @{$transcript->get_all_SeqEdits()};
1191 Description: Retrieves all post transcriptional sequence modifications
for
1195 Caller : spliced_seq()
1200 sub get_all_SeqEdits {
1205 my $attribs = $self->get_all_Attributes(
'_rna_edit');
1207 # convert attributes to SeqEdit objects
1208 foreach my $a (@$attribs) {
1216 =head2 get_all_Attributes
1218 Arg [1] : optional
string $attrib_code
1219 The code of the attribute type to retrieve values
for.
1220 Example : ($rna_edits) = @{$transcript->get_all_Attributes(
'_rna_edit')};
1221 @transc_attributes = @{$transcript->get_all_Attributes()};
1222 Description: Gets a list of Attributes of
this transcript.
1223 Optionally just get Attrubutes
for given code.
1225 Exceptions : warning
if transcript does not have attached adaptor and
1232 sub get_all_Attributes {
1234 my $attrib_code = shift;
1236 if( ! exists $self->{
'attributes' } ) {
1237 if(!$self->adaptor() ) {
1241 my $attribute_adaptor = $self->adaptor->db->get_AttributeAdaptor();
1242 $self->{
'attributes'} = $attribute_adaptor->fetch_all_by_Transcript($self);
1245 if( defined $attrib_code) {
1246 my @results = grep { uc($_->code()) eq uc($attrib_code) }
1247 @{$self->{
'attributes'}};
1250 return $self->{
'attributes'};
1255 =head2 add_Attributes
1258 You can have more Attributes as arguments, all will be added.
1259 Example : $transcript->add_Attributes($rna_edit_attribute);
1260 Description: Adds an Attribute to the Transcript. Usefull to
do _rna_edits.
1261 If you add an attribute before you retrieve any from database,
1262 lazy load will be disabled.
1264 Exceptions :
throw on incorrect arguments
1270 sub add_Attributes {
1271 my ( $self, @attribs ) = @_;
1273 if ( !exists( $self->{
'attributes'} ) ) {
1274 $self->{
'attributes'} = [];
1278 foreach my $attrib (@attribs) {
1279 assert_ref( $attrib,
'Bio::EnsEMBL::Attribute' );
1281 push( @{ $self->{
'attributes'} }, $attrib );
1283 if ( $attrib->code() eq
"_rna_edit" ) {
1289 my $translation = $self->translation();
1290 if ( defined($translation) ) {
1291 delete( $translation->{
'seq'} );
1295 # flush cdna coord cache b/c we may have added a SeqEdit
1296 delete( $self->{
'cdna_coding_start'} );
1297 delete( $self->{
'cdna_coding_end'} );
1298 delete( $self->{
'transcript_mapper'} );
1299 } ## end sub add_Attributes
1305 Example : $trans->add_Exon($exon)
1310 : or
exon clashes with another one
1316 my ( $self, $exon, $rank ) = @_;
1318 assert_ref( $exon,
'Bio::EnsEMBL::Exon' );
1320 $self->{
'_trans_exon_array'} ||= [];
1322 if ( defined($rank) ) {
1323 $self->{
'_trans_exon_array'}->[ $rank - 1 ] = $exon;
1329 my $ea = $self->{
'_trans_exon_array'};
1332 if ( $exon->strand() == 1 ) {
1334 my $exon_start = $exon->start();
1336 if ( $exon_start > $ea->[-1]->end() ) {
1337 push( @{$ea}, $exon );
1340 # Insert it at correct place
1343 foreach my $e ( @{$ea} ) {
1344 if ( $exon_start < $e->start() ) {
1345 if ( $exon->end() >= $e->start() ) {
1349 if ( $i and $exon_start <= $ea->[$i-1]->end() ) {
1353 splice( @{$ea}, $i, 0, $exon );
1364 my $exon_end = $exon->end();
1366 if ( $exon_end < $ea->[-1]->start() ) {
1367 push( @{$ea}, $exon );
1370 # Insert it at correct place
1373 foreach my $e ( @{$ea} ) {
1374 if ( $exon_end > $e->end() ) {
1375 if ( $exon->start() <= $e->end() ) {
1379 if ( $i and $exon_end >= $ea->[$i-1]->start() ) {
1383 splice( @{$ea}, $i, 0, $exon );
1392 } ## end
else [
if ( $exon->strand() ==...)]
1394 push( @{$ea}, $exon );
1399 if ( !$was_added ) {
1400 # The exon was not added because it was overloapping with an
1404 foreach my $e ( @{$ea} ) {
1408 . $e->strand() .
') '
1409 . ( $e->stable_id() ||
'' ) .
"\n";
1413 . $exon->start() .
'-'
1414 . $exon->end() .
' ('
1415 . $exon->strand() .
') '
1416 . ( $exon->stable_id() ||
'' ) .
"\n";
1418 throw(
"Exon overlaps with other exon in same transcript.\n"
1419 .
"Transcript Exons:\n$all_str\n"
1420 .
"This Exon:\n$cur_str" );
1423 # recalculate start, end, slice, strand
1424 $self->recalculate_coordinates();
1425 } ## end sub add_Exon
1428 =head2 get_all_Exons
1431 Only
return constitutive exons
if true (non-zero)
1433 Example : my @exons = @{ $transcript->get_all_Exons() };
1434 my @exons = @{ $transcript->get_all_Exons( -constitutive => 1 ) };
1436 Description: Returns an listref of the exons in
this transcript
1437 in order, i.e. the first
exon in the listref is the
1439 constitutive exons
if the CONSTITUTIVE argument is
1450 my ( $self, @args ) = @_;
1454 $constitutive = rearrange( [
'CONSTITUTIVE'], @args );
1457 if (!defined( $self->{
'_trans_exon_array'} )
1458 && defined( $self->adaptor() ) )
1460 $self->{
'_trans_exon_array'} =
1461 $self->adaptor()->db()->get_ExonAdaptor()
1462 ->fetch_all_by_Transcript($self);
1466 if ( defined($constitutive) && $constitutive != 0 ) {
1467 foreach my $exon ( @{ $self->{
'_trans_exon_array'} } ) {
1468 if ( $exon->is_constitutive() ) {
1469 push( @result, $exon );
1473 @result = @{ $self->{
'_trans_exon_array'} };
1477 } ## end sub get_all_Exons
1480 =head2 get_all_ExonTranscripts
1482 Example : my @exon_transcripts = @{ $transcript->get_all_ExonTranscripts() };
1484 Description: Returns an listref of the exons in
this transcript
1485 in order, i.e. the first
exon in the listref is the
1495 sub get_all_ExonTranscripts {
1496 my ( $self, @args ) = @_;
1498 if (!defined( $self->{
'_trans_exon_array'} )
1499 && defined( $self->adaptor() ) )
1501 $self->{
'_trans_exon_array'} =
1502 $self->
adaptor()->
db()->get_ExonAdaptor()
1503 ->fetch_all_by_Transcript($self);
1508 foreach my $exon ( @{ $self->{
'_trans_exon_array'} } ) {
1513 -TRANSCRIPT => $self
1515 push (@result, $exon_transcript) ;
1519 } ## end sub get_all_ExonTranscripts
1521 =head2 get_all_constitutive_Exons
1525 Example : my @exons = @{ $transcript->get_all_constitutive_Exons() };
1527 Description: Returns an listref of the constitutive exons in
this
1538 sub get_all_constitutive_Exons {
1540 return $self->get_all_Exons(
'-constitutive' => 1 );
1543 =head2 get_all_IntronSupportingEvidence
1545 Example : $ise->get_all_IntronSupportingEvidence();
1546 Description : Fetches all ISE instances linked to
this Transript
1547 Returntype : ArrayRef[Bio::EnsEMBL::IntronSupportEvidence] retrieved from
1548 the DB or from those added via C<add_IntronSupportingEvidence>
1553 sub get_all_IntronSupportingEvidence {
1555 if(! defined $self->{_ise_array} && defined $self->adaptor()) {
1556 my $isea = $self->
adaptor()->
db()->get_IntronSupportingEvidenceAdaptor();
1557 $self->{_ise_array} = $isea->fetch_all_by_Transcript($self);
1559 return $self->{_ise_array} || [];
1563 =head2 add_IntronSupportingEvidence
1565 Arg [1] : Bio::EnsEMBL::IntronSupportEvidence Object to add
1566 Example : $ise->add_IntronSupportingEvidence($ise);
1567 Description : Adds the IntronSupportEvidence instance to
this Transcript. The
1568 code checks to see
if it is a unique ISE instance
1569 Returntype : Boolean;
true means it was added. False means it was not
1570 as
this ISE was already attached
1575 sub add_IntronSupportingEvidence {
1576 my ($self, $ise) = @_;
1577 assert_ref($ise,
'Bio::EnsEMBL::IntronSupportingEvidence',
'IntronSupportingEvidence');
1579 foreach my $other_ise (@{$self->{_ise_array}}) {
1580 if($ise->equals($other_ise)) {
1586 push(@{$self->{_ise_array}}, $ise);
1592 =head2 get_all_Introns
1595 Example : my @introns = @{$transcript->get_all_Introns()};
1596 Description: Returns an listref of the introns in
this transcript in order.
1597 i.e. the first intron in the listref is the 5prime most
exon in
1606 sub get_all_Introns {
1608 if( ! defined $self->{
'_trans_exon_array'} && defined $self->adaptor() ) {
1609 $self->{
'_trans_exon_array'} = $self->
adaptor()->
db()->
1610 get_ExonAdaptor()->fetch_all_by_Transcript( $self );
1614 my @exons = @{$self->{
'_trans_exon_array'}};
1615 for(my $i=0; $i < scalar(@exons)-1; $i++){
1617 push(@introns, $intron)
1622 =head2 get_all_CDS_Introns
1625 Example : my @introns = @{$transcript->get_all_CDS_Introns()};
1626 Description: Returns an listref of the introns between coding exons in
this transcript in order.
1634 sub get_all_CDS_Introns {
1636 # return an empty list if there is no translation
1637 my $translation = $self->translation or
return [];
1638 if( ! defined $self->{
'_trans_exon_array'} && defined $self->adaptor() ) {
1639 $self->{
'_trans_exon_array'} = $self->
adaptor()->
db()->
1640 get_ExonAdaptor()->fetch_all_by_Transcript( $self );
1644 my @exons = @{$self->{
'_trans_exon_array'}};
1645 for(my $i=0; $i < scalar(@exons)-1; $i++){
1646 if (!$exons[$i]->is_coding($self)) { next; }
1648 push(@introns, $intron)
1657 Example : my $t_length = $transcript->length
1658 Description: Returns the sum of the length of all the exons in the
transcript.
1670 foreach my $ex (@{$self->get_all_Exons}) {
1671 $length += $ex->length;
1674 # adjust the length if post transcriptional edits are enabled
1675 if($self->edits_enabled()) {
1676 foreach my $se (@{$self->get_all_SeqEdits()}) {
1677 $length += $se->length_diff();
1688 Example : $transcript->flush_Exons();
1689 Description: Removes all Exons from
this transcript and flushes related
1701 $self->{
'transcript_mapper'} = undef;
1702 $self->{
'coding_region_start'} = undef;
1703 $self->{
'coding_region_end'} = undef;
1704 $self->{
'cdna_coding_start'} = undef;
1705 $self->{
'cdna_coding_end'} = undef;
1706 $self->{
'start'} = undef;
1707 $self->{
'end'} = undef;
1708 $self->{
'strand'} = undef;
1710 $self->{
'_trans_exon_array'} = [];
1713 =head2 flush_IntronSupportingEvidence
1715 Example : $transcript->flush_IntronSupportingEvidence();
1716 Description: Removes all IntronSupportingEvidence from
this transcript
1724 sub flush_IntronSupportingEvidence {
1726 $self->{_ise_array} = [];
1730 =head2 five_prime_utr
1733 Example : my $five_prime = $transcrpt->five_prime_utr
1734 or warn
"No five prime UTR";
1735 Description: Obtains a Bio::Seq
object of the five prime UTR of
this
1737 (i.e. non-translating) or has no five prime UTR undef is
1739 Returntype : Bio::Seq or undef
1746 sub five_prime_utr {
1749 my $cdna_coding_start = $self->cdna_coding_start();
1751 return undef
if(!$cdna_coding_start);
1753 my $seq = substr($self->spliced_seq, 0, $cdna_coding_start - 1);
1755 return undef
if(!$seq);
1758 Bio::Seq->new( -
id => $self->display_id,
1765 =head2 three_prime_utr
1768 Example : my $three_prime = $transcrpt->three_prime_utr
1769 or warn
"No three prime UTR";
1770 Description: Obtains a Bio::Seq
object of the three prime UTR of
this
1772 (i.e. non-translating) or has no three prime UTR,
1773 undef is returned instead.
1774 Returntype : Bio::Seq or undef
1781 sub three_prime_utr {
1784 my $cdna_coding_end = $self->cdna_coding_end();
1786 return undef
if(!$cdna_coding_end);
1788 my $seq = substr($self->spliced_seq, $cdna_coding_end);
1790 return undef
if(!$seq);
1793 Bio::Seq->new( -
id => $self->display_id,
1799 =head2 five_prime_utr_Feature
1801 Example : my $five_prime = $transcrpt->five_prime_utr_Feature
1802 or warn
"No five prime UTR";
1803 Description: Returns the genomic coordinates of the start and end of the
1804 5
' UTR of this transcript. Note that if you want the sequence
1805 of the 5' UTR use C<five_prime_utr> as
this will
return the
1812 sub five_prime_utr_Feature {
1816 my $features = $self->get_all_five_prime_UTRs();
1817 if (scalar(@$features) == 0) {
return; }
1818 foreach my $feature (@$features) {
1819 if ($feature->start() < $start) {
1820 $start = $feature->start();
1822 if ($feature->end() > $end) {
1823 $end = $feature->end();
1829 -STRAND => $self->strand(),
1830 -SLICE => $self->slice(),
1831 -TYPE =>
'five_prime_UTR',
1832 -TRANSCRIPT => $self
1839 =head2 three_prime_utr_Feature
1841 Example : my $five_prime = $transcrpt->three_prime_utr_Feature
1842 or warn
"No three prime UTR";
1843 Description: Returns the genomic coordinates of the start and end of the
1844 3
' UTR of this transcript. Note that if you want the sequence
1845 of the 3' UTR use C<three_prime_utr> as
this will
return the
1852 sub three_prime_utr_Feature {
1856 my $features = $self->get_all_three_prime_UTRs();
1857 if (scalar(@$features) == 0) {
return; }
1858 foreach my $feature (@$features) {
1859 if ($feature->start() < $start) {
1860 $start = $feature->start();
1862 if ($feature->end() > $end) {
1863 $end = $feature->end();
1869 -STRAND => $self->strand(),
1870 -SLICE => $self->slice(),
1871 -TYPE =>
'three_prime_UTR',
1872 -TRANSCRIPT => $self
1878 =head2 get_all_five_prime_UTRs
1880 Example : my $five_primes = $transcript->get_all_five_prime_UTRs
1881 Description: Returns a list of features forming the 5
' UTR of this transcript.
1882 Returntype : listref of Bio::EnsEMBL::UTR
1887 sub get_all_five_prime_UTRs {
1889 my $translation = $self->translation();
1890 return [] if ! $translation;
1894 my $cdna_coding_start = $self->cdna_coding_start();
1896 # if it is greater than 1 then it must have UTR
1897 if($cdna_coding_start > 1) {
1898 my @projections = $self->cdna2genomic(1, ($cdna_coding_start-1));
1899 foreach my $projection (@projections) {
1901 my $utr = Bio::EnsEMBL::UTR->new(
1902 -START => $projection->start - $self->slice->start + 1,
1903 -END => $projection->end - $self->slice->start + 1,
1904 -SEQ_REGION_START => $projection->start,
1905 -SEQ_REGION_END => $projection->end,
1906 -STRAND => $projection->strand,
1907 -SLICE => $self->slice,
1908 -TRANSCRIPT => $self,
1909 -TYPE => 'five_prime_utr
'
1919 =head2 get_all_three_prime_UTRs
1921 Example : my $three_primes = $transcript->get_all_three_prime_UTRs
1922 Description: Returns a list of features forming the 3' UTR of
this transcript.
1928 sub get_all_three_prime_UTRs {
1931 return []
if ! $translation;
1935 my $cdna_coding_end = $self->cdna_coding_end();
1936 if($cdna_coding_end < $self->length()) {
1937 my @projections = $self->cdna2genomic(($cdna_coding_end+1), $self->length());
1938 foreach my $projection (@projections) {
1939 next
if $projection->isa(
'Bio::EnsEMBL::Mapper::Gap');
1941 -START => $projection->start - $self->slice->start + 1,
1942 -END => $projection->end - $self->slice->start + 1,
1943 -SEQ_REGION_START => $projection->start,
1944 -SEQ_REGION_END => $projection->end,
1945 -STRAND => $projection->strand,
1946 -SLICE => $self->slice,
1947 -TRANSCRIPT => $self,
1948 -TYPE =>
'three_prime_utr'
1959 Example : my $cds = $transcript->get_all_CDS
1960 Description: Returns a list of features forming the coding regions of the
transcript
1969 return []
if ! $translation;
1972 my $translation_id = $translation->
stable_id();
1974 foreach my $exon (@{ $self->get_all_translateable_Exons}) {
1975 my $phase = $exon->phase();
1976 $phase = 0
if $phase < 0;
1977 $phase =~ tr/12/21/;
1980 -START => $exon->start,
1982 -STRAND => $exon->strand,
1983 -SEQ_REGION_START => $exon->seq_region_start,
1984 -SEQ_REGION_END => $exon->seq_region_end,
1985 -TRANSLATION_ID => $translation_id,
1986 -SLICE => $self->slice,
1987 -TRANSCRIPT => $self,
1998 =head2 get_all_translateable_Exons
2001 Description: Returns a list of exons that translate with the
2002 start and end exons truncated to the CDS regions.
2003 This
function does not take into account any SeqEdits
2004 (post transcriptional RNA modifictions) when constructing the
2005 the
'translateable' exons, and it does not update the phase
2006 information of the created
'translateable' exons.
2008 If
this transcript is a pseudogene (i.e. non-translateable)
2009 a reference to an empty list is returned.
2012 Exceptions :
throw if translation has invalid information
2019 sub get_all_translateable_Exons {
2022 #return an empty list if there is no translation (i.e. pseudogene)
2023 my $translation = $self->translation or
return [];
2024 my $start_exon = $translation->start_Exon;
2025 my $end_exon = $translation->end_Exon;
2026 my $t_start = $translation->
start;
2027 my $t_end = $translation->end;
2029 my( @translateable );
2031 foreach my $ex (@{$self->get_all_Exons}) {
2033 if ($ex ne $start_exon and ! @translateable) {
2034 next; # Not yet in translated region
2037 my $length = $ex->length;
2039 my $adjust_start = 0;
2041 # Adjust to translation start if this is the start exon
2042 if ($ex == $start_exon ) {
2043 if ($t_start < 1 or $t_start > $length) {
2044 warning(
"WARN: Translation start '$t_start' is outside exon " . $ex->display_id .
" length=$length");
2047 $adjust_start = $t_start - 1;
2050 # Adjust to translation end if this is the end exon
2051 if ($ex == $end_exon) {
2052 # if ($t_end < 1 or $t_end > $length) {
2053 # throw("Translation end '$t_end' is outside exon $ex length=$length");
2055 $adjust_end = $t_end - $length;
2058 # Make a truncated exon if the translation start or
2059 # end causes the coordinates to be altered.
2060 if ($adjust_end || $adjust_start) {
2061 my $newex = $ex->adjust_start_end( $adjust_start, $adjust_end );
2063 push( @translateable, $newex );
2065 push(@translateable, $ex);
2068 # Exit the loop when we've found the last exon
2069 last
if $ex eq $end_exon;
2071 return \@translateable;
2077 Arg [1] : Boolean, emulate the behavior of old bioperl versions where
2078 an incomplete
final codon of 2 characters is padded and guessed
2080 Description: Return the peptide (plus eventual stop codon)
for
2082 matching exons. It uses translateable_seq
2083 internally. Returns undef
if this Transcript does
2084 not have a translation (i.e. pseudogene).
2085 Returntype : Bio::Seq or undef
2093 my ($self, $complete_codon) = @_;
2096 if ( !defined( $self->translation() ) ) {
return undef }
2098 # Alternative codon tables (such as the mitochondrial codon table)
2099 # can be specified for a sequence region via the seq_region_attrib
2100 # table. A list of codon tables and their codes is at:
2101 # http://www.ncbi.nlm.nih.gov/Taxonomy/Utils/wprintgc.cgi
2103 if ( defined( $self->slice() ) ) {
2106 ($attrib) = @{ $self->slice()->get_all_Attributes(
'codon_table') };
2107 if ( defined($attrib) ) {
2108 $codon_table_id = $attrib->value();
2112 $codon_table_id ||= 1; #
default vertebrate codon table
2114 Bio::Tools::CodonTable->new( -
id => $codon_table_id );
2116 my $mrna = $self->translateable_seq();
2118 my $delta = CORE::length($mrna) % 3;
2120 # If we have a partial codon of we need to decide if we
2121 # trim it or not to fix some bad behaviour in older bioperl
2123 if ( $complete_codon ) {
2124 # If we want to do the bad behavior of bioperl 1.6.1 and older
2125 # where we guess the last codon if incomplete, pad an N
2126 # to the mrna sequence
2127 $mrna .=
'N' x (3 - $delta);
2129 # Otherwise trim those last bp's off so the behavior is
2130 # consistent across bioperl versions
2131 chop $mrna
for 1 .. $delta;
2135 if ( CORE::length($mrna) < 1 ) {
return undef }
2137 my $first_mrna_codon = substr( $mrna, 0, 3 );
2138 my $last_mrna_codon = substr( $mrna, -3, 3 );
2140 my $display_id = $self->translation->display_id()
2141 ||
"" . $self->translation();
2143 # From BioPerl perspective, we'll treat our CDS as incomplete:
2144 # thus, BioPerl will not
2145 # - remove the terminator character from the peptide
2146 # - check if there are terminator character inside the peptide
2147 # - turn the first amino acid into 'M', if the first codon is a
2149 # NOTE: We will not be checking for in-sequence '*', as we have to
2150 # apply the seq_edits after translation occurs
2152 my $p_seq = $codon_table->translate($mrna, 0);
2154 # Remove final stop codon from the mrna if it is present. Produced
2155 # peptides will not have '*' at end. If terminal stop codon is
2156 # desired call translatable_seq directly and produce a translation
2158 if ( $codon_table->is_ter_codon( $last_mrna_codon ) ) {
2162 # Update the first amino acid to M, as appropriate
2163 if ( substr($p_seq,0,1) ne
'M' && $codon_table->is_start_codon( $first_mrna_codon ) ) {
2164 $p_seq =
'M' . substr($p_seq,1);
2167 my $translation = Bio::Seq->new( -seq => $p_seq,
2168 -alphabet =>
'protein',
2169 -
id => $display_id );
2171 if ( $self->edits_enabled() ) {
2172 $self->translation()->modify_translation($translation);
2175 return $translation;
2176 } ## end sub translate
2181 Description: Returns a Bio::Seq
object which consists of just
2182 : the sequence of the exons concatenated together,
2183 : without messing
about with padding with N\
's from
2184 : Exon phases like B<dna_seq> does.
2187 Returntype : Bio::Seq
2198 Bio::Seq->new( -id => $self->display_id,
2201 -seq => $self->spliced_seq );
2207 Description: See Bio::EnsEMBL::TranscriptMapper::pep2genomic
2213 return $self->get_TranscriptMapper()->pep2genomic(@_);
2219 Description: See Bio::EnsEMBL::TranscriptMapper::genomic2pep
2225 return $self->get_TranscriptMapper()->genomic2pep(@_);
2231 Description: See Bio::EnsEMBL::TranscriptMapper::cdna2genomic
2237 return $self->get_TranscriptMapper()->cdna2genomic(@_);
2243 Description: See Bio::EnsEMBL::TranscriptMapper::genomic2cdna
2249 return $self->get_TranscriptMapper->genomic2cdna(@_);
2253 =head2 get_TranscriptMapper
2256 Example : my $trans_mapper = $transcript->get_TranscriptMapper();
2257 Description: Gets a TranscriptMapper object which can be used to perform
2258 a variety of coordinate conversions relating this transcript,
2259 genomic sequence and peptide resulting from this transcripts
2261 Returntype : Bio::EnsEMBL::TranscriptMapper
2263 Caller : cdna2genomic, pep2genomic, genomic2cdna, cdna2genomic
2268 sub get_TranscriptMapper {
2270 return $self->{'transcript_mapper
'} ||=
2271 Bio::EnsEMBL::TranscriptMapper->new($self);
2278 Usage : $start_exon = $transcript->start_Exon;
2279 Returntype : Bio::EnsEMBL::Exon
2280 Description : The first exon in the transcript.
2288 return $self->get_all_Exons()->[0];
2295 Usage : $end_exon = $transcript->end_Exon;
2296 Description : The last exon in the transcript.
2297 Returntype : Bio::EnsEMBL::Exon
2305 return $self->get_all_Exons()->[-1];
2312 Usage : $obj->description($newval)
2315 Args : newvalue (optional)
2322 $self->{'description
'} = shift if( @_ );
2323 return $self->{'description
'};
2330 Usage : $obj->version()
2340 $self->{'version
'} = shift if( @_ );
2341 return $self->{'version
'};
2347 Usage : $obj->stable_id
2357 $self->{'stable_id
'} = shift if( @_ );
2358 return $self->{'stable_id
'};
2361 =head2 stable_id_version
2363 Arg [1] : (optional) String - the stable ID with version to set
2364 Example : $transcript->stable_id("ENST0000000001.3");
2365 Description: Getter/setter for stable id with version for this transcript.
2373 sub stable_id_version {
2375 if(my $stable_id = shift) {
2376 # See if there's an embedded period, assume that
's a
2377 # version, might not work for some species but you
2378 # should use ->stable_id() and version() if you're worried
2380 my $vindex = rindex($stable_id,
'.');
2381 # Set the stable_id and version pair depending on if
2382 # we found a version delimiter in the stable_id
2383 ($self->{stable_id}, $self->{version}) = ($vindex > 0 ?
2384 (substr($stable_id,0,$vindex), substr($stable_id,$vindex+1)) :
2387 return $self->{stable_id} . ($self->{version} ?
".$self->{version}" :
'');
2392 Arg [1] : Boolean $is_current
2393 Example : $transcript->is_current(1)
2394 Description: Getter/setter
for is_current state of
this transcript.
2404 $self->{
'is_current'} = shift
if (@_);
2405 return $self->{
'is_current'};
2411 Arg [1] : (optional)
string to be used
for the created date
2413 Description: get/set
for attribute created date
2423 $self->{
'created_date'} = shift
if ( @_ );
2424 return $self->{
'created_date'};
2428 =head2 modified_date
2430 Arg [1] : (optional)
string to be used
for the modified date
2432 Description: get/set
for attribute modified date
2442 $self->{
'modified_date'} = shift
if ( @_ );
2443 return $self->{
'modified_date'};
2450 An
exon that should be replaced
2452 The replacement Exon
2454 Description: exchange an
exon in the current Exon list with a given one.
2455 Usually done before storing of Gene, so the Exons can
2456 be shared between Transcripts.
2459 Caller : GeneAdaptor->store()
2465 my ( $self, $old_exon, $new_exon, $skip_exon_sf) = @_;
2467 my $arref = $self->{
'_trans_exon_array'};
2468 for(my $i = 0; $i < @$arref; $i++) {
2469 if($arref->[$i] == $old_exon ) {
2470 $new_exon->add_supporting_features(@{$old_exon->get_all_supporting_features}) unless $skip_exon_sf;
2471 $arref->[$i] = $new_exon;
2476 if( defined $self->{
'translation'} ) {
2477 if( $self->translation()->start_Exon() == $old_exon ) {
2478 $self->translation()->start_Exon( $new_exon );
2480 if( $self->translation()->end_Exon() == $old_exon ) {
2481 $self->translation()->end_Exon( $new_exon );
2490 Example : $rank = $transcript->exon_rank($exon);
2491 Description: Returns the rank of an
exon relative to the
transcript
2493 Exceptions : Throws
if the
exon does not belong to the
transcript
2500 my ( $self, $exon ) = @_;
2502 if (!defined( $self->{
'_trans_exon_array'} )
2503 && defined( $self->adaptor() ) )
2505 $self->{
'_trans_exon_array'} =
2506 $self->adaptor()->db()->get_ExonAdaptor()
2507 ->fetch_all_by_Transcript($self);
2510 my $arref = $self->{
'_trans_exon_array'};
2513 if (!defined $arref) {
2514 throw "Transcript does not have any exons";
2516 for(my $i = 0; $i < @$arref; $i++) {
2517 if($arref->[$i]->stable_id() eq $exon->stable_id()) {
2523 if (!defined $rank) {
2524 throw "Exon does not belong to transcript";
2534 Example :
if ($transcriptA->equals($transcriptB)) { ... }
2535 Description : Compares two transcripts
for equality.
2536 The test
for eqality goes through the following list
2537 and terminates at the first
true match:
2540 then the transcripts are *not* equal.
2541 2. If the biotypes differ, then the transcripts are
2543 3. If both transcripts have stable IDs: if these are
2544 the same, the transcripts are equal, otherwise not.
2545 4. If both transcripts have the same number of exons
2546 and if these are (when compared pair-wise sorted by
2547 start-position and length) the same, then they are
2548 equal, otherwise not.
2550 Return type : Boolean (0, 1)
2552 Exceptions : Thrown if a non-
transcript is passed as the argument.
2557 my ( $self, $transcript ) = @_;
2559 if ( !defined($transcript) ) {
return 0 }
2560 if ( $self eq $transcript ) {
return 1 }
2562 assert_ref( $transcript,
'Bio::EnsEMBL::Transcript' );
2564 my $feature_equals = $self->SUPER::equals($transcript);
2565 if ( defined($feature_equals) && $feature_equals == 0 ) {
2569 if ( $self->get_Biotype->name ne $transcript->get_Biotype->name ) {
2573 if ( defined( $self->stable_id() ) &&
2574 defined( $transcript->stable_id() ) )
2576 if ( $self->stable_id() eq $transcript->stable_id() ) {
2584 my @self_exons = sort {
2585 $a->start() <=> $b->start() ||
2586 $a->length() <=> $b->length()
2587 } @{ $self->get_all_Exons() };
2588 my @transcript_exons = sort {
2589 $a->start() <=> $b->start() ||
2590 $a->length() <=> $b->length()
2591 } @{ $transcript->get_all_Exons() };
2593 if ( scalar(@self_exons) != scalar(@transcript_exons) ) {
2597 while (@self_exons) {
2598 my $self_exon = shift(@self_exons);
2599 my $transcript_exon = shift(@transcript_exons);
2601 if ( !$self_exon->equals($transcript_exon) ) {
2611 Arg 1 : String $coordinate_system_name
2612 Arg [2] : String $coordinate_system_version
2613 Example : $transcript = $transcript->transform(
'contig');
2614 $transcript = $transcript->transform(
'chromosome',
'NCBI33');
2615 Description: Moves
this Transcript to the given coordinate system.
2616 If
this Transcript has Exons attached, they move as well.
2617 A
new Transcript is returned. If the
transcript cannot be
2618 transformed to the destination coordinate system undef is
2621 Exceptions : wrong parameters
2623 Status : Medium Risk
2624 : deprecation needs to be removed at some time
2632 my $new_transcript = $self->SUPER::transform(@_);
2633 if ( !defined($new_transcript) ) {
2634 my @segments = @{ $self->
project(@_) };
2635 # if it projects, maybe the exons transform well?
2636 # lazy load them here
2640 $self->get_all_Exons();
2644 if( exists $self->{
'_trans_exon_array'} ) {
2646 my ( $low_start, $hi_end, $slice );
2647 # we want to check whether the transform preserved 5prime 3prime
2648 # ordering. This assumes 5->3 order. No complaints on transsplicing.
2650 my ( $last_new_start, $last_old_strand,
2651 $last_new_strand, $start_exon, $end_exon,
2652 $last_seq_region_name );
2654 my $ignore_order = 0;
2655 my $order_broken = 0;
2657 for my $old_exon ( @{$self->{
'_trans_exon_array'}} ) {
2658 my $new_exon = $old_exon->transform( @_ );
2659 return undef
if( !defined $new_exon );
2660 if( ! defined $new_transcript ) {
2662 if( $old_exon->strand() != $last_old_strand ) {
2663 # transsplicing, ignore ordering
2667 if( $new_exon->slice()->seq_region_name() ne
2668 $last_seq_region_name ) {
2672 if( $last_new_strand == 1 and
2673 $new_exon->start() < $last_new_start ) {
2677 if( $last_new_strand == -1 and
2678 $new_exon->start() > $last_new_start ) {
2682 #additional check that if exons were on same strand previously, they should be again
2683 if(($last_old_strand == $old_exon->strand()) and !($last_new_strand == $new_exon->strand())){
2687 if( $new_exon->start() < $low_start ) {
2688 $low_start = $new_exon->start();
2690 if( $new_exon->end() > $hi_end ) {
2691 $hi_end = $new_exon->end();
2695 $low_start = $new_exon->start();
2696 $hi_end = $new_exon->end();
2699 $last_seq_region_name = $new_exon->slice()->seq_region_name();
2700 $last_old_strand = $old_exon->strand();
2701 $last_new_start = $new_exon->start();
2702 $last_new_strand = $new_exon->strand();
2705 if( defined $self->{
'translation'} ) {
2706 if( $self->translation()->start_Exon() == $old_exon ) {
2707 $start_exon = $new_exon;
2709 if( $self->translation()->end_Exon() == $old_exon ) {
2710 $end_exon = $new_exon;
2713 push( @new_exons, $new_exon );
2716 if( $order_broken && !$ignore_order ) {
2717 warning(
"Order of exons broken in transform of ".$self->dbID() );
2721 if( !defined $new_transcript ) {
2722 %$new_transcript = %$self;
2723 bless $new_transcript, ref( $self );
2724 $new_transcript->start( $low_start );
2725 $new_transcript->end( $hi_end );
2726 $new_transcript->slice( $new_exons[0]->slice() );
2727 $new_transcript->strand( $new_exons[0]->strand() );
2730 $new_transcript->{
'_trans_exon_array'} = \@new_exons;
2732 # should be ok to do inside exon array loop
2733 # translations only exist together with the exons ...
2735 if( defined $self->{
'translation'} ) {
2736 my $new_translation;
2737 %$new_translation = %{$self->{
'translation'}};;
2738 bless $new_translation, ref( $self->{
'translation'} );
2739 $new_transcript->{
'translation'} = $new_translation;
2740 $new_translation->start_Exon( $start_exon );
2741 $new_translation->end_Exon( $end_exon );
2745 if( exists $self->{
'_supporting_evidence'} ) {
2747 for my $old_feature ( @{$self->{
'_supporting_evidence'}} ) {
2748 my $new_feature = $old_feature->transform( @_ );
2749 if (defined $new_feature) {
2750 push @new_features, $new_feature;
2753 $new_transcript->{
'_supporting_evidence'} = \@new_features;
2756 if(exists $self->{_ise_array}) {
2758 foreach my $old_feature ( @{$self->{_ise_array}} ) {
2759 my $new_feature = $old_feature->transform(@_);
2760 push( @new_features, $new_feature );
2762 $new_transcript->{_ise_array} = \@new_features;
2765 if(exists $self->{attributes}) {
2766 $new_transcript->{attributes} = [@{$self->{attributes}}];
2769 # flush cached internal values that depend on the exon coords
2770 $new_transcript->{
'transcript_mapper'} = undef;
2771 $new_transcript->{
'coding_region_start'} = undef;
2772 $new_transcript->{
'coding_region_end'} = undef;
2773 $new_transcript->{
'cdna_coding_start'} = undef;
2774 $new_transcript->{
'cdna_coding_end'} = undef;
2776 return $new_transcript;
2783 Example : $transcript = $transcript->transfer($slice);
2784 Description: Moves
this transcript to the given slice.
2785 If
this Transcripts has Exons attached, they move as well.
2797 my $new_transcript = $self->SUPER::transfer( @_ );
2798 return undef unless $new_transcript;
2800 if( defined $self->{
'translation'} ) {
2801 my $new_translation;
2802 %$new_translation = %{$self->{
'translation'}};;
2803 bless $new_translation, ref( $self->{
'translation'} );
2804 $new_transcript->{
'translation'} = $new_translation;
2807 if( exists $self->{
'_trans_exon_array'} ) {
2809 for my $old_exon ( @{$self->{
'_trans_exon_array'}} ) {
2810 my $new_exon = $old_exon->
transfer( @_ );
2811 if( defined $new_transcript->{
'translation'} ) {
2812 if( $new_transcript->translation()->start_Exon() == $old_exon ) {
2815 if( $new_transcript->translation()->end_Exon() == $old_exon ) {
2816 $new_transcript->translation()->end_Exon( $new_exon );
2819 push( @new_exons, $new_exon );
2822 $new_transcript->{
'_trans_exon_array'} = \@new_exons;
2825 if( exists $self->{
'_supporting_evidence'} ) {
2827 for my $old_feature ( @{$self->{
'_supporting_evidence'}} ) {
2828 my $new_feature = $old_feature->transfer( @_ );
2829 push( @new_features, $new_feature );
2831 $new_transcript->{
'_supporting_evidence'} = \@new_features;
2834 if(exists $self->{_ise_array}) {
2836 foreach my $old_feature ( @{$self->{_ise_array}} ) {
2837 my $new_feature = $old_feature->transfer(@_);
2838 push( @new_features, $new_feature );
2840 $new_transcript->{_ise_array} = \@new_features;
2843 if(exists $self->{attributes}) {
2844 $new_transcript->{attributes} = [@{$self->{attributes}}];
2847 # flush cached internal values that depend on the exon coords
2848 $new_transcript->{
'transcript_mapper'} = undef;
2849 $new_transcript->{
'coding_region_start'} = undef;
2850 $new_transcript->{
'coding_region_end'} = undef;
2851 $new_transcript->{
'cdna_coding_start'} = undef;
2852 $new_transcript->{
'cdna_coding_end'} = undef;
2854 return $new_transcript;
2858 =head2 recalculate_coordinates
2862 Description: called when
exon coordinate change happened to recalculate the
2863 coords of the
transcript. This method should be called
if one
2864 of the exons has been changed.
2872 sub recalculate_coordinates {
2875 my $exons = $self->get_all_Exons();
2877 if ( !$exons || !@{$exons} ) {
return }
2879 my ( $slice, $start, $end, $strand );
2882 for ( $e_index = 0; $e_index < @{$exons}; $e_index++ ) {
2883 my $e = $exons->[$e_index];
2885 # Skip missing or unmapped exons!
2886 if ( defined($e) && defined( $e->start() ) ) {
2887 $slice = $e->slice();
2888 $strand = $e->strand();
2889 $start = $e->start();
2896 my $transsplicing = 0;
2898 # Start loop after first exon with coordinates
2899 for ( ; $e_index < @{$exons}; $e_index++ ) {
2900 my $e = $exons->[$e_index];
2902 # Skip missing or unmapped exons!
2903 if ( !defined($e) || !defined( $e->start() ) ) { next }
2905 if ( $e->start() < $start ) {
2906 $start = $e->start();
2909 if ( $e->end() > $end ) {
2913 if ( defined($slice)
2915 && $e->slice()->name() ne $slice->name() )
2917 throw(
"Exons with different slices "
2918 .
"are not allowed on one Transcript" );
2921 if ( $e->strand() != $strand ) {
2924 } ## end
for ( ; $e_index < @{$exons...})
2925 if ($transsplicing) {
2926 warning(
"Transcript contained trans splicing event");
2929 $self->start($start);
2931 $self->strand($strand);
2932 $self->slice($slice);
2934 # flush cached internal values that depend on the exon coords
2935 $self->{
'transcript_mapper'} = undef;
2936 $self->{
'coding_region_start'} = undef;
2937 $self->{
'coding_region_end'} = undef;
2938 $self->{
'cdna_coding_start'} = undef;
2939 $self->{
'cdna_coding_end'} = undef;
2940 } ## end sub recalculate_coordinates
2946 Example : print $transcript->display_id();
2947 Description: This method returns a
string that is considered to be
2948 the
'display' identifier. For transcripts
this is (depending on
2949 availability and in
this order) the stable Id, the dbID or an
2953 Caller : web drawing code
2960 return $self->{
'stable_id'} || $self->dbID ||
'';
2964 =head2 get_all_DASFactories
2967 Function : Retrieves a listref of registered DAS objects
2968 Returntype: [ DAS_objects ]
2971 Example : $dasref = $prot->get_all_DASFactories
2976 sub get_all_DASFactories {
2978 return [ $self->adaptor()->db()->_each_DASFeatureFactory ];
2982 =head2 get_all_DAS_Features
2985 Example : $features = $prot->get_all_DAS_Features;
2986 Description: Retrieves a hash reference to a hash of DAS feature
2987 sets, keyed by the DNS, NOTE the values of
this hash
2988 are an anonymous array containing:
2989 (1) a pointer to an array of features;
2990 (2) a pointer to the DAS stylesheet
2991 Returntype : hashref of Bio::SeqFeatures
2999 sub get_all_DAS_Features {
3000 my ($self,@args) = @_;
3002 my $db = $self->adaptor->db;
3003 my $GeneAdaptor = $db->get_GeneAdaptor;
3004 my $Gene = $GeneAdaptor->fetch_by_transcript_stable_id($self->stable_id);
3005 my $slice = $Gene->feature_Slice;
3006 return $self->SUPER::get_all_DAS_Features($slice);
3010 =head2 get_all_RNAProducts
3012 Arg [1] : optional
string $type_code type of rnaproducts to retrieve
3013 Example : @transc_mirnas = @{$transcript->get_all_RNAProducts(
'miRNA')};
3014 @transc_rnaproducts = @{$transcript->get_all_RNAProducts()};
3015 Description: Gets a list of RNAProducts of
this transcript.
3016 Optionally just get RNAProducts
for given type code.
3020 Status : In Development
3024 sub get_all_RNAProducts {
3025 my ($self, $type_code) = @_;
3027 if (!exists $self->{
'rnaproducts'}) {
3028 if (!$self->adaptor()) {
3032 my $rnaproduct_adaptor = $self->
adaptor->
db->get_RNAProductAdaptor();
3033 $self->{
'rnaproducts'} = $rnaproduct_adaptor->fetch_all_by_Transcript($self);
3036 if (defined $type_code) {
3037 my @results = grep { $_->type_code() eq $type_code } @{$self->{
'rnaproducts'}};
3040 return $self->{
'rnaproducts'};
3046 =head2 _compare_xrefs
3048 Description:
compare xrefs based on priority (descending), then
3049 name (ascending), then display_label (ascending)
3053 sub _compare_xrefs {
3054 # compare on priority first (descending)
3055 if ( $a->priority() != $b->priority() ) {
3056 return $b->priority() <=> $a->priority();
3058 # equal priorities, compare on external_db name
3059 if ( $a->dbname() ne $b->dbname() ) {
3060 return $a->dbname() cmp $b->dbname();
3062 # equal priorities and names, compare on display_label
3063 return $a->display_id() cmp $b->display_id();
3071 Arg [1] : Boolean $load_xrefs
3072 Load (or don
't load) xrefs. Default is to load xrefs.
3073 Example : $transcript->load();
3074 Description : The Ensembl API makes extensive use of
3075 lazy-loading. Under some circumstances (e.g.,
3076 when copying genes between databases), all data of
3077 an object needs to be fully loaded. This method
3078 loads the parts of the object that are usually
3079 lazy-loaded. It will also call the equivalent
3080 method on any translation and on all exons of the
3087 my ( $self, $load_xrefs ) = @_;
3089 if ( !defined($load_xrefs) ) { $load_xrefs = 1 }
3091 my $translation = $self->translation();
3092 if ( defined($translation) ) {
3093 $translation->load($load_xrefs);
3095 my $alt_translations = $self->get_all_alternative_translations();
3097 if ( defined($alt_translations) ) {
3098 foreach my $alt_translation ( @{$alt_translations} ) {
3099 $alt_translation->load($load_xrefs);
3104 foreach my $exon ( @{ $self->get_all_Exons() } ) {
3110 $self->get_all_Attributes();
3111 $self->get_all_supporting_features();
3112 $self->get_all_IntronSupportingEvidence();
3115 $self->get_all_DBEntries();
3120 =head2 summary_as_hash
3122 Example : $transcript_summary = $transcript->summary_as_hash();
3123 Description : Extends Feature::summary_as_hash
3124 Retrieves a summary of this Transcript.
3125 Returns : hashref of descriptive strings
3126 Status : Intended for internal use
3129 sub summary_as_hash {
3131 my $summary_ref = $self->SUPER::summary_as_hash;
3132 $summary_ref->{'description
'} = $self->description;
3133 $summary_ref->{'Name
'} = $self->external_name if $self->external_name;
3134 $summary_ref->{'biotype
'} = $self->get_Biotype->name;
3135 $summary_ref->{'logic_name
'} = $self->analysis->logic_name() if defined $self->analysis();
3136 my $parent_gene = $self->get_Gene();
3137 $summary_ref->{'Parent
'} = $parent_gene->stable_id;
3138 $summary_ref->{'source
'} = $self->source();
3139 $summary_ref->{'transcript_id
'} = $summary_ref->{'id'};
3141 ## Specific attributes for merged species
3142 ## No data will be stored if these fields are not available
3143 my $havana_transcript = $self->havana_transcript();
3144 $summary_ref->{'havana_transcript
'} = $havana_transcript->display_id() if defined $havana_transcript;
3145 $summary_ref->{'havana_version
'} = $havana_transcript->version() if defined $havana_transcript;
3146 $summary_ref->{'ccdsid
'} = $self->ccds->display_id() if $self->ccds();
3147 $summary_ref->{'transcript_support_level
'} = $self->tsl() if $self->tsl();
3150 push @tags, $self->get_all_Attributes('gencode_basic
')->[0]->code if $self->gencode_basic();
3151 push @tags, 'Ensembl_canonical
' if $self->is_canonical();
3152 push @tags, $self->get_all_Attributes('gencode_primary
')->[0]->code if $self->gencode_primary();
3153 push @tags, $self->get_all_Attributes('ens_canon_extended
')->[0]->code if $self->ens_canon_extended();
3155 my $mane = $self->mane_transcript();
3157 push @tags, $mane->type() if ($mane->type());
3160 $summary_ref->{'tag
'} = \@tags if @tags;
3162 ## Stable identifier of the parent transcript this transcript was projected from
3163 my $proj_parent_attributes = $self->get_all_Attributes("proj_parent_t");
3164 if (@{$proj_parent_attributes}) {
3165 $summary_ref->{'projection_parent_transcript
'} = $proj_parent_attributes->[0]->value;
3167 return $summary_ref;
3170 =head2 gencode_basic
3172 Example : $gencode_basic = $transcript->gencode_basic();
3173 Description : Returns true if gencode_basic is set
3179 my @attributes = @{ $self->get_all_Attributes('gencode_basic
') };
3181 $basic = 1 if scalar(@attributes) > 0;
3185 =head2 gencode_primary
3187 Example : $gencode_primary = $transcript->gencode_primary();
3188 Description : Returns true if gencode_primary is set
3192 sub gencode_primary {
3194 my @attributes = @{ $self->get_all_Attributes('gencode_primary
') };
3196 $primary = 1 if scalar(@attributes) > 0;
3200 =head2 ens_canon_extended
3202 Example : $ens_canon_extended = $transcript->ens_canon_extended();
3203 Description : Returns true if ens_canon_extended is set
3207 sub ens_canon_extended {
3209 my @attributes = @{ $self->get_all_Attributes('ens_canon_extended
') };
3210 my $canon_extended = 0;
3211 $canon_extended = 1 if scalar(@attributes) > 0;
3212 return $canon_extended;
3217 Example : $tsl = $transcript->tsl();
3218 Description : Returns the corresponding transcript support level
3224 my @attributes = @{ $self->get_all_Attributes('TSL
') };
3226 $tsl = $attributes[0]->value if scalar(@attributes) > 0;
3227 if (defined $tsl) { $tsl =~ s/tsl//; }
3233 Example : $appris = $transcript->appris();
3234 Description : Returns the corresponding APPRIS tag
3241 my @attributes = @{ $self->get_all_Attributes('appris
') };
3243 $appris = $attributes[0]->value if scalar(@attributes) > 0;
3248 =head2 havana_transcript
3250 Example : $havana_transcript = $transcript->havana_transcript();
3251 Description : Locates the corresponding havana transcript
3252 Returns : Bio::EnsEMBL::DBEntry
3255 sub havana_transcript {
3257 my @otts = @{ $self->get_all_DBEntries('Vega_transcript
') };
3259 foreach my $xref (@otts) {
3260 if ($xref->display_id() =~ /OTT/) {
3270 Example : $ccds = $transcript->ccds();
3271 Description : Locates the corresponding ccds xref
3272 Returns : Bio::EnsEMBL::DBEntry
3277 my @ccds = @{ $self->get_all_DBEntries('CCDS
') };
3279 $ccds = $ccds[0] if scalar(@ccds) > 0;
3287 Example : $gene = $transcript->get_Gene;
3288 Description : Locates the parent Gene using a transcript dbID
3289 Returns : Bio::EnsEMBL::Gene
3295 my $gene_adaptor = $self->adaptor->db->get_GeneAdaptor();
3296 my $parent_gene = $gene_adaptor->fetch_by_transcript_id($self->dbID);
3297 return $parent_gene;
3302 Example : my $biotype = $transcript->get_Biotype;
3303 Description: Returns the Biotype object of this transcript.
3304 When no biotype exists, defaults to 'protein_coding
'.
3305 When used to set to a biotype that does not exist in
3306 the biotype table, a biotype object is created with
3307 the provided argument as name and object_type transcript.
3308 Returntype : Bio::EnsEMBL::Biotype
3316 # have a biotype object, return it
3318 return $self->{'biotype
'};
3321 # biotype is first set as a string retrieved from the transcript table
3322 # there is no biotype object in the transcript object, retrieve it using the biotype string
3323 # if no string, default to protein_coding. this is legacy behaviour and should probably be revisited
3324 my $biotype_name = $self->{'biotype
'} // 'protein_coding
';
3326 return $self->set_Biotype( $biotype_name );
3331 Arg [1] : Arg [1] : String - the biotype name to set
3332 Example : my $biotype = $transcript->set_Biotype('protin_coding
');
3333 Description: Sets the Biotype of this transcript to the provided biotype name.
3334 Returns the Biotype object of this transcript.
3335 When no biotype exists, defaults to 'protein_coding
' name.
3336 When setting a biotype that does not exist in
3337 the biotype table, a biotype object is created with
3338 the provided argument as name and object_type transcript.
3339 Returntype : Bio::EnsEMBL::Biotype
3340 Exceptions : If no argument provided
3345 my ( $self, $name ) = @_;
3347 throw('No argument provided
') unless defined $name;
3349 # retrieve biotype object from the biotype adaptor
3350 if( defined $self->adaptor() ) {
3351 my $ba = $self->adaptor()->db()->get_BiotypeAdaptor();
3352 $self->{'biotype
'} = $ba->fetch_by_name_object_type( $name, 'transcript' );
3354 # if $self->adaptor is unavailable, create a new biotype object containing name and object_type only
3356 $self->{'biotype
'} = Bio::EnsEMBL::Biotype->new(
3362 return $self->{'biotype
'} ;
3366 Arg [1] : (optional) String - the biotype to set
3367 Example : $transcript->biotype("protein_coding");
3368 Description: Getter/setter for the attribute biotype name.
3369 Recommended to use instead for a getter:
3370 $biotype = $transcript->get_Biotype;
3372 $biotype = $transcript->set_Biotype("protein_coding");
3373 The String biotype name can then be retrieved by
3374 calling name on the Biotype object:
3375 $biotype_name = $biotype->name;
3383 my ( $self, $biotype_name) = @_;
3385 # Setter? set_Biotype()
3386 if (defined $biotype_name) {
3387 return $self->set_Biotype($biotype_name)->name;
3390 # Getter? get_Biotype()
3391 return $self->get_Biotype->name;
3394 =head2 mane_transcript
3395 Example : $mane = $transcript->mane_transcript();
3396 Description: Retrieve the corresponding MANE transcript
3397 Returntype : Bio::EnsEMBL::MANE
3403 sub mane_transcript {
3405 if ($self->is_mane) {
3407 my $mane = Bio::EnsEMBL::MANE->new(
3408 -SEQ_REGION_START => $self->seq_region_start,
3409 -SEQ_REGION_END => $self->seq_region_end,
3410 -START => $self->start,
3412 -STABLE_ID => $self->stable_id,
3413 -SLICE => $self->slice,
3414 -TRANSCRIPT => $self
3422 Example : $boolean = $transcript->is_mane();
3423 Description: Check if a transcript is part of MANE
3424 Returntype : boolean
3433 foreach my $attribute (@{ $self->get_all_Attributes() } ) {
3434 if ($attribute->code=~ /MANE/) {