Generated on Mon Jun 23 16:24:56 2008 for BIU-1.7.0 by doxygen 1.5.1

src/biu/Alphabet.hh

Go to the documentation of this file.
00001 #ifndef ALPHABET_HH_
00002 #define ALPHABET_HH_
00003 
00004 
00005 #include <vector>
00006 #include <string>
00007 #include <map>
00008 
00009 namespace biu
00010 {
00011 
00018     class Alphabet
00019     {
00020     public:
00022         typedef size_t  AlphElem;
00024         typedef unsigned char   CAlphElem;
00025         
00027         typedef std::vector<AlphElem> Sequence;
00028         
00030         typedef std::vector<CAlphElem> CSequence;
00031         
00032     private:
00033     
00035         typedef std::map<std::string, AlphElem> STR2ALPH_TYPE;
00036         
00039         STR2ALPH_TYPE string2alph;  
00040         
00042         std::vector<std::string> alph2string;   
00043         
00045         size_t elementLength;       
00046         
00047     public:
00048     
00056         Alphabet(   const std::string& alphabetString, 
00057                     const size_t elementLength_);
00058         
00064         Alphabet(const std::vector<std::string> & alphabetStrings);
00065         
00066         virtual ~Alphabet();
00067 
00068         bool operator== (const Alphabet& alph2) const;
00069         bool operator!= (const Alphabet& alph2) const;
00070 
00072         size_t getAlphabetSize() const {
00073             return alph2string.size();
00074         }
00075         
00077         size_t getElementLength() const { 
00078             return elementLength;
00079         }
00080     
00082         // string to sequence to string
00084     
00086         Sequence getSequence(const std::string& seqString) const;
00087         
00089         AlphElem getElement(const std::string& alphElemStr) const;
00090         
00092         std::string getString(const Alphabet::Sequence& sequence) const;
00093         
00095         std::string getString(const Alphabet::AlphElem& elem) const;
00096         
00098         CSequence compress(const Alphabet::Sequence& sequence) const;
00099         
00103         Sequence decompress(const CSequence& sequence, const size_t seqLength) const;
00104         
00105     
00107         // miscellaneous
00109     
00112         bool isAlphabetString(const std::string& str) const;
00113         
00116         bool isAlphabetSequence(const Sequence& seq) const;
00117         
00120         size_t getIndex(const AlphElem& elem) const;
00121         
00125         size_t getIndex(const std::string& elemStr) const;
00126         
00129         AlphElem getElement(const size_t index) const;
00130         
00131     };
00132 
00133 } // namespace biu
00134 
00135 #endif /*ALPHABET_HH_*/