vdj_pipe
pipeline for processing DNA sequence data
read_info.hpp
Go to the documentation of this file.
1 
7 #ifndef READ_INFO_HPP_
8 #define READ_INFO_HPP_
9 #include <string>
10 #include "boost/assert.hpp"
11 #include "vdj_pipe/object_ids.hpp"
14 
15 namespace vdj_pipe{
18 class Read_info {
19 public:
20  explicit Read_info(const boost::string_ref name)
21  : name_(name.to_string()),
22  reverse_(false),
23  seq_file_(Path_id()),
24  trim_(sequence_interval::whole())
25  {}
26 
27  Read_info(
28  const boost::string_ref name,
29  const Path_id seq_file,
30  const unsigned len,
31  const bool reverse
32  )
33  : name_(name.to_string()),
34  reverse_(reverse),
35  seq_file_(seq_file),
36  trim_(0, (int)len)
37  {}
38 
39  const std::string& name() const {return name_;}
40  unsigned size() const {return width(trim_);}
41  bool empty() const {return boost::numeric::empty(trim_);}
42  Path_id seq_file() const {return seq_file_;}
43  bool is_reverse() const {return reverse_;}
44  sequence_interval const& trim() const {return trim_;}
45 
46  Read_info& reverse(const bool rev) {
47  reverse_ = rev;
48  return *this;
49  }
50 
51  Read_info& seq_file(const Path_id pid) {
52  BOOST_ASSERT((! seq_file_) || (seq_file_ == pid));
53  seq_file_ = pid;
54  return *this;
55  }
56 
57  Read_info& trim(const unsigned lo, const unsigned hi) {
58  return trim(sequence_interval(lo,hi));
59  }
60 
61  Read_info& trim(sequence_interval const& si) {
62  trim_ = intersect(trim_, si);
63  return *this;
64  }
65 
66  void combine(Read_info const& si) {
67  BOOST_ASSERT( name_ == si.name_ );
68  reverse_ |= si.is_reverse();
69  if( si.seq_file() ) seq_file(si.seq_file());
70  trim_ = intersect(trim_, si.trim());
71  }
72 
73 private:
74  std::string name_;
75  bool reverse_;
76  Path_id seq_file_;
77  sequence_interval trim_;
78 };
79 
80 template<class Ostr> inline Ostr& operator<<(Ostr& ostr, const Read_info si) {
81  ostr << si.name() << '[' << si.size() << ']';
82  return ostr;
83 }
84 
85 }//namespace vdj_pipe
86 #endif /* READ_INFO_HPP_ */
Main namespace of vdj_pipe library.
Definition: sequence_file.hpp:14
Definition: read_info.hpp:18