vdj_pipe
pipeline for processing DNA sequence data
value_map_access_single.hpp
Go to the documentation of this file.
1 
7 #ifndef VALUE_MAP_ACCESS_SINGLE_HPP_
8 #define VALUE_MAP_ACCESS_SINGLE_HPP_
9 #include "vdj_pipe/value_map.hpp"
10 #include "vdj_pipe/value_names.hpp"
11 
12 namespace vdj_pipe{
13 
16 class Vm_access_single : public Value_map {
17 public:
20 
21  struct Err : public base_exception {};
22 
24  : Value_map(), ids_(Value_ids_single::create(*this, names))
25  {}
26 
28  Value_map const& vm,
30  )
31  : Value_map(vm), ids_(Value_ids_single::ensure(*this, names))
32  {}
33 
35  : Value_map(vm), ids_(ids)
36  {}
37 
38  void reset(Value_ids_single const& ids) {ids_ = ids;}
39  std::string const& description() const {return value<std::string>(ids_.description());}
40  void description(std::string const& descr) {(*this)[ids_.description()] = descr;}
41  seq_type const& sequence() const {return value<std::string>(ids_.sequence());}
42  void sequence(seq_type const& seq) {(*this)[ids_.sequence()] = seq;}
43  qual_type const& quality() const {return value<qual_type>(ids_.quality());}
44  void quality(qual_type const& qual) {(*this)[ids_.quality()] = qual;}
45 
47  sequence_interval interval() const {return value<sequence_interval>(ids_.trim());}
48 
50  void interval(sequence_interval const& si) {(*this)[ids_.trim()] = si;}
51  void set_empty() {(*this)[ids_.trim()] = sequence_interval::empty();}
52 
53  void trim(sequence_interval const& si) {
54  (*this)[ids_.trim()] = intersect(interval(), si);
55  }
56 
58  bool is_reverse() const {
59  try{
60  if( ids_.direction() ) return boost::get<bool>((*this)[ids_.direction()]);
61  }catch(std::exception const&) {
62  BOOST_THROW_EXCEPTION(
63  Err()
64  << Err::msg_t("wrong type for current sequence direction")
65  << Err::nested_t(boost::current_exception())
66  );
67  }
68  return ids_.is_reverse();
69  }
70 
71  void set_reverse(const bool rev) {(*this)[ids_.direction()] = rev;}
72 
79  std::string sequence(
80  const bool trimmed,
81  const bool reverse_compl
82  ) const {
83  return Value_map::sequence(
84  ids_.sequence(),
85  ids_.trim(),
86  trimmed,
87  reverse_compl && is_reverse()
88  );
89  }
90 
91  qual_type quality(
92  const bool trimmed,
93  const bool reverse_compl
94  ) const {
95  return Value_map::quality(
96  ids_.quality(),
97  ids_.trim(),
98  trimmed,
99  reverse_compl && is_reverse()
100  );
101  }
102 
103  std::string const& sequence_path() const {
104  return value<std::string>(ids_.sequence_path());
105  }
106 
107  void sequence_path(std::string const& s) {(*this)[ids_.sequence_path()] = s;}
108 
109  std::string const& quality_path() const {
110  return value<std::string>(ids_.quality_path());
111  }
112 
113  void quality_path(std::string const& s) {(*this)[ids_.quality_path()] = s;}
114 
115 private:
117 };
118 
119 }//namespace vdj_pipe
120 #endif /* VALUE_MAP_ACCESS_SINGLE_HPP_ */
Value_ids_single ids_
Definition: value_map_access_single.hpp:116
qual_type quality(const bool trimmed, const bool reverse_compl) const
Definition: value_map_access_single.hpp:91
Val_id sequence() const
Definition: value_names.hpp:55
void sequence(seq_type const &seq)
Definition: value_map_access_single.hpp:42
void interval(sequence_interval const &si)
Definition: value_map_access_single.hpp:50
Definition: sequence_record.hpp:35
qual_type const & quality() const
Definition: value_map_access_single.hpp:43
std::string const & quality_path() const
Definition: value_map_access_single.hpp:109
Definition: value_map_access_single.hpp:16
void description(std::string const &descr)
Definition: value_map_access_single.hpp:40
void trim(sequence_interval const &si)
Definition: value_map_access_single.hpp:53
sequence_interval interval() const
Definition: value_map_access_single.hpp:47
Val_id trim() const
Definition: value_names.hpp:57
Qual_record::quality qual_type
Definition: value_map_access_single.hpp:19
Val_id sequence_path() const
Definition: value_names.hpp:59
Val_id quality() const
Definition: value_names.hpp:56
Val_id description() const
Definition: value_names.hpp:54
bool is_reverse() const
Definition: value_names.hpp:61
Main namespace of vdj_pipe library.
Definition: keywords_variable.hpp:11
boost::errinfo_nested_exception nested_t
Definition: exception.hpp:32
Qual_record::quality qual
Definition: match_element_run.cpp:26
Val_id quality_path() const
Definition: value_names.hpp:60
void set_empty()
Definition: value_map_access_single.hpp:51
void quality_path(std::string const &s)
Definition: value_map_access_single.hpp:113
Qual_record::quality quality(const Val_id qual_id, const Val_id trim_id, const bool trimmed, const bool reverse_compl) const
Definition: value_map.hpp:207
void quality(qual_type const &qual)
Definition: value_map_access_single.hpp:44
void reset(Value_ids_single const &ids)
Definition: value_map_access_single.hpp:38
std::string const & sequence_path() const
Definition: value_map_access_single.hpp:103
Provides access to standard values for single read pipeline.
Definition: value_names.hpp:33
Vm_access_single(Value_map const &vm, Value_ids_single const &ids)
Definition: value_map_access_single.hpp:34
std::string const & description() const
Definition: value_map_access_single.hpp:39
void sequence_path(std::string const &s)
Definition: value_map_access_single.hpp:107
std::string sequence
Definition: sequence_record.hpp:29
boost::numeric::interval< int, boost::numeric::interval_lib::policies< boost::numeric::interval_lib::rounded_math< int >, detail::Interval_checking_policy< int > > > sequence_interval
Definition: sequence_interval.hpp:40
Definition: exception.hpp:23
std::string sequence(const bool trimmed, const bool reverse_compl) const
Definition: value_map_access_single.hpp:79
boost::error_info< struct errinfo_message_, std::string > msg_t
Definition: exception.hpp:24
Vm_access_single(Value_map const &vm, Value_names::single_read_names const &names)
Definition: value_map_access_single.hpp:27
Definition: value_map_access_single.hpp:21
Seq_record::sequence seq_type
Definition: value_map_access_single.hpp:18
Store values mapped against name strings and value IDs.
Definition: value_map.hpp:23
boost::array< std::string, 8 > single_read_names
Definition: value_names.hpp:21
seq_type const & sequence() const
Definition: value_map_access_single.hpp:41
Val_id direction() const
Definition: value_names.hpp:58
Vm_access_single(Value_names::single_read_names const &names)
Definition: value_map_access_single.hpp:23
void set_reverse(const bool rev)
Definition: value_map_access_single.hpp:71
bool is_reverse() const
Definition: value_map_access_single.hpp:58
std::string sequence(const Val_id seq_id, const Val_id trim_id, const bool trimmed, const bool reverse_compl) const
Definition: value_map.hpp:191