From bfbf2ff23907ac86b5fd0cfb92ba94d2d1d236ed Mon Sep 17 00:00:00 2001 From: turtlebasket Date: Sat, 4 Feb 2023 14:49:44 -0800 Subject: [PATCH] WIP --- ncbi-api-test/.gitignore | 130 ++++ ncbi-api-test/index.js | 18 + ncbi-api-test/package.json | 9 + ncbi-api-test/yarn.lock | 4 + reagent-test/.gitignore | 156 +++++ reagent-test/README.md | 23 + reagent-test/index.html | 2 + reagent-test/package.json | 13 + reagent-test/public/css/site.css | 47 ++ reagent-test/public/index.html | 16 + reagent-test/shadow-cljs.edn | 18 + reagent-test/src/reagent_test/core.cljs | 53 ++ reagent-test/src/reagent_test/core_test.cljs | 5 + reagent-test/src/reagent_test/ncbi.cljs | 16 + reagent-test/src/reagent_test/ncbi_test.cljs | 10 + reagent-test/src/user.clj | 7 + reagent-test/yarn.lock | 684 +++++++++++++++++++ 17 files changed, 1211 insertions(+) create mode 100644 ncbi-api-test/.gitignore create mode 100644 ncbi-api-test/index.js create mode 100644 ncbi-api-test/package.json create mode 100644 ncbi-api-test/yarn.lock create mode 100644 reagent-test/.gitignore create mode 100644 reagent-test/README.md create mode 100644 reagent-test/index.html create mode 100644 reagent-test/package.json create mode 100644 reagent-test/public/css/site.css create mode 100644 reagent-test/public/index.html create mode 100644 reagent-test/shadow-cljs.edn create mode 100644 reagent-test/src/reagent_test/core.cljs create mode 100644 reagent-test/src/reagent_test/core_test.cljs create mode 100644 reagent-test/src/reagent_test/ncbi.cljs create mode 100644 reagent-test/src/reagent_test/ncbi_test.cljs create mode 100644 reagent-test/src/user.clj create mode 100644 reagent-test/yarn.lock diff --git a/ncbi-api-test/.gitignore b/ncbi-api-test/.gitignore new file mode 100644 index 0000000..6a7d6d8 --- /dev/null +++ b/ncbi-api-test/.gitignore @@ -0,0 +1,130 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp +.cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* \ No newline at end of file diff --git a/ncbi-api-test/index.js b/ncbi-api-test/index.js new file mode 100644 index 0000000..6acc328 --- /dev/null +++ b/ncbi-api-test/index.js @@ -0,0 +1,18 @@ +searchQuery = "science[journal]+AND+breast+cancer+AND+2008[pdat]"; + +function testSearch(query) { + fetch(`https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=${query}`) + .then((res) => { + console.log(`Status: ${res.status}`); + let reader = res.body.getReader(); + // while (!reader.closed) { + reader.read().then(out => { + // console.log(out) + var decoder = new TextDecoder('utf8'); + console.log(decoder.decode(out.value)); + }) + // } + }) +} + +testSearch(searchQuery); diff --git a/ncbi-api-test/package.json b/ncbi-api-test/package.json new file mode 100644 index 0000000..310bc1d --- /dev/null +++ b/ncbi-api-test/package.json @@ -0,0 +1,9 @@ +{ + "name": "ncbi-api-test", + "version": "0.0.1", + "main": "index.js", + "license": "MIT", + "scripts": { + "start": "node index.js" + } +} diff --git a/ncbi-api-test/yarn.lock b/ncbi-api-test/yarn.lock new file mode 100644 index 0000000..fb57ccd --- /dev/null +++ b/ncbi-api-test/yarn.lock @@ -0,0 +1,4 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + diff --git a/reagent-test/.gitignore b/reagent-test/.gitignore new file mode 100644 index 0000000..24168fd --- /dev/null +++ b/reagent-test/.gitignore @@ -0,0 +1,156 @@ +# tests +tests-out + +# clojure/cljs + +/target +/classes +/checkouts +profiles.clj +pom.xml +pom.xml.asc +*.jar +*.class +/.lein-* +/.nrepl-port +/resources/public/js +/public/js +/out +/.repl +*.log +/.env + +.lsp +.shadow-cljs +.clj-kondo + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp +.cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* \ No newline at end of file diff --git a/reagent-test/README.md b/reagent-test/README.md new file mode 100644 index 0000000..ae03dd9 --- /dev/null +++ b/reagent-test/README.md @@ -0,0 +1,23 @@ +# Reagent JBrowse Plugin Test + +## Development + +```bash +# Install dependencies +yarn +# Run dev server on port 3000 +yarn shadow-cljs watch app +``` + +Start a ClojureScript REPL + +``` +npx shadow-cljs browser-repl +``` + + +### Building for production + +``` +npx shadow-cljs release app +``` diff --git a/reagent-test/index.html b/reagent-test/index.html new file mode 100644 index 0000000..c771834 --- /dev/null +++ b/reagent-test/index.html @@ -0,0 +1,2 @@ + +shadow.test.browser \ No newline at end of file diff --git a/reagent-test/package.json b/reagent-test/package.json new file mode 100644 index 0000000..fc9f83e --- /dev/null +++ b/reagent-test/package.json @@ -0,0 +1,13 @@ +{ + "scripts": { + "test": "shadow-cljs compile tests", + "repl": "shadow-cljs node-repl" + }, + "devDependencies": { + "shadow-cljs": "^2.19.2" + }, + "dependencies": { + "react": "^17.0.2", + "react-dom": "^17.0.2" + } +} diff --git a/reagent-test/public/css/site.css b/reagent-test/public/css/site.css new file mode 100644 index 0000000..6d5ef4b --- /dev/null +++ b/reagent-test/public/css/site.css @@ -0,0 +1,47 @@ +body { + font-family: 'Helvetica Neue', Verdana, Helvetica, Arial, sans-serif; + max-width: 600px; + margin: 0 auto; + padding-top: 72px; + -webkit-font-smoothing: antialiased; + font-size: 1.125em; + color: #333; + line-height: 1.5em; +} + +h1, h2, h3 { + color: #000; +} +h1 { + font-size: 2.5em +} + +h2 { + font-size: 2em +} + +h3 { + font-size: 1.5em +} + +a { + text-decoration: none; + color: #09f; +} + +a:hover { + text-decoration: underline; +} + +.button-container { + display: flex; + flex-direction: row; +} + +.menu { + position: absolute; +} + +.menu-item { + width: 5rem; +} diff --git a/reagent-test/public/index.html b/reagent-test/public/index.html new file mode 100644 index 0000000..0212e0a --- /dev/null +++ b/reagent-test/public/index.html @@ -0,0 +1,16 @@ + + + + + + + + +
+

ClojureScript has not been compiled!

+

please run npx shadow-cljs watch app in order to start the compiler

+
+ + + + diff --git a/reagent-test/shadow-cljs.edn b/reagent-test/shadow-cljs.edn new file mode 100644 index 0000000..4351bc4 --- /dev/null +++ b/reagent-test/shadow-cljs.edn @@ -0,0 +1,18 @@ +{:source-paths ["src"] + :dependencies [[binaryage/devtools "1.0.6"] + [nrepl "1.0.0"] + [reagent "1.1.1"]] + :builds {:app {:target :browser + :output-dir "public/js" + :asset-path "/js" + :modules {:app {:entries [reagent-test.core]}} + :devtools {:after-load reagent-test.core/mount-root}} + + :tests {:target :node-test + :output-to "tests-out/tests.js" + :output-dir "tests-out/output" + :modules {:app {:entries [reagent-test.core-test + reagent-test.ncbi-test]}} + :autorun true}} + + :dev-http {3000 {:root "public"}}} diff --git a/reagent-test/src/reagent_test/core.cljs b/reagent-test/src/reagent_test/core.cljs new file mode 100644 index 0000000..a8696c2 --- /dev/null +++ b/reagent-test/src/reagent_test/core.cljs @@ -0,0 +1,53 @@ +(ns reagent-test.core + (:require + [reagent.core :as r] + [reagent.dom :as d] + [reagent-test.ncbi :refer [ncbi-search]])) + +;; ------------------------- +;; 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")} + {:text "help" :action #(js/console.log "test4")}]) + +;; ------------------------- +;; Menus + +(defn dropdown-or-action + "Render dropdown menu for an action button/menu" + [btn-item is-dropdown] + [:button {:class (if is-dropdown "menu-button" "")} + :text (:text btn-item) + :on-click (let [action (:action btn-item)] + (if (nil? action) + #(dropdown-or-action btn-item true) + action))]) + +;; ------------------------- +;; Views + +(defn home-page [] + [:div + [:h2 "Reagent Playground"] + [:p "A groundbreaking, revolutionary app that does stuff."] + [:div {:class "button-container"} + (map (fn [btn] [:button + {:on-click #(dropdown-or-action btn false)} + (:text btn)]) action-btns)]]) + +;; ------------------------- +;; Initialize app + +(defn mount-root [] + (d/render [home-page] (.getElementById js/document "app"))) + +(defn ^:export init! [] + (mount-root)) diff --git a/reagent-test/src/reagent_test/core_test.cljs b/reagent-test/src/reagent_test/core_test.cljs new file mode 100644 index 0000000..d0a4085 --- /dev/null +++ b/reagent-test/src/reagent_test/core_test.cljs @@ -0,0 +1,5 @@ +;; (ns reagent-test.core-test +;; (:require [reagent-test.core] +;; [cljs.test :refer (deftest is)])) + +;; (deftest ) diff --git a/reagent-test/src/reagent_test/ncbi.cljs b/reagent-test/src/reagent_test/ncbi.cljs new file mode 100644 index 0000000..2ef9b06 --- /dev/null +++ b/reagent-test/src/reagent_test/ncbi.cljs @@ -0,0 +1,16 @@ +(ns reagent-test.ncbi + (:require [clojure.core.async :refer [take!]] + [goog.string :as gstring] + [goog.string.format])) + +(defn ncbi-search + "Send search query to NCBI database. + [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))) diff --git a/reagent-test/src/reagent_test/ncbi_test.cljs b/reagent-test/src/reagent_test/ncbi_test.cljs new file mode 100644 index 0000000..a7350bf --- /dev/null +++ b/reagent-test/src/reagent_test/ncbi_test.cljs @@ -0,0 +1,10 @@ +(ns reagent-test.ncbi-test + (:require [cljs.test :refer [deftest is async?]] + [clojure.core.async :refer [