use ahash::AHashMap as HashMap;
use lazy_static::lazy_static;
lazy_static! {
pub static ref STD_CODE_MAP: HashMap<&'static str, &'static str> = {
let mut m = HashMap::new();
for (codon, amino_acid) in STD_CODE {
m.insert(*codon, amino_acid.as_ref());
}
m
};
}
const STD_CODE: &[(&str, &str)] = &[
("TTT", "F"),
("TTC", "F"),
("TTA", "L"),
("TTG", "L"),
("TCT", "S"),
("TCC", "S"),
("TCA", "S"),
("TCG", "S"),
("TAT", "Y"),
("TAC", "Y"),
("TAA", "*"),
("TAG", "*"),
("TGT", "C"),
("TGC", "C"),
("TGA", "*"),
("TGG", "W"),
("CTT", "L"),
("CTC", "L"),
("CTA", "L"),
("CTG", "L"),
("CCT", "P"),
("CCC", "P"),
("CCA", "P"),
("CCG", "P"),
("CAT", "H"),
("CAC", "H"),
("CAA", "Q"),
("CAG", "Q"),
("CGT", "R"),
("CGC", "R"),
("CGA", "R"),
("CGG", "R"),
("ATT", "I"),
("ATC", "I"),
("ATA", "I"),
("ATG", "M"),
("ACT", "T"),
("ACC", "T"),
("ACA", "T"),
("ACG", "T"),
("AAT", "N"),
("AAC", "N"),
("AAA", "K"),
("AAG", "K"),
("AGT", "S"),
("AGC", "S"),
("AGA", "R"),
("AGG", "R"),
("GTT", "V"),
("GTC", "V"),
("GTA", "V"),
("GTG", "V"),
("GCT", "A"),
("GCC", "A"),
("GCA", "A"),
("GCG", "A"),
("GAT", "D"),
("GAC", "D"),
("GAA", "E"),
("GAG", "E"),
("GGT", "G"),
("GGC", "G"),
("GGA", "G"),
("GGG", "G"),
("NNN", "X"),
("---", "-"),
("???", "?"),
];
pub struct NcbiTables<'a> {
translation: &'a [(&'a str, &'a str)],
}
impl Default for NcbiTables<'_> {
fn default() -> Self {
Self::new()
}
}
impl NcbiTables<'_> {
pub fn new() -> Self {
Self {
translation: STD_CODE,
}
}
pub fn standard_code(&self) -> HashMap<String, String> {
let mut code = HashMap::new();
self.translation.iter().for_each(|(codon, protein)| {
code.insert(codon.to_string(), protein.to_string());
});
code
}
pub fn vert_mtdna(&self) -> HashMap<String, String> {
let mut code = HashMap::new();
self.translation.iter().for_each(|(codon, protein)| {
match *codon {
"AGA" => code.insert(codon.to_string(), String::from("*")),
"AGG" => code.insert(codon.to_string(), String::from("*")),
"ATA" => code.insert(codon.to_string(), String::from("M")),
"TGA" => code.insert(codon.to_string(), String::from("W")),
_ => code.insert(codon.to_string(), protein.to_string()),
};
});
code
}
pub fn yeast_mtdna(&self) -> HashMap<String, String> {
let mut code = HashMap::new();
self.translation.iter().for_each(|(codon, protein)| {
match *codon {
"ATA" => code.insert(codon.to_string(), String::from("M")),
"CTT" => code.insert(codon.to_string(), String::from("T")),
"CTC" => code.insert(codon.to_string(), String::from("T")),
"CTA" => code.insert(codon.to_string(), String::from("T")),
"CTG" => code.insert(codon.to_string(), String::from("T")),
"TGA" => code.insert(codon.to_string(), String::from("W")),
_ => code.insert(codon.to_string(), protein.to_string()),
};
});
code
}
pub fn moldprotocoe_mtdna(&self) -> HashMap<String, String> {
let mut code = HashMap::new();
self.translation.iter().for_each(|(codon, protein)| {
match *codon {
"TGA" => code.insert(codon.to_string(), String::from("W")),
_ => code.insert(codon.to_string(), protein.to_string()),
};
});
code
}
pub fn invert_mtdna(&self) -> HashMap<String, String> {
let mut code = HashMap::new();
self.translation.iter().for_each(|(codon, protein)| {
match *codon {
"AGA" => code.insert(codon.to_string(), String::from("S")),
"AGG" => code.insert(codon.to_string(), String::from("S")),
"ATA" => code.insert(codon.to_string(), String::from("M")),
"TGA" => code.insert(codon.to_string(), String::from("W")),
_ => code.insert(codon.to_string(), protein.to_string()),
};
});
code
}
pub fn cildashex_nudna(&self) -> HashMap<String, String> {
let mut code = HashMap::new();
self.translation.iter().for_each(|(codon, protein)| {
match *codon {
"TAA" => code.insert(codon.to_string(), String::from("Q")),
"TAG" => code.insert(codon.to_string(), String::from("Q")),
_ => code.insert(codon.to_string(), protein.to_string()),
};
});
code
}
pub fn echiflatworm_mtdna(&self) -> HashMap<String, String> {
let mut code = HashMap::new();
self.translation.iter().for_each(|(codon, protein)| {
match *codon {
"AAA" => code.insert(codon.to_string(), String::from("N")),
"AGA" => code.insert(codon.to_string(), String::from("S")),
"AGG" => code.insert(codon.to_string(), String::from("S")),
"TGA" => code.insert(codon.to_string(), String::from("W")),
_ => code.insert(codon.to_string(), protein.to_string()),
};
});
code
}
pub fn euplotid_nudna(&self) -> HashMap<String, String> {
let mut code = HashMap::new();
self.translation.iter().for_each(|(codon, protein)| {
match *codon {
"TGA" => code.insert(codon.to_string(), String::from("C")),
_ => code.insert(codon.to_string(), protein.to_string()),
};
});
code
}
pub fn alt_yeast_nu(&self) -> HashMap<String, String> {
let mut code = HashMap::new();
self.translation.iter().for_each(|(codon, protein)| {
match *codon {
"CTG" => code.insert(codon.to_string(), String::from("S")),
_ => code.insert(codon.to_string(), protein.to_string()),
};
});
code
}
pub fn ascidian_mtdna(&self) -> HashMap<String, String> {
let mut code = HashMap::new();
self.translation.iter().for_each(|(codon, protein)| {
match *codon {
"AGA" => code.insert(codon.to_string(), String::from("G")),
"AGG" => code.insert(codon.to_string(), String::from("G")),
"ATA" => code.insert(codon.to_string(), String::from("M")),
"TGA" => code.insert(codon.to_string(), String::from("W")),
_ => code.insert(codon.to_string(), protein.to_string()),
};
});
code
}
pub fn alt_flatworm_mtdna(&self) -> HashMap<String, String> {
let mut code = HashMap::new();
self.translation.iter().for_each(|(codon, protein)| {
match *codon {
"AAA" => code.insert(codon.to_string(), String::from("N")),
"AGA" => code.insert(codon.to_string(), String::from("S")),
"AGG" => code.insert(codon.to_string(), String::from("S")),
"TAA" => code.insert(codon.to_string(), String::from("Y")),
"TGA" => code.insert(codon.to_string(), String::from("W")),
_ => code.insert(codon.to_string(), protein.to_string()),
};
});
code
}
pub fn chlorophycean_mtdna(&self) -> HashMap<String, String> {
let mut code = HashMap::new();
self.translation.iter().for_each(|(codon, protein)| {
match *codon {
"TAG" => code.insert(codon.to_string(), String::from("L")),
_ => code.insert(codon.to_string(), protein.to_string()),
};
});
code
}
pub fn trematode_mtdna(&self) -> HashMap<String, String> {
let mut code = HashMap::new();
self.translation.iter().for_each(|(codon, protein)| {
match *codon {
"TGA" => code.insert(codon.to_string(), String::from("W")),
"ATA" => code.insert(codon.to_string(), String::from("M")),
"AGA" => code.insert(codon.to_string(), String::from("S")),
"AGG" => code.insert(codon.to_string(), String::from("S")),
"AAA" => code.insert(codon.to_string(), String::from("N")),
_ => code.insert(codon.to_string(), protein.to_string()),
};
});
code
}
pub fn scenedesmus_mtdna(&self) -> HashMap<String, String> {
let mut code = HashMap::new();
self.translation.iter().for_each(|(codon, protein)| {
match *codon {
"TCA" => code.insert(codon.to_string(), String::from("*")),
"TAG" => code.insert(codon.to_string(), String::from("L")),
_ => code.insert(codon.to_string(), protein.to_string()),
};
});
code
}
pub fn thraustochytrium_mtdna(&self) -> HashMap<String, String> {
let mut code = HashMap::new();
self.translation.iter().for_each(|(codon, protein)| {
match *codon {
"TTA" => code.insert(codon.to_string(), String::from("*")),
_ => code.insert(codon.to_string(), protein.to_string()),
};
});
code
}
pub fn rhabdopleuridae_mtdna(&self) -> HashMap<String, String> {
let mut code = HashMap::new();
self.translation.iter().for_each(|(codon, protein)| {
match *codon {
"AGA" => code.insert(codon.to_string(), String::from("S")),
"AGG" => code.insert(codon.to_string(), String::from("K")),
"TGA" => code.insert(codon.to_string(), String::from("W")),
_ => code.insert(codon.to_string(), protein.to_string()),
};
});
code
}
pub fn candid_div_sr1_gracil(&self) -> HashMap<String, String> {
let mut code = HashMap::new();
self.translation.iter().for_each(|(codon, protein)| {
match *codon {
"TGA" => code.insert(codon.to_string(), String::from("G")),
_ => code.insert(codon.to_string(), protein.to_string()),
};
});
code
}
pub fn pachysolen_tanno_nu(&self) -> HashMap<String, String> {
let mut code = HashMap::new();
self.translation.iter().for_each(|(codon, protein)| {
match *codon {
"CTG" => code.insert(codon.to_string(), String::from("A")),
_ => code.insert(codon.to_string(), protein.to_string()),
};
});
code
}
pub fn mesodinium_nu(&self) -> HashMap<String, String> {
let mut code = HashMap::new();
self.translation.iter().for_each(|(codon, protein)| {
match *codon {
"TAA" => code.insert(codon.to_string(), String::from("Y")),
"TAG" => code.insert(codon.to_string(), String::from("Y")),
_ => code.insert(codon.to_string(), protein.to_string()),
};
});
code
}
pub fn peritrich_nu(&self) -> HashMap<String, String> {
let mut code = HashMap::new();
self.translation.iter().for_each(|(codon, protein)| {
match *codon {
"TAA" => code.insert(codon.to_string(), String::from("E")),
"TAG" => code.insert(codon.to_string(), String::from("E")),
_ => code.insert(codon.to_string(), protein.to_string()),
};
});
code
}
pub fn cephalodiscidae_mtdna(&self) -> HashMap<String, String> {
let mut code = HashMap::new();
self.translation.iter().for_each(|(codon, protein)| {
match *codon {
"TAA" => code.insert(codon.to_string(), String::from("Y")),
"TGA" => code.insert(codon.to_string(), String::from("W")),
"AGA" => code.insert(codon.to_string(), String::from("S")),
"AGG" => code.insert(codon.to_string(), String::from("K")),
_ => code.insert(codon.to_string(), protein.to_string()),
};
});
code
}
}