yat  0.21pre
Public Types | 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 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.
 
 BamHeader (BamHeader &&) noexcept
 Move 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...
 
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
 
BamHeaderoperator= (const BamHeader &rhs)
 assignment operator
 
BamHeaderoperator= (BamHeader &&rhs)
 move assignment operator
 

Friends

class BamReadIterator
 
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 Typedef Documentation

◆ read_group_iterator

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

read_group_iterator is a Readable Iterator and Bidirectional Traversal Iterator with value type std::string

See also
read_group_begin
read_group_end
Since
New in yat 0.14

Member Function Documentation

◆ n_targets()

int32_t theplu::yat::omic::BamHeader::n_targets ( void  ) const
Returns
Number of chromosomes

◆ parse_region()

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

◆ program_group()

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

◆ read_group() [1/2]

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"

To see which IDs are available in the header, iterate through the set of IDs with read_group_begin() (and read_group_end()).

Returns
value for key for line with ID id.
Since
New in yat 0.13

◆ read_group() [2/2]

const std::map<std::string, std::string>& theplu::yat::omic::BamHeader::read_group ( const std::string &  id) const
Returns
a map describing an @RG line such as
@RG ID:foo PL:ILLUMINA SM:Tumour

for which the returned map contains two entries: one with key PL and value ILLUMINA, and one with key SM and value Tumour.

Since
New in yat 0.14

◆ read_group_begin()

read_group_iterator theplu::yat::omic::BamHeader::read_group_begin ( void  ) const
Returns
first of available RG IDs
Since
New in yat 0.14

◆ read_group_end()

read_group_iterator theplu::yat::omic::BamHeader::read_group_end ( void  ) const
Returns
end of range of available RG IDs
See also
read_group_begin()
Since
New in yat 0.14

◆ swap()

void theplu::yat::omic::BamHeader::swap ( BamHeader other)

Exchanges the content in *this and other.

Since
New in yat 0.13

◆ target_length()

uint32_t theplu::yat::omic::BamHeader::target_length ( size_t  tid) const

Length of chromosome with ID tid

◆ target_name()

const char* theplu::yat::omic::BamHeader::target_name ( size_t  tid) const

Name of chromosome with ID tid

◆ text() [1/2]

std::string theplu::yat::omic::BamHeader::text ( void  ) const
Returns
text in header
Since
New in yat 0.13

◆ text() [2/2]

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&).

Since
New in yat 0.13

◆ tid()

int32_t theplu::yat::omic::BamHeader::tid ( const std::string &  name) const

inverse of target_name(size_t)

If name does not exist, a utility::runtime_error is thrown.

Since
new in yat 0.11

Friends And Related Function Documentation

◆ swap()

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 25 2023 03:34:29 for yat by  doxygen 1.8.14