Stream in variants from compressed/uncompressed VCF/BCF file or stdin.
More...
#include <vcfpp.h>
|
| 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 ®ion) |
| construct a vcf/bcf reader with subset samples More...
|
|
| BcfReader (const std::string &file, const std::string ®ion, const std::string &samples) |
| construct a vcf/bcf reader with subset samples in target region More...
|
|
void | close () |
| Close the VCF file and its associated files.
|
|
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 BcfHeader & | getHeader () const |
| return a BcfHeader object
|
|
int | getStatus (const std::string ®ion) |
| query the status of a given region in the VCF More...
|
|
int | getVariantsCount (const std::string ®ion) |
| count the number of variants by iterating through a given region. More...
|
|
void | setSamples (const std::string &samples) |
| explicitly stream to specific samples More...
|
|
void | setRegion (const std::string ®ion) |
| explicitly stream to specific region. throw invalid_argument error if index file not found. throw runtime_error if the region was not a valid bcftools-like format or was not presenting in the VCF. More...
|
|
bool | getNextVariant (BcfRecord &r) |
| read in the next variant More...
|
|
Stream in variants from compressed/uncompressed VCF/BCF file or stdin.
◆ BcfReader() [1/3]
vcfpp::BcfReader::BcfReader |
( |
const std::string & |
file | ) |
|
|
inline |
construct a vcf/bcf reader from file.
- Parameters
-
file | the 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
-
file | the input vcf/bcf with suffix vcf(.gz)/bcf(.gz) or stdin "-" |
region | samtools-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
-
file | the input vcf/bcf with suffix vcf(.gz) or bcf(.gz) |
region | samtools-like region "chr:start-end", skip if empty |
samples | LIST 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 |
◆ getNextVariant()
bool vcfpp::BcfReader::getNextVariant |
( |
BcfRecord & |
r | ) |
|
|
inline |
read in the next variant
- Parameters
-
◆ getStatus()
int vcfpp::BcfReader::getStatus |
( |
const std::string & |
region | ) |
|
|
inline |
query the status of a given region in the VCF
- Returns
- -2: the region is not a valid bcftools-like format, or it is not presenting in the VCF even though it's bcftols-like format.
-1: there is no index file found.
0: the region is valid but empty.
1: vaild and not empty.
◆ getVariantsCount()
int vcfpp::BcfReader::getVariantsCount |
( |
const std::string & |
region | ) |
|
|
inline |
count the number of variants by iterating through a given region.
- Note
- If you want to continue work on that region, remember to reset the region by setRegion()!
Also, check the status of the region first to handle the different cases!
◆ setRegion()
void vcfpp::BcfReader::setRegion |
( |
const std::string & |
region | ) |
|
|
inline |
explicitly stream to specific region. throw invalid_argument error if index file not found. throw runtime_error if the region was not a valid bcftools-like format or was not presenting in the VCF.
- Parameters
-
region | the string for region is samtools-like format, which can be 'chr', 'chr:start' and 'chr:start-end' |
◆ setSamples()
void vcfpp::BcfReader::setSamples |
( |
const std::string & |
samples | ) |
|
|
inline |
explicitly stream to specific samples
- Parameters
-
samples | the 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: