modified: makefile
[GalaxyCodeBases.git] / tools / lh3misc / crap / denovo2vcf.lua
blobfa37ed47d70821e3516284acb8f1fa85cf5e3d3c
1 #!/usr/bin/env luajit
3 require('klib')
5 -- convert Conrad et al. (2011) validation table to VCF
7 for l in io.lines() do
8 local t = l:split('\t')
9 if t[1] ~= 'id' then
10 local c = {t[15], t[16], t[11], t[12], t[13], t[14], t[39], t[40], 0, 0}
11 for i = 17, 38, 2 do
12 c[9], c[10] = c[9] + t[i], c[10] + t[i+1]
13 end
14 local tmp = t[5]:match('"(%S+)"')
15 if tmp ~= nil then t[5] = tmp end
16 if t[2] == '23' then t[2] = 'X' end
17 local o = {t[2], t[3], t[1], t[4], t[5]}
18 print(table.concat(o, '\t'), 30, '.',
19 'Type='..t[50]..';FLT='..t[51]..';Set='..t[6]..t[7]..t[8]..';CpG='..t[49],
20 'CUM:CSC',
21 c[1]..','..c[2]..':'..t[41]..','..t[42],
22 c[3]..','..c[4]..':'..t[43]..','..t[44],
23 c[5]..','..c[6]..':'..t[45]..','..t[46],
24 c[9]..','..c[10]..':'..t[47]..','..t[48],
25 c[7]..','..c[8]..':0,0')
26 else
27 print('##fileformat=VCFv4.0')
28 print('#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tNA12878\tNA12891\tNA12892\tChildren\tNA12877')
29 end
30 end