vdj_pipe
pipeline for processing DNA sequence data
me_positional.hpp
Go to the documentation of this file.
1 
7 #ifndef ME_POSITIONAL_HPP_
8 #define ME_POSITIONAL_HPP_
9 #include <cstdlib> // abs(int)
10 #include "boost/utility/string_ref.hpp"
12 #include "vdj_pipe/value_map.hpp"
13 #include "vdj_pipe/object_ids.hpp"
14 #include "vdj_pipe/exception.hpp"
16 #include "me_relative_interval.hpp"
17 
18 namespace vdj_pipe{ namespace match{
19 
23  //undefined to prevent bool to std::size_t cast
25  Value_map const&,
26  std::string const&,
27  const std::size_t,
28  const std::size_t,
29  const std::size_t
30  );
31 
32 public:
33  struct Err : public base_exception{};
34  typedef boost::string_ref sequence;
36 
38  Value_map const& vm,
39  std::string const& match_value_name,
40  Relative_interval const& ri
41  )
42  : vm_(vm),
43  name_val_id_(vm_.insert_new_name(match_value_name)),
44  ri_(ri)
45  {}
46 
48  Value_map const& vm,
49  std::string const& match_value_name,
50  const int pos,
51  const bool re_start,
52  const int length
53  )
54  : vm_(vm),
55  name_val_id_(vm_.insert_new_name(match_value_name)),
56  ri_(Relative_position(pos, re_start), length)
57  {}
58 
60  const sequence seq,
61  quality const&,
62  sequence_interval const& si
63  ) {
64  if( ! is_valid(si) ) return result();
65  const sequence_interval si1 = ri_(si, seq.size());
66  if( ! is_valid(si1) || width(si1) < abs(ri_.length()) ) return result();
67  return result(seq.substr(si1.lower(), width(si1)), si1);
68  }
69 
70  void finish() {}
71 
72 private:
74  Val_id name_val_id_;
76 
78  const sequence seq = sequence(),
80  ) {
81  if( name_val_id_ && seq.size() ) vm_[name_val_id_] = seq.to_string();
82  return si;
83  }
84 };
85 
86 
87 }//namespace match
88 }//namespace vdj_pipe
89 #endif /* ME_POSITIONAL_HPP_ */
Sequence position defined relatively to an interval.
Definition: me_relative_position.hpp:16
Definition: sequence_record.hpp:35
void finish()
Definition: me_positional.hpp:70
int length() const
Definition: me_relative_interval.hpp:41
Match_element_positional(Value_map const &vm, std::string const &match_value_name, const int pos, const bool re_start, const int length)
Definition: me_positional.hpp:47
Identify DNA sequence interval by position only.
Definition: me_positional.hpp:22
Match_element_positional(Value_map const &, std::string const &, const std::size_t, const std::size_t, const std::size_t)
sequence_interval result(const sequence seq=sequence(), sequence_interval const &si=sequence_interval_invalid())
Definition: me_positional.hpp:77
Main namespace of vdj_pipe library.
Definition: keywords_variable.hpp:11
Relative_interval ri_
Definition: me_positional.hpp:75
Value_map vm_
Definition: me_positional.hpp:73
sequence_interval operator()(const sequence seq, quality const &, sequence_interval const &si)
Definition: me_positional.hpp:59
sequence_interval sequence_interval_invalid()
Definition: sequence_interval.hpp:44
Qual_record::quality quality
Definition: me_positional.hpp:35
boost::string_ref sequence
Definition: me_positional.hpp:34
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
Definition: exception.hpp:23
bool is_valid(vdj_pipe::sequence_interval const &si)
Definition: sequence_interval.hpp:62
Store values mapped against name strings and value IDs.
Definition: value_map.hpp:23
Val_id name_val_id_
Definition: me_positional.hpp:74
Match_element_positional(Value_map const &vm, std::string const &match_value_name, Relative_interval const &ri)
Definition: me_positional.hpp:37
Definition: me_positional.hpp:33
const sequence_interval si1(0, 18)
Definition: me_relative_interval.hpp:15