-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.py
More file actions
69 lines (62 loc) · 2.31 KB
/
script.py
File metadata and controls
69 lines (62 loc) · 2.31 KB
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
69
# -*- coding: utf-8 -*-
"""
Spyder Editor
"""
import os
import time
def Preprocessing(bench, file, path):
fileout = path +"/" + bench +"/in/"+ file
filein = path +"/"+ bench +"/in/"+ file
ret_list = []
flag = 0
filein_list = open(filein, 'r').read().splitlines()
for line in filein_list:
if len(line.strip()) > 0:
if line.strip()[0] == '>':
ret_list.append(line.strip())
flag = 0
else:
if flag == 0:
ret_list.append(line.strip())
flag = 1
else:
ret_list[len(ret_list) - 1] += line.strip()
with open(fileout, 'w') as fileout_:
for line in ret_list:
fileout_.write(line + "\n")
def Run(prom, bench, file, path, i):
f_t = os.path.exists("./output/" + bench)
if not f_t:
os.makedirs("./output/" + bench)
os.system("%s %s/%s/%s ./output/%s/%s" % (prom, path, bench + "/in", file, bench, file))
def Compute(prom):
path = "./TEST"
bench_list = os.listdir(path)
tmp_bench = []
total_time = []
for i in range(1):
for bench in bench_list:
if os.path.isdir(path + "/" + bench):
tmp_bench.append(bench)
tmp_time = 0.0
file_num = 0
file_list = os.listdir(path + "/" + bench + "/in/")
for fileidx in range(len(file_list)):
tmp_str = ""
if file_list[fileidx][0:1] == ".":
continue
file_num += 1
print("Start constructing No. %d protein family: %s ..." % (fileidx, bench + "/in/" + file_list[fileidx]))
start = time.time()
Run(prom, bench, file_list[fileidx], path, i)
end = time.time()
tmp_time += (end - start)
print("Finish constructing No. %d protein family." % (fileidx))
total_time.append(tmp_time / float(file_num))
return tmp_bench, total_time
if __name__ == "__main__":
if not os.path.exists("./output"):
os.system("mkdir ./output/")
tmp_bench, total_time = Compute("python ./MLProbs.py ")
for i in range(len(tmp_bench)):
print("%s: %f" % (tmp_bench[i], total_time[i]))