EnsEMBL/UTR.pm untested

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