This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to get results from a curl

Hey, I tried to do id mapping on uniprot.org. When I enter API Request, I get the following result.

curl --form 'from=UniProtKB_AC-ID' \
     --form 'to=Ensembl' \
     --form 'ids=A0A0S2Z391,Q16611,Q9Y263,Q9UL54' \
     https://rest.uniprot.org/idmapping/run

I converted this code to python (as follows)

import requests

files = {
    'from': (None, 'UniProtKB_AC-ID'),
    'to': (None, 'Ensembl'),
    'ids': (None, 'A0A0S2Z391,Q16611,Q9Y263,Q9UL54'),
}

response = requests.post('https://rest.uniprot.org/idmapping/run', files=files)

How can i extract outputs from response? I mean the conversions.

ensembl biomart uniprot

Your code currently returns:

response.json()
{'jobId': 'db942c3c2818e24dc10010136c59c89c2acdef7e'}

I have no idea, how this API works, but you get a jobId returned upon posting your request. You will likely need to use this Id to retrieve the results with a second API request somehow, but that should be documented.

You can also always check how other people did it, if you search for packages on PyPi, e.g. uniprot-cli.

0 answers

No answers yet.

Log in to answer this question.