This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Extract data from VCF file

How can I extract below fields from a VCF file?

I am looking for python parser for VCF file.

'ALLELE_CALL', 'IS_HETEROZYGOUS', 'NUM_READS', 'TOTAL_READ_DEPTH'

My VCF file looks like:

#CHROM  POS     ID      REF     ALT     QUAL    FILTER  INFO    FORMAT MATERIAL1 MATERIAL2 MATERIAL..n
sequencing

what are VARIANT_TYPE, SEQUENCE,ALLELE_CALL,VALUE, etc... ? How can we know what you want to put in those columns ?

Updated the question.

2 answers

They're probably in the INFO field. You can just use cut, or GATK VariantsToTable, or PyVCF. Lots of options!

Try @brentp 's cyvcf2 (cython + htslib == fast VCF and BCF processing), a fast python (2 and 3) parsing of VCF and BCF including region-queries, published on Bioinformatics.

Log in to answer this question.