Ben,
As noted, PyMOL can already read XTCs via the VMD plugins. However, your
question is a good one: How can one update coordinates directly from
Python?
Unfortunately, there isn't an optimal way to do this yet, but here is one
way:
# example .py file for PyMOL
from pymol import cmd, stored
# force PyMOL to keep the input atom ordering
cmd.set("retain_order")
# load a PDB file
cmd.load("$TUT/1hpv.pdb","mov")
# create a new state 2 (copy of state 1)
cmd.create("mov","mov",1,2)
# get the coordinates from state 2 into a Python list
stored.list = []
cmd.iterate_state(2,"mov","stored.list.append([x,y,z])")
# create a modified list of coordinates
new_list = []
for xyz in stored.list: \
new_list.append([xyz[0]*0.7,xyz[1]*0.7, xyz[2]*0.7])
stored.list = new_list
# update the state 2 coordinates inside PyMOL
stored.list.reverse()
cmd.alter_state(2,"mov","(x,y,z)=stored.list.pop()")
# and rebuild the graphics objects
cmd.rebuild("mov")
Cheers,
Warren
--
DeLano Scientific LLC
Subscriber Support Services
mailto:[email protected]
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf
> Of Benjamin Hall
> Sent: Thursday, May 01, 2008 3:07 AM
> To: [email protected]
> Subject: [PyMOL] Adding new states from data
>
> Hi
>
> I've written an XTC (gromacs trajectory) reader in python,
> and I'm interested in using it to load xtc files in pymol.
> The file itself doesn't contain any atom/residue name
> information, just a list of coordinates compressed using a
> novel compression algorithm. How could I manually add a state
> to a model, replicate the metadata from the first state, then
> add the coordinate information from a frame? I couldn't see
> how to do this from the wiki
>
> Many thanks in advance
>
> Ben
>
>
> **************************************************************
> **********
> Benjamin A. Hall
> Structural Bioinformatics & Computational Biochemistry Unit
> University of Oxford http://sbcb.bioch.ox.ac.uk/hall.php
> +44 (0)1865 275380
> [email protected]
>
>
>
>
>
> --------------------------------------------------------------
> -----------
> This SF.net email is sponsored by the 2008 JavaOne(SM)
> Conference Don't miss this year's exciting event. There's
> still time to save $100.
> Use priority code J8TL2D2.
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java
> .sun.com/javaone
> _______________________________________________
> PyMOL-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pymol-users