Yes, there definitely was an error in the quotes... And thank you for the insight in the parenthesis, actually it works without, I was not able to figure it out.... So the script for i in pdb_names: stored.xyz = [] cmd.iterate_state(1,("%s and name fe" %(i)),"stored.xyz.append([x,y,z])") a=stored.xyz[0][0] b=stored.xyz[0][1] c=stored.xyz[0][2] cmd.alter_state ("1",("%s" %(i)),"x,y,z=x-a,y-b,z-c") cmd.alter_state ("1",("%s-h" %(i)),"x,y,z=x-a,y-b,z-c") now works fine... But I still have the strange thing with the y displacement. If I run the script and I check the fe position (set as the reference one): PyMOL>iterate_state 1,1AW3 and name fe,(x,y,z) (0.0, 9.5340003967285156, 0.0) So the y position has not change while the x and z have shifted....
Strange, no? Hi, Firstly, I can see why there is a syntax error for the alter_state command: cmd.alter_state ("1",("1AW3 and name fe"),((x,y,z)=(x-a,y-b,z-c))") has the quotes in the wrong place. I guess it should be: cmd.alter_state("1","(1AW3 and name fe)","((x,y,z)=(x-a,y-b,z-c))") I can make every atom move by saying: cmd.alter_state("1", "my_structure", "x, y, z = x + 1, y + 1, z + 1") So, the "x,y,z=x-a,y-b,z-c" would probably work, too. I hadn't realised that variables in the current scope were accessible from the alter_state scope, too. gilleain On 6/19/07, Gilles Truan <gtr...@cg...> wrote: > Sorry for my first post, I just relaized it was kind of hard to read > with all the funny tags.... I am reposting for clarity!!! > I am trying to run a script to translate all pdb structures so that an > atom of the protein gets the coordinate (0,0,0) > I have written a small script for that: > > for i in pdb_names: > stored.xyz = [] > cmd.iterate_state(1,("%s and name fe" %(i)),"stored.xyz.append([x,y,z])") > a=stored.xyz[0][0] > b=stored.xyz[0][1] > c=stored.xyz[0][2] > cmd.alter_state ("1",("%s" %(i)),"x=x-a") > cmd.alter_state ("1",("%s" %(i)),"y=y-b") > cmd.alter_state ("1",("%s" %(i)),"z=z-c") > > First, I have not been able to translate all the coordinates at once > in the script with something like > cmd.alter_state ("1",("%s" %(i)),"((x,y,z)=(x-a,y-b,z-c))") > I get this error message > > cmd.alter_state ("1",("1AW3 and name fe"),((x,y,z)=(x-a,y-b,z-c))") > ^ > SyntaxError: invalid syntax > > This was overcome by affecting each value separately. But then, when I > check the coordinates of the fe atom that should be (0,0,0) all of > them have zero values for x and z, but ot for y!!!!!! > All the y values are unaffected!!! > > Is there something I am missing in the number format? When I check > coordinates via the cmd.iterate_state, I can see that most of them are > numbers with around 15 to 16 significative figures... where the pdb > file has only three figures!! Is there something that is added by the > iterate_state command, and might this could affect the calculation of > the translation? > > Thanks in advance for your answers ;)