Skip to content

Commit

Permalink
pass Mozilla User-Agent to all Ensembl queries; see saezlab/CollecT…
Browse files Browse the repository at this point in the history
  • Loading branch information
deeenes committed Jul 2, 2024
1 parent ff3cc83 commit 14ac90a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 8 additions & 2 deletions pypath/inputs/biomart.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import pypath.share.common as common
import pypath_common.data as _data
import pypath.share.curl as curl
import pypath.share.settings as settings
import pypath.resources.urls as urls
import pypath.utils.taxonomy as taxonomy

Expand Down Expand Up @@ -135,7 +136,12 @@ def biomart_query(
xml_query = rewsp.sub('', xml_query)

biomart_url = urls.urls['ensembl']['biomart_url'] % xml_query
c = curl.Curl(biomart_url, large = True, silent = False)
c = curl.Curl(
biomart_url,
req_headers = [settings.get('user_agent')],
large = True,
silent = False,
)
success = False

for line in c.result:
Expand Down Expand Up @@ -231,7 +237,7 @@ def biomart_microarray_types(organism: int | str = 9606):
organism = taxonomy.ensure_ensembl_name(organism)

url = urls.urls['ensembl']['arraytypes'] % organism
c = curl.Curl(url)
c = curl.Curl(url, req_headers = [settings.get('user_agent')])
result = json.loads(c.result)

_ = [
Expand Down
3 changes: 2 additions & 1 deletion pypath/inputs/ensembl.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import pypath.resources.urls as urls
import pypath.share.curl as curl
import pypath.share.settings as settings


"""
Expand All @@ -43,7 +44,7 @@ def ensembl_organisms():
record = None
result = []
url = urls.urls['ensembl']['species']
c = curl.Curl(url)
c = curl.Curl(url, req_headers = [settings.get('user_agent')])

with warnings.catch_warnings():

Expand Down

0 comments on commit 14ac90a

Please sign in to comment.