msfiddle 2.0.0__tar.gz → 2.0.1__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.
Files changed (43) hide show
  1. msfiddle-2.0.1/PKG-INFO +251 -0
  2. msfiddle-2.0.1/README.md +210 -0
  3. {msfiddle-2.0.0 → msfiddle-2.0.1}/msfiddle/__init__.py +22 -27
  4. msfiddle-2.0.1/msfiddle/api.py +1110 -0
  5. {msfiddle-2.0.0 → msfiddle-2.0.1}/msfiddle/download.py +11 -1
  6. msfiddle-2.0.1/msfiddle/main.py +280 -0
  7. {msfiddle-2.0.0 → msfiddle-2.0.1}/msfiddle/utils/msms_utils.py +2 -2
  8. msfiddle-2.0.1/msfiddle.egg-info/PKG-INFO +251 -0
  9. {msfiddle-2.0.0 → msfiddle-2.0.1}/msfiddle.egg-info/SOURCES.txt +4 -0
  10. {msfiddle-2.0.0 → msfiddle-2.0.1}/msfiddle.egg-info/requires.txt +3 -0
  11. {msfiddle-2.0.0 → msfiddle-2.0.1}/setup.py +5 -2
  12. msfiddle-2.0.1/tests/test_api.py +162 -0
  13. msfiddle-2.0.1/tests/test_download.py +15 -0
  14. msfiddle-2.0.1/tests/test_main.py +17 -0
  15. {msfiddle-2.0.0 → msfiddle-2.0.1}/tests/test_msms_utils.py +1 -0
  16. msfiddle-2.0.0/PKG-INFO +0 -159
  17. msfiddle-2.0.0/README.md +0 -121
  18. msfiddle-2.0.0/msfiddle/main.py +0 -497
  19. msfiddle-2.0.0/msfiddle.egg-info/PKG-INFO +0 -159
  20. {msfiddle-2.0.0 → msfiddle-2.0.1}/LICENSE +0 -0
  21. {msfiddle-2.0.0 → msfiddle-2.0.1}/msfiddle/config/fiddle_tcn_casmi.yml +0 -0
  22. {msfiddle-2.0.0 → msfiddle-2.0.1}/msfiddle/config/fiddle_tcn_demo.yml +0 -0
  23. {msfiddle-2.0.0 → msfiddle-2.0.1}/msfiddle/config/fiddle_tcn_demo_wo_da.yml +0 -0
  24. {msfiddle-2.0.0 → msfiddle-2.0.1}/msfiddle/config/fiddle_tcn_embl.yml +0 -0
  25. {msfiddle-2.0.0 → msfiddle-2.0.1}/msfiddle/config/fiddle_tcn_orbitrap.yml +0 -0
  26. {msfiddle-2.0.0 → msfiddle-2.0.1}/msfiddle/config/fiddle_tcn_qtof.yml +0 -0
  27. {msfiddle-2.0.0 → msfiddle-2.0.1}/msfiddle/dataset.py +0 -0
  28. {msfiddle-2.0.0 → msfiddle-2.0.1}/msfiddle/demo/input_msms.mgf +0 -0
  29. {msfiddle-2.0.0 → msfiddle-2.0.1}/msfiddle/demo/output_buddy.csv +0 -0
  30. {msfiddle-2.0.0 → msfiddle-2.0.1}/msfiddle/demo/output_fiddle.csv +0 -0
  31. {msfiddle-2.0.0 → msfiddle-2.0.1}/msfiddle/demo/output_fiddle_all.csv +0 -0
  32. {msfiddle-2.0.0 → msfiddle-2.0.1}/msfiddle/demo/output_sirius.csv +0 -0
  33. {msfiddle-2.0.0 → msfiddle-2.0.1}/msfiddle/model_tcn.py +0 -0
  34. {msfiddle-2.0.0 → msfiddle-2.0.1}/msfiddle/utils/__init__.py +0 -0
  35. {msfiddle-2.0.0 → msfiddle-2.0.1}/msfiddle/utils/mol_utils.py +0 -0
  36. {msfiddle-2.0.0 → msfiddle-2.0.1}/msfiddle/utils/pkl_utils.py +0 -0
  37. {msfiddle-2.0.0 → msfiddle-2.0.1}/msfiddle/utils/refine_utils.py +0 -0
  38. {msfiddle-2.0.0 → msfiddle-2.0.1}/msfiddle.egg-info/dependency_links.txt +0 -0
  39. {msfiddle-2.0.0 → msfiddle-2.0.1}/msfiddle.egg-info/entry_points.txt +0 -0
  40. {msfiddle-2.0.0 → msfiddle-2.0.1}/msfiddle.egg-info/top_level.txt +0 -0
  41. {msfiddle-2.0.0 → msfiddle-2.0.1}/setup.cfg +0 -0
  42. {msfiddle-2.0.0 → msfiddle-2.0.1}/tests/test_mol_utils.py +0 -0
  43. {msfiddle-2.0.0 → msfiddle-2.0.1}/tests/test_refine_utils.py +0 -0
