-
Notifications
You must be signed in to change notification settings - Fork 1
/
peptide level feature.py
202 lines (161 loc) · 6.62 KB
/
peptide level feature.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# coding: utf-8
import os
import sys
import pandas as pd
import glob
def extracts(file1,drec):
fname,filename = os.path.split(file1)
#nac.pyc 3 methods
if (not os.path.exists(drec + filename + "feature-kmer.csv")):
print("Kmer method")
os.system("python nac.pyc " + file1 + " Protein Kmer -out " + drec + filename + "feature-kmer.csv -f csv")
else:
pass
if (not os.path.exists(drec + filename + "feature-DR.csv")):
print("DR method")
os.system("python nac.pyc " + file1 + " Protein DR -out " + drec + filename + "feature-DR.csv -f csv")
else:
pass
if (not os.path.exists(drec + filename + "feature-DP.csv")):
print("DP method")
os.system("python nac.pyc " + file1 + " Protein DP -out " + drec + filename + "feature-DP.csv -f csv")
else:
pass
# acc.pyc 8 methods
if (not os.path.exists(drec + filename + "feature-AC.csv")):
print("AC")
os.system(r"python acc.pyc " + file1 + " Protein AC -out " + drec + filename + "feature-AC.csv -f csv")
else:
pass
if (not os.path.exists(drec + filename + "feature-CC.csv")):
print("CC")
os.system(r"python acc.pyc " + file1 + " Protein CC -out " + drec + filename + "feature-CC.csv -f csv")
else:
pass
if (not os.path.exists(drec + filename + "feature-ACC.csv")):
print("ACC")
os.system("python acc.pyc " + file1 + " Protein ACC -out " + drec + filename + "feature-ACC.csv -f csv")
else:
pass
if (not os.path.exists
(drec + filename + "feature-PDT.csv")):
print("PDT")
os.system("python acc.pyc " + file1 + " Protein PDT -out " + drec + filename + "feature-PDT.csv -f csv")
else:
pass
if (not os.path.exists(drec + filename + "feature-PC-PseAAC.csv")):
print("PC-PseAAC")
str1 = "python pse.pyc " + file1 + " Protein " + " -method PC-PseAAC -out " + drec + filename + "feature-PC-PseAAC.csv -f csv"
print(str1)
os.system(str1)
else:
pass
if (not os.path.exists(drec + filename + "feature-SC-PseAAC.csv")):
print("SC-PseAAC")
os.system("python pse.pyc " + file1 + " Protein -method SC-PseAAC -out " + drec + filename + "feature-SC-PseAAC.csv -f csv")
else:
pass
if (not os.path.exists(drec + filename + "feature-PC-PseAAC-General.csv")):
print("PC-PseAAC-General")
os.system(
r"python pse.pyc " + file1 + " Protein -method PC-PseAAC-General -out " + drec + filename + "feature-PC-PseAAC-General.csv -f csv")
else:
pass
if (not os.path.exists(drec + filename + "feature-SC-PseAAC-General.csv")):
print("SC-PseAAC-General")
os.system(
r"python pse.pyc " + file1 + " Protein -method SC-PseAAC-General -out " + drec + filename + "feature-SC-PseAAC-General.csv -f csv")
else:
pass
#profile.pyc 9 methods
if (not os.path.exists(drec + filename + "feature-AC-PSSM.csv")):
print("AC-PSSM ")
os.system(
r"python profile.pyc " + file1 + " AC-PSSM -out " + drec + filename + "feature-AC-PSSM.csv -f csv -cpu 6")
else:
pass
#print(filename, "AC-PSSM method has existed")
if (not os.path.exists(drec + filename + "feature-Top-n-gram.csv")):
print("Top-n-gram")
os.system(
"python profile.pyc " + file1 + " Top-n-gram -out " + drec + filename + "feature-Top-n-gram.csv -f csv -n 2 -cpu 6")
else:
pass
#print(filename, "Top-n-gram method has existed")
if (not os.path.exists(drec + filename + "feature-PDT-Profile.csv")):
print("PDT-Profile")
os.system(
"python profile.pyc " + file1 + " PDT-Profile -out " + drec + filename + "feature-PDT-Profile.csv -f csv -n 2 -cpu 6")
else:
pass
#print(filename, "PDT-Pofile method has existed")
if (not os.path.exists(drec + filename + "feature-CC-PSSM.csv")):
print("CC-PSSM")
os.system(
"python profile.pyc " + file1 + " CC-PSSM -out " + drec + filename + "feature-CC-PSSM.csv -f csv -cpu 6")
else:
pass
#print(filename, "CC-PSSM method has existed")
if (not os.path.exists(drec + filename + "feature-ACC-PSSM.csv")):
print("ACC-PSSM")
os.system(
"python profile.pyc " + file1 + " ACC-PSSM -out " + drec + filename + "feature-ACC-PSSM.csv -f csv -cpu 6")
else:
pass
#print(filename, "ACC-PSSM method has existed")
if (not os.path.exists(drec + filename + "feature-PSSM-DT.csv")):
print("PSSM-DT")
os.system(
"python profile.pyc " + file1 + " PSSM-DT -out " + drec + filename + "feature-PSSM-DT.csv -f csv -cpu 6")
else:
pass
#print(filename, "PSSM-DT method has existed")
if (not os.path.exists(drec + filename + "feature-PSSM-RT.csv")):
print("PSSM-RT")
os.system(
"python profile.pyc " + file1 + " PSSM-RT -out " + drec + filename + "feature-PSSM-RT.csv -f csv -cpu 6")
else:
pass
#print(filename, "PSSM-RT method has existed")
if (not os.path.exists(drec + filename + "feature-DT.csv")):
print("DT")
os.system(r"python profile.pyc " + file1 + " DT -out " + drec + filename + "feature-DT.csv -f csv -cpu 6")
else:
pass
def matchfiles(tmpdir,suffix): # 读取文件路径
###windows os
# f = glob.glob(tmpdir + '\\*.' + suffix)
###linux os
fi = []
filenames = []
#f = glob.glob(tmpdir + suffix)
f = glob.glob(tmpdir + '/*.' + suffix)
return f
# fileout = open(dir + '\\' + suffix + '.txt','wt')
#
# for tmpfile in f:
# fname, modfasta_filename = os.path.split(tmpfile)
# print modfasta_filename
# filenames.append(modfasta_filename)
# fi.append(filenames)
# return fi
def mkd(x):
if(os.path.exists(x)):
pass
else:
os.makedirs(x)
def extractfeatures(files,path):
path_,filename = os.path.split(path)
# a = path+"/method-feature/"
b = "Input_data/Input_data_feature"+"/"+filename+"/"
# mkd(a)
mkd(b)
for i in files:
extracts(i,b)
def main(argv):
path = argv[1]
f = matchfiles(path,"fasta")
extractfeatures(f,path)
if __name__ == '__main__':
main(sys.argv)
#f = matchfiles("C:/Users/fanfan/Desktop/bishe/SCOP167-superfamily/","pos-test.c.2.1.3.fasta")