// BamReader.cpp (c) 2009 Derek Barnett, Michael Str�mberg
// Marth Lab, Department of Biology, Boston College
// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011 (DB)
+// Last modified: 29 July 2013 (DB)
// ---------------------------------------------------------------------------
// Provides read access to BAM files.
// ***************************************************************************
#include "api/BamReader.h"
-#include "api/internal/BamReader_p.h"
+#include "api/internal/bam/BamReader_p.h"
using namespace BamTools;
using namespace BamTools::Internal;
return d->CreateIndex(type);
}
+/*! \fn const SamHeader& BamReader::GetConstSamHeader(void) const
+ \brief Returns const reference to SAM header data.
+
+ Allows for read-only queries of SAM header data.
+
+ If you do not need to modify the SAM header, use this method to avoid the
+ potentially expensive copy used by GetHeader().
+
+ \note
+ \returns const reference to header data object
+ \sa GetHeader(), GetHeaderText()
+*/
+const SamHeader& BamReader::GetConstSamHeader(void) const {
+ return d->GetConstSamHeader();
+}
+
/*! \fn std::string BamReader::GetErrorString(void) const
\brief Returns a human-readable description of the last error that occurred
/*! \fn SamHeader BamReader::GetHeader(void) const
\brief Returns SAM header data.
- Header data is wrapped in a SamHeader object that can be conveniently queried & modified.
+ Header data is wrapped in a SamHeader object that can be conveniently queried and/or modified.
+ If you only need read access, consider using GetConstSamHeader() instead.
\note Modifying the retrieved SamHeader object does NOT affect the
current BAM file. This file has been opened in a read-only mode.
BamWriter to generate a new BAM file with the appropriate header information.
\returns header data object
- \sa GetHeaderText()
+ \sa GetConstSamHeader(), GetHeaderText()
*/
SamHeader BamReader::GetHeader(void) const {
return d->GetSamHeader();
However, this method does NOT populate the alignment's string data fields
(read name, bases, qualities, tags, filename). This provides a boost in speed
- when these fields are not required for every alignment. These fields can be
- populated 'lazily' (as needed) by calling BamAlignment::BuildCharData() later.
+ when these fields are not required for every alignment. These fields, excluding filename,
+ can be populated 'lazily' (as needed) by calling BamAlignment::BuildCharData() later.
\param[out] alignment destination for alignment record data
\returns \c true if a valid alignment was found
d->SetIndex(index);
}
-/*! \fn void BamReader::SetIndexCacheMode(const BamIndex::IndexCacheMode& mode)
- \brief Changes the caching behavior of the index data.
-
- Default mode is BamIndex::LimitedIndexCaching.
-
- \param[in] mode desired cache mode for index, see BamIndex::IndexCacheMode for
- description of the available cache modes
- \sa HasIndex()
-*/
-void BamReader::SetIndexCacheMode(const BamIndex::IndexCacheMode& mode) {
- d->SetIndexCacheMode(mode);
-}
-
/*! \fn bool BamReader::SetRegion(const BamRegion& region)
\brief Sets a target region of interest