[chimera-dev] [Chimera-users] Motion of an atom
Eric Pettersen
pett at cgl.ucsf.edu
Wed Jul 11 10:52:01 PDT 2012
Hi Raju,
Executing the code you sent below does not hang for me, so I don't know what that issue is. There are two other problems. One is that you are changing the Z coordinate, which moves the atom in/out of the screen, not left/right or up/down, so the motion may be hard to see. Second is that there is some kind of bad interaction between Idle and the wait() call. If you put your code into a script and execute it you can see the motion fine, but if you run the code in Idle you only see the start and end positions.
--Eric
On Jul 11, 2012, at 5:23 AM, Raju Purohit wrote:
> wait function doesn't seem to help. If I use wait(<some positive integer>), python stops executing ahead and hangs. If I use wait(<zero or some negative integer>), the code runs ignoring wait.
>
> This is my program:
> I have defined a variable atom1 which is an atom in chimera. Then I execute this program:
>
> >>> atom1.setCoord(chimera.Point(0,0,0));
> >>> for i in range(5):
> time.sleep(0.1);
> atom1.setCoord(chimera.Point(0,0,i));
> wait(1);
>
> I was expecting to see the atom move by 1 unit every loop but that does not happen. What would you suggest me to insert in this for loop so that the value on atom1 is updated in chimera?
>
> Thank you.
>
> On Tue, Jul 10, 2012 at 7:22 PM, Eric Pettersen <pett at cgl.ucsf.edu> wrote:
> Hi Raju,
> During the execution of a Python script, Chimera does not redraw the graphics screen until explicitly requested or when the script ends. The simplest way to ask for a redraw is to execute the "wait 1" Chimera command, which you can do from Python with:
>
> from chimera import runCommand
> runCommand("wait 1")
>
> So if you embed that in your loop you should be able to see your atom move. Frames are redrawn at a rate of 25 per second (though future versions of Chimera may allow faster redraw rates), so you may want to wait more than 1 frame if the atoms moves too fast.
> Alternatively, there is also a direct Python call to wait():
>
> from Midas import wait
> wait(1)
>
> FYI, there is another mailing list, chimera-dev, where programming-intensive questions like this one are more appropriate, so that the regular user's eyes don't glaze over. :-)
>
> --Eric
>
> Eric Pettersen
> UCSF Computer Graphics Lab
> http://www.cgl.ucsf.edu
>
> On Jul 10, 2012, at 9:07 AM, Raju Purohit wrote:
>
>> Hello friends,
>>
>> I need some help here.
>>
>> I created a basic model having just an atom and set its coordinates as (0,0,0). Now I want to make it move along a certain path defined mathematically (say, along x axis) and I need to see it move. So I used a for loop. But I couldn't see and motion and soon realised that the loop is very quick in executing and thus I could see the atom at its last coordinates. So I tried to add delay of 0.5 seconds for each loop by importing time module and useing time.sleep. But still I couldn't see any motion and the coordinates of the atom is set only at the end of the for loop. I could not see the intermediate path. I am sure you people must have tried this earlier and this problem has a solution but I just couldn't figure it out.
>>
>> Can you please help me out?
>>
>> Thank you in advance.
>>
>> --
>> Raju R.N.
>> Third Year, B.Tech
>> Mechanical Engineering
>> National Institute of Technology Karnataka, Surathkal
>>
>> _______________________________________________
>> Chimera-users mailing list
>> Chimera-users at cgl.ucsf.edu
>> http://www.rbvi.ucsf.edu/mailman/listinfo/chimera-users
>
>
>
>
>
>
> --
> Raju R.N.
> Third Year, B.Tech
> Mechanical Engineering
> National Institute of Technology Karnataka, Surathkal
>
> _______________________________________________
> Chimera-dev mailing list
> Chimera-dev at cgl.ucsf.edu
> http://www.rbvi.ucsf.edu/mailman/listinfo/chimera-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-dev/attachments/20120711/3d4ceec3/attachment.html>
More information about the Chimera-dev
mailing list