From 9887e427d4e0beb29af14e554a3508126f0d505a Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sat, 7 Nov 2020 09:24:17 +0000 Subject: Test: simplify and add regression test --- test/data/regression/TN_UT2.rdf | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/data/regression/TN_UT2.rdf (limited to 'test/data/regression') diff --git a/test/data/regression/TN_UT2.rdf b/test/data/regression/TN_UT2.rdf new file mode 100644 index 0000000..aa1356a --- /dev/null +++ b/test/data/regression/TN_UT2.rdf @@ -0,0 +1,33 @@ +_:Nc519408f538a4bb39ea09f56ce9bb88e "TN_UT2" . +_:N299826fb66794f11991cebc5f8d8b24a "https://bio.tools/BWA#!" . +_:N982774a13a39474aae39272447a09574 "https://www.uthsc.edu/medicine/molecular-sciences/faculty-directory/jonsson.php" . +_:N7857c4718ab741169bae9fafa9b47c75 "2020-04-26" . +_:N708d19e87323455c9f9bb317538f742d "Pjotr Prins" . +_:N95d4a000e14d4bd99b46d6ec84989aaf "SARS-CoV-2/human/USA/TN_UT2/2020" . + _:N982774a13a39474aae39272447a09574 . +_:N95d4a000e14d4bd99b46d6ec84989aaf . +_:Nc519408f538a4bb39ea09f56ce9bb88e . +_:N708d19e87323455c9f9bb317538f742d "Colleen Jonsson" . +_:N982774a13a39474aae39272447a09574 "Mariah Taylor, Colleen Jonsson" . + _:N7857c4718ab741169bae9fafa9b47c75 . +_:N708d19e87323455c9f9bb317538f742d "Regional Biocontainment Laboratory, Memphis, TN" . +_:N299826fb66794f11991cebc5f8d8b24a . +_:N708d19e87323455c9f9bb317538f742d "UTHSC, Memphis, Tennessee 38163, USA" . +_:N7857c4718ab741169bae9fafa9b47c75 . +_:N708d19e87323455c9f9bb317538f742d "TN_UT2" . +_:N7857c4718ab741169bae9fafa9b47c75 "TN_UT2" . +_:N708d19e87323455c9f9bb317538f742d . + _:N708d19e87323455c9f9bb317538f742d . + _:N299826fb66794f11991cebc5f8d8b24a . +_:N982774a13a39474aae39272447a09574 "TN_UT2 - Pegram, Tennessee, USA" . +_:N299826fb66794f11991cebc5f8d8b24a "Oxford Nanopore MiniIon RNA long reads" . +_:N7857c4718ab741169bae9fafa9b47c75 . + _:Nc519408f538a4bb39ea09f56ce9bb88e . +_:N708d19e87323455c9f9bb317538f742d "Mariah Taylor" . +_:N708d19e87323455c9f9bb317538f742d . + _:N95d4a000e14d4bd99b46d6ec84989aaf . +_:N708d19e87323455c9f9bb317538f742d "Colleen B. Jonsson" . +_:N708d19e87323455c9f9bb317538f742d "TN_UT2" . +_:N982774a13a39474aae39272447a09574 "http://creativecommons.org/licenses/by/4.0/" . +_:N708d19e87323455c9f9bb317538f742d "Mariah Taylor" . + -- cgit v1.2.3 From 9709eca5c76aabe823ba34d976c5d11a9d150b76 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sat, 7 Nov 2020 10:06:30 +0000 Subject: RDF: use URIs --- bh20sequploader/bh20seq-schema.yml | 8 ++++- bh20sequploader/bh20seq-shex.rdf | 5 +-- test/data/input/TN_UT2.yaml | 2 +- test/data/regression/TN_UT2.rdf | 64 +++++++++++++++++++------------------- 4 files changed, 43 insertions(+), 36 deletions(-) (limited to 'test/data/regression') diff --git a/bh20sequploader/bh20seq-schema.yml b/bh20sequploader/bh20seq-schema.yml index 861a5ca..645be5e 100644 --- a/bh20sequploader/bh20seq-schema.yml +++ b/bh20sequploader/bh20seq-schema.yml @@ -1,6 +1,6 @@ $base: http://biohackathon.org/bh20-seq-schema $namespaces: - cc: http://creativecommons.org/ns# + cc: https://creativecommons.org/ns# dc: http://purl.org/metadata/dublin_core_elements# sch: https://schema.org/ efo: http://www.ebi.ac.uk/efo/ @@ -19,6 +19,8 @@ $graph: type: string jsonldPredicate: _id: https://creativecommons.org/ns#License + _type: "@id" + noLinkCheck: true title: doc: Attribution title related to data license type: string? @@ -34,11 +36,15 @@ $graph: type: string? jsonldPredicate: _id: https://creativecommons.org/ns#attributionURL + _type: "@id" + noLinkCheck: true attribution_source: doc: Attribution source URL related to data license type: string? jsonldPredicate: _id: https://creativecommons.org/ns#attributionSource + _type: "@id" + noLinkCheck: true - name: hostSchema type: record diff --git a/bh20sequploader/bh20seq-shex.rdf b/bh20sequploader/bh20seq-shex.rdf index fa765dd..1b15c58 100644 --- a/bh20sequploader/bh20seq-shex.rdf +++ b/bh20sequploader/bh20seq-shex.rdf @@ -2,6 +2,7 @@ PREFIX : PREFIX hostSchema: PREFIX cc: +PREFIX cclicenses: PREFIX dc: PREFIX xsd: PREFIX obo: @@ -71,9 +72,9 @@ PREFIX wikidata: } :licenseShape{ - cc:License xsd:string ; + cc:License [ cclicenses:~ ] ; dc:Title xsd:string ?; cc:attributionName xsd:string ?; - cc:attributionURL xsd:string ?; + cc:attributionURL /^http/ ; cc:attributionSource xsd:string ?; } diff --git a/test/data/input/TN_UT2.yaml b/test/data/input/TN_UT2.yaml index 2c5f987..9c4370d 100644 --- a/test/data/input/TN_UT2.yaml +++ b/test/data/input/TN_UT2.yaml @@ -1,7 +1,7 @@ id: placeholder license: - license_type: http://creativecommons.org/licenses/by/4.0/ + license_type: https://creativecommons.org/licenses/by/4.0/ title: "TN_UT2 - Pegram, Tennessee, USA" attribution_name: "Mariah Taylor, Colleen Jonsson" attribution_url: https://www.uthsc.edu/medicine/molecular-sciences/faculty-directory/jonsson.php diff --git a/test/data/regression/TN_UT2.rdf b/test/data/regression/TN_UT2.rdf index aa1356a..84353a5 100644 --- a/test/data/regression/TN_UT2.rdf +++ b/test/data/regression/TN_UT2.rdf @@ -1,33 +1,33 @@ -_:Nc519408f538a4bb39ea09f56ce9bb88e "TN_UT2" . -_:N299826fb66794f11991cebc5f8d8b24a "https://bio.tools/BWA#!" . -_:N982774a13a39474aae39272447a09574 "https://www.uthsc.edu/medicine/molecular-sciences/faculty-directory/jonsson.php" . -_:N7857c4718ab741169bae9fafa9b47c75 "2020-04-26" . -_:N708d19e87323455c9f9bb317538f742d "Pjotr Prins" . -_:N95d4a000e14d4bd99b46d6ec84989aaf "SARS-CoV-2/human/USA/TN_UT2/2020" . - _:N982774a13a39474aae39272447a09574 . -_:N95d4a000e14d4bd99b46d6ec84989aaf . -_:Nc519408f538a4bb39ea09f56ce9bb88e . -_:N708d19e87323455c9f9bb317538f742d "Colleen Jonsson" . -_:N982774a13a39474aae39272447a09574 "Mariah Taylor, Colleen Jonsson" . - _:N7857c4718ab741169bae9fafa9b47c75 . -_:N708d19e87323455c9f9bb317538f742d "Regional Biocontainment Laboratory, Memphis, TN" . -_:N299826fb66794f11991cebc5f8d8b24a . -_:N708d19e87323455c9f9bb317538f742d "UTHSC, Memphis, Tennessee 38163, USA" . -_:N7857c4718ab741169bae9fafa9b47c75 . -_:N708d19e87323455c9f9bb317538f742d "TN_UT2" . -_:N7857c4718ab741169bae9fafa9b47c75 "TN_UT2" . -_:N708d19e87323455c9f9bb317538f742d . - _:N708d19e87323455c9f9bb317538f742d . - _:N299826fb66794f11991cebc5f8d8b24a . -_:N982774a13a39474aae39272447a09574 "TN_UT2 - Pegram, Tennessee, USA" . -_:N299826fb66794f11991cebc5f8d8b24a "Oxford Nanopore MiniIon RNA long reads" . -_:N7857c4718ab741169bae9fafa9b47c75 . - _:Nc519408f538a4bb39ea09f56ce9bb88e . -_:N708d19e87323455c9f9bb317538f742d "Mariah Taylor" . -_:N708d19e87323455c9f9bb317538f742d . - _:N95d4a000e14d4bd99b46d6ec84989aaf . -_:N708d19e87323455c9f9bb317538f742d "Colleen B. Jonsson" . -_:N708d19e87323455c9f9bb317538f742d "TN_UT2" . -_:N982774a13a39474aae39272447a09574 "http://creativecommons.org/licenses/by/4.0/" . -_:N708d19e87323455c9f9bb317538f742d "Mariah Taylor" . +_:N850430bbc537473e8fbab09c300daf2b . +_:Ncab40e8bd4b84431aa6782f7e7480ef3 . +_:N3c28bc8014134d77823451de114c6085 "Mariah Taylor" . +_:Ncab40e8bd4b84431aa6782f7e7480ef3 "TN_UT2" . + _:N850430bbc537473e8fbab09c300daf2b . +_:N3c28bc8014134d77823451de114c6085 "TN_UT2" . +_:N850430bbc537473e8fbab09c300daf2b . +_:N3c28bc8014134d77823451de114c6085 "UTHSC, Memphis, Tennessee 38163, USA" . +_:Nebe62f68542a47d0936e953195cf25d7 . +_:N3c28bc8014134d77823451de114c6085 "Colleen B. Jonsson" . +_:N78bfdbe9d12745e99164d619cb125277 . +_:Nbf9e7b47381b4965926a47bf5b34e489 "Oxford Nanopore MiniIon RNA long reads" . + _:Ncab40e8bd4b84431aa6782f7e7480ef3 . +_:Nbf9e7b47381b4965926a47bf5b34e489 "https://bio.tools/BWA#!" . +_:Nebe62f68542a47d0936e953195cf25d7 "TN_UT2" . + _:Nebe62f68542a47d0936e953195cf25d7 . +_:N850430bbc537473e8fbab09c300daf2b "Mariah Taylor, Colleen Jonsson" . +_:N78bfdbe9d12745e99164d619cb125277 "SARS-CoV-2/human/USA/TN_UT2/2020" . +_:N3c28bc8014134d77823451de114c6085 "Colleen Jonsson" . +_:N3c28bc8014134d77823451de114c6085 . +_:Nebe62f68542a47d0936e953195cf25d7 "2020-04-26" . +_:Nebe62f68542a47d0936e953195cf25d7 . +_:N850430bbc537473e8fbab09c300daf2b "TN_UT2 - Pegram, Tennessee, USA" . +_:Nbf9e7b47381b4965926a47bf5b34e489 . +_:N3c28bc8014134d77823451de114c6085 "Mariah Taylor" . +_:N3c28bc8014134d77823451de114c6085 "TN_UT2" . +_:N3c28bc8014134d77823451de114c6085 "Pjotr Prins" . + _:N3c28bc8014134d77823451de114c6085 . +_:N3c28bc8014134d77823451de114c6085 . + _:N78bfdbe9d12745e99164d619cb125277 . +_:N3c28bc8014134d77823451de114c6085 "Regional Biocontainment Laboratory, Memphis, TN" . + _:Nbf9e7b47381b4965926a47bf5b34e489 . -- cgit v1.2.3 From 8a02280c4bd05a7f8df598a75a1ea2d3caaddd7d Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sat, 7 Nov 2020 10:21:48 +0000 Subject: Tests: add runner and frame for SPARQL --- .guix-test | 2 +- test/data/regression/TN_UT2.rdf | 64 ++++++++++++++++++++--------------------- test/runner.py | 17 +++++++++++ test/test_shex.py | 8 ++---- test/test_sparql.py | 11 +++++++ 5 files changed, 64 insertions(+), 38 deletions(-) create mode 100644 test/runner.py create mode 100644 test/test_sparql.py (limited to 'test/data/regression') diff --git a/.guix-test b/.guix-test index 362fe8b..b8e92a0 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/test_shex.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 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 84353a5..28b7a2d 100644 --- a/test/data/regression/TN_UT2.rdf +++ b/test/data/regression/TN_UT2.rdf @@ -1,33 +1,33 @@ -_:N850430bbc537473e8fbab09c300daf2b . -_:Ncab40e8bd4b84431aa6782f7e7480ef3 . -_:N3c28bc8014134d77823451de114c6085 "Mariah Taylor" . -_:Ncab40e8bd4b84431aa6782f7e7480ef3 "TN_UT2" . - _:N850430bbc537473e8fbab09c300daf2b . -_:N3c28bc8014134d77823451de114c6085 "TN_UT2" . -_:N850430bbc537473e8fbab09c300daf2b . -_:N3c28bc8014134d77823451de114c6085 "UTHSC, Memphis, Tennessee 38163, USA" . -_:Nebe62f68542a47d0936e953195cf25d7 . -_:N3c28bc8014134d77823451de114c6085 "Colleen B. Jonsson" . -_:N78bfdbe9d12745e99164d619cb125277 . -_:Nbf9e7b47381b4965926a47bf5b34e489 "Oxford Nanopore MiniIon RNA long reads" . - _:Ncab40e8bd4b84431aa6782f7e7480ef3 . -_:Nbf9e7b47381b4965926a47bf5b34e489 "https://bio.tools/BWA#!" . -_:Nebe62f68542a47d0936e953195cf25d7 "TN_UT2" . - _:Nebe62f68542a47d0936e953195cf25d7 . -_:N850430bbc537473e8fbab09c300daf2b "Mariah Taylor, Colleen Jonsson" . -_:N78bfdbe9d12745e99164d619cb125277 "SARS-CoV-2/human/USA/TN_UT2/2020" . -_:N3c28bc8014134d77823451de114c6085 "Colleen Jonsson" . -_:N3c28bc8014134d77823451de114c6085 . -_:Nebe62f68542a47d0936e953195cf25d7 "2020-04-26" . -_:Nebe62f68542a47d0936e953195cf25d7 . -_:N850430bbc537473e8fbab09c300daf2b "TN_UT2 - Pegram, Tennessee, USA" . -_:Nbf9e7b47381b4965926a47bf5b34e489 . -_:N3c28bc8014134d77823451de114c6085 "Mariah Taylor" . -_:N3c28bc8014134d77823451de114c6085 "TN_UT2" . -_:N3c28bc8014134d77823451de114c6085 "Pjotr Prins" . - _:N3c28bc8014134d77823451de114c6085 . -_:N3c28bc8014134d77823451de114c6085 . - _:N78bfdbe9d12745e99164d619cb125277 . -_:N3c28bc8014134d77823451de114c6085 "Regional Biocontainment Laboratory, Memphis, TN" . - _:Nbf9e7b47381b4965926a47bf5b34e489 . +_: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" . diff --git a/test/runner.py b/test/runner.py new file mode 100644 index 0000000..3cfe042 --- /dev/null +++ b/test/runner.py @@ -0,0 +1,17 @@ +# Run tests. python3 test/runner.py + +import unittest + +# initialize the test suite +loader = unittest.TestLoader() +suite = unittest.TestSuite() + +import test_shex +import test_sparql + +suite.addTests(loader.loadTestsFromModule(test_shex)) +suite.addTests(loader.loadTestsFromModule(test_sparql)) + +# initialize a runner, pass it your suite and run it +runner = unittest.TextTestRunner(verbosity=3) +result = runner.run(suite) diff --git a/test/test_shex.py b/test/test_shex.py index e5d97cc..728bfdc 100644 --- a/test/test_shex.py +++ b/test/test_shex.py @@ -1,14 +1,12 @@ +# Run with python3 test/test_shex.py + import schema_salad.schema import schema_salad.ref_resolver import schema_salad.jsonld_context -# import pkg_resources -import logging -# import traceback -# from rdflib import Graph, Namespace from pyshex.evaluate import evaluate import unittest -class TestStringMethods(unittest.TestCase): +class TestShexMethods(unittest.TestCase): def test_schema(self): with open("bh20sequploader/bh20seq-schema.yml") as schema_resource: diff --git a/test/test_sparql.py b/test/test_sparql.py new file mode 100644 index 0000000..00bb3ed --- /dev/null +++ b/test/test_sparql.py @@ -0,0 +1,11 @@ +# Run with python3 test/test_sparql.py + +import unittest + +class TestSPARQL(unittest.TestCase): + + def test_sparql(self): + pass + +if __name__ == '__main__': + unittest.main() -- cgit v1.2.3 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 --- .guix-test | 2 +- test/data/regression/TN_UT2.rdf | 64 ++++++++++++++++++++--------------------- test/test_sparql.py | 30 ++++++++++++++++++- 3 files changed, 62 insertions(+), 34 deletions(-) (limited to 'test/data/regression') 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 . -_: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