Hi Tom,
Thank you for your quick reply. Your solution worked to get "foreach" to work and I have notes below if others in the future run into my problem. I was able to solve the issue with a bash script that creates command run files on the fly but it's pretty messy so if you have another way to do this it'd be nice to have things a bit cleaner. Below is my solution/follow-up question, a clarification to the $file1 question you asked and some notes about updating. Major apologies if I repeat myself or grammatical errors, as I wrote this email I came up with several ideas on how to make things work and had to edit the post multiple times each time I tried something new.
Follow up question:
With your help I got this to work by typing these commands into the terminal directly:
$:chimerax --nogui
(waited to load chimerax)
$:open chimera-data-processing.cxc foreach S_0001_*-4-all-chain-A.pdb
Is there a way to run the command script with foreach while opening chimerax? for example:
$:chimerax --nogui chimera-data-processing.cxc foreach S_0001_*-4-all-chain-A.pdb
If I run this it give me a bunch of python errors and errors related to $file. The workaround I made was to have the master bash script write a new chimera script on the fly every time with the user inputted filenames saved in the master bash script.
masterscript.sh:
###run in terminal: "./masterscript.sh S_0001_ hsk2-template-with-metals.pdb
pdbstoalign=$1
pdbwithmetals=$2
###$1 and $2 are equal to the user input while starting the script
###pdb editing stuff happening
if ($x = 5) ###5th alignment
###create foreach running script
echo "open chimera-data-processing.cxc foreach $pdbstoalign-[1-1000]-all-chain-A.pdb" > chimeraxrun.cxc
echo "quit" >> chimeraxrun.cxc
###create data processing script
echo 'open $file.pdb' > chimera-data-processing.cxc ###print exactly this line not variable $file
echo "open $pdbwithmetals" >> chimera-data-processing.cxc
echo "info" >> chimera-data-processing.cxc
echo "align #1:240-244,765-769,1290-1294,1815-1819@o to_atoms #2:240-244,765-769,1290-1294,1815-1819@o matchAtomNames true; wait 300" >> chimera-data-processing.cxc
echo "save $file-sf-aligned.pdb #1 format pdb relModel #2; wait 30" >> chimera-data-processing.cxc
chimerax --nogui chimeraxrun.cxc
###pdb processing with output
chimeraxrun.cxc:
open foreach chimera-data-processing.cxc foreach S_0001_[1-1000]-4-all-chain-A.pdb ###pdb filename comes from bash script
chimera-data-processing:
open $file.pdb
open hsk2-template-with-metals.pdb ###filename from bash master script
info
align #1:240-244,765-769,1290-1294,1815-1819@o to_atoms #2:240-244,765-769,1290-1294,1815-1819@o matchAtomNames true; wait 300
save $file-sf-aligned.pdb #1 format pdb relModel #2; wait 30
While this works it is very messy and I need to create multiple files on the fly. It would be much easier if I could pass variables into the chimerax scripts that I can use inside the script. Does this make any sense?
Clarification:
Hopefully the above example scripts clarifies why I asked about $file1 and $file2. I have 2 input files. a model with no metals and a template with models I need to align onto.
Updating issues:
I forgot to mention that I tried updating chimerax-daily with this command
sudo /usr/bin/chimerax-daily -m pip install --upgrade pip
which gave a success code. But when I checked the version via chimerax-daily --version I get this version.
UCSF ChimeraX version: 0.93 (2020-03-24)
Is there a way to update to the newest version without reinstalling? I found toolshed update documentation but this appears to be for packages not the entire build. As you can see it is not them most updated version. I downloaded bother chimerax and chimerax-daily again. chimerax installed and used foreach with no errors. However, chimerax-daily will not install unless I do a complete uninstall so I think I'll go forward with chimerax.
Another thing I noticed, while attempting ranges with chimerax-daily it only took single digit ranges. For example
S_0001-[1-10]-chain-A.pdb if only took pdbs with "1" in place of the range. if the range is 1-9 then it takes all files. If the range is 01-19 (trying to match number of digits) if only takes models 1 and 9. I get what it is doing here but I don't know the fix or if I'm doing it right. I'm just using a range for now to test 9 files instead of the full 1000. I'll replace the numbering with a '*' so it'll get them all. I won't have an issues going forward but thought this was significant for others in the future if I had typed it wrong.
Thank you again for your time and help,
Ryan