-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmerge_charges.py
59 lines (40 loc) · 1.28 KB
/
merge_charges.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
from pymol import cmd
def get_pos(selection):
pos_sel = []
for atom in cmd.get_model(selection).atom:
pos_sel.append([atom.coord[0], atom.coord[1], atom.coord[2]])
return pos_sel
file_name = "session_chlorine_minus1"
cmd.reinitialize()
cmd.load(file_name + ".pse", partial=1)
cmd.translate([-100,-100,-100],"complex",-1,0)
selections = cmd.get_names("all")
print(selections)
c=0
for selection in selections:
if "x0_y8_z8" in selection:
lim1 = c
if "x1_y-1_z-1" in selection:
lim2 = c
if "x2_y-1_z-1" in selection:
lim3 = c
if "x9_y8_z8" in selection:
lim4 = c
c+=1
selections_back = selections[0:lim1] + selections[lim2:lim3]
selections_circ= selections[lim3:lim4+1]+ selections[lim1:lim2]
print(selections_circ)
cmd.select("charges_circ",selections_circ[0])
for selection in selections_circ:
cmd.select("charges_circ",selection+ " or charges_circ")
cmd.select("charges_back",selections_back[0])
for selection in selections_back:
cmd.select("charges_back",selection+" or charges_back")
cmd.create("charges_backbone","charges_back")
cmd.create("charges_circle","charges_circ")
cmd.translate([100,100,100],"complex",-1,0)
for selection in selections_back:
cmd.delete(selection)
for selection in selections_circ:
cmd.delete(selection)
cmd.save(file_name+"_merged.pse")