]> git.donarmstrong.com Git - bamtools.git/blob - src/api/internal/BamWriter_p.h
e3547fe43061ba1646090e0a2a9643a3ac85ad3a
[bamtools.git] / src / api / internal / BamWriter_p.h
1 // ***************************************************************************
2 // BamWriter_p.h (c) 2010 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // ---------------------------------------------------------------------------
5 // Last modified: 6 October 2011 (DB)
6 // ---------------------------------------------------------------------------
7 // Provides the basic functionality for producing BAM files
8 // ***************************************************************************
9
10 #ifndef BAMWRITER_P_H
11 #define BAMWRITER_P_H
12
13 //  -------------
14 //  W A R N I N G
15 //  -------------
16 //
17 // This file is not part of the BamTools API.  It exists purely as an
18 // implementation detail.  This header file may change from version to
19 // version without notice, or even be removed.
20 //
21 // We mean it.
22
23 #include <api/BamAux.h>
24 #include <api/internal/BgzfStream_p.h>
25 #include <string>
26 #include <vector>
27
28 namespace BamTools {
29
30 class BamAlignment;
31
32 namespace Internal {
33
34 class BamWriterPrivate {
35
36     // ctor & dtor
37     public:
38         BamWriterPrivate(void);
39         ~BamWriterPrivate(void);
40
41     // interface methods
42     public:
43         void Close(void);
44         std::string GetErrorString(void) const;
45         bool IsOpen(void) const;
46         bool Open(const std::string& filename,
47                   const std::string& samHeaderText,
48                   const BamTools::RefVector& referenceSequences);
49         bool SaveAlignment(const BamAlignment& al);
50         void SetWriteCompressed(bool ok);
51
52     // 'internal' methods
53     public:
54         uint32_t CalculateMinimumBin(const int begin, int end) const;
55         void CreatePackedCigar(const std::vector<BamTools::CigarOp>& cigarOperations, std::string& packedCigar);
56         void EncodeQuerySequence(const std::string& query, std::string& encodedQuery);
57         void WriteAlignment(const BamAlignment& al);
58         void WriteCoreAlignment(const BamAlignment& al);
59         void WriteMagicNumber(void);
60         void WriteReferences(const BamTools::RefVector& referenceSequences);
61         void WriteSamHeaderText(const std::string& samHeaderText);
62
63     // data members
64     private:
65         BgzfStream m_stream;
66         bool m_isBigEndian;
67         std::string m_errorString;
68 };
69
70 } // namespace Internal
71 } // namespace BamTools
72
73 #endif // BAMWRITER_P_H