Gamgee
You miserable little maggot. I'll stove your head in!
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
indexed_sam_iterator.h
Go to the documentation of this file.
1 #ifndef gamgee__indexed_sam_iterator__guard
2 #define gamgee__indexed_sam_iterator__guard
3 
4 #include "sam.h"
5 
6 #include "../utils/hts_memory.h"
7 
8 #include "htslib/sam.h"
9 
10 #include <memory>
11 #include <string>
12 #include <vector>
13 
14 namespace gamgee {
15 
20  public:
25 
34  IndexedSamIterator(const std::shared_ptr<htsFile>& sam_file_ptr, const std::shared_ptr<hts_idx_t>& sam_index_ptr,
35  const std::shared_ptr<bam_hdr_t>& sam_header_ptr, const std::vector<std::string>& interval_list);
36 
40  IndexedSamIterator(IndexedSamIterator&& other) = default;
42 
46  IndexedSamIterator(const IndexedSamIterator& other) = delete;
47  IndexedSamIterator& operator=(const IndexedSamIterator& other) = delete;
48 
57  bool operator!=(const IndexedSamIterator& rhs);
58 
64  Sam& operator*();
65 
72  Sam& operator++();
73 
74  const std::string& current_interval() const;
75 
76  private:
77  std::shared_ptr<htsFile> m_sam_file_ptr;
78  std::shared_ptr<hts_idx_t> m_sam_index_ptr;
79  std::shared_ptr<bam_hdr_t> m_sam_header_ptr;
80  std::vector<std::string> m_interval_list;
81  std::vector<std::string>::iterator m_interval_iterator;
82  std::unique_ptr<hts_itr_t, utils::HtsIteratorDeleter> m_sam_itr_ptr;
83  std::shared_ptr<bam1_t> m_sam_record_ptr;
84  Sam m_sam_record;
85 
86  void fetch_next_record();
87 };
88 
89 }
90 
91 #endif
Sam & operator*()
dereference operator (needed by for-each loop)
Definition: indexed_sam_iterator.cpp:31
Utility class to enable for-each style iteration in the IndexedSamReader class.
Definition: indexed_sam_iterator.h:19
IndexedSamIterator()
creates an empty iterator (used for the end() method)
Definition: indexed_sam_iterator.cpp:10
void iterator(const char *fname)
Definition: test-vcf-api.c:248
bool operator!=(const IndexedSamIterator &rhs)
inequality operator (needed by for-each loop)
Definition: indexed_sam_iterator.cpp:40
Definition: exceptions.h:9
IndexedSamIterator & operator=(IndexedSamIterator &&other)=default
const std::string & current_interval() const
Definition: indexed_sam_iterator.cpp:55
Utility class to manipulate a Sam record.
Definition: sam.h:20
Sam & operator++()
pre-fetches the next record and tests for end of file
Definition: indexed_sam_iterator.cpp:35