Skip to content

Commit 6712584

Browse files
authored
Create get_box.py
1 parent bef1790 commit 6712584

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

plugins/get_box.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
from pymol import cmd
2+
import numpy as np
3+
4+
5+
@cmd.extend
6+
def get_box(box_sel, box_margin):
7+
"""
8+
Create a box (useful for VINA or DOCKTHOR).
9+
USAGE:
10+
get_box sel, margin
11+
EXAMPLE:
12+
get_box resn CU and chain A, 5
13+
14+
"""
15+
box_margin = int(box_margin)
16+
17+
box_coords = cmd.get_coords(box_sel)
18+
19+
max = np.max(box_coords, axis=0) + box_margin
20+
min = np.min(box_coords, axis=0) - box_margin
21+
22+
half_size = (max - min) / 2
23+
center = min + half_size
24+
25+
size_x, size_y, size_z = half_size * 2
26+
center_x, center_y, center_z = center
27+
28+
size_x, size_y, size_z = (
29+
round(float(size_x), 2),
30+
round(float(size_y), 2),
31+
round(float(size_z), 2),
32+
)
33+
34+
center_x, center_y, center_z = (
35+
round(float(center_x), 2),
36+
round(float(center_y), 2),
37+
round(float(center_z), 2),
38+
)
39+
print("Size:", size_x, size_y, size_z)
40+
print("Center:", center_x, center_y, center_z)

0 commit comments

Comments
 (0)