Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xref-queries always 404 #18

Closed
RickardSjogren opened this issue Apr 6, 2017 · 1 comment
Closed

Xref-queries always 404 #18

RickardSjogren opened this issue Apr 6, 2017 · 1 comment
Labels
Milestone

Comments

@RickardSjogren
Copy link
Contributor

It's not possible to perform cross-reference queries (version 1.0.3, Python 3.6.1). For instance the query:
https://pubchem.ncbi.nlm.nih.gov/rest/pug/substance/xref/PatentID/US6187568B1/sids/JSON

Can be formulated as:

import pubchempy as pcp
response = pcp.request('US6187568B1', 'PatentID', 'substance', operation='sids', searchtype='xref')

However, this request 404:s since the ID is sent as payload data instead of inserted in the URL here.

@RickardSjogren
Copy link
Contributor Author

A fix would be to change these lines to:

if namespace in ['listkey', 'formula', 'sourceid'] or searchtype == 'xref' or (searchtype and namespace == 'cid') or domain == 'sources':
    urlid = quote(identifier.encode('utf8'))

Then it would be nice to be able to use the short-hand:
sids = pcp.get_sids('US6187568B1', 'PatentID', 'substance', searchtype='xref'),
But doing this produces the wrong query since the operation is explicitly set None in get when setting searchtype.
However, passing on searchtype breaks TestRequest.test_listkey_requests

@mcs07 mcs07 closed this as completed in 3decff9 Apr 10, 2017
mcs07 added a commit that referenced this issue Apr 10, 2017
Allow requests with xref input
@mcs07 mcs07 added the bug label Apr 11, 2017
@mcs07 mcs07 modified the milestone: v1.0.4 Apr 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants