Skip to main content

Molecular Mass Calculations

Project description

Molmass is a Python library and console script to calculate the molecular mass (average, nominal, and isotopic pure), the elemental composition, and the mass distribution spectrum of a molecule given by its chemical formula, relative element weights, or sequence.

Calculations are based on the isotopic composition of the elements. Mass deficiency due to chemical bonding is not taken into account.

Examples of valid formulas are H2O, [2H]2O, CH3COOH, EtOH, CuSO4.5H2O, (COOH)2, AgCuRu4(H)2[CO]12{PPh3}2, CGCGAATTCGCG, MDRGEQGLLK, and O: 0.26, 30Si: 0.74.

Formulas are case sensitive and + denotes the arithmetic operator, not an ion charge.

For command line usage run python -m molmass --help

Author:Christoph Gohlke
License:BSD 3-Clause



Remove support for Python 3.6 (NEP 29). Add Particle types to (#5). Fix failure on WSL2 (#9). Fix layout issue.
Update to version 2020.6.10.
Update to version 2020.1.1. Remove support for Python 2.7 and 3.5.
Move modules into molmass package.
Add option to start web interface from console.
Style and docstring fixes. Make ‘from_fractions’ output deterministic.
Initial release.


>>> from molmass import Formula
>>> f = Formula('D2O')  # heavy water
>>> f.formula  # hill notation
>>> f.empirical
>>> f.mass  # average mass
>>> f.isotope.massnumber  # nominal mass
>>> f.isotope.mass  # monoisotopic mass
>>> f.atoms
>>> print(f.composition())
Element  Number  Relative mass  Fraction %
2H            2       4.028204     20.1133
O             1      15.999405     79.8867
Total:        3      20.027609    100.0000
>>> print(f.spectrum())
Relative mass    Fraction %      Intensity
20.023118         99.757000     100.000000
21.027335          0.038000       0.038093
22.027363          0.205000       0.205499

Project details

Download files

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

Files for molmass, version 2021.6.18
Filename, size File type Python version Upload date Hashes
Filename, size molmass-2021.6.18-py3-none-any.whl (66.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size molmass-2021.6.18.tar.gz (64.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page