jrderuiter / pybiomart

A simple pythonic interface to biomart.
MIT License
53 stars 11 forks source link

problem with accessing mouse regulatory features #17

Open ooakley opened 4 years ago

ooakley commented 4 years ago

So I'm trying to look at regulatory regions in the mouse genome across different epigenomic states - however when trying to access the epigenome_name attribute I get a connection error:

ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

Here's the code that should allow for some reproduction of what's going on - although I'm very much new to biomart so understand that I could be doing something particularly stupid!

server = pybiomart.Server(host='http://www.ensembl.org')
mart = server["ENSEMBL_MART_FUNCGEN"]
dataset = mart["mmusculus_regulatory_feature"]
query_attributes = ["chromosome_name", "chromosome_start", "chromosome_end", "epigenome_name"]
query_filters = {"chromosome_name": ["1"], "regulatory_feature_type_name": ["CTCF Binding Site"]}
ctcf_sites = dataset.query(attributes=query_attributes, filters=query_filters)

Querying for epigenome name on its own also results in an identical error (as below) - queries that don't include epigenome_name in either an attribute list or filter dict work as normal.

epigenome_df = dataset.query(attributes=["epigenome_name"])

I'm working on Mac OS Catalina, Version 10.15.2 (19C57)

ooakley commented 4 years ago

The full error is as follows:

---------------------------------------------------------------------------
RemoteDisconnected                        Traceback (most recent call last)
~/Documents/GitHub/VMIAP/venv/lib/python3.7/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    671                 headers=headers,
--> 672                 chunked=chunked,
    673             )

~/Documents/GitHub/VMIAP/venv/lib/python3.7/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    420                     # Otherwise it looks like a bug in the code.
--> 421                     six.raise_from(e, None)
    422         except (SocketTimeout, BaseSSLError, SocketError) as e:

~/Documents/GitHub/VMIAP/venv/lib/python3.7/site-packages/urllib3/packages/six.py in raise_from(value, from_value)

~/Documents/GitHub/VMIAP/venv/lib/python3.7/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    415                 try:
--> 416                     httplib_response = conn.getresponse()
    417                 except BaseException as e:

/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py in getresponse(self)
   1343             try:
-> 1344                 response.begin()
   1345             except ConnectionError:

/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py in begin(self)
    305         while True:
--> 306             version, status, reason = self._read_status()
    307             if status != CONTINUE:

/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py in _read_status(self)
    274             # sending a valid response.
--> 275             raise RemoteDisconnected("Remote end closed connection without"
    276                                      " response")

RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

ProtocolError                             Traceback (most recent call last)
~/Documents/GitHub/VMIAP/venv/lib/python3.7/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    448                     retries=self.max_retries,
--> 449                     timeout=timeout
    450                 )

~/Documents/GitHub/VMIAP/venv/lib/python3.7/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    719             retries = retries.increment(
--> 720                 method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
    721             )

~/Documents/GitHub/VMIAP/venv/lib/python3.7/site-packages/urllib3/util/retry.py in increment(self, method, url, response, error, _pool, _stacktrace)
    399             if read is False or not self._is_method_retryable(method):
--> 400                 raise six.reraise(type(error), error, _stacktrace)
    401             elif read is not None:

~/Documents/GitHub/VMIAP/venv/lib/python3.7/site-packages/urllib3/packages/six.py in reraise(tp, value, tb)
    733             if value.__traceback__ is not tb:
--> 734                 raise value.with_traceback(tb)
    735             raise value

~/Documents/GitHub/VMIAP/venv/lib/python3.7/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    671                 headers=headers,
--> 672                 chunked=chunked,
    673             )

~/Documents/GitHub/VMIAP/venv/lib/python3.7/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    420                     # Otherwise it looks like a bug in the code.
--> 421                     six.raise_from(e, None)
    422         except (SocketTimeout, BaseSSLError, SocketError) as e:

~/Documents/GitHub/VMIAP/venv/lib/python3.7/site-packages/urllib3/packages/six.py in raise_from(value, from_value)

~/Documents/GitHub/VMIAP/venv/lib/python3.7/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    415                 try:
--> 416                     httplib_response = conn.getresponse()
    417                 except BaseException as e:

/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py in getresponse(self)
   1343             try:
-> 1344                 response.begin()
   1345             except ConnectionError:

/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py in begin(self)
    305         while True:
--> 306             version, status, reason = self._read_status()
    307             if status != CONTINUE:

/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py in _read_status(self)
    274             # sending a valid response.
--> 275             raise RemoteDisconnected("Remote end closed connection without"
    276                                      " response")

ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

ConnectionError                           Traceback (most recent call last)
<ipython-input-7-4a7274907f9d> in <module>
----> 1 epigenome_df = dataset.query(attributes=["epigenome_name"])

~/Documents/GitHub/VMIAP/venv/lib/python3.7/site-packages/pybiomart/dataset.py in query(self, attributes, filters, only_unique, use_attr_names)
    260 
    261         # Fetch response.
--> 262         response = self.get(query=ElementTree.tostring(root))
    263 
    264         # Raise exception if an error occurred.

~/Documents/GitHub/VMIAP/venv/lib/python3.7/site-packages/pybiomart/base.py in get(self, **params)
    105         """
    106         if self._use_cache:
--> 107             r = requests.get(self.url, params=params)
    108         else:
    109             with requests_cache.disabled():

~/Documents/GitHub/VMIAP/venv/lib/python3.7/site-packages/requests/api.py in get(url, params, **kwargs)
     73 
     74     kwargs.setdefault('allow_redirects', True)
---> 75     return request('get', url, params=params, **kwargs)
     76 
     77 

~/Documents/GitHub/VMIAP/venv/lib/python3.7/site-packages/requests/api.py in request(method, url, **kwargs)
     58     # cases, and look like a memory leak in others.
     59     with sessions.Session() as session:
---> 60         return session.request(method=method, url=url, **kwargs)
     61 
     62 

~/Documents/GitHub/VMIAP/venv/lib/python3.7/site-packages/requests_cache/core.py in request(self, method, url, params, data, **kwargs)
    134             _normalize_parameters(params),
    135             _normalize_parameters(data),
--> 136             **kwargs
    137         )
    138         if self._is_cache_disabled:

~/Documents/GitHub/VMIAP/venv/lib/python3.7/site-packages/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    531         }
    532         send_kwargs.update(settings)
--> 533         resp = self.send(prep, **send_kwargs)
    534 
    535         return resp

~/Documents/GitHub/VMIAP/venv/lib/python3.7/site-packages/requests_cache/core.py in send(self, request, **kwargs)
    107 
    108         if response is None:
--> 109             return send_request_and_cache_response()
    110 
    111         if self._cache_expire_after is not None:

~/Documents/GitHub/VMIAP/venv/lib/python3.7/site-packages/requests_cache/core.py in send_request_and_cache_response()
     95 
     96         def send_request_and_cache_response():
---> 97             response = super(CachedSession, self).send(request, **kwargs)
     98             if response.status_code in self._cache_allowable_codes:
     99                 self.cache.save_response(cache_key, response)

~/Documents/GitHub/VMIAP/venv/lib/python3.7/site-packages/requests/sessions.py in send(self, request, **kwargs)
    644 
    645         # Send the request
--> 646         r = adapter.send(request, **kwargs)
    647 
    648         # Total elapsed time of the request (approximately)

~/Documents/GitHub/VMIAP/venv/lib/python3.7/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    496 
    497         except (ProtocolError, socket.error) as err:
--> 498             raise ConnectionError(err, request=request)
    499 
    500         except MaxRetryError as e:

ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))