Hi Pymol users,

I posted a question last week (attached below) that didn't generate any responses so I'm thinking maybe I was being too specific. So I'd like to restate the problem in a much more general way: I'm trying to apply a set of shifts sequentially from a numpy array to each atom in the structure. The basic way I try to do this is:

   cmd.load( "../4lzt_quasi.pdb", "full")
   cmd.create("anew", "full", 1, 1)
   cmd.alter_state(1,"anew" , "x,y,z = x+nm[(ID-1)*3],
   y+nm[(ID-1)*3+1], z+nm[(ID-1)*3+2]")


but it seems that the create command changes the IDs of the atoms so that the shifts are now applied to the wrong atoms (eg a CA atom with ID=5 has ID=1 in the newly created object).

So the question is:

- does anyone know how and why the ID's are change? (then I could reorder the shifts in my array to match the new object)
    - or is there a better way to apply shifts to the atoms?

Thanks!
Pawel



-------- Original Message --------
Subject:        Re: [PyMOL] discrepancy between python and commandline script
Date:   Fri, 08 Nov 2013 07:30:28 -0500
From:   Pawel <pawe...@gmail.com>
To:     Pawel Janowski <pawe...@gmail.com>, pymol-users@lists.sourceforge.net



Hi,

I've continued to investigate and have gotten even more confused. This script:

   from numpy import *
   import sys

   cmd.delete("all")
   cmd.load( "../4lzt_quasi.pdb", "full")
   cmd.create("anew", "full", 1, 1)
   print "First 3 shifts: ", nm[0:3], "\n"
   cmd.alter_state(1,"anew" , "x,y,z = x+nm[(ID-1)*3],
   y+nm[(ID-1)*3+1], z+nm[(ID-1)*3+2]")

   xyz1=[]
   cmd.iterate_state(1, 'full & id 5', 'xyz1.append([x,y,z])')
   xyz2=[]
   cmd.iterate_state(1, 'anew & id 1', 'xyz2.append([x,y,z])')
   print "Coords of full id 5:", array(xyz1)
   print "Coords of anew id 1:",  array(xyz2)
   print "Shift between full id5 and anew id1:",
   array(xyz1)-array(xyz2), "\n"

   xyz1=[]
   cmd.iterate_state(1, 'full & resid 1 & name ca ',
   'xyz1.append([x,y,z])')
   xyz2=[]
   cmd.iterate_state(1, 'anew & resid 1 & name ca ',
   'xyz2.append([x,y,z])')
   print "Coords of full resid1 name ca: ", array(xyz1)
   print "Coords of full resid1 name ca: ", array(xyz2)
   print "Shift between full id5 and anew id1: ", array(xyz1)-array(xyz2)
   print "\n"


yields:

   PyMOL>run pymoltest1.py
   First 3 shifts:  [-0.1263  0.0152 -0.0444]

   Coords of full id 5: [[  2.539   5.619  12.706]]
   Coords of anew id 1: [[  2.4127   5.6342  12.6616]]
   Shift between full id5 and anew id1: [[ 0.1263 -0.0152  0.0444]]

   Coords of full resid1 name ca:  [[  2.539   5.619  12.706]]
   Coords of full resid1 name ca:  [[  2.4127   5.6342  12.6616]]
   Shift between full id5 and anew id1:  [[ 0.1263 -0.0152 0.0444]]

What I see from this is:
- the first set of shifts is applied to the CA atom which is the fifth atom in the original pdb file and somehow becomes the second atom in the object created with cmd.create - the object created by cmd.create has atom id's spanning from 0 to N-1 (original object had atom ids from 1 to N)

I would like to know what is happening but, more importantly, what is the best way to apply the shifts vector "nm" to the atoms in the original object where the shifts in "nm" are according to the order in the pdb file.

Thanks!
Pawel





-------- Original Message --------
Subject:        discrepancy between python and commandline script
Date:   Thu, 07 Nov 2013 18:55:17 -0500
From:   Pawel <pawe...@gmail.com>
To:     pymol-users@lists.sourceforge.net



Hello,

I'm trying to understand what seems like an inconsistency between PyMOL commandline and python scripts. I have the following commandline script:

   delete all
   load ../4lzt_quasi.pdb, full
   cmd.create("anew", "full", 1, 1)
   cmd.alter_state(1,"anew" , "x,y,z = x+nm[(ID-1)*3],
   y+nm[(ID-1)*3+1], z+nm[(ID-1)*3+2]")
   iterate_state 1, full & id 1, print x, y,z
   iterate_state 1, anew & id 1, print x, y,z

Which I then run:

   PyMOL>@pymoltest1.txt
   ...
   PyMOL>iterate_state 1, full & id 1, print x, y,z
   2.69099998474 4.58500003815 13.6999998093
     IterateState: iterated over 1 atom coordinate states.
   PyMOL>iterate_state 1, anew & id 1, print x, y,z
   2.41267466545 5.63420581818 12.6615524292
     IterateState: iterated over 1 atom coordinate states.

Now I have this python script:

   cmd.delete( all)
   cmd.load( "../4lzt_quasi.pdb", "full")
   cmd.create("anew", "full", 1, 1)
   cmd.alter_state(1,"anew" , "x,y,z = x+nm[(ID-1)*3],
   y+nm[(ID-1)*3+1], z+nm[(ID-1)*3+2]")
   xyz1=[]
   cmd.iterate_state(1, 'full & id 1', 'xyz1.append([x,y,z])')
   xyz2=[]
   cmd.iterate_state(1, 'anew & id 1', 'xyz2.append([x,y,z])')
   print xyz1
   print xyz2

Which I run:

   PyMOL>run pymoltest1.py
   [[2.690999984741211, 4.585000038146973, 13.699999809265137]]
   [[2.5646746158599854, 4.600205898284912, 13.65555191040039]]

Why am I getting different coordinates for the second atom? The second set of coordinates from the first script are actually the coordinates of the 5th atom in my structure (CA of a LYS). I'm guessing that the alter_state command is somehow doing something different in one and the other case but it's hard to understand why.

Thanks for the help,
Pawel






------------------------------------------------------------------------------
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
_______________________________________________
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net

Reply via email to