An automated multi-objective DNA constraint solver designed to prevent synthesis failures in highly repetitive spidroin (spider silk) proteins.
Spidroins, the structural proteins that make up spider silk (like MaSp1), are composed of highly repetitive motifs such as GPGQQ and Poly-Alanine tracts. When engineering these genes for heterologous expression in E. coli, standard codon optimizers fail catastrophically:
- DNA Synthesis Limits: Commercial DNA synthesis platforms (like Twist Bioscience and IDT) enforce strict algorithms that reject sequences with exact long-range repeats or massive local GC spikes. Standard optimizers inadvertently group high-GC synonymous codons, triggering instant rejection from synthesis vendors.
- Homologous Recombination: In vivo, E. coli cells will undergo homologous recombination and delete your gene if it contains large stretches of exact homology, which is virtually guaranteed in unconstrained spidroin gene generation.
- RBS Occlusion: A high GC content at the 5' end will form tight mRNA hairpin loops, blocking the Ribosome Binding Site (RBS) and completely shutting down translation.
Spidroin optimization is a brutal, three-way tug-of-war between Codon Adaptation Index (CAI), GC limits, and sequence uniqueness.
We discovered a deep mathematical paradox inherently tied to the Spidroin sequence:
- The amino acids Alanine, Glycine, and Proline require codons that start with
GC,GG, andCCrespectively. This enforces a massive 58% GC floor on the sequence just by its physical nature. - To prevent repeats from exceeding synthesis limits (typically > 18bp exact matches) and avoid E. coli homologous recombination, we must force the optimizer to use synonymous codons to break up
GPGQQandA_ntracts. - The Trap: The moment the solver dips into synonymous alternative codons for Alanine or Glycine to break a repeat, the GC content of that codon spikes to 100%. The solver mathematically cannot maintain a global GC limit under 65% while simultaneously satisfying a tight uniqueness constraint (e.g.,
UniquifyAllKmers(9)). It is forced to use high-GC codons to be unique, but is forbidden from using them by the GC limit!
The Solution:
We engineered a precise constraint relaxation map. By allowing UniquifyAllKmers(15) (permitting exact repeats up to ~14bp, which is safely under Twist's 18bp rejection limit), we gave the stochastic solver the mathematical headroom it needed to reuse GC-poor codons (like GCT GCA GCT) without triggering synthesis or homologous recombination failures.
Clone this repository and set up your virtual environment:
python -m venv venv
.\venv\Scripts\activate # On Windows
pip install -r requirements.txtProvide a FASTA file containing your unoptimized DNA or Protein sequence. Run the CLI tool to automatically resolve all constraints and output a synthesis-ready sequence:
spidroin-engine optimize -i tests/data/mock_masp1.fasta -h e_coli --enzyme BsaI,BsmBI -o optimized.fastaThe optimize command automatically calls the reporter.py module, which takes the successfully generated sequence and appends it to sample-clonal-genes.csv. This CSV file is perfectly formatted for immediate, batch uploading to the Twist Bioscience portal for synthesis validation.
MIT License. Free to use, adapt, and deploy for your biotechnology needs.