libsequence  1.9.5
AlignStream.tcc
1 // Code for the -*- C++ -*- namespace Sequence::AlignStream<T>
2 
3 /*
4 
5 Copyright (C) 2003-2009 Kevin Thornton, krthornt[]@[]uci.edu
6 
7 Remove the brackets to email me.
8 
9 This file is part of libsequence.
10 
11 libsequence is free software: you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
15 
16 libsequence is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20 
21 You should have received a copy of the GNU General Public License
22 long with libsequence. If not, see <http://www.gnu.org/licenses/>.
23 
24 */
25 
26 /*! \file AlignStream.tcc
27  @brief implementation of AlignStream.hpp
28 */
29 
30 #include <Sequence/AlignStream.hpp>
31 
32 namespace Sequence
33 {
34  template<typename T>
35  AlignStream<T>::AlignStream(const std::vector<T> & _data)
36  {
37  data.assign(_data.begin(),_data.end());
38  if(!this->IsAlignment())
39  throw std::runtime_error("Sequence::AlignStream: construction attempted from invalid data");
40  }
41 
42  template<typename T>
43  AlignStream<T>::AlignStream( std::vector<T> && _data) : data(std::move(_data))
44  {
45  if(!this->IsAlignment())
46  throw std::runtime_error("Sequence::AlignStream: construction attempted from invalid data");
47  }
48 
49  template<typename T>
50  AlignStream<T>::AlignStream(const AlignStream<T> &a) : data( a.data )
51  {
52  if(!this->IsAlignment())
53  throw std::runtime_error("Sequence::AlignStream: construction attempted from invalid data");
54  }
55 
56  template<typename T>
57  AlignStream<T>::AlignStream( AlignStream<T> && a) : data( std::move(a.data) )
58  {
59  if(!this->IsAlignment())
60  throw std::runtime_error("Sequence::AlignStream: construction attempted from invalid data");
61  }
62 
63  template<typename T>
64  AlignStream<T>::~AlignStream(void)
65  {}
66 
67  template<typename T>
68  void AlignStream<T>::assign ( const_iterator beg,
69  const_iterator end )
70  /*!
71  store the data
72  */
73  {
74  data.assign(beg,end);
75  if (! this->IsAlignment() )
76  throw (std::runtime_error("AlignStream::assign -- data elements have different lengths"));
77  }
78 
79  template<typename T>
80  void AlignStream<T>::assign( std::vector<T> && _data )
81  /*
82  Implemented via std::swap
83  */
84  {
85  data.clear();
86  std::swap(data,_data);
87  }
88 
89  template<typename T>
90  typename AlignStream<T>::iterator AlignStream<T>::begin()
91  {
92  return data.begin();
93  }
94 
95  template<typename T>
96  typename AlignStream<T>::iterator AlignStream<T>::end()
97  {
98  return data.end();
99  }
100 
101  template<typename T>
102  typename AlignStream<T>::const_iterator AlignStream<T>::begin() const
103  {
104  return data.begin();
105  }
106 
107  template<typename T>
108  typename AlignStream<T>::const_iterator AlignStream<T>::end() const
109  {
110  return data.end();
111  }
112 
113  template < typename T >
114  bool AlignStream < T >::IsAlignment (void)
115  /*!
116  Implemented by a call to Alignment::IsAlignment
117  */
118  {
119  return Alignment::IsAlignment (data);
120  }
121 
122  template < typename T >
123  bool AlignStream < T >::Gapped (void)
124  /*!
125  Implemented by a call to Alignment::Gapped
126  */
127  {
128  return Alignment::Gapped (data);
129  }
130 
131  template < typename T >
132  unsigned AlignStream < T >::UnGappedLength (void)
133  /*!
134  Implemented by a call to Alignment::UnGappedLength
135  */
136  {
137  return Alignment::UnGappedLength (data);
138  }
139 
140  template < typename T >
141  void AlignStream < T >::RemoveGaps (void)
142  /*!
143  Implemented by a call to Alignment::RemoveGaps
144  */
145  {
146  Alignment::RemoveGaps (data);
147  }
148 
149  template < typename T >
150  void AlignStream < T >::RemoveTerminalGaps (void)
151  /*!
152  Implemented by a call to Alignment::RemoveTerminalGaps
153  */
154  {
155  Alignment::RemoveTerminalGaps (data);
156  }
157 
158  template < typename T >
159  std::vector < T >AlignStream < T >::Trim ( std::vector <int >sites)
160 
161 
162  /*!
163  Implemented by a call to Alignment::Trim
164  */
165  {
166  return Alignment::Trim (data, sites);
167  }
168 
169  template < typename T >
170  std::vector < T > AlignStream < T >::TrimComplement
171  (std::vector <int>sites)
172 
173  /*!
174  Implemented by a call to Alignment::TrimComplement
175  */
176  {
177  return Alignment::TrimComplement (data, sites);
178  }
179 
180  template <typename T >
181  const std::vector < T> AlignStream< T >::Data(void)
182  /*!
183  Returns the std::vector < T* > data
184  */
185  {
186  return data;
187  }
188 
189 }
190