# # add allele count field # import vcf import filez import sys import getopt def wrap(line, length=80): if len(line)<=length: return line if len(line)==0: return "" while length>=0 and line[length] != " ": length -= 1 start = length while length>=0 and line[length] == " ": length -= 1 if length>=0: return line[:length+1] + "\n" + wrap(line[start+1:]) while length e[3]: col = [col[e[3]]] else: col = ["."] # format the various types if type(col) in [type(""),type(0),type(0.0)]: col = str(col) elif type(col) == type({}): if e[0] == "INFO": col = v.format_formatdata( col, v._info, separator=";" ) else: col = v.format_formatdata( col, v._format, key=False ) elif type(col) == type([]): # change unextracted GT back into text format; other unextracted fields are comma-separated if e[2] == "GT" and len(col)==3: col = ''.join(map(str,col)) elif e[1] == "ref" or e[1] == "alt": col = ','.join(map(str,col)) else: col = ":".join(map(str,col)) else: print "Unexpected type found: ",type(col) print "Value:",col raise ValueError("") cols.append(col) print "\t".join(cols) if __name__ == "__main__": main()