vdj_pipe
pipeline for processing DNA sequence data
me_relative_position.hpp
Go to the documentation of this file.
1 
7 #ifndef ME_RELATIVE_POSITION_HPP_
8 #define ME_RELATIVE_POSITION_HPP_
9 #include <iosfwd>
11 
12 namespace vdj_pipe{ namespace match{
13 
17  //left undefined to avoid implicit bool->int cast
18  Relative_position(const bool, const int);
19 public:
21  : pos_(std::numeric_limits<int>::min()),
22  re_start_(true)
23  {}
24 
30  Relative_position(const int pos, const bool re_start)
31  : pos_(pos), re_start_(re_start)
32  {}
33 
34  int operator() (sequence_interval const& si) const {
35  if( is_valid(si) ) {
36  const sequence_interval::base_type n =
37  re_start_ ? si.lower() : si.upper();
38  return n + pos_;
39  }
40  return std::numeric_limits<int>::min();
41  }
42 
43  template<class ChT, class Tr> friend
44  std::basic_ostream<ChT,Tr>& operator<<(
45  std::basic_ostream<ChT,Tr>& os,
46  Relative_position const& rp
47  ) {
48  os << '@';
49  if( rp.re_start_ ) os << "start";
50  else os << "end";
51  if( rp.pos_ > 0 ) os << '+';
52  if( rp.pos_ ) os << rp.pos_;
53  return os;
54  }
55 
56 private:
57  int pos_;
58  bool re_start_;
59 };
60 
61 }//namespace match
62 }//namespace vdj_pipe
63 #endif /* ME_RELATIVE_POSITION_HPP_ */
Sequence position defined relatively to an interval.
Definition: me_relative_position.hpp:16
Relative_position()
Definition: me_relative_position.hpp:20
STL namespace.
Main namespace of vdj_pipe library.
Definition: keywords_variable.hpp:11
int operator()(sequence_interval const &si) const
Definition: me_relative_position.hpp:34
Relative_position(const int pos, const bool re_start)
Definition: me_relative_position.hpp:30
const std::size_t n
Definition: vector_set_test.cpp:26
boost::numeric::interval< int, boost::numeric::interval_lib::policies< boost::numeric::interval_lib::rounded_math< int >, detail::Interval_checking_policy< int > > > sequence_interval
Definition: sequence_interval.hpp:40
bool is_valid(vdj_pipe::sequence_interval const &si)
Definition: sequence_interval.hpp:62
bool re_start_
Definition: me_relative_position.hpp:58
int pos_
Definition: me_relative_position.hpp:57
friend std::basic_ostream< ChT, Tr > & operator<<(std::basic_ostream< ChT, Tr > &os, Relative_position const &rp)
Definition: me_relative_position.hpp:44