]> git.donarmstrong.com Git - bamtools.git/blob - src/utils/bamtools_pileup_engine.h
Cleaned up intra-API includes & moved version numbers to 2.0.0
[bamtools.git] / src / utils / bamtools_pileup_engine.h
1 // ***************************************************************************
2 // bamtools_pileup_engine.h (c) 2010 Derek Barnett, Erik Garrison
3 // Marth Lab, Department of Biology, Boston College
4 // ---------------------------------------------------------------------------
5 // Last modified: 10 October 2011
6 // ---------------------------------------------------------------------------
7 // Provides pileup at position functionality for various tools.
8 // ***************************************************************************
9
10 #ifndef BAMTOOLS_PILEUP_ENGINE_H
11 #define BAMTOOLS_PILEUP_ENGINE_H
12
13 #include "utils/utils_global.h"
14
15 #include <api/BamAlignment.h>
16 #include <vector>
17
18 namespace BamTools {
19
20 // contains auxiliary data about a single BamAlignment
21 // at current position considered
22 struct UTILS_EXPORT PileupAlignment {
23   
24     // data members
25     BamAlignment Alignment;
26     int32_t PositionInAlignment;
27     bool IsCurrentDeletion;
28     bool IsNextDeletion;
29     bool IsNextInsertion;
30     int DeletionLength;
31     int InsertionLength;
32     bool IsSegmentBegin;
33     bool IsSegmentEnd;
34     
35     // ctor
36     PileupAlignment(const BamAlignment& al)
37         : Alignment(al)
38         , PositionInAlignment(-1)
39         , IsCurrentDeletion(false)
40         , IsNextDeletion(false)
41         , IsNextInsertion(false)
42         , DeletionLength(0)
43         , InsertionLength(0)
44         , IsSegmentBegin(false)
45         , IsSegmentEnd(false)
46     { }
47 };
48   
49 // contains all data at a position
50 struct UTILS_EXPORT PileupPosition {
51   
52     // data members
53     int RefId;
54     int Position;
55     std::vector<PileupAlignment> PileupAlignments;
56
57     // ctor
58     PileupPosition(const int& refId = 0,
59                    const int& position = 0, 
60                    const std::vector<PileupAlignment>& alignments = std::vector<PileupAlignment>())
61         : RefId(refId)
62         , Position(position)
63         , PileupAlignments(alignments)
64     { }
65 };
66   
67 class UTILS_EXPORT PileupVisitor {
68   
69     public:
70         PileupVisitor(void) { }
71         virtual ~PileupVisitor(void) { }
72   
73     public:
74         virtual void Visit(const PileupPosition& pileupData) =0;
75 };
76
77 class UTILS_EXPORT PileupEngine {
78   
79     public:
80         PileupEngine(void);
81         ~PileupEngine(void);
82         
83     public:
84         bool AddAlignment(const BamAlignment& al);
85         void AddVisitor(PileupVisitor* visitor);
86         void Flush(void);
87         
88     private:
89         struct PileupEnginePrivate;
90         PileupEnginePrivate* d;
91 };
92
93 } // namespace BamTools
94
95 #endif // BAMTOOLS_PILEUP_ENGINE_H