vdj_pipe
pipeline for processing DNA sequence data
me_relative_interval.hpp
Go to the documentation of this file.
1 
7 #ifndef ME_RELATIVE_INTERVAL_HPP_
8 #define ME_RELATIVE_INTERVAL_HPP_
10 
11 namespace vdj_pipe{ namespace match{
12 
16  static const int unset;
17 public:
19  Relative_position const& rp,
20  const int length = unset
21  )
22  : rp_(rp),
23  len_(length)
24  {}
25 
27  sequence_interval const& si,
28  const std::size_t seq_len
29  ) const {
30  if( ! is_valid(si) ) return sequence_interval_invalid();
31  const int pos = rp_(si);
32  const sequence_interval si2 =
33  len_ < 0 ?
34  sequence_interval(pos + len_, pos) :
35  sequence_interval(pos, pos + len_)
36  ;
37  if( ! is_valid(si2) ) return sequence_interval_invalid();
38  return intersect(si2, sequence_interval(0U, seq_len));
39  }
40 
41  int length() const {return len_;}
42  bool length_defined() const {return len_ != unset;}
43  Relative_position const& position() const {return rp_;}
44 
45  template<class ChT, class Tr> friend
46  std::basic_ostream<ChT,Tr>& operator<<(
47  std::basic_ostream<ChT,Tr>& os,
48  Relative_interval const& ri
49  ) {
50  os << ri.rp_ << " len" << ri.len_;
51  return os;
52  }
53 
54 private:
56  int len_; //length is negative if end point is defined
57 };
58 
59 }//namespace match
60 }//namespace vdj_pipe
61 #endif /* ME_RELATIVE_INTERVAL_HPP_ */
Sequence position defined relatively to an interval.
Definition: me_relative_position.hpp:16
bool length_defined() const
Definition: me_relative_interval.hpp:42
int length() const
Definition: me_relative_interval.hpp:41
Relative_position const & position() const
Definition: me_relative_interval.hpp:43
static const int unset
Definition: me_relative_interval.hpp:16
friend std::basic_ostream< ChT, Tr > & operator<<(std::basic_ostream< ChT, Tr > &os, Relative_interval const &ri)
Definition: me_relative_interval.hpp:46
Main namespace of vdj_pipe library.
Definition: keywords_variable.hpp:11
sequence_interval sequence_interval_invalid()
Definition: sequence_interval.hpp:44
Relative_position rp_
Definition: me_relative_interval.hpp:55
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
int len_
Definition: me_relative_interval.hpp:56
Relative_interval(Relative_position const &rp, const int length=unset)
Definition: me_relative_interval.hpp:18
sequence_interval operator()(sequence_interval const &si, const std::size_t seq_len) const
Definition: me_relative_interval.hpp:26
Definition: me_relative_interval.hpp:15