Skip to content

Instantly share code, notes, and snippets.

@finswimmer
Created May 19, 2018 04:56
Show Gist options
  • Save finswimmer/b62948f036b956cd1acbe1e882b95d81 to your computer and use it in GitHub Desktop.
Save finswimmer/b62948f036b956cd1acbe1e882b95d81 to your computer and use it in GitHub Desktop.
import sys
from pysam import VariantFile
vcf_in = VariantFile(sys.argv[1])
print(str(vcf_in.header).strip())
for rec in vcf_in:
for key, value in rec.info.items():
if vcf_in.header.info[key].number not in ("A", "R", "G", ".", "0"):
if type(value) is tuple:
rec.info[key] = value[0:vcf_in.header.info[key].number]
print(str(rec).strip())
@finswimmer
Copy link
Author

Answer on biostars question: https://www.biostars.org/p/315408

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment