prostt5
Skill2 starsChanged 8 months agoMITView on GitHub
Skill for protein sequence-structure translation using ProstT5 from Rostlab. Use this skill when a user wants to predict protein structure as a 3Di structural alphabet string (Foldseek tokens) from an amino acid sequence, do inverse folding (recover an amino acid sequence from a 3Di structure), embed both amino acid and 3Di sequences, or work with Foldseek-compatible structure representations. ProstT5 is unique: it translates between sequence and structure via discrete tokens rather than 3D coordinates. Also trigger when the user mentions ProstT5, 3Di tokens, Foldseek sequence-structure translation, structural alphabet embeddings, or structure-conditioned protein design with discrete tokens.
- Installs packages
In this repository14 other files it gives its agents.
- alphafold3Skill
- alphafoldSkill
- boltzSkill
- chai1Skill
- diffdockSkill
- esm2Skill
- esm3Skill
- esmcSkill
- evo2Skill
- proteinmpnnSkill
- prott5Skill
- rfdiffusionSkill
- rnafmSkill
- scgptSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 206
Use ProstT5_fp16 on GPU for ~2× speed with no quality loss
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
ProstT5: Protein Sequence ↔ Structure Translation
Overview
ProstT5 is a T5-based protein language model finetuned from ProtT5-XL-U50 to translate between amino acid (AA) sequences and 3Di structural alphabet tokens — the same discrete structural tokens used by Foldseek for fast structure search.
Key capabilities:
- AA → 3Di ("folding"): predict structure as a 3Di string from sequence alone
- 3Di → AA ("inverse folding"): recover amino acid sequences from 3Di structure strings
- Embeddings: high-quality per-residue representations for both AA and 3Di sequences
What 3Di tokens are: Foldseek encodes protein structure as a 20-letter structural alphabet (one token per residue). This is not 3D coordinates — it's a compact structural language. It enables fast structure-based search and comparison without full coordinate files.
When to use ProstT5 vs ESMFold/ESM3:
- ProstT5 outputs 3Di tokens (useful for Foldseek search, structural alphabet analysis)
- ESMFold/ESM3 outputs 3D coordinates (PDB format, for visualization, MD simulation, etc.)
Installation
pip install transformers torch sentencepieceModel
| HF ID | Notes |
Rostlab/ProstT5 | Full precision |
Rostlab/ProstT5_fp16 | Half-precision variant (faster, recommended for GPU) |
Critical Preprocessing Rules
ProstT5 uses a shared tokenizer for both AA and 3Di sequences:
| Sequence type | Format | Prefix token |
| Amino acids | UPPERCASE, space-separated, UZOB→X | <AA2fold> |
| 3Di tokens | lowercase, space-separated | <fold2AA> |
The prefix token tells the model which direction to translate. It is required — omitting it produces wrong outputs.
import re
def preprocess_aa(sequence: str) -> str:
"""Prepare an amino acid sequence for ProstT5."""
sequence = re.sub(r"[UZOB]", "X", sequence.upper())
return "<AA2fold> " + " ".join(list(sequence))
def preprocess_3di(structure: str) -> str:
"""Prepare a 3Di sequence for ProstT5."""
return "<fold2AA> " + " ".join(list(structure.lower()))Core Workflows
1. Extract Embeddings (AA sequences)
import re, torch
from transformers import T5Tokenizer, T5EncoderModel
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
tokenizer = T5Tokenizer.from_pretrained("Rostlab/ProstT5", do_lower_case=False)
model = T5EncoderModel.from_pretrained("Rostlab/ProstT5").to(device)
model.half() if device.type == "cuda" else model.float()
model.eval()
sequences = ["MKTAYIAKQRQISFVK", "AGLIVHSPQWFYK"]
processed = [preprocess_aa(s) for s in sequences]
lengths = [len(s) for s in sequences]
ids = tokenizer(processed, return_tensors="pt", padding="longest",
add_special_tokens=True).to(device)
with torch.no_grad():
output = model(**ids)
# output.last_hidden_state shape: (batch, prefix+seq_len+EOS, 1024)
# Skip prefix token at index 0; residues are at indices [1 : seq_len+1]
for i, seq_len in enumerate(lengths):
per_residue = output.last_hidden_state[i, 1 : seq_len + 1].float() # (L, 1024)
per_protein = per_residue.mean(dim=0) # (1024,)Note: Unlike ProtT5 (no prefix), ProstT5 adds a prefix token (<AA2fold> or <fold2AA>) at position 0. Start residue slicing at index 1, not 0.
2. AA → 3Di Translation ("Folding")
Predict structure as a 3Di string from a protein sequence:
from transformers import T5Tokenizer, AutoModelForSeq2SeqLM
tokenizer = T5Tokenizer.from_pretrained("Rostlab/ProstT5", do_lower_case=False)
model = AutoModelForSeq2SeqLM.from_pretrained("Rostlab/ProstT5").to(device)
model.half() if device.type == "cuda" else model.float()
model.eval()
sequences = ["MKTAYIAKQRQISFVK", "AGLIVHSPQWFYK"]
processed = [preprocess_aa(s) for s in sequences]
lengths = [len(s) for s in sequences]
ids = tokenizer(processed, return_tensors="pt", padding="longest",
add_special_tokens=True).to(device)
gen_config = {
"do_sample": True,
"num_beams": 3,
"top_p": 0.95,
"temperature": 1.2,
"top_k": 6,
"repetition_penalty": 1.2,
}
with torch.no_grad():
translations = model.generate(
ids.input_ids,
attention_mask=ids.attention_mask,
max_length=max(lengths),
min_length=min(lengths),
early_stopping=True,
num_return_sequences=1,
**gen_config,
)
decoded = tokenizer.batch_decode(translations, skip_special_tokens=True)
structure_3di = ["".join(s.split()) for s in decoded] # remove spaces
print(structure_3di) # list of lowercase 3Di strings, one per input sequenceThe output is a list of 3Di strings (e.g., "adwkcvpmaklfdeg...") — one character per residue, all lowercase.
3. 3Di → AA Translation ("Inverse Folding")
Recover amino acid sequences from 3Di structure strings:
structures_3di = ["adwkcvpmaklfdeg", "strmcvpqklf"]
processed = [preprocess_3di(s) for s in structures_3di]
lengths = [len(s) for s in structures_3di]
ids = tokenizer(processed, return_tensors="pt", padding="longest",
add_special_tokens=True).to(device)
gen_config_inv = {
"do_sample": True,
"top_p": 0.90,
"temperature": 1.1,
"top_k": 6,
"repetition_penalty": 1.2,
}
with torch.no_grad():
translations = model.generate(
ids.input_ids,
attention_mask=ids.attention_mask,
max_length=max(lengths),
min_length=min(lengths),
early_stopping=True,
num_return_sequences=1,
**gen_config_inv,
)
decoded = tokenizer.batch_decode(translations, skip_special_tokens=True)
aa_sequences = ["".join(s.split()) for s in decoded]
print(aa_sequences) # recovered amino acid sequences (uppercase)Scripts
# AA → 3Di translation from FASTA
python scripts/translate.py sequences.fasta --direction aa2fold --output structures.fasta
# 3Di → AA inverse folding from FASTA
python scripts/translate.py structures.fasta --direction fold2aa --output recovered.fasta
# Generate embeddings from AA sequences
python scripts/translate.py sequences.fasta --direction embed --output embeddings.npyWhen to Use ProstT5 vs. Alternatives
| Goal | Recommended tool |
| 3Di tokens for Foldseek search | ProstT5 |
| Sequence similarity from structure | ProstT5 (embed 3Di) |
| 3D coordinates / PDB | ESMFold or ESM3 |
| Generative protein design | ESM3 |
| Pure AA embeddings | ProtT5 or ESM-C |
Best Practices
- Use
ProstT5_fp16on GPU for ~2× speed with no quality loss - Translation is slow (0.6–2.5s per protein) because it uses autoregressive decoding; embedding is fast
- The 3Di output can be directly used as input to Foldseek for structure-based search
- For validation, compare ProstT5's 3Di output against AlphaFold2/ESMFold-predicted structures
Resources
- GitHub: https://github.com/agemagician/ProtTrans
- HuggingFace: https://huggingface.co/Rostlab/ProstT5
- Foldseek: https://github.com/steineggerlab/foldseek
- Preprint: Heinzinger et al., 2023 — https://doi.org/10.1101/2023.07.23.550085
- Training data: https://huggingface.co/datasets/Rostlab/ProstT5Dataset
References
references/prostt5-api.md— detailed generation configs, batched translation, embedding 3Di sequences, integration with Foldseek
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

