# Translation

> Translation reads mrna into a protein.

Page: https://fframes-kit.pages.dev/docs/biology/translation/
Cargo feature: `biology` (`fframes-kit = { version = "..", features = ["biology"] }`)

`Translation` reads `mrna` into a protein. The ribosome slides onto the strand at the first
`AUG` and reads the reading frame (`reading_frame(mrna)`) one codon every `codon_time`
seconds from `delay`: a tRNA with the matching anticodon drops in carrying its amino acid
(`amino_acid(codon)`), the chain moves over onto it and gains a bond, and the empty tRNA
leaves. At the stop codon the ribosome comes apart and lets the chain go. The names of the
chain (`Met-Ala-Ser`) are written under the ribosome as it grows. Gallery scene:
`Translation`.

Gallery clip of `Translation`: https://fframes-kit.pages.dev/media/scenes/Translation-7b3e690c.mp4

```rust
use fframes_kit::prelude::*;
use fframes_kit::kits::biology::{amino_acid, reading_frame};

assert_eq!(amino_acid("AUG"), Some("Met"));
assert_eq!(amino_acid("UAA"), None); // a stop codon
let (start, codons) = reading_frame("GCAUGUUUUGAC");
assert_eq!((start, codons), (2, vec!["AUG".into(), "UUU".into(), "UGA".into()]));

fn protein<'a>(ui: &mut Ui<'a, '_, '_>) -> Svgr<'a> {
    ui.show(Translation {
        mrna: "GAUGUUUGGCUAAC".into(),
        codon_time: 1.0,
        ..ui.defaults()
    })
}
```

## API

Components are plain structs. Set the fields you need and fill the rest with `..ui.defaults()`: the defaults below come from the current theme (`theme.` values are fields of `Theme`).

### Translation

| Field | Type | Default | Description |
| --- | --- | --- | --- |
| `mrna` | `String` | `"GCCAUGGCUUCGAAAUGGUAAGC".into()` | The mRNA written with `A`, `U`, `G`, `C`; the ribosome starts at its first `AUG` and stops at a stop codon. |
| `delay` | `f32` | `0.0` | Seconds after the container's start before the ribosome begins to read. |
| `codon_time` | `f32` | `1.2` | Seconds the ribosome spends on each codon. |
| `center` | `(f64, f64)` | `(0.0, 0.0)` | The middle of the mRNA, in units of `ui.space`. |
| `spacing` | `f32` | `44.0` | Pixels between neighbouring bases along the mRNA. |
| `bases` | `BaseColors` | `BaseColors::default()` | Colour of each base letter. |
| `strand_color` | `Color` | `theme.colors.highlight` | Colour of the mRNA backbone. |
| `ribosome_color` | `Color` | `theme.colors.accent` | Colour of the ribosome. |
| `trna_color` | `Color` | `theme.colors.muted` | Colour of the tRNA molecules. |
| `amino_color` | `Color` | `Color::hex("#9775fa")` | Fill of the amino acid circles. |
| `base_style` | `TextStyle` | `base_style` | The font of the base letters: family, size in pixels and weight. |
| `amino_style` | `TextStyle` | `amino_style` | The font of the amino acid names on the circles: family, size in pixels and weight. |
| `chain_style` | `TextStyle` | `theme.typography.caption` | The font of the chain written under the mRNA: family, size in pixels and weight. |
| `text_color` | `Color` | `theme.colors.text` | Colour of the codon marks, amino acid outlines and chain text. |
| `enter` | `Option<FadeIn>` | `None` | Fade in at the start; `None` for none. |
| `exit` | `Option<FadeOut>` | `None` | Fade out before the end; `None` for none. |

Feature `biology` · [Source](https://github.com/khanhthanhdev/fframes-kit/blob/main/fframes-kit/src/kits/biology/expression.rs#L400)
