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  >
41 
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,
81 ) {
82  os << '[' << si.lower() << ',' << si.upper() << ']';
83  return os;
84 }
85 
86 }//namespace numeric
87 }//namespace boost
88 
89 #endif /* SEQUENCE_INTERVAL_HPP_ */
static value_type empty_upper()
Definition: sequence_interval.hpp:28
Definition: sanitize_string.cpp:15
static value_type nan()
Definition: sequence_interval.hpp:25
static bool is_empty(const value_type lo, const value_type up)
Definition: sequence_interval.hpp:29
int value_type
Definition: sequence_interval.hpp:22
Definition: sequence_interval.hpp:21
std::size_t hash_value(Base_id< S, V > const &id)
Definition: object_id_base.hpp:55
static bool is_nan(const value_type v)
Definition: sequence_interval.hpp:26
Main namespace of vdj_pipe library.
Definition: keywords_variable.hpp:11
sequence_interval sequence_interval_invalid()
Definition: sequence_interval.hpp:44
const std::size_t n
Definition: vector_set_test.cpp:26
Definition: sequence_interval.hpp:19
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
static value_type empty_lower()
Definition: sequence_interval.hpp:27
std::basic_ostream< ChT, Tr > & operator<<(std::basic_ostream< ChT, Tr > &os, Base_id< S, V > const &id)
Definition: object_id_base.hpp:46
static value_type neg_inf()
Definition: sequence_interval.hpp:24
static value_type pos_inf()
Definition: sequence_interval.hpp:23