aboutsummaryrefslogtreecommitdiff
path: root/test/test_sparql.py
diff options
context:
space:
mode:
authorlltommy2020-11-11 09:56:12 +0100
committerlltommy2020-11-11 09:56:12 +0100
commitd6aa323b6fc7a82e45cc1df51fc72c2d547146eb (patch)
tree6e8b77bde4dc34fab3fa8804906f3cb821f61dae /test/test_sparql.py
parentc5fe5de7e4c77bfb48b1ae2f662c2d9cc120c06e (diff)
parentc872248e43c1c66e5fed8ef341f7b4ac21d63e6f (diff)
downloadbh20-seq-resource-d6aa323b6fc7a82e45cc1df51fc72c2d547146eb.tar.gz
bh20-seq-resource-d6aa323b6fc7a82e45cc1df51fc72c2d547146eb.tar.lz
bh20-seq-resource-d6aa323b6fc7a82e45cc1df51fc72c2d547146eb.zip
Merge branch 'master' of https://github.com/arvados/bh20-seq-resource
Diffstat (limited to 'test/test_sparql.py')
-rw-r--r--test/test_sparql.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/test_sparql.py b/test/test_sparql.py
new file mode 100644
index 0000000..41cf717
--- /dev/null
+++ b/test/test_sparql.py
@@ -0,0 +1,39 @@
+# Run with python3 test/test_sparql.py
+
+import unittest
+import requests
+import logging
+
+
+
+class TestSPARQL(unittest.TestCase):
+
+ def test_sparql(self):
+ sparqlURL='http://sparql.genenetwork.org/sparql/'
+ id = "http://collections.lugli.arvadosapi.com/c=0002e93b86ad77824620bf938b97e134+126/sequence.fasta"
+ id = "MT800005.1"
+ query=f"""
+PREFIX pubseq: <http://biohackathon.org/bh20-seq-schema#MainSchema/>
+PREFIX sio: <http://semanticscience.org/resource/>
+select distinct ?sample ?geoname ?date ?source ?geo ?sampletype ?institute ?sequenceuri
+{{
+ ?sample sio:SIO_000115 "{id}" .
+ ?sequenceuri pubseq:sample ?sample .
+ ?sample <http://purl.obolibrary.org/obo/GAZ_00000448> ?geo .
+ ?geo rdfs:label ?geoname .
+ ?sample <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C25164> ?date .
+ OPTIONAL {{ ?sample <http://edamontology.org/data_2091> ?source }}
+ OPTIONAL {{ ?sample <http://purl.obolibrary.org/obo/OBI_0001479> ?sampletype }}
+ OPTIONAL {{ ?sample <http://purl.obolibrary.org/obo/NCIT_C41206> ?institute }}
+}}
+ """
+ print(query)
+ payload = {'query': query, 'format': 'json'}
+ r = requests.get(sparqlURL, params=payload)
+ result = r.json()['results']['bindings']
+ # for now we just take the first one
+ print(result)
+ self.assertEqual(result[0]['geoname']['value'],'Mahuva')
+
+if __name__ == '__main__':
+ unittest.main()