yat  0.21pre
Classes | Public Member Functions | Friends | Related Functions | List of all members
theplu::yat::omic::VcfHeader Class Reference

#include <yat/omic/VcfHeader.h>

Public Member Functions

 VcfHeader (const std::string &version)
 Constructor. More...
 
 VcfHeader (std::istream &is)
 
void add (const std::string &key, const std::string &value)
 
void add (const std::string &key, const std::string &ID, int number, const std::string &type, const std::string &description)
 
void add_info (const std::string &ID, const std::string &number, const std::string &type, const std::string &description)
 
void add_format (const std::string &ID, const std::string &number, const std::string &type, const std::string &description)
 
void add_program_command (int argc, char *argv[])
 
void add_program_version (const std::string &prog, const std::string &version)
 
void erase (size_t line)
 erase line line More...
 
const std::string & header (void) const
 
void header (const std::string &header)
 
const std::string & line (size_t i) const
 
std::string key (size_t line) const
 
void nicify (void)
 
std::string value (size_t line) const
 
std::string value (size_t line, const std::string &key) const
 
size_t size (void) const
 
const std::vector< std::string > & samples (void) const
 
void samples (const std::vector< std::string > &s)
 

Friends

std::ostream & operator<< (std::ostream &os, const VcfHeader &b)
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &, const VcfHeader &header)
 

Detailed Description

Since
New in yat 0.16

Constructor & Destructor Documentation

◆ VcfHeader() [1/2]

theplu::yat::omic::VcfHeader::VcfHeader ( const std::string &  version)

Constructor.

Creates an empty header

◆ VcfHeader() [2/2]

theplu::yat::omic::VcfHeader::VcfHeader ( std::istream &  is)

Consumes lines until a line does not start with '#' and constructs a VcfHeader.

Member Function Documentation

◆ add() [1/2]

void theplu::yat::omic::VcfHeader::add ( const std::string &  key,
const std::string &  value 
)

Adds a line ##key = value

◆ add() [2/2]

void theplu::yat::omic::VcfHeader::add ( const std::string &  key,
const std::string &  ID,
int  number,
const std::string &  type,
const std::string &  description 
)

Add a line

key=<ID,Number=number,Type=type,Description=description>

If number is 0, it's replaced with ".".

◆ add_format()

void theplu::yat::omic::VcfHeader::add_format ( const std::string &  ID,
const std::string &  number,
const std::string &  type,
const std::string &  description 
)

Same as add("FORMAT", ID, number, type, description)

number should be integer or special character as A: one per alt allele R: one per allele G: one per genotype .: unknown

◆ add_info()

void theplu::yat::omic::VcfHeader::add_info ( const std::string &  ID,
const std::string &  number,
const std::string &  type,
const std::string &  description 
)

Same as add("INFO", ID, number, type, description)

number should be integer or special character as A: one per alt allele R: one per allele G: one per genotype .: unknown

◆ add_program_command()

void theplu::yat::omic::VcfHeader::add_program_command ( int  argc,
char *  argv[] 
)

add a line with something like:

bcftools_viewCommand=view -l 9 -O z -; Date=Wed Apr 19 10:49:09 2017

◆ add_program_version()

void theplu::yat::omic::VcfHeader::add_program_version ( const std::string &  prog,
const std::string &  version 
)

add a line with something like

bcftools_normVersion=1.4+htslib-1.4

◆ erase()

void theplu::yat::omic::VcfHeader::erase ( size_t  line)

erase line line

The last line, starting with '#CHROM', cannot be erased. Use function samples(const std::vector<std::string>&) to alter that line.

Since
New in yat 0.18

◆ header() [1/2]

const std::string& theplu::yat::omic::VcfHeader::header ( void  ) const
Returns
the last line of the header

◆ header() [2/2]

void theplu::yat::omic::VcfHeader::header ( const std::string &  header)

Set the last line of the header

◆ key()

std::string theplu::yat::omic::VcfHeader::key ( size_t  line) const
Returns
everything between prefix '##' and first '=' of line line

◆ line()

const std::string& theplu::yat::omic::VcfHeader::line ( size_t  i) const
Returns
line i

◆ nicify()

void theplu::yat::omic::VcfHeader::nicify ( void  )

Sort lines

Lines are sorted with respect to their categories a) '##fileformat=' b) '##reference=' and '##contig=' c) '##INFO=' d) '##FILTER=' e) '##FORMAT=' f) other g) '#CHROM'

◆ samples() [1/2]

const std::vector<std::string>& theplu::yat::omic::VcfHeader::samples ( void  ) const

Sample names occur tab-delimited in the last line starting from 10th column.

Returns
samples name

◆ samples() [2/2]

void theplu::yat::omic::VcfHeader::samples ( const std::vector< std::string > &  s)

Set sample names

◆ size()

size_t theplu::yat::omic::VcfHeader::size ( void  ) const
Returns
number of lines

◆ value() [1/2]

std::string theplu::yat::omic::VcfHeader::value ( size_t  line) const

everything right of first '=' on line line

◆ value() [2/2]

std::string theplu::yat::omic::VcfHeader::value ( size_t  line,
const std::string &  key 
) const

returns "" if key is missing is false otherwise corresponding value e.g. value(i, "Description") returns value for key Description of line line

Friends And Related Function Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream &  ,
const VcfHeader header 
)
related
Since
new in yat 0.16

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