vdj_pipe
pipeline for processing DNA sequence data
sequence_interval.hpp
Go to the documentation of this file.
1 
7 #ifndef SEQUENCE_INTERVAL_HPP_
8 #define SEQUENCE_INTERVAL_HPP_
9 #include <iosfwd>
10 #include <limits>
11 #include "boost/functional/hash/hash_fwd.hpp"
12 #include "boost/numeric/interval.hpp"
13 #include "boost/numeric/interval/checking.hpp"
14 
15 namespace vdj_pipe{ namespace detail{
16 
19 template<class T> struct Interval_checking_policy;
20 
21 template<> struct Interval_checking_policy<int> {
22  typedef int value_type;
23  static value_type pos_inf() {return std::numeric_limits<value_type>::max();}
24  static value_type neg_inf() {return 0;}
25  static value_type nan() {return std::numeric_limits<value_type>::min();}
26  static bool is_nan(const value_type v) {return v == nan();}
27  static value_type empty_lower() {return 0;}
28  static value_type empty_upper() {return 0;}
29  static bool is_empty(const value_type lo, const value_type up) {return lo == up;}
30 };
31 
32 }//namespace detail
33 
34 typedef boost::numeric::interval<
35  int,
36  boost::numeric::interval_lib::policies<
37  boost::numeric::interval_lib::rounded_math<int>,
39  >
40  > sequence_interval;
41 
44 inline sequence_interval sequence_interval_invalid() {
45 /*
46  typedef sequence_interval::base_type value_type;
47  //impossible to create interval with nan()
48  return sequence_interval(
49  std::numeric_limits<value_type>::min(),
50  std::numeric_limits<value_type>::min()
51  );
52 */
53  return sequence_interval(-1, -1);
54 }
55 
56 }//namespace vdj_pipe
57 
58 namespace boost{ namespace numeric {
59 
62 inline bool is_valid( vdj_pipe::sequence_interval const& si) {
63  return si.upper() >= 0;
64 }
65 
68 inline std::size_t hash_value(vdj_pipe::sequence_interval const& si) {
69  std::size_t n = 0;
70  boost::hash_combine(n, si.lower());
71  boost::hash_combine(n, si.upper());
72  return n;
73 }
74 
77 template<class ChT, class Tr> inline
78 std::basic_ostream<ChT,Tr>& operator<<(
79  std::basic_ostream<ChT,Tr>& os,
80  vdj_pipe::sequence_interval const& si
81 ) {
82  os << '[' << si.lower() << ',' << si.upper() << ']';
83  return os;
84 }
85 
86 }//namespace numeric
87 }//namespace boost
88 
89 #endif /* SEQUENCE_INTERVAL_HPP_ */
Definition: sequence_interval.hpp:58
Definition: sequence_interval.hpp:21
Main namespace of vdj_pipe library.
Definition: sequence_file.hpp:14
Definition: sequence_interval.hpp:19