EnsEMBL/ExonTranscript.pm untested

filter: Statementstmt 0.0% 0 / 51 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 3 Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 87 CC 8 SCAR 20.1
CC
8
Cov
0%
summary_as_hash
20.0
exon
6.0
transcript
6.0
CRAP 7.5
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_50'; # TRIAL
54 $Bio::EnsEMBL::ExonTranscript::VERSION = '114.0.050';
55 use vars qw(@ISA);
56  
57 use Bio::EnsEMBL::Exon;
58 use Bio::EnsEMBL::Utils::Argument qw(rearrange);
59 use Scalar::Util qw(weaken isweak);
60  
61 @ISA = qw(Bio::EnsEMBL::Exon);
62  
63  
64 =head2 new
65  
66 Arg [Exon]: The Exon object
67 Arg [Transcript]: The Transcript object the exon belongs to
68 Example : $feature = Bio::EnsEMBL::ExonTranscript->new(-exon => $exon, -transcript => $transcript);
69 Description: Constructs a new Bio::EnsEMBL::ExonTranscript.
70 Returntype : Bio::EnsEMBL::ExonTranscript
71 Exceptions : Thrown on invalid -SLICE, -STRAND arguments
72 Caller : general, subclass constructors
73 Status : Stable
74  
75 =cut
76  
77 sub new {
78 my $caller = shift;
79  
80 #allow this to be called as class or object method
81 my $class = ref($caller) || $caller;
82 my $self = $class->SUPER::new(@_);
83  
84 my ($exon, $transcript, $rank) = rearrange(['EXON','TRANSCRIPT', 'RANK'],@_);
85  
86 $self->{'exon'} = $exon;
87 $self->{'transcript'} = $transcript;
88 $self->{'rank'} = $rank;
89  
90 foreach my $attribute (keys %$exon) {
91 $self->{$attribute} = $exon->{$attribute};
92 }
93  
94 return $self;
95 }
96  
97  
98 =head2 exon
99  
100 Arg [1] : (optional) Bio::EnsEMBL::Exon
101 Example : $exon = $exon_transcript->exon();
102 Description: Getter/Setter for the exon forming this
103 ExonTranscript.
104 Returntype : Bio::EnsEMBL::Exon
105 Exceptions : none
106 Caller : general
107 Status : Stable
108  
109 =cut
110  
111 sub exon {
112 my $self = shift;
113 $self->{'exon'} = shift if(@_);
114 return $self->{'exon'};
115 }
116  
117  
118 =head2 transcript
119  
120 Arg [1] : (optional) Bio::EnsEMBL::Transcript
121 Example : print $utr->type();
122 Description: Getter/Setter for the parent transcript
123 Returntype : Bio::EnsEMBL::Transcript
124 Exceptions : none
125 Caller : general
126 Status : Stable
127  
128 =cut
129  
130 sub transcript {
131 my $self = shift;
132 $self->{'transcript'} = shift if( @_ );
133 return ( $self->{'transcript'} );
134 }
135  
136 =head2 translation
137  
138 Description: Fetch the translation associated with
139 this transcript, if it exists. Return undef
140 if there is no translation, ie. a pseudogene
141 Returntype : Bio::EnsEMBL::Translation or undef
142 Caller : general
143 Status : Stable
144  
145 =cut
146  
147 sub translation {
148 my $self = shift;
149 return $self->transcript()->translation();
150 }
151  
152 =head2 get_Gene
153  
154 Description: Get the gene associated with the ExonTranscript,
155 if a transcript has been set
156 Returntype : Bio::EnsEMBL::Gene or undef
157 Exceptions : none
158 Caller : general
159 Status : Stable
160  
161 =cut
162  
163 sub get_Gene {
164 my $self = shift;
165  
166 if($self->{'transcript'}) {
167 return $self->{'transcript'}->get_Gene();
168 }
169  
170 return;
171 }
172  
173 =head2 rank
174  
175 Example : print $et->rank();
176 Description: Getter/Setter for the exon rank
177 Returntype : String
178 Exceptions : none
179 Caller : general
180 Status : Stable
181  
182 =cut
183  
184 sub rank {
185 my $self = shift;
186 $self->{'rank'} = shift if( @_ );
187 return ( $self->{'rank'} );
188 }
189  
190  
191 =head2 summary_as_hash
192  
193 Example : my $hash = $utr->summary_as_hash();
194 Description: Generates a HashRef compatible with GFFSerializer. Adds
195 rank and transcript attributes to the basic Feature
196 hash
197 Returntype : Hash
198 Exceptions : none
199 Caller : general
200 Status : Stable
201  
202 =cut
203  
204 sub summary_as_hash {
205 my ($self) = @_;
206 my $hash = $self->SUPER::summary_as_hash();
207 $hash->{'rank'} = $self->rank() if $self->rank();
208 $hash->{'Parent'} = $self->transcript->display_id() if $self->transcript();
209 $hash->{'source'} = $self->transcript->source() if $self->transcript();
210 return $hash;
211 }
212  
213  
214 1;