Skip to content
Snippets Groups Projects
Commit ae161e39 authored by Martin Larralde's avatar Martin Larralde
Browse files

Add method to get all symbols of an alphabet

parent 83627fd6
No related branches found
No related tags found
No related merge requests found
......@@ -32,11 +32,9 @@ pub trait Alphabet: Debug + Copy + Default + 'static {
fn default_symbol() -> Self::Symbol {
Default::default()
}
}
impl Alphabet for Dna {
type Symbol = Nucleotide;
const K: usize = 5;
/// Get all the symbols of this alphabet.
fn symbols() -> &'static [Self::Symbol];
}
// --- ComplementableAlphabet --------------------------------------------------
......@@ -52,6 +50,21 @@ impl<A: Alphabet> ComplementableAlphabet for A where <A as Alphabet>::Symbol: Co
#[derive(Default, Debug, Clone, Copy)]
pub struct Dna;
impl Alphabet for Dna {
type Symbol = Nucleotide;
const K: usize = 5;
fn symbols() -> &'static [Nucleotide] {
&[
Nucleotide::A,
Nucleotide::C,
Nucleotide::T,
Nucleotide::G,
Nucleotide::N,
]
}
}
/// A deoxyribonucleotide.
#[derive(Clone, Copy, PartialEq, Debug)]
#[repr(u8)]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment