Dynamic recalculation of clash score for a moving object. The real-valued clash score is then color-mapped onto the objects.
1 from PyQt5
import QtCore
6 class Anim(QtCore.QTimer):
7 def __init__(self, a, b):
8 QtCore.QTimer.__init__(self)
13 self.edi=self.a.view.handle.EditXCS(mol.UNBUFFERED_EDIT)
14 self.timeout.connect(self.OnTimer)
18 if self.angle>math.pi/2:
25 for a
in self.b.view.atoms:
26 score=mol.alg.ClashScore(a.handle, self.a.view)
27 a.SetFloatProp(
'clash', score)
28 self.a.UpdatePositions()
29 self.b.ReapplyColorOps()
32 def Hammer(off=geom.Vec3()):
33 ent=mol.CreateEntity()
34 edi=ent.EditXCS(mol.BUFFERED_EDIT)
35 chain=edi.InsertChain(
"A")
36 res=edi.AppendResidue(chain,
"QUAD")
37 a=edi.InsertAtom(res,
"A", off+
geom.Vec3(0.0, 0.0, 0.0),
"H")
38 b=edi.InsertAtom(res,
"B", off+
geom.Vec3(0.0, 4.0, 0.0),
"H")
39 c=edi.InsertAtom(res,
"C", off+
geom.Vec3(2.0, 4.0, 0.0),
"H")
40 d=edi.InsertAtom(res,
"D", off+
geom.Vec3(2.0, 5.0, 0.0),
"H")
41 e=edi.InsertAtom(res,
"E", off+
geom.Vec3(-2.0, 5.0, 0.0),
"H")
42 f=edi.InsertAtom(res,
"F", off+
geom.Vec3(-2.0, 4.0, 0.0),
"H")
52 ent=mol.CreateEntity()
53 edi=ent.EditXCS(mol.BUFFERED_EDIT)
54 chain=edi.InsertChain(
"A")
55 res=edi.AppendResidue(chain,
"QUAD")
57 for i
in range(-10, 10):
58 for j
in range(-10, 10):
60 atom=edi.InsertAtom(res,
"A%d" % index,
geom.Vec3(4.0, -2.0, 0.0)+
69 a_go=gfx.Entity(
"a", gfx.CUSTOM, a)
70 b_go=gfx.Entity(
"b", gfx.CUSTOM, b)
72 a.SetFloatProp(
'clash', 0.0)
80 grad.SetColorAt(0.0, gfx.Color(0.0, 1.0, 0.0))
81 grad.SetColorAt(0.5, gfx.Color(1.0, 0.0, 1.0))
82 grad.SetColorAt(1.0, gfx.Color(1.0, 0.0, 0.0))
83 b_go.ColorBy(
'clash', gfx.Color(0,1,0), gfx.Color(1,0,0), 0.0, 10.0, mol.Prop.Level.ATOM)
85 print(
'Demo 7: Illustrating a clash score')