Pymol - Independent Rotation Axes For Multiple Molecules
2
2
Entering edit mode
14.0 years ago
hurfdurf ▴ 490

This seems like a simple pymol task. I have an arbitrary number (<10) of PDB files each with one molecule/protein. I would like to set them up as a "chorus line" rotating around their own Y axes. I can figure out all the movie.roll, movie export, and mset commands, but am stuck on getting each molecule its own axis to rotate around. Spacing each molecule equidistant along the x axis (regardless of size) would be a bonus.

pymol python • 9.5k views
ADD COMMENT
2
Entering edit mode
14.0 years ago

Note: the solution is a bit of a hack, there might be easier ways. Anyway, this sounds like an interesting project so when you manage to create an acceptable movie please consider hosting the code on github and linking it here.

The commands you are looking for are most likely translate and rotate. These can be called for each object seperately (object movement) and not just your whole scene (camera movement). You can use standard python code (ie., a loop to call the above functions with cmd.[?]function[?]) in the PyMOL prompt.

In order to have each molecule rotate around their own central Y axis you have to, for all your objects:

  1. Translate an object to the origin
  2. Rotate it the desired amount around the y axix
  3. Translate it back where you want it to be
  4. Save the configuration to a new state

Points 1 to 3 are needed because of the way positions and transformations of objects are calculated with matrix operations. The mmatrix command might help here.

And then finally create the movie using all your new states (see PyMOL's movie syntax).

edit: also see this tutorial

ADD COMMENT
0
Entering edit mode
6.3 years ago

Hello @hurfdurf, today I found this good resource that answers exactly to your topic: Rotation with two independent rotation centers.

Here the python code:

#Rotate two different objects 360 degrees aroung thier axes
#@frames: number of frames to animate (integer)
#@rotation_axis: axis to rotate the structure ('x', 'y' or 'z')
#@obj1: first object (protein molecule)
#@obj2: second object (protein molecule)
def two_roll (frames, rotation_axis, obj1, obj2):
    angle=360/frames        
    frame=1
    #Loop over frames, make small rotation to each object, 
    #ray trace the scene and save the image
    while frame <= frames:
        #Set rotation center to object1
        cmd.origin(obj1)
        #Rotate object1
        cmd.rotate(rotation_axis, angle, obj1)
        #Set rotation center to object2
        cmd.origin(obj2)
        #Rotate object2
        cmd.rotate(rotation_axis, angle, obj2)
        #Ray trace and save the image
        ray()
        frame+=1

enter image description here

Cheers

ADD COMMENT

Login before adding your answer.

Traffic: 2034 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6