Pathogens & Parentheses



Pathogens & Parentheses

0 1


pathogens-and-parentheses


On Github rsslldnphy / pathogens-and-parentheses

Pathogens & Parentheses

How we use Clojure in the molecular serotyping of infectious disease

@rsslldnphy

BUGS Bioscience

Based in St Georges, Tooting

John Hunter

Known as the father of modern surgery

The Hunterian Museum

Edward Jenner

The first to write up the use of vaccination to prevent disease

Harry Hill!

Streptococcus pneumoniae

(or "the Pneumococcus")

A huge problem in the developing world, causing:

  • Pneumonia
  • Meningitis
  • Otitis Media (infection of the middle ear)

Streptococcus pneumoniae

Pneumonia accounts for the deaths of an estimated 1.3 million children under 5 each year.

40% of those those are caused by Pneumococcal disease.

Pneumococcal disease is the number one vaccine-preventable cause of death in children under 5.

Serotypes of Streptococcus pneumoniae

  • More than 90 different serotypes
  • Each vaccine targets a different set of serotypes
  • The distribution of serotypes differs between populations

Microarrays

  • Printed with 8x15000 (120,000) spots of DNA, or "oligonucleotide probes"
  • Each probe targets a specific region in the Streptococcus pneumoniae genome

The results

The code!

  • Overall architecture
  • Challenges so far
  • Our first open source project

Architecture

User-facing app

  • Single page Reagent app
  • JSON API using Liberator
  • Wired up with Stuart Sierra's component library

Components: lessons learnt

  • Comes at a cost of boilerplate code
  • Functions that take lots of dependencies as arguments
  • Can obscure what's important in a function signature

Components: lessons learnt

          (defn process-upload
  [db s3 sqs params]
  (->> (new-analysis params)
       (uploads/create-upload db s3)
       (analyses/queue-analysis db s3 sqs)))
        

Components: lessons learnt

          (defn process-upload
  [db s3 sqs params]
  (->> (new-analysis params)
       (db/insert-record db)
       (s3/archive-file s3)
       (agilent/parse)
       (s3/record-input s3)
       (sqs/queue-analysis sqs)
       (db/update-record db)))
        

Components: lessons learnt

          (defprotocol IUploadService
  (process-upload [this params]))

(defrecord UploadService [db s3 sqs]
  IUploadService
  (process-upload
    [this params]
    (->> (new-analysis params)
         (db/insert-record db)
         (s3/archive-file s3)
         (agilent/parse)
         (s3/record-input s3)
         (sqs/queue-analysis sqs)
         (db/update-record db)))
        

Single page app with Reagent

  • The React/Reagent model is really exciting!
  • Figwheel is fantastic
  • However, without a clear structure, you risk spaghetti code
  • This is something we're still working on...

Mundane stuff

Web story still feels rough around the edges.

Features you're used to having provided, you find you need to roll your own.

But, we're hopeful that Clojure will prove worth this upfront cost.

Plug!

Tern - migrations as data

https://github.com/bugsbio/lein-tern

Plug!

Tern - migrations as data

        {:up
 [{:create-table :cats
   :columns [[:id   "BIGSERIAL" "PRIMARY KEY"]
             [:name "TEXT"      "NOT NULL"]
             [:paws "INT"]]}]
 :down
 [{:drop-table :cats}]}
        

https://github.com/bugsbio/lein-tern

Thank you :-)

I'm @rsslldnphy on Twitter and Github

We're @bugsbio_dev on Twitter and bugsbio on Github

Slides are up at github.com/rsslldnphy/pathogens-and-parentheses

Don't forget to check out Tern at github.com/bugsbio/lein-tern!