| 1 | # Change atom coordinates so that model so that a z vector specified with 3 numbers becomes the z-axis,
|
|---|
| 2 | # and a y-vector goes to the yz-plane and a specified point goes to the origin.
|
|---|
| 3 | #
|
|---|
| 4 | # runscript orient.py #3 .7,.2,.12 -0.1,.2,.8 22.3,44.5,-19.0
|
|---|
| 5 | #
|
|---|
| 6 | # Arguments are z, y and origin in coordinates of the specified model. Axes vectors need not be normalized.
|
|---|
| 7 |
|
|---|
| 8 | def move_atoms(mnum, zarg, yarg, oarg):
|
|---|
| 9 | mid = int(mnum.lstrip('#'))
|
|---|
| 10 | from chimera import openModels, Molecule
|
|---|
| 11 | mlist = openModels.list(id = mid, modelTypes = [Molecule])
|
|---|
| 12 |
|
|---|
| 13 | z = [float(v) for v in zarg.split(',')]
|
|---|
| 14 | y = [float(v) for v in yarg.split(',')]
|
|---|
| 15 | o = [float(v) for v in oarg.split(',')]
|
|---|
| 16 |
|
|---|
| 17 | import Matrix as M
|
|---|
| 18 | xa, ya, za = M.orthonormal_frame(z, y)
|
|---|
| 19 | f = ((xa[0],ya[0],za[0],o[0]),
|
|---|
| 20 | (xa[1],ya[1],za[1],o[1]),
|
|---|
| 21 | (xa[2],ya[2],za[2],o[2])) # Map standard axes to specified ones.
|
|---|
| 22 | finv = M.invert_matrix(f)
|
|---|
| 23 | xfinv = M.chimera_xform(finv)
|
|---|
| 24 |
|
|---|
| 25 | for m in mlist:
|
|---|
| 26 | for a in m.atoms:
|
|---|
| 27 | a.setCoord(xfinv.apply(a.coord()))
|
|---|
| 28 |
|
|---|
| 29 | if len(arguments) != 4:
|
|---|
| 30 | from chimera import replyobj
|
|---|
| 31 | replyobj.status('Requires 4 arguments <model-id> <z-axis> <y-axis> <origin>')
|
|---|
| 32 | else:
|
|---|
| 33 | mnum, zarg, yarg, oarg = arguments
|
|---|
| 34 | move_atoms(mnum, zarg, yarg, oarg)
|
|---|