// SamFormatPrinter.cpp (c) 2010 Derek Barnett
// Marth Lab, Department of Biology, Boston College
// ---------------------------------------------------------------------------
-// Last modified: 19 April 2011 (DB)
+// Last modified: 12 October 2011 (DB)
// ---------------------------------------------------------------------------
// Provides functionality for printing formatted SAM header to string
// ***************************************************************************
-#include <api/SamConstants.h>
-#include <api/SamHeader.h>
-#include <api/internal/SamFormatPrinter_p.h>
+#include "api/SamConstants.h"
+#include "api/SamHeader.h"
+#include "api/internal/SamFormatPrinter_p.h"
using namespace BamTools;
using namespace BamTools::Internal;
#include <vector>
using namespace std;
+// ------------------------
+// static utility methods
+// ------------------------
+
+static inline
+const string FormatTag(const string& tag, const string& value) {
+ return string(Constants::SAM_TAB + tag + Constants::SAM_COLON + value);
+}
+
+// ---------------------------------
+// SamFormatPrinter implementation
+// ---------------------------------
+
SamFormatPrinter::SamFormatPrinter(const SamHeader& header)
: m_header(header)
{ }
SamFormatPrinter::~SamFormatPrinter(void) { }
-const string SamFormatPrinter::FormatTag(const string &tag, const string &value) const {
- return string(Constants::SAM_TAB + tag + Constants::SAM_COLON + value);
-}
-
const string SamFormatPrinter::ToString(void) const {
// clear out stream
SamSequenceConstIterator seqIter = m_header.Sequences.ConstBegin();
SamSequenceConstIterator seqEnd = m_header.Sequences.ConstEnd();
for ( ; seqIter != seqEnd; ++seqIter ) {
- const SamSequence& seq = (*seqIter);
+ const SamSequence& seq = seqIter->second;
// @SQ SN:<Name> LN:<Length>
out << Constants::SAM_SQ_BEGIN_TOKEN
SamReadGroupConstIterator rgIter = m_header.ReadGroups.ConstBegin();
SamReadGroupConstIterator rgEnd = m_header.ReadGroups.ConstEnd();
for ( ; rgIter != rgEnd; ++rgIter ) {
- const SamReadGroup& rg = (*rgIter);
+ const SamReadGroup& rg = rgIter->second;
// @RG ID:<ID>
out << Constants::SAM_RG_BEGIN_TOKEN