Man page - vcflib-api(1)
Packages contains this manual
- vcflib-api(1)
- vcfannotategenotypes(1)
- vcfcat(1)
- vcfgeno2alleles(1)
- vcfroc(1)
- vcfhethomratio(1)
- vcfcountalleles(1)
- vcfaddinfo(1)
- vcfrandomsample(1)
- vcfbreakmulti(1)
- vcfcheck(1)
- vcfsitesummarize(1)
- vcfdistance(1)
- vcfglbound(1)
- pyvcflib(1)
- vcfinfosummarize(1)
- vcflib(1)
- vcfnumalt(1)
- vcfsample2info(1)
- vcfkeepgeno(1)
- vcfgeno2haplo(1)
- vcfallelicprimitives(1)
- vcfindex(1)
- vcfecho(1)
- vcfwave(1)
- vcf2tsv(1)
- vcffixup(1)
- vcfremap(1)
- vcfnullgenofields(1)
- vcfoverlay(1)
- vcfremoveaberrantgenotypes(1)
- vcfflatten(1)
- vcfintersect(1)
- vcfprimers(1)
- vcfgenosamplenames(1)
- vcfafpath(1)
- vcfinfo2qual(1)
- vcfparsealts(1)
- vcffilter(1)
- vcfuniqalleles(1)
- vcfgenotypes(1)
- vcfsamplenames(1)
- vcfaltcount(1)
- vcfcombine(1)
- vcfuniq(1)
- vcf2dag(1)
- vcfgenotypecompare(1)
- vcfhetcount(1)
- vcfclassify(1)
- vcfkeepsamples(1)
- vcf2fasta(1)
- vcflength(1)
- vcfleftalign(1)
- vcfcommonsamples(1)
- vcfglxgt(1)
- vcfentropy(1)
- vcfrandom(1)
- vcfcreatemulti(1)
- vcfnulldotslashdot(1)
- vcfgenosummarize(1)
- vcfstats(1)
- vcfannotate(1)
- smoother(1)
- vcfstreamsort(1)
- vcfevenregions(1)
- vcfld(1)
- vcfkeepinfo(1)
- vcfqual2info(1)
- vcfremovesamples(1)
- abba-baba(1)
- vcfcleancomplex(1)
- vcfsamplediff(1)
apt-get install libvcflib-tools
Manual
- - coding: utf-8 - -
VCFLib APIOpen the VCF file
Read records
Other fields
Output a VCF record
Mirroring in the Python FFI
VCFLib API
This document describes the VCFLIB API as it is used by the vcflib modules and the python ffi. vcflib follows the VCF standard (http://samtools.github.io/hts-specs/VCFv4.1.pdf).
VCFLIB contains a lot of functionality, but the basis of going through a VCF file and fetching record (by record) information is straightforward and visible in all modules. A recent example can be found in vcfwave.
Open the VCF file
VariantCallFile variantFile;
if (optind < argc) {
string filename = argv[optind];
variantFile.open(filename);
} else {
variantFile.open(std::cin);
}
if (!variantFile.is_open()) {
return 1;
}
Read records
The following will parse the records and you can print out the first two fields with
Variant var(variantFile);
while (variantFile.getNextVariant(var)) {
cout << var.sequenceName << " " << var.position << endl;
}
Other fields
In the file Variant.h (https://github.com/vcflib/vcflib/blob/master/src/Variant.h) the Variant class is defined with fields/accessors, such as
string sequenceName;
long position;
long zeroBasedPosition(void) const;
string id;
string ref;
vector<string> alt; // a list of all the alternate alleles present at this locus
vector<string> alleles; // a list all alleles (ref + alt) at this locus
See above read records example to parse a file. Some things to know are that info fields are split into fields with values in โinfoโ and flags that are true in โinfoFlagsโ. The order of info fields is not kept in the C++ map data structure so we have to keep track of order in an infoKeys vector.
Output a VCF record
The default string outputter of the Variant class outputs a VCF record using the field that are defined:
Variant var(variantFile);
while (variantFile.getNextVariant(var)) {
cout << var << endl;
}
will output VCF.
Mirroring in the Python FFI
The Python FFI follows this API though some accessors may be renamed. See pythonffi.cpp and pyvcflib.md.