ensembl-hive  2.7.0
CDS.pm
Go to the documentation of this file.
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 
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 
61 use vars qw(@ISA);
62 
64 use Bio::EnsEMBL::Utils::Argument qw(rearrange);
65 use Scalar::Util qw(weaken isweak);
66 
67 @ISA = qw(Bio::EnsEMBL::Feature);
68 
69 use constant SEQUENCE_ONTOLOGY => {
70  acc => 'SO:0000316',
71  term => 'CDS',
72 };
73 
74 =head2 new
75 
76  Arg [...] : Named arguments passed to superclass
77  Example : $feature = Bio::EnsEMBL::CDS->new
78  (-start => 1,
79  -end => 100,
80  -strand => 1,
81  -slice => $slice,
82  -dbID => 10,
83  -transcript => $transcript,
84  -phase => 1);
85  Description: Constructs a new Bio::EnsEMBL::CDS.
86  Returntype : Bio::EnsEMBL::CDS
87  Exceptions : Thrown on invalid -SLICE, -STRAND arguments
88  Caller : general, subclass constructors
89  Status : Stable
90 
91 =cut
92 
93 sub new {
94  my $caller = shift;
95 
96  #allow this to be called as class or object method
97  my $class = ref($caller) || $caller;
98  my $self = $class->SUPER::new(@_);
99 
100  my ($transcript, $phase, $translation_id, $seq_region_start, $seq_region_end) = rearrange(['TRANSCRIPT','PHASE', 'TRANSLATION_ID', 'SEQ_REGION_START', 'SEQ_REGION_END'],@_);
101 
102  $self->{'transcript'} = $transcript;
103  $self->{'phase'} = $phase;
104  $self->{'translation_id'} = $translation_id;
105  $self->{'seq_region_start'} = $seq_region_start;
106  $self->{'seq_region_end'} = $seq_region_end;
107 
108  return $self;
109 }
110 
111 
112 =head2 transcript
113 
114  Arg [1] : (optional) Bio::EnsEMBL::Transcript
115  Example : $transcript = $cds->transcript();
116  Description: Getter/Setter for the transcript associated with this
117  CDS.
118  Returntype : Bio::EnsEMBL::Transcript
119  Exceptions : none
120  Caller : general
121  Status : Stable
122 
123 =cut
124 
125 sub transcript {
126  my $self = shift;
127  $self->{'transcript'} = shift if(@_);
128  return $self->{'transcript'};
129 }
130 
131 =head2 translation
132 
133  Description: Fetch the translation associated with
134  this transcript, if it exists. Return undef
135  if there is no translation, ie. a pseudogene
136  Returntype : Bio::EnsEMBL::Translation or undef
137  Caller : general
138  Status : Stable
139 
140 =cut
141 
142 sub translation {
143  my $self = shift;
144  return $self->transcript()->translation();
145 }
146 
147 =head2 seq_region_start
148 
149  Arg [1] : (optional) string $seq_region_start
150  Example : $seq_region_start = $cds->seq_region_start();
151  Description: Getter/Setter for the seq_region_start for this CDS.
152  Overwrite default method from Feature as CDS does not have
153  a table
154  Returntype : String
155  Exceptions : none
156  Caller : general
157  Status : Stable
158 
159 =cut
160 
161 sub seq_region_start {
162  my $self = shift;
163  $self->{'seq_region_start'} = shift if(@_);
164  return $self->{'seq_region_start'};
165 }
166 
167 =head2 seq_region_end
168 
169  Arg [1] : (optional) string $seq_region_end
170  Example : $seq_region_end = $cds->seq_region_end();
171  Description: Getter/Setter for the seq_region_end for this CDS.
172  Overwrite default method from Feature as CDS does not have
173  a table
174  Returntype : String
175  Exceptions : none
176  Caller : general
177  Status : Stable
178 
179 =cut
180 
181 sub seq_region_end {
182  my $self = shift;
183  $self->{'seq_region_end'} = shift if(@_);
184  return $self->{'seq_region_end'};
185 }
186 
187 =head2 get_Gene
188 
189  Description: Get the gene associated with the ExonTranscript,
190  if a transcript has been set
191  Returntype : Bio::EnsEMBL::Gene or undef
192  Exceptions : none
193  Caller : general
194  Status : Stable
195 
196 =cut
197 
198 sub get_Gene {
199  my $self = shift;
200 
201  if($self->{'transcript'}) {
202  return $self->{'transcript'}->get_Gene();
203  }
204 
205  return;
206 }
207 
208 =head2 translation_id
209 
210  Arg [1] : (optional) string $translation_id
211  Example : $translation_id = $cds->translation_id();
212  Description: Getter/Setter for the stable_id for the translation
213  associated with this CDS.
214  Returntype : String
215  Exceptions : none
216  Caller : general
217  Status : Stable
218 
219 =cut
220 
221 sub translation_id {
222  my $self = shift;
223  $self->{'translation_id'} = shift if(@_);
224  return $self->{'translation_id'};
225 }
226 
227 
228 =head2 phase
229 
230  Arg [1] : (optional) string $phase
231  Example : print $cds->phase();
232  Description: This method returns an integer that describes
233  the phase of the coding feature
234  Returntype : integer
235  Exceptions : none
236  Caller : general
237  Status : Stable
238 
239 =cut
240 
241 sub phase {
242  my $self = shift;
243  $self->{'phase'} = shift if( @_ );
244  return ( $self->{'phase'} || 0 );
245 }
246 
247 
248 =head2 summary_as_hash
249 
250  Example : my $hash = $cds->summary_as_hash();
251  Description: Generates a HashRef compatible with GFFSerializer. Adds
252  Parent, source and phase to the basic feature hash
253  Returntype : Hash
254  Exceptions : none
255  Caller : general
256  Status : Stable
257 
258 =cut
259 
260 sub summary_as_hash {
261  my ($self) = @_;
262  my $hash = $self->SUPER::summary_as_hash();
263  $hash->{'phase'} = $self->phase();
264  my $parent = $self->transcript();
265  $hash->{'Parent'} = $parent->display_id if defined $parent;
266  $hash->{'source'} = $self->transcript->source() if $self->transcript();
267  $hash->{'id'} = $self->translation_id() if $self->translation_id();
268  $hash->{'protein_id'} = $self->translation_id() if $self->translation_id();
269  return $hash;
270 }
271 
272 
273 1;
transcript
public transcript()
Bio::EnsEMBL::Translation
Definition: Translation.pm:32
Bio::EnsEMBL::Feature
Definition: Feature.pm:47
Bio::EnsEMBL::CDS::new
public Bio::EnsEMBL::CDS new()
Bio::EnsEMBL::Gene
Definition: Gene.pm:37
Bio::EnsEMBL::CDS
Definition: CDS.pm:28
Bio::EnsEMBL::Transcript
Definition: Transcript.pm:44
Bio::EnsEMBL::Transcript::translation
public Bio::EnsEMBL::Translation translation()
Bio::EnsEMBL::Utils::Argument
Definition: Argument.pm:34
Bio::EnsEMBL::Translation::transcript
public Bio::EnsEMBL::Transcript transcript()
Bio::EnsEMBL::Gene::summary_as_hash
public Hashref summary_as_hash()