]> git.donarmstrong.com Git - bamtools.git/blobdiff - src/utils/bamtools_pileup_engine.h
Added new PileupEngine to the toolkit. This is used by CoverageTool as well as Conver...
[bamtools.git] / src / utils / bamtools_pileup_engine.h
diff --git a/src/utils/bamtools_pileup_engine.h b/src/utils/bamtools_pileup_engine.h
new file mode 100644 (file)
index 0000000..675b8e6
--- /dev/null
@@ -0,0 +1,94 @@
+// ***************************************************************************
+// bamtools_pileup_engine.h (c) 2010 Derek Barnett, Erik Garrison
+// Marth Lab, Department of Biology, Boston College
+// All rights reserved.
+// ---------------------------------------------------------------------------
+// Last modified: 16 September 2010
+// ---------------------------------------------------------------------------
+// Provides pileup at position functionality for various tools.
+// ***************************************************************************
+
+#ifndef BAMTOOLS_PILEUP_ENGINE_H
+#define BAMTOOLS_PILEUP_ENGINE_H
+
+#include <vector>
+#include "BamAux.h"
+
+namespace BamTools {
+
+// contains auxiliary data about a single BamAlignment
+// at current position considered
+struct PileupAlignment {
+  
+    // data members
+    BamAlignment Alignment;
+    int32_t PositionInAlignment;
+    bool IsCurrentDeletion;
+    bool IsNextDeletion;
+    bool IsNextInsertion;
+    int DeletionLength;
+    int InsertionLength;
+    bool IsSegmentBegin;
+    bool IsSegmentEnd;
+    
+    // ctor
+    PileupAlignment(const BamAlignment& al)
+        : Alignment(al)
+        , PositionInAlignment(-1)
+        , IsCurrentDeletion(false)
+        , IsNextDeletion(false)
+        , IsNextInsertion(false)
+        , DeletionLength(0)
+        , InsertionLength(0)
+        , IsSegmentBegin(false)
+        , IsSegmentEnd(false)
+    { }
+};
+  
+// contains all data at a position
+struct PileupPosition {
+  
+    // data members
+    int RefId;
+    int Position;
+    std::vector<PileupAlignment> PileupAlignments;
+
+    // ctor
+    PileupPosition(const int& refId = 0,
+                   const int& position = 0, 
+                   const std::vector<PileupAlignment>& alignments = std::vector<PileupAlignment>())
+        : RefId(refId)
+        , Position(position)
+        , PileupAlignments(alignments)
+    { }
+};
+  
+class PileupVisitor {
+  
+    public:
+        PileupVisitor(void) { }
+        virtual ~PileupVisitor(void) { }
+  
+    public:
+        virtual void Visit(const PileupPosition& pileupData) =0;
+};
+
+class PileupEngine {
+  
+    public:
+        PileupEngine(void);
+        ~PileupEngine(void);
+        
+    public:
+        bool AddAlignment(const BamAlignment& al);
+        void AddVisitor(PileupVisitor* visitor);
+        void Flush(void);
+        
+    private:
+        struct PileupEnginePrivate;
+        PileupEnginePrivate* d;
+};
+
+} // namespace BamTools
+
+#endif // BAMTOOLS_PILEUP_ENGINE_H
\ No newline at end of file