-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathprepare4buildmodel.py
43 lines (32 loc) · 1.16 KB
/
prepare4buildmodel.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
import argparse
import numpy as np
import pandas as pd
parser = argparse.ArgumentParser(description='prepare for BuildModel in FoldX')
parser.add_argument("-i", '--input', help="input a txt file, a PS_pdbid_file.txt mostly")
parser.add_argument("-l", '--lines', help='number of lines you want')
args = parser.parse_args()
inf = args.input
lines = args.lines
def _3_2_1(x):
d = {'CYS': 'C', 'ASP': 'D', 'SER': 'S', 'GLN': 'Q', 'LYS': 'K',
'ILE': 'I', 'PRO': 'P', 'THR': 'T', 'PHE': 'F', 'ASN': 'N',
'GLY': 'G', 'HIS': 'H', 'LEU': 'L', 'ARG': 'R', 'TRP': 'W',
'ALA': 'A', 'VAL': 'V', 'GLU': 'E', 'TYR': 'Y', 'MET': 'M'}
y = d[x]
return y
def multi_sub(self, string, p, c):
new = []
for s in string:
new.append(s)
for index, point in enumerate(p):
new[point] = c[index]
return ''.join(new)
data = pd.read_table(inf, error_bad_lines=False, header=None)
sort_data = data.sort_values(by=[1])
part_data = sort_data.head(int(lines))
ofile = open('individual_list.txt', "w")
_list = np.array(part_data[0]).tolist()
for i in _list:
_3 = i[0:3]
mut = _3_2_1(_3) + i[3:len(i)] + ';'
print(mut, file=ofile)