Ben,
Here are two answers:
A) If you absolutely need to pipe commands into PyMOL, then you should use
the -K option to keep PyMOL from automatically quitting once standard input
has been exhausted:
echo '...;quit' | pymol -pKcq
Note that the '-i' and '-x' options are superfluous with '-c'.
B) However, a cleaner approach would be to run the Python script as the
first argument to PyMOL followed by a -d statement.
pymol -cq BuildHelix.py -d 'BuildMe("AAAAAAAAA")'
Cheers,
Warren
--
DeLano Scientific LLC
Subscriber Support Services
mailto:[email protected]
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf
> Of Benjamin Hall
> Sent: Thursday, April 24, 2008 8:35 AM
> To: [email protected]
> Subject: [PyMOL] Problem Saving Molecules from batch mode
>
> Hi
>
> I'm writing a short script to use pymol to generate "ideal"
> alpha helices out of arbitrary sequences. I use a short
> script, BuildHelix.py:
>
> from pymol import cmd, stored
>
> def BuildMe(sequence):
> cmd.set("secondary_structure",1.00)
> for aa in sequence: cmd._alt(string.lower(aa))
> cmd.save(sequence+".pdb")
>
> cmd.extend( "BuildMe", BuildMe )
>
> I can then run this from the gui prompt, or in interactive
> mode without the gui without issue, as follows:
>
> run BuildHelix.py
> BuildMe("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
> quit
>
> However, as I want to use this in an automated way, I have
> been trying this command:
>
> echo 'run
> BuildHelix.py\nBuildMe("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")\nq
uit\n)' | pymol -xpic
>
> This works intermittently, roughly 1 in 3 or 4 times. Adding
> cmd.sync() lines to either the script or the command doesn't
> change the results.
> However, if I use the command "quit()" (rather than "quit"),
> pymol crashes with an error in threading.py and the file is
> correctly written out. The error given is
>
> PyMOL>quit()
> Traceback (most recent call last):
> File "/var/lib/python-support/python2.5/pymol/parser.py",
> line 456, in parse
> exec(layer.com2+"\n",self.pymol_names,self.pymol_names)
> File "<string>", line 1, in <module>
> File "site.py", line 256, in __call__
> raise SystemExit(code)
> SystemExit: None
> Exception in thread Thread-1:
> Traceback (most recent call last):
> File "threading.py", line 460, in __bootstrap
> self.run()
> File "threading.py", line 440, in run
> self.__target(*self.__args, **self.__kwargs)
> File "/var/lib/python-support/python2.5/pymol/parser.py",
> line 500, in stdin_reader
> l = sys.stdin.readline()
> ValueError: I/O operation on closed file
>
> I'm running version 1.0re1, though I have also tested with 0.98.
>
> Any advice would be much appreciated. Thanks in advance
>
> Ben Hall
>
> --------------------------------------------------------------
> -----------
> This SF.net email is sponsored by the 2008 JavaOne(SM)
> Conference Don't miss this year's exciting event. There's
> still time to save $100.
> Use priority code J8TL2D2.
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java
.sun.com/javaone
> _______________________________________________
> PyMOL-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pymol-users