prody / ProDy

A Python Package for Protein Dynamics Analysis
http://prody.csb.pitt.edu
Other
435 stars 157 forks source link

searchPfam('PDB_ACC#') Infinite Query #1458

Closed mckeowr1 closed 2 years ago

mckeowr1 commented 2 years ago

Hi,

I'm having some issues using the searchPfam function. Whenever I search with a PDB_ACC# the query runs infinitely and never returns any data, the only output the command gives is @> Retrieving Pfam search results: https://pfam.xfam.org/protein/P13010?output=xml .

`import prody data = prody.searchPfam('13010', timeout = 10000)

Python Version: 3.9.5 installed with: conda install prody

When I manually kill the command I get this output: `--------------------------------------------------------------------------- KeyboardInterrupt Traceback (most recent call last) Input In [13], in ----> 1 data = prody.searchPfam('P13010', timeout = 100000)

File ~/opt/miniconda3/lib/python3.9/site-packages/prody/database/pfam.py:207, in searchPfam(query, **kwargs) 205 while LOGGER.timing('_pfam') < timeout: 206 try: --> 207 xml = openURL(url, timeout=timeout).read() 208 except Exception: 209 pass

File ~/opt/miniconda3/lib/python3.9/site-packages/prody/utilities/pathtools.py:408, in openURL(url, timeout, **kwargs) 405 request = str(url) 407 try: --> 408 return urlopen(request, timeout=int(timeout)) 409 except URLError: 410 raise IOError('{0} could not be opened for reading, invalid URL or ' 411 'no internet connection'.format(repr(request)))

File ~/opt/miniconda3/lib/python3.9/urllib/request.py:214, in urlopen(url, data, timeout, cafile, capath, cadefault, context) 212 else: 213 opener = _opener --> 214 return opener.open(url, data, timeout)

File ~/opt/miniconda3/lib/python3.9/urllib/request.py:517, in OpenerDirector.open(self, fullurl, data, timeout) 514 req = meth(req) 516 sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) --> 517 response = self._open(req, data) 519 # post-process response 520 meth_name = protocol+"_response"

File ~/opt/miniconda3/lib/python3.9/urllib/request.py:534, in OpenerDirector._open(self, req, data) 531 return result 533 protocol = req.type --> 534 result = self._call_chain(self.handle_open, protocol, protocol + 535 '_open', req) 536 if result: 537 return result

File ~/opt/miniconda3/lib/python3.9/urllib/request.py:494, in OpenerDirector._call_chain(self, chain, kind, meth_name, args) 492 for handler in handlers: 493 func = getattr(handler, meth_name) --> 494 result = func(args) 495 if result is not None: 496 return result

File ~/opt/miniconda3/lib/python3.9/urllib/request.py:1389, in HTTPSHandler.https_open(self, req) 1388 def https_open(self, req): -> 1389 return self.do_open(http.client.HTTPSConnection, req, 1390 context=self._context, check_hostname=self._check_hostname)

File ~/opt/miniconda3/lib/python3.9/urllib/request.py:1346, in AbstractHTTPHandler.do_open(self, http_class, req, **http_conn_args) 1344 try: 1345 try: -> 1346 h.request(req.get_method(), req.selector, req.data, headers, 1347 encode_chunked=req.has_header('Transfer-encoding')) 1348 except OSError as err: # timeout error 1349 raise URLError(err)

File ~/opt/miniconda3/lib/python3.9/http/client.py:1253, in HTTPConnection.request(self, method, url, body, headers, encode_chunked) 1250 def request(self, method, url, body=None, headers={}, *, 1251 encode_chunked=False): 1252 """Send a complete request to the server.""" -> 1253 self._send_request(method, url, body, headers, encode_chunked)

File ~/opt/miniconda3/lib/python3.9/http/client.py:1299, in HTTPConnection._send_request(self, method, url, body, headers, encode_chunked) 1295 if isinstance(body, str): 1296 # RFC 2616 Section 3.7.1 says that text default has a 1297 # default charset of iso-8859-1. 1298 body = _encode(body, 'body') -> 1299 self.endheaders(body, encode_chunked=encode_chunked)

File ~/opt/miniconda3/lib/python3.9/http/client.py:1248, in HTTPConnection.endheaders(self, message_body, encode_chunked) 1246 else: 1247 raise CannotSendHeader() -> 1248 self._send_output(message_body, encode_chunked=encode_chunked)

File ~/opt/miniconda3/lib/python3.9/http/client.py:1008, in HTTPConnection._send_output(self, message_body, encode_chunked) 1006 msg = b"\r\n".join(self._buffer) 1007 del self._buffer[:] -> 1008 self.send(msg) 1010 if message_body is not None: 1011 1012 # create a consistent interface to message_body 1013 if hasattr(message_body, 'read'): 1014 # Let file-like take precedence over byte-like. This 1015 # is needed to allow the current position of mmap'ed 1016 # files to be taken into account.

File ~/opt/miniconda3/lib/python3.9/http/client.py:948, in HTTPConnection.send(self, data) 946 if self.sock is None: 947 if self.auto_open: --> 948 self.connect() 949 else: 950 raise NotConnected()

File ~/opt/miniconda3/lib/python3.9/http/client.py:1415, in HTTPSConnection.connect(self) 1412 def connect(self): 1413 "Connect to a host on a given (SSL) port." -> 1415 super().connect() 1417 if self._tunnel_host: 1418 server_hostname = self._tunnel_host

File ~/opt/miniconda3/lib/python3.9/http/client.py:919, in HTTPConnection.connect(self) 917 def connect(self): 918 """Connect to the host and port specified in init.""" --> 919 self.sock = self._create_connection( 920 (self.host,self.port), self.timeout, self.source_address) 921 self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 923 if self._tunnel_host:

File ~/opt/miniconda3/lib/python3.9/socket.py:831, in create_connection(address, timeout, source_address) 829 if source_address: 830 sock.bind(source_address) --> 831 sock.connect(sa) 832 # Break explicitly a reference cycle 833 err = None

KeyboardInterrupt: `

jamesmkrieger commented 2 years ago

I'm guessing this is also due to some change on the pfam end like #1444

Hopefully, someone will have a chance to figure it out some time fairly soon

jamesmkrieger commented 2 years ago

The fix was to use request.get(url, verify=False) and now it works. I'll merge the pull request and then you should be able to use it by updating prody from github.

I'll probably make a release soon too as this seems like an important functionality for users to have fixed.

jamesmkrieger commented 2 years ago

This should now be fixed and available in ProDy 2.0.2 that can be obtained from PyPI with pip

jamesmkrieger commented 2 years ago

The conda install should be ready soon