| 1 | rgba = (1.0, 0.0, 0.0, 1.0)
|
|---|
| 2 | scale = 1.0
|
|---|
| 3 |
|
|---|
| 4 | def 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 |
|
|---|
| 15 | from chimera import selection, UserError, openModels
|
|---|
| 16 | atoms = [a for a in selection.currentAtoms() if hasattr(a, 'anisoU')]
|
|---|
| 17 | if not atoms:
|
|---|
| 18 | raise UserError("No ANISOU atoms selected")
|
|---|
| 19 |
|
|---|
| 20 | perMol = {}
|
|---|
| 21 | for a in atoms:
|
|---|
| 22 | perMol.setdefault(a.molecule, []).append(a)
|
|---|
| 23 |
|
|---|
| 24 | for 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)
|
|---|