From f9c64353ac87b1fe05e0cad68e358a7f69b3bcdc Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sat, 7 Nov 2020 10:31:27 +0000 Subject: Tests: added SPARQL test --- test/data/regression/TN_UT2.rdf | 64 ++++++++++++++++++++--------------------- test/test_sparql.py | 30 ++++++++++++++++++- 2 files changed, 61 insertions(+), 33 deletions(-) (limited to 'test') diff --git a/test/data/regression/TN_UT2.rdf b/test/data/regression/TN_UT2.rdf index 28b7a2d..05492d2 100644 --- a/test/data/regression/TN_UT2.rdf +++ b/test/data/regression/TN_UT2.rdf @@ -1,33 +1,33 @@ -_:N76e90938195c463c9dd2af9dadcf3d56 . -_:N14a259ceba1446a389be1076f7090540 . - _:N14a259ceba1446a389be1076f7090540 . - _:N1421ab28904c425faf6c308f77800e08 . -_:N76e90938195c463c9dd2af9dadcf3d56 "Colleen Jonsson" . - _:Na3153e61734c4cd1b7c4a11bb64b76cc . -_:N1421ab28904c425faf6c308f77800e08 . -_:N17d644aee0054862ab8beb6cdf5cb4d6 "https://bio.tools/BWA#!" . -_:N76e90938195c463c9dd2af9dadcf3d56 "TN_UT2" . -_:N69368ab7984c4659bcfa493bdca2d5f1 "SARS-CoV-2/human/USA/TN_UT2/2020" . -_:Na3153e61734c4cd1b7c4a11bb64b76cc . -_:N76e90938195c463c9dd2af9dadcf3d56 "Colleen B. Jonsson" . -_:N76e90938195c463c9dd2af9dadcf3d56 . - _:N76e90938195c463c9dd2af9dadcf3d56 . -_:N1421ab28904c425faf6c308f77800e08 "TN_UT2 - Pegram, Tennessee, USA" . -_:N1421ab28904c425faf6c308f77800e08 "Mariah Taylor, Colleen Jonsson" . -_:N76e90938195c463c9dd2af9dadcf3d56 "Mariah Taylor" . -_:N76e90938195c463c9dd2af9dadcf3d56 "Mariah Taylor" . -_:N76e90938195c463c9dd2af9dadcf3d56 "Regional Biocontainment Laboratory, Memphis, TN" . -_:N14a259ceba1446a389be1076f7090540 "TN_UT2" . -_:Na3153e61734c4cd1b7c4a11bb64b76cc . - _:N17d644aee0054862ab8beb6cdf5cb4d6 . -_:N1421ab28904c425faf6c308f77800e08 . -_:N76e90938195c463c9dd2af9dadcf3d56 "Pjotr Prins" . -_:N76e90938195c463c9dd2af9dadcf3d56 "UTHSC, Memphis, Tennessee 38163, USA" . -_:N17d644aee0054862ab8beb6cdf5cb4d6 "Oxford Nanopore MiniIon RNA long reads" . -_:N69368ab7984c4659bcfa493bdca2d5f1 . -_:Na3153e61734c4cd1b7c4a11bb64b76cc "TN_UT2" . -_:N76e90938195c463c9dd2af9dadcf3d56 "TN_UT2" . - _:N69368ab7984c4659bcfa493bdca2d5f1 . -_:N17d644aee0054862ab8beb6cdf5cb4d6 . -_:Na3153e61734c4cd1b7c4a11bb64b76cc "2020-04-26" . +_:N2db9cee579dd43f1b726d25af29c234e "TN_UT2" . +_:N2db9cee579dd43f1b726d25af29c234e . + _:Nd4901846018d495bb053138baa027814 . +_:N2db9cee579dd43f1b726d25af29c234e "Pjotr Prins" . +_:N2db9cee579dd43f1b726d25af29c234e "UTHSC, Memphis, Tennessee 38163, USA" . +_:Nd4901846018d495bb053138baa027814 "TN_UT2 - Pegram, Tennessee, USA" . + _:N7e96da40d73c4c2dbf05111f468abae3 . +_:N2db9cee579dd43f1b726d25af29c234e . +_:N98ebfff2566041cda89444d4cfe03752 "SARS-CoV-2/human/USA/TN_UT2/2020" . +_:N2db9cee579dd43f1b726d25af29c234e "Colleen Jonsson" . + _:N2db9cee579dd43f1b726d25af29c234e . +_:N572d266882144945822657d869333da9 "Oxford Nanopore MiniIon RNA long reads" . +_:N7e96da40d73c4c2dbf05111f468abae3 "TN_UT2" . +_:N2db9cee579dd43f1b726d25af29c234e "Mariah Taylor" . +_:Nd4901846018d495bb053138baa027814 . +_:N98ebfff2566041cda89444d4cfe03752 . +_:N7e96da40d73c4c2dbf05111f468abae3 "2020-04-26" . + _:N98ebfff2566041cda89444d4cfe03752 . +_:N572d266882144945822657d869333da9 . + _:N572d266882144945822657d869333da9 . +_:N2db9cee579dd43f1b726d25af29c234e "Mariah Taylor" . +_:N2db9cee579dd43f1b726d25af29c234e "TN_UT2" . +_:N572d266882144945822657d869333da9 "https://bio.tools/BWA#!" . +_:Nc89d151473da47de943e512a926416a8 . +_:Nd4901846018d495bb053138baa027814 . +_:N2db9cee579dd43f1b726d25af29c234e "Regional Biocontainment Laboratory, Memphis, TN" . +_:Nd4901846018d495bb053138baa027814 "Mariah Taylor, Colleen Jonsson" . +_:N7e96da40d73c4c2dbf05111f468abae3 . +_:N2db9cee579dd43f1b726d25af29c234e "Colleen B. Jonsson" . +_:Nc89d151473da47de943e512a926416a8 "TN_UT2" . +_:N7e96da40d73c4c2dbf05111f468abae3 . + _:Nc89d151473da47de943e512a926416a8 . diff --git a/test/test_sparql.py b/test/test_sparql.py index 00bb3ed..41cf717 100644 --- a/test/test_sparql.py +++ b/test/test_sparql.py @@ -1,11 +1,39 @@ # Run with python3 test/test_sparql.py import unittest +import requests +import logging + + class TestSPARQL(unittest.TestCase): def test_sparql(self): - pass + sparqlURL='http://sparql.genenetwork.org/sparql/' + id = "http://collections.lugli.arvadosapi.com/c=0002e93b86ad77824620bf938b97e134+126/sequence.fasta" + id = "MT800005.1" + query=f""" +PREFIX pubseq: +PREFIX sio: +select distinct ?sample ?geoname ?date ?source ?geo ?sampletype ?institute ?sequenceuri +{{ + ?sample sio:SIO_000115 "{id}" . + ?sequenceuri pubseq:sample ?sample . + ?sample ?geo . + ?geo rdfs:label ?geoname . + ?sample ?date . + OPTIONAL {{ ?sample ?source }} + OPTIONAL {{ ?sample ?sampletype }} + OPTIONAL {{ ?sample ?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() -- cgit v1.2.3