
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 -- Pranav Shah Postdoctoral Research Fellow. Division of Structural Biology, Wellcome Trust Centre for Human Genetics, University of Oxford, Roosevelt Drive, Oxford OX3 7BN, UK

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@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

Thanks for that pointer Elaine. I have a question- (a) <file> has no suffix error - I am running the program as described in the help page. Essentially, open test.cxc foreach myfile.* My script has the following three lines in it open $file color radial #1 palette rainbow save $file.png transparentBackground true Looking at the log, ChimeraX appears to be running two open commands for some reason. In the first instance it opens the map as expected but then stops executing a second open with the aforementioned error. Not sure why it needs to run open twice. Not sure where I am going wrong. Best, Pranav -- Pranav Shah Postdoctoral Research Fellow. Division of Structural Biology, Wellcome Trust Centre for Human Genetics, University of Oxford, Roosevelt Drive, Oxford OX3 7BN, UK On Fri, Jun 24, 2022 at 4:18 PM Elaine Meng <meng@cgl.ucsf.edu> wrote:
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@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

Ah! OK i see where I was going wrong. essentially there is no need to include an open command in the command file because that is implicit in the open call to the command file in the GUI. Best, Pranav -- Pranav Shah Postdoctoral Research Fellow. Division of Structural Biology, Wellcome Trust Centre for Human Genetics, University of Oxford, Roosevelt Drive, Oxford OX3 7BN, UK On Fri, Jun 24, 2022 at 4:50 PM Pranav Shah <p.shah.lab@gmail.com> wrote:
Thanks for that pointer Elaine. I have a question- (a) <file> has no suffix error - I am running the program as described in the help page. Essentially, open test.cxc foreach myfile.* My script has the following three lines in it open $file color radial #1 palette rainbow
save $file.png transparentBackground true
Looking at the log, ChimeraX appears to be running two open commands for some reason. In the first instance it opens the map as expected but then stops executing a second open with the aforementioned error. Not sure why it needs to run open twice.
Not sure where I am going wrong. Best, Pranav -- Pranav Shah Postdoctoral Research Fellow.
Division of Structural Biology, Wellcome Trust Centre for Human Genetics, University of Oxford, Roosevelt Drive, Oxford OX3 7BN, UK
On Fri, Jun 24, 2022 at 4:18 PM Elaine Meng <meng@cgl.ucsf.edu> wrote:
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@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

Yes, sorry about that, my example was wrong and should not have had the "open" command inside the cxc file. Glad you figured it out. Best, Elaine
On Jun 24, 2022, at 8:56 AM, Pranav Shah via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
Ah! OK i see where I was going wrong. essentially there is no need to include an open command in the command file because that is implicit in the open call to the command file in the GUI. Best, Pranav -- Pranav Shah Postdoctoral Research Fellow.
Division of Structural Biology, Wellcome Trust Centre for Human Genetics, University of Oxford, Roosevelt Drive, Oxford OX3 7BN, UK
On Fri, Jun 24, 2022 at 4:50 PM Pranav Shah <p.shah.lab@gmail.com> wrote:
Thanks for that pointer Elaine. I have a question- (a) <file> has no suffix error - I am running the program as described in the help page. Essentially, open test.cxc foreach myfile.* My script has the following three lines in it open $file color radial #1 palette rainbow
save $file.png transparentBackground true
Looking at the log, ChimeraX appears to be running two open commands for some reason. In the first instance it opens the map as expected but then stops executing a second open with the aforementioned error. Not sure why it needs to run open twice.
Not sure where I am going wrong. Best, Pranav -- Pranav Shah Postdoctoral Research Fellow.
Division of Structural Biology, Wellcome Trust Centre for Human Genetics, University of Oxford, Roosevelt Drive, Oxford OX3 7BN, UK
On Fri, Jun 24, 2022 at 4:18 PM Elaine Meng <meng@cgl.ucsf.edu> wrote:
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@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
_______________________________________________ ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu Manage subscription: https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users

