Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: aba2d6956e
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 38 lines (31 sloc) 0.972 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
import json
import time
import urllib, urllib2
from rdflib.Graph import Graph

result_url_base = "http://biordf.net/tmp/"
query_url = "http://biordf.net/cardioSHARE/query"

query = """
PREFIX pred: <http://sadiframework.org/ontologies/predicates.owl#>
PREFIX uniprot: <http://lsrn.org/UniProt:>
SELECT ?name WHERE {
uniprot:P15923 pred:hasName ?name
}
"""

query = " ".join(query.split("\n"))
req = urllib2.Request(query_url, urllib.urlencode(dict(query=query)))
response = urllib2.urlopen(req)

info = json.loads(response.read())
poll_url = query_url + "?" + urllib.urlencode(dict(poll=info["taskId"]))
while 1:
    response = urllib2.urlopen(poll_url)
    poll_text = response.read()
    # got our JSON response -- means we are ready to retrieve
    if poll_text.startswith("{"):
        break
    time.sleep(3)
poll_info = json.loads(poll_text)

results_url = result_url_base + info["taskId"]

g = Graph()
g.parse(results_url)
for stmt in g:
    print stmt
Something went wrong with that request. Please try again.