Giter Club home page Giter Club logo

msbuddy's Introduction

msbuddy

Maintainer PyPI docs 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

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 the msbuddy developer & maintainer Shipei Xing via [email protected] or [email protected].

msbuddy's People

Contributors

philipbear avatar

Stargazers

Phillip Ankley avatar V avatar  avatar  avatar 刘鑫 avatar Johon Li Tuobang 李拓邦 avatar Thomas Harwood avatar Jonas Dietrich avatar Wasim Sandhu avatar  avatar Yukai Wang avatar Mitja M. Zdouc avatar Helge Hecht avatar Manhoi.Hur avatar Hongchao Ji avatar J0siee avatar  avatar Huaxu Yu avatar

Watchers

 avatar  avatar

Forkers

hcji mhhur

msbuddy's Issues

No annotation for demo mgf file

Hello,
when I run the code from the quick start section for the formula annotation I don't get any annotation for the spectra. As input I used the provided demo mgf file.

MSBuddyAnnotationNotWorking

Any ideas why it doesn't work?

Error while instantiating a Msbuddy object

I am trying to run MSBUDDY for formula prediction on my own MS/MS data. I installed python 3.10 and msbuddy 0.2.9, and used the following codes:

from msbuddy import Msbuddy, MsbuddyConfig

# instantiate a MsbuddyConfig object
msb_config = MsbuddyConfig(ms_instr='qtof', # 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)

However, the following error showed up while instantiating a Msbuddy object:

msbuddy: molecular formula annotation for MS-based small molecule analysis.
Developed and maintained by Shipei Xing.
Traceback (most recent call last):
  File "/data/<user name>/FIDDLE/run_buddy/run_buddy.py", line 12, in <module>
    msb_engine = Msbuddy(msb_config)
  File "/home/<user name>/miniconda3/envs/buddy/lib/python3.9/site-packages/msbuddy/main.py", line 206, in __init__
    shared_data_dict = init_db()  # database initialization
  File "/home/<user name>/miniconda3/envs/buddy/lib/python3.9/site-packages/msbuddy/load.py", line 63, in init_db
    check_download_joblibload(
  File "/home/<user name>/miniconda3/envs/buddy/lib/python3.9/site-packages/msbuddy/load.py", line 41, in check_download_joblibload
    download(url, str(path))
  File "/home/<user name>/miniconda3/envs/buddy/lib/python3.9/site-packages/gdown/download.py", line 259, in download
    filename_from_url = m.groups()[0]
AttributeError: 'NoneType' object has no attribute 'groups'

I am quite confused about that. Could you please give me an idea of how to solve that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.