/** * Calculates mass in daltons. * $protein is a sequence of characters **/ function proteindb_mass($protein) { global $proteindb_proteins; $mass = 0.0; for ($i = 0; $i < strlen($protein); $i++) { $amino = $protein[$i]; if (proteindb_is_amino_acid($amino)) { $mass += $proteindb_proteins[$amino][2]; } } // this is combined mass of these amino acids, but they are linked // Subtract water molecules from peptide bonds. $mass -= (proteindb_count_amino($protein) - 1) * 18.02; return $mass; }
echo @$_POST['protein']; ?> </textarea><br> <input type="submit" value="Analyze"> </form> <?php ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); include_once 'proteindb.php'; if (@$_POST['protein']) { $protein = $_POST['protein']; ?> <hr> Total amino acids: <?php echo proteindb_count_amino($protein); ?> <br> Mass: <?php echo proteindb_mass($protein); ?> Da<br> Aromatic amino acids: <?php echo proteindb_count_with_property($protein, 'aromatic'); ?> <br> Aliphatic amino acids: <?php echo proteindb_count_with_property($protein, 'aliphatic'); ?> <br> Positive amino acids: <?php