enzymehunter 0.1.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.
Files changed (28) hide show
  1. enzymehunter-0.1.0/PKG-INFO +271 -0
  2. enzymehunter-0.1.0/README.md +241 -0
  3. enzymehunter-0.1.0/pyproject.toml +49 -0
  4. enzymehunter-0.1.0/setup.cfg +4 -0
  5. enzymehunter-0.1.0/src/enzymehunter/__init__.py +11 -0
  6. enzymehunter-0.1.0/src/enzymehunter/__main__.py +5 -0
  7. enzymehunter-0.1.0/src/enzymehunter/api.py +69 -0
  8. enzymehunter-0.1.0/src/enzymehunter/cli.py +93 -0
  9. enzymehunter-0.1.0/src/enzymehunter/contact_map_pdb.py +222 -0
  10. enzymehunter-0.1.0/src/enzymehunter/dataloader.py +132 -0
  11. enzymehunter-0.1.0/src/enzymehunter/device.py +45 -0
  12. enzymehunter-0.1.0/src/enzymehunter/distance_map.py +127 -0
  13. enzymehunter-0.1.0/src/enzymehunter/evaluate.py +263 -0
  14. enzymehunter-0.1.0/src/enzymehunter/extract.py +134 -0
  15. enzymehunter-0.1.0/src/enzymehunter/hf_assets.py +84 -0
  16. enzymehunter-0.1.0/src/enzymehunter/infer.py +81 -0
  17. enzymehunter-0.1.0/src/enzymehunter/losses.py +74 -0
  18. enzymehunter-0.1.0/src/enzymehunter/model.py +142 -0
  19. enzymehunter-0.1.0/src/enzymehunter/pipeline.py +333 -0
  20. enzymehunter-0.1.0/src/enzymehunter/runtime.py +57 -0
  21. enzymehunter-0.1.0/src/enzymehunter/uncertainty.py +84 -0
  22. enzymehunter-0.1.0/src/enzymehunter/utils.py +510 -0
  23. enzymehunter-0.1.0/src/enzymehunter.egg-info/PKG-INFO +271 -0
  24. enzymehunter-0.1.0/src/enzymehunter.egg-info/SOURCES.txt +26 -0
  25. enzymehunter-0.1.0/src/enzymehunter.egg-info/dependency_links.txt +1 -0
  26. enzymehunter-0.1.0/src/enzymehunter.egg-info/entry_points.txt +2 -0
  27. enzymehunter-0.1.0/src/enzymehunter.egg-info/requires.txt +21 -0
  28. enzymehunter-0.1.0/src/enzymehunter.egg-info/top_level.txt +1 -0
