-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathVIVOClient.py
More file actions
26 lines (19 loc) · 809 Bytes
/
VIVOClient.py
File metadata and controls
26 lines (19 loc) · 809 Bytes
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
__author__ = 'szednik'
from SPARQLWrapper import SPARQLWrapper, JSON
class VIVOClient(object):
uri_base = "http://info.deepcarbon.net/individual/"
vivo_endpoint = "http://deepcarbon.tw.rpi.edu:3030/VIVO/query"
def __init__(self):
super().__init__()
self.sparql = SPARQLWrapper(self.vivo_endpoint)
with open("concept-query.rq") as _file:
self.template = _file.read().replace('\n', " ")
def query_keyword(self, keyword):
_query = self.template.replace("{keyword}", keyword.lower())
self.sparql.setQuery(_query)
self.sparql.setReturnFormat(JSON)
results = self.sparql.query().convert()
r = []
for result in results["results"]["bindings"]:
r.append(result["concept"]["value"])
return r