HI Elaine, sorry to write to you privately. Writing for the sake of reducing the spam in other peoples inboxes. Can I ask how I could then use the foreach command to color the map value using values from another map? It seems forachfile has a very limited capacity to handle more complex workflows and I might have to turn to writing stuff up in python using the chimerax api. Best, Pranav -- Pranav Shah Postdoctoral Research Fellow. Division of Structural Biology, Wellcome Trust Centre for Human Genetics, University of Oxford, Roosevelt Drive, Oxford OX3 7BN, UK On Fri, Jun 24, 2022 at 5:02 PM Elaine Meng <meng@cgl.ucsf.edu> wrote:
Yes, sorry about that, my example was wrong and should not have had the "open" command inside the cxc file.
Glad you figured it out. Best, Elaine
On Jun 24, 2022, at 8:56 AM, Pranav Shah via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
Ah! OK i see where I was going wrong. essentially there is no need to include an open command in the command file because that is implicit in the open call to the command file in the GUI. Best, Pranav -- Pranav Shah Postdoctoral Research Fellow.
Division of Structural Biology, Wellcome Trust Centre for Human Genetics, University of Oxford, Roosevelt Drive, Oxford OX3 7BN, UK
On Fri, Jun 24, 2022 at 4:50 PM Pranav Shah <p.shah.lab@gmail.com> wrote:
Thanks for that pointer Elaine. I have a question- (a) <file> has no suffix error - I am running the program as described in the help page. Essentially, open test.cxc foreach myfile.* My script has the following three lines in it open $file color radial #1 palette rainbow
save $file.png transparentBackground true
Looking at the log, ChimeraX appears to be running two open commands for some reason. In the first instance it opens the map as expected but then stops executing a second open with the aforementioned error. Not sure why it needs to run open twice.
Not sure where I am going wrong. Best, Pranav -- Pranav Shah Postdoctoral Research Fellow.
Division of Structural Biology, Wellcome Trust Centre for Human Genetics, University of Oxford, Roosevelt Drive, Oxford OX3 7BN, UK
On Fri, Jun 24, 2022 at 4:18 PM Elaine Meng <meng@cgl.ucsf.edu> wrote:
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@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
_______________________________________________ ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu Manage subscription: https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users

