// ***************************************************************************
// BamReader_p.h (c) 2010 Derek Barnett
// Marth Lab, Department of Biology, Boston College
-// All rights reserved.
// ---------------------------------------------------------------------------
-// Last modified: 24 February 2011 (DB)
+// Last modified: 10 October 2011 (DB)
// ---------------------------------------------------------------------------
// Provides the basic functionality for reading BAM files
// ***************************************************************************
//
// We mean it.
-#include <api/BamAlignment.h>
-#include <api/BamIndex.h>
-#include <api/BamReader.h>
-#include <api/SamHeader.h>
-#include <api/internal/BamHeader_p.h>
-#include <api/internal/BamRandomAccessController_p.h>
-#include <api/internal/BgzfStream_p.h>
+#include "api/BamAlignment.h"
+#include "api/BamIndex.h"
+#include "api/BamReader.h"
+#include "api/SamHeader.h"
+#include "api/internal/BamHeader_p.h"
+#include "api/internal/BamRandomAccessController_p.h"
+#include "api/internal/BgzfStream_p.h"
#include <string>
namespace BamTools {
public:
// file operations
- void Close(void);
+ bool Close(void);
const std::string Filename(void) const;
bool IsOpen(void) const;
bool Open(const std::string& filename);
void SetIndex(BamIndex* index);
void SetIndexCacheMode(const BamIndex::IndexCacheMode& mode);
- // BamReaderPrivate interface
- public:
- BgzfStream* Stream(void);
+ // error handling
+ std::string GetErrorString(void) const;
+ void SetErrorString(const std::string& where, const std::string& what);
- // 'internal' methods
+ // internal methods, but available as a BamReaderPrivate 'interface'
+ //
+ // these methods should only be used by BamTools::Internal classes
+ // (currently only used by the BamIndex subclasses)
public:
// retrieves header text from BAM file
- bool LoadHeaderData(void);
+ void LoadHeaderData(void);
// retrieves BAM alignment under file pointer
// (does no overlap checking or character data parsing)
bool LoadNextAlignment(BamAlignment& alignment);
// builds reference data structure from BAM file
bool LoadReferenceData(void);
+ // seek reader to file position
+ bool Seek(const int64_t& position);
+ // return reader's file position
+ int64_t Tell(void) const;
// data members
public:
BamHeader m_header;
BamRandomAccessController m_randomAccessController;
BgzfStream m_stream;
+
+ // error handling
+ std::string m_errorString;
};
} // namespace Internal