+#include <stdexcept>
+
#include "alg/alphabet.hpp"
// some standard dna alphabets
//! the protein alphabet
const char *Alphabet::protein_cstr =
"AaCcDdEeFfGgHhIiKkLlMmNnPpQqRrSsTtVvWwYy\012\015";
+const char *Alphabet::empty_cstr = "";
const Alphabet& Alphabet::reduced_dna_alphabet() {
static Alphabet *a = new Alphabet(reduced_dna_cstr);
static Alphabet *a = new Alphabet(protein_cstr);
return *a;
}
+const Alphabet& Alphabet::empty_alphabet() {
+ static Alphabet *a = new Alphabet(empty_cstr);
+ return *a;
+}
Alphabet::Alphabet(const char *a) :
alphabet(a)
alphabet_set.insert(alphabet.begin(), alphabet.end());
}
+bool operator==(const Alphabet& x, const Alphabet& y)
+{
+ return x.alphabet == y.alphabet;
+}
+
+std::ostream& operator<<(std::ostream& out, const Alphabet& a)
+{
+ out << a.alphabet;
+}
+
bool Alphabet::exists(const char c) const
{
return (alphabet_set.find(c) != alphabet_set.end());
}
+
+const Alphabet& Alphabet::get_alphabet(AlphabetRef alpha)
+{
+ switch (alpha) {
+ case ::reduced_dna_alphabet:
+ return Alphabet::reduced_dna_alphabet();
+ case ::reduced_rna_alphabet:
+ return Alphabet::reduced_rna_alphabet();
+ case ::reduced_nucleic_alphabet:
+ return Alphabet::reduced_nucleic_alphabet();
+ case ::nucleic_alphabet:
+ return Alphabet::nucleic_alphabet();
+ case ::protein_alphabet:
+ return Alphabet::protein_alphabet();
+ default:
+ throw std::runtime_error("unrecognized alphabet type");
+ break;
+ }
+}
\ No newline at end of file