yat  0.13.2pre
Public Member Functions | Friends | Related Functions | List of all members
theplu::yat::omic::BamHeader Class Reference

Wrapper around bam_hdr_t struct. More...

#include <yat/omic/BamHeader.h>

Public Member Functions

 BamHeader (void)
 Default constructor.
 
 ~BamHeader (void)
 Destructor.
 
 BamHeader (const BamHeader &)
 Copy constructor.
 
void parse_region (const std::string &reg, 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...
 
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
 
BamHeaderoperator= (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)
 

Detailed Description

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.

Since
New in yat 0.10

Member Function Documentation

int32_t theplu::yat::omic::BamHeader::n_targets ( void  ) const
Returns
Number of chromosomes
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.

Exceptions
utility::runtime_erroron failure
Since
new in yat 0.11
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

@PG ID:bwa PN:bwa VN:0.6.1-r104

and for this line program_group("bwa", "VN") returns "0.6.1-r104"

Returns
value for key for line with ID id.
Since
New in yat 0.13
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

@RG ID:foo PL:ILLUMINA SM:Tumour

and for this line read_group("foo", "SM") returns "Tumour"

Returns
value for key for line with ID id.
Since
New in yat 0.13
void theplu::yat::omic::BamHeader::swap ( BamHeader other)

Exchanges the content in *this and other.

Since
New in yat 0.13
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
Returns
text in header
Since
New in yat 0.13
void theplu::yat::omic::BamHeader::text ( const std::string &  txt)

set text in header

This function parses txt and updates fields.

Since
New in yat 0.13
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.

Since
new in yat 0.11

Friends And Related Function Documentation

void swap ( BamHeader lhs,
BamHeader rhs 
)
related

Exchanges the content in the headers.

Since
New in yat 0.13

The documentation for this class was generated from the following file:

Generated on Wed Jan 4 2017 02:23:07 for yat by  doxygen 1.8.5