-
-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathSpliceosome_PyMOL.py
More file actions
executable file
·167 lines (148 loc) · 6.68 KB
/
Spliceosome_PyMOL.py
File metadata and controls
executable file
·167 lines (148 loc) · 6.68 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
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
import matplotlib.pyplot as plt # to start
import pandas as pd
import matplotlib.pyplot as plt
plt.style.use('classic')
import numpy as np
import sys
"""version when the same protein gets SMD2_2 and SMD2_1"""
f = "/Users/magnus/work-src/rna-tools/rna_tools/tools/PyMOL4RNA/Spliceosome_PyMOL.xlsx"
df = pd.read_excel(f)
strucs = [
['S1_B_5zwo', '5zwo', '_B5zwo'],
['S2_Bact_5gm6', '5gm6', '_Ba5gm6'],
['S3_C_5lj3', '5lj3', '_C5lj3'],
['S4_Cstar_5mps', '5mps', '_Cs5mps'],
['S5_P_6exn', '6exn', '_P6exn'],
['S5_P_5ylz', '5ylz', '_P5ylz'],
['S6_ILS_5y88', '5y88', '_I5y88'],
['SX_pX_3jb9', '3jb9', '_3jb9'],
['S6_hP_6icz', '6icz', '_hP_6icz'],
['hBa_6ff7', '6ff7', '_hBa_6ff7'],
['hC_5yzg', '5yzg', '_hC_5yzg'],
['hX_5xjc', '5xjc', '_hX_5xjc'],
['yCs_5mq0', '5mq0', '_yCs_5mq0'],
['yC_5lj5', '5lj5', '_yC_5lj5'],
['yPre_6g90', '6g90', '_yPre_6g90'],
['yE_6n7r', '6n7r', '_yE_6n7r'],
['yE_6n7p', '6n7p', '_yE_6n7p'],
]
strs = []
for s in strucs:
strs.append(s[1])
strs = str(strs) #strs = "['5gm6', '5zwo', '5lj3', '5gm6', '5mps', '6exn', '5ylz', '5y88', '3jb9', '6icz']"
#strucs = [['S3_C_5lj3', '5lj3']] # for debugging
txt = """
try:
from pymol import cmd
except ImportError:
print("PyMOL Python lib is missing")
# sys.exit(0)
def spl_extract():
for name in cmd.get_names("all"):
#if name in """ + strs + """: # this should be auto
print(" \ Extracting mode for %s" % name)
"""
for struc_col, pdb_id, complex_code in strucs:
txt += " if '" + pdb_id + "' in name.lower():\n"
for index, i in df.iterrows():
#print(i)
ref = str(i['chain']).strip()
struc = str(i[struc_col]).strip()
# print(ref, struc)
# todo fix cmd.extract("CDC40 (PRP17, SLU4, XRS2)", "chain n")
i['protein'] = i['protein'].split()[0]
if struc != 'nan' and struc != '-': # if ref != 'nan' # i dont' use reference chain any more
if ',' in struc:
subchains = struc.split(',') # a,P,h
for index , sc in enumerate(subchains):
sc = sc.strip()
# cmd.extract(name, selection, source_state, target_state)
txt += ' cmd.extract("' + i['protein'] + '_' + str(index + 1) + complex_code + '", "chain ' + sc + ' and ' + pdb_id + '")\n'
# one mode to see these two proteins
#print(' cmd.extract("' + i['protein'] + '", "chain ' + '+'.join(subchains) + '")')
else:
#if ref != struc:
txt += ' cmd.extract("' + i['protein'] + complex_code + '", "chain ' + struc + ' and ' + pdb_id + '")\n'
# the rest make unkown at the very end
txt += ' cmd.set_name("' + pdb_id + '", "unknown_other' + complex_code + '")\n'
txt += ' cmd.group("' + complex_code.replace('_', '') + '", "*' + complex_code + '")\n'
txt += ' cmd.do("order *, yes")\n'
print(txt)
with open('/home/magnus/work-src/rna-tools/rna_tools/tools/PyMOL4RNA/code_for_spl.py', 'w') as f:
f.write(txt)
# In[113]:
txt = """
try:
from pymol import cmd
except ImportError:
print("PyMOL Python lib is missing")
# sys.exit(0)
def spl_color():
for name in cmd.get_names("all"):
# cmd.do('color grey50') # off gray
if name in """ + strs + """: # this should be auto
print(" \ Extracting mode for %s" % name)
"""
for struc_col, pdb_id, complex_code in strucs:
txt += " if '" + pdb_id + "' in name.lower():\n"
for index, i in df.iterrows():
ref = str(i['chain']).strip()
struc = str(i[struc_col]).strip()
# print(ref, struc)
# todo fix cmd.extract("CDC40 (PRP17, SLU4, XRS2)", "chain n")
i['protein'] = i['protein'].split()[0]
if struc != 'nan' or struc != '-': # if ref != 'nan' # i dont' use reference chain any more
if ',' in struc:
subchains = struc.split(',') # a,P,h
for index , sc in enumerate(subchains):
sc = sc.strip()
# cmd.extract(name, selection, source_state, target_state)
txt += ' cmd.do("color ' + i['color'] + ', chain ' + sc + ' and ' + pdb_id + '")\n'
# one mode to see these two proteins
#print(' cmd.extract("' + i['protein'] + '", "chain ' + '+'.join(subchains) + '")')
else:
#if ref != struc:
txt += ' #' + i['protein'] +'\n'
try:
txt += ' cmd.do("color ' + i['color'] + ', chain ' + struc + ' and ' + pdb_id + '")' + '\n'
except TypeError:
print('Color entry is missing for ' + i['protein'])
sys.exit(1)
# color <object>
txt += ' cmd.do("color ' + i['color'] + ', ' + i['protein'] + complex_code + '")\n'
print(txt)
with open('/home/magnus/work-src/rna-tools/rna_tools/tools/PyMOL4RNA/code_for_color_spl.py', 'w') as f:
f.write(txt)
#strucs = [['S3_C_5lj3', '5lj3']] # for debugging
txt = """
try:
from pymol import cmd
except ImportError:
print("PyMOL Python lib is missing")
# sys.exit(0)
def spl_color():
#cmd.do('color grey50') # PRP8
"""
for struc_col, pdb_id, complex_code in strucs:
txt += ' if True: # fake if, just a quick hack\n'
for index, i in df.iterrows():
ref = str(i['chain']).strip()
struc = str(i[struc_col]).strip()
# print(ref, struc)
# todo fix cmd.extract("CDC40 (PRP17, SLU4, XRS2)", "chain n")
i['protein'] = i['protein'].split()[0]
if struc != 'nan' and struc != '-': # if ref != 'nan' # i dont' use reference chain any more
if ',' in struc:
subchains = struc.split(',') # a,P,h
for index , sc in enumerate(subchains):
sc = sc.strip()
# cmd.extract(name, selection, source_state, target_state)
txt += ' cmd.do("color ' + i['color'] + ', ' + i['protein'] + '_' + str(index + 1) + complex_code + '")\n'
# one mode to see these two proteins
#print(' cmd.extract("' + i['protein'] + '", "chain ' + '+'.join(subchains) + '")')
else:
#if ref != struc:
txt += ' cmd.do("color ' + i['color'] + ', ' + i['protein'] + complex_code + '")\n'
print(txt)
with open('/home/magnus/work-src/rna-tools/rna_tools/tools/PyMOL4RNA/code_for_color_spl_objects.py', 'w') as f:
f.write(txt)