Chimera scripting with --nogui can't write pdb files

Hey guys, i've been trying to put together a command line only set of scripts that will do some selection processing and save a pdb without going through the gui. If I use the command chimera --nogui --script close.py pdb1.pdb pdb2.pdb where close.py contains select #0 za<3 & #1:HOH write selected 1 output.pdb I should get the residues that match that selection criteria saved as the pdb output.pdb, correct? I get SyntaxError: invalid syntax for line 2 even though this works OUTSIDE a script. as in, if I just run chimera command line and enter those commands sequentially, it works. I also noticed that within the gui I need "#1" and outside it only works with '1" as the model number. I've also tried doing this with a python script: chimera --nogui --nostatus --script "close.py pdb1.pdb pdb2.pdb output.pdb" this should pass whatever I enter as $1 $2 $3 as arguments to my script, correct? So close.py for this version contains open (sys.argv[1]) open (sys.argv[2]) select #0 za<3 & #1:CVX write selected 1 (sys.argv[3]) which also pukes on the pdb write. I couldn't find any other way to write a pdb using python syntax, I assume the way i'm doing it is wrong, but I couldn't find a write.pdb function during my digging. Does anyone have suggestions for writing a pdb based on a selection without going through the gui? I plan on batching this up for a huge number of files and directories and going through the gui would be far too time consuming. Rebecca

Hi Rebecca, The basic problem is that your two commands aren't Python commands, they're Chimera commands and therefore produce syntax errors when executed as Python. If you just put those commands in a file named close.com instead, this should work for you: chimera --nogui pdb1.pdb pdb2.pdb close.com --Eric Eric Pettersen UCSF Computer Graphics Lab http://www.cgl.ucsf.edu On Jun 24, 2014, at 1:31 PM, rswett@chem.wayne.edu wrote:
Hey guys, i've been trying to put together a command line only set of scripts that will do some selection processing and save a pdb without going through the gui.
If I use the command chimera --nogui --script close.py pdb1.pdb pdb2.pdb
where close.py contains
select #0 za<3 & #1:HOH write selected 1 output.pdb
I should get the residues that match that selection criteria saved as the pdb output.pdb, correct?
I get SyntaxError: invalid syntax for line 2 even though this works OUTSIDE a script. as in, if I just run chimera command line and enter those commands sequentially, it works. I also noticed that within the gui I need "#1" and outside it only works with '1" as the model number.
I've also tried doing this with a python script:
chimera --nogui --nostatus --script "close.py pdb1.pdb pdb2.pdb output.pdb"
this should pass whatever I enter as $1 $2 $3 as arguments to my script, correct?
So close.py for this version contains
open (sys.argv[1]) open (sys.argv[2]) select #0 za<3 & #1:CVX write selected 1 (sys.argv[3])
which also pukes on the pdb write. I couldn't find any other way to write a pdb using python syntax, I assume the way i'm doing it is wrong, but I couldn't find a write.pdb function during my digging.
Does anyone have suggestions for writing a pdb based on a selection without going through the gui? I plan on batching this up for a huge number of files and directories and going through the gui would be far too time consuming.
Rebecca
_______________________________________________ Chimera-users mailing list Chimera-users@cgl.ucsf.edu http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users
participants (2)
-
Eric Pettersen
-
rswett@chem.wayne.edu