Hi Martin, the recommended way is to use PyMOL as your python interpreter, so instead of:
python file.py do this: pymol -cqr file.py However, launching a PyMOL process from a python terminal as you suggested is also possible. Have a look at Example 2 of http://pymolwiki.org/index.php/Launching_From_a_Script , the important lines are those: import pymol pymol.pymol_argv = ['pymol','-qc'] pymol.finish_launching() Cheers, Thomas Martin Hediger wrote, On 11/22/11 09:26: > Dear PyMOL List > It comes up once in a while, is it possible to use PyMOL features from > outside of PyMOL? An example, the below is a script (inspired by Thomas > Holder) which saves down to disk all amino acids of a protein structure > into separate PDB files. > > # ***************************************************************** > from pymol import cmd > from pymol import stored > from pymol.exporting import _resn_to_aa as one_letter > # ***************************************************************** > def seq(state, selection="name ca or resn hoh or resn lig"): > print "Generating seqs." > cmd.select("prot", selection) > while cmd.pop("_tmp", "prot"): > cmd.iterate("_tmp", "stored.x=(resn,resv)") > #print stored.x[0], stored.x[1] > > # Special case 1: Waters. > if stored.x[0] == 'HOH': > filename = 'seq-x%s-%s.pdb' % (stored.x[1], state) > # Special case 2: Substrate. > elif stored.x[0] == 'LIG': > filename = 'seq-x%s-%s.pdb' % (stored.x[1], state) > # Other: protein back-bone. > else: > filename = 'seq-%s%d-%s.pdb' % (one_letter[stored.x[0]].lower(), > stored.x[1], state) > cmd.save(filename, "byres _tmp") > cmd.delete('_tmp prot') > > cmd.extend('seq', seq) > # ----------------------------------------------------------------- > > Is it possible to somehow include this in a Python script, and running > it from the command line? If not, why? > > > Thanks for any feedback. -- Thomas Holder MPI for Developmental Biology Spemannstr. 35 D-72076 Tübingen ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d _______________________________________________ PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net) Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net