Loading...
Searching...
No Matches
BamTools::SamHeader Struct Reference

Represents the SAM-formatted text header that is part of the BAM file header. More...

`#include <SamHeader.h>`

## Public Member Functions

| SamHeader (const std::string &headerText=std::string())
| constructor
void | Clear ()
| Clears all header contents.
std::string | GetErrorString () const
| Returns a human-readable description of the last error that occurred.
bool | HasError () const
| Returns `true` if header encountered an error.
bool | IsValid (bool verbose=false) const
| Checks header contents for required data and proper formatting.
void | SetHeaderText (const std::string &headerText)
| Replaces header contents with headerText.
std::string | ToString () const
| Converts data fields to SAM-formatted text.
bool | HasVersion () const
| Returns `true` if header contains @HD ID:<Version>.
bool | HasSortOrder () const
| Returns `true` if header contains @HD SO:<SortOrder>.
bool | HasGroupOrder () const
| Returns `true` if header contains @HD GO:<GroupOrder>.
bool | HasSequences () const
| Returns `true` if header contains any @SQ entries.
bool | HasReadGroups () const
| Returns `true` if header contains any @RG entries.
bool | HasPrograms () const
| Returns `true` if header contains any @PG entries.
bool | HasComments () const
| Returns `true` if header contains any @CO entries.

## Public Attributes

std::string | Version
| corresponds to @HD VN:<Version>
std::string | SortOrder
| corresponds to @HD SO:<SortOrder>
std::string | GroupOrder
| corresponds to @HD GO:<GroupOrder>
std::vector< CustomHeaderTag > | CustomTags
SamSequenceDictionary | Sequences
| corresponds to @SQ entries
SamReadGroupDictionary | ReadGroups
| corresponds to @RG entries
SamProgramChain | Programs
| corresponds to @PG entries
std::vector< std::string > | Comments
| corresponds to @CO entries

## Detailed Description

Represents the SAM-formatted text header that is part of the BAM file header.

Provides direct read/write access to the SAM header data fields.

See also
  http://samtools.sourceforge.net/SAM1.pdf

## Constructor & Destructor Documentation

## SamHeader()

SamHeader::SamHeader | ( | const std::string & | headerText = std::string() | ) |

constructor

## Member Function Documentation

## Clear()

void SamHeader::Clear | ( |  | ) |

Clears all header contents.

## GetErrorString()

std::string SamHeader::GetErrorString | ( |  | ) | const

Returns a human-readable description of the last error that occurred.

This method allows elimination of STDERR pollution. Developers of client code may choose how the messages are displayed to the user, if at all.

Returns
  error description

## HasComments()

bool SamHeader::HasComments | ( |  | ) | const

Returns `true` if header contains any @CO entries.

## HasError()

bool SamHeader::HasError | ( |  | ) | const

Returns `true` if header encountered an error.

## HasGroupOrder()

bool SamHeader::HasGroupOrder | ( |  | ) | const

Returns `true` if header contains @HD GO:<GroupOrder>.

## HasPrograms()

bool SamHeader::HasPrograms | ( |  | ) | const

Returns `true` if header contains any @PG entries.

## HasReadGroups()

bool SamHeader::HasReadGroups | ( |  | ) | const

Returns `true` if header contains any @RG entries.

## HasSequences()

bool SamHeader::HasSequences | ( |  | ) | const

Returns `true` if header contains any @SQ entries.

## HasSortOrder()

bool SamHeader::HasSortOrder | ( |  | ) | const

Returns `true` if header contains @HD SO:<SortOrder>.

## HasVersion()

bool SamHeader::HasVersion | ( |  | ) | const

Returns `true` if header contains @HD ID:<Version>.

## IsValid()

bool SamHeader::IsValid | ( | bool | verbose = false | ) | const

Checks header contents for required data and proper formatting.

Parameters

  [in] | verbose | If set to true, validation errors & warnings will be printed to stderr. Otherwise, messages are available through SamHeader::GetErrorString().

Returns
  `true` if SAM header is well-formed

## SetHeaderText()

void SamHeader::SetHeaderText | ( | const std::string & | headerText | ) |

Replaces header contents with headerText.

Parameters

  [in] | headerText | SAM formatted-text that will be parsed into data fields

## ToString()

std::string SamHeader::ToString | ( |  | ) | const

Converts data fields to SAM-formatted text.

Applies any local modifications made since creating this object or calling SetHeaderText().

Returns
  SAM-formatted header text

## Member Data Documentation

## Comments

std::vector<std::string> BamTools::SamHeader::Comments

corresponds to @CO entries

## CustomTags

std::vector<CustomHeaderTag> BamTools::SamHeader::CustomTags

## GroupOrder

std::string BamTools::SamHeader::GroupOrder

corresponds to @HD GO:<GroupOrder>

## Programs

SamProgramChain BamTools::SamHeader::Programs

corresponds to @PG entries

See also
  SamProgram, SamProgramChain

## ReadGroups

SamReadGroupDictionary BamTools::SamHeader::ReadGroups

corresponds to @RG entries

See also
  SamReadGroup, SamReadGroupDictionary

## Sequences

SamSequenceDictionary BamTools::SamHeader::Sequences

corresponds to @SQ entries

See also
  SamSequence, SamSequenceDictionary

## SortOrder

std::string BamTools::SamHeader::SortOrder

corresponds to @HD SO:<SortOrder>

## Version

std::string BamTools::SamHeader::Version

corresponds to @HD VN:<Version>

Required for valid SAM header, if @HD record is present.

The documentation for this struct was generated from the following files:

- SamHeader.h
- SamHeader.cpp