From 6ee5810042f53023a261aae85df3be3adb16147b Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Mon, 20 Jul 2020 12:14:07 +0100 Subject: Adding an endpoint for documentation --- bh20simplewebuploader/main.py | 6 ++- test/rest-api.html | 110 ++++++++++++++++++++++++++++++++++++------ test/rest-api.org | 4 +- 3 files changed, 103 insertions(+), 17 deletions(-) diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index aad607d..029c2e3 100644 --- a/bh20simplewebuploader/main.py +++ b/bh20simplewebuploader/main.py @@ -638,6 +638,11 @@ def export_page(): def demo_page(): return render_template('demo.html',menu='DEMO',load_map=True) +@app.route('/apidoc') +def apidoc_page(): + buf = get_html_body('test/rest-api.html',"https://github.com/arvados/bh20-seq-resource/blob/master/test/rest-api.org") + return render_template('blog.html',menu='BLOG',embed=buf) + @app.route('/blog',methods=['GET']) def blog_page(): blog_content = request.args.get('id') # e.g. using-covid-19-pubseq-part3 @@ -652,7 +657,6 @@ def about_page(): buf = get_html_body('doc/web/about.html','https://github.com/arvados/bh20-seq-resource/blob/master/doc/web/about.org') return render_template('about.html',menu='ABOUT',embed=buf) - ## Dynamic API functions starting here ## This is quick and dirty for now, just to get something out and demonstrate the queries ## Feel free to rename the functions/endpoints, feel free to process result so we get nicer JSON diff --git a/test/rest-api.html b/test/rest-api.html index e0a10c7..c50d116 100644 --- a/test/rest-api.html +++ b/test/rest-api.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + @@ -246,18 +246,18 @@ for the JavaScript code in this tag.

Table of Contents

-
-

1 PubSeq REST API

+
+

1 PubSeq REST API

Here we document the public REST API that comes with PubSeq. The tests @@ -266,8 +266,8 @@ for running the tests inside emacs.

-
-

1.1 Introduction

+
+

1.1 Introduction

We built a REST API for COVID-19 PubSeq. The API source code can be @@ -299,11 +299,39 @@ assert response_body["service"] == "PubSeq", "PubSeq API not found" response_body

+ + + + +++ ++ ++ ++ ++ ++ + + + + + + + + + + +
service:PubSeqversion:0.1
-
-

1.2 Fetch EBI XML

+
+

1.2 Fetch EBI XML

PubSeq provides an API that is used to export formats that are @@ -315,12 +343,66 @@ documented requests.get("http://covid19.genenetwork.org/api/ebi/sample-MT32690.1.xml").text

+ +
+<?xml version="1.0" encoding="UTF-8"?>
+<SAMPLE_SET>
+  <SAMPLE alias="MT32690.1" center_name="COVID-19 PubSeq">
+    <TITLE>COVID-19 PubSeq Sample</TITLE>
+    <SAMPLE_NAME>
+      <TAXON_ID>2697049</TAXON_ID>
+      <SCIENTIFIC_NAME>Severe acute respiratory syndrome coronavirus 2</SCIENTIFIC_NAME>
+      <COMMON_NAME>SARS-CoV-2</COMMON_NAME>
+    </SAMPLE_NAME>
+    <SAMPLE_ATTRIBUTES>
+      <SAMPLE_ATTRIBUTE>
+        <TAG>investigation type</TAG>
+        <VALUE></VALUE>
+      </SAMPLE_ATTRIBUTE>
+      <SAMPLE_ATTRIBUTE>
+        <TAG>sequencing method</TAG>
+        <VALUE></VALUE>
+      </SAMPLE_ATTRIBUTE>
+      <SAMPLE_ATTRIBUTE>
+        <TAG>collection date</TAG>
+        <VALUE></VALUE>
+      </SAMPLE_ATTRIBUTE>
+      <SAMPLE_ATTRIBUTE>
+        <TAG>geographic location (latitude)</TAG>
+        <VALUE></VALUE>
+     <UNITS>DD</UNITS>
+      </SAMPLE_ATTRIBUTE>
+      <SAMPLE_ATTRIBUTE>
+        <TAG>geographic location (longitude)</TAG>
+        <VALUE></VALUE>
+     <UNITS>DD</UNITS>
+      </SAMPLE_ATTRIBUTE>
+      <SAMPLE_ATTRIBUTE>
+     <TAG>geographic location (country and/or sea)</TAG>
+     <VALUE></VALUE>
+      </SAMPLE_ATTRIBUTE>
+      <SAMPLE_ATTRIBUTE>
+        <TAG>geographic location (region and locality)</TAG>
+        <VALUE></VALUE>
+      </SAMPLE_ATTRIBUTE>
+      <SAMPLE_ATTRIBUTE>
+        <TAG>environment (material)</TAG>
+        <VALUE></VALUE>
+      </SAMPLE_ATTRIBUTE>
+      <SAMPLE_ATTRIBUTE>
+        <TAG>ENA-CHECKLIST</TAG>
+        <VALUE>ERC000011</VALUE>
+      </SAMPLE_ATTRIBUTE>
+    </SAMPLE_ATTRIBUTES>
+  </SAMPLE>
+</SAMPLE_SET>
+
-
-

2 Configure emacs to run tests

+
+

2 Configure emacs to run tests

Execute a code @@ -346,7 +428,7 @@ To skip confirmations you may also want to set

-
Created by
Pjotr Prins (pjotr.public768 at thebird 'dot' nl) using Emacs org-mode and a healthy dose of Lisp!
Modified 2020-07-20 Mon 06:02
. +
Created by Pjotr Prins (pjotr.public768 at thebird 'dot' nl) using Emacs org-mode and a healthy dose of Lisp!
Modified 2020-07-20 Mon 06:13
.
diff --git a/test/rest-api.org b/test/rest-api.org index fa4e9e6..6d118b5 100644 --- a/test/rest-api.org +++ b/test/rest-api.org @@ -22,7 +22,7 @@ curl http://covid19.genenetwork.org/api/version The Python3 version is -#+begin_src python :session +#+begin_src python :session :exports both import requests response = requests.get("http://covid19.genenetwork.org/api/version") response_body = response.json() @@ -39,7 +39,7 @@ PubSeq provides an API that is used to export formats that are suitable for uploading data to EBI/ENA from our [[http://covid19.genenetwork.org/export][EXPORT]] menu. This is documented [[http://covid19.genenetwork.org/blog?id=using-covid-19-pubseq-part6][here]]. -#+begin_src python :session +#+begin_src python :session :exports both requests.get("http://covid19.genenetwork.org/api/ebi/sample-MT32690.1.xml").text #+end_src -- cgit v1.2.3