Created
July 5, 2011 15:01
-
-
Save nickloman/1065006 to your computer and use it in GitHub Desktop.
A little script to expand VCF to allow the key-value list to be easily sorted/filtered
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from copy import copy | |
used_keys = ['DP', 'AF1', 'CI95', 'DP4', 'MQ', 'PV4', 'INDEL'] | |
initial_dict = dict([(k, '') for k in used_keys]) | |
for ln in sys.stdin: | |
d = copy(initial_dict) | |
cols = ln.rstrip().split("\t") | |
#print cols[7] | |
for keypair in cols[7].split(';'): | |
if '=' in keypair: | |
key, val = keypair.split("=") | |
d[key] = val | |
else: | |
d[keypair] = keypair | |
cols.extend([d[key] for key in used_keys]) | |
print "\t".join(cols) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment