File: vcfnulldotslashdot

package info (click to toggle)
libvcflib 1.0.0~rc2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 51,048 kB
  • sloc: cpp: 30,004; perl: 474; sh: 247; makefile: 206; python: 200; ansic: 148
file content (22 lines) | stat: -rwxr-xr-x 626 bytes parent folder | download
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)