vdj_pipe
pipeline for processing DNA sequence data
sequence_file_entry.hpp
Go to the documentation of this file.
1 
7 #ifndef SEQUENCE_FILE_ENTRY_HPP_
8 #define SEQUENCE_FILE_ENTRY_HPP_
9 #include <string>
10 #include <map>
11 #include "boost/property_tree/ptree_fwd.hpp"
12 #include "vdj_pipe/config.hpp"
13 #include "vdj_pipe/exception.hpp"
15 
16 namespace vdj_pipe{
17 class Input_manager;
18 class Value_map;
19 
26 class VDJ_PIPE_DECL Seq_file_entry {
27  enum qual_type {none, qual, fastq};
28 public:
29  typedef std::map<Val_id, value_variant> map_t;
30  typedef map_t::const_iterator iterator;
31  typedef map_t::const_iterator const_iterator;
32  typedef map_t::value_type value_type;
33 
34  struct Err : public base_exception {};
35 
36  Seq_file_entry(map_t const& m, Input_manager const& im, Value_map const& vm);
37 
38  const_iterator begin() const {return map_.begin();}
39  const_iterator end() const {return map_.end();}
40  bool is_paired() const {return seq_rev_;}
41  bool has_emid() const {return mid_;}
42  bool has_quality() const {return qt_ != none;}
43  bool has_qual_file() const {return qt_ == qual;}
44 
45  std::string const& sequence() const {
46  return get_str(seq_, "sequence");
47  }
48 
49  std::string const& quality() const {
50  return get_str(qual_, "quality");
51  }
52 
53  std::string const& seq_rev() const {
54  return get_str(seq_rev_, "reverse sequence");
55  }
56 
57  std::string const& qual_rev() const {
58  return get_str(qual_rev_, "reverse quality");
59  }
60 
61  std::string const& mid() const {
62  return get_str(mid_, "MID");
63  }
64 
65  std::string const& mid_rev() const {
66  return get_str(mid_rev_, "reverse MID");
67  }
68 
69 private:
70  qual_type qt_;
71  Val_id seq_;
72  Val_id qual_;
73  Val_id seq_rev_;
74  Val_id qual_rev_;
75  Val_id mid_;
76  Val_id mid_rev_;
77  map_t map_;
78 
79  void check(Input_manager const& im);
80 
81  std::string const& get_str(const Val_id id, std::string const& msg) const {
82  const const_iterator i = map_.find(id);
83  if( i == map_.end() ) BOOST_THROW_EXCEPTION(
84  Err()
85  << Err::msg_t(msg + " not found")
86  );
87  return boost::get<std::string>(i->second);
88  }
89 };
90 
93 VDJ_PIPE_DECL void store_values(Seq_file_entry const& sfe, Value_map& vm);
94 
95 }//namespace vdj_pipe
96 #endif /* SEQUENCE_FILE_ENTRY_HPP_ */
Main namespace of vdj_pipe library.
Definition: sequence_file.hpp:14
Definition: sequence_file_entry.hpp:26
Definition: input_manager.hpp:22
Definition: exception.hpp:23
Definition: sequence_file_entry.hpp:34
Store values mapped against name strings and value IDs.
Definition: value_map.hpp:23