-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkari.py
executable file
·69 lines (65 loc) · 2.76 KB
/
kari.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python
#=========================================================================
# This is OPEN SOURCE SOFTWARE governed by the Gnu General Public
# License (GPL) version 3, as described at www.opensource.org.
# Copyright (C)2021 William H. Majoros <[email protected]>
#=========================================================================
from __future__ import (absolute_import, division, print_function,
unicode_literals, generators, nested_scopes, with_statement)
from builtins import (bytes, dict, int, list, object, range, str, ascii,
chr, hex, input, next, oct, open, pow, round, super, filter, map, zip)
# The above imports should allow this program to run in both Python 2 and
# Python 3. You might need to update your version of module "future".
import sys
import ProgramName
from Pipe import Pipe
from Rex import Rex
rex=Rex()
def getNaiveEstimate(ref1,alt1,ref2,alt2,ref3,alt3):
ref1=float(ref1); alt1=float(alt1)
ref2=float(ref2); alt2=float(alt2)
ref3=float(ref3); alt3=float(alt3)
ref=ref1+ref2+ref3
alt=alt1+alt2+alt3
af=alt/(alt+ref)
return round(af,3)
#=========================================================================
# main()
#=========================================================================
if(len(sys.argv)!=2):
exit(ProgramName.get()+" <data.txt>\n")
(infile,)=sys.argv[1:]
with open(infile,"rt") as IN:
header=IN.readline()
for line in IN:
fields=line.rstrip().split("\t")
n=len(fields)
if(n!=14): continue
(ID,v,output3_ref,output3_alt,output2_ref,output2_alt,output1_ref,
output1_alt,input3_ref,input3_alt,input2_ref,input2_alt,input1_ref,
input1_alt)=fields
fields=(ID,3,input3_ref,input3_alt,input2_ref,input2_alt,input1_ref,
input1_alt,3,output3_ref,output3_alt,output2_ref,output2_alt,
output1_ref,output1_alt)
naiveQ=getNaiveEstimate(output3_ref,output3_alt,output2_ref,
output2_alt,output1_ref,output1_alt)
naiveP=getNaiveEstimate(input3_ref,input3_alt,input2_ref,
input2_alt,input1_ref,input1_alt)
fields=[str(x) for x in fields]
line="\t".join(fields)
OUT=open("temp.txt","wt")
print(line,file=OUT)
OUT.close()
cmd="git/bird2.py git/BIRD 1.2 temp.txt 1000 0-1"
pipe=Pipe(cmd)
header=pipe.readline()
output=None
while(True):
line=pipe.readline()
if(line is None): break
if(rex.find("Informational",line)): continue
if(rex.find("Exception",line)): continue
if(rex.find("warning",line)): continue
output=line
pipe.close()
print(v,naiveP,naiveQ,output,sep="\t")