#!/usr/bin/env python import sys,os.path f = open(os.path.splitext(sys.argv[1])[0] + ".avinput", "w+") for line in open(sys.argv[1]): if line[0] == "#": continue fields = line.rstrip().split("\t") #sys.stderr.write(str(fields) + "\n") alts = fields[4].split(",") alt = "" gt = fields[9].split(":")[0] if "1" in gt.split("/"): alt = alts[0] elif "2" in gt.split("/"): if alts[1:]: alt = alts[1] else: alt = alts[0] elif "3" in gt.split("/"): if alts[2:]: alt=alts[2] else: alt= alts[0] else: alt = alts[0] f.write("\t".join([fields[0],fields[1],str(int(fields[1]) + len(fields[3])-1),fields[3],alt,"GT:" + gt]) + "\n")