Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/SeqFeature/Gene/Exon.pm @ 0:1f6dce3d34e0
Uploaded
author | mahtabm |
---|---|
date | Thu, 11 Apr 2013 02:01:53 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1f6dce3d34e0 |
---|---|
1 # $Id: Exon.pm,v 1.8 2002/10/22 07:38:41 lapp Exp $ | |
2 # | |
3 # BioPerl module for Bio::SeqFeature::Gene::Exon | |
4 # | |
5 # Cared for by Hilmar Lapp <hlapp@gmx.net> | |
6 # | |
7 # Copyright Hilmar Lapp | |
8 # | |
9 # You may distribute this module under the same terms as perl itself | |
10 | |
11 # POD documentation - main docs before the code | |
12 | |
13 =head1 NAME | |
14 | |
15 Bio::SeqFeature::Gene::Exon - a feature representing an exon | |
16 | |
17 =head1 SYNOPSIS | |
18 | |
19 # obtain an exon instance $exon somehow | |
20 print "exon from ", $exon->start(), " to ", $exon->end(), | |
21 " on seq ", $exon->seq_id(), ", strand ", $exon->strand(), | |
22 ", encodes the peptide sequence ", | |
23 $exon->cds()->translate()->seq(), "\n"; | |
24 | |
25 =head1 DESCRIPTION | |
26 | |
27 This module implements a feature representing an exon by implementing the | |
28 Bio::SeqFeature::Gene::ExonI interface. | |
29 | |
30 Apart from that, this class also implements Bio::SeqFeatureI by inheriting | |
31 off Bio::SeqFeature::Generic. | |
32 | |
33 =head1 FEEDBACK | |
34 | |
35 =head2 Mailing Lists | |
36 | |
37 User feedback is an integral part of the evolution of this | |
38 and other Bioperl modules. Send your comments and suggestions preferably | |
39 to one of the Bioperl mailing lists. | |
40 Your participation is much appreciated. | |
41 | |
42 bioperl-l@bioperl.org - General discussion | |
43 http://bio.perl.org/MailList.html - About the mailing lists | |
44 | |
45 =head2 Reporting Bugs | |
46 | |
47 Report bugs to the Bioperl bug tracking system to help us keep track | |
48 the bugs and their resolution. | |
49 Bug reports can be submitted via email or the web: | |
50 | |
51 bioperl-bugs@bio.perl.org | |
52 http://bugzilla.bioperl.org/ | |
53 | |
54 =head1 AUTHOR - Hilmar Lapp | |
55 | |
56 Email hlapp@gmx.net | |
57 | |
58 Describe contact details here | |
59 | |
60 =head1 APPENDIX | |
61 | |
62 The rest of the documentation details each of the object methods. | |
63 Internal methods are usually preceded with a _ | |
64 | |
65 =cut | |
66 | |
67 | |
68 # Let the code begin... | |
69 | |
70 | |
71 package Bio::SeqFeature::Gene::Exon; | |
72 use vars qw(@ISA); | |
73 use strict; | |
74 | |
75 use Bio::SeqFeature::Generic; | |
76 use Bio::SeqFeature::Gene::ExonI; | |
77 | |
78 @ISA = qw(Bio::SeqFeature::Generic Bio::SeqFeature::Gene::ExonI); | |
79 | |
80 # | |
81 # A list of allowed exon types. See primary_tag(). | |
82 # | |
83 my @valid_exon_types = ('initial', 'internal', 'terminal'); | |
84 | |
85 sub new { | |
86 my ($caller, @args) = @_; | |
87 my $self = $caller->SUPER::new(@args); | |
88 my ($primary) = | |
89 $self->_rearrange([qw(PRIMARY)],@args); | |
90 | |
91 $primary = 'exon' unless $primary; | |
92 $self->primary_tag($primary); # this will also set is_coding() | |
93 $self->strand(0) if(! defined($self->strand())); | |
94 return $self; | |
95 } | |
96 | |
97 | |
98 =head2 is_coding | |
99 | |
100 Title : is_coding | |
101 Usage : if($exon->is_coding()) { | |
102 # do something | |
103 } | |
104 if($is_utr) { | |
105 $exon->is_coding(0); | |
106 } | |
107 Function: Get/set whether or not the exon codes for amino acid. | |
108 Returns : TRUE if the object represents a feature translated into protein, | |
109 and FALSE otherwise. | |
110 Args : A boolean value on set. | |
111 | |
112 | |
113 =cut | |
114 | |
115 sub is_coding { | |
116 my ($self,$val) = @_; | |
117 | |
118 if(defined($val)) { | |
119 $self->{'_iscoding'} = $val; | |
120 } | |
121 return $self->{'_iscoding'}; | |
122 } | |
123 | |
124 =head2 primary_tag | |
125 | |
126 Title : primary_tag | |
127 Usage : $tag = $feat->primary_tag() | |
128 $feat->primary_tag('exon') | |
129 Function: Get/set the primary tag for the exon feature. | |
130 | |
131 This method is overridden here in order to allow only for | |
132 tag values following a certain convention. For consistency reasons, | |
133 the tag value must either contain the string 'exon' or the string | |
134 'utr' (both case-insensitive). In the case of 'exon', a string | |
135 describing the type of exon may be appended or prefixed. Presently, | |
136 the following types are allowed: initial, internal, and terminal | |
137 (all case-insensitive). | |
138 | |
139 If the supplied tag value matches 'utr' (case-insensitive), | |
140 is_coding() will automatically be set to FALSE, and to TRUE | |
141 otherwise. | |
142 | |
143 Returns : A string. | |
144 Args : A string on set. | |
145 | |
146 | |
147 =cut | |
148 | |
149 # sub primary_tag { | |
150 # my ($self,$value) = @_; | |
151 | |
152 # if(defined($value)) { | |
153 # if((lc($value) =~ /utr/i) || (lc($value) eq "exon") || | |
154 # ((lc($value) =~ /exon/i) && | |
155 # (grep { $value =~ /$_/i; } @valid_exon_types))) { | |
156 # $self->is_coding($value =~ /utr/i ? 0 : 1); | |
157 # } else { | |
158 # $self->throw("primary tag $value is invalid for object of class ". | |
159 # ref($self)); | |
160 # } | |
161 # } | |
162 # return $self->SUPER::primary_tag($value); | |
163 # } | |
164 | |
165 =head2 location | |
166 | |
167 Title : location | |
168 Usage : my $location = $exon->location() | |
169 Function: Returns a location object suitable for identifying the location | |
170 of the exon on the sequence or parent feature. | |
171 | |
172 This method is overridden here to restrict allowed location types | |
173 to non-compound locations. | |
174 | |
175 Returns : Bio::LocationI object | |
176 Args : none | |
177 | |
178 | |
179 =cut | |
180 | |
181 sub location { | |
182 my ($self,$value) = @_; | |
183 | |
184 if(defined($value) && $value->isa('Bio::Location::SplitLocationI')) { | |
185 $self->throw("split or compound location is not allowed ". | |
186 "for an object of type " . ref($self)); | |
187 } | |
188 return $self->SUPER::location($value); | |
189 } | |
190 | |
191 =head2 cds | |
192 | |
193 Title : cds() | |
194 Usage : $cds = $exon->cds(); | |
195 Function: Get the coding sequence of the exon as a sequence object. | |
196 | |
197 The sequence of the returned object is prefixed by Ns (lower case) | |
198 if the frame of the exon is defined and different from zero. The | |
199 result is that the first base starts a codon (frame 0). | |
200 | |
201 This implementation returns undef if the particular exon is | |
202 not translated to protein, i.e., is_coding() returns FALSE. Undef | |
203 will also be returned if no sequence is attached to this exon | |
204 feature. | |
205 | |
206 Returns : A Bio::PrimarySeqI implementing object. | |
207 Args : | |
208 | |
209 | |
210 =cut | |
211 | |
212 sub cds { | |
213 my ($self) = @_; | |
214 | |
215 # UTR is not translated | |
216 return undef if(! $self->is_coding()); | |
217 | |
218 my $seq = $self->seq(); | |
219 if(defined($seq) && defined($self->frame()) && ($self->frame() != 0)) { | |
220 my $prefix = "n" x $self->frame(); | |
221 $seq->seq($prefix . $seq->seq()); | |
222 } | |
223 return $seq; | |
224 } | |
225 | |
226 1; |