Skip to main content

Calculates the Molecular Weight, to the appropriate significant digits, from a string of an arbitrary chemical formula, a protein sequence of one- or three-letter codes, or chemical common names that are recognized by PubChem.

Project description

Calculating the Molecular Weight from a Chemical Formula, Common Name, or Protein Sequence

PyPI version Actions Status Downloads License

The molecular weight (MW) can be algebraically calculated from any chemical formula that adheres to chemical conventions, which is exemplified in subsequent examples.

The ChemMW object of ChemW parses a chemical formula string – which can consist of any combination of elements and decimal stoichiometry – and precisely calculates the MW of the chemical formula. The significant digits of the reported MW matches the lowest significant digits from the set of elements that constitute the chemical formula, where the used elemental masses are the most precise contemporary measurements of pure elements, per the chemicals module.

The Proteins and PHREEQdg objects are applications of the ChemMW object that expand the utility of this library. The Proteins object returns the mass of a protein by either parsing a string of a protein sequence, or by parsing a FASTA-formatted file. This is applied in the Codons module for genome-scale biology and bioengineering. The PHREEQdb object of ChemW parses a PHREEQ database via the ChemMW object and exports a JSON of mineral masses for all of the described minerals in the database. This is pivotally applied to calculate the masses of complex minerals in the PHREEQC databases of the ROSSpy module for reverse osmosis research.

The ChemW library is offered with the MIT License. Examples of the module are available in the examples directory of the ChemW GitHub repository. Please submit errors or inaccuracies as GitHub issues so that they may be resolved.


The following command installs ChemW in a command prompt/terminal environment:

pip install chemw

The full documentation is available on ReadTheDocs.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ChemW-0.2.4.tar.gz (528.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page