Gamgee
You miserable little maggot. I'll stove your head in!
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sam_writer.h
Go to the documentation of this file.
1 #ifndef gamgee__sam_writer__guard
2 #define gamgee__sam_writer__guard
3 
4 #include <string>
5 #include <memory>
6 
7 #include "sam.h"
8 #include "sam_header.h"
9 
10 #include "../utils/hts_memory.h"
11 
12 #include "htslib/sam.h"
13 
14 namespace gamgee {
15 
20 class SamWriter {
21 
22  public:
23 
30  explicit SamWriter(const std::string& output_fname = "-", const bool binary = true);
31 
39  explicit SamWriter(const SamHeader& header, const std::string& output_fname = "-", const bool binary = true);
40 
45  SamWriter(const SamWriter& other) = delete;
46  SamWriter& operator=(const SamWriter& other) = delete;
47 
52  SamWriter(SamWriter&& other) = default;
53  SamWriter& operator=(SamWriter&& other) = default;
54 
59  void add_record(const Sam& body);
60 
66  void add_header(const SamHeader& header);
67 
68  private:
69  std::unique_ptr<htsFile, utils::HtsFileDeleter> m_out_file;
70  SamHeader m_header;
71 
72  static htsFile* open_file(const std::string& output_fname, const std::string& binary);
73  void write_header() const;
74 
75 };
76 
77 }
78 
79 #endif // gamgee__sam_writer__guard
SamWriter(const std::string &output_fname="-", const bool binary=true)
Creates a new SamWriter using the specified output file name.
Definition: sam_writer.cpp:7
SamWriter & operator=(const SamWriter &other)=delete
Definition: hts.h:109
Utility class to hold the header of a sam file.
Definition: sam_header.h:16
void add_record(const Sam &body)
Adds a record to the file stream.
Definition: sam_writer.cpp:24
void add_header(const SamHeader &header)
Adds a header to the file stream.
Definition: sam_writer.cpp:19
utility class to write out a SAM/BAM/CRAM file to any stream
Definition: sam_writer.h:20
Definition: exceptions.h:9
Utility class to manipulate a Sam record.
Definition: sam.h:20