Hi Pranav, If all the maps are colored by the same second map, then there isn't an issue. However, if each map has its own partner map for coloring, maybe it's possible by putting them in separate subdirectories, e.g. open myscript.cxc foreach ~/data/*.mrc and in this case include another "open" inside the myscript.cxc that would open the second map in different subdir open ~/data2/$file.mrc I haven't tried it, just an idea. However, depending on the complexity of whatever is your current workflow you may need to use python instead. As you can see, "foreach" is just for the common case of wanting to process many input files individually but with the same series of steps. Somebody else would have to advise if you need help with the python, however, as that is outside my skill set. Best, Elaine ----- Elaine C. Meng, Ph.D. UCSF Chimera(X) team Department of Pharmaceutical Chemistry University of California, San Francisco
On Jun 24, 2022, at 9:18 AM, Pranav Shah via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
HI Elaine, sorry to write to you privately. Writing for the sake of reducing the spam in other peoples inboxes. Can I ask how I could then use the foreach command to color the map value using values from another map? It seems forachfile has a very limited capacity to handle more complex workflows and I might have to turn to writing stuff up in python using the chimerax api. Best, Pranav -- Pranav Shah Postdoctoral Research Fellow.
Division of Structural Biology, Wellcome Trust Centre for Human Genetics, University of Oxford, Roosevelt Drive, Oxford OX3 7BN, UK
On Fri, Jun 24, 2022 at 5:02 PM Elaine Meng <meng@cgl.ucsf.edu> wrote:
Yes, sorry about that, my example was wrong and should not have had the "open" command inside the cxc file.
Glad you figured it out. Best, Elaine
On Jun 24, 2022, at 8:56 AM, Pranav Shah via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
Ah! OK i see where I was going wrong. essentially there is no need to include an open command in the command file because that is implicit in the open call to the command file in the GUI. Best, Pranav -- Pranav Shah Postdoctoral Research Fellow.
Division of Structural Biology, Wellcome Trust Centre for Human Genetics, University of Oxford, Roosevelt Drive, Oxford OX3 7BN, UK
On Fri, Jun 24, 2022 at 4:50 PM Pranav Shah <p.shah.lab@gmail.com> wrote:
Thanks for that pointer Elaine. I have a question- (a) <file> has no suffix error - I am running the program as described in the help page. Essentially, open test.cxc foreach myfile.* My script has the following three lines in it open $file color radial #1 palette rainbow
save $file.png transparentBackground true
Looking at the log, ChimeraX appears to be running two open commands for some reason. In the first instance it opens the map as expected but then stops executing a second open with the aforementioned error. Not sure why it needs to run open twice.
Not sure where I am going wrong. Best, Pranav -- Pranav Shah Postdoctoral Research Fellow.
Division of Structural Biology, Wellcome Trust Centre for Human Genetics, University of Oxford, Roosevelt Drive, Oxford OX3 7BN, UK
On Fri, Jun 24, 2022 at 4:18 PM Elaine Meng <meng@cgl.ucsf.edu> wrote:
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@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
_______________________________________________ ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu Manage subscription: https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
_______________________________________________ ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu Manage subscription: https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users

Hi Pranav, Currently ChimeraX does not have a way to substitute argument values into a *.cxc file except for the open command "foreach" option which allows substituting the file name in for $file. For simple series of commands you could define an alias, for example, alias radcolor open $1 ; color radial palette rainbow ; save $2 height 512 width 512 transparentBackground true This defines the radcolor command that you can use like radcolor mymap.mrc image.png Here's the documentation for the "alias" command https://www.cgl.ucsf.edu/chimerax/docs/user/commands/alias.html The other mechanism for handing arguments to a script is the "runscript" command which passes arguments to Python scripts only. I could imagine runscript being enhanced so that it works with a *.cxc command script and substitutes arguments in for $1, $2, $3, ... occurring in the script. https://www.cgl.ucsf.edu/chimerax/docs/user/commands/runscript.html Tom
On Jun 24, 2022, at 5:57 AM, Pranav Shah via ChimeraX-users <chimerax-users@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 -- Pranav Shah Postdoctoral Research Fellow.
Division of Structural Biology, Wellcome Trust Centre for Human Genetics, University of Oxford, Roosevelt Drive, Oxford OX3 7BN, UK _______________________________________________ ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu Manage subscription: https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users

Yeah, it would be really nice to be able to pass multiple commands to a script. I did think about putting together an alias with multiple lines, but thought it would be too unwieldy. Writing a python script ended up being the most efficient. Having said that, how does one get a voxelsize from a map? I tried to use mrcfile which I know is installed but ChimeraX doesnt appear to be able to load it. Best, Pranav -- Pranav Shah Postdoctoral Research Fellow. Division of Structural Biology, Wellcome Trust Centre for Human Genetics, University of Oxford, Roosevelt Drive, Oxford OX3 7BN, UK On Fri, Jun 24, 2022 at 8:09 PM Tom Goddard <goddard@sonic.net> wrote:
Hi Pranav,
Currently ChimeraX does not have a way to substitute argument values into a *.cxc file except for the open command "foreach" option which allows substituting the file name in for $file. For simple series of commands you could define an alias, for example,
alias radcolor open $1 ; color radial palette rainbow ; save $2 height 512 width 512 transparentBackground true
This defines the radcolor command that you can use like
radcolor mymap.mrc image.png
Here's the documentation for the "alias" command
https://www.cgl.ucsf.edu/chimerax/docs/user/commands/alias.html
The other mechanism for handing arguments to a script is the "runscript" command which passes arguments to Python scripts only. I could imagine runscript being enhanced so that it works with a *.cxc command script and substitutes arguments in for $1, $2, $3, ... occurring in the script.
https://www.cgl.ucsf.edu/chimerax/docs/user/commands/runscript.html
Tom
On Jun 24, 2022, at 5:57 AM, Pranav Shah via ChimeraX-users <chimerax-users@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 -- Pranav Shah Postdoctoral Research Fellow.
Division of Structural Biology, Wellcome Trust Centre for Human Genetics, University of Oxford, Roosevelt Drive, Oxford OX3 7BN, UK _______________________________________________ ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu Manage subscription: https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users

nvm, turns out I had to upgrade pip inthe ChimX sessh. Best, Pranav -- Pranav Shah Postdoctoral Research Fellow. Division of Structural Biology, Wellcome Trust Centre for Human Genetics, University of Oxford, Roosevelt Drive, Oxford OX3 7BN, UK On Fri, Jun 24, 2022 at 8:16 PM Pranav Shah <p.shah.lab@gmail.com> wrote:
Yeah, it would be really nice to be able to pass multiple commands to a script. I did think about putting together an alias with multiple lines, but thought it would be too unwieldy. Writing a python script ended up being the most efficient. Having said that, how does one get a voxelsize from a map? I tried to use mrcfile which I know is installed but ChimeraX doesnt appear to be able to load it.
Best, Pranav -- Pranav Shah Postdoctoral Research Fellow.
Division of Structural Biology, Wellcome Trust Centre for Human Genetics, University of Oxford, Roosevelt Drive, Oxford OX3 7BN, UK
On Fri, Jun 24, 2022 at 8:09 PM Tom Goddard <goddard@sonic.net> wrote:
Hi Pranav,
Currently ChimeraX does not have a way to substitute argument values into a *.cxc file except for the open command "foreach" option which allows substituting the file name in for $file. For simple series of commands you could define an alias, for example,
alias radcolor open $1 ; color radial palette rainbow ; save $2 height 512 width 512 transparentBackground true
This defines the radcolor command that you can use like
radcolor mymap.mrc image.png
Here's the documentation for the "alias" command
https://www.cgl.ucsf.edu/chimerax/docs/user/commands/alias.html
The other mechanism for handing arguments to a script is the "runscript" command which passes arguments to Python scripts only. I could imagine runscript being enhanced so that it works with a *.cxc command script and substitutes arguments in for $1, $2, $3, ... occurring in the script.
https://www.cgl.ucsf.edu/chimerax/docs/user/commands/runscript.html
Tom
On Jun 24, 2022, at 5:57 AM, Pranav Shah via ChimeraX-users <chimerax-users@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 -- Pranav Shah Postdoctoral Research Fellow.
Division of Structural Biology, Wellcome Trust Centre for Human Genetics, University of Oxford, Roosevelt Drive, Oxford OX3 7BN, UK _______________________________________________ ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu Manage subscription: https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users

Hi Pranav, I improved the ChimeraX runscript command so it can pass arguments to a ChimeraX command file (.cxc suffix) replacing $1, $2, $3 ... in the commands with the given arguments. This will be in tomorrow's daily builds. For example, run radcolor.cxc mymap.mrc mymap.png where the radcolor.cxc text file contains # Color map radially and save an image open $1 color radial palette rainbow save $2 height 512 width 512 transparentBackground true Thanks suggesting the idea. Tom
On Jun 24, 2022, at 12:09 PM, Tom Goddard via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
Hi Pranav,
Currently ChimeraX does not have a way to substitute argument values into a *.cxc file except for the open command "foreach" option which allows substituting the file name in for $file. For simple series of commands you could define an alias, for example,
alias radcolor open $1 ; color radial palette rainbow ; save $2 height 512 width 512 transparentBackground true
This defines the radcolor command that you can use like
radcolor mymap.mrc image.png
Here's the documentation for the "alias" command
https://www.cgl.ucsf.edu/chimerax/docs/user/commands/alias.html
The other mechanism for handing arguments to a script is the "runscript" command which passes arguments to Python scripts only. I could imagine runscript being enhanced so that it works with a *.cxc command script and substitutes arguments in for $1, $2, $3, ... occurring in the script.
https://www.cgl.ucsf.edu/chimerax/docs/user/commands/runscript.html
Tom
On Jun 24, 2022, at 5:57 AM, Pranav Shah via ChimeraX-users <chimerax-users@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 -- Pranav Shah Postdoctoral Research Fellow.
Division of Structural Biology, Wellcome Trust Centre for Human Genetics, University of Oxford, Roosevelt Drive, Oxford OX3 7BN, UK _______________________________________________ ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu Manage subscription: https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
_______________________________________________ ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu Manage subscription: https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users

Awesome, thanks! On Sat, 25 Jun 2022 at 00:45, Tom Goddard <goddard@sonic.net> wrote:
Hi Pranav,
I improved the ChimeraX runscript command so it can pass arguments to a ChimeraX command file (.cxc suffix) replacing $1, $2, $3 ... in the commands with the given arguments. This will be in tomorrow's daily builds. For example,
run radcolor.cxc mymap.mrc mymap.png
where the radcolor.cxc text file contains
# Color map radially and save an image open $1 color radial palette rainbow save $2 height 512 width 512 transparentBackground true
Thanks suggesting the idea.
Tom
On Jun 24, 2022, at 12:09 PM, Tom Goddard via ChimeraX-users < chimerax-users@cgl.ucsf.edu> wrote:
Hi Pranav,
Currently ChimeraX does not have a way to substitute argument values into a *.cxc file except for the open command "foreach" option which allows substituting the file name in for $file. For simple series of commands you could define an alias, for example,
alias radcolor open $1 ; color radial palette rainbow ; save $2 height 512 width 512 transparentBackground true
This defines the radcolor command that you can use like
radcolor mymap.mrc image.png
Here's the documentation for the "alias" command
https://www.cgl.ucsf.edu/chimerax/docs/user/commands/alias.html
The other mechanism for handing arguments to a script is the "runscript" command which passes arguments to Python scripts only. I could imagine runscript being enhanced so that it works with a *.cxc command script and substitutes arguments in for $1, $2, $3, ... occurring in the script.
https://www.cgl.ucsf.edu/chimerax/docs/user/commands/runscript.html
Tom
On Jun 24, 2022, at 5:57 AM, Pranav Shah via ChimeraX-users <
chimerax-users@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 -- Pranav Shah Postdoctoral Research Fellow.
Division of Structural Biology, Wellcome Trust Centre for Human Genetics, University of Oxford, Roosevelt Drive, Oxford OX3 7BN, UK _______________________________________________ ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu Manage subscription: https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
_______________________________________________ ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu Manage subscription: https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
-- Best, Pranav -- Pranav Shah Postdoctoral Research Fellow.
Division of Structural Biology, Wellcome Trust Centre for Human Genetics, University of Oxford, Roosevelt Drive, Oxford OX3 7BN, UK
participants (3)
-
Elaine Meng
-
Pranav Shah
-
Tom Goddard