Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/Variation/AAReverseMutate.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: AAReverseMutate.pm,v 1.6 2002/10/22 07:38:49 lapp Exp $ | |
| 2 # | |
| 3 # BioPerl module for Bio::Variation::AAReverseMutate | |
| 4 # | |
| 5 # Cared for by Heikki Lehvaslaiho <heikki@ebi.ac.uk> | |
| 6 # | |
| 7 # Copyright Heikki Lehvaslaiho | |
| 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::Variation::AAReverseMutate - point mutation and codon | |
| 16 information from single amino acid changes | |
| 17 | |
| 18 =head1 SYNOPSIS | |
| 19 | |
| 20 $aamut = new Bio::Variation::AAReverseMutate | |
| 21 (-aa_ori => 'F', | |
| 22 -aa_mut => 'S', | |
| 23 -codon_ori => 'ttc', # optional | |
| 24 -codon_table => '3' # defaults to 1 | |
| 25 ); | |
| 26 | |
| 27 @points = $aamut->each_Variant; | |
| 28 | |
| 29 if (scalar @points > 0 ) { | |
| 30 foreach $rnachange ( @points ) { | |
| 31 # $rnachange is a Bio::Variation::RNAChange object | |
| 32 print " ", $rnachange->allele_ori->seq, ">", | |
| 33 $rnachange->allele_mut->seq, " in ", | |
| 34 $rnachange->codon_ori, ">", $rnachange->codon_mut, | |
| 35 " at position ", $rnachange->codon_pos, "\n"; | |
| 36 } | |
| 37 } else { | |
| 38 print "No point mutations possible\n", | |
| 39 } | |
| 40 | |
| 41 =head1 DESCRIPTION | |
| 42 | |
| 43 Bio::Variation::AAReverseMutate objects take in reference and mutated | |
| 44 amino acid information and deduces potential point mutations at RNA | |
| 45 level leading to this change. The choice can be further limited by | |
| 46 letting the object know what is the the codon in the reference | |
| 47 sequence. The results are returned as L<Bio::Variation::RNAChange> | |
| 48 objects. | |
| 49 | |
| 50 =head1 FEEDBACK | |
| 51 | |
| 52 =head2 Mailing Lists | |
| 53 | |
| 54 User feedback is an integral part of the evolution of this and other | |
| 55 Bioperl modules. Send your comments and suggestions preferably to the | |
| 56 Bioperl mailing lists Your participation is much appreciated. | |
| 57 | |
| 58 bioperl-l@bioperl.org - General discussion | |
| 59 http://bio.perl.org/MailList.html - About the mailing lists | |
| 60 | |
| 61 =head2 Reporting Bugs | |
| 62 | |
| 63 report bugs to the Bioperl bug tracking system to help us keep track | |
| 64 the bugs and their resolution. Bug reports can be submitted via | |
| 65 email or the web: | |
| 66 | |
| 67 bioperl-bugs@bio.perl.org | |
| 68 http://bugzilla.bioperl.org/ | |
| 69 | |
| 70 =head1 AUTHOR - Heikki Lehvaslaiho | |
| 71 | |
| 72 Email: heikki@ebi.ac.uk | |
| 73 Address: | |
| 74 | |
| 75 EMBL Outstation, European Bioinformatics Institute | |
| 76 Wellcome Trust Genome Campus, Hinxton | |
| 77 Cambs. CB10 1SD, United Kingdom | |
| 78 | |
| 79 | |
| 80 =head1 APPENDIX | |
| 81 | |
| 82 The rest of the documentation details each of the object | |
| 83 methods. Internal methods are usually preceded with a _ | |
| 84 | |
| 85 =cut | |
| 86 | |
| 87 | |
| 88 # Let the code begin... | |
| 89 | |
| 90 package Bio::Variation::AAReverseMutate; | |
| 91 my $VERSION=1.0; | |
| 92 use vars qw(@ISA); | |
| 93 use strict; | |
| 94 | |
| 95 # Object preamble - inheritance | |
| 96 use Bio::Tools::CodonTable; | |
| 97 use Bio::Variation::RNAChange; | |
| 98 use Bio::Variation::Allele; | |
| 99 | |
| 100 @ISA = qw( Bio::Root::Root); | |
| 101 | |
| 102 sub new { | |
| 103 my($class,@args) = @_; | |
| 104 my $self = $class->SUPER::new(@args); | |
| 105 | |
| 106 my ($aa_ori, $aa_mut, $codon_ori, $codon_table) = | |
| 107 $self->_rearrange([qw(AA_ORI | |
| 108 AA_MUT | |
| 109 CODON | |
| 110 CODON_TABLE | |
| 111 )],@args); | |
| 112 | |
| 113 $aa_ori && $self->aa_ori($aa_ori); | |
| 114 $aa_mut && $self->aa_mut($aa_mut); | |
| 115 $codon_ori && $self->codon_ori($codon_ori); | |
| 116 $codon_table && $self->codon_table($codon_table); | |
| 117 | |
| 118 return $self; # success - we hope! | |
| 119 | |
| 120 } | |
| 121 | |
| 122 | |
| 123 =head2 aa_ori | |
| 124 | |
| 125 Title : aa_ori | |
| 126 Usage : $obj->aa_ori(); | |
| 127 Function: | |
| 128 | |
| 129 Sets and returns original aa sequence. If value is not | |
| 130 set, returns false. | |
| 131 | |
| 132 Amino acid sequences are stored in upper case characters, | |
| 133 others in lower case. | |
| 134 | |
| 135 Example : | |
| 136 Returns : string | |
| 137 Args : single character amino acid code | |
| 138 | |
| 139 =cut | |
| 140 | |
| 141 sub aa_ori { | |
| 142 my ($self,$value) = @_; | |
| 143 if( defined $value) { | |
| 144 if ( uc($value) !~ /^[ARNDCQEGHILKMFPSTWYVBZX*]$/ ) { | |
| 145 $self->throw("'$value' is not a valid one letter amino acid symbol\n"); | |
| 146 } else { | |
| 147 $self->{'aa_ori'} = uc $value; | |
| 148 } | |
| 149 } | |
| 150 return $self->{'aa_ori'}; | |
| 151 } | |
| 152 | |
| 153 | |
| 154 =head2 aa_mut | |
| 155 | |
| 156 Title : aa_mut | |
| 157 Usage : $obj->aa_mut(); | |
| 158 Function: | |
| 159 | |
| 160 Sets and returns the mutated allele sequence. If value is not | |
| 161 set, returns false. | |
| 162 | |
| 163 Example : | |
| 164 Returns : string | |
| 165 Args : single character amino acid code | |
| 166 | |
| 167 =cut | |
| 168 | |
| 169 | |
| 170 sub aa_mut { | |
| 171 my ($self,$value) = @_; | |
| 172 if( defined $value) { | |
| 173 if ( uc($value) !~ /^[ARNDCQEGHILKMFPSTWYVBZX*]$/ ) { | |
| 174 $self->throw("'$value' is not a valid one letter amino acid symbol\n"); | |
| 175 } else { | |
| 176 $self->{'aa_mut'} = uc $value; | |
| 177 } | |
| 178 } | |
| 179 return $self->{'aa_mut'}; | |
| 180 } | |
| 181 | |
| 182 | |
| 183 =head2 codon_ori | |
| 184 | |
| 185 Title : codon_ori | |
| 186 Usage : $obj->codon_ori(); | |
| 187 Function: | |
| 188 | |
| 189 Sets and returns codon_ori triplet. If value is not set, | |
| 190 returns false. The string has to be three characters | |
| 191 long. The chracter content is not checked. | |
| 192 | |
| 193 Example : | |
| 194 Returns : string | |
| 195 Args : string | |
| 196 | |
| 197 =cut | |
| 198 | |
| 199 sub codon_ori { | |
| 200 my ($self,$value) = @_; | |
| 201 if( defined $value) { | |
| 202 if (length $value != 3 or lc $value =~ /[^atgc]/) { | |
| 203 $self->warn("Codon string \"$value\" is not valid unique codon"); | |
| 204 } | |
| 205 $self->{'codon_ori'} = lc $value; | |
| 206 } | |
| 207 return $self->{'codon_ori'}; | |
| 208 } | |
| 209 | |
| 210 =head2 codon_table | |
| 211 | |
| 212 Title : codon_table | |
| 213 Usage : $obj->codon_table(); | |
| 214 Function: | |
| 215 | |
| 216 Sets and returns the codon table id of the RNA | |
| 217 If value is not set, returns 1, 'universal' code, as the default. | |
| 218 | |
| 219 Example : | |
| 220 Returns : integer | |
| 221 Args : none if get, the new value if set | |
| 222 | |
| 223 =cut | |
| 224 | |
| 225 | |
| 226 sub codon_table { | |
| 227 my ($self,$value) = @_; | |
| 228 if( defined $value) { | |
| 229 if ( not $value =~ /^\d+$/ ) { | |
| 230 $self->throw("'$value' is not a valid codon table ID\n". | |
| 231 "Has to be a positive integer. Defaulting to 1\n"); | |
| 232 } else { | |
| 233 $self->{'codon_table'} = $value; | |
| 234 } | |
| 235 } | |
| 236 if( ! exists $self->{'codon_table'} ) { | |
| 237 return 1; | |
| 238 } else { | |
| 239 return $self->{'codon_table'}; | |
| 240 } | |
| 241 } | |
| 242 | |
| 243 | |
| 244 =head2 each_Variant | |
| 245 | |
| 246 Title : each_Variant | |
| 247 Usage : $obj->each_Variant(); | |
| 248 Function: | |
| 249 | |
| 250 Returns a list of Variants. | |
| 251 | |
| 252 Example : | |
| 253 Returns : list of Variants | |
| 254 Args : none | |
| 255 | |
| 256 =cut | |
| 257 | |
| 258 sub each_Variant{ | |
| 259 my ($self,@args) = @_; | |
| 260 | |
| 261 $self->throw("aa_ori is not defined\n") if not defined $self->aa_ori; | |
| 262 $self->throw("aa_mut is not defined\n") if not defined $self->aa_mut; | |
| 263 | |
| 264 my (@points, $codon_pos, $allele_ori, $allele_mut); | |
| 265 my $ct = Bio::Tools::CodonTable->new( '-id' => $self->codon_table ); | |
| 266 foreach my $codon_ori ($ct->revtranslate($self->aa_ori)) { | |
| 267 next if $self->codon_ori and $self->codon_ori ne $codon_ori; | |
| 268 foreach my $codon_mut ($ct->revtranslate($self->aa_mut)) { | |
| 269 my $k = 0; | |
| 270 my $length = 0; | |
| 271 $codon_pos = $allele_ori = $allele_mut = undef; | |
| 272 while ($k<3) { | |
| 273 my $nt_ori = substr ($codon_ori, $k, 1); | |
| 274 my $nt_mut = substr ($codon_mut, $k, 1); | |
| 275 if ($nt_ori ne $nt_mut) { | |
| 276 $length++; | |
| 277 $codon_pos = $k+1; | |
| 278 $allele_ori = $nt_ori; | |
| 279 $allele_mut = $nt_mut; | |
| 280 } | |
| 281 $k++; | |
| 282 } | |
| 283 if ($length == 1) { | |
| 284 my $rna = Bio::Variation::RNAChange->new | |
| 285 ('-length' => '1', | |
| 286 '-codon_ori' => $codon_ori, | |
| 287 '-codon_mut' => $codon_mut, | |
| 288 '-codon_pos' => $codon_pos, | |
| 289 '-isMutation' => 1 | |
| 290 ); | |
| 291 my $all_ori = Bio::Variation::Allele->new('-seq'=>$allele_ori); | |
| 292 $rna->allele_ori($all_ori); | |
| 293 my $all_mut = Bio::Variation::Allele->new('-seq'=>$allele_mut); | |
| 294 $rna->allele_mut($all_mut); | |
| 295 push @points, $rna; | |
| 296 } | |
| 297 } | |
| 298 } | |
| 299 return @points; | |
| 300 } | |
| 301 | |
| 302 1; | 
