Physics-based evaluation of mRNA sequences using ribosome traffic modeling.
This tool treats mRNA translation as a nonequilibrium transport problem:
- Sequence → Energy Landscape: mRNA is coarse-grained into a 1D free-energy profile based on codon optimality and RNA secondary structure.
- Ribosome Dynamics: Ribosomes are modeled as driven, excluded particles (TASEP-like) with energy-dependent hopping rates.
- Ensemble Metrics: Translation efficiency is reported as throughput, variability, and an overall score.
- Unified CLI: Single
run.pyentry point for simulation and optimization. - Physics-Based Model: Absolute energy scaling allows direct comparison between different sequences.
- Evolutionary Optimizer: Genetic algorithm to find optimal synonymous codons.
- Neural Network Surrogate: Fast inference of local RNA structure stability (MFE) without constant
RNAfoldcalls. - ViennaRNA Integration: Robust ground-truth structure prediction.
├── run.py # Unified CLI for Simulate & Optimize
├── src/
│ ├── codons.py # Codon tables (Kazusa database) & deoptimization
│ ├── structure.py # RNAfold wrapper for secondary structure
│ ├── landscape.py # Energy landscape computation
│ ├── landscape_nn.py # Neural network for MFE prediction
│ ├── simulator.py # TASEP ribosome simulation
│ ├── analysis.py # Ensemble analysis and metrics
│ ├── optimizer.py # Evolutionary sequence optimization
│ ├── visualization.py # Plotting functions
│ └── sequences.py # Example CAR-T sequences
├── examples/
│ ├── train_model.py # Train the MFE predictor
│ ├── compare_improved_sequences.py # Detailed CAR-T comparison
│ └── mfe_model.pt # Pre-trained model
├── tests/
└── requirements.txt
- Python 3.8+
- ViennaRNA (for RNAfold)
# Install ViennaRNA (macOS)
brew install viennarna
# Or conda
conda install -c bioconda viennarna
# Python dependencies
pip install -r requirements.txtThe project is controlled via the run.py script in the root directory.
Before running large simulations, train the neural network surrogate. This speeds up structure prediction significantly.
cd examples
python train_model.py
cd ..Analyze an mRNA sequence to get its energy landscape and translation throughput.
# Analyze a raw sequence string
python run.py simulate ATGGCCCTGCCT...
# Analyze from a file
python run.py simulate --file my_sequence.txt
# Options
python run.py simulate --file seq.txt --trajectories 20 --steps 10000Evolve a sequence to find better synonymous codons that maximize translation.
# Basic optimization
python run.py optimize --file my_sequence.txt
# Advanced options
python run.py optimize --file seq.txt --generations 50 --population 20
# Start from worst possible codons (to see max improvement)
python run.py optimize --file seq.txt --deoptimizeOutput:
optimized_sequence.txt: The final best sequence.optimization_progress.png: Fitness over generations.before_after.png: Visual comparison of energy landscapes.optimization_comparison.png: Detailed statistics dashboard.
Run the included analysis to compare a codon-optimized CAR-CD19 sequence against a truly suboptimal version.
python examples/compare_improved_sequences.pyGenerate an animated GIF showing ribosomes (colored beads) moving along the mRNA. This demonstrates stalling at energy barriers and traffic jams.
cd examples
python visualize_ribosomes.pyOutput: examples/ribosome_traffic.gif
- X-axis: Codon Position
- Y-axis: Energy Barrier Height (Codon rarity + Secondary structure)
- Top Track: Optimized sequence showing fast, laminar flow.
- Bottom Track: Poor sequence showing stochastic stalling and pileups.
Each codon position has an effective energy combining:
| Component | Source | Effect |
|---|---|---|
| Codon optimality | Kazusa database | Rare codons → high energy (slow tRNA) |
| Local structure | RNAfold / NN | Stable hairpins → high energy (barrier) |
Update: The model now uses absolute energy scaling. This means an optimized sequence has a genuinely lower energy profile than a suboptimal one, allowing the simulator to predict realistic throughput differences (e.g., 2-3x improvement).
Uses a Totally Asymmetric Simple Exclusion Process (TASEP):
5' ────────────────────────────────────── 3'
🔵→ 🔵→ 🔵→
ribosome ribosome ribosome
- Initiation: Ribosomes enter at 5' end.
- Elongation: Hopping rate depends on the energy barrier ahead.
- Exclusion: Ribosomes occupy ~10 codons and cannot overlap.
- Termination: Protein is produced upon exiting the 3' end.
- Codon weights: Kazusa Codon Usage Database (Homo sapiens, 93,487 CDS)
- Structure prediction: ViennaRNA RNAfold
Non-Commercial Use Only. See LICENSE file for details.
