From 86f31ef60f65a820bf9ac25c3fc01c88f2a9ebfe Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Tue, 21 Jul 2020 11:38:33 +0100 Subject: Updated REST API doc --- test/rest-api.html | 224 +++++++++++++++++++++++++++++++++++++++++++++++------ test/rest-api.org | 7 +- 2 files changed, 206 insertions(+), 25 deletions(-) (limited to 'test') diff --git a/test/rest-api.html b/test/rest-api.html index 421d75a..6e5bf5a 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"> - + PubSeq REST API @@ -252,21 +252,21 @@ 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 @@ -275,8 +275,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 @@ -302,7 +302,9 @@ The Python3 version is

import requests
-response = requests.get("http://covid19.genenetwork.org/api/version")
+baseURL="http://localhost:5000" # for development
+# baseURL="http://covid19.genenetwork.org"
+response = requests.get(baseURL+"/api/version")
 response_body = response.json()
 assert response_body["service"] == "PubSeq", "PubSeq API not found"
 response_body
@@ -339,24 +341,196 @@ response_body
 
-
-

1.2 Fetch EBI XML

+
+

1.2 Search for an entry

+When you use the search box on PubSeq it queries the REST end point +for information on the search items. For example +

+ +
+
requests.get(baseURL+"/api/search?s=MT533203.1").json()
+
+
+ + + + +++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + + + + + + + + + + + + + + + + +
collection:http://collections.lugli.arvadosapi.com/c=0015b0d65dfd2e82bb3cee4436bf2893+126fasta:http://collections.lugli.arvadosapi.com/c=0015b0d65dfd2e82bb3cee4436bf2893+126/sequence.fastaid:MT533203.1info:http://identifiers.org/insdc/MT533203.1#sequence
+ +

+where collection is the raw uploaded data. The hash value in c= is +computed on the contents of the Arvados keep collection and effectively +acts as a deduplication uuid. +

+
+
+ +
+

1.3 Fetch metadata

+
+

+Using above collection link you can fetch the metadata in JSON as it +was uploaded originally from the SHeX expression, e.g. using +https://collections.lugli.arvadosapi.com/c=0015b0d65dfd2e82bb3cee4436bf2893+126/ +

+ +

+But better to use the more advanced sample metadata fetcher +because is does a bit more in terms of expansion +

+ +
+
requests.get(baseURL+"/api/sample/MT533203.1.json").json()
+
+
+ + + + +++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
collection:http://collections.lugli.arvadosapi.com/c=0015b0d65dfd2e82bb3cee4436bf2893+126date:2020-04-27fasta:http://collections.lugli.arvadosapi.com/c=0015b0d65dfd2e82bb3cee4436bf2893+126/sequence.fastaid:MT533203.1info:http://identifiers.org/insdc/MT533203.1#sequencemapper:minimap v. 2.17sequencer:http://www.ebi.ac.uk/efo/EFO_0008632specimen:http://purl.obolibrary.org/obo/NCIT_C155831
+
+
+ + + +
+

1.4 Fetch EBI XML

+
+

PubSeq provides an API that is used to export formats that are suitable for uploading data to EBI/ENA from our EXPORT menu. This is documented here.

-
requests.get("http://covid19.genenetwork.org/api/ebi/sample-MT32690.1.xml").text
+
requests.get(baseURL+"/api/ebi/sample-MT326090.1.xml").text
 
 <?xml version="1.0" encoding="UTF-8"?>
 <SAMPLE_SET>
-  <SAMPLE alias="MT32690.1" center_name="COVID-19 PubSeq">
+  <SAMPLE alias="MT326090.1" center_name="COVID-19 PubSeq">
     <TITLE>COVID-19 PubSeq Sample</TITLE>
     <SAMPLE_NAME>
       <TAXON_ID>2697049</TAXON_ID>
@@ -370,11 +544,11 @@ documented 
-

2 Configure emacs to run tests

+
+

2 Configure emacs to run tests

Execute a code @@ -423,6 +597,7 @@ block with C-c C-c. You may need to set 'org-babel-load-languages '((python . t))) (setq org-babel-python-command "python3") +(setq org-babel-eval-verbose t)

@@ -433,11 +608,16 @@ To skip confirmations you may also want to set
 (setq org-confirm-babel-evaluate nil)
 
+ + +

+To see output of the inpreter open then Python buffer. +

-
Created by
Pjotr Prins (pjotr.public768 at thebird 'dot' nl) using Emacs org-mode and a healthy dose of Lisp!
Modified 2020-07-21 Tue 01:32
. +
Created by Pjotr Prins (pjotr.public768 at thebird 'dot' nl) using Emacs org-mode and a healthy dose of Lisp!
Modified 2020-07-21 Tue 05:38
.
diff --git a/test/rest-api.org b/test/rest-api.org index 6dd6616..4b66147 100644 --- a/test/rest-api.org +++ b/test/rest-api.org @@ -77,6 +77,7 @@ requests.get(baseURL+"/api/sample/MT533203.1.json").json() #+end_src #+RESULTS: +| collection | : | http://collections.lugli.arvadosapi.com/c=0015b0d65dfd2e82bb3cee4436bf2893+126 | date | : | 2020-04-27 | fasta | : | http://collections.lugli.arvadosapi.com/c=0015b0d65dfd2e82bb3cee4436bf2893+126/sequence.fasta | id | : | MT533203.1 | info | : | http://identifiers.org/insdc/MT533203.1#sequence | mapper | : | minimap v. 2.17 | sequencer | : | http://www.ebi.ac.uk/efo/EFO_0008632 | specimen | : | http://purl.obolibrary.org/obo/NCIT_C155831 | @@ -108,11 +109,11 @@ requests.get(baseURL+"/api/ebi/sample-MT326090.1.xml").text sequencing method - + http://purl.obolibrary.org/obo/OBI_0000759 collection date - + 2020-03-21 geographic location (latitude) @@ -134,7 +135,7 @@ requests.get(baseURL+"/api/ebi/sample-MT326090.1.xml").text environment (material) - + http://purl.obolibrary.org/obo/NCIT_C155831 ENA-CHECKLIST -- cgit v1.2.3