Gamgee
You miserable little maggot. I'll stove your head in!
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
cigar.h
Go to the documentation of this file.
1 #ifndef __gamgee__cigar__
2 #define __gamgee__cigar__
3 
4 #include "htslib/sam.h"
5 
6 #include <memory>
7 #include <string>
8 
9 namespace gamgee {
10 
15 enum class CigarOperator { M, I, D, N, S, H, P, EQ, X, B };
16 
20 class Cigar {
21  public:
22  explicit Cigar(const std::shared_ptr<bam1_t>& sam_record);
23  Cigar(const Cigar& other);
24  Cigar(Cigar&& other) noexcept;
25  Cigar& operator=(const Cigar& other);
26  Cigar& operator=(Cigar&& other) noexcept;
27  ~Cigar() = default;
28 
29  uint32_t operator[](const uint32_t index) const;
30  uint32_t size() const { return m_num_cigar_elements; }
31  std::string to_string() const;
32 
36  inline static CigarOperator cigar_op(const uint32_t cigar_element) {
37  return static_cast<CigarOperator>(bam_cigar_op(cigar_element));
38  }
39 
43  inline static uint32_t cigar_oplen(const uint32_t cigar_element) {
44  return bam_cigar_oplen(cigar_element);
45  }
46 
47  private:
48  std::shared_ptr<bam1_t> m_sam_record;
49  uint32_t* m_cigar;
50  uint32_t m_num_cigar_elements;
51 
52  static const char cigar_ops_as_chars[];
53 };
54 
55 }
56 
57 #endif /* __gamgee__cigar__ */
static CigarOperator cigar_op(const uint32_t cigar_element)
gets the operator of an individual cigar element
Definition: cigar.h:36
std::string to_string() const
returns a string representation of this cigar
Definition: cigar.cpp:93
uint32_t size() const
number of base qualities in the container
Definition: cigar.h:30
CigarOperator
comprehensive list of valid cigar operators
Definition: cigar.h:15
Cigar(const std::shared_ptr< bam1_t > &sam_record)
creates a Cigar object that points to htslib memory already allocated
Definition: cigar.cpp:23
uint32_t operator[](const uint32_t index) const
use freely as you would an array.
Definition: cigar.cpp:84
Cigar & operator=(const Cigar &other)
creates a deep copy of a Cigar object
Definition: cigar.cpp:56
~Cigar()=default
default destruction is sufficient, since our shared_ptr will handle deallocation
static uint32_t cigar_oplen(const uint32_t cigar_element)
gets the length of an individual cigar element
Definition: cigar.h:43
Utility class to manage the memory of the cigar structure.
Definition: cigar.h:20