aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPjotr Prins2020-11-07 10:31:27 +0000
committerPjotr Prins2020-11-07 10:31:27 +0000
commitf9c64353ac87b1fe05e0cad68e358a7f69b3bcdc (patch)
tree8bf0abedd0b127d504c7b8598cb97849e73f6d6f
parent8a02280c4bd05a7f8df598a75a1ea2d3caaddd7d (diff)
downloadbh20-seq-resource-f9c64353ac87b1fe05e0cad68e358a7f69b3bcdc.tar.gz
bh20-seq-resource-f9c64353ac87b1fe05e0cad68e358a7f69b3bcdc.tar.lz
bh20-seq-resource-f9c64353ac87b1fe05e0cad68e358a7f69b3bcdc.zip
Tests: added SPARQL test
-rw-r--r--.guix-test2
-rw-r--r--test/data/regression/TN_UT2.rdf64
-rw-r--r--test/test_sparql.py30
3 files changed, 62 insertions, 34 deletions
diff --git a/.guix-test b/.guix-test
index b8e92a0..26d2548 100644
--- a/.guix-test
+++ b/.guix-test
@@ -8,4 +8,4 @@ export GUILE_LOAD_COMPILED_PATH=$GUIX_PROFILE/share/guile/site/3.0/
ls $GUILE_LOAD_PATH
-env GUIX_PACKAGE_PATH=~/iwrk/opensource/guix/guix-bioinformatics/ $GUIX_PROFILE/bin/guix environment -C guix --ad-hoc git python python-flask python-pyyaml python-pycurl python-magic nss-certs python-pyshex python-pyyaml openssl python-pyshex python-pyshexc minimap2 python-schema-salad python-arvados-python-client -- python3 test/runner.py
+env GUIX_PACKAGE_PATH=~/iwrk/opensource/guix/guix-bioinformatics/ $GUIX_PROFILE/bin/guix environment -C guix --ad-hoc git python python-flask python-pyyaml python-pycurl python-magic nss-certs python-pyshex python-pyyaml --network openssl python-pyshex python-pyshexc minimap2 python-schema-salad python-arvados-python-client -- python3 test/runner.py
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 <http://semanticscience.org/resource/SIO_000115> <https://orcid.org/0000-0002-8021-9162> .
-_:N14a259ceba1446a389be1076f7090540 <http://www.ebi.ac.uk/efo/EFO_0000532> <http://purl.obolibrary.org/obo/NCBITaxon_9606> .
-<file:///export/local/home/wrk/iwrk/opensource/code/vg/bh20-seq-resource/test/data/input/placeholder> <http://biohackathon.org/bh20-seq-schema#MainSchema/host> _:N14a259ceba1446a389be1076f7090540 .
-<file:///export/local/home/wrk/iwrk/opensource/code/vg/bh20-seq-resource/test/data/input/placeholder> <http://biohackathon.org/bh20-seq-schema#MainSchema/license> _:N1421ab28904c425faf6c308f77800e08 .
-_:N76e90938195c463c9dd2af9dadcf3d56 <http://purl.obolibrary.org/obo/NCIT_C42781> "Colleen Jonsson" .
-<file:///export/local/home/wrk/iwrk/opensource/code/vg/bh20-seq-resource/test/data/input/placeholder> <http://biohackathon.org/bh20-seq-schema#MainSchema/sample> _:Na3153e61734c4cd1b7c4a11bb64b76cc .
-_:N1421ab28904c425faf6c308f77800e08 <https://creativecommons.org/ns#attributionURL> <https://www.uthsc.edu/medicine/molecular-sciences/faculty-directory/jonsson.php> .
-_:N17d644aee0054862ab8beb6cdf5cb4d6 <http://www.ebi.ac.uk/efo/EFO_0002699> "https://bio.tools/BWA#!" .
-_:N76e90938195c463c9dd2af9dadcf3d56 <http://purl.obolibrary.org/obo/NCIT_C42781> "TN_UT2" .
-_:N69368ab7984c4659bcfa493bdca2d5f1 <http://semanticscience.org/resource/SIO_010055> "SARS-CoV-2/human/USA/TN_UT2/2020" .
-_:Na3153e61734c4cd1b7c4a11bb64b76cc <http://purl.obolibrary.org/obo/OBI_0001479> <http://purl.obolibrary.org/obo/NCIT_C155831> .
-_:N76e90938195c463c9dd2af9dadcf3d56 <http://semanticscience.org/resource/SIO_000116> "Colleen B. Jonsson" .
-_:N76e90938195c463c9dd2af9dadcf3d56 <http://semanticscience.org/resource/SIO_000115> <https://orcid.org/0000-0002-2640-7672> .
-<file:///export/local/home/wrk/iwrk/opensource/code/vg/bh20-seq-resource/test/data/input/placeholder> <http://biohackathon.org/bh20-seq-schema#MainSchema/submitter> _:N76e90938195c463c9dd2af9dadcf3d56 .
-_:N1421ab28904c425faf6c308f77800e08 <http://purl.org/metadata/dublin_core_elements#Title> "TN_UT2 - Pegram, Tennessee, USA" .
-_:N1421ab28904c425faf6c308f77800e08 <https://creativecommons.org/ns#attributionName> "Mariah Taylor, Colleen Jonsson" .
-_:N76e90938195c463c9dd2af9dadcf3d56 <http://purl.obolibrary.org/obo/NCIT_C42781> "Mariah Taylor" .
-_:N76e90938195c463c9dd2af9dadcf3d56 <http://semanticscience.org/resource/SIO_000116> "Mariah Taylor" .
-_:N76e90938195c463c9dd2af9dadcf3d56 <http://purl.obolibrary.org/obo/NCIT_C37984> "Regional Biocontainment Laboratory, Memphis, TN" .
-_:N14a259ceba1446a389be1076f7090540 <http://semanticscience.org/resource/SIO_000115> "TN_UT2" .
-_:Na3153e61734c4cd1b7c4a11bb64b76cc <http://purl.obolibrary.org/obo/GAZ_00000448> <http://www.wikidata.org/entity/Q3289517> .
-<file:///export/local/home/wrk/iwrk/opensource/code/vg/bh20-seq-resource/test/data/input/placeholder> <http://biohackathon.org/bh20-seq-schema#MainSchema/technology> _:N17d644aee0054862ab8beb6cdf5cb4d6 .
-_:N1421ab28904c425faf6c308f77800e08 <https://creativecommons.org/ns#License> <https://creativecommons.org/licenses/by/4.0/> .
-_:N76e90938195c463c9dd2af9dadcf3d56 <http://semanticscience.org/resource/SIO_000116> "Pjotr Prins" .
-_:N76e90938195c463c9dd2af9dadcf3d56 <http://semanticscience.org/resource/SIO_000172> "UTHSC, Memphis, Tennessee 38163, USA" .
-_:N17d644aee0054862ab8beb6cdf5cb4d6 <http://semanticscience.org/resource/SIO_001167> "Oxford Nanopore MiniIon RNA long reads" .
-_:N69368ab7984c4659bcfa493bdca2d5f1 <http://edamontology.org/data_1875> <http://purl.obolibrary.org/obo/NCBITaxon_2697049> .
-_:Na3153e61734c4cd1b7c4a11bb64b76cc <http://semanticscience.org/resource/SIO_000115> "TN_UT2" .
-_:N76e90938195c463c9dd2af9dadcf3d56 <http://www.ebi.ac.uk/efo/EFO_0001741> "TN_UT2" .
-<file:///export/local/home/wrk/iwrk/opensource/code/vg/bh20-seq-resource/test/data/input/placeholder> <http://biohackathon.org/bh20-seq-schema#MainSchema/virus> _:N69368ab7984c4659bcfa493bdca2d5f1 .
-_:N17d644aee0054862ab8beb6cdf5cb4d6 <http://purl.obolibrary.org/obo/OBI_0600047> <http://www.ebi.ac.uk/efo/EFO_0008632> .
-_:Na3153e61734c4cd1b7c4a11bb64b76cc <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C25164> "2020-04-26" .
+_:N2db9cee579dd43f1b726d25af29c234e <http://www.ebi.ac.uk/efo/EFO_0001741> "TN_UT2" .
+_:N2db9cee579dd43f1b726d25af29c234e <http://semanticscience.org/resource/SIO_000115> <https://orcid.org/0000-0002-8021-9162> .
+<file:///export/local/home/wrk/iwrk/opensource/code/vg/bh20-seq-resource/test/data/input/placeholder> <http://biohackathon.org/bh20-seq-schema#MainSchema/license> _:Nd4901846018d495bb053138baa027814 .
+_:N2db9cee579dd43f1b726d25af29c234e <http://semanticscience.org/resource/SIO_000116> "Pjotr Prins" .
+_:N2db9cee579dd43f1b726d25af29c234e <http://semanticscience.org/resource/SIO_000172> "UTHSC, Memphis, Tennessee 38163, USA" .
+_:Nd4901846018d495bb053138baa027814 <http://purl.org/metadata/dublin_core_elements#Title> "TN_UT2 - Pegram, Tennessee, USA" .
+<file:///export/local/home/wrk/iwrk/opensource/code/vg/bh20-seq-resource/test/data/input/placeholder> <http://biohackathon.org/bh20-seq-schema#MainSchema/sample> _:N7e96da40d73c4c2dbf05111f468abae3 .
+_:N2db9cee579dd43f1b726d25af29c234e <http://semanticscience.org/resource/SIO_000115> <https://orcid.org/0000-0002-2640-7672> .
+_:N98ebfff2566041cda89444d4cfe03752 <http://semanticscience.org/resource/SIO_010055> "SARS-CoV-2/human/USA/TN_UT2/2020" .
+_:N2db9cee579dd43f1b726d25af29c234e <http://purl.obolibrary.org/obo/NCIT_C42781> "Colleen Jonsson" .
+<file:///export/local/home/wrk/iwrk/opensource/code/vg/bh20-seq-resource/test/data/input/placeholder> <http://biohackathon.org/bh20-seq-schema#MainSchema/submitter> _:N2db9cee579dd43f1b726d25af29c234e .
+_:N572d266882144945822657d869333da9 <http://semanticscience.org/resource/SIO_001167> "Oxford Nanopore MiniIon RNA long reads" .
+_:N7e96da40d73c4c2dbf05111f468abae3 <http://semanticscience.org/resource/SIO_000115> "TN_UT2" .
+_:N2db9cee579dd43f1b726d25af29c234e <http://semanticscience.org/resource/SIO_000116> "Mariah Taylor" .
+_:Nd4901846018d495bb053138baa027814 <https://creativecommons.org/ns#attributionURL> <https://www.uthsc.edu/medicine/molecular-sciences/faculty-directory/jonsson.php> .
+_:N98ebfff2566041cda89444d4cfe03752 <http://edamontology.org/data_1875> <http://purl.obolibrary.org/obo/NCBITaxon_2697049> .
+_:N7e96da40d73c4c2dbf05111f468abae3 <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C25164> "2020-04-26" .
+<file:///export/local/home/wrk/iwrk/opensource/code/vg/bh20-seq-resource/test/data/input/placeholder> <http://biohackathon.org/bh20-seq-schema#MainSchema/virus> _:N98ebfff2566041cda89444d4cfe03752 .
+_:N572d266882144945822657d869333da9 <http://purl.obolibrary.org/obo/OBI_0600047> <http://www.ebi.ac.uk/efo/EFO_0008632> .
+<file:///export/local/home/wrk/iwrk/opensource/code/vg/bh20-seq-resource/test/data/input/placeholder> <http://biohackathon.org/bh20-seq-schema#MainSchema/technology> _:N572d266882144945822657d869333da9 .
+_:N2db9cee579dd43f1b726d25af29c234e <http://purl.obolibrary.org/obo/NCIT_C42781> "Mariah Taylor" .
+_:N2db9cee579dd43f1b726d25af29c234e <http://purl.obolibrary.org/obo/NCIT_C42781> "TN_UT2" .
+_:N572d266882144945822657d869333da9 <http://www.ebi.ac.uk/efo/EFO_0002699> "https://bio.tools/BWA#!" .
+_:Nc89d151473da47de943e512a926416a8 <http://www.ebi.ac.uk/efo/EFO_0000532> <http://purl.obolibrary.org/obo/NCBITaxon_9606> .
+_:Nd4901846018d495bb053138baa027814 <https://creativecommons.org/ns#License> <https://creativecommons.org/licenses/by/4.0/> .
+_:N2db9cee579dd43f1b726d25af29c234e <http://purl.obolibrary.org/obo/NCIT_C37984> "Regional Biocontainment Laboratory, Memphis, TN" .
+_:Nd4901846018d495bb053138baa027814 <https://creativecommons.org/ns#attributionName> "Mariah Taylor, Colleen Jonsson" .
+_:N7e96da40d73c4c2dbf05111f468abae3 <http://purl.obolibrary.org/obo/GAZ_00000448> <http://www.wikidata.org/entity/Q3289517> .
+_:N2db9cee579dd43f1b726d25af29c234e <http://semanticscience.org/resource/SIO_000116> "Colleen B. Jonsson" .
+_:Nc89d151473da47de943e512a926416a8 <http://semanticscience.org/resource/SIO_000115> "TN_UT2" .
+_:N7e96da40d73c4c2dbf05111f468abae3 <http://purl.obolibrary.org/obo/OBI_0001479> <http://purl.obolibrary.org/obo/NCIT_C155831> .
+<file:///export/local/home/wrk/iwrk/opensource/code/vg/bh20-seq-resource/test/data/input/placeholder> <http://biohackathon.org/bh20-seq-schema#MainSchema/host> _: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: <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()