@@ -0,0 +1,271 @@
1
+ Metadata-Version: 2.4
2
+ Name: enzymehunter
3
+ Version: 0.1.0
4
+ Summary: Fine-grained enzyme function prediction with EnzymeHunter
5
+ Author: CGXBio
6
+ Project-URL: Homepage, https://github.com/cgxbio/EnzymeHunter_pypi
7
+ Project-URL: Repository, https://github.com/cgxbio/EnzymeHunter_pypi
8
+ Project-URL: Issues, https://github.com/cgxbio/EnzymeHunter_pypi/issues
9
+ Requires-Python: <3.13,>=3.9
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: numpy>=1.24
12
+ Requires-Dist: pandas>=2.0
13
+ Requires-Dist: scipy>=1.10
14
+ Requires-Dist: scikit-learn>=1.2
15
+ Requires-Dist: biopython>=1.80
16
+ Requires-Dist: biotite>=0.39
17
+ Requires-Dist: tqdm>=4.65
18
+ Requires-Dist: torch>=2.0
19
+ Requires-Dist: torchvision>=0.15
20
+ Requires-Dist: fair-esm>=2.0
21
+ Requires-Dist: tm-vec>=1.0
22
+ Requires-Dist: huggingface_hub>=0.23
23
+ Provides-Extra: dev
24
+ Requires-Dist: build; extra == "dev"
25
+ Requires-Dist: twine; extra == "dev"
26
+ Requires-Dist: pytest; extra == "dev"
27
+ Requires-Dist: ruff; extra == "dev"
28
+ Provides-Extra: hf
29
+ Requires-Dist: huggingface_hub>=0.23; extra == "hf"
30
+
31
+ # EnzymeHunter
32
+
33
+ ## Overview
34
+
35
+ **EnzymeHunter**: Achieving fine-grained enzyme function prediction with a hierarchically-aware contrastive learning framework.
36
+ The prediction pipeline was developed and tested on **Linux (CentOS)** with
37
+ **Python 3.9**. The package also provides a CLI and Python API for installed
38
+ use.
39
+
40
+ ## EnzymeHunter Architecture
41
+
42
+ Architecture and workflow of the EnzymeHunter model:
43
+
44
+ ![EnzymeHunter Architecture](png/Architecture_EnzymeHunter.png)
45
+
46
+ ## Installation & Setup
47
+
48
+ ### Install from PyPI
49
+
50
+ The project provides a Python API and a command-line entry point. Large
51
+ pretrained weights and reference databases are distributed separately rather
52
+ than embedded in the PyPI wheel.
53
+
54
+ ```bash
55
+ python -m pip install enzymehunter
56
+ ```
57
+
58
+ The PyPI package does not embed the large pretrained weights or reference
59
+ database. Download both from Hugging Face with the command below, then run a
60
+ prediction from the download directory:
61
+
62
+ ```bash
63
+ cd /path/to/model-and-data
64
+ enzymehunter predict input.fasta -o results.csv
65
+ ```
66
+
67
+ By default, the CLI looks for `./model` and then
68
+ `~/.cache/enzymehunter/model`, so `--model-dir` is normally unnecessary. If
69
+ you store the model somewhere else, pass its location explicitly:
70
+
71
+ ```bash
72
+ enzymehunter predict input.fasta \
73
+ --model-dir /data/enzymehunter/model \
74
+ -o results.csv
75
+ ```
76
+
77
+ Use a specific device when needed:
78
+
79
+ ```bash
80
+ # Automatically choose CUDA when available, otherwise CPU
81
+ enzymehunter predict input.fasta --device auto -o results.csv
82
+
83
+ # Force CPU
84
+ enzymehunter predict input.fasta --device cpu -o results.csv
85
+
86
+ # Use physical GPU 1
87
+ enzymehunter predict input.fasta --device cuda:1 -o results.csv
88
+
89
+ # Model stored outside the default locations
90
+ enzymehunter predict input.fasta --model-dir /data/enzymehunter/model \
91
+ --device cuda:1 -o results.csv
92
+ ```
93
+
94
+ For `cuda:N`, the selected physical GPU is isolated as logical `cuda:0` for
95
+ the pipeline and its external tools, so all stages use the same GPU.
96
+
97
+ The model directory must contain the downloaded model files, and its parent
98
+ directory must contain the reference data used by the pipeline. Install
99
+ `diamond` separately and ensure it is available on `PATH` or in the model
100
+ directory. Linux with Python 3.9--3.11 is currently the tested environment.
101
+
102
+ The same operation is available from Python:
103
+
104
+ ```python
105
+ from enzymehunter import predict
106
+
107
+ # Uses ./model by default
108
+ predict("input.fasta", "results.csv")
109
+
110
+ # Use this only when the model is stored elsewhere
111
+ predict("input.fasta", "results.csv", model_dir="/data/enzymehunter/model")
112
+ ```
113
+
114
+ ### Download the model and reference data from Hugging Face
115
+
116
+ The `Tonybio/EnzymeHunter` repository contains both the `model/` tree and the
117
+ reference `data/` tree. Hugging Face support is installed automatically with
118
+ `enzymehunter`:
119
+
120
+ > Note: the current `model/` tree is approximately 18 GB, mainly because it
121
+ > contains the ESM2 and ProtT5 weights. Make sure the target disk has enough
122
+ > free space before starting.
123
+
124
+ ```bash
125
+ python -m pip install enzymehunter
126
+ enzymehunter download-hf-assets
127
+ ```
128
+
129
+ By default, this creates `./model/` and `./data/` in the current directory.
130
+ The older name `download-hf-model` remains an alias. Choose another directory
131
+ or a fixed revision with:
132
+
133
+ ```bash
134
+ enzymehunter download-hf-assets \
135
+ --dir /data/enzymehunter/model \
136
+ --repo-id Tonybio/EnzymeHunter \
137
+ --revision main
138
+ ```
139
+
140
+ The `--dir` value is the model directory; the downloader places `data/` next
141
+ to it. For example, `--dir /data/enzymehunter/model` creates:
142
+
143
+ ```text
144
+ /data/enzymehunter/
145
+ ├── model/
146
+ └── data/
147
+ ```
148
+
149
+ The downloader supports caching and resuming and only retrieves the
150
+ repository's `model/` and `data/` trees. The model tree is approximately
151
+ 18 GB, with additional space required for the reference data.
152
+
153
+ The downloader tries the official Hugging Face endpoint first. If that fails,
154
+ it automatically sets `HF_ENDPOINT=https://hf-mirror.com` and retries. To
155
+ disable this fallback:
156
+
157
+ ```bash
158
+ enzymehunter download-hf-assets --no-mirror-fallback
159
+ ```
160
+
161
+ ### Install from source for development
162
+
163
+ 1. **Clone the repository**
164
+
165
+ ```bash
166
+ git clone https://github.com/cgxbio/EnzymeHunter_pypi.git
167
+ cd EnzymeHunter_pypi
168
+ ```
169
+ 2. **Create and activate the virtual environment**
170
+
171
+ ```bash
172
+ conda env create -f environment.yml
173
+ conda activate EnzymeHunter
174
+ ```
175
+ 3. **Build and validate the package**
176
+
177
+ ```bash
178
+ python -m pip install -e ".[dev]"
179
+ python -m build
180
+ python -m twine check dist/*
181
+ ```
182
+
183
+ ## Assets layout
184
+
185
+ The prediction pipeline expects the model directory and its reference data to
186
+ be siblings:
187
+
188
+ ```
189
+ <assets-root>/
190
+ ├── model/ # Model files downloaded from Hugging Face
191
+ └── data/
192
+ ├── datasets/
193
+ │ ├── split100.csv
194
+ │ └── split100.fasta
195
+ ├── datasets_process/
196
+ │ └── train_dataset_model_embedding/
197
+ └── pdb/ # Optional PDB files named {UNIPROT_ID}.pdb
198
+ ```
199
+
200
+ The `--model-dir` option points to `model/`. Its parent directory is used to
201
+ locate the matching `data/` directory. If `--model-dir` is omitted, the CLI
202
+ looks for `./model` first and then `~/.cache/enzymehunter/model`.
203
+
204
+ ## Usage Example
205
+
206
+ Here are the common examples of using the **EnzymeHunter**, corresponding to different running modes:
207
+
208
+ ### 1. Normal Mode (Default Mode)
209
+
210
+ Use this mode when you need the program to automatically distinguish between enzymes and non-enzymes, and only predict EC numbers for proteins classified as enzymes:
211
+
212
+ ```bash
213
+ # Example: run prediction on a dataset where not all proteins are enzymes
214
+ enzymehunter predict input.fasta \
215
+ -o results.csv
216
+ ```
217
+
218
+ Explanation:
219
+
220
+ - The input is a regular FASTA file; sequence identifiers become the `Entry` column.
221
+ - The program first performs enzyme/non-enzyme classification.
222
+ - Only proteins predicted as enzymes (`pred_label=1`) undergo EC number prediction.
223
+ - Non-enzyme proteins are marked with EC number `0.0.0.0`.
224
+
225
+ ### 2. All-Enzymes Mode
226
+
227
+ Use this mode when you know all proteins in the dataset are enzymes and want to skip the enzyme/non-enzyme classification step, proceeding directly to EC number prediction:
228
+
229
+ ```bash
230
+ # Example: run prediction assuming all proteins are enzymes
231
+ enzymehunter predict input.fasta \
232
+ --all-are-enzymes \
233
+ -o results.csv
234
+ ```
235
+
236
+ Explanation:
237
+
238
+ - `--all-are-enzymes` treats every input protein as an enzyme.
239
+ - The enzyme/non-enzyme classification step is skipped.
240
+ - All proteins receive `pred_label=1` and `pred_prob=1.0`.
241
+
242
+ ### 3. PDB-Based Contact Map Mode
243
+
244
+ By default, EnzymeHunter uses **ESM2-predicted contact maps**. You can switch to **PDB-based contact maps** (computed from [AlphaFold](https://alphafold.com/download) or [ESMFold](https://github.com/facebookresearch/esm) 3D structures) with `--contact-map-source pdb`:
245
+
246
+ 1. Place your PDB structure files (named `{UNIPROT_ID}.pdb`) into the assets
247
+ directory under `data/pdb/` (for example, `/path/to/assets/data/pdb/`).
248
+ 2. Run the pipeline with `--contact-map-source pdb`:
249
+
250
+ In this mode, EnzymeHunter will use the model trained with PDB-derived contact maps.
251
+
252
+ ```bash
253
+ # Normal mode with PDB contact maps
254
+ enzymehunter predict input.fasta \
255
+ --contact-map-source pdb \
256
+ -o results.csv
257
+
258
+ # All-enzymes mode with PDB contact maps
259
+ enzymehunter predict input.fasta \
260
+ --all-are-enzymes \
261
+ --contact-map-source pdb \
262
+ -o results.csv
263
+ ```
264
+
265
+ ## Output
266
+
267
+ When using the PyPI CLI, the result is written to the path supplied with `-o`:
268
+
269
+ ```
270
+ results.csv
271
+ ```
@@ -0,0 +1,241 @@
1
+ # EnzymeHunter
2
+
3
+ ## Overview
4
+
5
+ **EnzymeHunter**: Achieving fine-grained enzyme function prediction with a hierarchically-aware contrastive learning framework.
6
+ The prediction pipeline was developed and tested on **Linux (CentOS)** with
7
+ **Python 3.9**. The package also provides a CLI and Python API for installed
8
+ use.
9
+
10
+ ## EnzymeHunter Architecture
11
+
12
+ Architecture and workflow of the EnzymeHunter model:
13
+
14
+ ![EnzymeHunter Architecture](png/Architecture_EnzymeHunter.png)
15
+
16
+ ## Installation & Setup
17
+
18
+ ### Install from PyPI
19
+
20
+ The project provides a Python API and a command-line entry point. Large
21
+ pretrained weights and reference databases are distributed separately rather
22
+ than embedded in the PyPI wheel.
23
+
24
+ ```bash
25
+ python -m pip install enzymehunter
26
+ ```
27
+
28
+ The PyPI package does not embed the large pretrained weights or reference
29
+ database. Download both from Hugging Face with the command below, then run a
30
+ prediction from the download directory:
31
+
32
+ ```bash
33
+ cd /path/to/model-and-data
34
+ enzymehunter predict input.fasta -o results.csv
35
+ ```
36
+
37
+ By default, the CLI looks for `./model` and then
38
+ `~/.cache/enzymehunter/model`, so `--model-dir` is normally unnecessary. If
39
+ you store the model somewhere else, pass its location explicitly:
40
+
41
+ ```bash
42
+ enzymehunter predict input.fasta \
43
+ --model-dir /data/enzymehunter/model \
44
+ -o results.csv
45
+ ```
46
+
47
+ Use a specific device when needed:
48
+
49
+ ```bash
50
+ # Automatically choose CUDA when available, otherwise CPU
51
+ enzymehunter predict input.fasta --device auto -o results.csv
52
+
53
+ # Force CPU
54
+ enzymehunter predict input.fasta --device cpu -o results.csv
55
+
56
+ # Use physical GPU 1
57
+ enzymehunter predict input.fasta --device cuda:1 -o results.csv
58
+
59
+ # Model stored outside the default locations
60
+ enzymehunter predict input.fasta --model-dir /data/enzymehunter/model \
61
+ --device cuda:1 -o results.csv
62
+ ```
63
+
64
+ For `cuda:N`, the selected physical GPU is isolated as logical `cuda:0` for
65
+ the pipeline and its external tools, so all stages use the same GPU.
66
+
67
+ The model directory must contain the downloaded model files, and its parent
68
+ directory must contain the reference data used by the pipeline. Install
69
+ `diamond` separately and ensure it is available on `PATH` or in the model
70
+ directory. Linux with Python 3.9--3.11 is currently the tested environment.
71
+
72
+ The same operation is available from Python:
73
+
74
+ ```python
75
+ from enzymehunter import predict
76
+
77
+ # Uses ./model by default
78
+ predict("input.fasta", "results.csv")
79
+
80
+ # Use this only when the model is stored elsewhere
81
+ predict("input.fasta", "results.csv", model_dir="/data/enzymehunter/model")
82
+ ```
83
+
84
+ ### Download the model and reference data from Hugging Face
85
+
86
+ The `Tonybio/EnzymeHunter` repository contains both the `model/` tree and the
87
+ reference `data/` tree. Hugging Face support is installed automatically with
88
+ `enzymehunter`:
89
+
90
+ > Note: the current `model/` tree is approximately 18 GB, mainly because it
91
+ > contains the ESM2 and ProtT5 weights. Make sure the target disk has enough
92
+ > free space before starting.
93
+
94
+ ```bash
95
+ python -m pip install enzymehunter
96
+ enzymehunter download-hf-assets
97
+ ```
98
+
99
+ By default, this creates `./model/` and `./data/` in the current directory.
100
+ The older name `download-hf-model` remains an alias. Choose another directory
101
+ or a fixed revision with:
102
+
103
+ ```bash
104
+ enzymehunter download-hf-assets \
105
+ --dir /data/enzymehunter/model \
106
+ --repo-id Tonybio/EnzymeHunter \
107
+ --revision main
108
+ ```
109
+
110
+ The `--dir` value is the model directory; the downloader places `data/` next
111
+ to it. For example, `--dir /data/enzymehunter/model` creates:
112
+
113
+ ```text
114
+ /data/enzymehunter/
115
+ ├── model/
116
+ └── data/
117
+ ```
118
+
119
+ The downloader supports caching and resuming and only retrieves the
120
+ repository's `model/` and `data/` trees. The model tree is approximately
121
+ 18 GB, with additional space required for the reference data.
122
+
123
+ The downloader tries the official Hugging Face endpoint first. If that fails,
124
+ it automatically sets `HF_ENDPOINT=https://hf-mirror.com` and retries. To
125
+ disable this fallback:
126
+
127
+ ```bash
128
+ enzymehunter download-hf-assets --no-mirror-fallback
129
+ ```
130
+
131
+ ### Install from source for development
132
+
133
+ 1. **Clone the repository**
134
+
135
+ ```bash
136
+ git clone https://github.com/cgxbio/EnzymeHunter_pypi.git
137
+ cd EnzymeHunter_pypi
138
+ ```
139
+ 2. **Create and activate the virtual environment**
140
+
141
+ ```bash
142
+ conda env create -f environment.yml
143
+ conda activate EnzymeHunter
144
+ ```
145
+ 3. **Build and validate the package**
146
+
147
+ ```bash
148
+ python -m pip install -e ".[dev]"
149
+ python -m build
150
+ python -m twine check dist/*
151
+ ```
152
+
153
+ ## Assets layout
154
+
155
+ The prediction pipeline expects the model directory and its reference data to
156
+ be siblings:
157
+
158
+ ```
159
+ <assets-root>/
160
+ ├── model/ # Model files downloaded from Hugging Face
161
+ └── data/
162
+ ├── datasets/
163
+ │ ├── split100.csv
164
+ │ └── split100.fasta
165
+ ├── datasets_process/
166
+ │ └── train_dataset_model_embedding/
167
+ └── pdb/ # Optional PDB files named {UNIPROT_ID}.pdb
168
+ ```
169
+
170
+ The `--model-dir` option points to `model/`. Its parent directory is used to
171
+ locate the matching `data/` directory. If `--model-dir` is omitted, the CLI
172
+ looks for `./model` first and then `~/.cache/enzymehunter/model`.
173
+
174
+ ## Usage Example
175
+
176
+ Here are the common examples of using the **EnzymeHunter**, corresponding to different running modes:
177
+
178
+ ### 1. Normal Mode (Default Mode)
179
+
180
+ Use this mode when you need the program to automatically distinguish between enzymes and non-enzymes, and only predict EC numbers for proteins classified as enzymes:
181
+
182
+ ```bash
183
+ # Example: run prediction on a dataset where not all proteins are enzymes
184
+ enzymehunter predict input.fasta \
185
+ -o results.csv
186
+ ```
187
+
188
+ Explanation:
189
+
190
+ - The input is a regular FASTA file; sequence identifiers become the `Entry` column.
191
+ - The program first performs enzyme/non-enzyme classification.
192
+ - Only proteins predicted as enzymes (`pred_label=1`) undergo EC number prediction.
193
+ - Non-enzyme proteins are marked with EC number `0.0.0.0`.
194
+
195
+ ### 2. All-Enzymes Mode
196
+
197
+ Use this mode when you know all proteins in the dataset are enzymes and want to skip the enzyme/non-enzyme classification step, proceeding directly to EC number prediction:
198
+
199
+ ```bash
200
+ # Example: run prediction assuming all proteins are enzymes
201
+ enzymehunter predict input.fasta \
202
+ --all-are-enzymes \
203
+ -o results.csv
204
+ ```
205
+
206
+ Explanation:
207
+
208
+ - `--all-are-enzymes` treats every input protein as an enzyme.
209
+ - The enzyme/non-enzyme classification step is skipped.
210
+ - All proteins receive `pred_label=1` and `pred_prob=1.0`.
211
+
212
+ ### 3. PDB-Based Contact Map Mode
213
+
214
+ By default, EnzymeHunter uses **ESM2-predicted contact maps**. You can switch to **PDB-based contact maps** (computed from [AlphaFold](https://alphafold.com/download) or [ESMFold](https://github.com/facebookresearch/esm) 3D structures) with `--contact-map-source pdb`:
215
+
216
+ 1. Place your PDB structure files (named `{UNIPROT_ID}.pdb`) into the assets
217
+ directory under `data/pdb/` (for example, `/path/to/assets/data/pdb/`).
218
+ 2. Run the pipeline with `--contact-map-source pdb`:
219
+
220
+ In this mode, EnzymeHunter will use the model trained with PDB-derived contact maps.
221
+
222
+ ```bash
223
+ # Normal mode with PDB contact maps
224
+ enzymehunter predict input.fasta \
225
+ --contact-map-source pdb \
226
+ -o results.csv
227
+
228
+ # All-enzymes mode with PDB contact maps
229
+ enzymehunter predict input.fasta \
230
+ --all-are-enzymes \
231
+ --contact-map-source pdb \
232
+ -o results.csv
233
+ ```
234
+
235
+ ## Output
236
+
237
+ When using the PyPI CLI, the result is written to the path supplied with `-o`:
238
+
239
+ ```
240
+ results.csv
241
+ ```
@@ -0,0 +1,49 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "enzymehunter"
7
+ version = "0.1.0"
8
+ description = "Fine-grained enzyme function prediction with EnzymeHunter"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9,<3.13"
11
+ authors = [
12
+ { name = "CGXBio" }
13
+ ]
14
+ dependencies = [
15
+ "numpy>=1.24",
16
+ "pandas>=2.0",
17
+ "scipy>=1.10",
18
+ "scikit-learn>=1.2",
19
+ "biopython>=1.80",
20
+ "biotite>=0.39",
21
+ "tqdm>=4.65",
22
+ "torch>=2.0",
23
+ "torchvision>=0.15",
24
+ "fair-esm>=2.0",
25
+ "tm-vec>=1.0",
26
+ "huggingface_hub>=0.23"
27
+ ]
28
+
29
+ [project.optional-dependencies]
30
+ dev = [
31
+ "build",
32
+ "twine",
33
+ "pytest",
34
+ "ruff"
35
+ ]
36
+ hf = [
37
+ "huggingface_hub>=0.23"
38
+ ]
39
+
40
+ [project.urls]
41
+ Homepage = "https://github.com/cgxbio/EnzymeHunter_pypi"
42
+ Repository = "https://github.com/cgxbio/EnzymeHunter_pypi"
43
+ Issues = "https://github.com/cgxbio/EnzymeHunter_pypi/issues"
44
+
45
+ [project.scripts]
46
+ enzymehunter = "enzymehunter.cli:main"
47
+
48
+ [tool.setuptools.packages.find]
49
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,11 @@
1
+ """EnzymeHunter: fine-grained enzyme function prediction."""
2
+
3
+
4
+ def predict(*args, **kwargs):
5
+ """Run a prediction, importing the heavy scientific stack lazily."""
6
+ from .api import predict as _predict
7
+
8
+ return _predict(*args, **kwargs)
9
+
10
+
11
+ __all__ = ["predict"]
@@ -0,0 +1,5 @@
1
+ from .cli import main
2
+
3
+
4
+ if __name__ == "__main__":
5
+ main()
@@ -0,0 +1,69 @@
1
+ """Public Python API for EnzymeHunter."""
2
+
3
+ from pathlib import Path
4
+ import shutil
5
+
6
+ from .runtime import workspace
7
+ from .device import configure_device, validate_device
8
+
9
+
10
+ def _default_model_dir():
11
+ """Find the model directory in the current project or user cache."""
12
+ current = Path.cwd()
13
+ if (current / "model").is_dir():
14
+ return current / "model"
15
+
16
+ cached = Path.home() / ".cache" / "enzymehunter"
17
+ if (cached / "model").is_dir():
18
+ return cached / "model"
19
+
20
+ return current / "model"
21
+
22
+
23
+ def predict(
24
+ input_fasta,
25
+ output_path=None,
26
+ model_dir=None,
27
+ all_enzymes=False,
28
+ contact_map_source="esm2",
29
+ device="auto",
30
+ ):
31
+ """Run EnzymeHunter on a FASTA file.
32
+
33
+ ``model_dir`` points to the directory containing EnzymeHunter model files.
34
+ It is optional: when omitted, ``./model`` and then
35
+ ``~/.cache/enzymehunter/model`` are checked. The matching reference data
36
+ is expected in the model directory's parent under ``data/``.
37
+ """
38
+ input_fasta = Path(input_fasta).expanduser().resolve()
39
+ if model_dir is None:
40
+ model_dir = _default_model_dir()
41
+ configure_device(device)
42
+ if not input_fasta.is_file():
43
+ raise FileNotFoundError(f"Input FASTA file does not exist: {input_fasta}")
44
+
45
+ if output_path is None:
46
+ output_path = input_fasta.with_name(f"{input_fasta.stem}_results.csv")
47
+ output_path = Path(output_path).expanduser().resolve()
48
+ output_path.parent.mkdir(parents=True, exist_ok=True)
49
+
50
+ # Import the scientific stack only when a prediction is requested. This
51
+ # keeps ``enzymehunter --help`` and package metadata commands lightweight.
52
+ from .pipeline import run_prediction_pipeline
53
+ validate_device(device)
54
+
55
+ with workspace(model_dir) as root:
56
+ dataset_name = input_fasta.stem
57
+ staged_input = root / "data" / "datasets" / f"{dataset_name}.fasta"
58
+ shutil.copy2(input_fasta, staged_input)
59
+
60
+ result = run_prediction_pipeline(
61
+ dataset_name,
62
+ all_enzymes=all_enzymes,
63
+ contact_map_source=contact_map_source,
64
+ )
65
+ # The legacy pipeline writes tab-separated files with a .csv suffix.
66
+ # The public API writes a conventional comma-separated CSV.
67
+ result.to_csv(output_path, index=False)
68
+
69
+ return result