Skip to content

Commit

Permalink
Merge branch 'master' of github.com:intermine/imcljs
Browse files Browse the repository at this point in the history
  • Loading branch information
yochannah committed May 16, 2017
2 parents fa40647 + 7defc71 commit 0236eb6
Show file tree
Hide file tree
Showing 13 changed files with 292 additions and 187 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ out
.lein-*
/resources/public/js
/resources/public/js/test
node_modules/
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: clojure
lein: lein2
script: lein2 doo phantom test once
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# imcljs

[![Build Status](https://travis-ci.org/intermine/imcljs.svg?branch=master)](https://travis-ci.org/intermine/imcljs)

A library for interacting with Intermine's web services.

## Getting Start
Expand Down
141 changes: 6 additions & 135 deletions src/imcljs/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -8,147 +8,18 @@
[imcljs.save :as save]
[imcljs.entity :as entity]))





(enable-console-print!)

(defn on-js-reload []
(def flymine {:root "beta.flymine.org/beta"
:model {:name "genomic"}})

(def flymine-beta {:root "beta.flymine.org/beta"
:model {:name "genomic"}})

(def mousemine {:root "www.mousemine.org/mousemine"
:model {:name "genomic"}})

(def a-query {:select ["Gene.symbol" "Gene.secondaryIdentifier" "Gene.homologues.homologue.name"]
:orderBy [{:symbol "asc"}]
:where [{:path "symbol"
:op "="
:value "ab*"}]})


(def region {:from "SequenceFeature"
:select ["SequenceFeature.id"]
:orderBy [["SequenceFeature.id" "asc"]]
:where [{:path "SequenceFeature"
:op "ISA"
:values ["Exon" "Intron" "Gene"]}]})



(def bigr {:from "SequenceFeature"
:select ["SequenceFeature.id"
"SequenceFeature.name"
"SequenceFeature.primaryIdentifier"
"SequenceFeature.symbol"
"SequenceFeature.chromosomeLocation.start"
"SequenceFeature.chromosomeLocation.end"
"SequenceFeature.chromosomeLocation.locatedOn.primaryIdentifier"]
:where [{:path "SequenceFeature.chromosomeLocation"
:op "OVERLAPS"
:values ["2L:14615455..14619002"
"2R:5866646..5868384"
"3R:2578486..2580016"]}
{:path "SequenceFeature.organism.shortName"
:op "="
:value "D. melanogaster"}]})

(def service {:root "beta.flymine.org/beta"
:model {:name "genomic"}})

(def ids-constraint-shortcut
{:from "Gene"
:select ["Gene.symbol"]
:where [{:path "Gene"
:ids [1000100 1000781 1001050 1001183 1001292]}]})

(def subclass-query
{:from "OntologyAnnotation",
:select ["subject.primaryIdentifier"
"subject.symbol"
"evidence.baseAnnotations.subject.symbol"
"evidence.baseAnnotations.subject.background.name"
"evidence.baseAnnotations.subject.zygosity"
"ontologyTerm.identifier"
"ontologyTerm.name"],
:orderBy [{:path "subject.symbol", :direction "ASC"}],
:where [{:path "ontologyTerm.parents", :type "MPTerm"}
{:path "ontologyTerm", :type "MPTerm"}
{:path "subject", :type "SequenceFeature"}
{:path "evidence.baseAnnotations.subject", :type "Genotype"}
{:path "ontologyTerm.parents", :op "LOOKUP", :value "*circulating glucose*", :code "A"}]})

(def subclass-query-2
{:name "Lookup_MPhenotype",
:title "Lookup --> Mammalian phenotypes (MP terms)",
:description "Returns MP terms whose names match the specified search terms.",
:constraintLogic "A and B",
:from "MPTerm",
:select ["name" "identifier" "description"],
:orderBy [{:path "name", :direction "ASC"}],
:where [{:path "obsolete",
:op "=",
:value "false", :code "B",
:editable false,
:switched "LOCKED",
:switchable false}
{:path "name",
:op "CONTAINS",
:value "hemoglobin",
:code "A",
:editable true,
:switched "LOCKED",
:switchable false}]})

(def constraint-query
{:from "Gene"
:select ["Gene.symbol" "Gene.secondaryIdentifier"]
:orderBy [{:symbol "asc"}]
:where [{:path "Gene"
:op "IN"
:value "PL FlyAtlas_maleglands_top"}
{:path "Gene.symbol"
:op "<="
:value "100"
:code "A"}]})

(def big-query
{:from "Gene"
:select ["Gene.symbol" "Gene.secondaryIdentifier"]
:orderBy [{:symbol "asc"}]})

(go
(let [fm (assoc flymine-beta :token (<! (fetch/session flymine-beta)))]
(save/im-list-union fm "UNION" ["pie" "five_genes"])))
(def query {:from "Gene" :select ["Gene.organism.name"]})

(defn on-js-reload []
(go
(let [fm (assoc flymine-beta :token (<! (fetch/session flymine-beta)))]
(.log js/console "D" (<! (save/im-list-copy fm "cookies" "cookies2")))))


#_(go
(.log js/console "d" (<! (fetch/table-rows flymine big-query {:start 50 :size 1}))))





(let [model (<! (fetch/model service))]
(println "adjusted" (path/adjust-path-to-last-class model "Gene.organism.name")))))

