Skip to main content

Tool to query MS/MS spectra against GNPS library data.

Project description

GitHub Workflow Status GitHub PyPI fair-software.eu

MS2Query - machine learning assisted library querying of MS/MS spectra.

MS2Query is a tool for fast library searching for both analogs and true matches.

Documentation for users

Prepare environmnent

We recommend to create an Anaconda environment with

conda create --name ms2query python=3.8
conda activate ms2query

Pip install MS2Query

MS2Query can simply be installed by running:

pip install ms2query

Run MS2Query

Below you can find an example script for running MS2Query. Before running the script, replace the variables ms2query_library_files_directory and ms2_spectra_directory with the correct directories.

This script will first download files for a default MS2Query library. This default library is trained on the GNPS library from 2021-04-09.

After downloading, a library search and an analog search is performed on the query spectra in your directory (ms2_spectra_directory). The results generated by MS2Query, are stored as csv files in a results directory within the same directory as your query spectra.

import os
from ms2query.run_ms2query import download_default_models, default_library_file_base_names, run_complete_folder
from ms2query.ms2library import create_library_object_from_one_dir

# Set the location where all your downloaded model files are stored
ms2query_library_files_directory = "./ms2query_library_files"
# define the folder in which your query spectra are stored.
# Accepted formats are: "mzML", "json", "mgf", "msp", "mzxml", "usi" or a pickled matchms object. 
ms2_spectra_directory = "specify_directory"

# Downloads pretrained models and files for MS2Query (>10GB download)
download_default_models(ms2query_library_files_directory, default_library_file_base_names())

# Create a MS2Library object 
ms2library = create_library_object_from_one_dir(ms2query_library_files_directory, default_library_file_base_names())

folder_to_store_results = os.path.join(ms2_spectra_directory, "results")

# Run library search and analog search on your files. 
# The results are stored in the specified folder_to_store_results.
run_complete_folder(ms2library, ms2_spectra_directory, folder_to_store_results)

Documentation for developers

Prepare environmnent

We recommend to create an Anaconda environment with

conda create --name ms2query python=3.7
conda activate ms2query

Clone repository

Clone the present repository, e.g. by running

git clone https://github.com/iomega/ms2query.git

And then install the required dependencies, e.g. by running the following from within the cloned directory

pip install -e .

To run all unit tests, to check if everything was installed successfully run:

pytest

Contributing

If you want to contribute to the development of ms2query, have a look at the contribution guidelines.

License

Copyright (c) 2021, Netherlands eScience Center

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the 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

ms2query-0.2.3.tar.gz (41.2 kB view details)

Uploaded Source

Built Distribution

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

ms2query-0.2.3-py3-none-any.whl (54.0 kB view details)

Uploaded Python 3

File details

Details for the file ms2query-0.2.3.tar.gz.

File metadata

  • Download URL: ms2query-0.2.3.tar.gz
  • Upload date:
  • Size: 41.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for ms2query-0.2.3.tar.gz
Algorithm Hash digest
SHA256 7f50c1c07df54b021e39cf0fc89c9e7bb85d4d8ffc6bb527d9c38d02190ac47c
MD5 55fc1e492f5f0ad5a42420f4e0224994
BLAKE2b-256 611383d51b4dc27b2c6fa7db3aa80f17eef1259b5b71268dc8a70b8b85eac450

See more details on using hashes here.

File details

Details for the file ms2query-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: ms2query-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 54.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for ms2query-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cfa510873d22d4f5f6d02ee48eca8088e1268c7369bc9b5b0937e5e716a36184
MD5 d53ec8b432e72078fecfc5b4a35ed627
BLAKE2b-256 ccba56a96657b7f901c5284bb6ddc97ec9dc7a7f41dd086416aacfb1f043f0a5

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