cxhernandez / ipymol

Control PyMOL sessions via IPython
MIT License
55 stars 19 forks source link

3 issues #14

Closed MooersLab closed 5 years ago

MooersLab commented 7 years ago

(1) I used juptyer notebook for python35. I had trouble with your examples notebook. I had add to replace "pymol" with "pymol._server" to get it to work.

(2) pymol._server.help('fetch') did not work even though help is listed when I do pymol._server.system.listMethods()

(3) The module ipymol is calling pymol from macports. I would like to redirect ipymol to call pymol 2.0.0 from my Applications folder on my Mac.

cxhernandez commented 7 years ago

Could you provide tracebacks for (1) and (2)? (3) is probably because executables installed by macports have priority in your PATH. Look at this post for more info on how to solve this.

MooersLab commented 7 years ago

Hi Carlos,

Sorry for the delay. Been busy teaching.

(1)

pymol.fetch('4mbs','second')

---------------------------------------------------------------------------AttributeError Traceback (most recent call last) in ()----> 1 pymol.fetch('4mbs','second') AttributeError: 'MolViewer' object has no attribute 'fetch'

(2) pymol._server.help('fetch') did not work even though help is listed when I do pymol._server.system.listMethods()

pymol._server.help('fetch')

---------------------------------------------------------------------------ConnectionRefusedError Traceback (most recent call last) in ()----> 1 pymol._server.help('fetch') /opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/xmlrpc/client.py in call(self, args) 1090 return _Method(self.send, "%s.%s" % (self.name, name)) 1091 def call(self, args):-> 1092 return self.send(self.name, args) 1093 1094 ## /opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/xmlrpc/client.py in request(self, methodname, params) 1430 self.handler, 1431 request,-> 1432 verbose=self.__verbose 1433 ) 1434 /opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/xmlrpc/client.py in request(self, host, handler, request_body, verbose) 1132 for i in (0, 1): 1133 try:-> 1134 return self.single_request(host, handler, request_body, verbose) 1135 except http.client.RemoteDisconnected: 1136 if i: /opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/xmlrpc/client.py in single_request(self, host, handler, request_body, verbose) 1144

issue XML-RPC request 1145 try:-> 1146

http_conn = self.send_request(host, handler, request_body, verbose) 1147 resp = http_conn.getresponse() 1148 if resp.status == 200: /opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/xmlrpc/client.py in send_request(self, host, handler, request_body, debug) 1257 headers.append(("User-Agent", self.user_agent)) 1258 self.send_headers(connection, headers)-> 1259 self.send_content(connection, request_body) 1260 return connection 1261 /opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/xmlrpc/client.py in send_content(self, connection, request_body) 1287 1288 connection.putheader("Content-Length", str(len(request_body)))-> 1289 connection.endheaders(request_body) 1290 1291 ## /opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py in endheaders(self, message_body) 1101 else: 1102 raise CannotSendHeader()-> 1103 self._send_output(message_body) 1104 1105 def request(self, method, url, body=None, headers={}): /opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py in _send_output(self, message_body) 932 del self._buffer[:] 933 --> 934 self.send(msg) 935 if message_body is not None: 936 self.send(message_body) /opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py in send(self, data) 875 if self.sock is None: 876 if self.auto_open:--> 877 self.connect() 878 else: 879 raise NotConnected() /opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py in connect(self) 847 """Connect to the host and port specified in init.""" 848 self.sock = self._create_connection(--> 849 (self.host,self.port), self.timeout, self.source_address) 850 self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 851 /opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/socket.py in create_connection(address, timeout, source_address) 710 711 if err is not None:--> 712 raise err 713 else: 714 raise error("getaddrinfo returns an empty list") /opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/socket.py in create_connection(address, timeout, source_address) 701 if source_address: 702 sock.bind(source_address)--> 703 sock.connect(sa) 704 return sock 705

(3) I got this working correctly now for some reason.

On Tue, Sep 26, 2017 at 3:06 PM, Carlos Hernández notifications@github.com wrote:

Could you provide tracebacks for (1) and (2)? (3) is probably because executables installed by macports have priority in your PATH. Look at this post https://superuser.com/a/51668 for more info on how to solve this.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cxhernandez/ipymol/issues/14#issuecomment-332319299, or mute the thread https://github.com/notifications/unsubscribe-auth/AOeSC3-k9Q9A7JZUASaGv6Y9f6NFBQV4ks5smVk4gaJpZM4PjA0a .

--

Blaine Mooers, Ph.D. Associate Professor Department of Biochemistry and Molecular Biology University of Oklahoma Health Sciences Center S.L. Young Biomedical Research Center Rm. 466

Letter address: Shipping address: P.O. Box 26901, BRC 466 975 NE 10th Street, BRC 466 Oklahoma City, OK 73190 Oklahoma City, OK 73104-5419

office: (405) 271-8300 lab: (405) 271-8313 fax: (405) 271-3910 e-mail: blaine-mooers@ouhsc.edu (or bmooers1@gmail.com) http://www.oumedicine.com/body.cfm?id=3877&oTopID=3877

cxhernandez commented 7 years ago

