1 // ***************************************************************************
2 // BamRandomAccessController_p.h (c) 2011 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // ---------------------------------------------------------------------------
5 // Last modified: 10 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);
60 void ClearRegion(void);
61 bool HasRegion(void) const;
62 RegionState AlignmentState(const BamAlignment& alignment) const;
63 bool RegionHasAlignments(void) const;
64 bool SetRegion(const BamRegion& region, const int& referenceCount);
68 std::string GetErrorString(void) const;
72 // adjusts requested region if necessary (depending on where data actually begins)
73 void AdjustRegion(const int& referenceCount);
74 // error-string handling
75 void SetErrorString(const std::string& where, const std::string& what);
81 BamIndex* m_index; // owns the index, not a copy - responsible for deleting
85 bool m_hasAlignmentsInRegion;
88 std::string m_errorString;
91 } // namespace Internal
92 } // namespace BamTools
94 #endif // BAMRACONTROLLER_P_H