Gamgee
You miserable little maggot. I'll stove your head in!
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
read_bases.h
Go to the documentation of this file.
1 #ifndef gamgee__read_bases__guard
2 #define gamgee__read_bases__guard
3 
4 #include "htslib/sam.h"
5 
6 #include <memory>
7 #include <map>
8 
9 namespace gamgee {
10 
16 enum class Base { A = 1, C = 2, G = 4, T = 8, N = 15 };
17 
26 class ReadBases {
27 public:
28  explicit ReadBases(const std::shared_ptr<bam1_t>& sam_record);
29  ReadBases(const ReadBases& other);
30  ReadBases(ReadBases&& other) = default;
31  ReadBases& operator=(const ReadBases& other);
32  ReadBases& operator=(ReadBases&& other) = default;
33  ~ReadBases() = default;
34 
35  Base operator[](const uint32_t index) const;
36  void set_base(const uint32_t index, const Base base);
37  uint32_t size() const { return m_num_bases; };
38  bool operator==(const ReadBases& other) const;
39  bool operator!=(const ReadBases& other) const;
40  std::string to_string() const;
41 
42 private:
43  std::shared_ptr<bam1_t> m_sam_record;
44  uint8_t* m_bases;
45  uint32_t m_num_bases;
46 
47  static const std::map<Base, const char*> base_to_string_map;
48 
49  friend class SamBuilder;
50 };
51 
52 }
53 
54 #endif /* gamgee__read_bases__guard */
Base
simple enum to hold all valid bases in the SAM format
Definition: read_bases.h:16
std::string to_string() const
produce a string representation of the bases in this object
Definition: read_bases.cpp:99
Base operator[](const uint32_t index) const
use freely as you would an array.
Definition: read_bases.cpp:57
~ReadBases()=default
default destruction is sufficient, since our shared_ptr will handle deallocation
class to build Sam objects from existing data or from scratch
Definition: sam_builder.h:58
ReadBases(const std::shared_ptr< bam1_t > &sam_record)
creates a ReadBases object that points to htslib memory already allocated
Definition: read_bases.cpp:21
void set_base(const uint32_t index, const Base base)
modify a base at a specific index
Definition: read_bases.cpp:68
uint32_t size() const
Definition: read_bases.h:37
Definition: exceptions.h:9
bool operator==(const ReadBases &other) const
number of base qualities in the container
Definition: read_bases.cpp:77
ReadBases & operator=(const ReadBases &other)
creates a deep copy of a ReadBases object
Definition: read_bases.cpp:43
Utility class to handle the memory management of the sam record object for read bases.
Definition: read_bases.h:26
bool operator!=(const ReadBases &other) const
check for inequality with another ReadBases object
Definition: read_bases.cpp:92