Skip to content

Instantly share code, notes, and snippets.

View elowy01's full-sized avatar

Ernesto Lowy elowy01

  • Biofidelity
  • Cambridge, UK
View GitHub Profile
@elowy01
elowy01 / Parse_VCF_BCFs_with_htslib_C++.md
Created November 16, 2020 10:28 — forked from gatoravi/Parse_VCF_BCFs_with_htslib_C++.md
Parse VCF/BCFs with htslib (C++)

#Gist of the gist This is a simple example showing how htslib can be used to parse VCF/BCF files in C++. Compiling options are shown in compile_and_run.sh, this assumes that you have compiled htslib into a static library - libhts.a, post a comment if you'd like help doing that.

The program takes a VCF file and spits out chromosome, position and number_of_alleles for each record in the VCF.

This test in the Samtools repo - [https://github.com/samtools/htslib/blob/1.2.1/test/test-vcf-api.c] also has some useful examples, note you might have to switch to the master branch version of that file to keep up with the currently rapidly evolving htslib API.

#Acknowledgements

@elowy01
elowy01 / test.sh
Created November 12, 2020 09:34 — forked from arq5x/test.sh
Compress and then Decompress a string with zlib.
# compile
$ g++ zlib-example.cpp -lz -o zlib-example
# run
$ ./zlib-example
Uncompressed size is: 36
Uncompressed string is: Hello Hello Hello Hello Hello Hello!
----------