jean_core/sequence/rna/
mod.rs

1mod base;
2
3pub use base::*;
4
5use crate::prelude::{Codons, Transcribe};
6
7use super::{
8  codon::Codon,
9  dna::{self, Dna},
10  Seq,
11};
12
13pub type Rna = Seq<Base>;
14
15impl Rna {
16  pub fn rev_transcribe(&self) -> Dna {
17    Dna::from(
18      &self
19        .0
20        .iter()
21        .map(|b| b.transcribe())
22        .collect::<Vec<dna::Base>>()[..],
23    )
24  }
25}
26
27impl Codons for Rna {
28  fn codons(&self) -> Seq<super::codon::Codon> {
29    Seq(
30      self
31        .0
32        .chunks_exact(3)
33        .map(|chunk| {
34          Codon::new((
35            char::from(chunk[0]) as u8,
36            char::from(chunk[1]) as u8,
37            char::from(chunk[2]) as u8,
38          ))
39        })
40        .collect(),
41    )
42  }
43}