[chimerax-users] Chimerax scripting error and passing user supplied arguments
Tom Goddard
goddard at sonic.net
Thu May 5 00:00:49 PDT 2022
Hi Ryan,
The "foreach" option you tried is exactly intended for this use. The error message "Missing filename suffix foreach" suggests you are using an old version of ChimeraX (older than ChimeraX 1.3) that does not have the "foreach" option so it thinks that "foreach" is the name of a file. Your script only saves one file so I don't understand what you mean by saving two files $file1 and $file2. You would just use "save $file-sf-aligned.pdb ..." to save the aligned file.
Tom
> On May 4, 2022, at 10:41 PM, Ryan Woltz via ChimeraX-users <chimerax-users at cgl.ucsf.edu> wrote:
>
> Dear community,
>
> I'm sorry if this is a repeated question, I've seen a few posts about taking in a file for the command line and doing some things then exiting. I got most of this down and I'm sure at this point it is just a matter or correcting a few lines of code.
>
> I'm trying to automate a protein modeling protocol and I have 1000 decoys at this point. Now I need to insert the 5 metals into 5 different pockets into all my decoys for a final relax before selecting my top model. I have a template pdb with all the metals in place. For 4 of these metals I have used rosetta align mover to align a decoy onto the template around a single metal binding site, save the pdb, then add on the metal coordinates then repeat for the next binding site. So this method works because the chain is continuous around these metal binding sites. However the final metal binding site is in the center and coordinated by 4 chains coming together and the positioning needs to be very precise.
>
> Chimera or chimerax solves this very well but I don't know how to put this into a script. I have a few solutions if someone can help me edit this to work. My script (chimera-data-processing.cxc) looks like this right now.
>
> cd results/
> open S_0001_X-4-all-chain-A.pdb ###X = 1-1000
> open hsk2-cam-homology-from-map-refined-6cno-alignment-template-1-all-chain-A.pdb
> info
> align #1:240-244,765-769,1290-1294,1815-1819 at o to_atoms #2:240-244,765-769,1290-1294,1815-1819 at o matchAtomNames true; wait 300
> save S_0001_X-4-all-chain-A-sf-aligned.pdb #1 format pdb relModel #2; wait 30
> cd ../
> close
> quit
>
> This script is perfect if run for have a single model with the exact name written into the script after typing:
>
> chimerax-daily --nogui chimera-data-processing.cxc
>
> I have two main solutions
> A) run a while loop that counts down and passes a filename to chimerax:
>
> while ( X < 1000 )
>
> chimerax-daily --nogui chimera-data-processing.cxc S_0001_X-4-all-chain-A.pdb hsk2-cam-homology-from-map-refined-6cno-alignment-template-1-all-chain-A.pdb
>
> Where in the chimerax script I take the arg1 (S_0001*.pdb) and arg2 (hsk2*.pdb)(assuming chimera-data-processing.cxc is arg0) and modify to look like this:
>
> open $arg1
> open $arg2
> ...
> save $arg1-sf-aligned.pdb #1 format pdb relModel #2; wait 30
>
> Option B is to use the foreach command described in the open command documentation (https://www.cgl.ucsf.edu/chimerax/docs/user/commands/open.html <https://www.cgl.ucsf.edu/chimerax/docs/user/commands/open.html>). However, a copy and past of that command:
>
> open myscript.cxc foreach ~/data/*.cif
> or
> open chimera-data-processing.cxc foreach results/S_0001_*-4-all-chain-A.pdb
>
> results in this error:
>
> Missing filename suffix foreach
>
> I also tried this:
>
> chimerax-daily --nogui chimera-data-processing.cxc foreach results/S_0001_*-4-all-chain-A.pdb
>
> But it just runs the command. this seems to ignore everything after the first filename. I also read that if I used foreach inside the script I could use $file to replace the filename it is currently working on, would there be a way to fave $file1 and $file2? to automate this I'd also like the change the name of the template file I'm aligning to. I also attempted the python method using sys.arg = arg[1] then running things but I couldn't get it to work because I have no experience in python. What is the suggested way to complete this task? Again this is in a much larger script with user inputs so ideally it would look like this in a script (very shorthanded just for the concepts). I can also run a python command script in my bash sctipt
>
> pdb transformations
>
> if (y = 5) ###alignment metal number)
> while ( x < 1000)
> ###arg0 = command script arg1 = pdb to align arg2 = template pdb with metals
> chimerax-daily --nogui chimera-command-script.cxc $filenamebase$x-$alignmentnumber-*.pdb $template.pdb ###strings for variables are provided when script is initialized.
>
> ###code to extract metal coords for S_0001_$x-4-*.pdb
>
> done
> fi
>
>
> chimera-command-script.cxc:
> open arg1
> open arg2
> align model #1 to model #2 on specific atoms
> save arg1-new-filename.pdb
> close
> exit
>
> if someone would like a follow-up email with my attempt at chimera python sctipt using runcommand I'm very happy to supply that as a foundation to help fix, I just thought this one is easier to fix since it is really close, the script works but only for 1 pdb at a time.
>
> Apologies for bad scripting terminology and confusion with python, I've had to teach coding to myself so I might have misused terms.
>
> Thanks for any help that can be given,
>
> Ryan
> _______________________________________________
> ChimeraX-users mailing list
> ChimeraX-users at cgl.ucsf.edu
> Manage subscription:
> https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.rbvi.ucsf.edu/pipermail/chimerax-users/attachments/20220505/606ab270/attachment.html>
More information about the ChimeraX-users
mailing list