spec2function 0.1.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.
- spec2function-0.1.1/LICENSE +21 -0
- spec2function-0.1.1/PKG-INFO +91 -0
- spec2function-0.1.1/README.md +62 -0
- spec2function-0.1.1/Spec2Function/MS2BioTextDataset.py +3159 -0
- spec2function-0.1.1/Spec2Function/__init__.py +17 -0
- spec2function-0.1.1/Spec2Function/assets.py +74 -0
- spec2function-0.1.1/Spec2Function/biotext_processor.py +380 -0
- spec2function-0.1.1/Spec2Function/config.py +118 -0
- spec2function-0.1.1/Spec2Function/data_augmentation.py +354 -0
- spec2function-0.1.1/Spec2Function/gpt_inference.py +739 -0
- spec2function-0.1.1/Spec2Function/llm_client.py +114 -0
- spec2function-0.1.1/Spec2Function/model/MS2BioText.py +522 -0
- spec2function-0.1.1/Spec2Function/model/MSBERT.py +261 -0
- spec2function-0.1.1/Spec2Function/model/__init__.py +56 -0
- spec2function-0.1.1/Spec2Function/model/config.py +249 -0
- spec2function-0.1.1/Spec2Function/model/utils.py +167 -0
- spec2function-0.1.1/Spec2Function/model_manager.py +1102 -0
- spec2function-0.1.1/Spec2Function/pubmed.py +251 -0
- spec2function-0.1.1/Spec2Function/read_raw_data.py +154 -0
- spec2function-0.1.1/Spec2Function/utils.py +216 -0
- spec2function-0.1.1/Spec2Function/workflow.py +233 -0
- spec2function-0.1.1/pyproject.toml +3 -0
- spec2function-0.1.1/setup.cfg +4 -0
- spec2function-0.1.1/setup.py +35 -0
- spec2function-0.1.1/spec2function.egg-info/PKG-INFO +91 -0
- spec2function-0.1.1/spec2function.egg-info/SOURCES.txt +27 -0
- spec2function-0.1.1/spec2function.egg-info/dependency_links.txt +1 -0
- spec2function-0.1.1/spec2function.egg-info/requires.txt +8 -0
- spec2function-0.1.1/spec2function.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MS2Function contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: spec2function
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Deep learning model for MS2 data annotation
|
|
5
|
+
Home-page: https://huggingface.co/cgxjdzz/ms2function-assets
|
|
6
|
+
Author: User
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.8
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: torch
|
|
13
|
+
Requires-Dist: transformers
|
|
14
|
+
Requires-Dist: numpy
|
|
15
|
+
Requires-Dist: pandas
|
|
16
|
+
Requires-Dist: scikit-learn
|
|
17
|
+
Requires-Dist: tqdm
|
|
18
|
+
Requires-Dist: wandb
|
|
19
|
+
Requires-Dist: huggingface_hub
|
|
20
|
+
Dynamic: author
|
|
21
|
+
Dynamic: classifier
|
|
22
|
+
Dynamic: description
|
|
23
|
+
Dynamic: description-content-type
|
|
24
|
+
Dynamic: home-page
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
Dynamic: requires-dist
|
|
27
|
+
Dynamic: requires-python
|
|
28
|
+
Dynamic: summary
|
|
29
|
+
|
|
30
|
+
# Spec2Function
|
|
31
|
+
|
|
32
|
+
Spec2Function provides MS2 spectrum annotation and metabolite set analysis powered by
|
|
33
|
+
MS2BioText models. Large model/data assets are hosted on Hugging Face Hub and are
|
|
34
|
+
downloaded automatically on first use.
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install spec2function
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Or for local development:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install -e .
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Assets (Hugging Face Hub)
|
|
49
|
+
|
|
50
|
+
Default asset repo: `cgxjdzz/spec2function-assets`
|
|
51
|
+
|
|
52
|
+
The package looks for the following files:
|
|
53
|
+
|
|
54
|
+
- `models/best_model.pth`
|
|
55
|
+
- `models/config.json`
|
|
56
|
+
- `data/hmdb_subsections_WITH_NAME.jsonl`
|
|
57
|
+
- `data/all_jsonl_embeddings.pt`
|
|
58
|
+
|
|
59
|
+
Environment overrides:
|
|
60
|
+
|
|
61
|
+
- `MS2FUNCTION_ASSET_DIR` (use local assets directory)
|
|
62
|
+
- `MS2FUNCTION_ASSET_REPO` (override HF repo id)
|
|
63
|
+
- `HUGGINGFACE_HUB_TOKEN` or `HF_TOKEN` (for private repos)
|
|
64
|
+
|
|
65
|
+
## Quickstart (single spectrum)
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
from pathlib import Path
|
|
69
|
+
from Spec2Function import run_single
|
|
70
|
+
|
|
71
|
+
json_input = {
|
|
72
|
+
"peaks": [[100.1, 200.0], [150.2, 300.0]],
|
|
73
|
+
"precursor_mz": 250.3,
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
result = run_single(json_input, project_root=Path(r"d:\NTU\Spec2Function"))
|
|
77
|
+
print(result)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Quickstart (metabolite set)
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from pathlib import Path
|
|
84
|
+
from Spec2Function import run_set
|
|
85
|
+
|
|
86
|
+
result = run_set(
|
|
87
|
+
r"d:\path\to\your.csv",
|
|
88
|
+
project_root=Path(r"d:\NTU\Spec2Function"),
|
|
89
|
+
)
|
|
90
|
+
print(result)
|
|
91
|
+
```
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Spec2Function
|
|
2
|
+
|
|
3
|
+
Spec2Function provides MS2 spectrum annotation and metabolite set analysis powered by
|
|
4
|
+
MS2BioText models. Large model/data assets are hosted on Hugging Face Hub and are
|
|
5
|
+
downloaded automatically on first use.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install spec2function
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or for local development:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install -e .
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Assets (Hugging Face Hub)
|
|
20
|
+
|
|
21
|
+
Default asset repo: `cgxjdzz/spec2function-assets`
|
|
22
|
+
|
|
23
|
+
The package looks for the following files:
|
|
24
|
+
|
|
25
|
+
- `models/best_model.pth`
|
|
26
|
+
- `models/config.json`
|
|
27
|
+
- `data/hmdb_subsections_WITH_NAME.jsonl`
|
|
28
|
+
- `data/all_jsonl_embeddings.pt`
|
|
29
|
+
|
|
30
|
+
Environment overrides:
|
|
31
|
+
|
|
32
|
+
- `MS2FUNCTION_ASSET_DIR` (use local assets directory)
|
|
33
|
+
- `MS2FUNCTION_ASSET_REPO` (override HF repo id)
|
|
34
|
+
- `HUGGINGFACE_HUB_TOKEN` or `HF_TOKEN` (for private repos)
|
|
35
|
+
|
|
36
|
+
## Quickstart (single spectrum)
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from pathlib import Path
|
|
40
|
+
from Spec2Function import run_single
|
|
41
|
+
|
|
42
|
+
json_input = {
|
|
43
|
+
"peaks": [[100.1, 200.0], [150.2, 300.0]],
|
|
44
|
+
"precursor_mz": 250.3,
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
result = run_single(json_input, project_root=Path(r"d:\NTU\Spec2Function"))
|
|
48
|
+
print(result)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Quickstart (metabolite set)
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from pathlib import Path
|
|
55
|
+
from Spec2Function import run_set
|
|
56
|
+
|
|
57
|
+
result = run_set(
|
|
58
|
+
r"d:\path\to\your.csv",
|
|
59
|
+
project_root=Path(r"d:\NTU\Spec2Function"),
|
|
60
|
+
)
|
|
61
|
+
print(result)
|
|
62
|
+
```
|