@@ -0,0 +1,251 @@
1
+ Metadata-Version: 2.4
2
+ Name: msfiddle
3
+ Version: 2.0.1
4
+ Summary: A package for predicting chemical formulas from tandem mass spectra
5
+ Home-page: https://github.com/JosieHong/msfiddle
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
+ # msfiddle
43
+
44
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
45
+ [![PyPI](https://img.shields.io/pypi/v/msfiddle)](https://pypi.org/project/msfiddle/)
46
+ [![Documentation](https://readthedocs.org/projects/msfiddle/badge/?version=latest)](https://msfiddle.readthedocs.io)
47
+
48
+ `msfiddle` is the PyPI package for FIDDLE, a deep learning method for chemical
49
+ formula prediction from tandem mass spectra (MS/MS).
50
+
51
+ ## Highlights
52
+
53
+ * Predict molecular formulas from MS/MS spectra with pre-trained FIDDLE models.
54
+ * Use the package from the command line, from native Python arrays, or from MGF files.
55
+ * Reuse loaded models for efficient batched prediction in Python applications.
56
+ * Incorporate BUDDY and SIRIUS candidate outputs in file-based workflows.
57
+
58
+ Paper: https://www.nature.com/articles/s41467-025-66060-9
59
+
60
+ Documentation: https://msfiddle.readthedocs.io
61
+
62
+ For the full experimental codebase, see https://github.com/JosieHong/FIDDLE.
63
+
64
+ ## Installation
65
+
66
+ ```bash
67
+ pip install msfiddle
68
+ ```
69
+
70
+ PyTorch is required for inference. Install the optional inference extra,
71
+ or install PyTorch separately for your platform:
72
+ ```bash
73
+ pip install "msfiddle[inference]"
74
+ ```
75
+
76
+ See the official PyTorch installation guide for custom CUDA builds:
77
+ https://pytorch.org/get-started/locally/.
78
+
79
+ ## Usage
80
+
81
+ ### Command-line interface
82
+
83
+ Download the pre-trained checkpoints before running predictions:
84
+ ```bash
85
+ # Download models to the default location (~/.msfiddle/check_point)
86
+ msfiddle-download-models
87
+
88
+ # Or specify a custom location and models
89
+ msfiddle-download-models --destination /path/to/models \
90
+ --models fiddle_tcn_qtof fiddle_rescore_qtof
91
+ ```
92
+
93
+ `msfiddle` 2.0.1 reuses the FIDDLE `v2.0.0` checkpoint assets.
94
+
95
+ Run the packaged demo:
96
+ ```bash
97
+ msfiddle --demo --result_path ./output_demo.csv --device 0
98
+ ```
99
+
100
+ Run the demo on CPU:
101
+ ```bash
102
+ msfiddle --demo --result_path ./output_demo.csv --device 0 --no_cuda
103
+ ```
104
+
105
+ Run prediction on your own [MGF file](#mgf-input):
106
+ ```bash
107
+ msfiddle --test_data /path/to/data.mgf \
108
+ --instrument_type orbitrap \
109
+ --result_path /path/to/results.csv \
110
+ --device 0
111
+ ```
112
+
113
+ `--instrument_type` accepts `orbitrap` (default) or `qtof`. If checkpoints are
114
+ missing, the CLI exits with instructions to run `msfiddle-download-models`.
115
+
116
+ ### Python API
117
+
118
+ Use `predict_from_spectrum` for one-off prediction from native MS/MS arrays:
119
+
120
+ ```python
121
+ from msfiddle import predict_from_spectrum
122
+
123
+ candidates = predict_from_spectrum(
124
+ mz_array=[60.0, 85.0, 100.0, 125.0, 150.0],
125
+ intensity_array=[10.0, 50.0, 20.0, 35.0, 15.0],
126
+ precursor_mz=180.063,
127
+ adduct="[M+H]+",
128
+ top_k=5,
129
+ instrument_type="orbitrap",
130
+ collision_energy="Unknown",
131
+ device="cpu",
132
+ )
133
+ ```
134
+
135
+ For repeated or batched prediction, reuse `MsFiddlePredictor` so checkpoints are
136
+ loaded once:
137
+ ```python
138
+ from msfiddle import MsFiddlePredictor
139
+
140
+ predictor = MsFiddlePredictor(instrument_type="orbitrap", device="cpu")
141
+
142
+ results = predictor.predict_batch(
143
+ [
144
+ {
145
+ "id": "sample-1",
146
+ "mz_array": [60.0, 85.0, 100.0, 125.0, 150.0],
147
+ "intensity_array": [10.0, 50.0, 20.0, 35.0, 15.0],
148
+ "precursor_mz": 180.063,
149
+ "adduct": "[M+H]+",
150
+ "collision_energy": "Unknown",
151
+ }
152
+ ]
153
+ )
154
+ ```
155
+
156
+ Python APIs do not download model checkpoints unless `download_models=True` is passed.
157
+
158
+ ## Input and output formats
159
+
160
+ ### CSV output
161
+
162
+ The CLI writes a CSV file with one row per spectrum. Key columns include:
163
+
164
+ | Column | Description |
165
+ | --- | --- |
166
+ | `ID` | Spectrum title from the MGF file. |
167
+ | `Mass` | Neutral mass calculated from precursor m/z and adduct. |
168
+ | `Pred Formula` | Initial formula predicted by the neural model. |
169
+ | `Pred Mass` | Model-predicted mass. |
170
+ | `Pred Atom Num` | Model-predicted atom count. |
171
+ | `Pred H/C Num` | Model-predicted H/C count. |
172
+ | `Refined Formula (0..4)` | Ranked refined formula candidates for the default top-5 output. |
173
+ | `Refined Mass (0..4)` | Masses for the default top-5 refined candidates. |
174
+ | `Rescore (0..4)` | Confidence scores for the default top-5 refined candidates. |
175
+
176
+ ### API output
177
+
178
+ The Python `predict_from_spectrum()` API returns a list of candidate dictionaries:
179
+ ```python
180
+ [
181
+ {
182
+ "formula": "C8H10O",
183
+ "score": 0.94,
184
+ "mass": 122.073,
185
+ "metadata": {...},
186
+ }
187
+ ]
188
+ ```
189
+
190
+ `predict_batch()` returns one record per input spectrum with `id`, `candidates`,
191
+ and `metadata`.
192
+
193
+ ### MGF input
194
+
195
+ The required MGF fields are `TITLE`, `PRECURSOR_MZ`, `PRECURSOR_TYPE`, and
196
+ `COLLISION_ENERGY`:
197
+ ```mgf
198
+ BEGIN IONS
199
+ TITLE=EMBL_MCF_2_0_HRMS_Library000529
200
+ PEPMASS=111.02016
201
+ CHARGE=1-
202
+ PRECURSOR_TYPE=[M-H]-
203
+ PRECURSOR_MZ=111.02016
204
+ COLLISION_ENERGY=50.0
205
+ SMILES=[H]c1c([H])n([H])c(=O)n([H])c1=O
206
+ FORMULA=C4H4N2O2
207
+ THEORETICAL_PRECURSOR_MZ=111.019453
208
+ PPM=6.368253318682487
209
+ SIMULATED_PRECURSOR_MZ=111.01946768634916
210
+ 41.0148 0.329893
211
+ 41.9986 89.226766
212
+ 55.8055 0.200544
213
+ 56.2625 0.194617
214
+ 67.0304 0.330612
215
+ 68.0258 0.402906
216
+ 111.0203 100.0
217
+ 112.0515 1.2809
218
+ END IONS
219
+ ```
220
+
221
+ ## Advanced Usage
222
+
223
+ Inspect checkpoint paths:
224
+ ```bash
225
+ msfiddle-checkpoint-paths
226
+ ```
227
+
228
+ Use custom config and checkpoint paths:
229
+ ```bash
230
+ msfiddle --test_data /path/to/data.mgf \
231
+ --config_path /path/to/config.yml \
232
+ --resume_path /path/to/tcn_model.pt \
233
+ --rescore_resume_path /path/to/rescore_model.pt \
234
+ --result_path /path/to/results.csv \
235
+ --device 0
236
+ ```
237
+
238
+ ## Citation
239
+
240
+ ```
241
+ @article{hong2025fiddle,
242
+ title={FIDDLE: a deep learning method for chemical formulas prediction from tandem mass spectra},
243
+ author={Hong, Yuhui and Li, Sujun and Ye, Yuzhen and Tang, Haixu},
244
+ journal={Nature Communications},
245
+ volume={16},
246
+ number={1},
247
+ pages={11102},
248
+ year={2025},
249
+ publisher={Nature Publishing Group UK London}
250
+ }
251
+ ```
@@ -0,0 +1,210 @@
1
+ # msfiddle
2
+
3
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
4
+ [![PyPI](https://img.shields.io/pypi/v/msfiddle)](https://pypi.org/project/msfiddle/)
5
+ [![Documentation](https://readthedocs.org/projects/msfiddle/badge/?version=latest)](https://msfiddle.readthedocs.io)
6
+
7
+ `msfiddle` is the PyPI package for FIDDLE, a deep learning method for chemical
8
+ formula prediction from tandem mass spectra (MS/MS).
9
+
10
+ ## Highlights
11
+
12
+ * Predict molecular formulas from MS/MS spectra with pre-trained FIDDLE models.
13
+ * Use the package from the command line, from native Python arrays, or from MGF files.
14
+ * Reuse loaded models for efficient batched prediction in Python applications.
15
+ * Incorporate BUDDY and SIRIUS candidate outputs in file-based workflows.
16
+
17
+ Paper: https://www.nature.com/articles/s41467-025-66060-9
18
+
19
+ Documentation: https://msfiddle.readthedocs.io
20
+
21
+ For the full experimental codebase, see https://github.com/JosieHong/FIDDLE.
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ pip install msfiddle
27
+ ```
28
+
29
+ PyTorch is required for inference. Install the optional inference extra,
30
+ or install PyTorch separately for your platform:
31
+ ```bash
32
+ pip install "msfiddle[inference]"
33
+ ```
34
+
35
+ See the official PyTorch installation guide for custom CUDA builds:
36
+ https://pytorch.org/get-started/locally/.
37
+
38
+ ## Usage
39
+
40
+ ### Command-line interface
41
+
42
+ Download the pre-trained checkpoints before running predictions:
43
+ ```bash
44
+ # Download models to the default location (~/.msfiddle/check_point)
45
+ msfiddle-download-models
46
+
47
+ # Or specify a custom location and models
48
+ msfiddle-download-models --destination /path/to/models \
49
+ --models fiddle_tcn_qtof fiddle_rescore_qtof
50
+ ```
51
+
52
+ `msfiddle` 2.0.1 reuses the FIDDLE `v2.0.0` checkpoint assets.
53
+
54
+ Run the packaged demo:
55
+ ```bash
56
+ msfiddle --demo --result_path ./output_demo.csv --device 0
57
+ ```
58
+
59
+ Run the demo on CPU:
60
+ ```bash
61
+ msfiddle --demo --result_path ./output_demo.csv --device 0 --no_cuda
62
+ ```
63
+
64
+ Run prediction on your own [MGF file](#mgf-input):
65
+ ```bash
66
+ msfiddle --test_data /path/to/data.mgf \
67
+ --instrument_type orbitrap \
68
+ --result_path /path/to/results.csv \
69
+ --device 0
70
+ ```
71
+
72
+ `--instrument_type` accepts `orbitrap` (default) or `qtof`. If checkpoints are
73
+ missing, the CLI exits with instructions to run `msfiddle-download-models`.
74
+
75
+ ### Python API
76
+
77
+ Use `predict_from_spectrum` for one-off prediction from native MS/MS arrays:
78
+
79
+ ```python
80
+ from msfiddle import predict_from_spectrum
81
+
82
+ candidates = predict_from_spectrum(
83
+ mz_array=[60.0, 85.0, 100.0, 125.0, 150.0],
84
+ intensity_array=[10.0, 50.0, 20.0, 35.0, 15.0],
85
+ precursor_mz=180.063,
86
+ adduct="[M+H]+",
87
+ top_k=5,
88
+ instrument_type="orbitrap",
89
+ collision_energy="Unknown",
90
+ device="cpu",
91
+ )
92
+ ```
93
+
94
+ For repeated or batched prediction, reuse `MsFiddlePredictor` so checkpoints are
95
+ loaded once:
96
+ ```python
97
+ from msfiddle import MsFiddlePredictor
98
+
99
+ predictor = MsFiddlePredictor(instrument_type="orbitrap", device="cpu")
100
+
101
+ results = predictor.predict_batch(
102
+ [
103
+ {
104
+ "id": "sample-1",
105
+ "mz_array": [60.0, 85.0, 100.0, 125.0, 150.0],
106
+ "intensity_array": [10.0, 50.0, 20.0, 35.0, 15.0],
107
+ "precursor_mz": 180.063,
108
+ "adduct": "[M+H]+",
109
+ "collision_energy": "Unknown",
110
+ }
111
+ ]
112
+ )
113
+ ```
114
+
115
+ Python APIs do not download model checkpoints unless `download_models=True` is passed.
116
+
117
+ ## Input and output formats
118
+
119
+ ### CSV output
120
+
121
+ The CLI writes a CSV file with one row per spectrum. Key columns include:
122
+
123
+ | Column | Description |
124
+ | --- | --- |
125
+ | `ID` | Spectrum title from the MGF file. |
126
+ | `Mass` | Neutral mass calculated from precursor m/z and adduct. |
127
+ | `Pred Formula` | Initial formula predicted by the neural model. |
128
+ | `Pred Mass` | Model-predicted mass. |
129
+ | `Pred Atom Num` | Model-predicted atom count. |
130
+ | `Pred H/C Num` | Model-predicted H/C count. |
131
+ | `Refined Formula (0..4)` | Ranked refined formula candidates for the default top-5 output. |
132
+ | `Refined Mass (0..4)` | Masses for the default top-5 refined candidates. |
133
+ | `Rescore (0..4)` | Confidence scores for the default top-5 refined candidates. |
134
+
135
+ ### API output
136
+
137
+ The Python `predict_from_spectrum()` API returns a list of candidate dictionaries:
138
+ ```python
139
+ [
140
+ {
141
+ "formula": "C8H10O",
142
+ "score": 0.94,
143
+ "mass": 122.073,
144
+ "metadata": {...},
145
+ }
146
+ ]
147
+ ```
148
+
149
+ `predict_batch()` returns one record per input spectrum with `id`, `candidates`,
150
+ and `metadata`.
151
+
152
+ ### MGF input
153
+
154
+ The required MGF fields are `TITLE`, `PRECURSOR_MZ`, `PRECURSOR_TYPE`, and
155
+ `COLLISION_ENERGY`:
156
+ ```mgf
157
+ BEGIN IONS
158
+ TITLE=EMBL_MCF_2_0_HRMS_Library000529
159
+ PEPMASS=111.02016
160
+ CHARGE=1-
161
+ PRECURSOR_TYPE=[M-H]-
162
+ PRECURSOR_MZ=111.02016
163
+ COLLISION_ENERGY=50.0
164
+ SMILES=[H]c1c([H])n([H])c(=O)n([H])c1=O
165
+ FORMULA=C4H4N2O2
166
+ THEORETICAL_PRECURSOR_MZ=111.019453
167
+ PPM=6.368253318682487
168
+ SIMULATED_PRECURSOR_MZ=111.01946768634916
169
+ 41.0148 0.329893
170
+ 41.9986 89.226766
171
+ 55.8055 0.200544
172
+ 56.2625 0.194617
173
+ 67.0304 0.330612
174
+ 68.0258 0.402906
175
+ 111.0203 100.0
176
+ 112.0515 1.2809
177
+ END IONS
178
+ ```
179
+
180
+ ## Advanced Usage
181
+
182
+ Inspect checkpoint paths:
183
+ ```bash
184
+ msfiddle-checkpoint-paths
185
+ ```
186
+
187
+ Use custom config and checkpoint paths:
188
+ ```bash
189
+ msfiddle --test_data /path/to/data.mgf \
190
+ --config_path /path/to/config.yml \
191
+ --resume_path /path/to/tcn_model.pt \
192
+ --rescore_resume_path /path/to/rescore_model.pt \
193
+ --result_path /path/to/results.csv \
194
+ --device 0
195
+ ```
196
+
197
+ ## Citation
198
+
199
+ ```
200
+ @article{hong2025fiddle,
201
+ title={FIDDLE: a deep learning method for chemical formulas prediction from tandem mass spectra},
202
+ author={Hong, Yuhui and Li, Sujun and Ye, Yuzhen and Tang, Haixu},
203
+ journal={Nature Communications},
204
+ volume={16},
205
+ number={1},
206
+ pages={11102},
207
+ year={2025},
208
+ publisher={Nature Publishing Group UK London}
209
+ }
210
+ ```
@@ -2,8 +2,14 @@
2
2
  msfiddle: A package for predicting chemical formulas from tandem mass spectra
3
3
  """
4
4
 
5
- __version__ = "0.1.0"
6
-
5
+ __version__ = "2.0.1"
6
+
7
+ from .api import (
8
+ MsFiddlePredictor,
9
+ predict_batch_from_spectra,
10
+ predict_from_mgf,
11
+ predict_from_spectrum,
12
+ )
7
13
  from .utils.mol_utils import vector_to_formula, formula_to_vector
8
14
  from .utils.msms_utils import mass_calculator
9
15
  from .utils.refine_utils import formula_refinement
@@ -12,48 +18,37 @@ from .download import check_models_exist, download_models, get_model_path
12
18
 
13
19
  def __getattr__(name):
14
20
  """Lazy-load torch-dependent components only when accessed."""
15
- if name in ("MS2FNet_tcn", "FDRNet"):
16
- from .model_tcn import MS2FNet_tcn, FDRNet
21
+ if name in ("MS2FNet_tcn", "FormulaEncoder", "RescoreHead"):
22
+ from .model_tcn import FormulaEncoder, MS2FNet_tcn, RescoreHead
17
23
 
18
24
  globals()["MS2FNet_tcn"] = MS2FNet_tcn
19
- globals()["FDRNet"] = FDRNet
25
+ globals()["FormulaEncoder"] = FormulaEncoder
26
+ globals()["RescoreHead"] = RescoreHead
20
27
  return globals()[name]
21
- if name in ("test_step", "rerank_by_fdr"):
22
- from .main import test_step, rerank_by_fdr
28
+ if name in ("test_step", "rescore_candidates"):
29
+ from .main import rescore_candidates, test_step
23
30
 
24
31
  globals()["test_step"] = test_step
25
- globals()["rerank_by_fdr"] = rerank_by_fdr
32
+ globals()["rescore_candidates"] = rescore_candidates
26
33
  return globals()[name]
27
34
  raise AttributeError(f"module 'msfiddle' has no attribute {name!r}")
28
35
 
29
36
 
30
- # Check if models are available and print a message if not
31
- import os
32
- import warnings
33
- import sys
34
-
35
- # Skip the warning if we're running the download command
36
- is_download_command = any("download-models" in arg for arg in sys.argv)
37
-
38
- if not is_download_command and not check_models_exist():
39
- warnings.warn(
40
- "Pre-trained models not found. To download them, run:\n"
41
- " msfiddle-download-models\n\n"
42
- "Or from Python:\n"
43
- " from msfiddle import download_models\n"
44
- " download_models()"
45
- )
46
-
47
37
  __all__ = [
48
38
  "__version__",
39
+ "MsFiddlePredictor",
40
+ "predict_from_spectrum",
41
+ "predict_batch_from_spectra",
42
+ "predict_from_mgf",
49
43
  "MS2FNet_tcn",
50
- "FDRNet",
44
+ "FormulaEncoder",
45
+ "RescoreHead",
51
46
  "formula_refinement",
52
47
  "mass_calculator",
53
48
  "vector_to_formula",
54
49
  "formula_to_vector",
55
50
  "test_step",
56
- "rerank_by_fdr",
51
+ "rescore_candidates",
57
52
  "download_models",
58
53
  "check_models_exist",
59
54
  "get_model_path",