[Bioperl-l] A new Perl module for Chemistry
Wed, 13 Sep 2000 15:10:17 -0500
I have written a new Perl Chemistry module that might be of interest to
you guys as well. I would like to request comments before I put it out
**** Special interest for biochemists -- adding a macro like "Gly" =>
"NHCH2CO" allows you to calculate masses of proteins and nucleic asids.
Chemistry::MolecularMass - Perl extension for calculating molecular
of a chemical compound given its chemical formula.
AUTHOR AND COPYRIGHT
Copyright (C) 2000, Maksim A. Khrapov firstname.lastname@example.org
This program is distributed under Perl Artistic Lisence. No
Use at your own risk.
my $mm = new Chemistry::MolecularMass;
my $mass = $mm->calc_mass("C2H5OH");
print $mass if defined($mass);
my %default_macros = $mm->all_macros;
$mm->add_macros("Ts" => "CH3C6H4SO2", "Bs" => "BrC6H4SO2");
$mass = $mm->calc_mass("TsOEt");
### if you are an organic chemist, you might want to do this:
$mm->add_macros("Pr" => "C3H7", "Ac" => "CH3COO");
my %elements = $mm->all_elements;
$mm->replace_elements("Na" => 24.00, "Cl" => 37.00);
$mass = $mm->calc_mass("NaCl");
Chemistry::MolecularMass is an Object Oriented Perl module for
molcular mass of chemical compounds implemented with Perl and C.
Molecular masses of elements stored in the module follow
of IUPAC (1995). The module includes elements from H(1) through
Uuu(113) and isotopes of hydrogen: deuterium and tritium. The
also allows a programmer to change the default masses of elements
for work with isotopes. It also includes some of the more common
chemical abbreviations as macros and allows to add new macros and
change the values of old macros. A hash of all macros and a hash
of all elements can be returned.
Each MolecularMass object has its own hashes of macros and
masses, so modifications made to one MolecularMass object do NOT
affect another. The whole thing was programmed with reentrancy
in mind, so it should be thread safe as well.
Maksim Khrapov <email@example.com> +1-512-328-5959 ext. 3015
http://www.dealernet.com/ -- Where will you buy your next car?