Variation/AAReverseMutate.pm

filter: Statementstmt 94.9% 75 / 79 Branchbran 73.6% 28 / 38 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 11 / 11 Podpod 100% 6 / 6 totaltotal 87.5% 126 / 144 CC 24 SCAR 16.9
CC
24
Cov
87%
each_Variant
10.0
new
5.4
codon_ori
4.5
CRAP 5.4
« Variation/Allele.pm ↑ Summary Variation/IO.pm »
1 #
2 # BioPerl module for Bio::Variation::AAReverseMutate
3 #
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 #
6 # Cared for by Heikki Lehvaslaiho <heikki-at-bioperl-dot-org>
7 #
8 # Copyright Heikki Lehvaslaiho
9 #
10 # You may distribute this module under the same terms as perl itself
11  
12 # POD documentation - main docs before the code
13  
14 =head1 NAME
15  
16 Bio::Variation::AAReverseMutate - point mutation and codon
17 information from single amino acid changes
18  
19 =head1 SYNOPSIS
20  
21 $aamut = Bio::Variation::AAReverseMutate->new
22 (-aa_ori => 'F',
23 -aa_mut => 'S',
24 -codon_ori => 'ttc', # optional
25 -codon_table => '3' # defaults to 1
26 );
27  
28 @points = $aamut->each_Variant;
29  
30 if (scalar @points > 0 ) {
31 foreach $rnachange ( @points ) {
32 # $rnachange is a Bio::Variation::RNAChange object
33 print " ", $rnachange->allele_ori->seq, ">",
34 $rnachange->allele_mut->seq, " in ",
35 $rnachange->codon_ori, ">", $rnachange->codon_mut,
36 " at position ", $rnachange->codon_pos, "\n";
37 }
38 } else {
39 print "No point mutations possible\n",
40 }
41  
42 =head1 DESCRIPTION
43  
44 Bio::Variation::AAReverseMutate objects take in reference and mutated
45 amino acid information and deduces potential point mutations at RNA
46 level leading to this change. The choice can be further limited by
47 letting the object know what is the the codon in the reference
48 sequence. The results are returned as L<Bio::Variation::RNAChange>
49 objects.
50  
51 =head1 FEEDBACK
52  
53 =head2 Mailing Lists
54  
55 User feedback is an integral part of the evolution of this and other
56 Bioperl modules. Send your comments and suggestions preferably to the
57 Bioperl mailing lists Your participation is much appreciated.
58  
59 bioperl-l@bioperl.org - General discussion
60 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
61  
62 =head2 Support
63  
64 Please direct usage questions or support issues to the mailing list:
65  
66 I<bioperl-l@bioperl.org>
67  
68 rather than to the module maintainer directly. Many experienced and
69 reponsive experts will be able look at the problem and quickly
70 address it. Please include a thorough description of the problem
71 with code and data examples if at all possible.
72  
73 =head2 Reporting Bugs
74  
75 Report bugs to the Bioperl bug tracking system to help us keep track
76 the bugs and their resolution. Bug reports can be submitted via the
77 web:
78  
79 https://github.com/bioperl/bioperl-live/issues
80  
81 =head1 AUTHOR - Heikki Lehvaslaiho
82  
83 Email: heikki-at-bioperl-dot-org
84  
85 =head1 APPENDIX
86  
87 The rest of the documentation details each of the object
88 methods. Internal methods are usually preceded with a _
89  
90 =cut
91  
92  
93 # Let the code begin...
94  
95 package Bio::Variation::AAReverseMutate;
96 2 $Bio::Variation::AAReverseMutate::VERSION = '1.7.5';
97 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
98  
99 # Object preamble - inheritance
100 2 ▶use Bio::Tools::CodonTable;
Subroutine BEGIN: called CC=1 SCAR=0.0
101 2 ▶use Bio::Variation::RNAChange;
Subroutine BEGIN: called CC=1 SCAR=0.0
102 2 ▶use Bio::Variation::Allele;
Subroutine BEGIN: called CC=1 SCAR=0.0
103  
104 2 ▶use base qw(Bio::Root::Root);
Subroutine BEGIN: called CC=1 SCAR=0.0
105  
106 1 ▶sub new {
Subroutine new: called CC=5 SCAR=16.8
Pod documented
107 1 my($class,@args) = @_;
108 1 my $self = $class->SUPER::new(@args);
109  
110 1 my ($aa_ori, $aa_mut, $codon_ori, $codon_table) =
111 $self->_rearrange([qw(AA_ORI
112 AA_MUT
113 CODON
114 CODON_TABLE
115 )],@args);
116  
117 1 ▶ $aa_ori && $self->aa_ori($aa_ori);
Branch: 1 branch
BranchTrueFalseTotal
$aa_ori and $self->aa_ori($aa_ori) 1 0 1
118 1 ▶ $aa_mut && $self->aa_mut($aa_mut);
Branch: 1 branch
BranchTrueFalseTotal
$aa_mut and $self->aa_mut($aa_mut) 1 0 1
119 1 ▶ $codon_ori && $self->codon_ori($codon_ori);
Branch: 1 branch
BranchTrueFalseTotal
$codon_ori and $self->codon_ori($codon_ori) 0 1 1
120 1 ▶ $codon_table && $self->codon_table($codon_table);
Branch: 1 branch
BranchTrueFalseTotal
$codon_table and $self->codon_table($codon_table) 0 1 1
121  
122 1 return $self; # success - we hope!
123  
124 }
125  
126  
127 =head2 aa_ori
128  
129 Title : aa_ori
130 Usage : $obj->aa_ori();
131 Function:
132  
133 Sets and returns original aa sequence. If value is not
134 set, returns false.
135  
136 Amino acid sequences are stored in upper case characters,
137 others in lower case.
138  
139 Example :
140 Returns : string
141 Args : single character amino acid code
142  
143 =cut
144  
145 6 ▶sub aa_ori {
Subroutine aa_ori: called CC=3 SCAR=11.2
Pod documented
146 6 my ($self,$value) = @_;
147 6 ▶ if( defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 1 5 6
148 1 ▶ if ( uc($value) !~ /^[ARNDCQEGHILKMFPSTWYVBZX*]$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not uc($value) =~ /^[ARNDCQEGHILKMFPSTWYVBZX*]$/) { } 0 1 1
149 0 $self->throw("'$value' is not a valid one letter amino acid symbol\n");
150 } else {
151 1 $self->{'aa_ori'} = uc $value;
152 }
153 }
154 6 return $self->{'aa_ori'};
155 }
156  
157  
158 =head2 aa_mut
159  
160 Title : aa_mut
161 Usage : $obj->aa_mut();
162 Function:
163  
164 Sets and returns the mutated allele sequence. If value is not
165 set, returns false.
166  
167 Example :
168 Returns : string
169 Args : single character amino acid code
170  
171 =cut
172  
173  
174 7 ▶sub aa_mut {
Subroutine aa_mut: called CC=3 SCAR=11.2
Pod documented
175 7 my ($self,$value) = @_;
176 7 ▶ if( defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 1 6 7
177 1 ▶ if ( uc($value) !~ /^[ARNDCQEGHILKMFPSTWYVBZX*]$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not uc($value) =~ /^[ARNDCQEGHILKMFPSTWYVBZX*]$/) { } 0 1 1
178 0 $self->throw("'$value' is not a valid one letter amino acid symbol\n");
179 } else {
180 1 $self->{'aa_mut'} = uc $value;
181 }
182 }
183 7 return $self->{'aa_mut'};
184 }
185  
186  
187 =head2 codon_ori
188  
189 Title : codon_ori
190 Usage : $obj->codon_ori();
191 Function:
192  
193 Sets and returns codon_ori triplet. If value is not set,
194 returns false. The string has to be three characters
195 long. The character content is not checked.
196  
197 Example :
198 Returns : string
199 Args : string
200  
201 =cut
202  
203 7 ▶sub codon_ori {
Subroutine codon_ori: called CC=4 SCAR=15.0
Pod documented
204 7 my ($self,$value) = @_;
205 7 ▶ if( defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 1 6 7
206 1 ▶ if (length $value != 3 or lc $value =~ /[^atgc]/) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $value != 3 or lc $value =~ /[^atgc]/) 0 1 1
Condition33%1/3
length $value != 3 or lc $value =~ /[^atgc]/
l!l&&r!l&&!r
001
MC/DC0%0/2
length $value != 3 or lc $value =~ /[^atgc]/
length $value != 3 lc $value =~ /[^atgc]/
Truth table33%1/3
A or B
A= length $value != 3B= lc $value =~ /[^atgc]/
ABresult
1X1
011
000
207 0 $self->warn("Codon string \"$value\" is not valid unique codon");
208 }
209 1 $self->{'codon_ori'} = lc $value;
210 }
211 7 return $self->{'codon_ori'};
212 }
213  
214 =head2 codon_table
215  
216 Title : codon_table
217 Usage : $obj->codon_table();
218 Function:
219  
220 Sets and returns the codon table id of the RNA
221 If value is not set, returns 1, 'universal' code, as the default.
222  
223 Example :
224 Returns : integer
225 Args : none if get, the new value if set
226  
227 =cut
228  
229  
230 6 ▶sub codon_table {
Subroutine codon_table: called CC=4 SCAR=14.0
Pod documented
231 6 my ($self,$value) = @_;
232 6 ▶ if( defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 2 4 6
233 2 ▶ if ( not $value =~ /^\d+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $value =~ /^\d+$/) { } 0 2 2
234 0 $self->throw("'$value' is not a valid codon table ID\n".
235 "Has to be a positive integer. Defaulting to 1\n");
236 } else {
237 2 $self->{'codon_table'} = $value;
238 }
239 }
240 6 ▶ if( ! exists $self->{'codon_table'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $self->{'codon_table'}) { } 2 4 6
241 2 return 1;
242 } else {
243 4 return $self->{'codon_table'};
244 }
245 }
246  
247  
248 =head2 each_Variant
249  
250 Title : each_Variant
251 Usage : $obj->each_Variant();
252 Function:
253  
254 Returns a list of Variants.
255  
256 Example :
257 Returns : list of Variants
258 Args : none
259  
260 =cut
261  
262 2 ▶sub each_Variant{
Subroutine each_Variant: called CC=10 SCAR=23.0
Pod documented
263 2 my ($self,@args) = @_;
264
265 2 ▶ $self->throw("aa_ori is not defined\n") if not defined $self->aa_ori;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->aa_ori 0 2 2
266 2 ▶ $self->throw("aa_mut is not defined\n") if not defined $self->aa_mut;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->aa_mut 0 2 2
267  
268 2 my (@points, $codon_pos, $allele_ori, $allele_mut);
269 2 my $ct = Bio::Tools::CodonTable->new( '-id' => $self->codon_table );
270 2 foreach my $codon_ori ($ct->revtranslate($self->aa_ori)) {
271 4 ▶ next if $self->codon_ori and $self->codon_ori ne $codon_ori;
Branch: 1 branch
BranchTrueFalseTotal
if $self->codon_ori and $self->codon_ori ne $codon_ori 1 3 4
Condition100%3/3
$self->codon_ori and $self->codon_ori ne $codon_ori
!ll&&!rl&&r
211
MC/DC100%2/2
$self->codon_ori and $self->codon_ori ne $codon_ori
$self->codon_ori $self->codon_ori ne $codon_ori
Truth table100%3/3
A and B
A= $self->codon_oriB= $self->codon_ori ne $codon_ori
ABresult
0X0
100
111
272 3 foreach my $codon_mut ($ct->revtranslate($self->aa_mut)) {
273 18 my $k = 0;
274 18 my $length = 0;
275 18 $codon_pos = $allele_ori = $allele_mut = undef;
276 18 ▶ while ($k<3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($k < 3) 54 18 72
277 54 my $nt_ori = substr ($codon_ori, $k, 1);
278 54 my $nt_mut = substr ($codon_mut, $k, 1);
279 54 ▶ if ($nt_ori ne $nt_mut) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nt_ori ne $nt_mut) 36 18 54
280 36 $length++;
281 36 $codon_pos = $k+1;
282 36 $allele_ori = $nt_ori;
283 36 $allele_mut = $nt_mut;
284 }
285 54 $k++;
286 }
287 18 ▶ if ($length == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length == 1) 3 15 18
288 3 my $rna = Bio::Variation::RNAChange->new
289 ('-length' => '1',
290 '-codon_ori' => $codon_ori,
291 '-codon_mut' => $codon_mut,
292 '-codon_pos' => $codon_pos,
293 '-isMutation' => 1
294 );
295 3 my $all_ori = Bio::Variation::Allele->new('-seq'=>$allele_ori);
296 3 $rna->allele_ori($all_ori);
297 3 my $all_mut = Bio::Variation::Allele->new('-seq'=>$allele_mut);
298 3 $rna->allele_mut($all_mut);
299 3 push @points, $rna;
300 }
301 }
302 }
303 2 return @points;
304 }
305  
306 2 1;
« Variation/Allele.pm ↑ Summary Variation/IO.pm »