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