Molecule Tutorials - Herong's Tutorial Examples - v1.26, by Herong Yang
Run Python Statements from PyMol
This section provides a tutorial on how to Run Python Statements from PyMol.
PyMol allows you to run Python statements automatically, if you have Python installed on your system.
If you just want to run a single Python statement, just enter the statement as is at the "PyMOL>" prompt or in a command script: For example:
PyMOL> print 1 + 2 3
If you want to run a statement block, then you need to add a backslash ('\') at the end of each statement except the last statement. For example:
PyMOL>for a in range(1,6): \ PyMOL> b = 6 - a \ PyMOL> print(a, b) 1 5 2 4 3 3 4 2 5 1
Note that you can not use PyMol commands inside a Python statement block. For example, if you try to turn the camera in a loop, you will get an error.
PyMOL>for a in range(1, 36): \ PyMOL> turn y, 10 File "toplevel", line 2 turn y, 10 ^ SyntaxError: invalid syntax
Python variables are not allowed in PyMol commands either:
PyMOL>angle = 45 PyMOL>turn y, angle Traceback (most recent call last): File "/Applications/PyMOL.app/.../viewing.py", line 1411, in turn r = _cmd.turn(_self._COb,str(axis),float(angle)) ValueError: could not convert string to float: 'angle'
As you can see, integrating Python statements into PyMol command scripts is not that useful.
Table of Contents
Molecule Names and Identifications
Nucleobase, Nucleoside, Nucleotide, DNA and RNA
►Run Python Statements from PyMol
Launch PyMol from Python Interpreter
PyMol Python API Only Functions
ChEMBL Database - European Molecular Biology Laboratory
PubChem Database - National Library of Medicine
INSDC (International Nucleotide Sequence Database Collaboration)
HGNC (HUGO Gene Nomenclature Committee)