Gamgee
You miserable little maggot. I'll stove your head in!
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
multiple_variant_iterator.h
Go to the documentation of this file.
1 #ifndef gamgee__multiple_variant_iterator__guard
2 #define gamgee__multiple_variant_iterator__guard
3 
4 #include "htslib/vcf.h"
5 
6 #include "variant.h"
7 #include "variant_iterator.h"
8 
9 #include <memory>
10 #include <queue>
11 
12 namespace gamgee {
13 
14 using VariantIteratorIndexPair = std::pair<std::shared_ptr<VariantIterator>, uint32_t>;
15 using VariantIndexPair = std::pair<Variant, uint32_t>;
16 
21  public:
22 
26  MultipleVariantIterator() = default;
27 
34  MultipleVariantIterator(const std::vector<std::shared_ptr<htsFile>>& variant_files, const std::vector<std::shared_ptr<bcf_hdr_t>>& variant_headers);
35 
41 
47 
58  bool operator!=(const MultipleVariantIterator& rhs);
59 
65  std::vector<VariantIndexPair>& operator*();
66 
72  std::vector<VariantIndexPair>& operator++();
73 
74  private:
75  // fetches the next Variant vector
76  void fetch_next_vector();
77 
78  // comparison class for genomic locations in the priority queue
79  class Comparator {
80  public:
81  bool operator()(const VariantIteratorIndexPair& left, const VariantIteratorIndexPair& right);
82  };
83 
84  // the individual file iterators
85  std::priority_queue<VariantIteratorIndexPair, std::vector<VariantIteratorIndexPair>, Comparator> m_queue;
86 
87  // caches next Variant vector
88  std::vector<VariantIndexPair> m_variant_vector;
89 };
90 
91 } // end namespace gamgee
92 
93 #endif // gamgee__multiple_variant_iterator__guard
std::vector< VariantIndexPair > & operator*()
dereference operator (needed by for-each loop)
Definition: multiple_variant_iterator.cpp:16
MultipleVariantIterator & operator=(MultipleVariantIterator &&other)=default
bool operator!=(const MultipleVariantIterator &rhs)
pseudo-inequality operator (needed by for-each loop)
Definition: multiple_variant_iterator.cpp:27
std::pair< Variant, uint32_t > VariantIndexPair
Definition: multiple_variant_iterator.h:15
std::vector< VariantIndexPair > & operator++()
advances the iterator, fetching the next vector
Definition: multiple_variant_iterator.cpp:20
std::pair< std::shared_ptr< VariantIterator >, uint32_t > VariantIteratorIndexPair
Definition: multiple_variant_iterator.h:14
Utility class to enable for-each style iteration in the MultipleVariantReader class.
Definition: multiple_variant_iterator.h:20
MultipleVariantIterator()=default
creates an empty iterator (used for the end() method)
Definition: exceptions.h:9