From 80954e51a20e25e03b7f8b3fcb9e8ca7f675c068 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Wed, 11 Nov 2020 17:23:30 +0000 Subject: Fix resolving permalinks such as http://covid19.genenetwork.org/resource/MT326090.1 --- bh20simplewebuploader/main.py | 9 ++++-- test/data/regression/TN_UT2.rdf | 64 ++++++++++++++++++++--------------------- test/test_sparql.py | 5 ++-- 3 files changed, 41 insertions(+), 37 deletions(-) diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index 1d12d9e..0495613 100644 --- a/bh20simplewebuploader/main.py +++ b/bh20simplewebuploader/main.py @@ -688,6 +688,9 @@ sparqlURL='http://sparql.genenetwork.org/sparql/' ## # Example http://covid19.genenetwork.org/resource/MT326090.1 +# http://localhost:5067/resource/lugli-4zz18-oixhf5jl3lqlegz +# http://localhost:5067/resource/MT326090.1 +# # Example http://host/resource/SRR11621868 @app.route('/resource/') def resource(id): @@ -735,9 +738,11 @@ union logging.info("^^^^^^^^^^^^^^^^^^^^^^^^^^^^") # return jsonify({'sequences': int(result[0]["num"]["value"])}) sequenceuri=sample['sequenceuri']['value'] + # http://covid19.genenetwork.org/resource/lugli-4zz18-gx0ifousk9yu0ql m = re.match(r"http://collections.lugli.arvadosapi.com/c=([^/]*)/sequence.fasta|http://covid19.genenetwork.org/resource/(.*)", sequenceuri) - fastauri = "http://collections.lugli.arvadosapi.com/c=%s/sequence.fasta" % m.group(1) - metauri = "http://collections.lugli.arvadosapi.com/c=%s/metadata.yaml" % m.group(1) + collection = m.group(1) or m.group(2) + fastauri = f"http://collections.lugli.arvadosapi.com/c={collection}/sequence.fasta" + metauri = f"http://collections.lugli.arvadosapi.com/c={collection}/metadata.yaml" locationuri=sample['geo']['value'] location=sample['geoname']['value'] date=sample['date']['value'] diff --git a/test/data/regression/TN_UT2.rdf b/test/data/regression/TN_UT2.rdf index 05492d2..15a0141 100644 --- a/test/data/regression/TN_UT2.rdf +++ b/test/data/regression/TN_UT2.rdf @@ -1,33 +1,33 @@ -_: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 . +_:N0f57e5210af14083b1fb7f52e83f5c84 "Mariah Taylor, Colleen Jonsson" . + _:N770ee69b1f114d7481a5456be97d2426 . +_:N0c4f8c1d8de04a5d97a78124723de78b "Mariah Taylor" . +_:N770ee69b1f114d7481a5456be97d2426 . +_:N0c4f8c1d8de04a5d97a78124723de78b "UTHSC, Memphis, Tennessee 38163, USA" . +_:N0f57e5210af14083b1fb7f52e83f5c84 "TN_UT2 - Pegram, Tennessee, USA" . + _:Nbe0034a38484480ba179a898c4795f4e . +_:N0c4f8c1d8de04a5d97a78124723de78b . +_:N0c4f8c1d8de04a5d97a78124723de78b "TN_UT2" . +_:N0c4f8c1d8de04a5d97a78124723de78b "Pjotr Prins" . +_:N0c4f8c1d8de04a5d97a78124723de78b . +_:N2fa20d9d6d7b4beaaf53160cf1969569 "SARS-CoV-2/human/USA/TN_UT2/2020" . + _:N0f57e5210af14083b1fb7f52e83f5c84 . +_:Nea46fcb87c5547e8a98e3e52fd8d8a45 . +_:N770ee69b1f114d7481a5456be97d2426 "2020-04-26" . +_:N0f57e5210af14083b1fb7f52e83f5c84 . + _:N0c4f8c1d8de04a5d97a78124723de78b . +_:N0c4f8c1d8de04a5d97a78124723de78b "Colleen B. Jonsson" . +_:N0f57e5210af14083b1fb7f52e83f5c84 . +_:N0c4f8c1d8de04a5d97a78124723de78b "Colleen Jonsson" . +_:N0c4f8c1d8de04a5d97a78124723de78b "Regional Biocontainment Laboratory, Memphis, TN" . +_:N0c4f8c1d8de04a5d97a78124723de78b "TN_UT2" . + _:Nea46fcb87c5547e8a98e3e52fd8d8a45 . + _:N2fa20d9d6d7b4beaaf53160cf1969569 . +_:Nbe0034a38484480ba179a898c4795f4e "Oxford Nanopore MiniIon RNA long reads" . +_:N0c4f8c1d8de04a5d97a78124723de78b "Mariah Taylor" . +_:N770ee69b1f114d7481a5456be97d2426 . +_:N2fa20d9d6d7b4beaaf53160cf1969569 . +_:N770ee69b1f114d7481a5456be97d2426 "TN_UT2" . +_:Nbe0034a38484480ba179a898c4795f4e . +_:Nbe0034a38484480ba179a898c4795f4e "https://bio.tools/BWA#!" . +_:Nea46fcb87c5547e8a98e3e52fd8d8a45 "TN_UT2" . diff --git a/test/test_sparql.py b/test/test_sparql.py index 41cf717..6f74470 100644 --- a/test/test_sparql.py +++ b/test/test_sparql.py @@ -4,12 +4,11 @@ import unittest import requests import logging - - class TestSPARQL(unittest.TestCase): def test_sparql(self): - sparqlURL='http://sparql.genenetwork.org/sparql/' + # sparqlURL='http://sparql.genenetwork.org/sparql/' + sparqlURL='http://127.0.0.1:8890//sparql/' id = "http://collections.lugli.arvadosapi.com/c=0002e93b86ad77824620bf938b97e134+126/sequence.fasta" id = "MT800005.1" query=f""" -- cgit v1.2.3