Skip to content

Instantly share code, notes, and snippets.

@winni2k
Last active August 29, 2015 14:18
Show Gist options
  • Save winni2k/9a9ccb9ac45a45392a2c to your computer and use it in GitHub Desktop.
Save winni2k/9a9ccb9ac45a45392a2c to your computer and use it in GitHub Desktop.
Code snippet for including Erik Garrison's tabixpp located at https://github.com/ekg/tabixpp
#include "tabix.hpp"
void anyfunc(){
//tabixed vcf
string inVCF = "input.vcf.gz";
// region
string region = "20:1-4000000";
// create tabix object
Tabix tbx(inVCF);
// set region to extract from vcf
if (tbx.setRegion(region) != true)
throw std::runtime_error("Malformed region string: " + region);
// get the header
string header;
tbx.getHeader(header);
// read each line in region
while (tbx.getNextLine(line)) {
// parse vcf record as string
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment