Extend the python mussa interface.
[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     rc_map(Alphabet::get_alphabet(a).get_complement_map()) 
43   {}
44   SeqString(const std::string &s, AlphabetRef a=reduced_nucleic_alphabet) : 
45     std::string(s),
46     alphabet(a),
47     rc_map(Alphabet::get_alphabet(a).get_complement_map()) 
48   {}
49
50   AlphabetRef get_alphabet_ref() { return alphabet; }
51   const Alphabet& get_alphabet() const;
52   
53   std::string create_reverse_complement_map() const;
54   
55 private:
56   AlphabetRef alphabet;
57 public:
58   const std::string rc_map;
59 private:  
60   friend class boost::serialization::access;
61   template<class Archive>
62   void serialize(Archive& ar, const unsigned int /*version*/) {
63     //ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(std::string);
64     ar & boost::serialization::make_nvp("bases",
65       boost::serialization::base_object<std::string>(*this)
66     );
67     ar & BOOST_SERIALIZATION_NVP(alphabet);
68   }
69 };
70 typedef boost::shared_ptr<SeqString> SeqStringRef;
71  
72 #endif /*SEQ_HPP_*/