Tool to query MS/MS spectra against GNPS library data.
Project description
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.