"forEach" command to open multiple pdb from multiple directories and save images there ?

Hi, I would like to open multiple alphafold results that are stored in several folders, make an image, and save the image in those orignial folders. I'm using the forEach command to open all the results and run the script to create an image, and it works very well: open script.cxc forEach /PATH*/ranked_*.pdb script.cxc: open reference-structure.pdb match #1 to #2 color #*/B green color #*/C red color #*/D blue view matrix camera 0.87509,0.019021,-0.48356,-124.35,0.48393,-0.035333,0.87439,694.49,-0.00044561,-0.99919,-0.040123,163.41 I'm only stuck at the saving process where I'd like to save an image ranked_*.png matching the original name and folder location: save /PATH*/$file.png doesn't work because the /PATH*/ is not recognized as an existing directory. save /$PATH*/$file.png gives the same error. If I remove the /PATH/ it saves all the images on top of each other and it defeats the purpose. Could you let me know how to save in the folder where the .pdb was read from? Thank you Vincent -- Vincent Chaptal, PhD Director of GdR APPICOM Drug Resistance and Membrane Proteins Lab MMSB -UMR5086 7 passage du Vercors 69007 LYON FRANCE +33 4 37 65 29 01 http://www.appicom.cnrs.fr http://mmsb.cnrs.fr/en/

Hi Vincent, How to put the filename prefix in output files is explained in the "forEach" help: <https://rbvi.ucsf.edu/chimerax/docs/user/commands/open.html#forEachFile> Namely, you have to use "$file" in the image save command in your cxc file. Less important, I don't think you need the #* in your script (although I guess it doesn't hurt if it works) -- simply using the chain spec (e.g. /B) will get that chain in all models. I hope this helps, Elaine ----- Elaine C. Meng, Ph.D. UCSF Chimera(X) team Resource for Biocomputing, Visualization, and Informatics Department of Pharmaceutical Chemistry University of California, San Francisco
On Jan 20, 2025, at 3:12 AM, Vincent CHAPTAL via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
Hi,
I would like to open multiple alphafold results that are stored in several folders, make an image, and save the image in those orignial folders.
I'm using the forEach command to open all the results and run the script to create an image, and it works very well:
open script.cxc forEach /PATH*/ranked_*.pdb
script.cxc: open reference-structure.pdb match #1 to #2 color #*/B green color #*/C red color #*/D blue view matrix camera 0.87509,0.019021,-0.48356,-124.35,0.48393,-0.035333,0.87439,694.49,-0.00044561,-0.99919,-0.040123,163.41
I'm only stuck at the saving process where I'd like to save an image ranked_*.png matching the original name and folder location: save /PATH*/$file.png doesn't work because the /PATH*/ is not recognized as an existing directory. save /$PATH*/$file.png gives the same error.
If I remove the /PATH/ it saves all the images on top of each other and it defeats the purpose.
Could you let me know how to save in the folder where the .pdb was read from?
Thank you Vincent

Hi Elaine, thanks, I see my mistake. I didn't understand that I didn't need to specify the path to save the images, now that I use only the 'save $file.png' it works beautifully. Thanks Vincent Le 20/01/2025 à 17:41, Elaine Meng a écrit :
Hi Vincent, How to put the filename prefix in output files is explained in the "forEach" help:
<https://rbvi.ucsf.edu/chimerax/docs/user/commands/open.html#forEachFile>
Namely, you have to use "$file" in the image save command in your cxc file.
Less important, I don't think you need the #* in your script (although I guess it doesn't hurt if it works) -- simply using the chain spec (e.g. /B) will get that chain in all models.
I hope this helps, Elaine ----- Elaine C. Meng, Ph.D. UCSF Chimera(X) team Resource for Biocomputing, Visualization, and Informatics Department of Pharmaceutical Chemistry University of California, San Francisco
On Jan 20, 2025, at 3:12 AM, Vincent CHAPTAL via ChimeraX-users<chimerax-users@cgl.ucsf.edu> wrote:
Hi,
I would like to open multiple alphafold results that are stored in several folders, make an image, and save the image in those orignial folders.
I'm using the forEach command to open all the results and run the script to create an image, and it works very well:
open script.cxc forEach /PATH*/ranked_*.pdb
script.cxc: open reference-structure.pdb match #1 to #2 color #*/B green color #*/C red color #*/D blue view matrix camera 0.87509,0.019021,-0.48356,-124.35,0.48393,-0.035333,0.87439,694.49,-0.00044561,-0.99919,-0.040123,163.41
I'm only stuck at the saving process where I'd like to save an image ranked_*.png matching the original name and folder location: save /PATH*/$file.png doesn't work because the /PATH*/ is not recognized as an existing directory. save /$PATH*/$file.png gives the same error.
If I remove the /PATH/ it saves all the images on top of each other and it defeats the purpose.
Could you let me know how to save in the folder where the .pdb was read from?
Thank you Vincent
-- Vincent Chaptal, PhD Director of GdR APPICOM Drug Resistance and Membrane Proteins Lab MMSB -UMR5086 7 passage du Vercors 69007 LYON FRANCE +33 4 37 65 29 01 http://www.appicom.cnrs.fr http://mmsb.cnrs.fr/en/
participants (2)
-
Elaine Meng
-
Vincent CHAPTAL