1 // ***************************************************************************
2 // BamRandomAccessController_p.h (c) 2011 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // All rights reserved.
5 // ---------------------------------------------------------------------------
6 // Last modified: 24 February 2011(DB)
7 // ---------------------------------------------------------------------------
8 // Manages random access operations in a BAM file
9 // ***************************************************************************
11 #ifndef BAMRACONTROLLER_P_H
12 #define BAMRACONTROLLER_P_H
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 version
20 // without notice, or even be removed.
24 #include <api/BamAux.h>
25 #include <api/BamIndex.h>
33 class BamReaderPrivate;
35 class BamRandomAccessController {
38 public: enum RegionState { BeforeRegion = 0
45 BamRandomAccessController(void);
46 ~BamRandomAccessController(void);
55 void ClearIndex(void);
56 bool CreateIndex(BamReaderPrivate* reader, const BamIndex::IndexType& type);
57 bool HasIndex(void) const;
58 bool IndexHasAlignmentsForReference(const int& refId);
59 bool LocateIndex(const std::string& bamFilename, const BamIndex::IndexType& preferredType);
60 bool OpenIndex(const std::string& indexFilename);
61 void SetIndex(BamIndex* index);
62 void SetIndexCacheMode(const BamIndex::IndexCacheMode& mode);
66 void ClearRegion(void);
67 bool HasRegion(void) const;
68 RegionState AlignmentState(const BamAlignment& alignment) const;
69 bool RegionHasAlignments(void) const;
70 bool SetRegion(BamReaderPrivate* reader,
71 const BamRegion& region,
72 const int& referenceCount);
76 // adjusts requested region if necessary (depending on where data actually begins)
77 void AdjustRegion(const int& referenceCount);
83 BamIndex* m_index; // owns index, not a copy - responsible for deleting
84 BamIndex::IndexCacheMode m_indexCacheMode;
88 bool m_hasAlignmentsInRegion;
91 } // namespace Internal
92 } // namespace BamTools
94 #endif // BAMRACONTROLLER_P_H