Scripts: aniso.py

File aniso.py, 904 bytes (added by pett, 17 years ago)
Line 
1rgba = (1.0, 0.0, 0.0, 1.0)
2scale = 1.0
3
4def ellipsoid(surface, center, axes, lengths):
5 from Icosahedron import icosahedron_triangulation
6 varray, tarray = icosahedron_triangulation(subdivision_levels = 3,
7 sphere_factor = 1.0)
8 from numpy import dot, sqrt
9 ee = varray * sqrt(lengths)
10 ev = dot(ee, axes)
11 ev += center
12
13 surface.addPiece(ev, tarray, rgba)
14
15from chimera import selection, UserError, openModels
16atoms = [a for a in selection.currentAtoms() if hasattr(a, 'anisoU')]
17if not atoms:
18 raise UserError("No ANISOU atoms selected")
19
20perMol = {}
21for a in atoms:
22 perMol.setdefault(a.molecule, []).append(a)
23
24for m, matoms in perMol.items():
25 import _surface
26 sm = _surface.SurfaceModel()
27 sm.name = "ANISOU for %s" % m
28 from numpy.linalg import svd
29 for a in matoms:
30 ignore, vals, vecs = svd(a.anisoU)
31 vals *= scale
32 ellipsoid(sm, a.coord(), vecs, vals)
33 openModels.add([sm], sameAs=m)