peptalk-llm 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.
- peptalk_llm-0.1.0/.github/workflows/ci.yml +22 -0
- peptalk_llm-0.1.0/.github/workflows/pypi-publish.yaml +35 -0
- peptalk_llm-0.1.0/.gitignore +7 -0
- peptalk_llm-0.1.0/.python-version +1 -0
- peptalk_llm-0.1.0/CHANGELOG.md +31 -0
- peptalk_llm-0.1.0/LICENSE +21 -0
- peptalk_llm-0.1.0/PKG-INFO +423 -0
- peptalk_llm-0.1.0/README.md +387 -0
- peptalk_llm-0.1.0/RELEASING.md +13 -0
- peptalk_llm-0.1.0/docs/design.md +158 -0
- peptalk_llm-0.1.0/docs/provider-options.html +367 -0
- peptalk_llm-0.1.0/docs/shared-database.md +53 -0
- peptalk_llm-0.1.0/docs/templates.md +155 -0
- peptalk_llm-0.1.0/examples/proteins.fasta +30 -0
- peptalk_llm-0.1.0/justfile +32 -0
- peptalk_llm-0.1.0/pyproject.toml +82 -0
- peptalk_llm-0.1.0/src/peptalk/__init__.py +26 -0
- peptalk_llm-0.1.0/src/peptalk/annotator.py +357 -0
- peptalk_llm-0.1.0/src/peptalk/batch.py +148 -0
- peptalk_llm-0.1.0/src/peptalk/checks.py +92 -0
- peptalk_llm-0.1.0/src/peptalk/cli.py +620 -0
- peptalk_llm-0.1.0/src/peptalk/exchange.py +182 -0
- peptalk_llm-0.1.0/src/peptalk/fasta.py +174 -0
- peptalk_llm-0.1.0/src/peptalk/headers.py +91 -0
- peptalk_llm-0.1.0/src/peptalk/parse.py +62 -0
- peptalk_llm-0.1.0/src/peptalk/pricing.py +71 -0
- peptalk_llm-0.1.0/src/peptalk/providers/__init__.py +92 -0
- peptalk_llm-0.1.0/src/peptalk/providers/anthropic.py +143 -0
- peptalk_llm-0.1.0/src/peptalk/providers/base.py +56 -0
- peptalk_llm-0.1.0/src/peptalk/providers/gemini.py +122 -0
- peptalk_llm-0.1.0/src/peptalk/providers/openai.py +129 -0
- peptalk_llm-0.1.0/src/peptalk/providers/stub.py +65 -0
- peptalk_llm-0.1.0/src/peptalk/py.typed +0 -0
- peptalk_llm-0.1.0/src/peptalk/report.py +113 -0
- peptalk_llm-0.1.0/src/peptalk/schema.py +185 -0
- peptalk_llm-0.1.0/src/peptalk/server.py +324 -0
- peptalk_llm-0.1.0/src/peptalk/store.py +274 -0
- peptalk_llm-0.1.0/src/peptalk/templates/__init__.py +279 -0
- peptalk_llm-0.1.0/src/peptalk/templates/active_site/__init__.py +83 -0
- peptalk_llm-0.1.0/src/peptalk/templates/active_site/prompt.txt +4 -0
- peptalk_llm-0.1.0/src/peptalk/templates/ask/__init__.py +85 -0
- peptalk_llm-0.1.0/src/peptalk/templates/ask/catalytic_residue.txt +4 -0
- peptalk_llm-0.1.0/src/peptalk/templates/ask/function.txt +4 -0
- peptalk_llm-0.1.0/src/peptalk/templates/ask/localization.txt +4 -0
- peptalk_llm-0.1.0/src/peptalk/templates/combined/__init__.py +64 -0
- peptalk_llm-0.1.0/src/peptalk/templates/combined/prompt.txt +18 -0
- peptalk_llm-0.1.0/src/peptalk/templates/features/__init__.py +86 -0
- peptalk_llm-0.1.0/src/peptalk/templates/features/prompt.txt +4 -0
- peptalk_llm-0.1.0/src/peptalk/templates/function/__init__.py +59 -0
- peptalk_llm-0.1.0/src/peptalk/templates/function/prompt.txt +4 -0
- peptalk_llm-0.1.0/src/peptalk/templates/localization/__init__.py +98 -0
- peptalk_llm-0.1.0/src/peptalk/templates/localization/prompt.txt +4 -0
- peptalk_llm-0.1.0/src/peptalk/templates/structure/__init__.py +78 -0
- peptalk_llm-0.1.0/src/peptalk/templates/structure/prompt.txt +4 -0
- peptalk_llm-0.1.0/tests/conftest.py +57 -0
- peptalk_llm-0.1.0/tests/data/example.fasta +30 -0
- peptalk_llm-0.1.0/tests/data/fs2f_features_reply.json +5 -0
- peptalk_llm-0.1.0/tests/data/fs2f_pseudo_replies.json +17 -0
- peptalk_llm-0.1.0/tests/test_annotator.py +74 -0
- peptalk_llm-0.1.0/tests/test_anthropic.py +144 -0
- peptalk_llm-0.1.0/tests/test_batch.py +48 -0
- peptalk_llm-0.1.0/tests/test_cli.py +157 -0
- peptalk_llm-0.1.0/tests/test_context_payload.py +116 -0
- peptalk_llm-0.1.0/tests/test_fasta.py +22 -0
- peptalk_llm-0.1.0/tests/test_gemini.py +84 -0
- peptalk_llm-0.1.0/tests/test_headers.py +54 -0
- peptalk_llm-0.1.0/tests/test_openai.py +101 -0
- peptalk_llm-0.1.0/tests/test_parse_and_checks.py +49 -0
- peptalk_llm-0.1.0/tests/test_readme.py +23 -0
- peptalk_llm-0.1.0/tests/test_server.py +148 -0
- peptalk_llm-0.1.0/tests/test_store.py +70 -0
- peptalk_llm-0.1.0/tests/test_tasks.py +89 -0
- peptalk_llm-0.1.0/uv.lock +1686 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [main]
|
|
5
|
+
pull_request:
|
|
6
|
+
jobs:
|
|
7
|
+
test:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
strategy:
|
|
10
|
+
matrix:
|
|
11
|
+
python-version: ["3.11", "3.12", "3.13"]
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- uses: astral-sh/setup-uv@v6
|
|
15
|
+
with:
|
|
16
|
+
python-version: ${{ matrix.python-version }}
|
|
17
|
+
- run: uv sync --all-extras
|
|
18
|
+
- run: uv run ruff check src tests
|
|
19
|
+
- run: uv run ruff format --check src tests
|
|
20
|
+
- run: uv run mypy src
|
|
21
|
+
- run: uv run pytest
|
|
22
|
+
- run: uv build
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
name: Publish Python Package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
release:
|
|
6
|
+
types: [created]
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build-n-publish:
|
|
10
|
+
name: Build and publish Python 🐍 distributions 📦 to PyPI
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
environment: release
|
|
13
|
+
permissions:
|
|
14
|
+
id-token: write
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v6
|
|
17
|
+
|
|
18
|
+
- name: Install uv
|
|
19
|
+
uses: astral-sh/setup-uv@v7
|
|
20
|
+
|
|
21
|
+
- name: Set up Python
|
|
22
|
+
uses: actions/setup-python@v6
|
|
23
|
+
with:
|
|
24
|
+
python-version: '3.12'
|
|
25
|
+
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: uv sync --all-extras
|
|
28
|
+
|
|
29
|
+
- name: Build source and wheel archives
|
|
30
|
+
run: uv build
|
|
31
|
+
|
|
32
|
+
- name: Publish
|
|
33
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
34
|
+
with:
|
|
35
|
+
verbose: true
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.11
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 (first release)
|
|
4
|
+
|
|
5
|
+
peptalk (on PyPI as `peptalk-llm`; import and command `peptalk`) asks a frontier LLM what a protein sequence says, from sequence alone, by direct single-shot API calls.
|
|
6
|
+
|
|
7
|
+
- **Providers:** direct clients for Anthropic (Messages API), Gemini and OpenAI. Each question is one user message
|
|
8
|
+
with no system prompt and no tools. An input-token check confirms that nothing besides the prompt was sent.
|
|
9
|
+
- **Tasks:** `features`, `active-site` and `structure`, the prompts of the fable-sequence-to-function study,
|
|
10
|
+
checked byte for byte when blind. Also `function`, `combined`, `localization`, and the ask templates
|
|
11
|
+
`ask-function`, `ask-catalytic-residue` and `ask-localization` (yes/no/uncertain verdicts on one claim, with
|
|
12
|
+
`peptalk ask --claims`).
|
|
13
|
+
- **Checks instead of model confidence:**
|
|
14
|
+
- residues at their stated positions, ranges inside the sequence, identifiers well formed;
|
|
15
|
+
- optional shuffled-sequence controls.
|
|
16
|
+
- **FASTA headers:** UniProt, NCBI and plain profiles, with all fields kept on each record.
|
|
17
|
+
- **Header context:** `--context blind|organism|full`, defaulting to `organism`.
|
|
18
|
+
- **Optional payloads:** a stated confidence, a rationale, residue evidence and alternatives (`--with`).
|
|
19
|
+
- **Structured output:** provider JSON-Schema output, off unless `--structured` is given.
|
|
20
|
+
- **Store:** a SQLite log of every call with full provenance, which also serves as the cache. Cache-key fields
|
|
21
|
+
are configurable; the default covers sequence MD5, task, prompt version, parameters, context, payload, output
|
|
22
|
+
mode, provider, model and effort.
|
|
23
|
+
- **Batches:** the batch APIs of Anthropic, OpenAI and Gemini, at half price.
|
|
24
|
+
- **Exports:**
|
|
25
|
+
- JSONL export and import that merge without duplicates;
|
|
26
|
+
- Parquet, for querying with DuckDB;
|
|
27
|
+
- GFF3 of located features;
|
|
28
|
+
- FASTA of annotated sequences named by MD5, for DIAMOND or BLAST.
|
|
29
|
+
- **REST API:** FastAPI (`peptalk-llm[server]`, `peptalk serve`), with synchronous annotation, background and
|
|
30
|
+
batch jobs, and lookup by sequence MD5.
|
|
31
|
+
- **Docs:** `docs/design.md`, `docs/templates.md` and `docs/provider-options.html`.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Christopher J. Mungall and Marcin P. Joachimiak
|
|
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,423 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: peptalk-llm
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Ask a frontier LLM what a protein sequence says, from sequence alone: domains, membrane features, active sites, structure and function of full-length proteins
|
|
5
|
+
Project-URL: Homepage, https://github.com/ai4curation/peptalk
|
|
6
|
+
Project-URL: Study, https://github.com/ai4curation/fable-sequence-to-function
|
|
7
|
+
Author: Marcin P. Joachimiak
|
|
8
|
+
Author-email: Chris Mungall <cjm@berkeleybop.org>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: annotation,bioinformatics,claude,gene ontology,llm,pfam,protein
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
16
|
+
Requires-Python: >=3.11
|
|
17
|
+
Requires-Dist: anthropic>=2.14.0
|
|
18
|
+
Requires-Dist: pydantic>=2.14.4
|
|
19
|
+
Requires-Dist: typer>=0.29.2
|
|
20
|
+
Provides-Extra: all
|
|
21
|
+
Requires-Dist: fastapi>=0.165.0; extra == 'all'
|
|
22
|
+
Requires-Dist: google-genai>=3.6.1; extra == 'all'
|
|
23
|
+
Requires-Dist: openai>=3.59.0; extra == 'all'
|
|
24
|
+
Requires-Dist: pyarrow>=26.0.1; extra == 'all'
|
|
25
|
+
Requires-Dist: uvicorn>=0.54.0; extra == 'all'
|
|
26
|
+
Provides-Extra: gemini
|
|
27
|
+
Requires-Dist: google-genai>=3.6.1; extra == 'gemini'
|
|
28
|
+
Provides-Extra: openai
|
|
29
|
+
Requires-Dist: openai>=3.59.0; extra == 'openai'
|
|
30
|
+
Provides-Extra: parquet
|
|
31
|
+
Requires-Dist: pyarrow>=26.0.1; extra == 'parquet'
|
|
32
|
+
Provides-Extra: server
|
|
33
|
+
Requires-Dist: fastapi>=0.165.0; extra == 'server'
|
|
34
|
+
Requires-Dist: uvicorn>=0.54.0; extra == 'server'
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
# peptalk
|
|
38
|
+
|
|
39
|
+
**peptalk: ask a frontier LLM what a protein sequence says, from sequence alone.**
|
|
40
|
+
|
|
41
|
+
Despite the name, peptalk works on full-length proteins, not just peptides. It returns Pfam domains with
|
|
42
|
+
boundaries, transmembrane helices, signal peptides, catalytic residues that are present or substituted,
|
|
43
|
+
secondary structure and contacts, and function.
|
|
44
|
+
|
|
45
|
+
Each question is one direct API call to Anthropic, Gemini or OpenAI: a single user message holding the prompt
|
|
46
|
+
and the sequence, with no system prompt, no tools and no agent. Every call is checked against the sequence,
|
|
47
|
+
priced, and logged with full provenance in a local SQLite store, which also serves as the cache. The prompts
|
|
48
|
+
come from the [fable-sequence-to-function](https://github.com/ai4curation/fable-sequence-to-function) study
|
|
49
|
+
(fs2f). The study's manuscript is
|
|
50
|
+
[manuscript.pdf](https://github.com/ai4curation/fable-sequence-to-function/blob/main/manuscript.pdf), with a
|
|
51
|
+
[summary of results](https://ai4curation.io/fable-sequence-to-function/); the preprint is forthcoming.
|
|
52
|
+
|
|
53
|
+
On PyPI the package is `peptalk-llm`, because the name `peptalk` was too close to an existing project; the
|
|
54
|
+
import and the command are both `peptalk`.
|
|
55
|
+
|
|
56
|
+
## Install
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install peptalk-llm # Claude models
|
|
60
|
+
pip install 'peptalk-llm[all]' # adds Gemini, OpenAI, the REST API and Parquet export
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
With [uv](https://docs.astral.sh/uv/): `uv tool install 'peptalk-llm[all]'`, or try it without
|
|
64
|
+
installing: `uvx --from peptalk-llm peptalk --help`.
|
|
65
|
+
|
|
66
|
+
The extras are `gemini`, `openai`, `server` (REST API) and `parquet`; `all` is all four.
|
|
67
|
+
|
|
68
|
+
## Set a key
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
export ANTHROPIC_API_KEY=sk-ant-... # Claude
|
|
72
|
+
export GEMINI_API_KEY=... # Gemini (or GOOGLE_API_KEY)
|
|
73
|
+
export OPENAI_API_KEY=sk-... # OpenAI
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The provider follows from the model name (`claude-*`, `gemini-*`, `gpt-*`), or set `--provider`.
|
|
77
|
+
|
|
78
|
+
## Quickstart (CLI)
|
|
79
|
+
|
|
80
|
+
The examples use [`examples/proteins.fasta`](https://github.com/ai4curation/peptalk/blob/main/examples/proteins.fasta):
|
|
81
|
+
three proteins from the fs2f tests. They are an ABC transporter ATPase (UniProt A0ABQ0J1P6), the *Toxoplasma*
|
|
82
|
+
kinase ROP17 (Q2PAY3), and ROP17 with its catalytic Asp436 changed to Asn. In a clone of this repository the file
|
|
83
|
+
is already there; otherwise fetch it:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
mkdir -p examples
|
|
87
|
+
curl -sL -o examples/proteins.fasta https://raw.githubusercontent.com/ai4curation/peptalk/main/examples/proteins.fasta
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Annotate a FASTA file.** Each sequence is asked each task. Records go to `results.jsonl`, and progress and a
|
|
91
|
+
cost total go to the terminal:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
peptalk annotate examples/proteins.fasta -t features -t active-site -o results.jsonl
|
|
95
|
+
peptalk summarize results.jsonl
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
id task condition confidence protein_name call
|
|
100
|
+
A0ABQ0J1P6 features real checks_passed ABC transporter ATP-binding prot… PF00005:27-224
|
|
101
|
+
Q2PAY3_asp_to_asn active-site real checks_passed Rhoptry protein of the ROP2 fam… active=no lost D436N,R435G,G456T
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
(Answers from live runs: Claude Haiku 5.5 at low effort for the first row, Claude Fable 5.2 at high effort for
|
|
105
|
+
the second.)
|
|
106
|
+
|
|
107
|
+
`id` is the first word of the FASTA header, kept so you can match results to your input. `protein_name` is the
|
|
108
|
+
model's own guess. The header's identifier and name reach the model only with `--context full`; by default it
|
|
109
|
+
sees the organism at most (see [Header context](#header-context)), so its name owes nothing to yours. Here it
|
|
110
|
+
named the ROP17 mutant a ROP2-family pseudokinase without seeing "ROP17" anywhere.
|
|
111
|
+
|
|
112
|
+
**One sequence, from standard input, as a table:**
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
printf '>my_protein\nMKTAYIAKQRQISFVKSHFSRQLEERLGLIEVQAPILSRVGDGTQDNLSGAEKAVQVKVKALPDAQ\n' \
|
|
116
|
+
| peptalk annotate - -t active-site -m claude-opus-5-5 -e medium -f tsv
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Add the shuffled control.** The same task is also asked of a shuffled copy of each sequence. An answer is
|
|
120
|
+
flagged when the shuffled copy also gets a domain, an "active" call or a recognised name:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
peptalk annotate examples/proteins.fasta -t features --shuffle-control -o results.jsonl
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Check one claim at a time.** Ask templates put a single claim to the model and get back yes, no or uncertain.
|
|
127
|
+
A claims file has one row per claim:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
printf 'id\ttask\tposition\tresidue\nQ2PAY3_wt\task-catalytic-residue\t436\tD\n' > claims.tsv
|
|
131
|
+
peptalk ask examples/proteins.fasta --claims claims.tsv -w confidence
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Ask for more than the annotation.** `--with` (`-w`) adds a stated confidence, a short rationale, the residues
|
|
135
|
+
cited as evidence (checked against the sequence), or the alternatives considered. These cost tokens and can
|
|
136
|
+
change the answer, so keep one choice for a whole evaluation:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
peptalk annotate examples/proteins.fasta -t active-site -w confidence,evidence
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Many sequences: a batch.** A batch costs half as much and returns within 24 hours. Sequences that already
|
|
143
|
+
have stored answers are left out:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
peptalk batch submit examples/proteins.fasta -t features --manifest run1.json
|
|
147
|
+
peptalk batch status run1.json
|
|
148
|
+
peptalk batch collect run1.json -o results.jsonl
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
**Inspect the log and cache.** Every call is logged, and asking again reuses the stored answer:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
peptalk log # the 20 most recent calls
|
|
155
|
+
peptalk log --sql "SELECT model, count(*) AS calls, sum(thinking_tokens) AS thinking, round(sum(cost_usd), 2) AS usd
|
|
156
|
+
FROM calls GROUP BY model"
|
|
157
|
+
peptalk annotate examples/proteins.fasta --no-reuse # ask again anyway
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Export and share:**
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
peptalk export -o mine.jsonl # every logged call, one JSON record per line
|
|
164
|
+
peptalk import theirs.jsonl # merge someone else's export; calls already present are skipped
|
|
165
|
+
peptalk export --parquet calls.parquet # for DuckDB, pandas, polars
|
|
166
|
+
peptalk export --gff3 features.gff3 # located features (domains, TM helices, residues) as GFF3
|
|
167
|
+
peptalk fasta -o annotated.fasta # each annotated sequence once, named by its MD5, for DIAMOND or BLAST
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
`peptalk --help` lists every command and `peptalk COMMAND --help` its options. `peptalk tasks` lists the tasks with their
|
|
171
|
+
prompt versions. `peptalk tasks --show active-site` prints a task's prompt template and `--schema` its answer
|
|
172
|
+
schema. `peptalk headers FILE` shows the fields parsed from each header. `--provider stub` calls no model,
|
|
173
|
+
so a pipeline can be checked for free.
|
|
174
|
+
|
|
175
|
+
## REST API
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
pip install 'peptalk-llm[server]'
|
|
179
|
+
peptalk serve # http://127.0.0.1:8000, OpenAPI docs at /docs
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
| Endpoint | What it does |
|
|
183
|
+
|---|---|
|
|
184
|
+
| `POST /annotate` | Annotate a few sequences and wait for the answers (up to `--max-sync` questions, default 20). |
|
|
185
|
+
| `POST /jobs` | Start a larger job: `"mode": "live"` asks in the background, `"mode": "batch"` submits one provider batch. Returns a `job_id`. |
|
|
186
|
+
| `GET /jobs/{job_id}` | Job status, with the answers once done. Polling a batch job collects it when the provider has finished. |
|
|
187
|
+
| `GET /sequences/{seq_md5}` | Every stored answer for a sequence, by the MD5 of its upper-case residues; filter with `?task=` and `?model=`. |
|
|
188
|
+
| `GET /health`, `GET /models`, `GET /tasks`, `GET /tasks/{name}/schema` | Status and record count; installed providers, defaults and prices; tasks, prompt versions and parameters; a task's answer schema. |
|
|
189
|
+
|
|
190
|
+
Requests take the CLI's options as fields: `context`, `header_profile`, `params` (for ask templates), `payload`,
|
|
191
|
+
`structured`, `shuffle_control`, `reuse` and `verify_input`.
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
curl -s localhost:8000/annotate -H 'content-type: application/json' -d '{
|
|
195
|
+
"sequences": [{"id": "my_protein", "sequence": "MKTAYIAKQRQISFVKSHFSRQLEERLGLIEVQAPILSRVGDGTQDNLSGAEKAVQVKVKALPDAQ"}],
|
|
196
|
+
"tasks": ["active-site"], "model": "claude-opus-5-5", "effort": "medium"}'
|
|
197
|
+
|
|
198
|
+
curl -s localhost:8000/jobs -H 'content-type: application/json' \
|
|
199
|
+
-d "{\"fasta\": $(jq -Rs . < examples/proteins.fasta), \"tasks\": [\"features\"], \"mode\": \"batch\"}"
|
|
200
|
+
curl -s localhost:8000/jobs/JOB_ID
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
The server takes provider keys from its own environment and logs to the same store as the CLI. It has no
|
|
204
|
+
authentication of its own, so it listens on localhost unless you pass `--host`.
|
|
205
|
+
|
|
206
|
+
## Python
|
|
207
|
+
|
|
208
|
+
```python
|
|
209
|
+
from peptalk import Annotator, Store, read_fasta
|
|
210
|
+
from peptalk.providers import provider_for
|
|
211
|
+
from peptalk.store import default_db_path
|
|
212
|
+
|
|
213
|
+
model = "claude-fable-5-2"
|
|
214
|
+
annotator = Annotator(provider_for(model), model=model, effort="high", store=Store(default_db_path()),
|
|
215
|
+
context="organism", payload=["confidence"])
|
|
216
|
+
|
|
217
|
+
for a in annotator.annotate(read_fasta("examples/proteins.fasta"), ["active-site"], shuffle_control=True):
|
|
218
|
+
print(a.id, a.condition, a.confidence, (a.answer or {}).get("catalytically_active"), a.cost_usd)
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Each result is an `Annotation` (a Pydantic model). It carries the parsed `answer`, the reply `text`, the
|
|
222
|
+
`checks`, `usage` (input, output and thinking tokens) and `cost_usd`, plus provenance: `seq_md5`,
|
|
223
|
+
`prompt_version`, `served_model` and `options`. Batches are in `peptalk.batch`
|
|
224
|
+
(`submit`, `collect`) and the API in `peptalk.server.create_app`.
|
|
225
|
+
|
|
226
|
+
## Tasks
|
|
227
|
+
|
|
228
|
+
| Task | Prompt | Returns |
|
|
229
|
+
|---|---|---|
|
|
230
|
+
| `features` (default) | fs2f FEAT | Pfam domains with 1-based boundaries, transmembrane helices, signal peptide, name, EC number, function |
|
|
231
|
+
| `active-site` | fs2f PSEUDO | catalytic residues present, canonical residues substituted or missing, active yes/no/uncertain, reason |
|
|
232
|
+
| `structure` | fs2f STRFN | helix and strand ranges, fold, 20 long-range contacts, function, functional residues, recognised or not |
|
|
233
|
+
| `function` | new, **untested** | summary, family, GO molecular function / process / component terms, EC number |
|
|
234
|
+
| `combined` | protein-function-agent reader, **untested merge** | the keys of `features` and `active-site` plus fold, function and recognised, in one question |
|
|
235
|
+
| `localization` | new, **untested** | compartments, targeting signals with boundaries, transmembrane helices |
|
|
236
|
+
| `ask-function` | new, **untested**; parameters `term`, `label` | does the protein have this GO function? yes / no / uncertain |
|
|
237
|
+
| `ask-catalytic-residue` | new, **untested**; parameters `position`, `residue` | is this residue catalytic? (and is it really at that position?) |
|
|
238
|
+
| `ask-localization` | new, **untested**; parameter `compartment` | is the protein located there? |
|
|
239
|
+
|
|
240
|
+
Each sequence is sent alone, wrapped at 60 residues. Blind and with no payload, the three fs2f prompts are
|
|
241
|
+
exactly the study's, which the tests check byte for byte. A task's prompt version is a hash of its prompt file,
|
|
242
|
+
so an edited prompt never shares stored answers with the old one. Writing a new task is a prompt file and a
|
|
243
|
+
small Python module: see [docs/templates.md](https://github.com/ai4curation/peptalk/blob/main/docs/templates.md).
|
|
244
|
+
|
|
245
|
+
## Header context
|
|
246
|
+
|
|
247
|
+
FASTA headers are parsed with a profile (`--header-profile`: `auto`, `uniprot`, `ncbi`, `plain`). All parsed
|
|
248
|
+
fields are kept on each record (`header`): accession, entry name, name, organism, taxon id, gene and so on.
|
|
249
|
+
`--context` sets how much of the header the model sees:
|
|
250
|
+
|
|
251
|
+
| `--context` | The model sees |
|
|
252
|
+
|---|---|
|
|
253
|
+
| `blind` | `>sequence` only: the fs2f protocol |
|
|
254
|
+
| `organism` (default) | `>sequence OS=Escherichia coli (strain K12) OX=83333` |
|
|
255
|
+
| `full` | the whole header as given, accession and name included |
|
|
256
|
+
|
|
257
|
+
The default is `organism`. An annotator legitimately knows the organism, and it helps: it decides whether a
|
|
258
|
+
signal peptide or a chloroplast transit peptide is plausible, and which families to expect. It does not let the
|
|
259
|
+
model copy an existing annotation. The full header usually carries a database name. Given one, the model may
|
|
260
|
+
recall the entry instead of reading the sequence, and repeat whatever the name says; the study found submitter
|
|
261
|
+
names the blind models rightly did not repeat. Use `full` only when headers carry trusted context that names
|
|
262
|
+
nothing, and use `blind` for validation studies and comparisons with fs2f. The level is recorded on each
|
|
263
|
+
record and is part of the cache key, so blind and informed answers never mix. A header with no organism gives the
|
|
264
|
+
blind prompt at the `organism` level, and is recorded as `blind`.
|
|
265
|
+
|
|
266
|
+
## Exports and GFF3
|
|
267
|
+
|
|
268
|
+
`peptalk export --gff3` writes the located features of the answers: domains, TM helices, targeting signals,
|
|
269
|
+
catalytic residues and secondary structure, with Sequence Ontology types and `Dbxref` where there is one.
|
|
270
|
+
Contacts, function calls, GO terms and verdicts have no place in GFF3 and stay in the JSON or Parquet records,
|
|
271
|
+
which each feature points back to. [docs/design.md](https://github.com/ai4curation/peptalk/blob/main/docs/design.md)
|
|
272
|
+
gives the mapping, and also covers header profiles, templates, schemas and payloads.
|
|
273
|
+
|
|
274
|
+
## Structured output (opt-in)
|
|
275
|
+
|
|
276
|
+
By default peptalk asks for JSON in plain text and parses it, the protocol fs2f used, on every provider.
|
|
277
|
+
`--structured` instead sends the task's JSON Schema to the provider for constrained decoding. It is off by
|
|
278
|
+
default because it changes the question. On Claude Haiku 5.5 a 400-token prompt became a 2,447-token request,
|
|
279
|
+
the provider adding schema instructions of its own. In one sample it also gave a different answer. The output
|
|
280
|
+
mode is recorded and is part of the cache key.
|
|
281
|
+
|
|
282
|
+
The default model is `claude-fable-5-2` at `high` effort, the strongest sequence reader in fs2f.
|
|
283
|
+
`claude-opus-5-5` costs half as much per token. Effort labels are each provider's own (`low`, `medium`,
|
|
284
|
+
`high`, and for Claude also `xhigh` and `max`).
|
|
285
|
+
|
|
286
|
+
## Checks and confidence
|
|
287
|
+
|
|
288
|
+
The study found that models state wrong calls as confidently as right ones, so the annotator does not ask the
|
|
289
|
+
model how sure it is. Each record instead carries `checks` and a `confidence` derived from them:
|
|
290
|
+
|
|
291
|
+
- `input_tokens_match`: the call reported exactly as many input tokens as the provider counts for the prompt
|
|
292
|
+
alone, so nothing else was sent. `--no-verify-input` skips the counting request.
|
|
293
|
+
- `residues_match_sequence`: each residue the model names is at the position it gives.
|
|
294
|
+
- `substitutions_match_sequence`: a residue reported in place of a canonical one is really there.
|
|
295
|
+
- `domain_bounds`, `tm_helix_bounds`, `secondary_structure_bounds`, `contacts_valid`: ranges fall inside the
|
|
296
|
+
sequence, and contacts are at least 24 residues apart.
|
|
297
|
+
- `pfam_accession_form`, `go_id_form`: identifiers are well formed (not that they exist or are right).
|
|
298
|
+
- `shuffled_control` (with `--shuffle-control`): the shuffled copy got no domain, was not called active, was
|
|
299
|
+
not recognised, and got no "yes" to an ask question. A transmembrane helix in a shuffled copy is not counted
|
|
300
|
+
against the answer.
|
|
301
|
+
- `claim_residue_matches_sequence` (ask templates): the residue a claim names is really at that position.
|
|
302
|
+
- `evidence_residues_match_sequence` (with `-w evidence`): each residue the model cites is where it says.
|
|
303
|
+
|
|
304
|
+
`confidence` is `checks_passed`, `flagged` (a check failed) or `no_answer` (failed call, refusal, tool
|
|
305
|
+
invocation in the reply, or no valid answer object). `checks_passed` means only that these checks passed.
|
|
306
|
+
Treat every answer as a hypothesis to verify. This record-level `confidence` is peptalk's. The model's own stated
|
|
307
|
+
probability, when asked for with `-w confidence`, is `answer.confidence`.
|
|
308
|
+
|
|
309
|
+
## The store: log and cache
|
|
310
|
+
|
|
311
|
+
Every call that reaches a provider is logged in a SQLite file, failures and refusals included. The file is
|
|
312
|
+
`~/.local/share/peptalk/peptalk.db` by default; change it with `--db` or `$PEPTALK_DB`. Each record holds:
|
|
313
|
+
|
|
314
|
+
- the sequence and its MD5 (the checksum UniParc uses)
|
|
315
|
+
- the prompt version and hash
|
|
316
|
+
- the provider, the model requested and the model that served the answer
|
|
317
|
+
- the effort, the request options as sent, and the client library version
|
|
318
|
+
- input, output and thinking tokens, and the prompt-only token count
|
|
319
|
+
- cost, stop reason, start and finish times, and the reply text
|
|
320
|
+
|
|
321
|
+
Before asking, the annotator looks for a usable stored answer whose key fields match. The default key is
|
|
322
|
+
`seq_md5,task,prompt_version,params,context,payload,output,provider,model,effort`. A renamed sequence is still
|
|
323
|
+
found and an interrupted run resumes where it stopped. Answers given with a different header context, payload or
|
|
324
|
+
output mode are never reused. `--cache-key` sets other fields. For example,
|
|
325
|
+
`--cache-key seq_md5,task,prompt_version,model` reuses an answer given at any effort, and adding `options`
|
|
326
|
+
requires identical request options. Answers are sampled, so reuse returns a stored sample. A reused answer keeps
|
|
327
|
+
the `uid` of the call that produced it.
|
|
328
|
+
|
|
329
|
+
SQLite is the local store because several processes (the CLI, batch collection, the API server) can write to it
|
|
330
|
+
at once.
|
|
331
|
+
|
|
332
|
+
### Querying with DuckDB
|
|
333
|
+
|
|
334
|
+
DuckDB reads both the live SQLite store and Parquet exports:
|
|
335
|
+
|
|
336
|
+
```sql
|
|
337
|
+
INSTALL sqlite; LOAD sqlite;
|
|
338
|
+
ATTACH '~/.local/share/peptalk/peptalk.db' AS peptalk (TYPE sqlite, READ_ONLY);
|
|
339
|
+
|
|
340
|
+
SELECT model, effort, count(*) AS calls, sum(thinking_tokens) AS thinking, round(sum(cost_usd), 2) AS usd
|
|
341
|
+
FROM peptalk.calls GROUP BY ALL;
|
|
342
|
+
|
|
343
|
+
-- the full record is JSON in the `record` column
|
|
344
|
+
SELECT id, json_extract_string(record, '$.answer.catalytically_active') AS active
|
|
345
|
+
FROM peptalk.calls WHERE task = 'active-site' AND condition = 'real';
|
|
346
|
+
|
|
347
|
+
-- a Parquet export (peptalk export --parquet calls.parquet): one row per call, deduplicated by uid
|
|
348
|
+
SELECT seq_md5, task, model, protein_name, confidence FROM 'calls.parquet' WHERE condition = 'real';
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
## Sharing results
|
|
352
|
+
|
|
353
|
+
`peptalk export` writes self-contained JSON records, each with its sequence, `seq_md5` and call `uid`.
|
|
354
|
+
`peptalk import` adds only the calls a store does not already have, so exports from several people pool without
|
|
355
|
+
duplicates. `peptalk fasta` writes each annotated sequence once, named by its MD5, so DIAMOND or BLAST hits join
|
|
356
|
+
back to the records on `seq_md5`. [docs/shared-database.md](https://github.com/ai4curation/peptalk/blob/main/docs/shared-database.md) sketches a shared,
|
|
357
|
+
searchable database built from these pieces; it is designed, not built.
|
|
358
|
+
|
|
359
|
+
## Cost
|
|
360
|
+
|
|
361
|
+
Anthropic list prices are built in (dollars per million tokens; thinking is billed as output; batches at half
|
|
362
|
+
price). For other models pass `--prices prices.json` with `{"model-id": {"input": 1.25, "output": 10.0}}`.
|
|
363
|
+
Without a price, cost is left empty.
|
|
364
|
+
|
|
365
|
+
In a live run, one Fable 5.2 `active-site` question at high effort took 48 seconds and cost $0.19, almost all of
|
|
366
|
+
it thinking and output. Twelve Haiku 5.5 questions at low effort cost $0.007 in total. Provider prompt caching
|
|
367
|
+
saves nothing here: input is a few percent of the cost, and the fixed prompts (212 to 315 tokens) are below
|
|
368
|
+
Anthropic's 512-token caching minimum.
|
|
369
|
+
|
|
370
|
+
## Refusals
|
|
371
|
+
|
|
372
|
+
Safety classifiers occasionally decline a protein question. The record then has
|
|
373
|
+
`stop_reason: refusal:<category>` and no answer. For Claude models, `--fallback` lets Anthropic's server-side
|
|
374
|
+
fallback answer with another model instead. It is off by default because which model answers matters;
|
|
375
|
+
`served_model` records it.
|
|
376
|
+
|
|
377
|
+
## Why direct API calls, and what the study found
|
|
378
|
+
|
|
379
|
+
fs2f asked most of its Claude questions through the Claude Code command line. That route adds context of its
|
|
380
|
+
own and can attach connector tools: a one-sentence prompt carried 5,851 input tokens, and two PSEUDO questions
|
|
381
|
+
carried 97,813 and 6,413. Those results should be read as possibly contaminated. A direct API call carries only
|
|
382
|
+
what the caller sends, and the `input_tokens_match` check confirms it on every call. In a live test, the
|
|
383
|
+
ROP17 active-site question reported 829 input tokens, exactly the prompt's own count.
|
|
384
|
+
|
|
385
|
+
From the fs2f tests (November 2026; small test sets, sampled answers, mostly through the CLI route above):
|
|
386
|
+
|
|
387
|
+
- **Domains.** Claude Fable 5.2 named a correct Pfam family for 39 of 45 sampled bacterial and archaeal
|
|
388
|
+
proteins, and Opus 5.5 for 35, with a mean boundary overlap of 0.86. Both almost never gave a domain to a
|
|
389
|
+
shuffled sequence.
|
|
390
|
+
- **Obscure families.** Fable 5.2 named the exact family for 8 of 15 obscure domain-of-unknown-function proteins,
|
|
391
|
+
Opus 5.5 for 3 and Gemini 4 Neon for none.
|
|
392
|
+
- **Catalytic residues.** Fable 5.2, Opus 5.5 and Gemini 4 Neon called all 20 wild-type kinases active and none
|
|
393
|
+
of the 20 catalytic-Asp mutants. The same substitution at an unannotated position left the call unchanged.
|
|
394
|
+
- **Structure and function.** On 12 proteins with no close earlier PDB entry, Fable 5.2 reached 76% three-state
|
|
395
|
+
accuracy (best single-state guess 57%) and 37% long-range contact precision (chance 2%). No model named the
|
|
396
|
+
function correctly for more than half of them.
|
|
397
|
+
- **The model matters.** Opus 4.6 invented a domain for 28 of 60 shuffled sequences and missed most active-site
|
|
398
|
+
substitutions.
|
|
399
|
+
|
|
400
|
+
None of this compares the models with specialised predictors such as InterProScan, DeepTMHMM, SignalP or
|
|
401
|
+
AlphaFold. [docs/provider-options.html](https://github.com/ai4curation/peptalk/blob/main/docs/provider-options.html) records how the provider layer was chosen.
|
|
402
|
+
|
|
403
|
+
## Development
|
|
404
|
+
|
|
405
|
+
```bash
|
|
406
|
+
just test # pytest and doctests
|
|
407
|
+
just check # ruff, mypy, tests
|
|
408
|
+
just build # sdist and wheel in dist/
|
|
409
|
+
just smoke # live calls with Claude Haiku 5.5 on examples/proteins.fasta (about one cent)
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
The tests call no model. `tests/data` holds one fs2f FEAT protein and the ROP17 kinase with its catalytic
|
|
413
|
+
Asp436Asn mutant, with the replies Fable 5.2 gave to them in fs2f.
|
|
414
|
+
|
|
415
|
+
## Citation
|
|
416
|
+
|
|
417
|
+
Mungall CJ, Joachimiak MP. General-purpose language models are neurosymbolic reasoners able to annotate
|
|
418
|
+
proteins from sequence. 2026; preprint forthcoming. Manuscript:
|
|
419
|
+
https://github.com/ai4curation/fable-sequence-to-function/blob/main/manuscript.pdf
|
|
420
|
+
|
|
421
|
+
## License
|
|
422
|
+
|
|
423
|
+
MIT
|