Gamgee
You miserable little maggot. I'll stove your head in!
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
variant_filters.h
Go to the documentation of this file.
1 #ifndef gamgee__variant_filters__guard
2 #define gamgee__variant_filters__guard
3 
5 
6 #include "../utils/hts_memory.h"
7 
8 #include "htslib/vcf.h"
9 
10 #include <string>
11 #include <memory>
12 
13 namespace gamgee {
14 
24  public:
30  explicit VariantFilters(const std::shared_ptr<bcf_hdr_t>& header, const std::shared_ptr<bcf1_t>& body) : m_header {header}, m_body {body} {}
31 
36  std::string operator[](int index) const { return utils::htslib_filter_name(m_header.get(), m_body.get(), index); }
37 
41  uint32_t size() const { return uint32_t(m_body->d.n_flt); }
42 
46  bool missing() const { return size() == 0; }
47 
51  VariantFiltersIterator begin() const {return VariantFiltersIterator{m_header, m_body, 0}; }
52 
56  VariantFiltersIterator end() const {return VariantFiltersIterator{m_header, m_body, uint32_t(m_body->d.n_flt)};}
57 
58  private:
59  std::shared_ptr<bcf_hdr_t> m_header;
60  std::shared_ptr<bcf1_t> m_body;
61 
62 };
63 
64 
65 }
66 
67 #endif // gamgee__variant_filters__guard
uint32_t size() const
returns the number of filters in the filter field
Definition: variant_filters.h:41
simple random-access iterator class for VariantFilters objects
Definition: variant_filters_iterator.h:18
VariantFilters(const std::shared_ptr< bcf_hdr_t > &header, const std::shared_ptr< bcf1_t > &body)
standard constructor used by the Variant API
Definition: variant_filters.h:30
std::string operator[](int index) const
random access operator
Definition: variant_filters.h:36
VariantFiltersIterator begin() const
returns an iterator pointing to the first element in the list of filters.
Definition: variant_filters.h:51
Definition: exceptions.h:9
class to manipulate filter field objects without making copies.
Definition: variant_filters.h:23
std::string htslib_filter_name(bcf_hdr_t *header, bcf1_t *body, int index)
helper function to translate an index into a string in the filter list
Definition: hts_memory.cpp:144
VariantFiltersIterator end() const
Returns an iterator referring to one-past-the-last element in the list of filters.
Definition: variant_filters.h:56
bool missing() const
returns true if the filters field is missing
Definition: variant_filters.h:46