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 
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:
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 
94 
95 }//namespace vdj_pipe
96 #endif /* SEQUENCE_FILE_ENTRY_HPP_ */
std::string const & mid_rev() const
Definition: sequence_file_entry.hpp:65
map_t map_
Definition: sequence_file_entry.hpp:77
const_iterator begin() const
Definition: sequence_file_entry.hpp:38
map_t::value_type value_type
Definition: sequence_file_entry.hpp:32
map_t::const_iterator iterator
Definition: sequence_file_entry.hpp:30
qual_type qt_
Definition: sequence_file_entry.hpp:70
qual_type
Definition: sequence_file_entry.hpp:27
std::string const & quality() const
Definition: sequence_file_entry.hpp:49
bool is_paired() const
Definition: sequence_file_entry.hpp:40
bool has_qual_file() const
Definition: sequence_file_entry.hpp:43
std::map< Val_id, value_variant > map_t
Definition: sequence_file_entry.hpp:29
std::string const & sequence() const
Definition: sequence_file_entry.hpp:45
Val_id qual_
Definition: sequence_file_entry.hpp:72
Main namespace of vdj_pipe library.
Definition: keywords_variable.hpp:11
Qual_record::quality qual
Definition: match_element_run.cpp:26
Val_id seq_rev_
Definition: sequence_file_entry.hpp:73
std::string const & mid() const
Definition: sequence_file_entry.hpp:61
std::string const & get_str(const Val_id id, std::string const &msg) const
Definition: sequence_file_entry.hpp:81
#define VDJ_PIPE_DECL
Definition: config.hpp:23
Val_id qual_rev_
Definition: sequence_file_entry.hpp:74
Val_id seq_
Definition: sequence_file_entry.hpp:71
Definition: sequence_file_entry.hpp:26
std::string const & seq_rev() const
Definition: sequence_file_entry.hpp:53
Val_id mid_rev_
Definition: sequence_file_entry.hpp:76
Definition: input_manager.hpp:22
const_iterator end() const
Definition: sequence_file_entry.hpp:39
void store_values(Seq_file_entry const &sfe, Value_map &vm)
Definition: sequence_file_entry.cpp:119
Definition: exception.hpp:23
boost::error_info< struct errinfo_message_, std::string > msg_t
Definition: exception.hpp:24
Definition: sequence_file_entry.hpp:34
bool has_emid() const
Definition: sequence_file_entry.hpp:41
bool has_quality() const
Definition: sequence_file_entry.hpp:42
Store values mapped against name strings and value IDs.
Definition: value_map.hpp:23
Definition: file_properties.hpp:20
map_t::const_iterator const_iterator
Definition: sequence_file_entry.hpp:31
Val_id mid_
Definition: sequence_file_entry.hpp:75
std::string const & qual_rev() const
Definition: sequence_file_entry.hpp:57