[chimerax-users] using variables in command files

Elaine Meng meng at cgl.ucsf.edu
Fri Jun 24 09:02:10 PDT 2022


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 at 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 at 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 at 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 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
>>> 
> 
> _______________________________________________
> ChimeraX-users mailing list
> ChimeraX-users at cgl.ucsf.edu
> Manage subscription:
> https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users




More information about the ChimeraX-users mailing list