forked from Pymol-Scripts/Pymol-script-repo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gridbox.py
113 lines (94 loc) · 2.9 KB
/
gridbox.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
# Copyright (c) 2014 Chen Zhaoqiang DDDC SIMM
#qq 744891290 qqgroup 144539789
# A PyMOL script for drawing a CGO box by the coordinate of the center,and the size of box
#center_x,center_y,center_z,size_x,size_y,size_z,
import pymol
from pymol import cmd
from pymol.wizard import Wizard
from chempy import cpv
from pymol.cgo import *
def gridbox(center_x,center_y,center_z,size_x,size_y,size_z,name="gridbox",r1=0,g1=0,b1=1,trasp=0.2):
"""
DESCRIPTION
Create a box from the center coordinate of the box and the size of box
USAGE
run gridbox.py
1the simplest
gridbox center_x,center_y,center_z,size_x,size_y,size_z
2rename the box object
gridbox center_x,center_y,center_z,size_x,size_y,size_z,name,
3set the color of the box object
gridbox center_x,center_y,center_z,size_x,size_y,size_z,name,r1,g1,b1
4set the trasp of the box
gridbox center_x,center_y,center_z,size_x,size_y,size_z,name,r1,g1,b1,trasp
ps:the value of r1,g1,b1 trasp range is 0-1
trasp=1,no trasprent
"""
center_x=float(center_x)
center_y=float(center_y)
center_z=float(center_z)
size_x=float(size_x)
size_y=float(size_y)
size_z=float(size_z)
r1=float(r1)
g1=float(g1)
b1=float(b1)
trasp=float(trasp)
p1=[center_x-size_x/2,center_y-size_y/2,center_z+size_z/2]
p2=[center_x-size_x/2,center_y+size_y/2,center_z+size_z/2]
p3=[center_x+size_x/2,center_y+size_y/2,center_z+size_z/2]
p4=[center_x+size_x/2,center_y-size_y/2,center_z+size_z/2]
p5=[center_x-size_x/2,center_y-size_y/2,center_z-size_z/2]
p6=[center_x-size_x/2,center_y+size_y/2,center_z-size_z/2]
p7=[center_x+size_x/2,center_y+size_y/2,center_z-size_z/2]
p8=[center_x+size_x/2,center_y-size_y/2,center_z-size_z/2]
obj=[
ALPHA,trasp,
COLOR,r1,g1,b1,
BEGIN, TRIANGLE_STRIP,
VERTEX,p1[0],p1[1],p1[2],
VERTEX,p2[0],p2[1],p2[2],
VERTEX,p4[0],p4[1],p4[2],
VERTEX,p3[0],p3[1],p3[2],
END,
BEGIN, TRIANGLE_STRIP,
# COLOR,1,0,0,
VERTEX,p1[0], p1[1], p1[2],
VERTEX,p5[0], p5[1], p5[2],
VERTEX,p4[0], p4[1], p4[2],
VERTEX,p8[0], p8[1], p8[2],
END,
BEGIN, TRIANGLE_STRIP,
VERTEX,p4[0],p4[1],p4[2],
VERTEX,p8[0],p8[1],p8[2],
VERTEX,p3[0],p3[1],p3[2],
VERTEX,p7[0],p7[1],p7[2],
END,
BEGIN, TRIANGLE_STRIP,
VERTEX,p7[0],p7[1],p7[2],
VERTEX,p3[0],p3[1],p3[2],
VERTEX,p6[0],p6[1],p6[2],
VERTEX,p2[0],p2[1],p2[2],
END,
BEGIN, TRIANGLE_STRIP,
# COLOR,0,1,0,
VERTEX,p2[0],p2[1],p2[2],
VERTEX,p6[0],p6[1],p6[2],
VERTEX,p1[0],p1[1],p1[2],
VERTEX,p5[0],p5[1],p5[2],
END,
BEGIN, TRIANGLE_STRIP,
VERTEX,p1[0],p1[1],p1[2],
VERTEX,p5[0],p5[1],p5[2],
VERTEX,p4[0],p4[1],p4[2],
VERTEX,p8[0],p8[1],p8[2],
END,
BEGIN, TRIANGLE_STRIP,
VERTEX,p5[0],p5[1],p5[2],
VERTEX,p8[0],p8[1],p8[2],
VERTEX,p6[0],p6[1],p6[2],
VERTEX,p7[0],p7[1],p7[2],
END,
]
cmd.load_cgo(obj, name)
cmd.extend('gridbox', gridbox)