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