1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
#!/usr/bin/env python
import sys
import math
def bincoeff(n,k): return math.factorial(n) / (math.factorial(n-k)*math.factorial(k))
def multcoeff(n,k): return bincoeff(n+k-1,k)
for line in sys.stdin:
if line.startswith("#"):
print line.strip()
continue
fields = line.strip().split("\t")
alleles = len(fields[4].split(","))+1
# assume that we have GT:GL
# how many genotypes? assume diploid
flatgls = ",".join(map(str,[0]*multcoeff(alleles,2)))
for i in range(9, len(fields)):
if fields[i] == ".":
fields[i] = "./.:" + flatgls
print "\t".join(fields)
|