Hi Osvaldo, A3) PyMOL captures sys.stdout, but you can reclaim it:
import sys, pymol stdout = sys.stdout pymol.finish_launching() sys.stdout = stdout B4) "cmd" is your ServerProxy instance, so don't import anything "from pymol" Cheers, Thomas On 24 Aug 2014, at 13:36, Osvaldo Martin <[email protected]> wrote: > I was trying to use pymol within Ipython notebook, but I can get all the > functionality of PyMOL and/or Ipython, let me explain. > > I tried the following two options: > > A) Like a normal script > > 1) I lauch PyMOL (inside the ipython notebook) > import pymol > from pymol import cmd, stored > pymol.finish_launching() > > 2) I do stuff like > cmd.load('mol.pdb') > > 3) I import custom python/pymol code without any problem > > The problem with this approach is that the output of commands like > "cmd.get_area" are rendered inside the notebook, but the output of commands > like "ls" are rendered inside PyMOL terminal. > > B) Like a remote connection > > 1) I lunch pymol using "pymol -R" > 2) I Lunch the XML-RPC server (inside the notebook) by doing > > from xmlrpclib import ServerProxy > cmd = ServerProxy(uri="http://localhost:9123/RPC2") > > 3) I do stuff like > cmd.load('mol.pdb') > > 4) I try to import custom python/pymol code e.g somethin like > > from pymol import cmd, stored > > def get_phi(res_num): > if res_num != 0: > cmd.select('A', 'resi %s and name C' % (res_num-1)) > cmd.select('B', 'resi %s and name N' % res_num) > cmd.select('C', 'resi %s and name CA' % res_num) > cmd.select('D', 'resi %s and name C' % res_num) > return cmd.get_dihedral('A', 'B', 'C', 'D') > else: > return float('nan') > > and I get the error "'module' object has no attribute 'glutThread'", normally > this will be fixed by adding the line 'pymol.finish_launching()', but If I do > that Ipython get locked (waiting to launch a new PyMOL session). -- Thomas Holder PyMOL Developer Schrödinger, Inc. ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/ _______________________________________________ PyMOL-users mailing list ([email protected]) Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users Archives: http://www.mail-archive.com/[email protected]
