EnsEMBL/UTR.pm untested

filter: Statementstmt 0.0% 0 / 60 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 9 Subroutinesub 0.0% 0 / 15 Podpod 0.0% 0 / 10 totaltotal 0.0% 0 / 110 CC 9 SCAR 19.3
CC
9
Cov
0%
summary_as_hash
20.0
transcript
6.0
seq_region_start
6.0
CRAP 6.9
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::UTR - A UTR feature with a location and a type (five prime/3 prime)
34  
35 =head1 SYNOPSIS
36  
37 use Bio::EnsEMBL::UTR;
38  
39 $feature = Bio::EnsEMBL::UTR->new(
40 -start => 100,
41 -end => 220,
42 -strand => -1,
43 -slice => $slice,
44 -type => 'five_prime_UTR',
45 -transcript => $transcript
46 );
47  
48 =head1 DESCRIPTION
49  
50 This is a UTR feature within the Ensembl system.
51 A UTR repsents the non-coding (untranslated) regions
52 of a transcript. It can be 5' or 3'
53  
54 =head1 METHODS
55  
56 =cut
57  
58 use strict;
59  
60 package Bio::EnsEMBL::UTR;
61 $Bio::EnsEMBL::UTR::VERSION = '114.0.0_50'; # TRIAL
62 $Bio::EnsEMBL::UTR::VERSION = '114.0.050';
63 use vars qw(@ISA);
64  
65 use Bio::EnsEMBL::Feature;
66 use Bio::EnsEMBL::Utils::Argument qw(rearrange);
67 use Scalar::Util qw(weaken isweak);
68  
69 @ISA = qw(Bio::EnsEMBL::Feature);
70  
71  
72 =head2 new
73  
74 Arg [...] : Named arguments passed to superclass
75 Example : $feature = Bio::EnsEMBL::UTR->new
76 (-start => 1,
77 -end => 100,
78 -strand => 1,
79 -slice => $slice,
80 -dbID => 10,
81 -transcript => $transcript,
82 -type => 'five_prime_UTR');
83 Description: Constructs a new Bio::EnsEMBL::UTR.
84 Returntype : Bio::EnsEMBL::UTR
85 Exceptions : Thrown on invalid -SLICE, -STRAND arguments
86 Caller : general, subclass constructors
87 Status : Stable
88  
89 =cut
90  
91 sub new {
92 my $caller = shift;
93  
94 #allow this to be called as class or object method
95 my $class = ref($caller) || $caller;
96 my $self = $class->SUPER::new(@_);
97  
98 my ($transcript, $type, $seq_region_start, $seq_region_end) = rearrange(['TRANSCRIPT','TYPE', 'SEQ_REGION_START', 'SEQ_REGION_END'],@_);
99  
100 $self->{'transcript'} = $transcript;
101 $self->{'type'} = $type;
102 $self->{'seq_region_start'} = $seq_region_start;
103 $self->{'seq_region_end'} = $seq_region_end;
104  
105 return $self;
106 }
107  
108  
109 =head2 transcript
110  
111 Arg [1] : (optional) Bio::EnsEMBL::Transcript
112 Example : $transcript = $utr->transcript();
113 Description: Getter/Setter for the transcript associated with this
114 UTR.
115 Returntype : Bio::EnsEMBL::Transcript
116 Exceptions : none
117 Caller : general
118 Status : Stable
119  
120 =cut
121  
122 sub transcript {
123 my $self = shift;
124 $self->{'transcript'} = shift if(@_);
125 return $self->{'transcript'};
126 }
127  
128 =head2 translation
129  
130 Description: Fetch the translation associated with
131 this transcript, if it exists. Return undef
132 if there is no translation, ie. a pseudogene
133 Returntype : Bio::EnsEMBL::Translation or undef
134 Caller : general
135 Status : Stable
136  
137 =cut
138  
139 sub translation {
140 my $self = shift;
141 return $self->transcript()->translation();
142 }
143  
144 =head2 seq_region_start
145  
146 Arg [1] : (optional) string $seq_region_start
147 Example : $seq_region_start = $cds->seq_region_start();
148 Description: Getter/Setter for the seq_region_start for this UTR.
149 Overwrite default method from Feature as UTR does not have
150 a table
151 Returntype : String
152 Exceptions : none
153 Caller : general
154 Status : Stable
155  
156 =cut
157  
158 sub seq_region_start {
159 my $self = shift;
160 $self->{'seq_region_start'} = shift if(@_);
161 return $self->{'seq_region_start'};
162 }
163  
164 =head2 seq_region_end
165  
166 Arg [1] : (optional) string $seq_region_end
167 Example : $seq_region_end = $cds->seq_region_end();
168 Description: Getter/Setter for the seq_region_end for this UTR.
169 Overwrite default method from Feature as UTR does not have
170 a table
171 Returntype : String
172 Exceptions : none
173 Caller : general
174 Status : Stable
175  
176 =cut
177  
178 sub seq_region_end {
179 my $self = shift;
180 $self->{'seq_region_end'} = shift if(@_);
181 return $self->{'seq_region_end'};
182 }
183  
184 =head2 get_Gene
185  
186 Description: Get the gene associated with the ExonTranscript,
187 if a transcript has been set
188 Returntype : Bio::EnsEMBL::Gene or undef
189 Exceptions : none
190 Caller : general
191 Status : Stable
192  
193 =cut
194  
195 sub get_Gene {
196 my $self = shift;
197  
198 if($self->{'transcript'}) {
199 return $self->{'transcript'}->get_Gene();
200 }
201  
202 return;
203 }
204  
205 =head2 type
206  
207 Arg [1] : (optional) string $type
208 Example : print $utr->type();
209 Description: This method returns a string that describes
210 the type of UTR feature (5 prime or 3 prime)
211 Returntype : string
212 Exceptions : none
213 Caller : general
214 Status : Stable
215  
216 =cut
217  
218 sub type {
219 my $self = shift;
220 $self->{'type'} = shift if( @_ );
221 return ( $self->{'type'} || 'UTR' );
222 }
223  
224  
225 # package variable to minimize duplication
226 my %utr_type_so_mapping = (
227 'five_prime_utr' => {
228 acc => 'SO:0000204',
229 term => 'five_prime_UTR',
230 },
231 'three_prime_utr' => {
232 acc => 'SO:0000205',
233 term => 'three_prime_UTR',
234 }
235 );
236  
237 =head2 feature_so_acc
238  
239 Example : print $utr->feature_so_acc;
240 Description: This method returns a string containing the SO accession number of the UTR, based on type.
241 Overrides Bio::EnsEMBL::Feature::feature_so_acc
242 Returntype : string (Sequence Ontology accession number)
243  
244 =cut
245  
246 sub feature_so_acc {
247 my $self = shift;
248  
249 # return UTR type SO acc, or UTR acc
250 return $utr_type_so_mapping{$self->type}->{'acc'} // 'SO:0000203';
251 }
252  
253 =head2 feature_so_term
254  
255 Example : print $utr->feature_so_term;
256 Description: This method returns a string containing the SO accession term of the UTR, based on type.
257 Overrides Bio::EnsEMBL::Feature::feature_so_term
258 Returntype : string (Sequence Ontology term)
259  
260 =cut
261  
262 sub feature_so_term {
263 my $self = shift;
264  
265 # return UTR type SO acc, or UTR acc
266 return $utr_type_so_mapping{$self->type}->{'term'} // 'UTR';
267 }
268  
269 =head2 summary_as_hash
270  
271 Example : my $hash = $utr->summary_as_hash();
272 Description: Generates a HashRef compatible with GFFSerializer. Adds
273 Parent, source and type to the basic Feature hash
274 Returntype : Hash
275 Exceptions : none
276 Caller : general
277 Status : Stable
278  
279 =cut
280  
281 sub summary_as_hash {
282 my ($self) = @_;
283 my $hash = $self->SUPER::summary_as_hash();
284 $hash->{'type'} = $self->type() if $self->type();
285 my $parent = $self->transcript();
286 $hash->{'Parent'} = $parent->display_id if defined $parent;
287 $hash->{'source'} = $self->transcript->source() if $self->transcript();
288 delete $hash->{id};
289 return $hash;
290 }
291  
292  
293 1;