Hi Shivam, 

Just building on Elaine's suggestion, another easy way to loop through the pdb structures is using glob. Something like

import glob
from chimerax.core.commands import run
for pdb in glob.glob("your_path/*.pdb"):
     run(session, "open " + pdb)
     # whatever ChimeraX commands

Best,
Harper


From: ChimeraX-users <chimerax-users-bounces@cgl.ucsf.edu> on behalf of Elaine Meng via ChimeraX-users <chimerax-users@cgl.ucsf.edu>
Sent: Friday, July 1, 2022 10:30 AM
To: Shivam Gupta <shivam-gupta@pharmafoods.co.jp>
Cc: ChimeraX Users Help <chimerax-users@cgl.ucsf.edu>
Subject: [chimerax-users] scripting to check H-bonds in multiple structures
 


Hi Shivam,
I don't know Python so I can't answer about that part.  However, you might be able to do without python, at least if each docked structure is a separate input file. 

(1) first figure out what ChimeraX command(s) you want to run on each structure.  You would do this by interactively using ChimeraX on one or two example structures, before you try to put commands into a script.  Either you can try using the "hbonds" command directly by typing it into the command line, or you can use the H-Bonds GUI interface to choose the options that you want, and then click Apply -- this will show the resulting command in the Log.  See:
<https://urldefense.com/v3/__https://rbvi.ucsf.edu/chimerax/docs/user/commands/hbonds.html__;!!KGKeukY!ywCOj9rScLmdHukt6hZ8NdcEHGq2DWt26v4lvUU-IKf0-0ytADpXYHQiDWrFYuwWlphfimVRCLAgdSQLxB7KhfANTosO49j8cpQ$ >
<https://urldefense.com/v3/__https://rbvi.ucsf.edu/chimerax/docs/user/tools/hbonds.html__;!!KGKeukY!ywCOj9rScLmdHukt6hZ8NdcEHGq2DWt26v4lvUU-IKf0-0ytADpXYHQiDWrFYuwWlphfimVRCLAgdSQLxB7KhfANTosO_wz-gV4$ >

If each docked structure is a separate input file (e.g. each one is a separate PDB file) then you can try the following two additional steps:

(2) put the ChimeraX command(s) from step (1) above into a plain text file named something.cxc
<https://urldefense.com/v3/__https://rbvi.ucsf.edu/chimerax/docs/user/commands/usageconventions.html*cxc-files__;Iw!!KGKeukY!ywCOj9rScLmdHukt6hZ8NdcEHGq2DWt26v4lvUU-IKf0-0ytADpXYHQiDWrFYuwWlphfimVRCLAgdSQLxB7KhfANTosOYOFuYC0$ >

(3) use the "open" command to run the .cxc file and its "forEachFile" option to specify looping through all the PDB files. For an example, see:
<https://urldefense.com/v3/__https://rbvi.ucsf.edu/chimerax/docs/user/commands/open.html*forEachFile__;Iw!!KGKeukY!ywCOj9rScLmdHukt6hZ8NdcEHGq2DWt26v4lvUU-IKf0-0ytADpXYHQiDWrFYuwWlphfimVRCLAgdSQLxB7KhfANTosO3bQNjp4$ >

However, if all the dockings are together in a single big file you may instead need to use python to loop through them as models (e.g. #2.1, 2.2, 2.3, etc.) and run the command(s) from step (1) above.  Somebody else would have to advise on that.

I hope this helps,
Elaine
-----
Elaine C. Meng, Ph.D.                      
UCSF Chimera(X) team
Department of Pharmaceutical Chemistry
University of California, San Francisco


> On Jun 30, 2022, at 10:31 PM, Shivam Gupta via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
>
> Hello Chimera Team,
>
> I want to explore the possibility of checking the protein-protein interaction (hydrogen bond) in the docked structure using python script.
>
> Is it possible to check hydrogen bonds for high throughput data (docked protein structures) using Python?
>
> Please guide me over this.
>
> Thanks
>


_______________________________________________
ChimeraX-users mailing list
ChimeraX-users@cgl.ucsf.edu
Manage subscription:
https://urldefense.com/v3/__https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users__;!!KGKeukY!ywCOj9rScLmdHukt6hZ8NdcEHGq2DWt26v4lvUU-IKf0-0ytADpXYHQiDWrFYuwWlphfimVRCLAgdSQLxB7KhfANTosO2347UwE$