1 // ***************************************************************************
2 // BamRandomAccessController_p.h (c) 2011 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // ---------------------------------------------------------------------------
5 // Last modified: 24 February 2011(DB)
6 // ---------------------------------------------------------------------------
7 // Manages random access operations in a BAM file
8 // ***************************************************************************
10 #ifndef BAMRACONTROLLER_P_H
11 #define BAMRACONTROLLER_P_H
17 // This file is not part of the BamTools API. It exists purely as an
18 // implementation detail. This header file may change from version to version
19 // without notice, or even be removed.
23 #include <api/BamAux.h>
24 #include <api/BamIndex.h>
32 class BamReaderPrivate;
34 class BamRandomAccessController {
37 public: enum RegionState { BeforeRegion = 0
44 BamRandomAccessController(void);
45 ~BamRandomAccessController(void);
54 void ClearIndex(void);
55 bool CreateIndex(BamReaderPrivate* reader, const BamIndex::IndexType& type);
56 bool HasIndex(void) const;
57 bool IndexHasAlignmentsForReference(const int& refId);
58 bool LocateIndex(BamReaderPrivate* reader, const BamIndex::IndexType& preferredType);
59 bool OpenIndex(const std::string& indexFilename, BamReaderPrivate* reader);
60 void SetIndex(BamIndex* index);
61 void SetIndexCacheMode(const BamIndex::IndexCacheMode& mode);
65 void ClearRegion(void);
66 bool HasRegion(void) const;
67 RegionState AlignmentState(const BamAlignment& alignment) const;
68 bool RegionHasAlignments(void) const;
69 bool SetRegion(BamReaderPrivate* reader,
70 const BamRegion& region,
71 const int& referenceCount);
75 // adjusts requested region if necessary (depending on where data actually begins)
76 void AdjustRegion(const int& referenceCount);
82 BamIndex* m_index; // owns index, not a copy - responsible for deleting
83 BamIndex::IndexCacheMode m_indexCacheMode;
87 bool m_hasAlignmentsInRegion;
90 } // namespace Internal
91 } // namespace BamTools
93 #endif // BAMRACONTROLLER_P_H