1 // ***************************************************************************
2 // BamRandomAccessController_p.h (c) 2011 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // ---------------------------------------------------------------------------
5 // Last modified: 6 October 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);
47 // BamRandomAccessController interface
51 void ClearIndex(void);
52 bool CreateIndex(BamReaderPrivate* reader, const BamIndex::IndexType& type);
53 bool HasIndex(void) const;
54 bool IndexHasAlignmentsForReference(const int& refId);
55 bool LocateIndex(BamReaderPrivate* reader, const BamIndex::IndexType& preferredType);
56 bool OpenIndex(const std::string& indexFilename, BamReaderPrivate* reader);
57 void SetIndex(BamIndex* index);
58 void SetIndexCacheMode(const BamIndex::IndexCacheMode& mode);
61 void ClearRegion(void);
62 bool HasRegion(void) const;
63 RegionState AlignmentState(const BamAlignment& alignment) const;
64 bool RegionHasAlignments(void) const;
65 bool SetRegion(const BamRegion& region, const int& referenceCount);
69 std::string GetErrorString(void) const;
73 // adjusts requested region if necessary (depending on where data actually begins)
74 void AdjustRegion(const int& referenceCount);
75 // error-string handling
76 void SetErrorString(const std::string& where, const std::string& what);
82 BamIndex* m_index; // owns the index, not a copy - responsible for deleting
83 BamIndex::IndexCacheMode m_indexCacheMode;
87 bool m_hasAlignmentsInRegion;
90 std::string m_errorString;
93 } // namespace Internal
94 } // namespace BamTools
96 #endif // BAMRACONTROLLER_P_H