mbgbioinfo has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; use warnings; my %MWs; my $line; my @AA; my $AA; #create the hash MWs with the amino acids and their molecular weight. %MWs = ( "A" => 71.1, "D" => 115.0, "F" => 147.1, "H" => 137.1, "K" => 128.1, "M" => 131.1, "P" => 97.1, "R" => 156.1, "T" => 101.1, "W" => 186.2, "C" => 103.1, "E" => 129.1, "G" => 57.1, "I" => 113.1, "L" => 113.1, "N" => 114.1, "Q" => 128.1, "S" => 87.1, "V" => 99.1, "Y" => 163.1, "\n" => 0.0 ); my $sum = 0.0; #I want the amino acids one by one and not all of them. $/ = \1; print "Type amino acids.\n"; while ( $line = <STDIN> ) #I create an array which contains all the typed amino acids.Each cell +of the array contains one amino acid. { @AA = $line; foreach $AA(@AA) { #I want now the sum of protein's molecular weight. $sum += $MWs{ "$AA(@AA)" }; } } print "Molecular weight of this peptide is: $sum \n"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: MOLECULAR WEIGHT SUM
by pme (Monsignor) on Mar 20, 2016 at 21:50 UTC | |
|
Re: MOLECULAR WEIGHT SUM
by 1nickt (Canon) on Mar 20, 2016 at 21:56 UTC | |
|
Re: MOLECULAR WEIGHT SUM
by davido (Cardinal) on Mar 20, 2016 at 22:06 UTC | |
|
Re: MOLECULAR WEIGHT SUM
by kevbot (Vicar) on Mar 20, 2016 at 21:54 UTC |