# C-c C-e h h publish
# C-c ! insert date (use . for active agenda, C-u C-c ! for date+time, C-u C-c . for time)
# C-c C-t task rotate
# RSS_IMAGE_URL: http://xxxx.xxxx.free.fr/rss_icon.png
#+TITLE: PubSeq REST API
#+AUTHOR: Pjotr Prins
#+HTML_LINK_HOME: http://covid19.genenetwork.org/apidoc
# OPTIONS: section-numbers: nil, with-drawers: t
#+HTML_HEAD:
* PubSeq REST API
Here we document the public REST API that comes with PubSeq. The tests
run in the amazing emacs [[https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html][org-babel]]. See the bottom of this document
for running the tests inside emacs.
** Introduction
We built a REST API for COVID-19 PubSeq. The API source code can be
found in [[https://github.com/arvados/bh20-seq-resource/tree/master/bh20simplewebuploader/api.py][api.py]]. To see if the service is up try
#+begin_src sh
curl http://covid19.genenetwork.org/api/version
#+end_src
#+begin_src js
{
"service": "PubSeq",
"version": 0.1
}
#+end_src
The Python3 version is
#+begin_src python :session :exports both
import requests
response = requests.get("http://covid19.genenetwork.org/api/version")
response_body = response.json()
assert response_body["service"] == "PubSeq", "PubSeq API not found"
response_body
#+end_src
#+RESULTS:
| service | : | PubSeq | version | : | 0.1 |
** Fetch metadata
** Fetch EBI XML
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 :exports both
requests.get("http://covid19.genenetwork.org/api/ebi/sample-MT32690.1.xml").text
#+end_src
#+RESULTS:
#+begin_example
COVID-19 PubSeq Sample2697049Severe acute respiratory syndrome coronavirus 2SARS-CoV-2investigation typesequencing methodcollection dategeographic location (latitude)DDgeographic location (longitude)DDgeographic location (country and/or sea)geographic location (region and locality)environment (material)ENA-CHECKLISTERC000011
#+end_example
* Configure emacs to run tests
Execute a code
block with C-c C-c. You may need to set
#+begin_src elisp
(org-babel-do-load-languages
'org-babel-load-languages
'((python . t)))
(setq org-babel-python-command "python3")
#+end_src
#+RESULTS:
: python3
To skip confirmations you may also want to set
: (setq org-confirm-babel-evaluate nil)