Rice Mitochondria Optimizer v2
A CodonTransformer-style BigBird model fine-tuned to codon-optimize protein sequences for expression from rice (Oryza sativa) mitochondrial codon usage. Given a protein sequence, it predicts a DNA coding sequence.
This is the second mitochondria model and the "final model" of the project. The first version, Rice_Mitochondria_Optimizer, was trained on rice mitochondrial genomes cut into many small ~6 kb sections. This version was trained on whole genes instead: each training sequence is a complete coding sequence with a start and a stop codon. Fewer, higher-quality sequences were preferred over many small segments.
Training
- Data: Complete rice mitochondrial coding sequences (start codon, single terminal stop codon, no internal stops), 69 genes.
- GC control: GC control was used during fine-tuning but deliberately relaxed in favor of 5′ MFE. GC content and MFE both relate to RNA stability, but MFE measures stability more directly. As a result, the output GC is somewhat below the 43.5% target while the 5′ RNA structure is much better preserved.
Usage
import torch
from transformers import AutoTokenizer, BigBirdForMaskedLM
from CodonTransformer.CodonPrediction import predict_dna_sequence # from the project repo
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
tokenizer = AutoTokenizer.from_pretrained("gupta-reyansh123/Rice_Mitochondria_Optimizer_v2")
model = BigBirdForMaskedLM.from_pretrained("gupta-reyansh123/Rice_Mitochondria_Optimizer_v2").to(device)
output = predict_dna_sequence(
protein="MKTVRQERLKSIVRILERSKEPVSGAQLAEELSVSRQVIVQDIAYLRSLGYNIVATPRGYVLA",
organism=0,
device=device,
tokenizer=tokenizer,
model=model,
)
print(output.predicted_dna)
The model has 2048 positions and a single token type; organism=0 is the only organism it was trained on.
Evaluation
Evaluated on 100 native nifH genes (the test protein set), compared with Geneious, IDT, and two earlier fine-tuned models. The full table is in dataset_comparison_summary.csv.
| Dataset | GC % | GC3 % | CAI | Codon similarity to original % | Δ5′ MFE (kcal/mol) |
|---|---|---|---|---|---|
| Native nifH (nif1 + nif2) | 53.28 | 62.56 | 0.681 | n/a | n/a |
| Geneious | 44.71 | 39.58 | 0.777 | 34.51 | 0.815 |
| IDT | 44.46 | 39.21 | 0.781 | 34.21 | 0.652 |
| Unconstrained model (no GC control) | 41.59 | 29.34 | 0.857 | 32.10 | 1.039 |
| Constrained model | 44.35 | 37.85 | 0.805 | 38.78 | 2.252 |
| Final model (this model) | 41.85 | 31.39 | 0.819 | 38.57 | 0.020 |
| Target | 43.51 | 40.08 | 1.0 | 1.0 | 0 |
Metric notes:
- CAI uses relative-adaptiveness weights built from 69 complete rice mitochondrial genes, scored as a geometric mean per sequence.
- Δ5′ MFE is the average change in minimum free energy of the first 50 nucleotides (ViennaRNA, 37 °C), optimized minus original. 0 means the native 5′ structure is preserved.
- Codon similarity is the codon-level similarity to the native sequence.
All 100 predictions translate back to the input protein. The evaluation uses a single gene family (nifH), so these numbers should not be read as a general benchmark.
Limitations
- Trained on rice mitochondrial data only; not intended for other organisms.
- Evaluated on one gene family and a small test set.
- GC and GC3 of the output are below the 43.5% and 40.1% targets. This is the intended trade-off from relaxing GC control in favor of 5′ MFE.
Code and evaluation scripts: see the project repository.