Thank you very much,
It was very helpful since i did not find similar examples on the web that
combine this directives
Thanks again
Stéphane
----------------------------------------------------------
Envoyé : mardi 23 juin 2020 09:10
À : ABEL Stephane
Cc : Pedro Lacerda; pymol-users
Objet : Re: [PyMOL] Python script with iterate_state and selection command
Hi Stéphane,
Pedro is correct, you should change the selection like he suggested.
You also need to:
- Make a state specific selection with cmd.select(..., state=i)
- Adjust the loop to start at 1 and not at 0
- Use "stored.resid.append(resv)" as the expression
This should work:
###
from pymol import cmd, stored
objname = "mytraj"
cmd.load("1JNO_GrA_DMPC_NACL_Membrane_TIP3P_SemiIso_rep3_Water_InChannel_0ns.pdb",
objname)
cmd.load_traj("1JNO_GrA_DMPC_NACL_Membrane_TIP3P_SemiIso_rep3_Water_InChannel_0_50ns_Every_0.5ns_TRANSLATED.xtc",
objname)
nb_states = cmd.count_states(objname)
for i in range(1, nb_states + 1):
stored.resid = []
cmd.select("water_channel", "resn SOL within 3.5 of resn CHO", state=i)
cmd.iterate("water_channel", 'stored.resid.append(resv)')
print("frame " + str(i) + ":" + str(stored.residues))
###
Hope that helps.
Cheers,
Thomas
> On Jun 22, 2020, at 4:52 PM, ABEL Stephane <[email protected]> wrote:
>
> Hi Pedro
>
> It does not work, the pymol crashes if I use this selection
>
> Stéphane
>
> ----------------------------------------------------------
> Stéphane Abel, Ph.D.
> CEA Centre de Saclay
> DRF/JOLIOT/I2BC-S/SB2SM/LBMS
> Bat 528, Office 138C
> Gif-sur-Yvette, F-91191 FRANCE
> Phone (portable) : +33 6 49 37 70 60
> ________________________________________
> De : Pedro Lacerda [[email protected]]
> Envoyé : lundi 22 juin 2020 16:26
> À : ABEL Stephane
> Cc : pymol-users
> Objet : Re: [PyMOL] Python script with iterate_state and selection command
>
> Hi,
>
> Not sure if I understood your code but maybe you want change Myselection to:
>
> Myselection="resname SOL within 3.5 of resname CHO"
>
> -- Pedro Lacerda
>
> Em seg, 22 de jun de 2020 10:44, ABEL Stephane
> <[email protected]<mailto:[email protected]>> escreveu:
> Hello all,
>
> I would like to write a basic python script to select residues for each state
> using the iterate_state and output the results first in pymol console window
> with the following format
>
> frame 1 : resid ...
> frame 2 : resid ...
> ...
>
> ### my script ##
>
> from pymol import cmd, stored
>
> mytraj=""
> mytraj2=""
>
> ## Load PDB
> cmd.load("1JNO_GrA_DMPC_NACL_Membrane_TIP3P_SemiIso_rep3_Water_InChannel_0ns.pdb"),
> mytraj
>
> ## Load XTC
> cmd.load_traj("1JNO_GrA_DMPC_NACL_Membrane_TIP3P_SemiIso_rep3_Water_InChannel_0_50ns_Every_0.5ns_TRANSLATED.xtc"),
> mytraj2
>
> stored.resid = []
>
> Myselection="select water_channel, resname SOL within 3.5 of resname CHO"
>
> nb_states=cmd.count_states(mytraj2) ---> Contains 102 states
> print(mytraj2, nb_states)
>
> state=1
> for i in range (nb_states) :
> print(i)
> cmd.iterate_state (i, (Myselection), 'resid.append(resv)') ---->
> Should to ireate for all the states
> print("frame " + str(i) + ":" + str(stored.residues)) ---> Print the
> results of the Myselection command in the console
>
> ###
>
> But the first problem I have is the syntax of the iterate_state. I obtain the
> following error
> "Selector-Error: Invalid selection name "select".
> ( select water_channel, resname SOL within 3.5 of resname CHO )<--"
>
> When I put this selection command directly in Pymol, it works and i can
> obtain the desired waters that was near 3.5 A of the CHO over all the states
> . So What is the correct syntax for the selection with "iterate_state" ? And
> how to output the results again for each state in the screen .
>
> Thanks in advance for your help
>
> Stéphane
>
>
> _______________________________________________
> PyMOL-users mailing list
> Archives: http://www.mail-archive.com/[email protected]
> Unsubscribe:
> https://sourceforge.net/projects/pymol/lists/pymol-users/unsubscribe
>
>
> _______________________________________________
> PyMOL-users mailing list
> Archives: http://www.mail-archive.com/[email protected]
> Unsubscribe:
> https://sourceforge.net/projects/pymol/lists/pymol-users/unsubscribe
--
Thomas Holder
PyMOL Principal Developer
Schrödinger, Inc.
_______________________________________________
PyMOL-users mailing list
Archives: http://www.mail-archive.com/[email protected]
Unsubscribe:
https://sourceforge.net/projects/pymol/lists/pymol-users/unsubscribe