Skip to main content

A Python package for finding molecular formula candidates from a mass and error window

Project description

find-mfs: Accurate mass ➜ Molecular Formulae

CI PyPI version Python 3.10+ License: GPL v3

find-mfs is a simple Python package for finding molecular formulae candidates which fit some given mass (+/- an error window). It implements Böcker & Lipták's algorithm for efficient formula finding, as implemented in SIRIUS.

find-mfs also implements other methods for filtering the MF candidate lists:

  • Octet rule
  • Ring/double bond equivalents (RDBE's)
  • Predicted isotope envelopes, generated using using Łącki and Startek's algorithm as implemented in IsoSpecPy

Motivation:

I needed to perform mass decomposition and, shockingly, I could not find a Python library for it (despite being a routine process). find-mfs is intended to be used by anyone looking to incorporate molecular formula finding into their Python project.

Installation

pip install find-mfs

Example Usage:

# For simple queries, one can use this convenience function
from find_mfs import find_chnops

find_chnops(
    mass=613.2391,         # Novobiocin [M+H]+ ion; C31H37N2O11+
    charge=1,              # Charge should be specified - electron mass matters
    error_ppm=5.0,         # Can also specify error_da instead
                           # --- FORMULA FILTERS ----
    check_octet=True,      # Candidates must obey the octet rule
    filter_rdbe=(0, 20),   # Candidates must have 0 to 20 ring/double-bond equivalents
    max_counts='C*H*N*O*P0S2'      # Element constraints: unlimited C/H/N/O,
                                   # No phosphorous atoms, up to two sulfurs.
)

Output:

FormulaSearchResults(query_mass=613.2391, n_results=38)

Formula                   Error (ppm)     Error (Da)      RDBE
----------------------------------------------------------------------
[C6H25N30O4S]+                     -0.12       0.000073       9.5
[C31H37N2O11]+                      0.14       0.000086      14.5
[C14H29N24OS2]+                     0.18       0.000110      12.5
[C16H41N10O11S2]+                   0.20       0.000121       1.5
[C29H33N12S2]+                     -0.64       0.000392      19.5
... and 33 more
# If processing many masses, it's better to instantiate a FormulaFinder object
from find_mfs import FormulaFinder

finder = FormulaFinder()
finder.find_formulae(
    mass=613.2391,         # Novobiocin [M+H]+ ion; C31H37N2O11+
    charge=1,              
    error_ppm=5.0,         
    # ... etc
)

Jupyter Notebook:

See this Jupyter notebook for more thorough examples/demonstrations


If you use this package, make sure to cite:

Contributing

Contributions are welcome. Here's a list of features I feel should be implemented eventually:

  • Statistics-based isotope envelope fitting
  • Fragmentation constraints
  • Element ratio constraints
  • GUI app

License

This project is distributed under the GPL-3 license.

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

find_mfs-0.2.0.tar.gz (219.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

find_mfs-0.2.0-py3-none-any.whl (220.7 kB view details)

Uploaded Python 3

File details

Details for the file find_mfs-0.2.0.tar.gz.

File metadata

  • Download URL: find_mfs-0.2.0.tar.gz
  • Upload date:
  • Size: 219.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for find_mfs-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a60943cfc44f216b6875545885e1fe3286392e4e3b3253fd9c5c05528300aeb9
MD5 379ce51bd983ead6b7918c8673a9d6ad
BLAKE2b-256 b245e59ded70954596d87cdb4f21568711d0d4f018f188b01a15a7cc7390681e

See more details on using hashes here.

File details

Details for the file find_mfs-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: find_mfs-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 220.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for find_mfs-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1e3578ed117e94fa112853c24e09e2344b55e67486efd13961447436ae7c156d
MD5 27a37fd04db6aefb27301bb4040bfb6a
BLAKE2b-256 8b68abaf3871fb75da7dcd2f9e45e50e876d87cec1c08313a94a3dd2dc0aa7bc

See more details on using hashes here.

Supported by

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