Upload Sort_Dlkcat.py
Browse files- Sort_Dlkcat.py +39 -0
Sort_Dlkcat.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from tname import *
|
2 |
+
from Rfile import *
|
3 |
+
|
4 |
+
def Sort_Dlkcat(file):
|
5 |
+
contents = j_reads(file.name)
|
6 |
+
dlkcats = [] # 存储kcat值
|
7 |
+
# dlkcat sort
|
8 |
+
for i in range(2, len(contents)):
|
9 |
+
content = contents[i].split()
|
10 |
+
dlkcats.append(float(content[3]))
|
11 |
+
|
12 |
+
sorted_dlkcat = [] # 按kcat值从大到小对其索引进行排序
|
13 |
+
sorted_dlkcat = sorted(range(len(dlkcats)), key=lambda k: dlkcats[k], reverse=True)
|
14 |
+
|
15 |
+
name = Name()
|
16 |
+
name = name + r"kcat_sort.fa" # 结果文件名称
|
17 |
+
|
18 |
+
# 第一条序列单独写入
|
19 |
+
with open(name, "a") as f:
|
20 |
+
content = contents[1].split()
|
21 |
+
f.write(content[0])
|
22 |
+
f.write("\t")
|
23 |
+
f.write("Kcat value=")
|
24 |
+
f.write(content[3])
|
25 |
+
f.write("\n")
|
26 |
+
f.write(content[2])
|
27 |
+
f.write("\n")
|
28 |
+
for i in range(0, len(dlkcats)):
|
29 |
+
with open(name, "a") as f:
|
30 |
+
content = contents[sorted_dlkcat[i] + 2].split()
|
31 |
+
f.write(content[0])
|
32 |
+
f.write("\t")
|
33 |
+
f.write("Kcat value=")
|
34 |
+
f.write(content[3])
|
35 |
+
f.write("\n")
|
36 |
+
f.write(content[2])
|
37 |
+
f.write("\n")
|
38 |
+
|
39 |
+
return name
|