vdj_pipe
pipeline for processing DNA sequence data
me_battery.hpp
Go to the documentation of this file.
1 
7 #ifndef ME_BATTERY_HPP_
8 #define ME_BATTERY_HPP_
9 #include <iosfwd>
10 #include <string>
11 #include <vector>
12 
13 #include "me_aligned.hpp"
14 #include "me_ambiguous.hpp"
15 #include "me_combination.hpp"
16 #include "me_positional.hpp"
17 #include "me_short.hpp"
18 #include "me_truncate.hpp"
19 #include "me_types.hpp"
20 #include "sequence_map_types.hpp"
21 #include "vdj_pipe/exception.hpp"
23 
24 namespace vdj_pipe{ namespace match{
25 
28 class Match_element_visitor : public boost::static_visitor<sequence_interval> {
31 public:
33  sequence const& seq,
34  quality const& qual
35  )
36  : seq_(seq), qual_(qual)
37  {}
38 
39  void set_interval(sequence_interval const& si) {si_ = si;}
40 
41  template<class ME> sequence_interval operator()(ME& me) const {
42  return me(seq_, qual_, si_);
43  }
44 
45 private:
46  sequence const& seq_;
47  quality const& qual_;
49 };
50 
56 public:
57  struct Err : public base_exception{};
58 
60  variant_vector const& vv,
61  truncate_vector const& tv,
62  detail::string_vector const& names,
63  detail::string_vector const& dep_names,
64  std::vector<bool> const& is_required,
65  combination_vector const& cv
66  );
67 
68  std::size_t size() const {return mev_.size();}
69 
77  sequence const& seq,
78  quality const& qual,
79  sequence_interval const& si
80  ) {
81  //sequence intervals: input followed by ones generated by match elements
82  interval_vector siv(size() + 1, sequence_interval_invalid());
83  siv[0] = si;
84  Match_element_visitor vis(seq, qual);
85  sequence_interval trunc = sequence_interval::whole();
86  for(std::size_t n = 0; n != mev_.size(); ++n) {
87  //sequence interval to which current match element is defined relative to
89  sequence_interval const& dep = siv[me_deps_[n]];
90  if( is_valid(dep) ) {
91  //current match element will use the interval it depends on
92  vis.set_interval(dep);
93  result = boost::apply_visitor(vis, mev_[n]);
94  siv[n + 1] = result;
95  const sequence_interval trunc1 = tv_[n](result);
96  trunc = intersect(trunc, trunc1);
97  }
98  if( required_[n] && ! is_valid(result) ) {
99  trunc = sequence_interval::empty();
100  ++n_removed_;
101  }
102  }
103 
104  for(std::size_t n = 0; n != cv_.size(); ++n) {
105  cv_[n](seq, siv);
106  }
107  return trunc;
108  }
109 
110  void finish();
111  std::size_t n_removed() const {return n_removed_;}
112 
113 private:
116 
117  //for each match element indicate which other match element,
118  //if any, it refers to
119  std::vector<std::size_t> me_deps_;
120  std::vector<bool> required_;
122  std::size_t n_removed_;
123 };
124 
125 }//namespace match
126 }//namespace vdj_pipe
127 #endif /* ME_BATTERY_HPP_ */
sequence const & seq_
Definition: me_battery.hpp:46
Definition: me_battery.hpp:28
std::size_t n_removed() const
Definition: me_battery.hpp:111
Match_element_visitor(sequence const &seq, quality const &qual)
Definition: me_battery.hpp:32
variant_vector mev_
Definition: me_battery.hpp:114
Qual_record::quality quality
Definition: me_battery.hpp:30
Definition: sequence_record.hpp:35
std::vector< std::size_t > me_deps_
Definition: me_battery.hpp:119
sequence_interval operator()(sequence const &seq, quality const &qual, sequence_interval const &si)
Definition: me_battery.hpp:76
truncate_vector tv_
Definition: me_battery.hpp:115
Qual_record::quality quality
Definition: me_battery.hpp:55
std::vector< std::string > string_vector
Definition: sequence_map_types.hpp:16
Main namespace of vdj_pipe library.
Definition: keywords_variable.hpp:11
quality const & qual_
Definition: me_battery.hpp:47
std::size_t n_removed_
Definition: me_battery.hpp:122
Qual_record::quality qual
Definition: match_element_run.cpp:26
std::size_t size() const
Definition: me_battery.hpp:68
Definition: me_battery.hpp:53
sequence_interval si_
Definition: me_battery.hpp:48
sequence_interval operator()(ME &me) const
Definition: me_battery.hpp:41
std::vector< sequence_interval > interval_vector
Definition: me_types.hpp:34
sequence_interval sequence_interval_invalid()
Definition: sequence_interval.hpp:44
std::vector< me_variant > variant_vector
Definition: me_types.hpp:31
Seq_record::sequence sequence
Definition: me_battery.hpp:54
Definition: me_battery.hpp:57
std::vector< Truncate > truncate_vector
Definition: me_types.hpp:32
const std::size_t n
Definition: vector_set_test.cpp:26
std::string sequence
Definition: sequence_record.hpp:29
combination_vector cv_
Definition: me_battery.hpp:121
std::vector< bool > required_
Definition: me_battery.hpp:120
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
void set_interval(sequence_interval const &si)
Definition: me_battery.hpp:39
std::vector< Match_combination > combination_vector
Definition: me_types.hpp:33
Seq_record::sequence sequence
Definition: me_battery.hpp:29