Skip to main content

Molecular formula annotation for MS-based small molecule analysis.

Project description

msbuddy

Maintainer PyPI docs PyPI Downloads Generic badge

Sample Image

msbuddy is developed for molecular formula analysis in MS-based small molecule (<1500 Da) studies.

msbuddy is able to provide formula annotations for queries:

  • with or without MS1 isotopic pattern
  • with or without MS/MS spectra
  • in either positive or negative ionization mode

The minimum requirement for a msbuddy query is a single m/z value and its ionization polarity.

Official documentation is available at https://msbuddy.readthedocs.io/en/latest/.

Installation

msbuddy is available on PyPI, you can install the latest version via pip:

pip install msbuddy

To perform formula annotation, you also have to install the lightgbm package.

pip install lightgbm

Note: Python version >= 3.9 and <3.13 is required.

Python usage

Quick start (docs)

As a quick start, we here load a mgf file and annotate the molecular formula for each query. All the configurations are specified in the MsbuddyConfig class. Parallel computing is supported.

from msbuddy import Msbuddy, MsbuddyConfig

# instantiate a MsbuddyConfig object
msb_config = MsbuddyConfig(ms_instr='orbitrap', # supported: "qtof", "orbitrap", "fticr" or None
                                                # custom MS1 and MS2 tolerance will be used if None
                           ppm=True,  # use ppm for mass tolerance
                           ms1_tol=5,  # MS1 tolerance in ppm or Da
                           ms2_tol=10,  # MS2 tolerance in ppm or Da
                           halogen=False)

# instantiate a Msbuddy object
msb_engine = Msbuddy(msb_config)

# load data, here we use a mgf file as an example
msb_engine.load_mgf('input_file.mgf')

# annotate molecular formula
msb_engine.annotate_formula()

# retrieve the annotation result summary
result = msb_engine.get_summary()

See demo mgf file. One of the following fields is recommended to be included, which will be used as the query identifier: TITLE, FEATURE_ID, SPECTRUMID, or SPECTRUM_ID.

MS/MS spectra can be loaded via their USIs if they are publicly available:

# you can load multiple USIs at once
msb_engine.load_usi(['mzspec:GNPS:GNPS-LIBRARY:accession:CCMSLIB00003740036',
                     'mzspec:GNPS:GNPS-LIBRARY:accession:CCMSLIB00003740037'])

Here is a test case on Google Colab.

Other API functions

See more in the documentation.

Command-line tool (docs)

msbuddy can also be used as a command-line tool. Result summary will be generated in a tsv file. More detailed annotation results can be written with the -details option (or -d for short).

Here is an example command for a mgf file from Orbitrap:

msbuddy -mgf <mgf_file> -output <output_folder> -ms orbitrap -details

for a single USI string (from FT-ICR, for example):

msbuddy -usi <usi_string> -output <output_folder> -ms fticr

or a csv file (template files) containing multiple USI strings (QTOF in this example):

msbuddy -csv <csv_file> -output <output_folder> -ms qtof -details

For mgf file or csv file, you can omit the -output option, and results will be written in the same folder as the input file.

Here is an example of processing a mgf file from Orbitrap (-ms orbitrap) in parallel (-p) using 12 cores (-n_cpu 12). Detailed results are written (-d). Halogen atoms (FClBrI) are also considered (-hal).

msbuddy -mgf <mgf_file> -ms orbitrap -p -n_cpu 12 -d -hal

Run the following command to see the full list of options:

msbuddy --help

Links

msbuddy documentation

PyPI release

Change log

GitHub repository

Citation

S. Xing et al. BUDDY: molecular formula discovery via bottom-up MS/MS interrogation. Nature Methods 2023. DOI: 10.1038/s41592-023-01850-x

License

This work is licensed under the Apache License 2.0.

Contact

Please contact me via philipxsp@hotmail.com.

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

msbuddy-0.3.14.tar.gz (47.4 kB view details)

Uploaded Source

Built Distribution

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

msbuddy-0.3.14-py3-none-any.whl (52.4 kB view details)

Uploaded Python 3

File details

Details for the file msbuddy-0.3.14.tar.gz.

File metadata

  • Download URL: msbuddy-0.3.14.tar.gz
  • Upload date:
  • Size: 47.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.18

File hashes

Hashes for msbuddy-0.3.14.tar.gz
Algorithm Hash digest
SHA256 72b221fb8eb904204f16fe05704b1a9829668243986cb2288967a7cd4b99bd90
MD5 a4d34af023634f1ae0801ce8fac6371f
BLAKE2b-256 86733cc2e99045defbe77bd91f8b3a493b4c29c543abaf5d109654e8a053e455

See more details on using hashes here.

File details

Details for the file msbuddy-0.3.14-py3-none-any.whl.

File metadata

  • Download URL: msbuddy-0.3.14-py3-none-any.whl
  • Upload date:
  • Size: 52.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.18

File hashes

Hashes for msbuddy-0.3.14-py3-none-any.whl
Algorithm Hash digest
SHA256 7053f63fd3eb8d0cfd1680ea222e2c640f879ecbc6cd79bca7211d8d8820746d
MD5 eb50cf83335af20bf94f23458787eb70
BLAKE2b-256 72e6f6cc88ac09654432f609a12398e5e05ac4a72a25a9905d73c15cc5e65c15

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