Gamgee
You miserable little maggot. I'll stove your head in!
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
sam_writer.h
Go to the documentation of this file.
1 #ifndef __gamgee_sam_writer__
2 #define __gamgee_sam_writer__
3 
4 #include <string>
5 
6 #include "sam.h"
7 #include "sam_header.h"
8 #include "htslib/sam.h"
9 
10 namespace gamgee {
11 
16 class SamWriter {
17 
18  public:
19 
26  explicit SamWriter(const std::string& output_fname = "-", const bool binary = true);
27 
35  explicit SamWriter(const SamHeader& header, const std::string& output_fname = "-", const bool binary = true);
36 
40  ~SamWriter();
41 
46  void add_record(const Sam& body);
47 
53  void add_header(const SamHeader& header);
54 
55  private:
56  htsFile* m_out_file;
57  SamHeader m_header;
58 
59  static htsFile* open_file(const std::string& output_fname, const std::string& binary);
60  void write_header() const;
61 
62 };
63 
64 }
65 #endif
SamWriter(const std::string &output_fname="-", const bool binary=true)
Creates a new SamWriter using the specified output file name.
Definition: sam_writer.cpp:5
Utility class to hold the header of a sam file.
Definition: sam_header.h:13
void add_record(const Sam &body)
Adds a record to the file stream.
Definition: sam_writer.cpp:26
void add_header(const SamHeader &header)
Adds a header to the file stream.
Definition: sam_writer.cpp:21
~SamWriter()
takes care of closing the file/stream
Definition: sam_writer.cpp:17
utility class to write out a SAM/BAM/CRAM file to any stream
Definition: sam_writer.h:16
Utility class to manipulate a Sam record.
Definition: sam.h:19