[chimerax-users] using variables in command files
Elaine Meng
meng at cgl.ucsf.edu
Fri Jun 24 08:18:16 PDT 2022
Hi Pranav,
For something like this I believe you would instead use the "foreach" option of the "open" command to open the ChimeraX command file, which could contain "$file" meaning the base name (before suffix) of the input files. This also allows specifying multiple input files to loop through in one "open" command, as explained here
<https://rbvi.ucsf.edu/chimerax/docs/user/commands/open.html#forEachFile>
Your command file would contain something like
open $file
color radial palette rainbow
save $file.png height 512 width 512 transparentBackground True
...i.e. there is only one substitution string $file (you can't have a different $outfile), but in the example above if you opened 2gbp.pdb, the saved image would then be named 2gbp.png. If you opened infile.mrc, then the saved image would be named infile.png.
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 24, 2022, at 5:57 AM, Pranav Shah via ChimeraX-users <chimerax-users at cgl.ucsf.edu> wrote:
>
> Hi Team,
> Is it possible for one to declare a variable in a command file that
> can then be passed to via the chimeraX command line interface. A
> minimal example of something I would like to do is -
> command.cxc
> open $file
> color radial palette rainbow
> save $outfile.png height 512 width 512 transparentBackground True
>
> In the chimeraX command line window I would then like to run
> open command.cxc infile.mrc outfile.png
> Best,
> Pranav
More information about the ChimeraX-users
mailing list