grade-client 1.2.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.
- grade_client-1.2.0/DEVELOPMENT.md +47 -0
- grade_client-1.2.0/LICENSE +21 -0
- grade_client-1.2.0/MANIFEST.in +8 -0
- grade_client-1.2.0/PKG-INFO +291 -0
- grade_client-1.2.0/README.md +273 -0
- grade_client-1.2.0/build_support.py +21 -0
- grade_client-1.2.0/grade/__init__.py +3 -0
- grade_client-1.2.0/grade/__main__.py +5 -0
- grade_client-1.2.0/grade/cli.py +91 -0
- grade_client-1.2.0/grade/cloud.py +600 -0
- grade_client-1.2.0/grade/ifm.py +182 -0
- grade_client-1.2.0/grade/inference.py +441 -0
- grade_client-1.2.0/grade/inputs.py +60 -0
- grade_client-1.2.0/grade/model_registry.py +54 -0
- grade_client-1.2.0/grade/modeling.py +88 -0
- grade_client-1.2.0/grade/pam.py +118 -0
- grade_client-1.2.0/grade/resume.py +197 -0
- grade_client-1.2.0/grade/runner.py +72 -0
- grade_client-1.2.0/grade/targets/__init__.py +0 -0
- grade_client-1.2.0/grade/targets/targets_gpcr_v2.fa +658 -0
- grade_client-1.2.0/grade/tcm.py +109 -0
- grade_client-1.2.0/grade/writers.py +120 -0
- grade_client-1.2.0/grade_client.egg-info/PKG-INFO +291 -0
- grade_client-1.2.0/grade_client.egg-info/SOURCES.txt +42 -0
- grade_client-1.2.0/grade_client.egg-info/dependency_links.txt +1 -0
- grade_client-1.2.0/grade_client.egg-info/entry_points.txt +3 -0
- grade_client-1.2.0/grade_client.egg-info/requires.txt +7 -0
- grade_client-1.2.0/grade_client.egg-info/top_level.txt +1 -0
- grade_client-1.2.0/pyproject.toml +42 -0
- grade_client-1.2.0/requirements.txt +6 -0
- grade_client-1.2.0/run_inference.py +11 -0
- grade_client-1.2.0/scripts/sync_cloud_skill.py +36 -0
- grade_client-1.2.0/setup.cfg +4 -0
- grade_client-1.2.0/skills/grade-cloud/SKILL.md +149 -0
- grade_client-1.2.0/skills/grade-cloud/scripts/grade_predict.py +602 -0
- grade_client-1.2.0/tests/test_grade_cloud_client.py +396 -0
- grade_client-1.2.0/tests/test_inference_cache.py +82 -0
- grade_client-1.2.0/tests/test_inference_cli.py +44 -0
- grade_client-1.2.0/tests/test_inference_resume.py +614 -0
- grade_client-1.2.0/tests/test_model_registry.py +41 -0
- grade_client-1.2.0/tests/test_model_selection.py +89 -0
- grade_client-1.2.0/tests/test_target_cache.py +102 -0
- grade_client-1.2.0/tests/test_unified_cli.py +214 -0
- grade_client-1.2.0/tests/test_writers_atomic.py +167 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Maintaining grade-client
|
|
2
|
+
|
|
3
|
+
The distribution is `grade-client` version 1.2.0; its import name is `grade` and primary command is `grade`. The basic installation provides Cloud inference with `requests`. `.[local]` adds the pinned local inference dependencies; use Python 3.11 for that environment.
|
|
4
|
+
|
|
5
|
+
## Cloud implementation and independent Skill
|
|
6
|
+
|
|
7
|
+
Maintain Cloud registration, credentials, HTTP behavior and the standalone CLI in `grade/cloud.py`. It must remain independently executable using standard-library imports plus the lazily imported `requests` dependency. Do not introduce relative imports or dependencies on other `grade` modules into this file.
|
|
8
|
+
|
|
9
|
+
The package's six-column orchestration lives in `grade/runner.py`; the Skill script retains its four-column interface. Both use the same credential configuration and Cloud contract. Generate the standalone script after changing the source:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
python scripts/sync_cloud_skill.py
|
|
13
|
+
python scripts/sync_cloud_skill.py --check
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
`skills/grade-cloud/scripts/grade_predict.py` is a checked-in generated artifact. Building a wheel or source distribution fails if it does not match the source; builds do not silently regenerate it. The distributed Skill contains the complete script and does not import `grade`.
|
|
17
|
+
|
|
18
|
+
## Tests and packaging
|
|
19
|
+
|
|
20
|
+
Run from this directory:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
python -m grade --help
|
|
24
|
+
python -m grade.inference --help
|
|
25
|
+
python skills/grade-cloud/scripts/grade_predict.py --help
|
|
26
|
+
python scripts/sync_cloud_skill.py --check
|
|
27
|
+
python -m unittest discover -s tests -v
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Full inference-cache tests require local inference dependencies. Import failures due to missing PyTorch are not passing tests. Cloud client, unified CLI, registry, writers and resume-control tests run without PyTorch and use synthetic credentials and temporary configurations. Do not use the operator's actual client configuration in tests.
|
|
31
|
+
|
|
32
|
+
For a clean build environment:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
python -m pip install build
|
|
36
|
+
python -m build
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
This produces `grade_client-1.2.0.tar.gz` and `grade_client-1.2.0-py3-none-any.whl`. Check that the wheel contains bundled targets, both console entrypoints, and only `requests` as a mandatory runtime dependency. Torch 2.4.0 and Transformers 4.44.0 belong to the `local` extra. Install the wheel and source archive in separate fresh environments, outside the source tree, and verify default Cloud routing and explicit local errors without importing heavy dependencies. Separately test a copied Skill directory in an environment without the `grade` module.
|
|
40
|
+
|
|
41
|
+
Publication to PyPI or changes to GitHub visibility require explicit authorization. Keep README installation instructions limited to available installation methods, without release-status notes or future publication instructions. Usage examples should use macOS/Linux commands and paths without a separate platform-support declaration. Keep Citation as bibliographic placeholders until a confirmed citation is supplied. Do not publish under the unrelated PyPI name `grade`.
|
|
42
|
+
|
|
43
|
+
## Repository boundaries
|
|
44
|
+
|
|
45
|
+
Changes here do not update the independent GRADE-Cloud deployment or its fixed historical core wheel. Do not replace its lock, source snapshot, requirements or model assets as part of a client release. Cloud deployment and real authenticated inference checks are separate authorized operations.
|
|
46
|
+
|
|
47
|
+
Local model loading, target caching, DDP, scoring and resume fingerprints retain their training/inference contracts. A supplied `--model-dir` never falls back to Cloud. CLI calls without that argument default to Cloud, including the compatibility entrypoints. Programmatic `grade.inference.run_inference(args)` remains the local pipeline.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 GRADE Authors
|
|
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,291 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: grade-client
|
|
3
|
+
Version: 1.2.0
|
|
4
|
+
Summary: GRADE: GPCR-peptide ranking with Cloud and optional local inference
|
|
5
|
+
Author: Xia Binbin
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/devxia/GRADE
|
|
8
|
+
Requires-Python: >=3.11
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: requests<3,>=2.31
|
|
12
|
+
Provides-Extra: local
|
|
13
|
+
Requires-Dist: torch==2.4.0; extra == "local"
|
|
14
|
+
Requires-Dist: transformers==4.44.0; extra == "local"
|
|
15
|
+
Requires-Dist: tqdm; extra == "local"
|
|
16
|
+
Requires-Dist: safetensors; extra == "local"
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# GRADE
|
|
20
|
+
|
|
21
|
+
**GPCR-targeted Ranking-guided Agonist Design Engine**
|
|
22
|
+
|
|
23
|
+
GRADE ranks candidate peptides for predicted agonist activity at a target GPCR. Supply a GPCR amino acid sequence and a peptide list to receive scores sorted from highest to lowest for experimental prioritization.
|
|
24
|
+
|
|
25
|
+
The **grade-client** Python package provides the `grade` command. GRADE is also available through an independent [Agent Skill](#agent-skill) and the [Cloud API](#cloud-api).
|
|
26
|
+
|
|
27
|
+
**GRADE-paper** is the model used in the accompanying publication.
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
Use Python 3.11 or newer. Clone the [GRADE repository](https://github.com/devxia/GRADE) and install the package in a virtual environment:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
git clone https://github.com/devxia/GRADE.git
|
|
35
|
+
cd GRADE
|
|
36
|
+
|
|
37
|
+
python3.11 -m venv .venv
|
|
38
|
+
source .venv/bin/activate
|
|
39
|
+
python -m pip install .
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Quick Start
|
|
43
|
+
|
|
44
|
+
An email address is required to use the prediction service.
|
|
45
|
+
|
|
46
|
+
Save your candidates as `candidates.fasta`:
|
|
47
|
+
|
|
48
|
+
```fasta
|
|
49
|
+
>peptide_1
|
|
50
|
+
ACDEFGHIKLMNPQRSTVWY
|
|
51
|
+
>peptide_2
|
|
52
|
+
YTVSRQPNMLKIHGFEDCA
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Run a prediction against the bundled human CCR5 target:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
grade \
|
|
59
|
+
--target-name CCR5_HUMAN \
|
|
60
|
+
--peptides candidates.fasta \
|
|
61
|
+
--output scores.csv
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Replace the example peptides with your candidates. For non-interactive use, add `--email user@example.org`. Run `grade --help` for all command options.
|
|
65
|
+
|
|
66
|
+
### Use your own target
|
|
67
|
+
|
|
68
|
+
Save the complete amino acid sequence of your target in `target.fasta`, then run:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
grade \
|
|
72
|
+
--target-fasta target.fasta \
|
|
73
|
+
--peptides candidates.fasta \
|
|
74
|
+
--output scores.csv
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
If the target FASTA has several entries, add `--target-name` with the complete header of the desired entry. Each invocation scores one target. You may instead supply its amino acid sequence directly with `--target-seq`.
|
|
78
|
+
|
|
79
|
+
### Inputs and result files
|
|
80
|
+
|
|
81
|
+
| Target input | Arguments | Requirement |
|
|
82
|
+
|---|---|---|
|
|
83
|
+
| Bundled GPCR | `--target-name CCR5_HUMAN` | Exact header in the [bundled FASTA](grade/targets/targets_gpcr_v2.fa) |
|
|
84
|
+
| One sequence in a file | `--target-fasta target.fasta` | Exactly one FASTA entry |
|
|
85
|
+
| Selected entry in a file | `--target-fasta targets.fa --target-name CCR5_HUMAN` | Exact complete header in the supplied FASTA |
|
|
86
|
+
| Direct sequence | `--target-seq` followed by the amino acid sequence | Cannot be combined with other target arguments |
|
|
87
|
+
|
|
88
|
+
| Peptide format | Extensions | Contents |
|
|
89
|
+
|---|---|---|
|
|
90
|
+
| FASTA | `.fasta`, `.faa`, `.fa` | Full header becomes the candidate identifier |
|
|
91
|
+
| CSV | `.csv` | `sequence`, `peptide` or `seq` column; optional `name`, `peptide_name` or `id` |
|
|
92
|
+
| Text | `.txt` | One sequence per line, or whitespace-separated name and sequence |
|
|
93
|
+
|
|
94
|
+
Sequence whitespace is removed and letters are uppercased. Empty sequences and duplicate identifiers are rejected. Supply amino acid letters without residue numbers or chemical modification notation. Cloud encodes each target and peptide with a 1024-token limit, including special tokens; longer sequences are truncated.
|
|
95
|
+
|
|
96
|
+
Use the output extension to choose CSV, TSV or JSON. To keep only the highest-scoring candidates:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
grade \
|
|
100
|
+
--target-name CCR5_HUMAN \
|
|
101
|
+
--peptides candidates.fasta \
|
|
102
|
+
--top-k 20 \
|
|
103
|
+
--output top20.json
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
`--output-format` overrides extension-based selection. An unrecognized extension defaults to CSV. The package writes the following fields; JSON output is an array with the same keys:
|
|
107
|
+
|
|
108
|
+
| Field | Meaning |
|
|
109
|
+
|---|---|
|
|
110
|
+
| `rank` | Descending-score rank, starting at 1 |
|
|
111
|
+
| `target` | Selected target header, or `custom_target` for a direct sequence |
|
|
112
|
+
| `peptide_name` | Candidate identifier |
|
|
113
|
+
| `src` | Source label; override with `--source-label` |
|
|
114
|
+
| `sequence` | Normalized candidate sequence |
|
|
115
|
+
| `score` | Positive-class softmax score from 0 to 1 |
|
|
116
|
+
|
|
117
|
+
Higher scores indicate greater predicted agonist potential for the target GPCR. The accompanying work treats scores above 0.9 as high-confidence candidates for experimental prioritization, not as a mandatory cutoff or calibrated probability of success. Functional assays are needed to establish agonist activity.
|
|
118
|
+
|
|
119
|
+
Results are checked before the output file is replaced. `grade-inference`, `python -m grade` and `python -m grade.inference` accept the same arguments as `grade`; `--output-csv` remains an alias for `--output`.
|
|
120
|
+
|
|
121
|
+
### Cloud quota
|
|
122
|
+
|
|
123
|
+
View the remaining daily prediction quota and reset time:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
grade --usage
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
| Limit | Value |
|
|
130
|
+
|---|---|
|
|
131
|
+
| Peptides per request | Up to 50 |
|
|
132
|
+
| Predictions per email per UTC day | 50 |
|
|
133
|
+
| Predictions per client per UTC day | 50, counted independently |
|
|
134
|
+
| Effective available quota | Smaller of the two remaining balances |
|
|
135
|
+
| Reset time | UTC midnight; 08:00 Beijing time |
|
|
136
|
+
|
|
137
|
+
The package and Skill share the same quota. Repeated predictions count again, and `--top-k` does not reduce the number submitted. Users sharing a public IP do not share a daily quota.
|
|
138
|
+
|
|
139
|
+
If the service returns 429, follow the daily reset time or `Retry-After` value. A timed-out request may have consumed quota; check `grade --usage` before retrying.
|
|
140
|
+
|
|
141
|
+
## Agent Skill
|
|
142
|
+
|
|
143
|
+
The [GRADE Cloud Skill](skills/grade-cloud/SKILL.md) runs independently of the `grade-client` package. It needs Python and `requests`.
|
|
144
|
+
|
|
145
|
+
Install with Node.js and access to the GitHub repository:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
npx skills add devxia/GRADE --skill grade-cloud
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Alternatively, ask your agent:
|
|
152
|
+
|
|
153
|
+
> Install the grade-cloud skill from https://github.com/devxia/GRADE.
|
|
154
|
+
|
|
155
|
+
Example request:
|
|
156
|
+
|
|
157
|
+
> Use GRADE to rank the peptides in candidates.fasta against my GPCR target and save the results to scores.csv.
|
|
158
|
+
|
|
159
|
+
Provide an email address, the target sequence and candidate peptides. The Skill uses GRADE-paper and the same prediction service as the package.
|
|
160
|
+
|
|
161
|
+
The bundled script can also run directly from the cloned repository without installing `grade-client`:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
python -m pip install requests
|
|
165
|
+
python skills/grade-cloud/scripts/grade_predict.py --help
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Supply the target sequence with `--target-seq`, the candidate file with `--peptides`, and optionally an output path with `--output`. The script supports CSV, TSV, JSON and Top-K; it prints results to stdout when no output path is given. Its fields are `rank,peptide_name,sequence,score`.
|
|
169
|
+
|
|
170
|
+
## Use a local model
|
|
171
|
+
|
|
172
|
+
GRADE uses Cloud resources unless you specify a local model directory with `--model-dir`. Local inference requires no email and has no Cloud quota.
|
|
173
|
+
|
|
174
|
+
From the cloned `GRADE` directory, install the local inference dependencies:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
python -m pip install ".[local]"
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Use Python 3.11 with PyTorch 2.4.0 and Transformers 4.44.0. A CUDA-enabled GPU is recommended for larger screens; CPU inference is also supported.
|
|
181
|
+
|
|
182
|
+
Specify your configured model directory:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
grade \
|
|
186
|
+
--model-dir /path/to/model \
|
|
187
|
+
--target-name CCR5_HUMAN \
|
|
188
|
+
--peptides candidates.fasta \
|
|
189
|
+
--output local_scores.csv
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Replace `/path/to/model` with your model directory. Local inference accepts the same [inputs and result formats](#inputs-and-result-files). The `src` field defaults to the candidate filename stem locally and `grade-api` for Cloud predictions.
|
|
193
|
+
|
|
194
|
+
Local requests remain on your machine. Errors do not trigger a fallback to Cloud. `--model-dir` cannot be combined with `--model`, which selects the Cloud model.
|
|
195
|
+
|
|
196
|
+
### GPU and multi-GPU inference
|
|
197
|
+
|
|
198
|
+
For CUDA mixed precision:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
grade \
|
|
202
|
+
--model-dir /path/to/model \
|
|
203
|
+
--target-name CCR5_HUMAN \
|
|
204
|
+
--peptides candidates.fasta \
|
|
205
|
+
--output local_scores.csv \
|
|
206
|
+
--batch-size 64 \
|
|
207
|
+
--fp16
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
For four GPUs:
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
torchrun --nproc_per_node=4 --rdzv_backend=c10d --rdzv_endpoint=localhost:0 \
|
|
214
|
+
-m grade.inference \
|
|
215
|
+
--model-dir /path/to/model \
|
|
216
|
+
--target-name CCR5_HUMAN \
|
|
217
|
+
--peptides candidates.fasta \
|
|
218
|
+
--output local_scores.csv \
|
|
219
|
+
--batch-size 64 \
|
|
220
|
+
--fp16
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Batch size applies per process. Distributed execution requires an explicit local model directory. CPU users should omit mixed-precision flags.
|
|
224
|
+
|
|
225
|
+
### Local options and resume
|
|
226
|
+
|
|
227
|
+
| Local-only option | Default | Purpose |
|
|
228
|
+
|---|---|---|
|
|
229
|
+
| `--batch-size` | 8 | Candidates per batch per process |
|
|
230
|
+
| `--num-workers` | 0 | Data-loading workers per process |
|
|
231
|
+
| `--max-length` | 1024 | Tokenizer maximum length; longer sequences are truncated |
|
|
232
|
+
| `--fp16` / `--bf16` | Off | CUDA mixed precision; choose at most one |
|
|
233
|
+
| `--attn-implementation` | `sdpa` | `eager`, `sdpa`, or `flash_attention_2`, subject to runtime support |
|
|
234
|
+
| `--checkpoint-interval` | 100 | Save progress every N batches |
|
|
235
|
+
| `--no-resume` | Off | Start fresh, replacing prior progress and output |
|
|
236
|
+
| `--no-target-cache` | Off | Disable target encoding reuse |
|
|
237
|
+
|
|
238
|
+
These options require `--model-dir`.
|
|
239
|
+
|
|
240
|
+
Local runs save progress automatically. Resume with the same output path, model identity and resolved directory, target identifier/sequence, ordered candidate identifiers/sequences, effective source label, maximum length, process count, precision and attention settings. Changing the candidate filename can change its default source label. `--top-k` and output format may change when resuming. Incompatible progress files are rejected without replacing existing results; choose a new output path or explicitly use `--no-resume`.
|
|
241
|
+
|
|
242
|
+
## Cloud API
|
|
243
|
+
|
|
244
|
+
Base URL: `https://devxia--grade-web.modal.run`
|
|
245
|
+
|
|
246
|
+
The package and Skill handle these requests for most users. Direct integrations can use the same protocol:
|
|
247
|
+
|
|
248
|
+
| Endpoint | Request | Response |
|
|
249
|
+
|---|---|---|
|
|
250
|
+
| `POST /client/register` | JSON `email` | `client_token`, `client_id`, normalized `email` |
|
|
251
|
+
| `POST /usage` | Bearer credential and JSON `email` | `limit`, `remaining`, `reset_at` |
|
|
252
|
+
| `POST /predict` | Bearer credential and prediction JSON | Ranked predictions |
|
|
253
|
+
|
|
254
|
+
Register once with an email, retain the issued credential privately, and send it in subsequent requests as `Authorization: Bearer <client_token>`. Do not put real credentials in published scripts or logs.
|
|
255
|
+
|
|
256
|
+
Example prediction request for the bundled CCR5_HUMAN sequence:
|
|
257
|
+
|
|
258
|
+
```json
|
|
259
|
+
{
|
|
260
|
+
"email": "user@example.org",
|
|
261
|
+
"model": "GRADE-paper",
|
|
262
|
+
"target_seq": "MDYQVSSPIYDINYYTSEPCQKINVKQIAARLLPPLYSLVFIFGFVGNMLVILILINCKRLKSMTDIYLLNLAISDLFFLLTVPFWAHYAAAQWDFGNTMCQLLTGLYFIGFFSGIFFIILLTIDRYLAVVHAVFALKARTVTFGVVTSVITWVVAVFASLPGIIFTRSQKEGLHYTCSSHFPYSQYQFWKNFQTLKIVILGLVLPLLVMVICYSGILKTLLRCRNEKKRHRAVRLIFTIMIVYFLFWAPYNIVLLLNTFQEFFGLNNCSSSNRLDQAMQVTETLGMTHCCINPIIYAFVGEKFRNYLLVFFQKHIAKRFCKCCSIFQQEAPERASSVYTRSTGEQEISVGL",
|
|
263
|
+
"peptides": [
|
|
264
|
+
{"name": "peptide_1", "sequence": "ACDEFGHIKLMNPQRSTVWY"},
|
|
265
|
+
{"name": "peptide_2", "sequence": "YTVSRQPNMLKIHGFEDCA"}
|
|
266
|
+
]
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Omitting `model` selects GRADE-paper. Explicit null, empty or unsupported selections are rejected. Optional `format` is `json` (default), `csv` or `tsv`.
|
|
271
|
+
|
|
272
|
+
JSON responses contain `model`, `target`, `count` and descending-score `results`. Each result has `peptide_name`, `sequence` and `score`. The direct API labels its target `custom_target`; the package retains a locally resolved FASTA target name in its output. Direct CSV/TSV responses contain `rank,target,peptide_name,src,sequence,score`, with `src` set to `grade-api`.
|
|
273
|
+
|
|
274
|
+
Successful responses include `X-GRADE-Model`, `X-GRADE-Quota-Limit`, `X-GRADE-Quota-Remaining` and `X-GRADE-Quota-Reset`. The [Cloud quota](#cloud-quota) applies to every access method.
|
|
275
|
+
|
|
276
|
+
| Status | Meaning |
|
|
277
|
+
|---|---|
|
|
278
|
+
| 401 | Missing or invalid client credential |
|
|
279
|
+
| 422 | Invalid email, target, candidate list, request size, model or format |
|
|
280
|
+
| 429 | Daily quota or short-term frequency limit; follow reset/`Retry-After` |
|
|
281
|
+
| 500/503 | Server failure or uncertain outcome; check usage before retrying |
|
|
282
|
+
|
|
283
|
+
## Citation
|
|
284
|
+
|
|
285
|
+
If you use GRADE in your research, please cite:
|
|
286
|
+
|
|
287
|
+
> [Authors]. [Article title]. *[Journal]* **[Volume]**, [Pages] ([Year]). DOI: [DOI].
|
|
288
|
+
|
|
289
|
+
## License
|
|
290
|
+
|
|
291
|
+
The source code is licensed under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
# GRADE
|
|
2
|
+
|
|
3
|
+
**GPCR-targeted Ranking-guided Agonist Design Engine**
|
|
4
|
+
|
|
5
|
+
GRADE ranks candidate peptides for predicted agonist activity at a target GPCR. Supply a GPCR amino acid sequence and a peptide list to receive scores sorted from highest to lowest for experimental prioritization.
|
|
6
|
+
|
|
7
|
+
The **grade-client** Python package provides the `grade` command. GRADE is also available through an independent [Agent Skill](#agent-skill) and the [Cloud API](#cloud-api).
|
|
8
|
+
|
|
9
|
+
**GRADE-paper** is the model used in the accompanying publication.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
Use Python 3.11 or newer. Clone the [GRADE repository](https://github.com/devxia/GRADE) and install the package in a virtual environment:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
git clone https://github.com/devxia/GRADE.git
|
|
17
|
+
cd GRADE
|
|
18
|
+
|
|
19
|
+
python3.11 -m venv .venv
|
|
20
|
+
source .venv/bin/activate
|
|
21
|
+
python -m pip install .
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
An email address is required to use the prediction service.
|
|
27
|
+
|
|
28
|
+
Save your candidates as `candidates.fasta`:
|
|
29
|
+
|
|
30
|
+
```fasta
|
|
31
|
+
>peptide_1
|
|
32
|
+
ACDEFGHIKLMNPQRSTVWY
|
|
33
|
+
>peptide_2
|
|
34
|
+
YTVSRQPNMLKIHGFEDCA
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Run a prediction against the bundled human CCR5 target:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
grade \
|
|
41
|
+
--target-name CCR5_HUMAN \
|
|
42
|
+
--peptides candidates.fasta \
|
|
43
|
+
--output scores.csv
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Replace the example peptides with your candidates. For non-interactive use, add `--email user@example.org`. Run `grade --help` for all command options.
|
|
47
|
+
|
|
48
|
+
### Use your own target
|
|
49
|
+
|
|
50
|
+
Save the complete amino acid sequence of your target in `target.fasta`, then run:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
grade \
|
|
54
|
+
--target-fasta target.fasta \
|
|
55
|
+
--peptides candidates.fasta \
|
|
56
|
+
--output scores.csv
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
If the target FASTA has several entries, add `--target-name` with the complete header of the desired entry. Each invocation scores one target. You may instead supply its amino acid sequence directly with `--target-seq`.
|
|
60
|
+
|
|
61
|
+
### Inputs and result files
|
|
62
|
+
|
|
63
|
+
| Target input | Arguments | Requirement |
|
|
64
|
+
|---|---|---|
|
|
65
|
+
| Bundled GPCR | `--target-name CCR5_HUMAN` | Exact header in the [bundled FASTA](grade/targets/targets_gpcr_v2.fa) |
|
|
66
|
+
| One sequence in a file | `--target-fasta target.fasta` | Exactly one FASTA entry |
|
|
67
|
+
| Selected entry in a file | `--target-fasta targets.fa --target-name CCR5_HUMAN` | Exact complete header in the supplied FASTA |
|
|
68
|
+
| Direct sequence | `--target-seq` followed by the amino acid sequence | Cannot be combined with other target arguments |
|
|
69
|
+
|
|
70
|
+
| Peptide format | Extensions | Contents |
|
|
71
|
+
|---|---|---|
|
|
72
|
+
| FASTA | `.fasta`, `.faa`, `.fa` | Full header becomes the candidate identifier |
|
|
73
|
+
| CSV | `.csv` | `sequence`, `peptide` or `seq` column; optional `name`, `peptide_name` or `id` |
|
|
74
|
+
| Text | `.txt` | One sequence per line, or whitespace-separated name and sequence |
|
|
75
|
+
|
|
76
|
+
Sequence whitespace is removed and letters are uppercased. Empty sequences and duplicate identifiers are rejected. Supply amino acid letters without residue numbers or chemical modification notation. Cloud encodes each target and peptide with a 1024-token limit, including special tokens; longer sequences are truncated.
|
|
77
|
+
|
|
78
|
+
Use the output extension to choose CSV, TSV or JSON. To keep only the highest-scoring candidates:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
grade \
|
|
82
|
+
--target-name CCR5_HUMAN \
|
|
83
|
+
--peptides candidates.fasta \
|
|
84
|
+
--top-k 20 \
|
|
85
|
+
--output top20.json
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
`--output-format` overrides extension-based selection. An unrecognized extension defaults to CSV. The package writes the following fields; JSON output is an array with the same keys:
|
|
89
|
+
|
|
90
|
+
| Field | Meaning |
|
|
91
|
+
|---|---|
|
|
92
|
+
| `rank` | Descending-score rank, starting at 1 |
|
|
93
|
+
| `target` | Selected target header, or `custom_target` for a direct sequence |
|
|
94
|
+
| `peptide_name` | Candidate identifier |
|
|
95
|
+
| `src` | Source label; override with `--source-label` |
|
|
96
|
+
| `sequence` | Normalized candidate sequence |
|
|
97
|
+
| `score` | Positive-class softmax score from 0 to 1 |
|
|
98
|
+
|
|
99
|
+
Higher scores indicate greater predicted agonist potential for the target GPCR. The accompanying work treats scores above 0.9 as high-confidence candidates for experimental prioritization, not as a mandatory cutoff or calibrated probability of success. Functional assays are needed to establish agonist activity.
|
|
100
|
+
|
|
101
|
+
Results are checked before the output file is replaced. `grade-inference`, `python -m grade` and `python -m grade.inference` accept the same arguments as `grade`; `--output-csv` remains an alias for `--output`.
|
|
102
|
+
|
|
103
|
+
### Cloud quota
|
|
104
|
+
|
|
105
|
+
View the remaining daily prediction quota and reset time:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
grade --usage
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
| Limit | Value |
|
|
112
|
+
|---|---|
|
|
113
|
+
| Peptides per request | Up to 50 |
|
|
114
|
+
| Predictions per email per UTC day | 50 |
|
|
115
|
+
| Predictions per client per UTC day | 50, counted independently |
|
|
116
|
+
| Effective available quota | Smaller of the two remaining balances |
|
|
117
|
+
| Reset time | UTC midnight; 08:00 Beijing time |
|
|
118
|
+
|
|
119
|
+
The package and Skill share the same quota. Repeated predictions count again, and `--top-k` does not reduce the number submitted. Users sharing a public IP do not share a daily quota.
|
|
120
|
+
|
|
121
|
+
If the service returns 429, follow the daily reset time or `Retry-After` value. A timed-out request may have consumed quota; check `grade --usage` before retrying.
|
|
122
|
+
|
|
123
|
+
## Agent Skill
|
|
124
|
+
|
|
125
|
+
The [GRADE Cloud Skill](skills/grade-cloud/SKILL.md) runs independently of the `grade-client` package. It needs Python and `requests`.
|
|
126
|
+
|
|
127
|
+
Install with Node.js and access to the GitHub repository:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
npx skills add devxia/GRADE --skill grade-cloud
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Alternatively, ask your agent:
|
|
134
|
+
|
|
135
|
+
> Install the grade-cloud skill from https://github.com/devxia/GRADE.
|
|
136
|
+
|
|
137
|
+
Example request:
|
|
138
|
+
|
|
139
|
+
> Use GRADE to rank the peptides in candidates.fasta against my GPCR target and save the results to scores.csv.
|
|
140
|
+
|
|
141
|
+
Provide an email address, the target sequence and candidate peptides. The Skill uses GRADE-paper and the same prediction service as the package.
|
|
142
|
+
|
|
143
|
+
The bundled script can also run directly from the cloned repository without installing `grade-client`:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
python -m pip install requests
|
|
147
|
+
python skills/grade-cloud/scripts/grade_predict.py --help
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Supply the target sequence with `--target-seq`, the candidate file with `--peptides`, and optionally an output path with `--output`. The script supports CSV, TSV, JSON and Top-K; it prints results to stdout when no output path is given. Its fields are `rank,peptide_name,sequence,score`.
|
|
151
|
+
|
|
152
|
+
## Use a local model
|
|
153
|
+
|
|
154
|
+
GRADE uses Cloud resources unless you specify a local model directory with `--model-dir`. Local inference requires no email and has no Cloud quota.
|
|
155
|
+
|
|
156
|
+
From the cloned `GRADE` directory, install the local inference dependencies:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
python -m pip install ".[local]"
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Use Python 3.11 with PyTorch 2.4.0 and Transformers 4.44.0. A CUDA-enabled GPU is recommended for larger screens; CPU inference is also supported.
|
|
163
|
+
|
|
164
|
+
Specify your configured model directory:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
grade \
|
|
168
|
+
--model-dir /path/to/model \
|
|
169
|
+
--target-name CCR5_HUMAN \
|
|
170
|
+
--peptides candidates.fasta \
|
|
171
|
+
--output local_scores.csv
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Replace `/path/to/model` with your model directory. Local inference accepts the same [inputs and result formats](#inputs-and-result-files). The `src` field defaults to the candidate filename stem locally and `grade-api` for Cloud predictions.
|
|
175
|
+
|
|
176
|
+
Local requests remain on your machine. Errors do not trigger a fallback to Cloud. `--model-dir` cannot be combined with `--model`, which selects the Cloud model.
|
|
177
|
+
|
|
178
|
+
### GPU and multi-GPU inference
|
|
179
|
+
|
|
180
|
+
For CUDA mixed precision:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
grade \
|
|
184
|
+
--model-dir /path/to/model \
|
|
185
|
+
--target-name CCR5_HUMAN \
|
|
186
|
+
--peptides candidates.fasta \
|
|
187
|
+
--output local_scores.csv \
|
|
188
|
+
--batch-size 64 \
|
|
189
|
+
--fp16
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
For four GPUs:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
torchrun --nproc_per_node=4 --rdzv_backend=c10d --rdzv_endpoint=localhost:0 \
|
|
196
|
+
-m grade.inference \
|
|
197
|
+
--model-dir /path/to/model \
|
|
198
|
+
--target-name CCR5_HUMAN \
|
|
199
|
+
--peptides candidates.fasta \
|
|
200
|
+
--output local_scores.csv \
|
|
201
|
+
--batch-size 64 \
|
|
202
|
+
--fp16
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Batch size applies per process. Distributed execution requires an explicit local model directory. CPU users should omit mixed-precision flags.
|
|
206
|
+
|
|
207
|
+
### Local options and resume
|
|
208
|
+
|
|
209
|
+
| Local-only option | Default | Purpose |
|
|
210
|
+
|---|---|---|
|
|
211
|
+
| `--batch-size` | 8 | Candidates per batch per process |
|
|
212
|
+
| `--num-workers` | 0 | Data-loading workers per process |
|
|
213
|
+
| `--max-length` | 1024 | Tokenizer maximum length; longer sequences are truncated |
|
|
214
|
+
| `--fp16` / `--bf16` | Off | CUDA mixed precision; choose at most one |
|
|
215
|
+
| `--attn-implementation` | `sdpa` | `eager`, `sdpa`, or `flash_attention_2`, subject to runtime support |
|
|
216
|
+
| `--checkpoint-interval` | 100 | Save progress every N batches |
|
|
217
|
+
| `--no-resume` | Off | Start fresh, replacing prior progress and output |
|
|
218
|
+
| `--no-target-cache` | Off | Disable target encoding reuse |
|
|
219
|
+
|
|
220
|
+
These options require `--model-dir`.
|
|
221
|
+
|
|
222
|
+
Local runs save progress automatically. Resume with the same output path, model identity and resolved directory, target identifier/sequence, ordered candidate identifiers/sequences, effective source label, maximum length, process count, precision and attention settings. Changing the candidate filename can change its default source label. `--top-k` and output format may change when resuming. Incompatible progress files are rejected without replacing existing results; choose a new output path or explicitly use `--no-resume`.
|
|
223
|
+
|
|
224
|
+
## Cloud API
|
|
225
|
+
|
|
226
|
+
Base URL: `https://devxia--grade-web.modal.run`
|
|
227
|
+
|
|
228
|
+
The package and Skill handle these requests for most users. Direct integrations can use the same protocol:
|
|
229
|
+
|
|
230
|
+
| Endpoint | Request | Response |
|
|
231
|
+
|---|---|---|
|
|
232
|
+
| `POST /client/register` | JSON `email` | `client_token`, `client_id`, normalized `email` |
|
|
233
|
+
| `POST /usage` | Bearer credential and JSON `email` | `limit`, `remaining`, `reset_at` |
|
|
234
|
+
| `POST /predict` | Bearer credential and prediction JSON | Ranked predictions |
|
|
235
|
+
|
|
236
|
+
Register once with an email, retain the issued credential privately, and send it in subsequent requests as `Authorization: Bearer <client_token>`. Do not put real credentials in published scripts or logs.
|
|
237
|
+
|
|
238
|
+
Example prediction request for the bundled CCR5_HUMAN sequence:
|
|
239
|
+
|
|
240
|
+
```json
|
|
241
|
+
{
|
|
242
|
+
"email": "user@example.org",
|
|
243
|
+
"model": "GRADE-paper",
|
|
244
|
+
"target_seq": "MDYQVSSPIYDINYYTSEPCQKINVKQIAARLLPPLYSLVFIFGFVGNMLVILILINCKRLKSMTDIYLLNLAISDLFFLLTVPFWAHYAAAQWDFGNTMCQLLTGLYFIGFFSGIFFIILLTIDRYLAVVHAVFALKARTVTFGVVTSVITWVVAVFASLPGIIFTRSQKEGLHYTCSSHFPYSQYQFWKNFQTLKIVILGLVLPLLVMVICYSGILKTLLRCRNEKKRHRAVRLIFTIMIVYFLFWAPYNIVLLLNTFQEFFGLNNCSSSNRLDQAMQVTETLGMTHCCINPIIYAFVGEKFRNYLLVFFQKHIAKRFCKCCSIFQQEAPERASSVYTRSTGEQEISVGL",
|
|
245
|
+
"peptides": [
|
|
246
|
+
{"name": "peptide_1", "sequence": "ACDEFGHIKLMNPQRSTVWY"},
|
|
247
|
+
{"name": "peptide_2", "sequence": "YTVSRQPNMLKIHGFEDCA"}
|
|
248
|
+
]
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Omitting `model` selects GRADE-paper. Explicit null, empty or unsupported selections are rejected. Optional `format` is `json` (default), `csv` or `tsv`.
|
|
253
|
+
|
|
254
|
+
JSON responses contain `model`, `target`, `count` and descending-score `results`. Each result has `peptide_name`, `sequence` and `score`. The direct API labels its target `custom_target`; the package retains a locally resolved FASTA target name in its output. Direct CSV/TSV responses contain `rank,target,peptide_name,src,sequence,score`, with `src` set to `grade-api`.
|
|
255
|
+
|
|
256
|
+
Successful responses include `X-GRADE-Model`, `X-GRADE-Quota-Limit`, `X-GRADE-Quota-Remaining` and `X-GRADE-Quota-Reset`. The [Cloud quota](#cloud-quota) applies to every access method.
|
|
257
|
+
|
|
258
|
+
| Status | Meaning |
|
|
259
|
+
|---|---|
|
|
260
|
+
| 401 | Missing or invalid client credential |
|
|
261
|
+
| 422 | Invalid email, target, candidate list, request size, model or format |
|
|
262
|
+
| 429 | Daily quota or short-term frequency limit; follow reset/`Retry-After` |
|
|
263
|
+
| 500/503 | Server failure or uncertain outcome; check usage before retrying |
|
|
264
|
+
|
|
265
|
+
## Citation
|
|
266
|
+
|
|
267
|
+
If you use GRADE in your research, please cite:
|
|
268
|
+
|
|
269
|
+
> [Authors]. [Article title]. *[Journal]* **[Volume]**, [Pages] ([Year]). DOI: [DOI].
|
|
270
|
+
|
|
271
|
+
## License
|
|
272
|
+
|
|
273
|
+
The source code is licensed under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""Fail package builds when the independently distributed Skill is stale."""
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
import runpy
|
|
4
|
+
|
|
5
|
+
from setuptools.command.build_py import build_py
|
|
6
|
+
from setuptools.command.sdist import sdist
|
|
7
|
+
|
|
8
|
+
# Build backends need not add the source root to sys.path.
|
|
9
|
+
check_sync = runpy.run_path(str(Path(__file__).resolve().parent / "scripts/sync_cloud_skill.py"))["check_sync"]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class CheckedBuildPy(build_py):
|
|
13
|
+
def run(self):
|
|
14
|
+
check_sync()
|
|
15
|
+
super().run()
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class CheckedSdist(sdist):
|
|
19
|
+
def run(self):
|
|
20
|
+
check_sync()
|
|
21
|
+
super().run()
|