libsequence  1.9.5
PolyTableSlice.hpp
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2003-2009 Kevin Thornton, krthornt[]@[]uci.edu
4 
5 Remove the brackets to email me.
6 
7 This file is part of libsequence.
8 
9 libsequence is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 libsequence is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 long with libsequence. If not, see <http://www.gnu.org/licenses/>.
21 
22 */
23 
24 #ifndef __POLY_TABLE_SLICE_HPP__
25 #define __POLY_TABLE_SLICE_HPP__
26 #include <vector>
27 #include <utility>
28 #include <type_traits>
30 
115 namespace Sequence
116 {
117  template<typename T> class PolyTableSlice
118  {
119  public:
121  typedef std::pair<PolyTable::const_site_iterator,
122  PolyTable::const_site_iterator> range;
123  private:
124  static_assert( std::is_base_of<Sequence::PolyTable,T>::value,
125  "T must be derived from Sequence::PolyTable" );
126  //we store the window info as pointers to the range of sites
127  //in each window
128  std::vector< range > windows;
129  void process_windows( const PolyTable::const_site_iterator beg,
130  const PolyTable::const_site_iterator end,
131  const double & window_size,
132  const double & step_len,
133  const double & starting_pos,
134  const double & ending_pos);
135 
136  void process_windows_fixed( const PolyTable::const_site_iterator beg,
137  const PolyTable::const_site_iterator end,
138  const unsigned & window_size_S,
139  const unsigned & window_step_len );
140 
141  public:
157  explicit PolyTableSlice( const PolyTable::const_site_iterator beg,
158  const PolyTable::const_site_iterator end,
159  const unsigned & window_size_S,
160  const unsigned & window_step_len );
161 
172  explicit PolyTableSlice( const PolyTable::const_site_iterator beg,
173  const PolyTable::const_site_iterator end,
174  const unsigned nwindows);
175 
176 
200  explicit PolyTableSlice( const PolyTable::const_site_iterator beg,
201  const PolyTable::const_site_iterator end,
202  const double & window_size,
203  const double & step_len,
204  const double & starting_pos = 0.,
205  const double & ending_pos = 1.0);
209  typedef std::vector<range>::const_iterator const_iterator;
213  const_iterator cbegin() const;
217  const_iterator cend() const;
223  T get_slice(const const_iterator) const ;
227  std::vector<range>::size_type size() const;
233  T operator[](const unsigned &) const ;
234  };
235 }
236 #include <Sequence/bits/PolyTableSlice.tcc>
237 
238 #endif
std::pair< PolyTable::const_site_iterator, PolyTable::const_site_iterator > range
Range of a window = [first,second)
T get_slice(const const_iterator) const
The namespace in which this library resides.
const_iterator cend() const
std::vector< range >::size_type size() const
A container class for "sliding windows" along a polymorphism table.
T operator[](const unsigned &) const
std::vector< range >::const_iterator const_iterator
PolyTableSlice(const PolyTable::const_site_iterator beg, const PolyTable::const_site_iterator end, const unsigned &window_size_S, const unsigned &window_step_len)
const_iterator cbegin() const