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:
30  typedef Vm_access_paired vma_type;
31  VDJ_PIPE_STATIC_STRING_METHOD(name, "apply")
32  VDJ_PIPE_STATIC_STRING_METHOD(category, "paired read")
33  VDJ_PIPE_STATIC_STRING_METHOD(
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:
49  step_variant_single step_;
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")
77  VDJ_PIPE_STATIC_STRING_METHOD(
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:
97  Visitor av_;
98  step_variant_single step_;
99 };
100 
101 namespace step{
102 
105 class VDJ_PIPE_DECL Apply_to_maker {
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")
110  VDJ_PIPE_STATIC_STRING_METHOD(
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_ */
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
Main namespace of vdj_pipe library.
Definition: sequence_file.hpp:14
Definition: visitor.hpp:71
Definition: pipe_environment.hpp:26
Definition: visitor.hpp:18
Provides access to standard values for single read pipeline.
Definition: value_names.hpp:33
Definition: exception.hpp:23
Definition: apply_to_adaptor.hpp:107
Apply enclosed processing step multiple times to sequence reads of specified kind: forward...
Definition: apply_to_adaptor.hpp:55
Definition: step_maker.hpp:40
Definition: apply_to_adaptor.hpp:105
Definition: visitor.hpp:35