00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __ALIGNSTREAM_H__
00025 #define __ALIGNSTREAM_H__
00026
00027 #include <Sequence/Alignment.hpp>
00028 #include <Sequence/SeqExceptions.hpp>
00029 #include <boost/type_traits.hpp>
00030 #include <boost/static_assert.hpp>
00031 #include <utility>
00032 #include <string>
00057 namespace Sequence
00058 {
00059 template < typename T >
00060 class AlignStream
00061 {
00062 private:
00063
00064 typedef std::pair<std::string,std::string> baseType;
00065 BOOST_STATIC_ASSERT( (boost::is_base_and_derived<baseType,T>::value
00066 || boost::is_same<baseType,T>::value) );
00071 std::vector < T >data;
00072 public:
00073 AlignStream(const std::vector<T> & _data);
00074 AlignStream(const AlignStream<T> &a)
00075 {this->assign(a.begin(),a.end());}
00076 AlignStream(void){}
00077 virtual ~ AlignStream (void);
00078 typedef typename std::vector<T>::size_type size_type;
00079 typedef typename std::vector<T>::reference reference;
00080 typedef typename std::vector<T>::const_reference const_reference;
00081 size_type size(void) const
00085 {
00086 return data.size();
00087 }
00088 reference operator[](const size_type & i)
00089
00093 {
00094 return data[i];
00095 }
00096 const_reference operator[](const size_type & i) const
00101 {
00102 return data[i];
00103 }
00107 typedef typename std::vector<T>::iterator iterator;
00111 typedef typename std::vector<T>::const_iterator const_iterator;
00112 iterator begin();
00113 iterator end();
00114 const_iterator begin() const;
00115 const_iterator end() const;
00116 bool IsAlignment (void);
00117 bool Gapped (void);
00118 unsigned UnGappedLength (void);
00119 void RemoveGaps (void);
00120 void RemoveTerminalGaps (void);
00121 std::vector < T >Trim ( std::vector < int >sites)
00122 throw (Sequence::SeqException);
00123 std::vector < T >TrimComplement ( std::vector < int >sites)
00124 throw (Sequence::SeqException);
00125 const std::vector< T > Data(void);
00129 virtual std::istream & read (std::istream & s) = 0;
00133 virtual std::ostream & print (std::ostream & s) const = 0;
00134
00144 void assign(const_iterator beg,const_iterator end)
00145 throw (Sequence::SeqException);
00146 };
00147
00148
00149 template < typename T >
00150 std::istream & operator>> (std::istream & s, AlignStream < T > &c)
00157 {
00158 return c.read (s);
00159 }
00160
00161 template < typename T >
00162 std::ostream & operator<< (std::ostream & s,const AlignStream < T > &c)
00169 {
00170 return c.print (s);
00171 }
00172
00173 }
00174 #include <Sequence/bits/AlignStream.tcc>
00175 #endif