msfiddle 2.2.0__tar.gz → 2.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- msfiddle-2.3.0/PKG-INFO +128 -0
- msfiddle-2.3.0/README.md +87 -0
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle/__init__.py +0 -8
- msfiddle-2.3.0/msfiddle/__main__.py +5 -0
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle/api.py +287 -81
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle/config/fiddle_tcn_casmi.yml +10 -9
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle/config/fiddle_tcn_demo.yml +12 -10
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle/config/fiddle_tcn_demo_wo_da.yml +12 -10
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle/config/fiddle_tcn_embl.yml +29 -22
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle/config/fiddle_tcn_orbitrap.yml +18 -19
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle/config/fiddle_tcn_qtof.yml +24 -26
- msfiddle-2.3.0/msfiddle/config/fiddle_tcn_timstof.yml +142 -0
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle/dataset.py +14 -43
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle/download.py +59 -81
- msfiddle-2.3.0/msfiddle/evaluate.py +152 -0
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle/external_results.py +35 -6
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle/main.py +98 -112
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle/model_tcn.py +17 -0
- msfiddle-2.3.0/msfiddle/settings.py +75 -0
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle/utils/__init__.py +6 -0
- msfiddle-2.3.0/msfiddle/utils/casmi2026.py +231 -0
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle/utils/mol_utils.py +0 -23
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle/utils/msms_utils.py +96 -63
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle/utils/pkl_utils.py +59 -48
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle/utils/refine_utils.py +1 -60
- msfiddle-2.3.0/msfiddle.egg-info/PKG-INFO +128 -0
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle.egg-info/SOURCES.txt +9 -4
- {msfiddle-2.2.0 → msfiddle-2.3.0}/setup.py +1 -1
- {msfiddle-2.2.0 → msfiddle-2.3.0}/tests/test_api.py +153 -71
- msfiddle-2.3.0/tests/test_casmi2026.py +305 -0
- msfiddle-2.3.0/tests/test_config.py +35 -0
- msfiddle-2.3.0/tests/test_download.py +93 -0
- msfiddle-2.3.0/tests/test_evaluate.py +62 -0
- msfiddle-2.3.0/tests/test_external_results.py +209 -0
- msfiddle-2.3.0/tests/test_main.py +43 -0
- msfiddle-2.3.0/tests/test_mol_utils.py +47 -0
- msfiddle-2.3.0/tests/test_msms_utils.py +118 -0
- {msfiddle-2.2.0 → msfiddle-2.3.0}/tests/test_muon.py +4 -25
- msfiddle-2.3.0/tests/test_pkl_utils.py +64 -0
- msfiddle-2.3.0/tests/test_refine_utils.py +130 -0
- msfiddle-2.2.0/PKG-INFO +0 -169
- msfiddle-2.2.0/README.md +0 -128
- msfiddle-2.2.0/msfiddle.egg-info/PKG-INFO +0 -169
- msfiddle-2.2.0/tests/test_download.py +0 -29
- msfiddle-2.2.0/tests/test_external_results.py +0 -282
- msfiddle-2.2.0/tests/test_generate_ms.py +0 -52
- msfiddle-2.2.0/tests/test_main.py +0 -17
- msfiddle-2.2.0/tests/test_mol_utils.py +0 -94
- msfiddle-2.2.0/tests/test_msms_utils.py +0 -86
- msfiddle-2.2.0/tests/test_preprocessing_speedups.py +0 -148
- msfiddle-2.2.0/tests/test_refine_enumeration.py +0 -136
- msfiddle-2.2.0/tests/test_refine_fast_mass.py +0 -106
- msfiddle-2.2.0/tests/test_refine_utils.py +0 -64
- {msfiddle-2.2.0 → msfiddle-2.3.0}/LICENSE +0 -0
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle/demo/input_msms.mgf +0 -0
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle/demo/output_buddy.csv +0 -0
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle/demo/output_fiddle.csv +0 -0
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle/demo/output_fiddle_all.csv +0 -0
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle/demo/output_sirius.csv +0 -0
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle/optim.py +0 -0
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle.egg-info/dependency_links.txt +0 -0
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle.egg-info/entry_points.txt +0 -0
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle.egg-info/requires.txt +0 -0
- {msfiddle-2.2.0 → msfiddle-2.3.0}/msfiddle.egg-info/top_level.txt +0 -0
- {msfiddle-2.2.0 → msfiddle-2.3.0}/setup.cfg +0 -0
msfiddle-2.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: msfiddle
|
|
3
|
+
Version: 2.3.0
|
|
4
|
+
Summary: A package for predicting chemical formulas from tandem mass spectra
|
|
5
|
+
Home-page: https://github.com/JosieHong/FIDDLE
|
|
6
|
+
Author: Yuhui Hong
|
|
7
|
+
Author-email: josieexception@outlook.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering :: Chemistry
|
|
12
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
|
|
15
|
+
Requires-Python: >=3.8
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: numpy<2.0.0,>=1.20.0
|
|
19
|
+
Requires-Dist: pandas>=2.0.0
|
|
20
|
+
Requires-Dist: tqdm>=4.60.0
|
|
21
|
+
Requires-Dist: pyyaml>=6.0
|
|
22
|
+
Requires-Dist: scikit-learn>=1.0.0
|
|
23
|
+
Requires-Dist: scipy>=1.8.0
|
|
24
|
+
Requires-Dist: pyarrow>=10.0.0
|
|
25
|
+
Requires-Dist: rdkit>=2022.03.5
|
|
26
|
+
Requires-Dist: molmass
|
|
27
|
+
Requires-Dist: pyteomics
|
|
28
|
+
Provides-Extra: inference
|
|
29
|
+
Requires-Dist: torch; extra == "inference"
|
|
30
|
+
Dynamic: author
|
|
31
|
+
Dynamic: author-email
|
|
32
|
+
Dynamic: classifier
|
|
33
|
+
Dynamic: description
|
|
34
|
+
Dynamic: description-content-type
|
|
35
|
+
Dynamic: home-page
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
Dynamic: provides-extra
|
|
38
|
+
Dynamic: requires-dist
|
|
39
|
+
Dynamic: requires-python
|
|
40
|
+
Dynamic: summary
|
|
41
|
+
|
|
42
|
+
<p align="center">
|
|
43
|
+
<a href="https://github.com/JosieHong/FIDDLE">
|
|
44
|
+
<picture>
|
|
45
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/JosieHong/FIDDLE/main/img/fiddle-logo-dark@2x.png">
|
|
46
|
+
<img src="https://raw.githubusercontent.com/JosieHong/FIDDLE/main/img/fiddle-logo-light@2x.png" alt="FIDDLE" width="480">
|
|
47
|
+
</picture>
|
|
48
|
+
</a>
|
|
49
|
+
</p>
|
|
50
|
+
|
|
51
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
52
|
+
[](https://doi.org/10.5281/zenodo.19181279)
|
|
53
|
+
[](https://github.com/JosieHong/FIDDLE/releases)
|
|
54
|
+
|
|
55
|
+
FIDDLE predicts molecular formulas from MS/MS spectra with deep learning.
|
|
56
|
+
|
|
57
|
+
**[Paper](https://www.nature.com/articles/s41467-025-66060-9)** · **[Documentation](https://msfiddle.readthedocs.io)** · **[Try the demo on Hugging Face](https://huggingface.co/spaces/J0siee/FIDDLE)**
|
|
58
|
+
|
|
59
|
+
## Quick start
|
|
60
|
+
|
|
61
|
+
Install the [`msfiddle`](https://pypi.org/project/msfiddle/) package, download the pre-trained models once, then predict formulas:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pip install "msfiddle[inference]"
|
|
65
|
+
msfiddle download
|
|
66
|
+
msfiddle predict --demo --result_path demo.csv # 21 bundled example spectra
|
|
67
|
+
|
|
68
|
+
# your own spectra
|
|
69
|
+
msfiddle predict --test_data spectra.mgf --instrument_type orbitrap --result_path results.csv
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
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)`.
|
|
73
|
+
|
|
74
|
+
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`.
|
|
75
|
+
|
|
76
|
+
The [documentation](https://msfiddle.readthedocs.io) covers the Python API, BUDDY and SIRIUS integration, custom checkpoints, all output columns, and [benchmark results](https://msfiddle.readthedocs.io/en/latest/benchmarks.html).
|
|
77
|
+
|
|
78
|
+
## Reproduce the paper
|
|
79
|
+
|
|
80
|
+
This repository also holds the research code for training and evaluation. Run everything from the repository root (`FIDDLE/`).
|
|
81
|
+
|
|
82
|
+
1. Create the environment with [Anaconda](https://docs.anaconda.com/anaconda/install/) (use `environment_mac.yml` on Apple Silicon):
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
conda env create -f environment.yml
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
2. (optional) Install [BUDDY](https://github.com/Philipbear/msbuddy) and [SIRIUS](https://v6.docs.sirius-ms.io/) for the comparison experiments. SIRIUS needs a free account; log in once as `install_sirius.sh` prints at the end.
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
bash running_scripts/install_buddy.sh
|
|
92
|
+
bash running_scripts/install_sirius.sh
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
3. Download the models into `./check_point/`, where the scripts expect them:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
msfiddle download -d ./check_point
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
| Script | Description |
|
|
102
|
+
|---|---|
|
|
103
|
+
| `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` |
|
|
104
|
+
| `running_scripts/experiments_test_benchmark.sh` | Evaluate on external benchmarks (CASMI 2016, CASMI 2017, EMBL-MCF 2.0) |
|
|
105
|
+
| `running_scripts/experiments_test_nist23.sh` | Train and evaluate with compounds new in NIST23 held out |
|
|
106
|
+
| `running_scripts/experiments_test_chimeric.sh` | Evaluate on chimeric spectra |
|
|
107
|
+
| `running_scripts/experiments_test_noised.sh` | Evaluate on spectra with added noise peaks |
|
|
108
|
+
|
|
109
|
+
The benchmark, chimeric and noise experiments use the released models; the chimeric and noise ones also need the data those models were trained on.
|
|
110
|
+
|
|
111
|
+
To train from scratch, see `scripts/train_tcn_gpus_cl.py` and `scripts/train_rescore.py` with the configs in [`msfiddle/config/`](https://github.com/JosieHong/FIDDLE/tree/main/msfiddle/config).
|
|
112
|
+
|
|
113
|
+
## Citation
|
|
114
|
+
|
|
115
|
+
If you use FIDDLE, please cite:
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
@article{hong2025fiddle,
|
|
119
|
+
title={FIDDLE: a deep learning method for chemical formulas prediction from tandem mass spectra},
|
|
120
|
+
author={Hong, Yuhui and Li, Sujun and Ye, Yuzhen and Tang, Haixu},
|
|
121
|
+
journal={Nature Communications},
|
|
122
|
+
volume={16},
|
|
123
|
+
number={1},
|
|
124
|
+
pages={11102},
|
|
125
|
+
year={2025},
|
|
126
|
+
publisher={Nature Publishing Group UK London}
|
|
127
|
+
}
|
|
128
|
+
```
|
msfiddle-2.3.0/README.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://github.com/JosieHong/FIDDLE">
|
|
3
|
+
<picture>
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/JosieHong/FIDDLE/main/img/fiddle-logo-dark@2x.png">
|
|
5
|
+
<img src="https://raw.githubusercontent.com/JosieHong/FIDDLE/main/img/fiddle-logo-light@2x.png" alt="FIDDLE" width="480">
|
|
6
|
+
</picture>
|
|
7
|
+
</a>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
11
|
+
[](https://doi.org/10.5281/zenodo.19181279)
|
|
12
|
+
[](https://github.com/JosieHong/FIDDLE/releases)
|
|
13
|
+
|
|
14
|
+
FIDDLE predicts molecular formulas from MS/MS spectra with deep learning.
|
|
15
|
+
|
|
16
|
+
**[Paper](https://www.nature.com/articles/s41467-025-66060-9)** · **[Documentation](https://msfiddle.readthedocs.io)** · **[Try the demo on Hugging Face](https://huggingface.co/spaces/J0siee/FIDDLE)**
|
|
17
|
+
|
|
18
|
+
## Quick start
|
|
19
|
+
|
|
20
|
+
Install the [`msfiddle`](https://pypi.org/project/msfiddle/) package, download the pre-trained models once, then predict formulas:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install "msfiddle[inference]"
|
|
24
|
+
msfiddle download
|
|
25
|
+
msfiddle predict --demo --result_path demo.csv # 21 bundled example spectra
|
|
26
|
+
|
|
27
|
+
# your own spectra
|
|
28
|
+
msfiddle predict --test_data spectra.mgf --instrument_type orbitrap --result_path results.csv
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
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)`.
|
|
32
|
+
|
|
33
|
+
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`.
|
|
34
|
+
|
|
35
|
+
The [documentation](https://msfiddle.readthedocs.io) covers the Python API, BUDDY and SIRIUS integration, custom checkpoints, all output columns, and [benchmark results](https://msfiddle.readthedocs.io/en/latest/benchmarks.html).
|
|
36
|
+
|
|
37
|
+
## Reproduce the paper
|
|
38
|
+
|
|
39
|
+
This repository also holds the research code for training and evaluation. Run everything from the repository root (`FIDDLE/`).
|
|
40
|
+
|
|
41
|
+
1. Create the environment with [Anaconda](https://docs.anaconda.com/anaconda/install/) (use `environment_mac.yml` on Apple Silicon):
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
conda env create -f environment.yml
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
2. (optional) Install [BUDDY](https://github.com/Philipbear/msbuddy) and [SIRIUS](https://v6.docs.sirius-ms.io/) for the comparison experiments. SIRIUS needs a free account; log in once as `install_sirius.sh` prints at the end.
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
bash running_scripts/install_buddy.sh
|
|
51
|
+
bash running_scripts/install_sirius.sh
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
3. Download the models into `./check_point/`, where the scripts expect them:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
msfiddle download -d ./check_point
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
| Script | Description |
|
|
61
|
+
|---|---|
|
|
62
|
+
| `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` |
|
|
63
|
+
| `running_scripts/experiments_test_benchmark.sh` | Evaluate on external benchmarks (CASMI 2016, CASMI 2017, EMBL-MCF 2.0) |
|
|
64
|
+
| `running_scripts/experiments_test_nist23.sh` | Train and evaluate with compounds new in NIST23 held out |
|
|
65
|
+
| `running_scripts/experiments_test_chimeric.sh` | Evaluate on chimeric spectra |
|
|
66
|
+
| `running_scripts/experiments_test_noised.sh` | Evaluate on spectra with added noise peaks |
|
|
67
|
+
|
|
68
|
+
The benchmark, chimeric and noise experiments use the released models; the chimeric and noise ones also need the data those models were trained on.
|
|
69
|
+
|
|
70
|
+
To train from scratch, see `scripts/train_tcn_gpus_cl.py` and `scripts/train_rescore.py` with the configs in [`msfiddle/config/`](https://github.com/JosieHong/FIDDLE/tree/main/msfiddle/config).
|
|
71
|
+
|
|
72
|
+
## Citation
|
|
73
|
+
|
|
74
|
+
If you use FIDDLE, please cite:
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
@article{hong2025fiddle,
|
|
78
|
+
title={FIDDLE: a deep learning method for chemical formulas prediction from tandem mass spectra},
|
|
79
|
+
author={Hong, Yuhui and Li, Sujun and Ye, Yuzhen and Tang, Haixu},
|
|
80
|
+
journal={Nature Communications},
|
|
81
|
+
volume={16},
|
|
82
|
+
number={1},
|
|
83
|
+
pages={11102},
|
|
84
|
+
year={2025},
|
|
85
|
+
publisher={Nature Publishing Group UK London}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
@@ -30,12 +30,6 @@ def __getattr__(name):
|
|
|
30
30
|
globals()["FormulaEncoder"] = FormulaEncoder
|
|
31
31
|
globals()["RescoreHead"] = RescoreHead
|
|
32
32
|
return globals()[name]
|
|
33
|
-
if name in ("test_step", "rescore_candidates"):
|
|
34
|
-
from .main import rescore_candidates, test_step
|
|
35
|
-
|
|
36
|
-
globals()["test_step"] = test_step
|
|
37
|
-
globals()["rescore_candidates"] = rescore_candidates
|
|
38
|
-
return globals()[name]
|
|
39
33
|
raise AttributeError(f"module 'msfiddle' has no attribute {name!r}")
|
|
40
34
|
|
|
41
35
|
|
|
@@ -52,8 +46,6 @@ __all__ = [
|
|
|
52
46
|
"mass_calculator",
|
|
53
47
|
"vector_to_formula",
|
|
54
48
|
"formula_to_vector",
|
|
55
|
-
"test_step",
|
|
56
|
-
"rescore_candidates",
|
|
57
49
|
"download_models",
|
|
58
50
|
"check_models_exist",
|
|
59
51
|
"get_model_path",
|