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:
18  typedef Seq_record::sequence seq_type;
20 
21  struct Err : public base_exception {};
22 
23  Vm_access_single(Value_names::single_read_names const& names)
24  : Value_map(), ids_(Value_ids_single::create(*this, names))
25  {}
26 
28  Value_map const& vm,
29  Value_names::single_read_names const& names
30  )
31  : Value_map(vm), ids_(Value_ids_single::ensure(*this, names))
32  {}
33 
34  Vm_access_single(Value_map const& vm, Value_ids_single const& ids)
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:
116  Value_ids_single ids_;
117 };
118 
119 }//namespace vdj_pipe
120 #endif /* VALUE_MAP_ACCESS_SINGLE_HPP_ */
void interval(sequence_interval const &si)
Definition: value_map_access_single.hpp:50
Definition: sequence_record.hpp:35
Definition: value_map_access_single.hpp:16
sequence_interval interval() const
Definition: value_map_access_single.hpp:47
Main namespace of vdj_pipe library.
Definition: sequence_file.hpp:14
static Value_ids_single create(Value_map &vm, Value_names::single_read_names const &names)
Provides access to standard values for single read pipeline.
Definition: value_names.hpp:33
Definition: exception.hpp:23
std::string sequence(const bool trimmed, const bool reverse_compl) const
Definition: value_map_access_single.hpp:79
static Value_ids_single ensure(Value_map const &vm, Value_names::single_read_names const &names)
Definition: value_map_access_single.hpp:21
Store values mapped against name strings and value IDs.
Definition: value_map.hpp:23
bool is_reverse() const
Definition: value_map_access_single.hpp:58