Properties Before Structure: A Three-Stage Campaign Ordered by Cost¶
Run cheap stability and solubility filters across your full library first. Spend the structural prediction budget only on sequences that survive.
What you'll learn:
- Why pipeline order matters: cheap predictions first, expensive validation last
- Filtering a designed library by melting temperature and solubility
- Using Boltz-2 (no-MSA) to validate fold quality on surviving candidates
- Interpreting pLDDT and pTM scores from a structure prediction
export BIOLMAI_TOKEN=your-token-here
Note: This notebook requires Boltz-2 access via the BioLM API. Confirm availability at biolm.ai/models.
Setup¶
import os
from biolmai.pipeline import (
DataPipeline, DuckDBDataStore,
ThresholdFilter, RankingFilter,
ValidAminoAcidFilter, EmbeddingSpec,
DiversitySamplingFilter,
)
TOKEN = os.environ.get("BIOLMAI_TOKEN", "")
if not TOKEN:
raise EnvironmentError(
"Set BIOLMAI_TOKEN before running.\n"
"Get one at https://biolm.ai/ui/accounts/user-api-tokens/"
)
import matplotlib.pyplot as pltDesigned library¶
A mixed library of designed sequences — some will fold well, some won't.
DESIGNED_LIBRARY = [
# Well-folded scaffolds (expected high pLDDT)
"MKTAYIAKQRQISFVKSHFSRQLEERVKILEQELEKAKEELKERLEELEKAKEEL",
"GSHMDELYKAALEKAKQELKEAKQELKEAKQELKEAKQELKEAKQELKEAKQEL",
"MHHHHHHSSGENLYFQGAEAAAKEAAAKEAAAKEAAAKEAAAKEAAAKEAAAK",
"EVQLVESGGGLVQPGGSLRLSCAASGFNIKDTYIHWVRQAPGKGLEWVARI",
"DIQMTQSPSSLSASVGDRVTITCRASQSISSYLNWYQQKPGKAPKLLIY",
# Likely disordered / low confidence
"GSGSGSGSGSGSGSGSGSGSGSGSGSGSGSGSGSGSGSGSGSGSGSGSGS",
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG",
"KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK",
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE",
# Mixed
"GIGKFLHSAKKFGKAFVGEIMNS",
"KWKLFKKIPKFLHLAKKF",
"LLGDFFRKSKEKIGKEFKRIVQRIKDFLRNLVPRTES",
]
print(f"{len(DESIGNED_LIBRARY)} sequences in designed library")The pipeline¶
Three gates in order of increasing compute cost:
- Melting temperature — fast stability filter across all 13 sequences
- Solubility ranking — keep the top 7 most soluble survivors
- Boltz-2 structural validation — run no-MSA fold prediction only on sequences that passed both gates
pipeline = DataPipeline(sequences=DESIGNED_LIBRARY, verbose=True)
# Gate 1: thermal stability — cheap, runs on all sequences
pipeline.add_prediction(
"temberture-regression", extractions="prediction",
columns="melting_temperature", stage_name="tm",
)
pipeline.add_filter(
ThresholdFilter("melting_temperature", min_value=50.0),
stage_name="tm_gate",
)
# Gate 2: solubility ranking — cheap, runs on Tm survivors
pipeline.add_prediction(
"biolmsol", extractions="solubility_score",
columns="solubility", stage_name="sol",
depends_on=["tm_gate"],
)
pipeline.add_filter(
RankingFilter("solubility", n=7, ascending=False),
stage_name="sol_gate",
)
# Gate 3: structural validation — expensive, runs only on top 7
pipeline.add_cofolding_prediction(
"boltz2",
params={"use_msa": False},
extractions=["confidence.complex_plddt", "confidence.ptm"],
columns={"confidence.complex_plddt": "plddt", "confidence.ptm": "ptm"},
stage_name="fold_validate",
depends_on=["sol_gate"],
)
pipeline.add_filter(
ThresholdFilter("plddt", min_value=0.65),
stage_name="fold_gate",
)
pipeline.run()pipeline.summary()pipeline.plot("funnel")Fold quality scores on final candidates¶
fold_df = pipeline.query("""
SELECT s.sequence,
MAX(CASE WHEN p.prediction_type = 'plddt' THEN ROUND(p.value, 3) END) AS plddt,
MAX(CASE WHEN p.prediction_type = 'ptm' THEN ROUND(p.value, 3) END) AS ptm
FROM sequences s
JOIN predictions p ON s.sequence_id = p.sequence_id
WHERE p.prediction_type IN ('plddt', 'ptm')
GROUP BY s.sequence
ORDER BY plddt DESC
""")
fold_dfWhen to include a fold validation step¶
Include it when:
- The library contains de novo designed sequences where folding is not guaranteed
- Downstream assays depend on a defined structure (enzymes, binders, scaffolds)
- You want a confidence check before committing to wet-lab synthesis
Skip it when:
- The sequences are natural variants of a well-characterised fold
- The library consists of short peptides where structure predictors are unreliable
- You are screening intrinsically disordered regions — low pLDDT is expected
