EnsEMBL/CDS.pm untested

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