ml-peptide-generation
Use when designing peptides or protein fragments that should bind a target, generating a ranked candidate pool for a target sequence, or comparing how peptide length and top-k sampling affect candidate quality. Generates candidates with the PepMLM-650M masked language model, excl
Install
npx skills add https://github.com/ssinder/bioinformatics-agent-skills/tree/main/skills/ml-peptide-generation
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install ssinder-bioinformatics-agent-skills@llmmart
git clone https://github.com/ssinder/bioinformatics-agent-skills.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole ssinder/bioinformatics-agent-skills collection as a plugin from our marketplace. Git is the plain clone.
Skill manifest
Overview
Generates candidate binder peptides for a target protein with PepMLM-650M, a masked language model trained on protein sequences.
The mechanism is straightforward: append N <mask> tokens to the target sequence, ask the model for its amino-acid distribution at each masked position, and sample from it. Repeating for N positions produces an N-residue peptide.
Two things this skill does that a naive implementation does not:
- Reproducible by construction. Every run takes an explicit
--seed. The same seed and input always produce the same peptides, so a parameter sweep is a controlled experiment rather than a lottery. - Illegal residues are excluded at sampling time, not afterwards. The vocabulary contains
X(unknown),BandZ(ambiguous amino acids); sampling from it produces peptides that are not chemically meaningful. Those candidates are removed before the draw, so the sampling budget is not wasted on rejects.
When to Use This Skill
- Designing a peptide or protein fragment intended to bind a target protein
- Producing a ranked candidate pool for a set of targets
- Comparing peptide lengths (10 / 12 / 15 aa) or top-k settings
- Screening candidates before committing to synthesis or wet-lab validation
Quick Start
export PYTHONPATH="$PWD/packages"
# Generate (requires torch + transformers)
python scripts/generate_peptides.py \
--input-fasta targets.fasta \
--output-dir results/ \
--peptide-lengths 10,12,15 \
--num-binders 20 \
--seed 42
# Analyse (standard library only, no GPU needed)
python scripts/analyze_peptides.py \
--input results/peptides.csv \
--output-dir analysis/ \
--max-ppl 5.0
Workflow
- Collect targets —
--input-fasta(FASTA),--input-csv(needsidandseqcolumns) or--input-seq(a single sequence). - Set the seed —
--seedfixesrandom,numpyandtorch. The seed is written into every output row so a run can be reproduced later. - Generate — for each target × peptide length × top-k combination, sample
--num-binderspeptides and score each by pseudo-perplexity. - Analyse —
analyze_peptides.pyfilters invalid peptides, applies optional PPL/length thresholds, and reports per-configuration statistics. - Select — rank by pseudo-perplexity and carry the top candidates into downstream validation.
Parameters
generate_peptides.py
| Parameter | Default | Description |
|---|---|---|
--input-fasta |
— | Target protein FASTA file |
--input-csv |
— | Target CSV file (needs id and seq columns) |
--input-seq |
— | A single target sequence |
--output-dir |
peptide_results |
Output directory |
--per-target-dir |
off | Also write one CSV per target |
--peptide-lengths |
10,12,15 |
Peptide lengths to generate |
--top-ks |
3 |
Top-k values to sweep |
--num-binders |
10 |
Peptides per (target × length × top-k) |
--seed |
42 |
Random seed — same seed, same results |
--model |
TianlaiChen/PepMLM-650M |
Pretrained model |
--device |
auto | Force cuda or cpu |
--allow-invalid-amino-acids |
off | Allow sampling X/B/Z |
analyze_peptides.py
| Parameter | Default | Description |
|---|---|---|
--input |
required | One or more result CSV files |
--output-dir |
peptide_analysis |
Output directory |
--max-ppl |
none | Keep only peptides with PPL ≤ this value |
--min-length / --max-length |
none | Peptide length bounds |
--keep-invalid |
off | Keep peptides containing non-standard residues |
--top-n |
20 |
How many to print |
Outputs
| File | Content |
|---|---|
peptides.csv |
All candidates: rank, target, length, top-k, binder, pseudo-perplexity, validity flag, seed |
peptides.json |
Same content as JSON |
filtered_peptides.csv |
Candidates passing the filters, sorted by PPL |
parameter_analysis.csv / .json |
Per-configuration totals, mean/median/min/max PPL |
Validation
- Pseudo-perplexity measures the model's own belief, not binding affinity. A low PPL means "this looks like a peptide the model would have generated", not "this binds the target". It is a triage filter for wet-lab follow-up, nothing more; any affinity claim needs an experimental or orthogonal computational check.
- PPL is only comparable within one (target, length) pair. The scale depends on the target sequence; do not compare PPL across different targets and conclude one target is "easier".
- Check the validity flag.
has_unknown_aa=Truemeans the peptide contains a residue the model could not decide on — not a real design. The skill excludes these at sampling time, but the flag stays in the output so the filter can be audited. - Verify reproducibility. Re-run with the same
--seedand diffpeptides.csv; the files must be byte-identical apart from thegenerated_attimestamp. - Peptides shorter than about 8 residues rarely bind meaningfully. Use
--min-lengthto exclude them from a synthesis list. - The model truncates at 552 tokens. Longer targets are rejected by the skill rather than silently truncated — a truncated target produces peptides for the wrong protein.
References
references/methodology.md— PepMLM mechanism, pseudo-perplexity derivation, sampling strategyreferences/troubleshooting.md— common failures and how to diagnose them- Model card: https://huggingface.co/TianlaiChen/PepMLM-650M
- E-utilities context for target discovery: the
bioproject-searchskill
Files (bioinformatics-agent-skills)
-
evals
-
evals.json 10.7 KB
Loading…
-
-
references
-
methodology.md 8.8 KB
Loading… -
troubleshooting.md 6.3 KB
Loading…
-
-
scripts
-
analyze_peptides.py 11.7 KB
Loading… -
generate_peptides.py 11.6 KB
Loading… -
pepmlm_client.py 20.9 KB
Loading…
-
-
requirements.txt 606 B
Loading… -
SKILL.md 6.4 KB
--- name: ml-peptide-generation description: "Use when designing peptides or protein fragments that should bind a target, generating a ranked candidate pool for a target sequence, or comparing how peptide length and top-k sampling affect candidate quality. Generates candidates with the PepMLM-650M masked language model, excluding illegal residues (X, B, Z); reports pseudo-perplexity per candidate, supports reproducible seeds, and needs no GPU. 用于多肽生成与候选排序。" license: MIT compatibility: Python 3.9+; generation needs torch + transformers; analysis needs only the standard library metadata: version: "1.0" last-reviewed: "2026-10-26" skill-author: sinder edam-topic: "topic_0203" edam-operation: "operation_3646, operation_3799" edam-input-data: "data_1254" edam-output-data: "data_2016" edam-input-format: "format_1929" edam-output-format: "format_1929, format_3752" # ML Peptide Generation --- ## Overview Generates candidate binder peptides for a target protein with **PepMLM-650M**, a masked language model trained on protein sequences. The mechanism is straightforward: append N `<mask>` tokens to the target sequence, ask the model for its amino-acid distribution at each masked position, and sample from it. Repeating for N positions produces an N-residue peptide. Two things this skill does that a naive implementation does not: - **Reproducible by construction.** Every run takes an explicit `--seed`. The same seed and input always produce the same peptides, so a parameter sweep is a controlled experiment rather than a lottery. - **Illegal residues are excluded at sampling time, not afterwards.** The vocabulary contains `X` (unknown), `B` and `Z` (ambiguous amino acids); sampling from it produces peptides that are not chemically meaningful. Those candidates are removed *before* the draw, so the sampling budget is not wasted on rejects. ## When to Use This Skill - Designing a peptide or protein fragment intended to bind a target protein - Producing a ranked candidate pool for a set of targets - Comparing peptide lengths (10 / 12 / 15 aa) or top-k settings - Screening candidates before committing to synthesis or wet-lab validation ## Quick Start ```bash export PYTHONPATH="$PWD/packages" # Generate (requires torch + transformers) python scripts/generate_peptides.py \ --input-fasta targets.fasta \ --output-dir results/ \ --peptide-lengths 10,12,15 \ --num-binders 20 \ --seed 42 # Analyse (standard library only, no GPU needed) python scripts/analyze_peptides.py \ --input results/peptides.csv \ --output-dir analysis/ \ --max-ppl 5.0 ``` ## Workflow 1. **Collect targets** — `--input-fasta` (FASTA), `--input-csv` (needs `id` and `seq` columns) or `--input-seq` (a single sequence). 2. **Set the seed** — `--seed` fixes `random`, `numpy` and `torch`. The seed is written into every output row so a run can be reproduced later. 3. **Generate** — for each target × peptide length × top-k combination, sample `--num-binders` peptides and score each by pseudo-perplexity. 4. **Analyse** — `analyze_peptides.py` filters invalid peptides, applies optional PPL/length thresholds, and reports per-configuration statistics. 5. **Select** — rank by pseudo-perplexity and carry the top candidates into downstream validation. ## Parameters ### `generate_peptides.py` | Parameter | Default | Description | |---|---|---| | `--input-fasta` | — | Target protein FASTA file | | `--input-csv` | — | Target CSV file (needs `id` and `seq` columns) | | `--input-seq` | — | A single target sequence | | `--output-dir` | `peptide_results` | Output directory | | `--per-target-dir` | off | Also write one CSV per target | | `--peptide-lengths` | `10,12,15` | Peptide lengths to generate | | `--top-ks` | `3` | Top-k values to sweep | | `--num-binders` | `10` | Peptides per (target × length × top-k) | | `--seed` | `42` | Random seed — same seed, same results | | `--model` | `TianlaiChen/PepMLM-650M` | Pretrained model | | `--device` | auto | Force `cuda` or `cpu` | | `--allow-invalid-amino-acids` | off | Allow sampling `X`/`B`/`Z` | ### `analyze_peptides.py` | Parameter | Default | Description | |---|---|---| | `--input` | required | One or more result CSV files | | `--output-dir` | `peptide_analysis` | Output directory | | `--max-ppl` | none | Keep only peptides with PPL ≤ this value | | `--min-length` / `--max-length` | none | Peptide length bounds | | `--keep-invalid` | off | Keep peptides containing non-standard residues | | `--top-n` | `20` | How many to print | ## Outputs | File | Content | |---|---| | `peptides.csv` | All candidates: rank, target, length, top-k, binder, pseudo-perplexity, validity flag, seed | | `peptides.json` | Same content as JSON | | `filtered_peptides.csv` | Candidates passing the filters, sorted by PPL | | `parameter_analysis.csv` / `.json` | Per-configuration totals, mean/median/min/max PPL | ## Validation - **Pseudo-perplexity measures the model's own belief, not binding affinity.** A low PPL means "this looks like a peptide the model would have generated", not "this binds the target". It is a triage filter for wet-lab follow-up, nothing more; any affinity claim needs an experimental or orthogonal computational check. - **PPL is only comparable within one (target, length) pair.** The scale depends on the target sequence; do not compare PPL across different targets and conclude one target is "easier". - **Check the validity flag.** `has_unknown_aa=True` means the peptide contains a residue the model could not decide on — not a real design. The skill excludes these at sampling time, but the flag stays in the output so the filter can be audited. - **Verify reproducibility.** Re-run with the same `--seed` and diff `peptides.csv`; the files must be byte-identical apart from the `generated_at` timestamp. - **Peptides shorter than about 8 residues rarely bind meaningfully.** Use `--min-length` to exclude them from a synthesis list. - **The model truncates at 552 tokens.** Longer targets are rejected by the skill rather than silently truncated — a truncated target produces peptides for the wrong protein. ## References - `references/methodology.md` — PepMLM mechanism, pseudo-perplexity derivation, sampling strategy - `references/troubleshooting.md` — common failures and how to diagnose them - Model card: <https://huggingface.co/TianlaiChen/PepMLM-650M> - E-utilities context for target discovery: the `bioproject-search` skill
Comments (0)
Sign in to join the conversation.
Reviews (0)
No reviews yet.
No comments yet.