Skip to main content

FIDDLE

License DOI Release

FIDDLE predicts molecular formulas from MS/MS spectra with deep learning.

Paper · Documentation · Try the demo on Hugging Face

Quick start

Install the msfiddle package, download the pre-trained models once, then predict formulas:

pip install "msfiddle[inference]"
msfiddle download
msfiddle predict --demo --result_path demo.csv        # 21 bundled example spectra

# your own spectra
msfiddle predict --test_data spectra.mgf --instrument_type orbitrap --result_path results.csv

The inference extra installs PyTorch. For a particular PyTorch build (another CUDA version, CPU only), install it from pytorch.org first, then pip install msfiddle.

Use --instrument_type qtof for Q-TOF data and --instrument_type timstof for timsTOF data. Each spectrum needs TITLE, PRECURSOR_MZ, PRECURSOR_TYPE and COLLISION_ENERGY. The results list ranked candidates per spectrum in Refined Formula (0), Refined Formula (1), … with their scores in Rescore (k).

When the true formulas are known (a SMILES or FORMULA field in each spectrum), add --eval to also report top-k accuracy, saved as results_eval.csv. msfiddle validate --test_data your.mgf checks a file without the models and says why any spectrum would be skipped; if accuracy is lower than expected, see troubleshooting.

The documentation covers the Python API, BUDDY and SIRIUS integration, custom checkpoints, all output columns, and benchmark results.

Reproduce the paper

This repository also holds the research code for training and evaluation. Run everything from the repository root (FIDDLE/).

  1. Create the environment with Anaconda (use environment_mac.yml on Apple Silicon):
conda env create -f environment.yml
  1. (optional) Install BUDDY and SIRIUS for the comparison experiments. SIRIUS needs a free account; log in once as install_sirius.sh prints at the end.
bash running_scripts/install_buddy.sh
bash running_scripts/install_sirius.sh
  1. Download the models into ./check_point/, where the scripts expect them:
msfiddle download -d ./check_point
Script Description
running_scripts/train_release_v2.4.sh As train_release_v2.3.sh, but as in the paper the theoretical precursor m/z of NIST20 and NIST23 is replaced by the theoretical m/z plus a seeded Gaussian error within the instrument's tolerance; trains one instrument after another on two GPUs
running_scripts/train_release_v2.3.sh Build the data, train the release models (TCN and rescore) for Q-TOF, Orbitrap and timsTOF in parallel and evaluate them; INSTRUMENTS=timstof runs one of them. timsTOF trains on the Enveda CASMI 2026 library at data/origin/casmi2026/train.parquet
running_scripts/experiments_test_benchmark.sh Evaluate on external benchmarks (CASMI 2016, CASMI 2017, EMBL-MCF 2.0)
running_scripts/experiments_test_nist23.sh Train and evaluate with compounds new in NIST23 held out
running_scripts/experiments_test_chimeric.sh Evaluate on chimeric spectra
running_scripts/experiments_test_noised.sh Evaluate on spectra with added noise peaks

The benchmark, chimeric and noise experiments use the released models; the chimeric and noise ones also need the data those models were trained on.

To train from scratch, see scripts/train_tcn_gpus_cl.py and scripts/train_rescore.py with the configs in msfiddle/config/.

Citation

If you use FIDDLE, please cite:

@article{hong2025fiddle,
  title={FIDDLE: a deep learning method for chemical formulas prediction from tandem mass spectra},
  author={Hong, Yuhui and Li, Sujun and Ye, Yuzhen and Tang, Haixu},
  journal={Nature Communications},
  volume={16},
  number={1},
  pages={11102},
  year={2025},
  publisher={Nature Publishing Group UK London}
}

Metadata

Release files for msfiddle 2.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for msfiddle 2.4.0
File Size Uploaded Provenance Actions
msfiddle-2.4.0.tar.gz 103.1 kB Without provenance Details for msfiddle-2.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for msfiddle 2.4.0
File Interpreter ABI Platform Actions
msfiddle-2.4.0-py3-none-any.whl Python 3 none any Details for msfiddle-2.4.0-py3-none-any.whl

Total release size: 203.2 kB

Release files / msfiddle-2.4.0.tar.gz

Download URL msfiddle-2.4.0.tar.gz
Size 103.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ab0490633fea081894183e31a8ae7cbefb64f4c74e8f72bc1e04fec2f18bc1e5
BLAKE2b-256 checksum
How to use checksums
61c98ecfb142327bba1bfecee2b2ef821ef29890029d5a5ec07044c5e39b139f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.22

Release files / msfiddle-2.4.0-py3-none-any.whl

Download URL msfiddle-2.4.0-py3-none-any.whl
Size 100.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
829d2576db9b10c285058466e4c7de708e5668040dce1f313c14c7bd86a88d9b
BLAKE2b-256 checksum
How to use checksums
af4d3f40dd307121294d1af43676562f2f71506fff9ee4186e531e47af6a4603
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.22

Security for msfiddle 2.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page