Loading...
Searching...
No Matches
SamHeader.h
Go to the documentation of this file.
// ***************************************************************************
// SamHeader.h (c) 2010 Derek Barnett
// Marth Lab, Department of Biology, Boston College
// ---------------------------------------------------------------------------
// Last modified: 10 October 2011 (DB)
// ---------------------------------------------------------------------------
// Provides direct read/write access to the SAM header data fields.
// ***************************************************************************
#ifndef SAM_HEADER_H
#define SAM_HEADER_H
#include <string>
#include <vector>
#include "api/BamAux.h"
#include "api/SamProgramChain.h"
#include "api/SamReadGroupDictionary.h"
#include "api/SamSequenceDictionary.h"
#include "api/api_global.h"
namespace BamTools {
struct API_EXPORT SamHeader
{
// ctor & dtor
SamHeader(const std::string& headerText = std::string());
// query/modify entire SamHeader
void Clear(); // clears all header contents
std::string GetErrorString() const;
bool HasError() const;
bool IsValid(bool verbose = false) const; // returns true if SAM header is well-formed
void SetHeaderText(
const std::string& headerText); // replaces data fields with contents of SAM-formatted text
std::string ToString() const; // returns the printable, SAM-formatted header text
// convenience query methods
bool HasVersion() const; // returns true if header contains format version entry
bool HasSortOrder() const; // returns true if header contains sort order entry
bool HasGroupOrder() const; // returns true if header contains group order entry
bool HasSequences() const; // returns true if header contains any sequence entries
bool HasReadGroups() const; // returns true if header contains any read group entries
bool HasPrograms() const; // returns true if header contains any program record entries
bool HasComments() const; // returns true if header contains comments
// --------------
// data members
// --------------
// header metadata (@HD line)
std::string Version; // VN:<Version> *Required, if @HD record is present*
std::string SortOrder; // SO:<SortOrder>
std::string GroupOrder; // GO:<GroupOrder>
std::vector<CustomHeaderTag> CustomTags; // optional custom tags on @HD line
// header sequences (@SQ entries)
SamSequenceDictionary Sequences;
// header read groups (@RG entries)
SamReadGroupDictionary ReadGroups;
// header program data (@PG entries)
SamProgramChain Programs;
// header comments (@CO entries)
std::vector<std::string> Comments;
// internal data
private:
mutable std::string m_errorString;
};
} // namespace BamTools
#endif // SAM_HEADER_H
BamAux.h
SamProgramChain.h
SamReadGroupDictionary.h
SamSequenceDictionary.h
api_global.h
BamTools::SamProgramChain
Sorted container "chain" of SamProgram records.
Definition SamProgramChain.h:27
BamTools::SamReadGroupDictionary
Container of SamReadGroup entries.
Definition SamReadGroupDictionary.h:27
BamTools::SamSequenceDictionary
Container of SamSequence entries.
Definition SamSequenceDictionary.h:27
BamTools
Contains all BamTools classes & methods.
Definition Sort.h:24
BamTools::SamHeader::HasPrograms
bool HasPrograms() const
Returns true if header contains any @PG entries.
Definition SamHeader.cpp:146
BamTools::SamHeader::HasSequences
bool HasSequences() const
Returns true if header contains any @SQ entries.
Definition SamHeader.cpp:130
BamTools::SamHeader::HasError
bool HasError() const
Returns true if header encountered an error.
Definition SamHeader.cpp:98
BamTools::SamHeader::HasVersion
bool HasVersion() const
Returns true if header contains @HD ID:<Version>.
Definition SamHeader.cpp:106
BamTools::SamHeader::ReadGroups
SamReadGroupDictionary ReadGroups
corresponds to @RG entries
Definition SamHeader.h:61
BamTools::SamHeader::HasGroupOrder
bool HasGroupOrder() const
Returns true if header contains @HD GO:<GroupOrder>.
Definition SamHeader.cpp:122
BamTools::SamHeader::HasReadGroups
bool HasReadGroups() const
Returns true if header contains any @RG entries.
Definition SamHeader.cpp:138
BamTools::SamHeader::SortOrder
std::string SortOrder
corresponds to @HD SO:<SortOrder>
Definition SamHeader.h:53
BamTools::SamHeader::SamHeader
SamHeader(const std::string &headerText=std::string())
constructor
Definition SamHeader.cpp:56
BamTools::SamHeader::CustomTags
std::vector< CustomHeaderTag > CustomTags
Definition SamHeader.h:55
BamTools::SamHeader::Clear
void Clear()
Clears all header contents.
Definition SamHeader.cpp:65
BamTools::SamHeader::ToString
std::string ToString() const
Converts data fields to SAM-formatted text.
Definition SamHeader.cpp:224
BamTools::SamHeader::Comments
std::vector< std::string > Comments
corresponds to @CO entries
Definition SamHeader.h:67
BamTools::SamHeader::HasSortOrder
bool HasSortOrder() const
Returns true if header contains @HD SO:<SortOrder>.
Definition SamHeader.cpp:114
BamTools::SamHeader::Programs
SamProgramChain Programs
corresponds to @PG entries
Definition SamHeader.h:64
BamTools::SamHeader::HasComments
bool HasComments() const
Returns true if header contains any @CO entries.
Definition SamHeader.cpp:154
BamTools::SamHeader::SetHeaderText
void SetHeaderText(const std::string &headerText)
Replaces header contents with headerText.
Definition SamHeader.cpp:197
BamTools::SamHeader::IsValid
bool IsValid(bool verbose=false) const
Checks header contents for required data and proper formatting.
Definition SamHeader.cpp:166
BamTools::SamHeader::GetErrorString
std::string GetErrorString() const
Returns a human-readable description of the last error that occurred.
Definition SamHeader.cpp:90
BamTools::SamHeader::GroupOrder
std::string GroupOrder
corresponds to @HD GO:<GroupOrder>
Definition SamHeader.h:54
BamTools::SamHeader::Sequences
SamSequenceDictionary Sequences
corresponds to @SQ entries
Definition SamHeader.h:58
BamTools::SamHeader::Version
std::string Version
corresponds to @HD VN:<Version>
Definition SamHeader.h:52