vcfpp
Public Member Functions | Public Attributes | List of all members
vcfpp::BcfReader Class Reference

Stream in variants from compressed/uncompressed VCF/BCF file or stdin. More...

#include <vcfpp.h>

Public Member Functions

 BcfReader ()
 Construct an empty BcfReader.
 
 BcfReader (const std::string &file)
 construct a vcf/bcf reader from file. More...
 
 BcfReader (const std::string &file, const std::string &region)
 construct a vcf/bcf reader with subset samples More...
 
 BcfReader (const std::string &file, const std::string &region, const std::string &samples)
 construct a vcf/bcf reader with subset samples in target region More...
 
void close ()
 close the BcfReader object.
 
void open (const std::string &file)
 open a VCF/BCF/STDIN file for streaming in
 
int setThreads (int n)
 set the number of threads to use
 
const BcfHeadergetHeader () const
 return a BcfHeader object
 
uint64_t getVariantsCount (BcfRecord &r, const std::string &region)
 get the number of records of given region
 
void setSamples (const std::string &samples)
 explicitly stream to specific samples More...
 
void setRegion (const std::string &region)
 explicitly stream to specific region More...
 
bool getNextVariant (BcfRecord &r)
 read in the next variant More...
 

Public Attributes

BcfHeader header
 a BcfHeader object
 
int nsamples
 number of samples in the VCF
 
std::vector< std::string > SamplesName
 number of samples in the VCF
 

Detailed Description

Stream in variants from compressed/uncompressed VCF/BCF file or stdin.

Constructor & Destructor Documentation

◆ BcfReader() [1/3]

vcfpp::BcfReader::BcfReader ( const std::string &  file)
inline

construct a vcf/bcf reader from file.

Parameters
filethe input vcf/bcf with suffix vcf(.gz)/bcf(.gz) or stdin "-"

◆ BcfReader() [2/3]

vcfpp::BcfReader::BcfReader ( const std::string &  file,
const std::string &  region 
)
inline

construct a vcf/bcf reader with subset samples

Parameters
filethe input vcf/bcf with suffix vcf(.gz)/bcf(.gz) or stdin "-"
regionsamtools-like region "chr:start-end", skip if empty

◆ BcfReader() [3/3]

vcfpp::BcfReader::BcfReader ( const std::string &  file,
const std::string &  region,
const std::string &  samples 
)
inline

construct a vcf/bcf reader with subset samples in target region

Parameters
filethe input vcf/bcf with suffix vcf(.gz) or bcf(.gz)
regionsamtools-like region "chr:start-end", skip if empty
samplesLIST samples to include or exclude as a comma-separated string.
LIST : select samples in list
^LIST : exclude samples from list
"-" : include all samples
"" : exclude all samples

Member Function Documentation

◆ getNextVariant()

bool vcfpp::BcfReader::getNextVariant ( BcfRecord r)
inline

read in the next variant

Parameters
rr is a BcfRecord object to be filled in.

◆ setRegion()

void vcfpp::BcfReader::setRegion ( const std::string &  region)
inline

explicitly stream to specific region

Parameters
regionthe string is samtools-like format which is chr:start-end

◆ setSamples()

void vcfpp::BcfReader::setSamples ( const std::string &  samples)
inline

explicitly stream to specific samples

Parameters
samplesthe string is bcftools-like format, which is comma separated list of samples to include (or exclude with "^" prefix).

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