yat
0.14.5pre
|
Wrapper around bam_hdr_t struct. More...
#include <yat/omic/BamHeader.h>
Public Types | |
typedef boost::transform_iterator < utility::PairFirst< const strMap2::value_type > , strMap2::const_iterator > | read_group_iterator |
Public Member Functions | |
BamHeader (void) | |
Default constructor. | |
~BamHeader (void) | |
Destructor. | |
BamHeader (const BamHeader &) | |
Copy constructor. | |
void | parse_region (const std::string ®, int &tid, int &begin, int &end) const |
const std::string & | program_group (const std::string &id, const std::string &key) const |
Access value in @PG lines. More... | |
const std::string & | read_group (const std::string &id, const std::string &key) const |
Access value in @RG lines. More... | |
const std::map< std::string, std::string > & | read_group (const std::string &id) const |
read_group_iterator | read_group_begin (void) const |
read_group_iterator | read_group_end (void) const |
void | swap (BamHeader &other) |
Exchanges the content in *this and other. More... | |
const char * | target_name (size_t tid) const |
uint32_t | target_length (size_t tid) const |
std::string | text (void) const |
void | text (const std::string &txt) |
set text in header More... | |
int32_t | tid (const std::string &name) const |
inverse of target_name(size_t) More... | |
int32_t | n_targets (void) const |
BamHeader & | operator= (const BamHeader &rhs) |
assignment operator | |
Friends | |
class | InBamFile |
class | OutBamFile |
Related Functions | |
(Note that these are not member functions.) | |
void | swap (BamHeader &lhs, BamHeader &rhs) |
Wrapper around bam_hdr_t struct.
Class is typically created via InBamFile::header().
It is possible to copy and assign a BamHeader, but note that a BamHeader does not own underlying data. The underlying data is owned by the InBamFile and the BamHeader is thus invalid after the corresponding InBamFile has been destroyed.
typedef boost::transform_iterator< utility::PairFirst<const strMap2::value_type>, strMap2::const_iterator> theplu::yat::omic::BamHeader::read_group_iterator |
read_group_iterator is used to iterate through read groups
int32_t theplu::yat::omic::BamHeader::n_targets | ( | void | ) | const |
void theplu::yat::omic::BamHeader::parse_region | ( | const std::string & | reg, |
int & | tid, | ||
int & | begin, | ||
int & | end | ||
) | const |
Parse a region in the format: 'chr2:100,000-200,000 and return values in variables tid, begin and end. reg is 1-based and begin and end are 0-based, i.e., "chr2:100,000-200,000" will set begin = 99999 and end = 200000.
utility::runtime_error | on failure |
const std::string& theplu::yat::omic::BamHeader::program_group | ( | const std::string & | id, |
const std::string & | key | ||
) | const |
Access value in @PG
lines.
A program group line in the header typically looks like
and for this line program_group
("bwa", "VN") returns "0.6.1-r104"
const std::string& theplu::yat::omic::BamHeader::read_group | ( | const std::string & | id, |
const std::string & | key | ||
) | const |
Access value in @RG
lines.
A read group line in the header typically looks like
and for this line read_group
("foo", "SM") returns "Tumour"
To see which IDs are available in the header, iterate through the set of IDs with read_group_begin() (and read_group_end()).
const std::map<std::string, std::string>& theplu::yat::omic::BamHeader::read_group | ( | const std::string & | id | ) | const |
for which the returned map contains two entries: one with key PL
and value ILLUMINA
, and one with key SM
and value Tumour
.
read_group_iterator theplu::yat::omic::BamHeader::read_group_begin | ( | void | ) | const |
read_group_iterator theplu::yat::omic::BamHeader::read_group_end | ( | void | ) | const |
void theplu::yat::omic::BamHeader::swap | ( | BamHeader & | other | ) |
Exchanges the content in *this
and other.
uint32_t theplu::yat::omic::BamHeader::target_length | ( | size_t | tid | ) | const |
Length of chromosome with ID tid
const char* theplu::yat::omic::BamHeader::target_name | ( | size_t | tid | ) | const |
Name of chromosome with ID tid
std::string theplu::yat::omic::BamHeader::text | ( | void | ) | const |
void theplu::yat::omic::BamHeader::text | ( | const std::string & | txt | ) |
set text in header
This function parses txt and updates fields.
Function invalidates object's iterators and reference returned from read_group(const std::string&).
int32_t theplu::yat::omic::BamHeader::tid | ( | const std::string & | name | ) | const |
inverse of target_name(size_t)
If compiled against libbam and name does not exist, behavious is undefined. If compiled against htslib, a utility::runtime_error is thrown.
Exchanges the content in the headers.