pub struct RandomBases {}
pub struct RandomAT {}
impl Iterator for RandomBases {
type Item = char;
fn next(&mut self) -> Option<Self::Item> {
use rand::Rng;
let mut rng = rand::thread_rng();
let between = rand::distributions::Uniform::from(0..4);
Some(match rng.sample(&between) {
0 => 'A',
1 => 'C',
2 => 'G',
_ => 'T',
})
}
}
impl Iterator for RandomAT {
type Item = char;
fn next(&mut self) -> Option<Self::Item> {
use rand::Rng;
let mut rng = rand::thread_rng();
if rng.gen() {
Some('A')
} else {
Some('T')
}
}
}
impl RandomBases {
pub fn new() -> Self {
RandomBases {}
}
}
impl RandomAT {
pub fn new() -> Self {
RandomAT {}
}
}
pub fn complement(base: char) -> char {
match base {
'A' | 'a' => 'T',
'T' | 't' => 'A',
'C' | 'c' => 'G',
'G' | 'g' => 'C',
_ => {
panic!("unexpected character");
}
}
}