The explanation will be given in the following environment. Linux: 3.13.0-37-generic #64-Ubuntu
Python 2.7.6
<module name>.path
>>> import pymol
>>> pymol.__path__
['/usr/lib/python2.7/dist-packages/pymol']
[hnishi@hn python_pymol]$ sudo apt-get install python-biopython
help(<module name>)
>>> import Bio
>>> help(Bio)
** pymol -c **: open pymol with CUI only
cui_pymol.py
import pymol
pymol.pymol_argv = ['pymol','-c']
pymol.finish_launching()
pymol.cmd.fetch("4m61")
Output result
[hnishi@hn python_pymol]$ python cui_pymol.py
PyMOL(TM) Molecular Graphics System, Version 1.7.0.0.
Copyright (c) Schrodinger, LLC.
All Rights Reserved.
Created by Warren L. DeLano, Ph.D.
PyMOL is user-supported open-source software. Although some versions
are freely available, PyMOL is not in the public domain.
If PyMOL is helpful in your work or study, then please volunteer
support for our ongoing efforts to create open and affordable scientific
software by purchasing a PyMOL Maintenance and/or Support subscription.
More information can be found at "http://www.pymol.org".
Enter "help" for a list of commands.
Enter "help <command-name>" for information on a specific command.
Hit ESC anytime to toggle between text and graphics.
Command mode. No graphics front end.
PyMOL: normal program termination.
With the option pymol -q
, you can hide the version information etc. that appears at the beginning of the log (Quiet).
For options when starting pymol http://pymolwiki.org/index.php/Command_Line_Options reference
** pymol.cmd.iterate_state (\ <state >, \ <selection >, \ <expression >) **: pymol function and object information
iterate_state.py
#!/usr/bin/python2.7 -i
import sys, os
### pymol launching
import pymol
pymol.pymol_argv = ['pymol','-qc'] + sys.argv[1:]
pymol.finish_launching()
cmd = pymol.cmd
### read pdb
r = cmd.fetch("4m61","obj1")
print r
cmd.iterate_state(1, "obj1 and name CA and resi 3 and chai A", "print x,y,z") #print coordinates
Output result
[hnishi@hn python_pymol]$ python iterate_state.py
obj1
9.97799968719 35.7999992371 20.9699993134
The mystery that there are 4 digits or less even though the value is up to 3 decimal places on the PDB file.
Source cui_pymol.py https://gist.github.com/hnishi/3b9a3247a4bc356e17c7.js
gui_pymol.py
#!/usr/bin/env python
# Tell PyMOL we don't want any GUI features.
# It runs PyMol fullscreen stereo, and disables the internal gui.
import __main__
__main__.pymol_argv = [ 'pymol', '-qei' ] #$ pymol -qei
# Importing the PyMOL module will create the window.
import pymol
# Call the function below before using any PyMOL modules.
pymol.finish_launching()
[hnishi@hn python_pymol]$ python gui_pymol.py
The pymol window launches in full screen.
The internal GUI function is turned off. Instead, it's light enough to run slimy from the server via x-window.
dir(<something>)
python2.7
>>> import Bio
>>> print dir(Bio)
['BiopythonDeprecationWarning', 'BiopythonExperimentalWarning', 'BiopythonParserWarning', 'BiopythonWarning', 'MissingExternalDependencyError', 'MissingPythonDependencyError', '__builtins__', '__doc__', '__docformat__', '__file__', '__name__', '__package__', '__path__', '__version__']
from multiprocessing import Pool a = range(100) a p = Pool()
How to write a pymol script http://qiita.com/hnishi/items/e77b270ad1a6d574d6cc
Use pymol from python http://pymolwiki.org/index.php/Launching_From_a_Script Extract object information in pymol http://www.pymolwiki.org/index.php/Simple_Scripting
Recommended Posts