#_(go
(let [model (<! (fetch/model flymine))]
(.log js/console (fetch/table-rows flymine constraint-query))))


;(go
; (let [fm (assoc flymine :token (<! (fetch/session flymine)))]
; (save/im-list fm a-query)))
#_(go
(let [model (<! (fetch/model flymine))]
(.log js/console (query/deconstruct-by-class model a-query))))

;(go (.log js/console "templates" (<! (fetch/templates flymine))))
;(go (.log js/console "enrichment" (<! (fetch/enrichment flymine {:list "PL FlyTF_putativeTFs"}))))
;(go (.log js/console "rows" (<! (fetch/rows flymine a-query))))
)
20 changes: 19 additions & 1 deletion src/imcljs/fetch.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
(ns imcljs.fetch
(:require [imcljs.internal.io :refer [restful]]))
(:require-macros [cljs.core.async.macros :refer [go]])
(:require [imcljs.internal.io :refer [restful]]
[cljs.core.async :refer [<! >! chan]]))

; Quicksearch

Expand Down Expand Up @@ -30,6 +32,22 @@
[service query & [options]]
(restful :post "/query/results" service (merge {:query query :format "count"} options)))

(defn possible-values
[service path & [options]]
(restful :get "/path/values" service (merge {:path path :format "json"} options)))

(defn unique-values
"Fetches unique values for a path within a query. Providing a limit shortcircuits the request
and returns false if the unique values exceed the limit"
[service query path & [limit]]
(let [return-chan (chan)]
(go
(let [{unique-count :uniqueValues} (<! (rows service query {:summaryPath path :size 1 :format "jsonrows"}))]
(if (or (not limit) (<= unique-count limit))
(>! return-chan (<! (rows service query {:summaryPath path :size limit :format "jsonrows"})))
(>! return-chan false))))
return-chan))

; Assets

(defn lists
Expand Down
8 changes: 4 additions & 4 deletions src/imcljs/internal/io.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@

(defmethod restful :post [method path service options & [xform]]
;(body- (post-wrapper- path service options) xform)
(post-wrapper- path service options xform)
)
(post-wrapper- path service options xform))


(defmethod restful :get [method path service options & [xform]]
;(body- (request-wrapper- path service options) xform)
(request-wrapper- path service options xform)
)
(request-wrapper- path service options xform))


(defmethod restful :delete [method path service options & [xform]]
(delete-wrapper- path service options xform))
5 changes: 3 additions & 2 deletions src/imcljs/internal/utils.cljs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(ns imcljs.internal.utils)
(ns imcljs.internal.utils
(:require [clojure.string :refer [split]]))

(def does-not-contain? (complement contains?))

Expand All @@ -10,7 +11,7 @@

(defn append- [text val] (str val text))

(def alphabet (apply sorted-set (clojure.string/split "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "")))
(def alphabet (apply sorted-set (split "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "")))

(defn scrub-url
"Ensures that a url starts with an http protocol and ends with /service"
Expand Down
Loading

0 comments on commit 0236eb6

Please sign in to comment.