Skip to main content

FIDDLE

License DOI Release

FIDDLE is a deep learning method for predicting molecular formulas from MS/MS spectra. This repository contains the full research codebase for model training, evaluation, and paper reproduction, plus the msfiddle PyPI package (in ./msfiddle/) for inference-only use.


Breaking change (v2.0.0): The rescore model has been redesigned (Siamese architecture), see details in CHANGELOG.md.

Set up

Requirements

  1. Install Anaconda, if not already installed.

  2. Create the environment with the necessary packages:

conda env create -f environment.yml

On Apple Silicon (macOS ARM64), use environment_mac.yml instead.

  1. (optional) Install BUDDY and SIRIUS following the respective installation instructions provided in each tool's documentation.

Pre-trained Model Weights

To use the pre-trained models, please use the following scripts to download the weights from the release page and place them in the ./check_point/ directory:

  • Orbitrap models:
    • fiddle_tcn_orbitrap.pt: formula prediction model on Orbitrap spectra
    • fiddle_rescore_orbitrap.pt: rescore model on Orbitrap spectra
  • Q-TOF models:
    • fiddle_tcn_qtof.pt: formula prediction model on Q-TOF spectra
    • fiddle_rescore_qtof.pt: rescore model on Q-TOF spectra
bash ./running_scripts/download_models.sh

Usage

The input format is mgf, where title, precursor_mz, precursor_type, collision_energy fields are required. Here, we sampled 21 spectra from the EMBL-MCF 2.0 dataset as an example.

BEGIN IONS
TITLE=EMBL_MCF_2_0_HRMS_Library000531
PEPMASS=129.01941
CHARGE=1-
PRECURSOR_TYPE=[M-H]-
PRECURSOR_MZ=129.01941
COLLISION_ENERGY=50.0
SMILES=[H]OC(=O)C([H])=C(C(=O)O[H])C([H])([H])[H]
FORMULA=C5H6O4
THEORETICAL_PRECURSOR_MZ=129.018785
PPM=4.844255818912111
SIMULATED_PRECURSOR_MZ=129.02032113281717
41.2041 0.410228
55.7698 0.503672
56.8647 0.461943
85.0296 100.0
129.0196 8.036902
END IONS

Run FIDDLE!

python scripts/run_fiddle.py --test_data ./msfiddle/demo/input_msms.mgf \
                    --config_path ./msfiddle/config/fiddle_tcn_orbitrap.yml \
                    --resume_path ./check_point/fiddle_tcn_orbitrap.pt \
                    --rescore_resume_path ./check_point/fiddle_rescore_orbitrap.pt \
                    --result_path ./msfiddle/demo/output_fiddle.csv --device 0

If you'd like to integrate the results from SIRIUS and BUDDY, please organize the results in the format shown in ./msfiddle/demo/buddy_output.csv and ./msfiddle/demo/sirius_output.csv, and provide them to run FIDDLE:

python scripts/run_fiddle.py --test_data ./msfiddle/demo/input_msms.mgf \
                    --config_path ./msfiddle/config/fiddle_tcn_orbitrap.yml \
                    --resume_path ./check_point/fiddle_tcn_orbitrap.pt \
                    --rescore_resume_path ./check_point/fiddle_rescore_orbitrap.pt \
                    --buddy_path ./msfiddle/demo/output_buddy.csv \
                    --sirius_path ./msfiddle/demo/output_sirius.csv \
                    --result_path ./msfiddle/demo/output_fiddle_all.csv --device 0

See scripts/test_caffeine.py for a worked example running FIDDLE on a caffeine Orbitrap spectrum fetched live from GNPS.

Reproduce paper results

All scripts should be run from the repository root (FIDDLE/).

Script Description
running_scripts/experiments_test_benchmark.sh Evaluate on external benchmarks (CASMI 2016, CASMI 2017, EMBL-MCF 2.0)
running_scripts/experiments_test_nist23.sh Evaluate on NIST23
running_scripts/experiments_test_chimeric.sh Evaluate on chimeric spectra
running_scripts/experiments_test_noised.sh Evaluate under noise conditions
running_scripts/experiments_ablation_study.sh Run ablation study
running_scripts/experiments_demo.sh Run demo experiment
running_scripts/train_released_models.sh Train TCN and rescore models for both Orbitrap and Q-TOF

For training from scratch, see the train scripts (scripts/train_tcn_gpus.py, scripts/train_tcn_gpus_cl.py, scripts/train_rescore.py) and the corresponding config files in ./msfiddle/config/.

Citation

@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.2.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.2.0
File Size Uploaded Provenance
msfiddle-2.2.0.tar.gz 80.0 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 159.3 kB

Release files / msfiddle-2.2.0.tar.gz

Download URL msfiddle-2.2.0.tar.gz
Size 80.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6c4f88efbaed6bd6bfa17b75889234dd31d192363d41b9ada52a224b74ee6ceb
BLAKE2b-256 checksum
How to use checksums
1e5457a3dd738e7abac216ade8f4a6d00f6baa13a6152fef3e5019dddb4e6c86
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.2.0-py3-none-any.whl

Download URL msfiddle-2.2.0-py3-none-any.whl
Size 79.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa43d9796c98980dcf9d04d7a6da8e4a010133554d39b72a32bc5b708c23730e
BLAKE2b-256 checksum
How to use checksums
451c1a610c96a6b67fa5342b2f6677ee77e7ef81f109f1b72910ca418b6a1571
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.2.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