Remove prototype boost serialiation code.
[mussa.git] / alg / sequence.hpp
index 9c7ddd4a1e9fb8a397e1332f95dd346ac19ca462..706f499f29a48596a0471245448a61568ff0535f 100644 (file)
 #include <boost/filesystem/path.hpp>
 #include <boost/filesystem/fstream.hpp>
 
-#include <boost/serialization/base_object.hpp>
-#include <boost/serialization/export.hpp>
-#include <boost/serialization/list.hpp>
-#include <boost/serialization/nvp.hpp>
-#include <boost/serialization/string.hpp>
-#include <boost/serialization/shared_ptr.hpp>
-#include <boost/serialization/utility.hpp>
-#include <boost/serialization/version.hpp>
-#include <boost/serialization/vector.hpp>
-
 #include <boost/shared_ptr.hpp>
 #include <boost/enable_shared_from_this.hpp>
 
 
 // Sequence data class
 
-//! Attach annotation information to a sequence track
-struct annot
+/* The way that motifs are found currently doesn't really 
+ * indicate that the match was a reverse compliment
+ */
+struct motif
 {
-  annot();
-  annot(int begin, int end, std::string type, std::string name);
-  ~annot();
-  
+  motif();
+  //motif(int begin, int end, std::string type, std::string name);
+  //! this constructor is for when we're adding motifs to our annotations
+  motif(int begin, std::string motif);
+  ~motif();
+
   int begin;
   int end;
   std::string type;
   std::string name;
+  std::string sequence;
+
+  friend bool operator==(const motif& left, const motif& right);
 
-  friend bool operator==(const annot& left, const annot& right);
-private:
   // boost::serialization support
+private:
   friend class boost::serialization::access;
   template<class Archive>
   void serialize(Archive& ar, const unsigned int /*version*/) {
@@ -60,33 +56,9 @@ private:
     ar & BOOST_SERIALIZATION_NVP(end);
     ar & BOOST_SERIALIZATION_NVP(type);
     ar & BOOST_SERIALIZATION_NVP(name);
-  }
-};
-BOOST_CLASS_EXPORT(annot);
-
-
-/* The way that motifs are found currently doesn't really 
- * indicate that the match was a reverse compliment
- */
-struct motif : public annot
-{
-  std::string sequence;
-
-  motif() : annot(), sequence("") {};
-  //! this constructor is for when we're adding motifs to our annotations
-  motif(int begin, std::string motif);
-  ~motif();
-
-  // boost::serialization support
-private:
-  friend class boost::serialization::access;
-  template<class Archive>
-  void serialize(Archive& ar, const unsigned int /*version*/) {
-    ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(annot);
     ar & BOOST_SERIALIZATION_NVP(sequence);
   }
 };
-BOOST_CLASS_EXPORT(motif);
 
 class Sequence;
 typedef boost::shared_ptr<Sequence> SequenceRef;
@@ -95,6 +67,8 @@ typedef boost::shared_ptr<Sequence> SequenceRef;
 class Sequence 
 {
 public:
+
+
   typedef SeqString::value_type value_type;
   typedef SeqString::difference_type difference_type;
   typedef SeqString::iterator iterator;
@@ -220,14 +194,19 @@ public:
   void load_annot(const boost::filesystem::path file_path, int start_index, int end_index);
   //! load sequence annotations
   //! \throws mussa_load_error 
-  void load_annot(std::fstream& data_stream, int start_index, int end_index);
+  void load_annot(std::istream& data_stream, int start_index, int end_index);
   //! parse annotation file
   /*! \throws annotation_load_error 
    */
   void parse_annot(std::string data, int start_index=0, int end_index=0);
   //! add an annotation to our list of annotations
-  void add_annotation(const annot& a);
-  const std::list<annot>& annotations() const;
+  void add_annotation(const SeqSpanRef a);
+  //! add an annotation using tristan's mussa file paramenters
+  void add_annotation(std::string name, std::string type, size_type start, size_type stop);
+  //! create an initialized annotation with the "standard" types.
+  SeqSpanRef make_annotation(std::string name, std::string type, size_type start, size_type stop) const;
+  const SeqSpanRefList& annotations() const;
+  
   const MotifList& motifs() const;
 
   //! add a motif to our list of motifs
@@ -240,9 +219,11 @@ public:
   //! annotate the current sequence with other sequences
   void find_sequences(std::list<Sequence>::iterator start, 
                      std::list<Sequence>::iterator end);
+  SeqSpanRef seqspan() { return seq; }
   
   void save(boost::filesystem::fstream &save_file);
-  void load_museq(boost::filesystem::path load_file_path, int seq_num);
+  //void load_museq(boost::filesystem::path load_file_path, int seq_num);
+  static SequenceRef load_museq(boost::filesystem::fstream& load_file);
   
 protected:  
   SeqSpanRef seq;
@@ -251,8 +232,8 @@ protected:
   //! species name
   std::string species;
 
-  //! store our oldstyle annotations
-  std::list<annot> annots;
+  //! store annotation regions
+  SeqSpanRefListRef annotation_list;
   //! a seperate list for motifs since we're currently not saving them
   MotifListRef motif_list;
 
@@ -264,16 +245,6 @@ protected:
   //! look for a string sequence type and and it to an annotation list
   void add_string_annotation(std::string a_seq, std::string name);
   
-  // boost::serialization support
-  friend class boost::serialization::access;
-  template<class Archive>
-  void serialize(Archive& ar, const unsigned int /*version*/) {
-    ar & BOOST_SERIALIZATION_NVP(seq);
-    ar & BOOST_SERIALIZATION_NVP(header);
-    ar & BOOST_SERIALIZATION_NVP(species);
-    ar & BOOST_SERIALIZATION_NVP(annots);
-    ar & BOOST_SERIALIZATION_NVP(motif_list);
-  }
 };
-BOOST_CLASS_EXPORT(Sequence);
+
 #endif