intermine / pombemine

0 stars 1 forks source link

Can we make queries through the HTTP API #56

Closed manulera closed 2 years ago

manulera commented 2 years ago

Hello, I am Manu I work in Pombase as well.

I wanted to ask you if it's possible to make a query through http, if we have the query xml.

danielabutano commented 2 years ago

Hi @manulera yes you can, something like http://pombemine.rahtiapp.fi/pombemine/service/query/results?query={your xml query}&format={json, tsv, xml}&size=10 More details in the docuementation here The new frontend doesn't not provide yet the Web Service URL link (similar to the button in the template)

image

danielabutano commented 2 years ago

@manulera If I have answered your question, could you please close the ticket? Thanks!

manulera commented 2 years ago

Hi @danielabutano sorry for the late reply. I have been meaning to try it but I kept postponing.

That's what I had tried, but it kept not working. I realised the problem for me was that I had left the \n in the xml string. I had to run the strip() command on the string and then it worked. I suppose this can be a common issue if people have stored their queries in xml files. Maybe this is obvious for someone working often with xml. A working example in python, in case:

import requests

query = """
<query model="genomic" view="Gene.primaryIdentifier Gene.symbol Gene.organism.species Gene.alleles.primaryIdentifier Gene.alleles.description Gene.alleles.expression" constraintLogic="(A)" sortOrder="">
   <constraint path="Gene.organism.species" value="pombe" op="=" code="A"/>
</query>
"""
query = query.strip()

response = requests.get(
    f'http://pombemine.rahtiapp.fi/pombemine/service/query/results?query={query}&format={"tsv"}&size=10'
)

print(response.status_code)
print(response._content)