@MooersLab: Would you mind installing the latest version of the master branch (which incorporates fixes in #15) and see if that solves your issue?

MooersLab commented 7 years ago

Hi Carlos,

Thank you for the follow-up.

I used the deleted the old ipymol.

I installed the new ipymol from github with python 2.7.

I used the example notebook.

The first cell runs without error and opens a new instance of PyMOL.

The second cell gives the following error.

pymol.fetch('4MBS')

---------------------------------------------------------------------------AttributeError Traceback (most recent call last) in ()----> 1 pymol.fetch('4MBS') AttributeError: 'MolViewer' object has no attribute 'fetch'

Best regards,

Blaine

On Fri, Nov 3, 2017 at 5:00 PM, Carlos Hernández notifications@github.com wrote:

@MooersLab https://github.com/mooerslab: Would you mind installing the latest version of the master branch (which incorporates fixes in #15 https://github.com/cxhernandez/ipymol/pull/15) and see if that solves your issue?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cxhernandez/ipymol/issues/14#issuecomment-341837974, or mute the thread https://github.com/notifications/unsubscribe-auth/AOeSC3zJJk3cTjqmFS1sJKT6IUDloSGOks5sy40ZgaJpZM4PjA0a .

--

Blaine Mooers, Ph.D. Associate Professor Department of Biochemistry and Molecular Biology University of Oklahoma Health Sciences Center S.L. Young Biomedical Research Center Rm. 466

Letter address: Shipping address: P.O. Box 26901, BRC 466 975 NE 10th Street, BRC 466 Oklahoma City, OK 73190 Oklahoma City, OK 73104-5419

office: (405) 271-8300 lab: (405) 271-8313 fax: (405) 271-3910 e-mail: blaine-mooers@ouhsc.edu (or bmooers1@gmail.com) http://www.oumedicine.com/body.cfm?id=3877&oTopID=3877

cxhernandez commented 6 years ago

Just received word from Schrödinger that this is an issue on their end in the latest version of PyMOL (v2.0.4), but that they're hoping to address it in an upcoming release. For the time being, ipymol only works with v1.86 and below of PyMOL.

MooersLab commented 6 years ago

Hi Carlos,

Thank you very much for following up with Schrödinger.

On Mon, Jan 29, 2018 at 5:15 PM, Carlos Hernández notifications@github.com wrote:

Just received word from Schrödinger that this is an issue on their end in the latest version of PyMOL (v2.0.4), but that they're hoping to address it in an upcoming release. For the time being, ipymol only works with v1.86 and below of PyMOL.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cxhernandez/ipymol/issues/14#issuecomment-361420144, or mute the thread https://github.com/notifications/unsubscribe-auth/AOeSC7yXgf2D4n02_6I5MY56wxmf2LHdks5tPlD5gaJpZM4PjA0a .

-- Best regards,

Blaine

Blaine Mooers, Ph.D. Associate Professor Department of Biochemistry and Molecular Biology College of Medicine University of Oklahoma Health Sciences Center S.L. Young Biomedical Research Center Rm. 466 975 NE 10th Street https://maps.google.com/?q=975+NE+10th+Street&entry=gmail&source=g, BRC 466 Oklahoma City, OK 73104-5419

office: (405) 271-8300 lab: (405) 271-8313

Faculty webpage http://tinyurl.com/ouhscMooers X-ray lab (LBSF) http://research.ouhsc.edu/CoreFacilities/LaboratoryofBiomolecularStructureandFunction.aspx COBRE in Structural Biology http://structuralbiology.ou.edu/ SSRL UEC Facebook Page https://www.facebook.com/ssrluec/ SSRL UEC https://www-ssrl.slac.stanford.edu/content/about-ssrl/advisory-panels/ssrl-users-organization/members/ssrluo-2016-executive-committee-members SSRL SAC https://www-ssrl.slac.stanford.edu/content/about-ssrl/scientific-advisory-committee LCLS UEC https://www-ssrl.slac.stanford.edu/lcls-resources/lcls-users-organization-executive-committee

EasyPyMOL https://github.com/MooersLab/EasyPyMOL Molecular Graphics https://www.oumedicine.com/docs/default-source/ad-biochemistry-workfiles/moleculargraphicslinks.html

https://www.oumedicine.com/docs/default-source/ad-biochemistry-workfiles/MolecularGraphicsLinks.html Small Angle Scattering http://www.oumedicine.com/docs/default-source/ad-biochemistry-workfiles/small-angle-scattering-links-27aug2014.html?sfvrsn=0 office: (405) 271-8300 lab: (405) 271-8313 e-mail: blaine-mooers@ouhsc.edu (or bmooers1@gmail.com)

MooersLab commented 5 years ago

I updated ipymol with git pull origin master. I have PyMOL 2.2.3. I am using macports python3.7. screen shot 2019-02-07 at 7 40 15 am

from ipymol import viewer as pymol
pymol.start()
pymol.fetch('3odu')

Success with pymol.fetch!!!

pymol.display()

returns an error message to the Jupyter notebook as shown in the snapshot.

Wytamma commented 5 years ago

cmd.png() saves the file with .png, but the namedtemporaryfile name attribute has no suffix.

You could write your own display function.

import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import tempfile

def display(self):
    with tempfile.NamedTemporaryFile(suffix='.png') as fh:
        self._server.do("png {};".format(fh.name))
        imgplot = plt.imshow((mpimg.imread(fh.name)))
    # The tmp file may not delete so you might need to add 'os.remove(fh.name)' here. 
    return imgplot

Then run display(pymol)

cxhernandez commented 5 years ago

@Wytamma: do you mind contributing your solution as a PR?

cxhernandez commented 5 years ago

Should be resolved by #18