vdj_pipe
pipeline for processing DNA sequence data
apply_to_adaptor.hpp
Go to the documentation of this file.
1 
7 #ifndef APPLY_TO_ADAPTOR_HPP_
8 #define APPLY_TO_ADAPTOR_HPP_
9 #include <vector>
10 #include "boost/foreach.hpp"
11 #include "boost/property_tree/ptree_fwd.hpp"
12 #include "boost/variant/static_visitor.hpp"
13 #include "vdj_pipe/config.hpp"
15 #include "vdj_pipe/exception.hpp"
21 
22 namespace vdj_pipe{
23 class Pipe_environment;
24 
28 class Apply_one {
29 public:
31  VDJ_PIPE_STATIC_STRING_METHOD(name, "apply")
32  VDJ_PIPE_STATIC_STRING_METHOD(category, "paired read")
34  comment,
35  "apply specified step to either forward, reverse, or merged sequences"
36  )
37  VDJ_PIPE_STATIC_STRING_METHOD(description, "XXX")
38 
39  Apply_one(step_variant_single const& step) : step_(step) {}
40  void run() {boost::apply_visitor(Run_visitor(), step_);}
41  void finish() {boost::apply_visitor(Finish_visitor(), step_);}
42 
43  void summary(std::ostream& os) const {
44  Summary_visitor2 sv2(os);
45  boost::apply_visitor(sv2, step_);
46  }
47 
48 private:
50 };
51 
55 class Apply_many {
56  typedef std::vector<Value_ids_single> vid_vector;
57 
58  class Visitor : public boost::static_visitor<> {
59  public:
60  Visitor(vid_vector const& idv) : idv_(idv) {}
61 
62  template<typename Step> void operator()(Step& step) const {
63  BOOST_FOREACH(Value_ids_single const& vis, idv_) {
64  step.reset_access(vis);
65  step.run();
66  }
67  }
68 
69  private:
70  vid_vector idv_;
71  };
72 
73  public:
74 
75  VDJ_PIPE_STATIC_STRING_METHOD(name, "apply")
76  VDJ_PIPE_STATIC_STRING_METHOD(category, "paired read")
78  comment,
79  "apply specified step to either forward, reverse, or merged sequences"
80  )
81  VDJ_PIPE_STATIC_STRING_METHOD(description, "XXX")
82 
83  struct Err : public base_exception {};
84 
85  Apply_many(vid_vector const& idv, step_variant_single const& step)
86  : av_(idv), step_(step) {}
87 
88  void run() {boost::apply_visitor(Run_visitor(), step_);}
89  void finish() {boost::apply_visitor(Finish_visitor(), step_);}
90 
91  void summary(std::ostream& os) const {
92  Summary_visitor2 sv2(os);
93  apply_visitor(sv2, step_);
94  }
95 
96 private:
99 };
100 
101 namespace step{
102 
106 public:
107  struct Err : public base_exception {};
108  VDJ_PIPE_STATIC_STRING_METHOD(name, "apply")
109  VDJ_PIPE_STATIC_STRING_METHOD(category, "paired read")
111  comment,
112  "apply specified step to forward, reverse, or merged sequences"
113  )
114 
115  typedef boost::variant<Apply_one, Apply_many> result_type;
116  typedef Vm_access_paired vma_type;
117 
118  static result_type make(
119  vma_type const& vma,
120  boost::property_tree::ptree const& pt,
121  Pipe_environment& pe
122  );
123 
124 private:
125  static Value_ids_single make_ids(
126  vma_type const& vma,
127  std::string const& type
128  );
129 };
130 
133 template<> struct Find_maker<Apply_one > {typedef Apply_to_maker type;};
134 template<> struct Find_maker<Apply_many> {typedef Apply_to_maker type;};
135 
136 }//namespace step
137 }//namespace vdj_pipe
138 #endif /* APPLY_TO_ADAPTOR_HPP_ */
void summary(std::ostream &os) const
Definition: apply_to_adaptor.hpp:91
Visitor(vid_vector const &idv)
Definition: apply_to_adaptor.hpp:60
Definition: sanitize_string.cpp:15
void run()
Definition: apply_to_adaptor.hpp:88
Apply_to_maker type
Definition: apply_to_adaptor.hpp:134
step_variant_single step_
Definition: apply_to_adaptor.hpp:49
Apply_to_maker type
Definition: apply_to_adaptor.hpp:133
STL namespace.
Vm_access_paired vma_type
Definition: apply_to_adaptor.hpp:30
Apply enclosed processing step once to a sequence read of specified kind: forward, reverse, or merged.
Definition: apply_to_adaptor.hpp:28
Access to value map for paired read pipeline and processing steps.
Definition: value_map_access_paired.hpp:16
std::vector< Value_ids_single > vid_vector
Definition: apply_to_adaptor.hpp:56
void operator()(Step &step) const
Definition: apply_to_adaptor.hpp:62
vid_vector idv_
Definition: apply_to_adaptor.hpp:70
Main namespace of vdj_pipe library.
Definition: keywords_variable.hpp:11
Definition: visitor.hpp:71
Definition: pipe_environment.hpp:26
#define VDJ_PIPE_DECL
Definition: config.hpp:23
step_variant_single step_
Definition: apply_to_adaptor.hpp:98
Definition: visitor.hpp:18
Provides access to standard values for single read pipeline.
Definition: value_names.hpp:33
Definition: apply_to_adaptor.hpp:58
Definition: exception.hpp:23
void finish()
Definition: apply_to_adaptor.hpp:89
VDJ_PIPE_STATIC_STRING_METHOD(comment,"apply specified step to either forward, reverse, or merged sequences") Apply_one(step_variant_single const &step)
Definition: apply_to_adaptor.hpp:33
Definition: apply_to_adaptor.hpp:107
boost::make_recursive_variant_over< step::single_read_vector >::type step_variant_single
Definition: step_variant_single_read.hpp:66
Apply enclosed processing step multiple times to sequence reads of specified kind: forward...
Definition: apply_to_adaptor.hpp:55
Visitor av_
Definition: apply_to_adaptor.hpp:97
Definition: step_maker.hpp:40
void summary(std::ostream &os) const
Definition: apply_to_adaptor.hpp:43
Definition: apply_to_adaptor.hpp:105
bpt::ptree ptree
Definition: processing_step_utils.hpp:19
Definition: visitor.hpp:35
void finish()
Definition: apply_to_adaptor.hpp:41
void run()
Definition: apply_to_adaptor.hpp:40