Move alphabet type into SeqString
[mussa.git] / alg / seq.hpp
1 #ifndef SEQ_HPP_
2 #define SEQ_HPP_
3
4 #include <string>
5
6 #include <boost/serialization/base_object.hpp>
7 #include <boost/serialization/export.hpp>
8 #include <boost/serialization/list.hpp>
9 #include <boost/serialization/nvp.hpp>
10 #include <boost/serialization/string.hpp>
11 #include <boost/serialization/shared_ptr.hpp>
12 #include <boost/serialization/utility.hpp>
13 #include <boost/serialization/version.hpp>
14 #include <boost/serialization/vector.hpp>
15
16 #include <boost/shared_ptr.hpp>
17
18 #include "alphabet.hpp"
19 //! These classes provide for the internal implementation for the Sequence class
20
21 /** the only purpose of this class is that the shared_ptr template 
22  * functions need the serialization support to be in-class.
23  */
24
25 class SeqString : public std::string
26 {
27 public:
28   typedef std::string::difference_type difference_type;
29   typedef std::string::iterator iterator;
30   typedef std::string::reverse_iterator reverse_iterator;
31   typedef std::string::const_iterator const_iterator;
32   typedef std::string::const_reverse_iterator const_reverse_iterator;
33   typedef std::string::reference reference;
34   typedef std::string::const_reference const_reference;
35   typedef std::string::size_type size_type;
36   typedef std::string::value_type value_type;
37   static const size_type npos = std::string::npos;
38   
39   SeqString(AlphabetRef a=reduced_nucleic_alphabet) : 
40     std::string(),
41     alphabet(a) 
42   {}
43   SeqString(const std::string &s, AlphabetRef a=reduced_nucleic_alphabet) : 
44     std::string(s),
45     alphabet(a)
46   {}
47
48   AlphabetRef get_alphabet_ref() { return alphabet; }
49   const Alphabet& get_alphabet() const;
50   
51   std::string create_reverse_complement_map() const;
52 private:
53   AlphabetRef alphabet;
54   friend class boost::serialization::access;
55   template<class Archive>
56   void serialize(Archive& ar, const unsigned int /*version*/) {
57     //ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(std::string);
58     ar & boost::serialization::make_nvp("bases",
59       boost::serialization::base_object<std::string>(*this)
60     );
61     ar & BOOST_SERIALIZATION_NVP(alphabet);
62   }
63 };
64 typedef boost::shared_ptr<SeqString> SeqStringRef;
65  
66 #endif /*SEQ_HPP_*/