Gamgee
You miserable little maggot. I'll stove your head in!
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sam_pair_iterator.h
Go to the documentation of this file.
1 #ifndef gamgee__sam_pair_iterator__guard
2 #define gamgee__sam_pair_iterator__guard
3 
4 #include "sam.h"
5 
6 #include "htslib/sam.h"
7 
8 #include <fstream>
9 #include <queue>
10 #include <memory>
11 
12 namespace gamgee {
13 
18  public:
19 
24 
31  SamPairIterator(const std::shared_ptr<htsFile>& sam_file_ptr, const std::shared_ptr<bam_hdr_t>& sam_header_ptr);
32 
36  SamPairIterator(const SamPairIterator& other) = delete;
37  SamPairIterator& operator=(const SamPairIterator& other) = delete;
38 
42  SamPairIterator(SamPairIterator&& other) = default;
43  SamPairIterator& operator=(SamPairIterator&& other) = default;
44 
53  bool operator!=(const SamPairIterator& rhs);
54 
60  std::pair<Sam,Sam> operator*();
61 
68  std::pair<Sam,Sam> operator++();
69 
70  private:
71  using SamPtrQueue = std::queue<std::shared_ptr<bam1_t>>;
72 
73  SamPtrQueue m_supp_alignments;
74  std::shared_ptr<htsFile> m_sam_file_ptr;
75  std::shared_ptr<bam_hdr_t> m_sam_header_ptr;
76  std::shared_ptr<bam1_t> m_sam_record_ptr1;
77  std::shared_ptr<bam1_t> m_sam_record_ptr2;
78  std::pair<Sam,Sam> m_sam_records;
79 
80  std::pair<Sam,Sam> fetch_next_pair();
81  bool read_sam(std::shared_ptr<bam1_t>& record_ptr);
82  Sam make_sam(std::shared_ptr<bam1_t>& record_ptr);
83  Sam next_primary_alignment(std::shared_ptr<bam1_t>& record_ptr);
84  std::pair<Sam,Sam> next_supplementary_alignment();
85 };
86 
87 } // end namespace gamgee
88 
89 #endif // gamgee__sam_pair_iterator__guard
std::pair< Sam, Sam > operator++()
pre-fetches the next record and tests for end of file
Definition: sam_pair_iterator.cpp:35
std::pair< Sam, Sam > operator*()
dereference operator (needed by for-each loop)
Definition: sam_pair_iterator.cpp:31
bool operator!=(const SamPairIterator &rhs)
inequality operator (needed by for-each loop)
Definition: sam_pair_iterator.cpp:40
SamPairIterator & operator=(const SamPairIterator &other)=delete
Definition: exceptions.h:9
Utility class to manipulate a Sam record.
Definition: sam.h:20
SamPairIterator()
creates an empty iterator (used for the end() method)
Definition: sam_pair_iterator.cpp:16
Utility class to enable for-each style iteration by pairs in the SamReader class. ...
Definition: sam_pair_iterator.h:17