Editing atoms
Jump to navigation
Jump to search
Altering atom coordinates
Example:
alter_state 1,(pdb1cse),x=x-10.0
The latter section can contain formulae involving at least the xyz coordinates, lots of constants and the (+-*/) operators.
Translate or rotate individual objects
There is a "translate" function similar to "rotate", the docs for these don't exist yet, because the implementation isn't finished. However, feel free to use them in the following forms:
translate vector,object-name,state
vector needs to be something like [x,y,z]
translate [1,0,0],pept
rotate axis,angle,object-name,state
axis can be either the letter x,y,z or a 3D vector [x,y,z]
rotate x,90,pept
rotate [1,1,1],10,pept
Get coordinates from Python
- The actual C-langauge arrays aren't exposed, but there are at least three different ways you can modify coordinates from within Python: You can get a python object which contains the molecular information, modify the coordinates in that object, load the modified molecule into PyMOL, update the modified coordinates to the original model, and then delete the modified object. (link to example)
- Another approach is the "alter_state" function, which can perform the same transformation in a single PyMOL command statement:
alter_state 1,pept,(x,y)=(-y,x)
Likewise sub-selections can be transformed as well:
alter_state 1,(pept and name ca),(x,y,z)=(x+5,y,z)
- A third approach is to use alter_state with the global "stored" object: Example in a Python script)
Approaches 2 gives the best performance, approach 3 gives more flexibility, and approach 1 gives you a reusable and fully modifiable Python object.