Skip to main content

Mass spectrometry query language python implementation

Project description

Mass Spec Query Language

Unit Testing Periodic Testing of Package

The Mass Spec Query Language (MassQL) is a domain specific language meant to be a succinct way to express a query in a mass spectrometry centric fashion. It is inspired by SQL, but it attempts to bake in assumptions of mass spectrometry to make querying much more natural for mass spectrometry users. Broadly we attempt to design it according to several principles:

  1. Expressiveness - Capture complex mass spectrometry patterns that the community would like to look for
  2. Precision - Exactly prescribe how to find data without ambiguity
  3. Scalable - Easily facilitating the querying of one spectrum all the way up to entire repositories of data
  4. Relatively Natural - MassQL should be relatively easy to read and write and even use to communicate ideas about mass spectrometry, you know like a language.

Repository Structure

This is the repository to define the language and reference implementation. This contains several parts

  1. Language Grammar
  2. Reference Implementation Python API
  3. Command line Utility to execute
  4. NextFlow Workflow For Large Scale Analysis
  5. ProteoSAFe workflow
  6. Dash interactive exploration

Developers/Contact

Mingxun Wang is the main creator and developer of MassQL. Contact me for contributing or using it!

Language Specification/Documentation

Checkout specifics for the language, examples, and design patterns at the documentation.

Documentation Link

Python API

We currently test massql in python 3.9, but are figuring out other versions if they work or not.

To install massql

pip install massql

Here is the most basic operation you can do

from massql import msql_engine

results_df = msql_engine.process_query(input_query, input_filename)

If you want to push in a data frame you already have, you can specify it

from massql import msql_engine
from massql import msql_fileloading

# Loading Data
ms1_df, ms2_df = msql_fileloading.load_data(input_filename)

# Executing Query
results_df = msql_engine.process_query(input_query, input_filename, ms1_df=ms1_df, ms2_df=ms2_df)

Command Line Tool

You can use the command line tool massql to query things or put things into a pipeline.

A few examples of what you can do

massql test.mzML "QUERY scaninfo(MS2DATA)" --output_file results.tsv

Web API

API Version

/api

Parsing query into intermediate JSON string

/parse?query=<query string>

Example Link

Visualization of Query

Visualization image of MS1 spectra

/visualize/ms1

Example Link

Visualization image of MS2 spectra

/visualize/ms2

Testing

To run tests, you'll need to first fetch some fixtures that are not bundled with the git repo: cd tests && sh ./get_data.sh

You will also want to install the extra requirements for the test suite: pip install -r requirements_test.txt

License

MIT 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

massql-2025.12.10.tar.gz (45.9 kB view details)

Uploaded Source

Built Distribution

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

massql-2025.12.10-py3-none-any.whl (40.3 kB view details)

Uploaded Python 3

File details

Details for the file massql-2025.12.10.tar.gz.

File metadata

  • Download URL: massql-2025.12.10.tar.gz
  • Upload date:
  • Size: 45.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.16

File hashes

Hashes for massql-2025.12.10.tar.gz
Algorithm Hash digest
SHA256 bee394c67f856940368da98fa1cbf82fc115aac94a7dc027c142956c2697e6fb
MD5 75ec7997eea38e557d997b18b6f14308
BLAKE2b-256 f98286aea2baf91cd5906ffd248eb5c9edf52b1f863abe6eff4a17d86bbf936c

See more details on using hashes here.

File details

Details for the file massql-2025.12.10-py3-none-any.whl.

File metadata

  • Download URL: massql-2025.12.10-py3-none-any.whl
  • Upload date:
  • Size: 40.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.16

File hashes

Hashes for massql-2025.12.10-py3-none-any.whl
Algorithm Hash digest
SHA256 803eca7c467b2cb5cb030611b199f92f9bd84997b885b559b9084eacb2a4a8fc
MD5 149045e1677a475a5eb7e5db7bc84391
BLAKE2b-256 11f485f4b74a4b0b0cf53b162de71881ae16a7c1ac9b49102476891d12ab7234

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