vdj_pipe
pipeline for processing DNA sequence data
pipe_environment.hpp
Go to the documentation of this file.
1 
7 #ifndef PIPE_ENVIRONMENT_HPP_
8 #define PIPE_ENVIRONMENT_HPP_
9 #include <iosfwd>
10 #include "boost/property_tree/ptree_fwd.hpp"
11 #include "boost/shared_ptr.hpp"
12 #include "boost/chrono/process_cpu_clocks.hpp"
13 #include "vdj_pipe/config.hpp"
15 #include "vdj_pipe/exception.hpp"
18 #include "vdj_pipe/value_map.hpp"
19 
20 namespace vdj_pipe{
21 class Seq_file_map;
22 class Step_variant_store;
23 
26 class VDJ_PIPE_DECL Pipe_environment {
27  typedef boost::shared_ptr<Input_manager> in_manager_ptr;
28  typedef boost::shared_ptr<Output_manager> out_manager_ptr;
29  BOOST_STATIC_CONSTANT(std::size_t, unset = static_cast<std::size_t>(-1));
30  static void input_csv(
31  boost::property_tree::ptree const& pt,
32  std::vector<std::string>& vs
33  );
34 
35 public:
36  struct Err : public base_exception {};
37 
39  boost::property_tree::ptree const& pt,
40  Value_map const& vm
41  );
42  Step_variant_store const& steps() const {return *steps_;}
43  Step_variant_store& steps() {return *steps_;}
44  Input_manager const& input() const {return *im_;}
45  Input_manager& input() {return *im_;}
46  Output_manager const& output() const {return *om_;}
47  Output_manager& output() {return *om_;}
48  char delimiter() const {return om_->delimiter();}
49  std::size_t max_reads() const {return max_reads_;}
50  std::size_t max_file_reads() const {return max_file_reads_;}
51 
52  bool process_more() {
53  if(
54  max_reads() <= (std::size_t)vm_.read_count() ||
55  max_file_reads() <= (std::size_t)vm_.file_read_count()
56  ) {
57  reads_skipped_ = true;
58  return false;
59  }
60  return true;
61  }
62 
63  std::size_t read_count() const;
64  void finish();
65  void process_read();
66  void summary();
67 
68  void write_config(
69  boost::property_tree::ptree const& pt,
70  std::string const& path
71  ) const;
72 
73  void start_file(std::string const& fn);
74  void finish_file();
75 
76 private:
77  boost::shared_ptr<Step_variant_store> steps_;
78  in_manager_ptr im_;
79  out_manager_ptr om_;
80  std::size_t max_reads_;
81  std::size_t max_file_reads_;
82  std::string summary_output_path_;
83  boost::chrono::process_real_cpu_clock::time_point t1_, t2_, t3_;
84  bool is_running_;
85  bool reads_skipped_;
86  Value_map vm_;
87 
88 private:
89  std::ostream& print_summary(std::ostream& os) const;
90 
91 };
92 
93 }//namespace vdj_pipe
94 #endif /* PIPE_ENVIRONMENT_HPP_ */
Definition: pipe_environment.hpp:36
Main namespace of vdj_pipe library.
Definition: sequence_file.hpp:14
Definition: pipe_environment.hpp:26
Definition: input_manager.hpp:22
Definition: step_variant_store.hpp:40
Definition: exception.hpp:23
Definition: output_manager.hpp:20
Store values mapped against name strings and value IDs.
Definition: value_map.hpp:23