Skip to content

jackwimbish/vcfreader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

A simple, stateful VCF (http://www.1000genomes.org/node/101) parser for python.

Emphasizes ease of use over performance.

Useful for reading and modifying VCFs.

import sys
from vcfreader import VCFReader

vcfr = VCFReader('/path/to/my_vcf.vcf')

# show which samples are in this file
print ', '.join(vcfr.samples)

while vcfr.nextentry():
    # let me see the genotype of the first sample in this VCF
    gt = vcfr.getgenotype(vcfr.samples[0])
    print ','.join(gt)

    # let me see the AF at this variant
    print vcfr.INFO.get('AF')

    # let's set a custom annotation in the INFO
    vcfr.INFO['ANNOT'] = "HELLOWORLD"

    # now if we write out this variant with outputentry, the update to INFO will be reflected
    vcfr.outputentry()

About

VCF parser for Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages