SciLifeLab/genomics-status

Name: genomics-status

Owner: Science For Life Laboratory

Description: Tornado server for tracking samples at NGI Stockholm

Created: 2012-06-13 14:39:29.0

Updated: 2016-10-31 12:52:49.0

Pushed: 2018-01-10 16:25:16.0

Homepage: https://genomics-status.scilifelab.se

Size: 4241

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Genomics Status

Genomics Status is a Tornado web app for visualizing information and statistics regarding SciLifeLab Genomics platform operations.

Status interfaces with StatusDB; the CouchDB database instance we're using at SciLifeLab to store metadata in various forms. Document specifications for StatusDB are available in the internal wiki. Documentation about CouchDB can be found here.

Installing and running genomics status

NOTE: These steps assume that:

1 - Clone the repository with the --recursive option (this will also download nvd3 library):

clone --recursive https://github.com/SciLifeLab/status.git

2 - Install the package

tatus
on setup.py install

3 - You'll need to install genologics package separately:

install git+https://github.com/SciLifeLab/genologics.git

4 - For running, it requires a settings.yaml file which points to the CouchDB server to use, and which port to serve the web app to. You will also need a .genologicsrc file with the API credentials for our Genologics LIMS. The files should look like these:

<status_dir>/run_dir/settings.yaml:

h_server: http://<username>:<password>@tools-dev.scilifelab.se:5984
name: <tools_username>
word: <tools_password>
: 9761
rect_uri: http://localhost:9761/login

le_oauth:
key_old: write
key: anything
secret: here

act_person: someone@domain.com

ruments:
HiSeq:
    INSTRUMENT_ID: INSTRUMENT_NAME
MiSeq:
    INSTRUMENT_ID: INSTRUMENT_NAME

word_seed: dont_needed

u Trello API credentials, you need a board named "Suggestion Box"
lo:
api_key: <trello_api_key>
api_secret: <trello_api_secret>
token: <trello_token>

ax_projects
- proj_id1
- proj_id2

~/.genologicsrc:

ologics]
URI=https://genologics-stage.scilifelab.se:8443
NAME=<lims_api_username>
WORD=<lims_api_password>

5 - Run the tornado app from run_dir :

un_dir
on ../status_app.py --testing_mode

--testing_mode will skip the google authentication, which is convenient for testing

The status web app both provides the HTML web interface, and a RESTful api for accessing the data being visualized on the various pages.

If you've used the settings.yaml template above, you should now be able to access the site at http://localhost:9761/login

Genomics Status architecture

This pictures illustrates the architecture of how Genomics Status is built with a real example, a request to https://genomics-status.scilifelab.se/projects/all. It is simplified for the sake of comprehension, in reality there are a few more API calls.

Genomics Status Architecture

  1. The web browser (a human, actually) requests the page /projects/all. The browser sends the request to Tornado, which has assigned the ProjectsHandler to this call.
  2. Tornado returns a rendered template with all the parameters needes to build the projects page, i.e username, projects to list, etc.
  3. Within the template, in order to build the project list, it performas a JavaScript (JQuery) call to GenStat API.
  4. Tornado queries StatusDB information about the projects and parses it correctly.
  5. A JSON document is returned to the web browser
  6. Which uses it to build the project list client-side.

This design aims to decouple design and backend, as well as avoid making calls to the database from the web browser.

It also facilitates the reusability of the API for other possible applications.

Tornado

Tornado is a Python web framework and asynchronous networking library. Genomics Status is based on Tornado.

A very basic tornado web app, but enough to get the idea, would be something like this:

rt tornado.ioloop
rt tornado.web

s MainHandler(tornado.web.RequestHandler):
def get(self):
    self.write("Hello, world")

ication = tornado.web.Application([
(r"/", MainHandler),


_name__ == "__main__":
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()

Basically, you have to define a handlaer for each URL you want your application to serve. In this case, we define just one handler for the URI '/'. This will just print a "Hello, World" page.

Handlers that inherit from `tornado.web.RequestHandler` should implement at least one of the HTTP basic operations, i.e GET, POST or PUT.

Tornado templating

Tornado templates are a good way to generate dynamic pages server side. The advantage of templates is that you can embeed python code in them. The official documentation is good enough to learn how they work.

On Genomics Status, templates are located in status/run_dir/design


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.