aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPjotr Prins2020-11-11 17:23:30 +0000
committerPjotr Prins2020-11-11 17:24:41 +0000
commit80954e51a20e25e03b7f8b3fcb9e8ca7f675c068 (patch)
tree3ba0688c92a4516bdac63fa11e02925ccae3deef
parent8039f9f7989bb8000f88738ede20d934dde70c2c (diff)
downloadbh20-seq-resource-80954e51a20e25e03b7f8b3fcb9e8ca7f675c068.tar.gz
bh20-seq-resource-80954e51a20e25e03b7f8b3fcb9e8ca7f675c068.tar.lz
bh20-seq-resource-80954e51a20e25e03b7f8b3fcb9e8ca7f675c068.zip
Fix resolving permalinks such as http://covid19.genenetwork.org/resource/MT326090.1
-rw-r--r--bh20simplewebuploader/main.py9
-rw-r--r--test/data/regression/TN_UT2.rdf64
-rw-r--r--test/test_sparql.py5
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/<id>')
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 <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 .
+_:N0f57e5210af14083b1fb7f52e83f5c84 <https://creativecommons.org/ns#attributionName> "Mariah Taylor, 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> _:N770ee69b1f114d7481a5456be97d2426 .
+_:N0c4f8c1d8de04a5d97a78124723de78b <http://purl.obolibrary.org/obo/NCIT_C42781> "Mariah Taylor" .
+_:N770ee69b1f114d7481a5456be97d2426 <http://purl.obolibrary.org/obo/GAZ_00000448> <http://www.wikidata.org/entity/Q3289517> .
+_:N0c4f8c1d8de04a5d97a78124723de78b <http://semanticscience.org/resource/SIO_000172> "UTHSC, Memphis, Tennessee 38163, USA" .
+_:N0f57e5210af14083b1fb7f52e83f5c84 <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/technology> _:Nbe0034a38484480ba179a898c4795f4e .
+_:N0c4f8c1d8de04a5d97a78124723de78b <http://semanticscience.org/resource/SIO_000115> <https://orcid.org/0000-0002-8021-9162> .
+_:N0c4f8c1d8de04a5d97a78124723de78b <http://purl.obolibrary.org/obo/NCIT_C42781> "TN_UT2" .
+_:N0c4f8c1d8de04a5d97a78124723de78b <http://semanticscience.org/resource/SIO_000116> "Pjotr Prins" .
+_:N0c4f8c1d8de04a5d97a78124723de78b <http://semanticscience.org/resource/SIO_000115> <https://orcid.org/0000-0002-2640-7672> .
+_:N2fa20d9d6d7b4beaaf53160cf1969569 <http://semanticscience.org/resource/SIO_010055> "SARS-CoV-2/human/USA/TN_UT2/2020" .
+<file:///export/local/home/wrk/iwrk/opensource/code/vg/bh20-seq-resource/test/data/input/placeholder> <http://biohackathon.org/bh20-seq-schema#MainSchema/license> _:N0f57e5210af14083b1fb7f52e83f5c84 .
+_:Nea46fcb87c5547e8a98e3e52fd8d8a45 <http://www.ebi.ac.uk/efo/EFO_0000532> <http://purl.obolibrary.org/obo/NCBITaxon_9606> .
+_:N770ee69b1f114d7481a5456be97d2426 <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C25164> "2020-04-26" .
+_:N0f57e5210af14083b1fb7f52e83f5c84 <https://creativecommons.org/ns#License> <https://creativecommons.org/licenses/by/4.0/> .
+<file:///export/local/home/wrk/iwrk/opensource/code/vg/bh20-seq-resource/test/data/input/placeholder> <http://biohackathon.org/bh20-seq-schema#MainSchema/submitter> _:N0c4f8c1d8de04a5d97a78124723de78b .
+_:N0c4f8c1d8de04a5d97a78124723de78b <http://semanticscience.org/resource/SIO_000116> "Colleen B. Jonsson" .
+_:N0f57e5210af14083b1fb7f52e83f5c84 <https://creativecommons.org/ns#attributionURL> <https://www.uthsc.edu/medicine/molecular-sciences/faculty-directory/jonsson.php> .
+_:N0c4f8c1d8de04a5d97a78124723de78b <http://purl.obolibrary.org/obo/NCIT_C42781> "Colleen Jonsson" .
+_:N0c4f8c1d8de04a5d97a78124723de78b <http://purl.obolibrary.org/obo/NCIT_C37984> "Regional Biocontainment Laboratory, Memphis, TN" .
+_:N0c4f8c1d8de04a5d97a78124723de78b <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/host> _:Nea46fcb87c5547e8a98e3e52fd8d8a45 .
+<file:///export/local/home/wrk/iwrk/opensource/code/vg/bh20-seq-resource/test/data/input/placeholder> <http://biohackathon.org/bh20-seq-schema#MainSchema/virus> _:N2fa20d9d6d7b4beaaf53160cf1969569 .
+_:Nbe0034a38484480ba179a898c4795f4e <http://semanticscience.org/resource/SIO_001167> "Oxford Nanopore MiniIon RNA long reads" .
+_:N0c4f8c1d8de04a5d97a78124723de78b <http://semanticscience.org/resource/SIO_000116> "Mariah Taylor" .
+_:N770ee69b1f114d7481a5456be97d2426 <http://purl.obolibrary.org/obo/OBI_0001479> <http://purl.obolibrary.org/obo/NCIT_C155831> .
+_:N2fa20d9d6d7b4beaaf53160cf1969569 <http://edamontology.org/data_1875> <http://purl.obolibrary.org/obo/NCBITaxon_2697049> .
+_:N770ee69b1f114d7481a5456be97d2426 <http://semanticscience.org/resource/SIO_000115> "TN_UT2" .
+_:Nbe0034a38484480ba179a898c4795f4e <http://purl.obolibrary.org/obo/OBI_0600047> <http://www.ebi.ac.uk/efo/EFO_0008632> .
+_:Nbe0034a38484480ba179a898c4795f4e <http://www.ebi.ac.uk/efo/EFO_0002699> "https://bio.tools/BWA#!" .
+_:Nea46fcb87c5547e8a98e3e52fd8d8a45 <http://semanticscience.org/resource/SIO_000115> "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"""