Skip to content

Instantly share code, notes, and snippets.

@adamewing
Created April 20, 2014 04:36
Show Gist options
  • Save adamewing/11105144 to your computer and use it in GitHub Desktop.
Save adamewing/11105144 to your computer and use it in GitHub Desktop.
Make INDELs parse as INDELs via PyVCF by removing SVTYPE field
#!/usr/bin/env python
import vcf
import sys
'''
PyVCF will parse INDELs as SVs if they have SVTYPE in the INFO field.
This provides a quick-fix.
contact: adam.ewing@mater.uq.edu.au
'''
def convert(vcf_fn):
invcf = vcf.Reader(filename=vcf_fn)
outvcf = vcf.Writer(sys.stdout, invcf)
for rec in invcf:
del(rec.INFO['SVTYPE'])
outvcf.write_record(rec)
if __name__ == '__main__':
if len(sys.argv) == 2:
convert(sys.argv[1])
else:
print "usage:",sys.argv[0],"<VCF>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment