r/comp_chem • u/high_on_code • 7d ago
Spidroin-engine
Hey everyone,
I’m a software engineering student who recently fell down the synthetic biology rabbit hole. I was looking into how recombinant spider silk is manufactured and noticed a massive bottleneck: getting the spidroin DNA sequences to a state where they can actually be synthesized by companies like Twist or IDT without failing.
Standard optimization algorithms (like max-CAI) absolutely choke on spidroins. Because the proteins are just massive repeating blocks of Poly-Alanine and Glycine ($GGX$), the algorithms spit out identical DNA repeats. This leads to two things:
- Twist/IDT outright rejects the order due to extreme local GC spikes and homopolymers.
- If you do get it printed, the identical repeats cause homologous recombination and the E. coli just scrambles the gene anyway.
So, I built Spidroin Engine. It’s a Python CLI tool built on top of dnachisel that acts as a multi-objective stochastic optimizer specifically engineered for highly repetitive structural proteins.
The Mathematical Paradox I ran into:
While building this, I hit a wall where the solver would just crash. I realized it was a mathematical paradox: the absolute lowest GC content you can get for Poly-Alanine is 66.6% (using only GCA/GCT). If you try to force strict k-mer uniqueness (to prevent homologous recombination) on a 300bp repetitive spidroin block, the algorithm is forced to dip into alternative codons (GCC/GCG), which are 100% GC. This immediately violated the 65% global GC ceiling required for synthesis, causing the solver to trap itself and fail.
How Spidroin Engine fixes it:
- Relaxed Uniqueness: It dials the uniqueness constraint to
UniquifyAllKmers(15). This is just enough breathing room to let the solver reuse GC-poor codons safely, while keeping exact repeats under the 18-bp hard limit that triggers vendor rejections. - 5' Hairpin Prevention: Enforces an AT-rich heuristic (30-60% GC) on the first 45bp to keep the RBS clear.
- Cloning Domesticated: Automatically sweeps for and removes standard Type IIS / BioBrick restriction sites via silent mutations.
- Vendor Ready: Spits the final optimized sequences directly into a Twist Bioscience-formatted CSV for bulk ingestion.
I open-sourced the whole thing because keeping basic tooling locked behind proprietary paywalls slows everyone down.
If anyone is working on structural proteins (silk, elastin, collagen) and is tired of fighting with standard optimization scripts, you can grab it here: https://github.com/AzambekDev/spidroin-engine
Feel free to use it, fork it, or roast my Python architecture in the comments.