| 1 | =head1 LICENSE | ||
| 2 | |||
| 3 | See the NOTICE file distributed with this work for additional information | ||
| 4 | regarding copyright ownership. | ||
| 5 | |||
| 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 | ||
| 9 | |||
| 10 | http://www.apache.org/licenses/LICENSE-2.0 | ||
| 11 | |||
| 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. | ||
| 17 | |||
| 18 | =cut | ||
| 19 | |||
| 20 | |||
| 21 | =head1 CONTACT | ||
| 22 | |||
| 23 | Please email comments or questions to the public Ensembl | ||
| 24 | developers list at <http://lists.ensembl.org/mailman/listinfo/dev>. | ||
| 25 | |||
| 26 | Questions may also be sent to the Ensembl help desk at | ||
| 27 | <http://www.ensembl.org/Help/Contact>. | ||
| 28 | |||
| 29 | =cut | ||
| 30 | |||
| 31 | =head1 NAME | ||
| 32 | |||
| 33 | Bio::EnsEMBL::ExonTranscript - An Exon feature in relation to a transcript | ||
| 34 | |||
| 35 | =head1 SYNOPSIS | ||
| 36 | |||
| 37 | use Bio::EnsEMBL::ExonTranscript; | ||
| 38 | |||
| 39 | $feature = Bio::EnsEMBL::ExonTranscript->new(-exon => $exon, -transcript => $transcript); | ||
| 40 | |||
| 41 | =head1 DESCRIPTION | ||
| 42 | |||
| 43 | This is a feature which extends the Exon class to add | ||
| 44 | the relation to a specific transcript. | ||
| 45 | |||
| 46 | =head1 METHODS | ||
| 47 | |||
| 48 | =cut | ||
| 49 | |||
| 50 | use strict; | ||
| 51 | |||
| 52 | package Bio::EnsEMBL::ExonTranscript; | ||
| 53 | $Bio::EnsEMBL::ExonTranscript::VERSION = '114.0.0'; | ||
| 54 | use vars qw(@ISA); | ||
| 55 | |||
| 56 | use Bio::EnsEMBL::Exon; | ||
| 57 | use Bio::EnsEMBL::Utils::Argument qw(rearrange); | ||
| 58 | use Scalar::Util qw(weaken isweak); | ||
| 59 | |||
| 60 | @ISA = qw(Bio::EnsEMBL::Exon); | ||
| 61 | |||
| 62 | |||
| 63 | =head2 new | ||
| 64 | |||
| 65 | Arg [Exon]: The Exon object | ||
| 66 | Arg [Transcript]: The Transcript object the exon belongs to | ||
| 67 | Example : $feature = Bio::EnsEMBL::ExonTranscript->new(-exon => $exon, -transcript => $transcript); | ||
| 68 | Description: Constructs a new Bio::EnsEMBL::ExonTranscript. | ||
| 69 | Returntype : Bio::EnsEMBL::ExonTranscript | ||
| 70 | Exceptions : Thrown on invalid -SLICE, -STRAND arguments | ||
| 71 | Caller : general, subclass constructors | ||
| 72 | Status : Stable | ||
| 73 | |||
| 74 | =cut | ||
| 75 | |||
| 76 | sub new { | ||
| 77 | my $caller = shift; | ||
| 78 | |||
| 79 | #allow this to be called as class or object method | ||
| 80 | my $class = ref($caller) || $caller; | ||
| 81 | my $self = $class->SUPER::new(@_); | ||
| 82 | |||
| 83 | my ($exon, $transcript, $rank) = rearrange(['EXON','TRANSCRIPT', 'RANK'],@_); | ||
| 84 | |||
| 85 | $self->{'exon'} = $exon; | ||
| 86 | $self->{'transcript'} = $transcript; | ||
| 87 | $self->{'rank'} = $rank; | ||
| 88 | |||
| 89 | foreach my $attribute (keys %$exon) { | ||
| 90 | $self->{$attribute} = $exon->{$attribute}; | ||
| 91 | } | ||
| 92 | |||
| 93 | return $self; | ||
| 94 | } | ||
| 95 | |||
| 96 | |||
| 97 | =head2 exon | ||
| 98 | |||
| 99 | Arg [1] : (optional) Bio::EnsEMBL::Exon | ||
| 100 | Example : $exon = $exon_transcript->exon(); | ||
| 101 | Description: Getter/Setter for the exon forming this | ||
| 102 | ExonTranscript. | ||
| 103 | Returntype : Bio::EnsEMBL::Exon | ||
| 104 | Exceptions : none | ||
| 105 | Caller : general | ||
| 106 | Status : Stable | ||
| 107 | |||
| 108 | =cut | ||
| 109 | |||
| 110 | sub exon { | ||
| 111 | my $self = shift; | ||
| 112 | $self->{'exon'} = shift if(@_); | ||
| 113 | return $self->{'exon'}; | ||
| 114 | } | ||
| 115 | |||
| 116 | |||
| 117 | =head2 transcript | ||
| 118 | |||
| 119 | Arg [1] : (optional) Bio::EnsEMBL::Transcript | ||
| 120 | Example : print $utr->type(); | ||
| 121 | Description: Getter/Setter for the parent transcript | ||
| 122 | Returntype : Bio::EnsEMBL::Transcript | ||
| 123 | Exceptions : none | ||
| 124 | Caller : general | ||
| 125 | Status : Stable | ||
| 126 | |||
| 127 | =cut | ||
| 128 | |||
| 129 | sub transcript { | ||
| 130 | my $self = shift; | ||
| 131 | $self->{'transcript'} = shift if( @_ ); | ||
| 132 | return ( $self->{'transcript'} ); | ||
| 133 | } | ||
| 134 | |||
| 135 | =head2 translation | ||
| 136 | |||
| 137 | Description: Fetch the translation associated with | ||
| 138 | this transcript, if it exists. Return undef | ||
| 139 | if there is no translation, ie. a pseudogene | ||
| 140 | Returntype : Bio::EnsEMBL::Translation or undef | ||
| 141 | Caller : general | ||
| 142 | Status : Stable | ||
| 143 | |||
| 144 | =cut | ||
| 145 | |||
| 146 | sub translation { | ||
| 147 | my $self = shift; | ||
| 148 | return $self->transcript()->translation(); | ||
| 149 | } | ||
| 150 | |||
| 151 | =head2 get_Gene | ||
| 152 | |||
| 153 | Description: Get the gene associated with the ExonTranscript, | ||
| 154 | if a transcript has been set | ||
| 155 | Returntype : Bio::EnsEMBL::Gene or undef | ||
| 156 | Exceptions : none | ||
| 157 | Caller : general | ||
| 158 | Status : Stable | ||
| 159 | |||
| 160 | =cut | ||
| 161 | |||
| 162 | sub get_Gene { | ||
| 163 | my $self = shift; | ||
| 164 | |||
| 165 | if($self->{'transcript'}) { | ||
| 166 | return $self->{'transcript'}->get_Gene(); | ||
| 167 | } | ||
| 168 | |||
| 169 | return; | ||
| 170 | } | ||
| 171 | |||
| 172 | =head2 rank | ||
| 173 | |||
| 174 | Example : print $et->rank(); | ||
| 175 | Description: Getter/Setter for the exon rank | ||
| 176 | Returntype : String | ||
| 177 | Exceptions : none | ||
| 178 | Caller : general | ||
| 179 | Status : Stable | ||
| 180 | |||
| 181 | =cut | ||
| 182 | |||
| 183 | sub rank { | ||
| 184 | my $self = shift; | ||
| 185 | $self->{'rank'} = shift if( @_ ); | ||
| 186 | return ( $self->{'rank'} ); | ||
| 187 | } | ||
| 188 | |||
| 189 | |||
| 190 | =head2 summary_as_hash | ||
| 191 | |||
| 192 | Example : my $hash = $utr->summary_as_hash(); | ||
| 193 | Description: Generates a HashRef compatible with GFFSerializer. Adds | ||
| 194 | rank and transcript attributes to the basic Feature | ||
| 195 | hash | ||
| 196 | Returntype : Hash | ||
| 197 | Exceptions : none | ||
| 198 | Caller : general | ||
| 199 | Status : Stable | ||
| 200 | |||
| 201 | =cut | ||
| 202 | |||
| 203 | sub summary_as_hash { | ||
| 204 | my ($self) = @_; | ||
| 205 | my $hash = $self->SUPER::summary_as_hash(); | ||
| 206 | $hash->{'rank'} = $self->rank() if $self->rank(); | ||
| 207 | $hash->{'Parent'} = $self->transcript->display_id() if $self->transcript(); | ||
| 208 | $hash->{'source'} = $self->transcript->source() if $self->transcript(); | ||
| 209 | return $hash; | ||
| 210 | } | ||
| 211 | |||
| 212 | |||
| 213 | 1; |