more WIP
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
{
|
||||
"scripts": {
|
||||
"build": "shadow-cljs compile app",
|
||||
"dev": "shadow-cljs watch app",
|
||||
"test": "shadow-cljs compile tests",
|
||||
"repl": "shadow-cljs node-repl"
|
||||
},
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
{:source-paths ["src"]
|
||||
:dependencies [[binaryage/devtools "1.0.6"]
|
||||
[nrepl "1.0.0"]
|
||||
[reagent "1.1.1"]]
|
||||
[reagent "1.1.1"]
|
||||
[cljs-http "0.1.46"]]
|
||||
|
||||
:builds {:app {:target :browser
|
||||
:output-dir "public/js"
|
||||
:asset-path "/js"
|
||||
@@ -13,6 +15,7 @@
|
||||
:output-dir "tests-out/output"
|
||||
:modules {:app {:entries [reagent-test.core-test
|
||||
reagent-test.ncbi-test]}}
|
||||
:autorun true}}
|
||||
:autorun true
|
||||
:devtools {:ignore-warnings true}}}
|
||||
|
||||
:dev-http {3000 {:root "public"}}}
|
||||
|
||||
@@ -1,21 +1,14 @@
|
||||
(ns reagent-test.core
|
||||
(:require
|
||||
[reagent.core :as r]
|
||||
[reagent.dom :as d]
|
||||
[reagent-test.ncbi :refer [ncbi-search]]))
|
||||
(:require [cljs.core.async :refer [<! go]]
|
||||
[reagent-test.ncbi :refer [ncbi-search]]
|
||||
[reagent.dom :as d]))
|
||||
|
||||
;; -------------------------
|
||||
;; Component data (custom)
|
||||
|
||||
(def action-btns [{:text "file"
|
||||
:items [{:text "new" :action #(dorun (js/console.log "test")
|
||||
(js/console.log "hi"))}
|
||||
{:text "new" :action #(js/alert "hi")}
|
||||
{:text "quit" :action #()}]}
|
||||
{:text "edit"
|
||||
:items [{:text "hi" :action #(js/console.log "test2")}
|
||||
{:text "bye" :action #(js/console.log "bye")}]}
|
||||
{:text "view" :action #(js/console.log "test3")}
|
||||
(def action-btns [{:text "tools" :action #(js/console.log "hi")}
|
||||
{:text "search" :action #((go (let [res (<! (ncbi-search "pubmed" "science[journal]+AND+breast+cancer+AND+2008[pdat]"))]
|
||||
(js/console.log res))))}
|
||||
{:text "help" :action #(js/console.log "test4")}])
|
||||
|
||||
;; -------------------------
|
||||
|
||||
@@ -1,16 +1,33 @@
|
||||
(ns reagent-test.ncbi
|
||||
(:require [clojure.core.async :refer [take!]]
|
||||
(:require [cljs.core.async :refer [<! go]]
|
||||
[cljs-http.client :as http]
|
||||
[goog.string :as gstring]
|
||||
[goog.string.format]))
|
||||
[goog.string.format]
|
||||
[goog.dom.xml :refer [loadXml]]))
|
||||
|
||||
(defn ncbi-search
|
||||
"Send search query to NCBI database.
|
||||
(def base-url "https://eutils.ncbi.nlm.nih.gov/entrez/eutils")
|
||||
|
||||
(defn ncbi-db-search
|
||||
"Send search query to NCBI database, and get back a list of ID strings.
|
||||
[More info](https://www.ncbi.nlm.nih.gov/books/NBK25500/#_chapter1_Searching_a_Database_)
|
||||
|
||||
Example Query: `science[journal]+AND+breast+cancer+AND+2008[pdat]`"
|
||||
[query]
|
||||
(let [res (->> query
|
||||
(gstring/format "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=%s")
|
||||
js/fetch
|
||||
take!)]
|
||||
(js/console.log res)))
|
||||
[db-id query]
|
||||
(go (let [res (<! (http/get (gstring/format
|
||||
"%s/esearch.fcgi?db=%s&term=%s"
|
||||
base-url db-id query)))
|
||||
xml-doc (loadXml res)]
|
||||
(. xml-doc getElementByTagName "Id"))))
|
||||
|
||||
(defn ncbi-db-get-summary
|
||||
"Get summary by ID.
|
||||
[More info](https://www.ncbi.nlm.nih.gov/books/NBK25500/#_chapter1_Downloading_Document_Summaries_)"
|
||||
[db-id id]
|
||||
(go (let [res (<! (http/get (gstring/format
|
||||
"%s/esummary.fcgi?db=%s&id=%s"
|
||||
base-url db-id id)))
|
||||
xml-doc (loadXml res)]
|
||||
(js/console.log "hi"))))
|
||||
|
||||
(defn ncbi-search-gene [query] (ncbi-db-search "gene" query))
|
||||
(defn ncbi-id-gene [query] (ncbi-db-search "gene" query))
|
||||
|
||||
@@ -1,10 +1,21 @@
|
||||
(ns reagent-test.ncbi-test
|
||||
(:require [cljs.test :refer [deftest is async?]]
|
||||
[clojure.core.async :refer [<! go]]
|
||||
(:require [cljs.pprint :refer [pprint]]
|
||||
[cljs.test :refer [deftest]]
|
||||
[cljs.core.async :refer [<! go]]
|
||||
[reagent-test.ncbi :refer [ncbi-search]]))
|
||||
|
||||
(deftest a-test
|
||||
(dorun
|
||||
(go
|
||||
(let [res (<! (ncbi-search "science[journal]+AND+breast+cancer+AND+2008[pdat]"))]
|
||||
(js/console.log res)))))
|
||||
;; (deftest test-ncbi-search-pubmed
|
||||
;; (go (let [res (<! (ncbi-search "pubmed" "science[journal]+AND+breast+cancer+AND+2008[pdat]"))
|
||||
;; status (:status res)
|
||||
;; buf (:buf res)]
|
||||
;; (assert (not (nil? res)))
|
||||
;; (assert (not (nil? buf)))
|
||||
;; (assert (= status 200))
|
||||
;; (pprint res)
|
||||
;; (pprint "hi"))))
|
||||
|
||||
(deftest test-ncbi-search-pubmed
|
||||
(let [res (ncbi-search "pubmed" "science[journal]+AND+breast+cancer+AND+2008[pdat]")]
|
||||
(assert (not (nil? res)))
|
||||
(pprint res)
|
||||
(pprint "hi")))
|
||||
|
||||
Reference in New Issue
Block a user