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.5.sh Build the data, train the release models (TCN and rescore) for Q-TOF, Orbitrap and timsTOF and evaluate them; INSTRUMENTS=timstof runs one of them. As in the paper, the precursor m/z of NIST20 and NIST23, computed from the structure, is replaced by the theoretical m/z plus a seeded Gaussian error. 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.5.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.5.0
File Size Uploaded Provenance Actions
msfiddle-2.5.0.tar.gz 105.5 kB Without provenance Details for msfiddle-2.5.0.tar.gz

Built distribution (wheel)

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

Total release size: 207.0 kB

Release files / msfiddle-2.5.0.tar.gz

Download URL msfiddle-2.5.0.tar.gz
Size 105.5 kB
Tags Source
SHA-256 checksum
How to use checksums
1c9c170e24fe8efcda21ae9e0d607d833d922e6e02396185addcd388e72194f7
BLAKE2b-256 checksum
How to use checksums
5654e215412664819e8a462397906b63dce6c86cae36bc24ac32000c37c0d4cd
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.5.0-py3-none-any.whl

Download URL msfiddle-2.5.0-py3-none-any.whl
Size 101.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
35bd9b5af00a173c1dbf0170ef2e8ebd83f8c784fd07a73d6faba1be01ab1be0
BLAKE2b-256 checksum
How to use checksums
af75b0dc40b4076d5bb358a1264503919e0e28352033f085fc8b1fe29d82a4ed
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.5.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