From 66e7a3c0b4c3e299b6db8a4e5f36ab358aa12504 Mon Sep 17 00:00:00 2001 From: Jeffrey Wong Date: Tue, 7 Feb 2023 13:49:21 -0500 Subject: [PATCH 01/43] Use version 16 LTS --- .nvmrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.nvmrc b/.nvmrc index f599e28b8..b6a7d89c6 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -10 +16 From 69ef230a199bd7c31c78246f703d4829aeec410e Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Tue, 7 Feb 2023 15:53:59 -0500 Subject: [PATCH 02/43] Feb 7th: Ran "npm install --save neo4j-driver" hence the changes to package-lock.json and package.json Added code to starting-neo4j.js but it doesn't seem to be doing anything as of yet --- package-lock.json | 645 ++++++++++-------------- package.json | 1 + src/client/components/starting-neo4j.js | 73 +++ 3 files changed, 340 insertions(+), 379 deletions(-) diff --git a/package-lock.json b/package-lock.json index ea9415508..14dd77dfd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -47,6 +47,7 @@ "minisearch": "^3.0.2", "morgan": "^1.9.1", "mousetrap": "^1.6.1", + "neo4j-driver": "^5.5.0", "node-cache": "^5.1.2", "node-cron": "^2.0.3", "node-fetch": "^2.6.7", @@ -1477,12 +1478,6 @@ "browserslist": "cli.js" } }, - "node_modules/babel-preset-env/node_modules/caniuse-lite": { - "version": "1.0.30000889", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000889.tgz", - "integrity": "sha512-MFxcQ6x/LEEoaIhO7Zdb7Eg8YyNONN+WBnS5ERJ0li2yRw51+i4xXUNxnLaveTb/4ZoJqsWKEmlomhG2pYzlQA==", - "dev": true - }, "node_modules/babel-preset-env/node_modules/electron-to-chromium": { "version": "1.3.73", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.73.tgz", @@ -1660,9 +1655,23 @@ } }, "node_modules/base64-js": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", - "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==" + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] }, "node_modules/base64-stream": { "version": "0.1.5", @@ -2391,10 +2400,20 @@ "dev": true }, "node_modules/caniuse-lite": { - "version": "1.0.30000792", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000792.tgz", - "integrity": "sha1-0M6pgfgRjzlhRxr7tDyaHlu/AzI=", - "dev": true + "version": "1.0.30001450", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001450.tgz", + "integrity": "sha512-qMBmvmQmFXaSxexkjjfMvD5rnDL0+m+dUMZKoDYsGG8iZN29RuYh9eRoMvKsT6uMAWlyUUGDEQGJJYjzCIO9ew==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + } + ] }, "node_modules/capture-stack-trace": { "version": "1.0.1", @@ -5345,34 +5364,26 @@ }, "node_modules/fsevents/node_modules/abbrev": { "version": "1.1.1", - "dev": true, "inBundle": true, - "license": "ISC", - "optional": true + "license": "ISC" }, "node_modules/fsevents/node_modules/ansi-regex": { "version": "2.1.1", - "dev": true, "inBundle": true, "license": "MIT", - "optional": true, "engines": { "node": ">=0.10.0" } }, "node_modules/fsevents/node_modules/aproba": { "version": "1.2.0", - "dev": true, "inBundle": true, - "license": "ISC", - "optional": true + "license": "ISC" }, "node_modules/fsevents/node_modules/are-we-there-yet": { "version": "1.1.5", - "dev": true, "inBundle": true, "license": "ISC", - "optional": true, "dependencies": { "delegates": "^1.0.0", "readable-stream": "^2.0.6" @@ -5380,17 +5391,13 @@ }, "node_modules/fsevents/node_modules/balanced-match": { "version": "1.0.0", - "dev": true, "inBundle": true, - "license": "MIT", - "optional": true + "license": "MIT" }, "node_modules/fsevents/node_modules/brace-expansion": { "version": "1.1.11", - "dev": true, "inBundle": true, "license": "MIT", - "optional": true, "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -5398,75 +5405,57 @@ }, "node_modules/fsevents/node_modules/chownr": { "version": "1.1.3", - "dev": true, "inBundle": true, - "license": "ISC", - "optional": true + "license": "ISC" }, "node_modules/fsevents/node_modules/code-point-at": { "version": "1.1.0", - "dev": true, "inBundle": true, "license": "MIT", - "optional": true, "engines": { "node": ">=0.10.0" } }, "node_modules/fsevents/node_modules/concat-map": { "version": "0.0.1", - "dev": true, "inBundle": true, - "license": "MIT", - "optional": true + "license": "MIT" }, "node_modules/fsevents/node_modules/console-control-strings": { "version": "1.1.0", - "dev": true, "inBundle": true, - "license": "ISC", - "optional": true + "license": "ISC" }, "node_modules/fsevents/node_modules/core-util-is": { "version": "1.0.2", - "dev": true, "inBundle": true, - "license": "MIT", - "optional": true + "license": "MIT" }, "node_modules/fsevents/node_modules/debug": { "version": "3.2.6", - "dev": true, "inBundle": true, "license": "MIT", - "optional": true, "dependencies": { "ms": "^2.1.1" } }, "node_modules/fsevents/node_modules/deep-extend": { "version": "0.6.0", - "dev": true, "inBundle": true, "license": "MIT", - "optional": true, "engines": { "node": ">=4.0.0" } }, "node_modules/fsevents/node_modules/delegates": { "version": "1.0.0", - "dev": true, "inBundle": true, - "license": "MIT", - "optional": true + "license": "MIT" }, "node_modules/fsevents/node_modules/detect-libc": { "version": "1.0.3", - "dev": true, "inBundle": true, "license": "Apache-2.0", - "optional": true, "bin": { "detect-libc": "bin/detect-libc.js" }, @@ -5476,27 +5465,21 @@ }, "node_modules/fsevents/node_modules/fs-minipass": { "version": "1.2.7", - "dev": true, "inBundle": true, "license": "ISC", - "optional": true, "dependencies": { "minipass": "^2.6.0" } }, "node_modules/fsevents/node_modules/fs.realpath": { "version": "1.0.0", - "dev": true, "inBundle": true, - "license": "ISC", - "optional": true + "license": "ISC" }, "node_modules/fsevents/node_modules/gauge": { "version": "2.7.4", - "dev": true, "inBundle": true, "license": "ISC", - "optional": true, "dependencies": { "aproba": "^1.0.3", "console-control-strings": "^1.0.0", @@ -5510,10 +5493,8 @@ }, "node_modules/fsevents/node_modules/glob": { "version": "7.1.6", - "dev": true, "inBundle": true, "license": "ISC", - "optional": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -5531,17 +5512,13 @@ }, "node_modules/fsevents/node_modules/has-unicode": { "version": "2.0.1", - "dev": true, "inBundle": true, - "license": "ISC", - "optional": true + "license": "ISC" }, "node_modules/fsevents/node_modules/iconv-lite": { "version": "0.4.24", - "dev": true, "inBundle": true, "license": "MIT", - "optional": true, "dependencies": { "safer-buffer": ">= 2.1.2 < 3" }, @@ -5551,20 +5528,16 @@ }, "node_modules/fsevents/node_modules/ignore-walk": { "version": "3.0.3", - "dev": true, "inBundle": true, "license": "ISC", - "optional": true, "dependencies": { "minimatch": "^3.0.4" } }, "node_modules/fsevents/node_modules/inflight": { "version": "1.0.6", - "dev": true, "inBundle": true, "license": "ISC", - "optional": true, "dependencies": { "once": "^1.3.0", "wrappy": "1" @@ -5572,27 +5545,21 @@ }, "node_modules/fsevents/node_modules/inherits": { "version": "2.0.4", - "dev": true, "inBundle": true, - "license": "ISC", - "optional": true + "license": "ISC" }, "node_modules/fsevents/node_modules/ini": { "version": "1.3.5", - "dev": true, "inBundle": true, "license": "ISC", - "optional": true, "engines": { "node": "*" } }, "node_modules/fsevents/node_modules/is-fullwidth-code-point": { "version": "1.0.0", - "dev": true, "inBundle": true, "license": "MIT", - "optional": true, "dependencies": { "number-is-nan": "^1.0.0" }, @@ -5602,17 +5569,13 @@ }, "node_modules/fsevents/node_modules/isarray": { "version": "1.0.0", - "dev": true, "inBundle": true, - "license": "MIT", - "optional": true + "license": "MIT" }, "node_modules/fsevents/node_modules/minimatch": { "version": "3.0.4", - "dev": true, "inBundle": true, "license": "ISC", - "optional": true, "dependencies": { "brace-expansion": "^1.1.7" }, @@ -5622,17 +5585,13 @@ }, "node_modules/fsevents/node_modules/minimist": { "version": "0.0.8", - "dev": true, "inBundle": true, - "license": "MIT", - "optional": true + "license": "MIT" }, "node_modules/fsevents/node_modules/minipass": { "version": "2.9.0", - "dev": true, "inBundle": true, "license": "ISC", - "optional": true, "dependencies": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -5640,20 +5599,16 @@ }, "node_modules/fsevents/node_modules/minizlib": { "version": "1.3.3", - "dev": true, "inBundle": true, "license": "MIT", - "optional": true, "dependencies": { "minipass": "^2.9.0" } }, "node_modules/fsevents/node_modules/mkdirp": { "version": "0.5.1", - "dev": true, "inBundle": true, "license": "MIT", - "optional": true, "dependencies": { "minimist": "0.0.8" }, @@ -5663,10 +5618,8 @@ }, "node_modules/fsevents/node_modules/ms": { "version": "2.1.2", - "dev": true, "inBundle": true, - "license": "MIT", - "optional": true + "license": "MIT" }, "node_modules/fsevents/node_modules/nan": { "version": "2.14.0", @@ -5677,10 +5630,8 @@ }, "node_modules/fsevents/node_modules/needle": { "version": "2.4.0", - "dev": true, "inBundle": true, "license": "MIT", - "optional": true, "dependencies": { "debug": "^3.2.6", "iconv-lite": "^0.4.4", @@ -5695,10 +5646,8 @@ }, "node_modules/fsevents/node_modules/node-pre-gyp": { "version": "0.14.0", - "dev": true, "inBundle": true, "license": "BSD-3-Clause", - "optional": true, "dependencies": { "detect-libc": "^1.0.2", "mkdirp": "^0.5.1", @@ -5717,10 +5666,8 @@ }, "node_modules/fsevents/node_modules/nopt": { "version": "4.0.1", - "dev": true, "inBundle": true, "license": "ISC", - "optional": true, "dependencies": { "abbrev": "1", "osenv": "^0.1.4" @@ -5731,27 +5678,21 @@ }, "node_modules/fsevents/node_modules/npm-bundled": { "version": "1.1.1", - "dev": true, "inBundle": true, "license": "ISC", - "optional": true, "dependencies": { "npm-normalize-package-bin": "^1.0.1" } }, "node_modules/fsevents/node_modules/npm-normalize-package-bin": { "version": "1.0.1", - "dev": true, "inBundle": true, - "license": "ISC", - "optional": true + "license": "ISC" }, "node_modules/fsevents/node_modules/npm-packlist": { "version": "1.4.7", - "dev": true, "inBundle": true, "license": "ISC", - "optional": true, "dependencies": { "ignore-walk": "^3.0.1", "npm-bundled": "^1.0.1" @@ -5759,10 +5700,8 @@ }, "node_modules/fsevents/node_modules/npmlog": { "version": "4.1.2", - "dev": true, "inBundle": true, "license": "ISC", - "optional": true, "dependencies": { "are-we-there-yet": "~1.1.2", "console-control-strings": "~1.1.0", @@ -5772,60 +5711,48 @@ }, "node_modules/fsevents/node_modules/number-is-nan": { "version": "1.0.1", - "dev": true, "inBundle": true, "license": "MIT", - "optional": true, "engines": { "node": ">=0.10.0" } }, "node_modules/fsevents/node_modules/object-assign": { "version": "4.1.1", - "dev": true, "inBundle": true, "license": "MIT", - "optional": true, "engines": { "node": ">=0.10.0" } }, "node_modules/fsevents/node_modules/once": { "version": "1.4.0", - "dev": true, "inBundle": true, "license": "ISC", - "optional": true, "dependencies": { "wrappy": "1" } }, "node_modules/fsevents/node_modules/os-homedir": { "version": "1.0.2", - "dev": true, "inBundle": true, "license": "MIT", - "optional": true, "engines": { "node": ">=0.10.0" } }, "node_modules/fsevents/node_modules/os-tmpdir": { "version": "1.0.2", - "dev": true, "inBundle": true, "license": "MIT", - "optional": true, "engines": { "node": ">=0.10.0" } }, "node_modules/fsevents/node_modules/osenv": { "version": "0.1.5", - "dev": true, "inBundle": true, "license": "ISC", - "optional": true, "dependencies": { "os-homedir": "^1.0.0", "os-tmpdir": "^1.0.0" @@ -5833,27 +5760,21 @@ }, "node_modules/fsevents/node_modules/path-is-absolute": { "version": "1.0.1", - "dev": true, "inBundle": true, "license": "MIT", - "optional": true, "engines": { "node": ">=0.10.0" } }, "node_modules/fsevents/node_modules/process-nextick-args": { "version": "2.0.1", - "dev": true, "inBundle": true, - "license": "MIT", - "optional": true + "license": "MIT" }, "node_modules/fsevents/node_modules/rc": { "version": "1.2.8", - "dev": true, "inBundle": true, "license": "(BSD-2-Clause OR MIT OR Apache-2.0)", - "optional": true, "dependencies": { "deep-extend": "^0.6.0", "ini": "~1.3.0", @@ -5866,17 +5787,13 @@ }, "node_modules/fsevents/node_modules/rc/node_modules/minimist": { "version": "1.2.0", - "dev": true, "inBundle": true, - "license": "MIT", - "optional": true + "license": "MIT" }, "node_modules/fsevents/node_modules/readable-stream": { "version": "2.3.6", - "dev": true, "inBundle": true, "license": "MIT", - "optional": true, "dependencies": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", @@ -5889,10 +5806,8 @@ }, "node_modules/fsevents/node_modules/rimraf": { "version": "2.7.1", - "dev": true, "inBundle": true, "license": "ISC", - "optional": true, "dependencies": { "glob": "^7.1.3" }, @@ -5902,65 +5817,49 @@ }, "node_modules/fsevents/node_modules/safe-buffer": { "version": "5.1.2", - "dev": true, "inBundle": true, - "license": "MIT", - "optional": true + "license": "MIT" }, "node_modules/fsevents/node_modules/safer-buffer": { "version": "2.1.2", - "dev": true, "inBundle": true, - "license": "MIT", - "optional": true + "license": "MIT" }, "node_modules/fsevents/node_modules/sax": { "version": "1.2.4", - "dev": true, "inBundle": true, - "license": "ISC", - "optional": true + "license": "ISC" }, "node_modules/fsevents/node_modules/semver": { "version": "5.7.1", - "dev": true, "inBundle": true, "license": "ISC", - "optional": true, "bin": { "semver": "bin/semver" } }, "node_modules/fsevents/node_modules/set-blocking": { "version": "2.0.0", - "dev": true, "inBundle": true, - "license": "ISC", - "optional": true + "license": "ISC" }, "node_modules/fsevents/node_modules/signal-exit": { "version": "3.0.2", - "dev": true, "inBundle": true, - "license": "ISC", - "optional": true + "license": "ISC" }, "node_modules/fsevents/node_modules/string_decoder": { "version": "1.1.1", - "dev": true, "inBundle": true, "license": "MIT", - "optional": true, "dependencies": { "safe-buffer": "~5.1.0" } }, "node_modules/fsevents/node_modules/string-width": { "version": "1.0.2", - "dev": true, "inBundle": true, "license": "MIT", - "optional": true, "dependencies": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -5972,10 +5871,8 @@ }, "node_modules/fsevents/node_modules/strip-ansi": { "version": "3.0.1", - "dev": true, "inBundle": true, "license": "MIT", - "optional": true, "dependencies": { "ansi-regex": "^2.0.0" }, @@ -5985,20 +5882,16 @@ }, "node_modules/fsevents/node_modules/strip-json-comments": { "version": "2.0.1", - "dev": true, "inBundle": true, "license": "MIT", - "optional": true, "engines": { "node": ">=0.10.0" } }, "node_modules/fsevents/node_modules/tar": { "version": "4.4.13", - "dev": true, "inBundle": true, "license": "ISC", - "optional": true, "dependencies": { "chownr": "^1.1.1", "fs-minipass": "^1.2.5", @@ -6014,34 +5907,26 @@ }, "node_modules/fsevents/node_modules/util-deprecate": { "version": "1.0.2", - "dev": true, "inBundle": true, - "license": "MIT", - "optional": true + "license": "MIT" }, "node_modules/fsevents/node_modules/wide-align": { "version": "1.1.3", - "dev": true, "inBundle": true, "license": "ISC", - "optional": true, "dependencies": { "string-width": "^1.0.2 || 2" } }, "node_modules/fsevents/node_modules/wrappy": { "version": "1.0.2", - "dev": true, "inBundle": true, - "license": "ISC", - "optional": true + "license": "ISC" }, "node_modules/fsevents/node_modules/yallist": { "version": "3.1.1", - "dev": true, "inBundle": true, - "license": "ISC", - "optional": true + "license": "ISC" }, "node_modules/function-bind": { "version": "1.1.1", @@ -6735,9 +6620,23 @@ } }, "node_modules/ieee754": { - "version": "1.1.13", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", - "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] }, "node_modules/ignore": { "version": "3.3.7", @@ -9320,6 +9219,81 @@ "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz", "integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==" }, + "node_modules/neo4j-driver": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/neo4j-driver/-/neo4j-driver-5.5.0.tgz", + "integrity": "sha512-wxUMmvXKEZIoUxn9lw73ptu4sZDF8Vc75yppA/cGm3nipUJnTsMMtKWBGxLAi9D6sOqBNLnXIfWrnzhdN7cl6Q==", + "dependencies": { + "neo4j-driver-bolt-connection": "^5.5.0", + "neo4j-driver-core": "^5.5.0", + "rxjs": "^7.8.0" + } + }, + "node_modules/neo4j-driver-bolt-connection": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/neo4j-driver-bolt-connection/-/neo4j-driver-bolt-connection-5.5.0.tgz", + "integrity": "sha512-n80fyvDTq9NMLXLNnaS7ppvtHhtJqmmoZFuyDtIK4GKs8DvqqtmZ110a3ab+Z9/ElFg8XU4HXFu7UNEiBuUCag==", + "dependencies": { + "buffer": "^6.0.3", + "neo4j-driver-core": "^5.5.0", + "string_decoder": "^1.3.0" + } + }, + "node_modules/neo4j-driver-bolt-connection/node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/neo4j-driver-bolt-connection/node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/neo4j-driver-bolt-connection/node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/neo4j-driver-core": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/neo4j-driver-core/-/neo4j-driver-core-5.5.0.tgz", + "integrity": "sha512-SXuzSxKAvGzb2drvk0T4I54D0hlIVLMdUUMnxqshjt/nLhIpXIry4++0g5jKkg3SVf+gzvD8buOIMAElWLAjoQ==" + }, "node_modules/next-tick": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", @@ -11932,12 +11906,6 @@ "lodash.uniq": "^4.5.0" } }, - "node_modules/postcss-cssnext/node_modules/caniuse-lite": { - "version": "1.0.30000885", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000885.tgz", - "integrity": "sha512-cXKbYwpxBLd7qHyej16JazPoUacqoVuDhvR61U7Fr5vSxMUiodzcYa1rQYRYfZ5GexV03vGZHd722vNPLjPJGQ==", - "dev": true - }, "node_modules/postcss-cssnext/node_modules/chalk": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", @@ -14509,6 +14477,14 @@ "rx-lite": "*" } }, + "node_modules/rxjs": { + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.0.tgz", + "integrity": "sha512-F2+gxDshqmIub1KdvZkaEfGDwLNpPvk9Fs6LD/MyQxNgMds/WH9OdDDXOmxUZpME+iSK3rQCctkL0DYyytUqMg==", + "dependencies": { + "tslib": "^2.1.0" + } + }, "node_modules/safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", @@ -16647,9 +16623,9 @@ "dev": true }, "node_modules/tslib": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.0.tgz", - "integrity": "sha512-lTqkx847PI7xEDYJntxZH89L2/aXInsyF2luSafe/+0fHOMjlBNXdH6th7f70qxLDhul7KZK0zC8V5ZIyHl0/g==" + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==" }, "node_modules/tty-browserify": { "version": "0.0.0", @@ -20347,12 +20323,6 @@ "electron-to-chromium": "^1.3.47" } }, - "caniuse-lite": { - "version": "1.0.30000889", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000889.tgz", - "integrity": "sha512-MFxcQ6x/LEEoaIhO7Zdb7Eg8YyNONN+WBnS5ERJ0li2yRw51+i4xXUNxnLaveTb/4ZoJqsWKEmlomhG2pYzlQA==", - "dev": true - }, "electron-to-chromium": { "version": "1.3.73", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.73.tgz", @@ -20524,9 +20494,9 @@ "integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg=" }, "base64-js": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", - "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==" + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" }, "base64-stream": { "version": "0.1.5", @@ -21163,9 +21133,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30000792", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000792.tgz", - "integrity": "sha1-0M6pgfgRjzlhRxr7tDyaHlu/AzI=", + "version": "1.0.30001450", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001450.tgz", + "integrity": "sha512-qMBmvmQmFXaSxexkjjfMvD5rnDL0+m+dUMZKoDYsGG8iZN29RuYh9eRoMvKsT6uMAWlyUUGDEQGJJYjzCIO9ew==", "dev": true }, "capture-stack-trace": { @@ -23602,27 +23572,19 @@ "dependencies": { "abbrev": { "version": "1.1.1", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "ansi-regex": { "version": "2.1.1", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "aproba": { "version": "1.2.0", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "are-we-there-yet": { "version": "1.1.5", "bundled": true, - "dev": true, - "optional": true, "requires": { "delegates": "^1.0.0", "readable-stream": "^2.0.6" @@ -23630,15 +23592,11 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, - "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -23646,81 +23604,57 @@ }, "chownr": { "version": "1.1.3", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "code-point-at": { "version": "1.1.0", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "concat-map": { "version": "0.0.1", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "core-util-is": { "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "debug": { "version": "3.2.6", "bundled": true, - "dev": true, - "optional": true, "requires": { "ms": "^2.1.1" } }, "deep-extend": { "version": "0.6.0", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "delegates": { "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "detect-libc": { "version": "1.0.3", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "fs-minipass": { "version": "1.2.7", "bundled": true, - "dev": true, - "optional": true, "requires": { "minipass": "^2.6.0" } }, "fs.realpath": { "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "gauge": { "version": "2.7.4", "bundled": true, - "dev": true, - "optional": true, "requires": { "aproba": "^1.0.3", "console-control-strings": "^1.0.0", @@ -23735,8 +23669,6 @@ "glob": { "version": "7.1.6", "bundled": true, - "dev": true, - "optional": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -23748,15 +23680,11 @@ }, "has-unicode": { "version": "2.0.1", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "iconv-lite": { "version": "0.4.24", "bundled": true, - "dev": true, - "optional": true, "requires": { "safer-buffer": ">= 2.1.2 < 3" } @@ -23764,8 +23692,6 @@ "ignore-walk": { "version": "3.0.3", "bundled": true, - "dev": true, - "optional": true, "requires": { "minimatch": "^3.0.4" } @@ -23773,8 +23699,6 @@ "inflight": { "version": "1.0.6", "bundled": true, - "dev": true, - "optional": true, "requires": { "once": "^1.3.0", "wrappy": "1" @@ -23782,51 +23706,37 @@ }, "inherits": { "version": "2.0.4", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "ini": { "version": "1.3.5", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } }, "isarray": { "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "minimatch": { "version": "3.0.4", "bundled": true, - "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "minipass": { "version": "2.9.0", "bundled": true, - "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -23835,8 +23745,6 @@ "minizlib": { "version": "1.3.3", "bundled": true, - "dev": true, - "optional": true, "requires": { "minipass": "^2.9.0" } @@ -23844,17 +23752,13 @@ "mkdirp": { "version": "0.5.1", "bundled": true, - "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } }, "ms": { "version": "2.1.2", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "nan": { "version": "2.14.0", @@ -23866,8 +23770,6 @@ "needle": { "version": "2.4.0", "bundled": true, - "dev": true, - "optional": true, "requires": { "debug": "^3.2.6", "iconv-lite": "^0.4.4", @@ -23877,8 +23779,6 @@ "node-pre-gyp": { "version": "0.14.0", "bundled": true, - "dev": true, - "optional": true, "requires": { "detect-libc": "^1.0.2", "mkdirp": "^0.5.1", @@ -23895,8 +23795,6 @@ "nopt": { "version": "4.0.1", "bundled": true, - "dev": true, - "optional": true, "requires": { "abbrev": "1", "osenv": "^0.1.4" @@ -23905,23 +23803,17 @@ "npm-bundled": { "version": "1.1.1", "bundled": true, - "dev": true, - "optional": true, "requires": { "npm-normalize-package-bin": "^1.0.1" } }, "npm-normalize-package-bin": { "version": "1.0.1", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "npm-packlist": { "version": "1.4.7", "bundled": true, - "dev": true, - "optional": true, "requires": { "ignore-walk": "^3.0.1", "npm-bundled": "^1.0.1" @@ -23930,8 +23822,6 @@ "npmlog": { "version": "4.1.2", "bundled": true, - "dev": true, - "optional": true, "requires": { "are-we-there-yet": "~1.1.2", "console-control-strings": "~1.1.0", @@ -23941,42 +23831,30 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "object-assign": { "version": "4.1.1", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "once": { "version": "1.4.0", "bundled": true, - "dev": true, - "optional": true, "requires": { "wrappy": "1" } }, "os-homedir": { "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "os-tmpdir": { "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "osenv": { "version": "0.1.5", "bundled": true, - "dev": true, - "optional": true, "requires": { "os-homedir": "^1.0.0", "os-tmpdir": "^1.0.0" @@ -23984,21 +23862,15 @@ }, "path-is-absolute": { "version": "1.0.1", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "process-nextick-args": { "version": "2.0.1", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "rc": { "version": "1.2.8", "bundled": true, - "dev": true, - "optional": true, "requires": { "deep-extend": "^0.6.0", "ini": "~1.3.0", @@ -24008,17 +23880,13 @@ "dependencies": { "minimist": { "version": "1.2.0", - "bundled": true, - "dev": true, - "optional": true + "bundled": true } } }, "readable-stream": { "version": "2.3.6", "bundled": true, - "dev": true, - "optional": true, "requires": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", @@ -24032,53 +23900,37 @@ "rimraf": { "version": "2.7.1", "bundled": true, - "dev": true, - "optional": true, "requires": { "glob": "^7.1.3" } }, "safe-buffer": { "version": "5.1.2", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "safer-buffer": { "version": "2.1.2", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "sax": { "version": "1.2.4", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "semver": { "version": "5.7.1", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "set-blocking": { "version": "2.0.0", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "signal-exit": { "version": "3.0.2", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "string_decoder": { "version": "1.1.1", "bundled": true, - "dev": true, - "optional": true, "requires": { "safe-buffer": "~5.1.0" } @@ -24086,8 +23938,6 @@ "string-width": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -24097,23 +23947,17 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, - "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } }, "strip-json-comments": { "version": "2.0.1", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "tar": { "version": "4.4.13", "bundled": true, - "dev": true, - "optional": true, "requires": { "chownr": "^1.1.1", "fs-minipass": "^1.2.5", @@ -24126,30 +23970,22 @@ }, "util-deprecate": { "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "wide-align": { "version": "1.1.3", "bundled": true, - "dev": true, - "optional": true, "requires": { "string-width": "^1.0.2 || 2" } }, "wrappy": { "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "yallist": { "version": "3.1.1", - "bundled": true, - "dev": true, - "optional": true + "bundled": true } } }, @@ -24726,9 +24562,9 @@ "integrity": "sha1-90aPYBNfXl2tM5nAqBvpoWA6CCs=" }, "ieee754": { - "version": "1.1.13", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", - "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" }, "ignore": { "version": "3.3.7", @@ -26856,6 +26692,55 @@ "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz", "integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==" }, + "neo4j-driver": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/neo4j-driver/-/neo4j-driver-5.5.0.tgz", + "integrity": "sha512-wxUMmvXKEZIoUxn9lw73ptu4sZDF8Vc75yppA/cGm3nipUJnTsMMtKWBGxLAi9D6sOqBNLnXIfWrnzhdN7cl6Q==", + "requires": { + "neo4j-driver-bolt-connection": "^5.5.0", + "neo4j-driver-core": "^5.5.0", + "rxjs": "^7.8.0" + } + }, + "neo4j-driver-bolt-connection": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/neo4j-driver-bolt-connection/-/neo4j-driver-bolt-connection-5.5.0.tgz", + "integrity": "sha512-n80fyvDTq9NMLXLNnaS7ppvtHhtJqmmoZFuyDtIK4GKs8DvqqtmZ110a3ab+Z9/ElFg8XU4HXFu7UNEiBuUCag==", + "requires": { + "buffer": "^6.0.3", + "neo4j-driver-core": "^5.5.0", + "string_decoder": "^1.3.0" + }, + "dependencies": { + "buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + }, + "string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "requires": { + "safe-buffer": "~5.2.0" + } + } + } + }, + "neo4j-driver-core": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/neo4j-driver-core/-/neo4j-driver-core-5.5.0.tgz", + "integrity": "sha512-SXuzSxKAvGzb2drvk0T4I54D0hlIVLMdUUMnxqshjt/nLhIpXIry4++0g5jKkg3SVf+gzvD8buOIMAElWLAjoQ==" + }, "next-tick": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", @@ -29033,12 +28918,6 @@ "lodash.uniq": "^4.5.0" } }, - "caniuse-lite": { - "version": "1.0.30000885", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000885.tgz", - "integrity": "sha512-cXKbYwpxBLd7qHyej16JazPoUacqoVuDhvR61U7Fr5vSxMUiodzcYa1rQYRYfZ5GexV03vGZHd722vNPLjPJGQ==", - "dev": true - }, "chalk": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", @@ -31225,6 +31104,14 @@ "rx-lite": "*" } }, + "rxjs": { + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.0.tgz", + "integrity": "sha512-F2+gxDshqmIub1KdvZkaEfGDwLNpPvk9Fs6LD/MyQxNgMds/WH9OdDDXOmxUZpME+iSK3rQCctkL0DYyytUqMg==", + "requires": { + "tslib": "^2.1.0" + } + }, "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", @@ -33022,9 +32909,9 @@ "dev": true }, "tslib": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.0.tgz", - "integrity": "sha512-lTqkx847PI7xEDYJntxZH89L2/aXInsyF2luSafe/+0fHOMjlBNXdH6th7f70qxLDhul7KZK0zC8V5ZIyHl0/g==" + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==" }, "tty-browserify": { "version": "0.0.0", diff --git a/package.json b/package.json index 6d533b271..c97265398 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,7 @@ "minisearch": "^3.0.2", "morgan": "^1.9.1", "mousetrap": "^1.6.1", + "neo4j-driver": "^5.5.0", "node-cache": "^5.1.2", "node-cron": "^2.0.3", "node-fetch": "^2.6.7", diff --git a/src/client/components/starting-neo4j.js b/src/client/components/starting-neo4j.js index 8b622ee88..4671429fc 100644 --- a/src/client/components/starting-neo4j.js +++ b/src/client/components/starting-neo4j.js @@ -26,3 +26,76 @@ async function getAllDocs() {// eslint-disable-line no-unused-vars const docJSONs = await res.json(); return await toDocs(docJSONs, this.docSocket, this.eleSocket); } + +const neo4j = require('neo4j-driver'); +const driver = neo4j.driver('neo4j+s://784b1fe44e530692a44bee70af1f243c.neo4jsandbox.com:7687', neo4j.auth.basic('neo4j', 'metals-wires-alarms')); // free sandbox. temporary + +const makeNodeQuery = 'MERGE (gene:Gene {id: $id}) \n' ++ 'ON CREATE SET gene.factoidId = $factoidId, \n' ++ 'gene.name = $name, \n' ++ 'gene.type = $type, \n' ++ 'gene.dbId = $dbId, \n' ++ 'gene.dbName = $dbName)'; + +// Format of nodeData are as follows: +// { id: 'element.association.dbPrefix'+ ':' + 'element.association.id', factoidId: 'element.id', +// name: 'element.name', type: 'element.type', dbId: 'element.association.id', +// dbName: "element.association.dbName"} +const nodeData = [ + // MAPK6 data + { id: 'ncbigene:5597', factoidId: '598f8bef-f858-4dd0-b1c6-5168a8ae5349', name: 'MAPK6', + type: 'protein', dbId: '5597', dbName: 'NCBI Gene'}, + // AKT data + { id: 'ncbigene:207', factoidId: '4081348e-20b8-4bf8-836f-695827a4f9a2', name: 'AKT', + type: 'protein', dbId: '207', dbName: 'NCBI Gene'} +]; + +const makeRelationshipQuery = 'MATCH (x:Gene {id: $id1}) \n' ++ 'MATCH (y:Gene {id: $id2}) \n' ++ 'WHERE (element.id = $id3) \n' ++ 'MERGE (x)-[r:INTERACTION {id: $id3}]->(y) \n' ++ 'ON CREATE SET r.type = $type, \n' ++ 'r.createdDate = $createdDate, \n' ++ 'r.lastEditedDate = $lastEditedDate, \n' ++ 'r.abstract = $abstract, \n' ++ 'r.text = $text, \n' ++ 'r.doi = $doi, \n' ++ 'r.pmid = $pmid, \n' ++ 'r.ISODate = $ISODate, \n' ++ 'r.authors = $abbreviation, \n' ++ 'r.documentId = $documentId \n' ++ 'r.title = $title'; + +// Parameters of edgeData are as follows: +// { id1: 'element.association.dbPrefix'+ ':' + 'element.association.id', +// id2: 'element.association.dbPrefix'+ ':' + 'element.association.id', id3: 'element.id', +// type: 'element.type', createdDate: 'value.createdDate', +// lastEditedDate: 'value.lastEditedDate', abstract: 'value.citation.abstract', +// text: 'value.text', doi: 'value.citation.doi', +// pmid: 'value.citation.pmid', ISODate: 'value.citation.ISODate', +// abbreviation: 'value.citation.authors.abbreviation', documentId: 'value.id', title: 'value.citation.title'} +const edgeData = [{ id1: 'ncbigene:5597', id2: 'ncbigene:207', id3: '01ef22cc-2a8e-46d4-9060-6bf1c273869b', +type: 'phosphorylation', createdDate: '2022-12-14T21:16:57.000Z', lastEditedDate: '2022-12-15T14:41:51.000Z', +abstract: 'PLACEHOLDER TEXT', text: 'MAPK6 activates AKT via phosphorylation.', +doi: '10.1126/sciadv.abi6439', pmid: '34767444', ISODate: '2021-11-12T00:00:00.000Z', +abbreviation: 'Qinbo Cai, Wolong Zhou, Wei Wang, ..., Feng Yang', documentId: 'a896d611-affe-4b45-a5e1-9bc560ffceab', +title: 'MAPK6-AKT signaling promotes tumor growth and resistance to mTOR kinase blockade.'}]; + +const session = driver.session(); +session +.beginTransaction() +.then(transaction => { + transaction.run(makeNodeQuery, nodeData) // Step 1: Make the nodes + .then(result1 => { + console.log("Nodes created:", result1.summary.counters.nodesCreated); + return transaction.run (makeRelationshipQuery, edgeData); // Step 2: Make the relationship + }) + .then (result2 => { + console.log(result2.records.map(record => record.get("type"))); + return transaction.commit(); + }) + .then (() => { + session.close(); + driver.close(); + }); +}); \ No newline at end of file From 331c1cd77c0ad02d7c04eab3ed326bbcca1645df Mon Sep 17 00:00:00 2001 From: Jeffrey Wong Date: Tue, 7 Feb 2023 16:00:29 -0500 Subject: [PATCH 03/43] Bump node version. --- .nvmrc | 2 +- package-lock.json | 50 +++++++++++++++++------------------------------ package.json | 2 +- 3 files changed, 20 insertions(+), 34 deletions(-) diff --git a/.nvmrc b/.nvmrc index b6a7d89c6..e65243f2e 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -16 +16.19.0 diff --git a/package-lock.json b/package-lock.json index 5e0916779..8bffa01ee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -111,7 +111,7 @@ "webpack-bundle-analyzer": "^2.9.2" }, "engines": { - "node": ">=10.0.0" + "node": ">=16.19.0" } }, "node_modules/@apidevtools/json-schema-ref-parser": { @@ -1477,12 +1477,6 @@ "browserslist": "cli.js" } }, - "node_modules/babel-preset-env/node_modules/caniuse-lite": { - "version": "1.0.30000889", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000889.tgz", - "integrity": "sha512-MFxcQ6x/LEEoaIhO7Zdb7Eg8YyNONN+WBnS5ERJ0li2yRw51+i4xXUNxnLaveTb/4ZoJqsWKEmlomhG2pYzlQA==", - "dev": true - }, "node_modules/babel-preset-env/node_modules/electron-to-chromium": { "version": "1.3.73", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.73.tgz", @@ -2391,10 +2385,20 @@ "dev": true }, "node_modules/caniuse-lite": { - "version": "1.0.30000792", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000792.tgz", - "integrity": "sha1-0M6pgfgRjzlhRxr7tDyaHlu/AzI=", - "dev": true + "version": "1.0.30001450", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001450.tgz", + "integrity": "sha512-qMBmvmQmFXaSxexkjjfMvD5rnDL0+m+dUMZKoDYsGG8iZN29RuYh9eRoMvKsT6uMAWlyUUGDEQGJJYjzCIO9ew==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + } + ] }, "node_modules/capture-stack-trace": { "version": "1.0.1", @@ -11932,12 +11936,6 @@ "lodash.uniq": "^4.5.0" } }, - "node_modules/postcss-cssnext/node_modules/caniuse-lite": { - "version": "1.0.30000885", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000885.tgz", - "integrity": "sha512-cXKbYwpxBLd7qHyej16JazPoUacqoVuDhvR61U7Fr5vSxMUiodzcYa1rQYRYfZ5GexV03vGZHd722vNPLjPJGQ==", - "dev": true - }, "node_modules/postcss-cssnext/node_modules/chalk": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", @@ -20347,12 +20345,6 @@ "electron-to-chromium": "^1.3.47" } }, - "caniuse-lite": { - "version": "1.0.30000889", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000889.tgz", - "integrity": "sha512-MFxcQ6x/LEEoaIhO7Zdb7Eg8YyNONN+WBnS5ERJ0li2yRw51+i4xXUNxnLaveTb/4ZoJqsWKEmlomhG2pYzlQA==", - "dev": true - }, "electron-to-chromium": { "version": "1.3.73", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.73.tgz", @@ -21163,9 +21155,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30000792", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000792.tgz", - "integrity": "sha1-0M6pgfgRjzlhRxr7tDyaHlu/AzI=", + "version": "1.0.30001450", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001450.tgz", + "integrity": "sha512-qMBmvmQmFXaSxexkjjfMvD5rnDL0+m+dUMZKoDYsGG8iZN29RuYh9eRoMvKsT6uMAWlyUUGDEQGJJYjzCIO9ew==", "dev": true }, "capture-stack-trace": { @@ -29033,12 +29025,6 @@ "lodash.uniq": "^4.5.0" } }, - "caniuse-lite": { - "version": "1.0.30000885", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000885.tgz", - "integrity": "sha512-cXKbYwpxBLd7qHyej16JazPoUacqoVuDhvR61U7Fr5vSxMUiodzcYa1rQYRYfZ5GexV03vGZHd722vNPLjPJGQ==", - "dev": true - }, "chalk": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", diff --git a/package.json b/package.json index dc5bd8866..f4ab8e975 100644 --- a/package.json +++ b/package.json @@ -133,7 +133,7 @@ "webpack-bundle-analyzer": "^2.9.2" }, "engines": { - "node": ">=10.0.0" + "node": ">=16.19.0" }, "version": "0.22.0" } From efe8cbc5f67b74af688d3dd95bfbf1520b2e9033 Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Tue, 7 Feb 2023 16:12:05 -0500 Subject: [PATCH 04/43] Trying a different connection to neo4j --- src/client/components/starting-neo4j.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/components/starting-neo4j.js b/src/client/components/starting-neo4j.js index 4671429fc..1b69d4692 100644 --- a/src/client/components/starting-neo4j.js +++ b/src/client/components/starting-neo4j.js @@ -28,7 +28,7 @@ async function getAllDocs() {// eslint-disable-line no-unused-vars } const neo4j = require('neo4j-driver'); -const driver = neo4j.driver('neo4j+s://784b1fe44e530692a44bee70af1f243c.neo4jsandbox.com:7687', neo4j.auth.basic('neo4j', 'metals-wires-alarms')); // free sandbox. temporary +const driver = neo4j.driver('bolt://52.23.228.198:7687', neo4j.auth.basic('neo4j', 'metals-wires-alarms')); // free sandbox. temporary const makeNodeQuery = 'MERGE (gene:Gene {id: $id}) \n' + 'ON CREATE SET gene.factoidId = $factoidId, \n' @@ -81,7 +81,7 @@ doi: '10.1126/sciadv.abi6439', pmid: '34767444', ISODate: '2021-11-12T00:00:00.0 abbreviation: 'Qinbo Cai, Wolong Zhou, Wei Wang, ..., Feng Yang', documentId: 'a896d611-affe-4b45-a5e1-9bc560ffceab', title: 'MAPK6-AKT signaling promotes tumor growth and resistance to mTOR kinase blockade.'}]; -const session = driver.session(); +const session = driver.session({database:"neo4j"}); session .beginTransaction() .then(transaction => { From 58394a4aae6d5e95ac2f1c2dde0162c0620dce75 Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Wed, 8 Feb 2023 11:16:19 -0500 Subject: [PATCH 05/43] Max has helped me start testing/actually running my code --- src/neo4j/starting-neo4j.js | 101 ++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 src/neo4j/starting-neo4j.js diff --git a/src/neo4j/starting-neo4j.js b/src/neo4j/starting-neo4j.js new file mode 100644 index 000000000..a53bfe565 --- /dev/null +++ b/src/neo4j/starting-neo4j.js @@ -0,0 +1,101 @@ +async function loadDoc(data, docSocket, eleSocket) { + const { id, secret } = data; + + const doc = new Document({ + socket: docSocket, + factoryOptions: { socket: eleSocket }, + data: { id, secret } + }); + + await doc.load(); + await doc.sync(true); + + return doc; +} + +async function toDocs(docJSONs, docSocket, eleSocket) { + const docPromises = docJSONs.map(async docJSON => await loadDoc(docJSON, docSocket, eleSocket)); + + return Promise.all( docPromises ); +} + +async function getAllDocs() {// eslint-disable-line no-unused-vars + const url = 'https://biofactoid.org/api/document/a896d611-affe-4b45-a5e1-9bc560ffceab'; + + const res = await fetch(`${url}`); + const docJSONs = await res.json(); + return await toDocs(docJSONs, this.docSocket, this.eleSocket); +} + +const neo4j = require('neo4j-driver'); +const driver = neo4j.driver('bolt://52.23.228.198:7687', neo4j.auth.basic('neo4j', 'metals-wires-alarms')); // free sandbox. temporary + +const makeNodeQuery = 'MERGE (gene:Gene {id: $id}) \n' ++ 'ON CREATE SET gene.factoidId = $factoidId, \n' ++ 'gene.name = $name, \n' ++ 'gene.type = $type, \n' ++ 'gene.dbId = $dbId, \n' ++ 'gene.dbName = $dbName'; + +// Format of nodeData are as follows: +// { id: 'element.association.dbPrefix'+ ':' + 'element.association.id', factoidId: 'element.id', +// name: 'element.name', type: 'element.type', dbId: 'element.association.id', +// dbName: "element.association.dbName"} +const nodeData = [ + // MAPK6 data + { id: 'ncbigene:5597', factoidId: '598f8bef-f858-4dd0-b1c6-5168a8ae5349', name: 'MAPK6', + type: 'protein', dbId: '5597', dbName: 'NCBI Gene'}, + // AKT data + { id: 'ncbigene:207', factoidId: '4081348e-20b8-4bf8-836f-695827a4f9a2', name: 'AKT', + type: 'protein', dbId: '207', dbName: 'NCBI Gene'} +]; + +const makeRelationshipQuery = 'MATCH (x:Gene {id: $id1}) \n' ++ 'MATCH (y:Gene {id: $id2}) \n' ++ 'WHERE (element.id = $id3) \n' ++ 'MERGE (x)-[r:INTERACTION {id: $id3}]->(y) \n' ++ 'ON CREATE SET r.type = $type, \n' ++ 'r.createdDate = $createdDate, \n' ++ 'r.lastEditedDate = $lastEditedDate, \n' ++ 'r.abstract = $abstract, \n' ++ 'r.text = $text, \n' ++ 'r.doi = $doi, \n' ++ 'r.pmid = $pmid, \n' ++ 'r.ISODate = $ISODate, \n' ++ 'r.authors = $abbreviation, \n' ++ 'r.documentId = $documentId \n' ++ 'r.title = $title'; + +// Parameters of edgeData are as follows: +// { id1: 'element.association.dbPrefix'+ ':' + 'element.association.id', +// id2: 'element.association.dbPrefix'+ ':' + 'element.association.id', id3: 'element.id', +// type: 'element.type', createdDate: 'value.createdDate', +// lastEditedDate: 'value.lastEditedDate', abstract: 'value.citation.abstract', +// text: 'value.text', doi: 'value.citation.doi', +// pmid: 'value.citation.pmid', ISODate: 'value.citation.ISODate', +// abbreviation: 'value.citation.authors.abbreviation', documentId: 'value.id', title: 'value.citation.title'} +const edgeData = [{ id1: 'ncbigene:5597', id2: 'ncbigene:207', id3: '01ef22cc-2a8e-46d4-9060-6bf1c273869b', +type: 'phosphorylation', createdDate: '2022-12-14T21:16:57.000Z', lastEditedDate: '2022-12-15T14:41:51.000Z', +abstract: 'PLACEHOLDER TEXT', text: 'MAPK6 activates AKT via phosphorylation.', +doi: '10.1126/sciadv.abi6439', pmid: '34767444', ISODate: '2021-11-12T00:00:00.000Z', +abbreviation: 'Qinbo Cai, Wolong Zhou, Wei Wang, ..., Feng Yang', documentId: 'a896d611-affe-4b45-a5e1-9bc560ffceab', +title: 'MAPK6-AKT signaling promotes tumor growth and resistance to mTOR kinase blockade.'}]; + +const session = driver.session({database:"neo4j"}); +session +.beginTransaction() +.then(transaction => { + transaction.run(makeNodeQuery, nodeData) // Step 1: Make the nodes + .then(result1 => { + console.log("Nodes created:", result1.summary.counters.nodesCreated); + return transaction.run (makeRelationshipQuery, edgeData); // Step 2: Make the relationship + }) + .then (result2 => { + console.log(result2.records.map(record => record.get("type"))); + return transaction.commit(); + }) + .then (() => { + session.close(); + driver.close(); + }); +}); \ No newline at end of file From 2a56322b10ca9f16bd39bc068ea26b7b1aaf2253 Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Wed, 8 Feb 2023 11:17:20 -0500 Subject: [PATCH 06/43] Can now run code in test-temp-run.js --- package.json | 3 +- src/client/components/starting-neo4j.js | 101 ------------------------ src/neo4j/test-temp-run.js | 1 + 3 files changed, 3 insertions(+), 102 deletions(-) delete mode 100644 src/client/components/starting-neo4j.js create mode 100644 src/neo4j/test-temp-run.js diff --git a/package.json b/package.json index c97265398..55a9449f0 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,8 @@ "watch": "run-p watch:*", "test": "mocha -r esm --recursive", "test:travis": "run-s lint", - "ci": "run-s test lint" + "ci": "run-s test lint", + "neo4j": "node -r esm ./src/neo4j/test-temp-run.js" }, "dependencies": { "@appsignal/express": "^0.5.1", diff --git a/src/client/components/starting-neo4j.js b/src/client/components/starting-neo4j.js deleted file mode 100644 index 1b69d4692..000000000 --- a/src/client/components/starting-neo4j.js +++ /dev/null @@ -1,101 +0,0 @@ -async function loadDoc(data, docSocket, eleSocket) { - const { id, secret } = data; - - const doc = new Document({ - socket: docSocket, - factoryOptions: { socket: eleSocket }, - data: { id, secret } - }); - - await doc.load(); - await doc.sync(true); - - return doc; -} - -async function toDocs(docJSONs, docSocket, eleSocket) { - const docPromises = docJSONs.map(async docJSON => await loadDoc(docJSON, docSocket, eleSocket)); - - return Promise.all( docPromises ); -} - -async function getAllDocs() {// eslint-disable-line no-unused-vars - const url = 'https://biofactoid.org/api/document/a896d611-affe-4b45-a5e1-9bc560ffceab'; - - const res = await fetch(`${url}`); - const docJSONs = await res.json(); - return await toDocs(docJSONs, this.docSocket, this.eleSocket); -} - -const neo4j = require('neo4j-driver'); -const driver = neo4j.driver('bolt://52.23.228.198:7687', neo4j.auth.basic('neo4j', 'metals-wires-alarms')); // free sandbox. temporary - -const makeNodeQuery = 'MERGE (gene:Gene {id: $id}) \n' -+ 'ON CREATE SET gene.factoidId = $factoidId, \n' -+ 'gene.name = $name, \n' -+ 'gene.type = $type, \n' -+ 'gene.dbId = $dbId, \n' -+ 'gene.dbName = $dbName)'; - -// Format of nodeData are as follows: -// { id: 'element.association.dbPrefix'+ ':' + 'element.association.id', factoidId: 'element.id', -// name: 'element.name', type: 'element.type', dbId: 'element.association.id', -// dbName: "element.association.dbName"} -const nodeData = [ - // MAPK6 data - { id: 'ncbigene:5597', factoidId: '598f8bef-f858-4dd0-b1c6-5168a8ae5349', name: 'MAPK6', - type: 'protein', dbId: '5597', dbName: 'NCBI Gene'}, - // AKT data - { id: 'ncbigene:207', factoidId: '4081348e-20b8-4bf8-836f-695827a4f9a2', name: 'AKT', - type: 'protein', dbId: '207', dbName: 'NCBI Gene'} -]; - -const makeRelationshipQuery = 'MATCH (x:Gene {id: $id1}) \n' -+ 'MATCH (y:Gene {id: $id2}) \n' -+ 'WHERE (element.id = $id3) \n' -+ 'MERGE (x)-[r:INTERACTION {id: $id3}]->(y) \n' -+ 'ON CREATE SET r.type = $type, \n' -+ 'r.createdDate = $createdDate, \n' -+ 'r.lastEditedDate = $lastEditedDate, \n' -+ 'r.abstract = $abstract, \n' -+ 'r.text = $text, \n' -+ 'r.doi = $doi, \n' -+ 'r.pmid = $pmid, \n' -+ 'r.ISODate = $ISODate, \n' -+ 'r.authors = $abbreviation, \n' -+ 'r.documentId = $documentId \n' -+ 'r.title = $title'; - -// Parameters of edgeData are as follows: -// { id1: 'element.association.dbPrefix'+ ':' + 'element.association.id', -// id2: 'element.association.dbPrefix'+ ':' + 'element.association.id', id3: 'element.id', -// type: 'element.type', createdDate: 'value.createdDate', -// lastEditedDate: 'value.lastEditedDate', abstract: 'value.citation.abstract', -// text: 'value.text', doi: 'value.citation.doi', -// pmid: 'value.citation.pmid', ISODate: 'value.citation.ISODate', -// abbreviation: 'value.citation.authors.abbreviation', documentId: 'value.id', title: 'value.citation.title'} -const edgeData = [{ id1: 'ncbigene:5597', id2: 'ncbigene:207', id3: '01ef22cc-2a8e-46d4-9060-6bf1c273869b', -type: 'phosphorylation', createdDate: '2022-12-14T21:16:57.000Z', lastEditedDate: '2022-12-15T14:41:51.000Z', -abstract: 'PLACEHOLDER TEXT', text: 'MAPK6 activates AKT via phosphorylation.', -doi: '10.1126/sciadv.abi6439', pmid: '34767444', ISODate: '2021-11-12T00:00:00.000Z', -abbreviation: 'Qinbo Cai, Wolong Zhou, Wei Wang, ..., Feng Yang', documentId: 'a896d611-affe-4b45-a5e1-9bc560ffceab', -title: 'MAPK6-AKT signaling promotes tumor growth and resistance to mTOR kinase blockade.'}]; - -const session = driver.session({database:"neo4j"}); -session -.beginTransaction() -.then(transaction => { - transaction.run(makeNodeQuery, nodeData) // Step 1: Make the nodes - .then(result1 => { - console.log("Nodes created:", result1.summary.counters.nodesCreated); - return transaction.run (makeRelationshipQuery, edgeData); // Step 2: Make the relationship - }) - .then (result2 => { - console.log(result2.records.map(record => record.get("type"))); - return transaction.commit(); - }) - .then (() => { - session.close(); - driver.close(); - }); -}); \ No newline at end of file diff --git a/src/neo4j/test-temp-run.js b/src/neo4j/test-temp-run.js new file mode 100644 index 000000000..a5bd06d36 --- /dev/null +++ b/src/neo4j/test-temp-run.js @@ -0,0 +1 @@ +console.log("This is my test run!"); \ No newline at end of file From 67a50115794449e97e5f5630002a598a92d33ca5 Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Wed, 8 Feb 2023 11:57:08 -0500 Subject: [PATCH 07/43] Test now runs, generates helpful errors about cypher/neo4j --- src/neo4j/starting-neo4j.js | 43 +++++++++++++++++++++---------------- src/neo4j/test-temp-run.js | 10 ++++++++- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/neo4j/starting-neo4j.js b/src/neo4j/starting-neo4j.js index a53bfe565..53750080d 100644 --- a/src/neo4j/starting-neo4j.js +++ b/src/neo4j/starting-neo4j.js @@ -1,3 +1,6 @@ +// const neo4j = require('neo4j-driver'); <-- old, read up on imports and exports +import neo4j from 'neo4j-driver'; + async function loadDoc(data, docSocket, eleSocket) { const { id, secret } = data; @@ -27,7 +30,7 @@ async function getAllDocs() {// eslint-disable-line no-unused-vars return await toDocs(docJSONs, this.docSocket, this.eleSocket); } -const neo4j = require('neo4j-driver'); + const driver = neo4j.driver('bolt://52.23.228.198:7687', neo4j.auth.basic('neo4j', 'metals-wires-alarms')); // free sandbox. temporary const makeNodeQuery = 'MERGE (gene:Gene {id: $id}) \n' @@ -81,21 +84,25 @@ doi: '10.1126/sciadv.abi6439', pmid: '34767444', ISODate: '2021-11-12T00:00:00.0 abbreviation: 'Qinbo Cai, Wolong Zhou, Wei Wang, ..., Feng Yang', documentId: 'a896d611-affe-4b45-a5e1-9bc560ffceab', title: 'MAPK6-AKT signaling promotes tumor growth and resistance to mTOR kinase blockade.'}]; -const session = driver.session({database:"neo4j"}); -session -.beginTransaction() -.then(transaction => { - transaction.run(makeNodeQuery, nodeData) // Step 1: Make the nodes - .then(result1 => { - console.log("Nodes created:", result1.summary.counters.nodesCreated); - return transaction.run (makeRelationshipQuery, edgeData); // Step 2: Make the relationship - }) - .then (result2 => { - console.log(result2.records.map(record => record.get("type"))); - return transaction.commit(); - }) - .then (() => { - session.close(); - driver.close(); + + +export async function test() { + const session = driver.session({database:"neo4j"}); + await session + .beginTransaction() + .then(transaction => { + transaction.run(makeNodeQuery, nodeData) // Step 1: Make the nodes + .then(result1 => { + console.log("Nodes created:", result1.summary.counters.nodesCreated); + return transaction.run (makeRelationshipQuery, edgeData); // Step 2: Make the relationship + }) + .then (result2 => { + console.log(result2.records.map(record => record.get("type"))); + return transaction.commit(); + }) + .then (() => { + session.close(); + driver.close(); + }); }); -}); \ No newline at end of file +} \ No newline at end of file diff --git a/src/neo4j/test-temp-run.js b/src/neo4j/test-temp-run.js index a5bd06d36..d682c8eb5 100644 --- a/src/neo4j/test-temp-run.js +++ b/src/neo4j/test-temp-run.js @@ -1 +1,9 @@ -console.log("This is my test run!"); \ No newline at end of file +import { test } from './starting-neo4j.js'; + +async function running() { + console.log("We are starting now!"); + await test(); + console.log("This is my test run!"); +} + +running(); \ No newline at end of file From 208228e793d5c8ca8421cda527e43ce7deb2651b Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Wed, 8 Feb 2023 15:14:49 -0500 Subject: [PATCH 08/43] helloWorld function can write to sandbox successfully --- src/neo4j/starting-neo4j.js | 63 +++++++++++++++++++++++-------------- src/neo4j/test-temp-run.js | 6 ++-- 2 files changed, 43 insertions(+), 26 deletions(-) diff --git a/src/neo4j/starting-neo4j.js b/src/neo4j/starting-neo4j.js index 53750080d..39e72edde 100644 --- a/src/neo4j/starting-neo4j.js +++ b/src/neo4j/starting-neo4j.js @@ -1,4 +1,4 @@ -// const neo4j = require('neo4j-driver'); <-- old, read up on imports and exports +// const neo4j = require('neo4j-driver'); <-- old, read up on imports and exports in book import neo4j from 'neo4j-driver'; async function loadDoc(data, docSocket, eleSocket) { @@ -33,12 +33,13 @@ async function getAllDocs() {// eslint-disable-line no-unused-vars const driver = neo4j.driver('bolt://52.23.228.198:7687', neo4j.auth.basic('neo4j', 'metals-wires-alarms')); // free sandbox. temporary -const makeNodeQuery = 'MERGE (gene:Gene {id: $id}) \n' -+ 'ON CREATE SET gene.factoidId = $factoidId, \n' -+ 'gene.name = $name, \n' -+ 'gene.type = $type, \n' -+ 'gene.dbId = $dbId, \n' -+ 'gene.dbName = $dbName'; +const makeNodeQuery = + `MERGE (gene:Gene {id: $id}) + ON CREATE SET gene.factoidId = $factoidId, + gene.name = $name, + gene.type = $type, + gene.dbId = $dbId, + gene.dbName = $dbName`; // Format of nodeData are as follows: // { id: 'element.association.dbPrefix'+ ':' + 'element.association.id', factoidId: 'element.id', @@ -53,21 +54,21 @@ const nodeData = [ type: 'protein', dbId: '207', dbName: 'NCBI Gene'} ]; -const makeRelationshipQuery = 'MATCH (x:Gene {id: $id1}) \n' -+ 'MATCH (y:Gene {id: $id2}) \n' -+ 'WHERE (element.id = $id3) \n' -+ 'MERGE (x)-[r:INTERACTION {id: $id3}]->(y) \n' -+ 'ON CREATE SET r.type = $type, \n' -+ 'r.createdDate = $createdDate, \n' -+ 'r.lastEditedDate = $lastEditedDate, \n' -+ 'r.abstract = $abstract, \n' -+ 'r.text = $text, \n' -+ 'r.doi = $doi, \n' -+ 'r.pmid = $pmid, \n' -+ 'r.ISODate = $ISODate, \n' -+ 'r.authors = $abbreviation, \n' -+ 'r.documentId = $documentId \n' -+ 'r.title = $title'; +const makeRelationshipQuery = +`MATCH (x:Gene {id: $id1}) +MATCH (y:Gene {id: $id2}) +MERGE (x)-[r:INTERACTION {id: $id3}]->(y) +ON CREATE SET r.type = $type, +r.createdDate = $createdDate, +r.lastEditedDate = $lastEditedDate, +r.abstract = $abstract, +r.text = $text, +r.doi = $doi, +r.pmid = $pmid, +r.ISODate = $ISODate, +r.authors = $abbreviation, +r.documentId = $documentId, +r.title = $title`; // Parameters of edgeData are as follows: // { id1: 'element.association.dbPrefix'+ ':' + 'element.association.id', @@ -84,7 +85,23 @@ doi: '10.1126/sciadv.abi6439', pmid: '34767444', ISODate: '2021-11-12T00:00:00.0 abbreviation: 'Qinbo Cai, Wolong Zhou, Wei Wang, ..., Feng Yang', documentId: 'a896d611-affe-4b45-a5e1-9bc560ffceab', title: 'MAPK6-AKT signaling promotes tumor growth and resistance to mTOR kinase blockade.'}]; - +export async function helloWorld() { + const session = driver.session({database:"neo4j"}); + await session + .beginTransaction() + .then(transaction => { + transaction.run('MERGE (a:Greeting) SET a.message = $message RETURN a.message + ", from node " + id(a)', + { message: 'Hello World!!!' }) + .then(result1 => { + console.log("Message Sent: ", result1.records[0].get(0)); + return transaction.commit(); + }) + .then (() => { + session.close(); + driver.close(); + }); + }); +} export async function test() { const session = driver.session({database:"neo4j"}); diff --git a/src/neo4j/test-temp-run.js b/src/neo4j/test-temp-run.js index d682c8eb5..d8b408c90 100644 --- a/src/neo4j/test-temp-run.js +++ b/src/neo4j/test-temp-run.js @@ -1,9 +1,9 @@ -import { test } from './starting-neo4j.js'; +import { helloWorld, test } from './starting-neo4j.js'; async function running() { console.log("We are starting now!"); - await test(); + await helloWorld(); console.log("This is my test run!"); } -running(); \ No newline at end of file + running(); \ No newline at end of file From 905452b759e5b53cff0c634cb817f417bb59c0ea Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Wed, 8 Feb 2023 17:17:04 -0500 Subject: [PATCH 09/43] makeGeneNodeTest() is successful, but has exit issue --- src/neo4j/starting-neo4j.js | 84 ++++++++++++++++++++++--------------- src/neo4j/test-temp-run.js | 12 ++++-- 2 files changed, 60 insertions(+), 36 deletions(-) diff --git a/src/neo4j/starting-neo4j.js b/src/neo4j/starting-neo4j.js index 39e72edde..e7b5ee321 100644 --- a/src/neo4j/starting-neo4j.js +++ b/src/neo4j/starting-neo4j.js @@ -33,6 +33,24 @@ async function getAllDocs() {// eslint-disable-line no-unused-vars const driver = neo4j.driver('bolt://52.23.228.198:7687', neo4j.auth.basic('neo4j', 'metals-wires-alarms')); // free sandbox. temporary +export async function helloWorld() { + const session = driver.session({database:"neo4j"}); + await session + .beginTransaction() + .then(transaction => { + transaction.run('MERGE (a:Greeting) SET a.message = $message RETURN a.message + ", from node " + id(a)', + { message: 'Hello World!!!' }) + .then(result1 => { + console.log("Message Sent: ", result1.records[0].get(0)); + return transaction.commit(); + }) + .then (() => { + session.close(); + driver.close(); + }); + }); +} + const makeNodeQuery = `MERGE (gene:Gene {id: $id}) ON CREATE SET gene.factoidId = $factoidId, @@ -54,21 +72,39 @@ const nodeData = [ type: 'protein', dbId: '207', dbName: 'NCBI Gene'} ]; +// this test does as I want, but it doesn't exit by itself (need to use Ctrl-C) +export async function makeGeneNodeTest() { + for (let i = 0; i < nodeData.length; i++) { + const session = driver.session({database:"neo4j"}); + await session + .run(makeNodeQuery, nodeData[i]) + .then(result => { + console.log("Gene Node created:", nodeData[i].name); + session.close(); + }) + .catch(error => { + console.error(error); + session.close(); + driver.close(); + }); + } +} + const makeRelationshipQuery = -`MATCH (x:Gene {id: $id1}) -MATCH (y:Gene {id: $id2}) -MERGE (x)-[r:INTERACTION {id: $id3}]->(y) -ON CREATE SET r.type = $type, -r.createdDate = $createdDate, -r.lastEditedDate = $lastEditedDate, -r.abstract = $abstract, -r.text = $text, -r.doi = $doi, -r.pmid = $pmid, -r.ISODate = $ISODate, -r.authors = $abbreviation, -r.documentId = $documentId, -r.title = $title`; + `MATCH (x:Gene {id: $id1}) + MATCH (y:Gene {id: $id2}) + MERGE (x)-[r:INTERACTION {id: $id3}]->(y) + ON CREATE SET r.type = $type, + r.createdDate = $createdDate, + r.lastEditedDate = $lastEditedDate, + r.abstract = $abstract, + r.text = $text, + r.doi = $doi, + r.pmid = $pmid, + r.ISODate = $ISODate, + r.authors = $abbreviation, + r.documentId = $documentId, + r.title = $title`; // Parameters of edgeData are as follows: // { id1: 'element.association.dbPrefix'+ ':' + 'element.association.id', @@ -85,25 +121,7 @@ doi: '10.1126/sciadv.abi6439', pmid: '34767444', ISODate: '2021-11-12T00:00:00.0 abbreviation: 'Qinbo Cai, Wolong Zhou, Wei Wang, ..., Feng Yang', documentId: 'a896d611-affe-4b45-a5e1-9bc560ffceab', title: 'MAPK6-AKT signaling promotes tumor growth and resistance to mTOR kinase blockade.'}]; -export async function helloWorld() { - const session = driver.session({database:"neo4j"}); - await session - .beginTransaction() - .then(transaction => { - transaction.run('MERGE (a:Greeting) SET a.message = $message RETURN a.message + ", from node " + id(a)', - { message: 'Hello World!!!' }) - .then(result1 => { - console.log("Message Sent: ", result1.records[0].get(0)); - return transaction.commit(); - }) - .then (() => { - session.close(); - driver.close(); - }); - }); -} - -export async function test() { +export async function test() { // This test does not yet work const session = driver.session({database:"neo4j"}); await session .beginTransaction() diff --git a/src/neo4j/test-temp-run.js b/src/neo4j/test-temp-run.js index d8b408c90..78c4f71b8 100644 --- a/src/neo4j/test-temp-run.js +++ b/src/neo4j/test-temp-run.js @@ -1,9 +1,15 @@ -import { helloWorld, test } from './starting-neo4j.js'; +import { helloWorld, makeGeneNodeTest } from './starting-neo4j.js'; -async function running() { +async function helloTest() { // eslint-disable-line no-unused-vars console.log("We are starting now!"); await helloWorld(); console.log("This is my test run!"); } - running(); \ No newline at end of file +async function makeNodeTest() { + console.log("Starting makeNodeTest"); + await makeGeneNodeTest(); + console.log("Finish makeNodeTest"); +} + +makeNodeTest(); \ No newline at end of file From f6a8bf3022e343891e181e17743c82433021f8b2 Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Thu, 9 Feb 2023 12:08:35 -0500 Subject: [PATCH 10/43] Got rid of helloWorld test. Pruned relationship properties --- src/neo4j/starting-neo4j.js | 167 ++++++++++++++++++------------------ src/neo4j/test-temp-run.js | 10 +-- 2 files changed, 84 insertions(+), 93 deletions(-) diff --git a/src/neo4j/starting-neo4j.js b/src/neo4j/starting-neo4j.js index e7b5ee321..55a4e3fda 100644 --- a/src/neo4j/starting-neo4j.js +++ b/src/neo4j/starting-neo4j.js @@ -17,127 +17,124 @@ async function loadDoc(data, docSocket, eleSocket) { } async function toDocs(docJSONs, docSocket, eleSocket) { - const docPromises = docJSONs.map(async docJSON => await loadDoc(docJSON, docSocket, eleSocket)); + const docPromises = docJSONs.map(async docJSON => await loadDoc(docJSON, docSocket, eleSocket)); - return Promise.all( docPromises ); + return Promise.all(docPromises); } async function getAllDocs() {// eslint-disable-line no-unused-vars - const url = 'https://biofactoid.org/api/document/a896d611-affe-4b45-a5e1-9bc560ffceab'; + const url = 'https://biofactoid.org/api/document/a896d611-affe-4b45-a5e1-9bc560ffceab'; - const res = await fetch(`${url}`); - const docJSONs = await res.json(); - return await toDocs(docJSONs, this.docSocket, this.eleSocket); + const res = await fetch(`${url}`); + const docJSONs = await res.json(); + return await toDocs(docJSONs, this.docSocket, this.eleSocket); } const driver = neo4j.driver('bolt://52.23.228.198:7687', neo4j.auth.basic('neo4j', 'metals-wires-alarms')); // free sandbox. temporary -export async function helloWorld() { - const session = driver.session({database:"neo4j"}); - await session - .beginTransaction() - .then(transaction => { - transaction.run('MERGE (a:Greeting) SET a.message = $message RETURN a.message + ", from node " + id(a)', - { message: 'Hello World!!!' }) - .then(result1 => { - console.log("Message Sent: ", result1.records[0].get(0)); - return transaction.commit(); - }) - .then (() => { - session.close(); - driver.close(); - }); - }); -} - -const makeNodeQuery = - `MERGE (gene:Gene {id: $id}) - ON CREATE SET gene.factoidId = $factoidId, - gene.name = $name, - gene.type = $type, - gene.dbId = $dbId, - gene.dbName = $dbName`; - // Format of nodeData are as follows: // { id: 'element.association.dbPrefix'+ ':' + 'element.association.id', factoidId: 'element.id', // name: 'element.name', type: 'element.type', dbId: 'element.association.id', // dbName: "element.association.dbName"} const nodeData = [ // MAPK6 data - { id: 'ncbigene:5597', factoidId: '598f8bef-f858-4dd0-b1c6-5168a8ae5349', name: 'MAPK6', - type: 'protein', dbId: '5597', dbName: 'NCBI Gene'}, + { + id: 'ncbigene:5597', factoidId: '598f8bef-f858-4dd0-b1c6-5168a8ae5349', name: 'MAPK6', + type: 'protein', dbId: '5597', dbName: 'NCBI Gene' + }, // AKT data - { id: 'ncbigene:207', factoidId: '4081348e-20b8-4bf8-836f-695827a4f9a2', name: 'AKT', - type: 'protein', dbId: '207', dbName: 'NCBI Gene'} + { + id: 'ncbigene:207', factoidId: '4081348e-20b8-4bf8-836f-695827a4f9a2', name: 'AKT', + type: 'protein', dbId: '207', dbName: 'NCBI Gene' + } ]; -// this test does as I want, but it doesn't exit by itself (need to use Ctrl-C) +const makeNodeQuery = + `MERGE (gene:Gene {id: $id}) + ON CREATE SET gene.factoidId = $factoidId, + gene.name = $name, + gene.type = $type, + gene.dbId = $dbId, + gene.dbName = $dbName + RETURN gene.name`; + +// this test makes the MAPK6 node +export async function makeMAPK6Test() { + let session; + try { + session = driver.session({ database: "neo4j" }); + let result = await session.run(makeNodeQuery, nodeData[0]); + console.log("Gene Node created:", result.records[0].get(0)); + } catch (error) { + console.error(error); + throw error; + } finally { + session.close(); + driver.close(); + } +} + +// this test does as I want (make both nodes at once) but it doesn't +// exit by itself (need to use Ctrl-C) export async function makeGeneNodeTest() { + //let session; for (let i = 0; i < nodeData.length; i++) { - const session = driver.session({database:"neo4j"}); - await session - .run(makeNodeQuery, nodeData[i]) - .then(result => { - console.log("Gene Node created:", nodeData[i].name); + let session; + try { + session = driver.session({ database: "neo4j" }); + let result = await session.run(makeNodeQuery, nodeData[i]); + console.log("Gene Node created"); session.close(); - }) - .catch(error => { + } catch (error) { console.error(error); session.close(); driver.close(); - }); + throw error; } + } } -const makeRelationshipQuery = +// Parameters of relationshipData are as follows: +// { id1: 'element.association.dbPrefix'+ ':' + 'element.association.id', +// id2: 'element.association.dbPrefix'+ ':' + 'element.association.id', id3: 'element.id', +// type: 'element.type', doi: 'value.citation.doi', +// pmid: 'value.citation.pmid', documentId: 'value.id', title: 'value.citation.title'} +const relationshipData = [{ + id1: 'ncbigene:5597', id2: 'ncbigene:207', id3: '01ef22cc-2a8e-46d4-9060-6bf1c273869b', + type: 'phosphorylation', doi: '10.1126/sciadv.abi6439', pmid: '34767444', + documentId: 'a896d611-affe-4b45-a5e1-9bc560ffceab', + title: 'MAPK6-AKT signaling promotes tumor growth and resistance to mTOR kinase blockade.' +}]; + +const makeRelationshipQuery = `MATCH (x:Gene {id: $id1}) MATCH (y:Gene {id: $id2}) MERGE (x)-[r:INTERACTION {id: $id3}]->(y) ON CREATE SET r.type = $type, - r.createdDate = $createdDate, - r.lastEditedDate = $lastEditedDate, - r.abstract = $abstract, - r.text = $text, r.doi = $doi, - r.pmid = $pmid, - r.ISODate = $ISODate, - r.authors = $abbreviation, + r.pmid = $pmid, r.documentId = $documentId, r.title = $title`; -// Parameters of edgeData are as follows: -// { id1: 'element.association.dbPrefix'+ ':' + 'element.association.id', -// id2: 'element.association.dbPrefix'+ ':' + 'element.association.id', id3: 'element.id', -// type: 'element.type', createdDate: 'value.createdDate', -// lastEditedDate: 'value.lastEditedDate', abstract: 'value.citation.abstract', -// text: 'value.text', doi: 'value.citation.doi', -// pmid: 'value.citation.pmid', ISODate: 'value.citation.ISODate', -// abbreviation: 'value.citation.authors.abbreviation', documentId: 'value.id', title: 'value.citation.title'} -const edgeData = [{ id1: 'ncbigene:5597', id2: 'ncbigene:207', id3: '01ef22cc-2a8e-46d4-9060-6bf1c273869b', -type: 'phosphorylation', createdDate: '2022-12-14T21:16:57.000Z', lastEditedDate: '2022-12-15T14:41:51.000Z', -abstract: 'PLACEHOLDER TEXT', text: 'MAPK6 activates AKT via phosphorylation.', -doi: '10.1126/sciadv.abi6439', pmid: '34767444', ISODate: '2021-11-12T00:00:00.000Z', -abbreviation: 'Qinbo Cai, Wolong Zhou, Wei Wang, ..., Feng Yang', documentId: 'a896d611-affe-4b45-a5e1-9bc560ffceab', -title: 'MAPK6-AKT signaling promotes tumor growth and resistance to mTOR kinase blockade.'}]; - -export async function test() { // This test does not yet work - const session = driver.session({database:"neo4j"}); +export async function test() { // This test does not yet work!!! + const session = driver.session({ database: "neo4j" }); await session - .beginTransaction() - .then(transaction => { - transaction.run(makeNodeQuery, nodeData) // Step 1: Make the nodes - .then(result1 => { - console.log("Nodes created:", result1.summary.counters.nodesCreated); - return transaction.run (makeRelationshipQuery, edgeData); // Step 2: Make the relationship - }) - .then (result2 => { - console.log(result2.records.map(record => record.get("type"))); - return transaction.commit(); - }) - .then (() => { - session.close(); - driver.close(); + .beginTransaction() + .then(transaction => { + transaction.run(makeNodeQuery, nodeData) // Step 1: Make the nodes + .then(result1 => { + console.log("Nodes created:", result1.summary.counters.nodesCreated); + // Step 2: Make the relationship + return transaction.run(makeRelationshipQuery, relationshipData); + }) + .then(result2 => { + console.log(result2.records.map(record => record.get("type"))); + return transaction.commit(); + }) + .then(() => { + session.close(); + driver.close(); + }); }); - }); } \ No newline at end of file diff --git a/src/neo4j/test-temp-run.js b/src/neo4j/test-temp-run.js index 78c4f71b8..715009181 100644 --- a/src/neo4j/test-temp-run.js +++ b/src/neo4j/test-temp-run.js @@ -1,14 +1,8 @@ -import { helloWorld, makeGeneNodeTest } from './starting-neo4j.js'; - -async function helloTest() { // eslint-disable-line no-unused-vars - console.log("We are starting now!"); - await helloWorld(); - console.log("This is my test run!"); -} +import { makeMAPK6Test, makeGeneNodeTest } from './starting-neo4j.js'; async function makeNodeTest() { console.log("Starting makeNodeTest"); - await makeGeneNodeTest(); + await makeMAPK6Test(); console.log("Finish makeNodeTest"); } From 396c2b9b3f7cd13afd96087425bd78e5cb01b520 Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Thu, 9 Feb 2023 13:40:30 -0500 Subject: [PATCH 11/43] Co-authored-by: Jeffrey --- src/neo4j/.env | 1 + src/neo4j/docker-compose.yml | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 src/neo4j/.env create mode 100644 src/neo4j/docker-compose.yml diff --git a/src/neo4j/.env b/src/neo4j/.env new file mode 100644 index 000000000..96205fc08 --- /dev/null +++ b/src/neo4j/.env @@ -0,0 +1 @@ +GRAPHDB_IMAGE_TAG=5.4.0 \ No newline at end of file diff --git a/src/neo4j/docker-compose.yml b/src/neo4j/docker-compose.yml new file mode 100644 index 000000000..3fb7a389f --- /dev/null +++ b/src/neo4j/docker-compose.yml @@ -0,0 +1,20 @@ +version: "3.8" +services: + graphdb: + image: neo4j:${GRAPHDB_IMAGE_TAG:-latest} + restart: unless-stopped + container_name: graphdb + ports: + - "7474:7474" + - "7687:7687" + volumes: + - graphdb-data:/data + - graphdb-plugins:/plugins + environment: + NEO4J_AUTH: none + NEO4J_apoc_export_file_enabled: true + NEO4J_apoc_import_file_enabled: true + NEO4J_apoc_import_file_use__neo4j__config: true + NEO4J_PLUGINS: '["apoc"]' + networks: + - graphdb-config-network \ No newline at end of file From 5811664c57b2502d24fc67091791e72be0768455 Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Thu, 9 Feb 2023 13:55:48 -0500 Subject: [PATCH 12/43] Docker-compose working now --- src/neo4j/docker-compose.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/neo4j/docker-compose.yml b/src/neo4j/docker-compose.yml index 3fb7a389f..3d7df97f7 100644 --- a/src/neo4j/docker-compose.yml +++ b/src/neo4j/docker-compose.yml @@ -17,4 +17,12 @@ services: NEO4J_apoc_import_file_use__neo4j__config: true NEO4J_PLUGINS: '["apoc"]' networks: - - graphdb-config-network \ No newline at end of file + - graphdb-config-network + +volumes: + graphdb-data: + graphdb-plugins: + +networks: + graphdb-config-network: + driver: bridge \ No newline at end of file From 783585c9904840e1c40403c4dd2f325238a8b5e0 Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Thu, 9 Feb 2023 14:21:43 -0500 Subject: [PATCH 13/43] code now writes to docker instance --- src/neo4j/starting-neo4j.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/neo4j/starting-neo4j.js b/src/neo4j/starting-neo4j.js index 55a4e3fda..5573ab8bc 100644 --- a/src/neo4j/starting-neo4j.js +++ b/src/neo4j/starting-neo4j.js @@ -31,7 +31,7 @@ async function getAllDocs() {// eslint-disable-line no-unused-vars } -const driver = neo4j.driver('bolt://52.23.228.198:7687', neo4j.auth.basic('neo4j', 'metals-wires-alarms')); // free sandbox. temporary +const driver = neo4j.driver('bolt://localhost:7687'); // Format of nodeData are as follows: // { id: 'element.association.dbPrefix'+ ':' + 'element.association.id', factoidId: 'element.id', From b6ba65bd5440fffaebed9b32308233bf1034c18c Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Thu, 9 Feb 2023 14:33:30 -0500 Subject: [PATCH 14/43] put document functions in a different file for organization --- src/neo4j/get-doc-functions.js | 28 ++++++++++++++++++++++++++++ src/neo4j/starting-neo4j.js | 30 ------------------------------ 2 files changed, 28 insertions(+), 30 deletions(-) create mode 100644 src/neo4j/get-doc-functions.js diff --git a/src/neo4j/get-doc-functions.js b/src/neo4j/get-doc-functions.js new file mode 100644 index 000000000..875f65331 --- /dev/null +++ b/src/neo4j/get-doc-functions.js @@ -0,0 +1,28 @@ +async function loadDoc(data, docSocket, eleSocket) { + const { id, secret } = data; + + const doc = new Document({ + socket: docSocket, + factoryOptions: { socket: eleSocket }, + data: { id, secret } + }); + + await doc.load(); + await doc.sync(true); + + return doc; +} + +async function toDocs(docJSONs, docSocket, eleSocket) { + const docPromises = docJSONs.map(async docJSON => await loadDoc(docJSON, docSocket, eleSocket)); + + return Promise.all(docPromises); +} + +async function getAllDocs() {// eslint-disable-line no-unused-vars + const url = 'https://biofactoid.org/api/document/a896d611-affe-4b45-a5e1-9bc560ffceab'; + + const res = await fetch(`${url}`); + const docJSONs = await res.json(); + return await toDocs(docJSONs, this.docSocket, this.eleSocket); +} \ No newline at end of file diff --git a/src/neo4j/starting-neo4j.js b/src/neo4j/starting-neo4j.js index 5573ab8bc..787590994 100644 --- a/src/neo4j/starting-neo4j.js +++ b/src/neo4j/starting-neo4j.js @@ -1,36 +1,6 @@ // const neo4j = require('neo4j-driver'); <-- old, read up on imports and exports in book import neo4j from 'neo4j-driver'; -async function loadDoc(data, docSocket, eleSocket) { - const { id, secret } = data; - - const doc = new Document({ - socket: docSocket, - factoryOptions: { socket: eleSocket }, - data: { id, secret } - }); - - await doc.load(); - await doc.sync(true); - - return doc; -} - -async function toDocs(docJSONs, docSocket, eleSocket) { - const docPromises = docJSONs.map(async docJSON => await loadDoc(docJSON, docSocket, eleSocket)); - - return Promise.all(docPromises); -} - -async function getAllDocs() {// eslint-disable-line no-unused-vars - const url = 'https://biofactoid.org/api/document/a896d611-affe-4b45-a5e1-9bc560ffceab'; - - const res = await fetch(`${url}`); - const docJSONs = await res.json(); - return await toDocs(docJSONs, this.docSocket, this.eleSocket); -} - - const driver = neo4j.driver('bolt://localhost:7687'); // Format of nodeData are as follows: From c0a491ffca9eb33e95eb43b39e132e8cefcece15 Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Fri, 10 Feb 2023 16:06:53 -0500 Subject: [PATCH 15/43] put query strings and hard coded data in different files --- src/neo4j/graph-data.js | 30 ++++++++++++++++ src/neo4j/query-strings.js | 18 ++++++++++ src/neo4j/starting-neo4j.js | 68 +++++++------------------------------ 3 files changed, 60 insertions(+), 56 deletions(-) create mode 100644 src/neo4j/graph-data.js create mode 100644 src/neo4j/query-strings.js diff --git a/src/neo4j/graph-data.js b/src/neo4j/graph-data.js new file mode 100644 index 000000000..73299a0ff --- /dev/null +++ b/src/neo4j/graph-data.js @@ -0,0 +1,30 @@ +// Format of node data are as follows: +// { id: 'element.association.dbPrefix'+ ':' + 'element.association.id', factoidId: 'element.id', +// name: 'element.name', type: 'element.type', dbId: 'element.association.id', +// dbName: "element.association.dbName"} +export const nodeData = [ + // MAPK6 data + { + id: 'ncbigene:5597', factoidId: '598f8bef-f858-4dd0-b1c6-5168a8ae5349', name: 'MAPK6', + type: 'protein', dbId: '5597', dbName: 'NCBI Gene' + }, + // AKT data + { + id: 'ncbigene:207', factoidId: '4081348e-20b8-4bf8-836f-695827a4f9a2', name: 'AKT', + type: 'protein', dbId: '207', dbName: 'NCBI Gene' + } +]; + +// Parameters of relationshipData are as follows: +// { id1: 'element.association.dbPrefix'+ ':' + 'element.association.id', +// id2: 'element.association.dbPrefix'+ ':' + 'element.association.id', id3: 'element.id', +// type: 'element.type', doi: 'value.citation.doi', +// pmid: 'value.citation.pmid', documentId: 'value.id', title: 'value.citation.title'} +export const relationshipData = [ + { + id1: 'ncbigene:5597', id2: 'ncbigene:207', id3: '01ef22cc-2a8e-46d4-9060-6bf1c273869b', + type: 'phosphorylation', doi: '10.1126/sciadv.abi6439', pmid: '34767444', + documentId: 'a896d611-affe-4b45-a5e1-9bc560ffceab', + title: 'MAPK6-AKT signaling promotes tumor growth and resistance to mTOR kinase blockade.' + } +]; diff --git a/src/neo4j/query-strings.js b/src/neo4j/query-strings.js new file mode 100644 index 000000000..1b36bfa49 --- /dev/null +++ b/src/neo4j/query-strings.js @@ -0,0 +1,18 @@ +export const makeNodeQuery = + `MERGE (gene:Gene {id: $id}) + ON CREATE SET gene.factoidId = $factoidId, + gene.name = $name, + gene.type = $type, + gene.dbId = $dbId, + gene.dbName = $dbName + RETURN gene.name`; + +export const makeRelationshipQuery = + `MATCH (x:Gene {id: $id1}) + MATCH (y:Gene {id: $id2}) + MERGE (x)-[r:INTERACTION {id: $id3}]->(y) + ON CREATE SET r.type = $type, + r.doi = $doi, + r.pmid = $pmid, + r.documentId = $documentId, + r.title = $title`; \ No newline at end of file diff --git a/src/neo4j/starting-neo4j.js b/src/neo4j/starting-neo4j.js index 787590994..c5424e0f0 100644 --- a/src/neo4j/starting-neo4j.js +++ b/src/neo4j/starting-neo4j.js @@ -1,35 +1,10 @@ -// const neo4j = require('neo4j-driver'); <-- old, read up on imports and exports in book import neo4j from 'neo4j-driver'; +import { makeNodeQuery, makeRelationshipQuery } from './query-strings'; +import { nodeData, relationshipData } from './graph-data'; const driver = neo4j.driver('bolt://localhost:7687'); -// Format of nodeData are as follows: -// { id: 'element.association.dbPrefix'+ ':' + 'element.association.id', factoidId: 'element.id', -// name: 'element.name', type: 'element.type', dbId: 'element.association.id', -// dbName: "element.association.dbName"} -const nodeData = [ - // MAPK6 data - { - id: 'ncbigene:5597', factoidId: '598f8bef-f858-4dd0-b1c6-5168a8ae5349', name: 'MAPK6', - type: 'protein', dbId: '5597', dbName: 'NCBI Gene' - }, - // AKT data - { - id: 'ncbigene:207', factoidId: '4081348e-20b8-4bf8-836f-695827a4f9a2', name: 'AKT', - type: 'protein', dbId: '207', dbName: 'NCBI Gene' - } -]; - -const makeNodeQuery = - `MERGE (gene:Gene {id: $id}) - ON CREATE SET gene.factoidId = $factoidId, - gene.name = $name, - gene.type = $type, - gene.dbId = $dbId, - gene.dbName = $dbName - RETURN gene.name`; - -// this test makes the MAPK6 node +// this test makes the MAPK6 node. Successful export async function makeMAPK6Test() { let session; try { @@ -40,13 +15,13 @@ export async function makeMAPK6Test() { console.error(error); throw error; } finally { - session.close(); - driver.close(); + session.close(); + driver.close(); } + return; } -// this test does as I want (make both nodes at once) but it doesn't -// exit by itself (need to use Ctrl-C) +// this test does as I want (make both nodes at once) but it doesn't exit by itself (need to use Ctrl-C) export async function makeGeneNodeTest() { //let session; for (let i = 0; i < nodeData.length; i++) { @@ -54,7 +29,7 @@ export async function makeGeneNodeTest() { try { session = driver.session({ database: "neo4j" }); let result = await session.run(makeNodeQuery, nodeData[i]); - console.log("Gene Node created"); + console.log("Gene Node created: ", result.records); session.close(); } catch (error) { console.error(error); @@ -63,31 +38,12 @@ export async function makeGeneNodeTest() { throw error; } } + console.log("Loop ends!"); + return; } -// Parameters of relationshipData are as follows: -// { id1: 'element.association.dbPrefix'+ ':' + 'element.association.id', -// id2: 'element.association.dbPrefix'+ ':' + 'element.association.id', id3: 'element.id', -// type: 'element.type', doi: 'value.citation.doi', -// pmid: 'value.citation.pmid', documentId: 'value.id', title: 'value.citation.title'} -const relationshipData = [{ - id1: 'ncbigene:5597', id2: 'ncbigene:207', id3: '01ef22cc-2a8e-46d4-9060-6bf1c273869b', - type: 'phosphorylation', doi: '10.1126/sciadv.abi6439', pmid: '34767444', - documentId: 'a896d611-affe-4b45-a5e1-9bc560ffceab', - title: 'MAPK6-AKT signaling promotes tumor growth and resistance to mTOR kinase blockade.' -}]; - -const makeRelationshipQuery = - `MATCH (x:Gene {id: $id1}) - MATCH (y:Gene {id: $id2}) - MERGE (x)-[r:INTERACTION {id: $id3}]->(y) - ON CREATE SET r.type = $type, - r.doi = $doi, - r.pmid = $pmid, - r.documentId = $documentId, - r.title = $title`; - -export async function test() { // This test does not yet work!!! +// This test does not yet work!!! +export async function test() { const session = driver.session({ database: "neo4j" }); await session .beginTransaction() From 970a0fabdad5148535844d5e5231fec57e88ce09 Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Mon, 13 Feb 2023 10:50:08 -0500 Subject: [PATCH 16/43] makeGeneNodeTest now works --- src/neo4j/starting-neo4j.js | 14 +++++++------- src/neo4j/test-temp-run.js | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/neo4j/starting-neo4j.js b/src/neo4j/starting-neo4j.js index c5424e0f0..3db595730 100644 --- a/src/neo4j/starting-neo4j.js +++ b/src/neo4j/starting-neo4j.js @@ -9,19 +9,19 @@ export async function makeMAPK6Test() { let session; try { session = driver.session({ database: "neo4j" }); - let result = await session.run(makeNodeQuery, nodeData[0]); - console.log("Gene Node created:", result.records[0].get(0)); + let result = await session.executeWrite(makeNodeQuery, nodeData[0]); + console.log("Gene Node created:", result.records[0].get('gene.name')); } catch (error) { console.error(error); throw error; } finally { - session.close(); + await session.close(); driver.close(); } return; } -// this test does as I want (make both nodes at once) but it doesn't exit by itself (need to use Ctrl-C) +// this test makes both the MAPK6 node and the AKT node, then terminates successfully export async function makeGeneNodeTest() { //let session; for (let i = 0; i < nodeData.length; i++) { @@ -30,14 +30,14 @@ export async function makeGeneNodeTest() { session = driver.session({ database: "neo4j" }); let result = await session.run(makeNodeQuery, nodeData[i]); console.log("Gene Node created: ", result.records); - session.close(); + await session.close(); } catch (error) { console.error(error); - session.close(); - driver.close(); + await session.close(); throw error; } } + driver.close(); console.log("Loop ends!"); return; } diff --git a/src/neo4j/test-temp-run.js b/src/neo4j/test-temp-run.js index 715009181..de2488486 100644 --- a/src/neo4j/test-temp-run.js +++ b/src/neo4j/test-temp-run.js @@ -2,7 +2,8 @@ import { makeMAPK6Test, makeGeneNodeTest } from './starting-neo4j.js'; async function makeNodeTest() { console.log("Starting makeNodeTest"); - await makeMAPK6Test(); + //await makeMAPK6Test(); + await makeGeneNodeTest(); console.log("Finish makeNodeTest"); } From db670c6fcc7b267ca35331c672ce9c06acd823e6 Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Mon, 13 Feb 2023 11:56:39 -0500 Subject: [PATCH 17/43] using "executeWrite" in tests instead of "run" --- src/neo4j/starting-neo4j.js | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/src/neo4j/starting-neo4j.js b/src/neo4j/starting-neo4j.js index 3db595730..a88efec2f 100644 --- a/src/neo4j/starting-neo4j.js +++ b/src/neo4j/starting-neo4j.js @@ -9,7 +9,9 @@ export async function makeMAPK6Test() { let session; try { session = driver.session({ database: "neo4j" }); - let result = await session.executeWrite(makeNodeQuery, nodeData[0]); + let result = await session.executeWrite(tx => { + return tx.run(makeNodeQuery, nodeData[0]); + }); console.log("Gene Node created:", result.records[0].get('gene.name')); } catch (error) { console.error(error); @@ -23,12 +25,13 @@ export async function makeMAPK6Test() { // this test makes both the MAPK6 node and the AKT node, then terminates successfully export async function makeGeneNodeTest() { - //let session; for (let i = 0; i < nodeData.length; i++) { let session; try { session = driver.session({ database: "neo4j" }); - let result = await session.run(makeNodeQuery, nodeData[i]); + let result = await session.executeWrite(tx => { + return tx.run(makeNodeQuery, nodeData[i]); + }); console.log("Gene Node created: ", result.records); await session.close(); } catch (error) { @@ -42,25 +45,9 @@ export async function makeGeneNodeTest() { return; } -// This test does not yet work!!! +// This test does not yet work!!! Will make the MAPK6 node, AKT node and the relationship between them export async function test() { const session = driver.session({ database: "neo4j" }); - await session - .beginTransaction() - .then(transaction => { - transaction.run(makeNodeQuery, nodeData) // Step 1: Make the nodes - .then(result1 => { - console.log("Nodes created:", result1.summary.counters.nodesCreated); - // Step 2: Make the relationship - return transaction.run(makeRelationshipQuery, relationshipData); - }) - .then(result2 => { - console.log(result2.records.map(record => record.get("type"))); - return transaction.commit(); - }) - .then(() => { - session.close(); - driver.close(); - }); - }); + await session.close(); + return; } \ No newline at end of file From 39c28f4f4d6ef1dfb553dbbd6249d3415f4d6083 Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Mon, 13 Feb 2023 14:22:14 -0500 Subject: [PATCH 18/43] 2 node + relationship test has succeeded --- src/neo4j/starting-neo4j.js | 41 ++++++++++++++++++++++++++++++------- src/neo4j/test-temp-run.js | 5 +++-- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/neo4j/starting-neo4j.js b/src/neo4j/starting-neo4j.js index a88efec2f..776a88aa2 100644 --- a/src/neo4j/starting-neo4j.js +++ b/src/neo4j/starting-neo4j.js @@ -4,7 +4,7 @@ import { nodeData, relationshipData } from './graph-data'; const driver = neo4j.driver('bolt://localhost:7687'); -// this test makes the MAPK6 node. Successful +// makes the MAPK6 node. Successful export async function makeMAPK6Test() { let session; try { @@ -23,7 +23,7 @@ export async function makeMAPK6Test() { return; } -// this test makes both the MAPK6 node and the AKT node, then terminates successfully +// makes both the MAPK6 node and the AKT node, then terminates. Successful export async function makeGeneNodeTest() { for (let i = 0; i < nodeData.length; i++) { let session; @@ -33,11 +33,11 @@ export async function makeGeneNodeTest() { return tx.run(makeNodeQuery, nodeData[i]); }); console.log("Gene Node created: ", result.records); - await session.close(); } catch (error) { console.error(error); - await session.close(); throw error; + } finally { + await session.close(); } } driver.close(); @@ -45,9 +45,36 @@ export async function makeGeneNodeTest() { return; } -// This test does not yet work!!! Will make the MAPK6 node, AKT node and the relationship between them +// makes the MAPK6 node, AKT node and the relationship between them. Successful export async function test() { - const session = driver.session({ database: "neo4j" }); - await session.close(); + let session; + try { + session = driver.session({ database: "neo4j" }); + const tx = session.beginTransaction(); + try { + // Step 1: Make the nodes + for (let i = 0; i < nodeData.length; i++) { + let result = await tx.run(makeNodeQuery, nodeData[i]); + console.log("Gene Node created: ", result.records); + } + + // Step 2: Make the relationship + tx.run(makeRelationshipQuery, relationshipData[0]); + console.log ("Relationship made!"); + + // Step 3: Commit the transactions + await tx.commit(); + } catch(error) { + await tx.rollback(); + console.error(error); + throw error; + } + } catch(error) { + console.error(error); + throw error; + } finally { + await session.close(); + } + driver.close(); return; } \ No newline at end of file diff --git a/src/neo4j/test-temp-run.js b/src/neo4j/test-temp-run.js index de2488486..79bea1ad8 100644 --- a/src/neo4j/test-temp-run.js +++ b/src/neo4j/test-temp-run.js @@ -1,9 +1,10 @@ -import { makeMAPK6Test, makeGeneNodeTest } from './starting-neo4j.js'; +import { test, makeMAPK6Test, makeGeneNodeTest } from './starting-neo4j.js'; async function makeNodeTest() { console.log("Starting makeNodeTest"); //await makeMAPK6Test(); - await makeGeneNodeTest(); + //await makeGeneNodeTest(); + await test(); console.log("Finish makeNodeTest"); } From 9378be3573c9ccf970c3b7487bf120206a3419a2 Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Mon, 13 Feb 2023 16:45:31 -0500 Subject: [PATCH 19/43] read1() test for primary use case works --- src/neo4j/query-strings.js | 9 ++++++++- src/neo4j/starting-neo4j.js | 26 ++++++++++++++++++++++++-- src/neo4j/test-temp-run.js | 5 +++-- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/neo4j/query-strings.js b/src/neo4j/query-strings.js index 1b36bfa49..c994861a0 100644 --- a/src/neo4j/query-strings.js +++ b/src/neo4j/query-strings.js @@ -15,4 +15,11 @@ export const makeRelationshipQuery = r.doi = $doi, r.pmid = $pmid, r.documentId = $documentId, - r.title = $title`; \ No newline at end of file + r.title = $title`; + +export const giveInfoByGeneId = + `MATCH (n:Gene {id: "ncbigene:207"})<-[r]-(m) + RETURN n, r, m + UNION + MATCH (m)-[r]->(n:Gene {id: "ncbigene:207"}) + RETURN n, r, m`; \ No newline at end of file diff --git a/src/neo4j/starting-neo4j.js b/src/neo4j/starting-neo4j.js index 776a88aa2..bdad7b663 100644 --- a/src/neo4j/starting-neo4j.js +++ b/src/neo4j/starting-neo4j.js @@ -1,5 +1,5 @@ import neo4j from 'neo4j-driver'; -import { makeNodeQuery, makeRelationshipQuery } from './query-strings'; +import { giveInfoByGeneId, makeNodeQuery, makeRelationshipQuery } from './query-strings'; import { nodeData, relationshipData } from './graph-data'; const driver = neo4j.driver('bolt://localhost:7687'); @@ -62,7 +62,6 @@ export async function test() { tx.run(makeRelationshipQuery, relationshipData[0]); console.log ("Relationship made!"); - // Step 3: Commit the transactions await tx.commit(); } catch(error) { await tx.rollback(); @@ -77,4 +76,27 @@ export async function test() { } driver.close(); return; +} + +// this test reads the database. Use case of: user gives "ncbigene:207" and +// the database returns all nodes and relationships connected to it +export async function read1() { + let session; + try { + session = driver.session({ database: "neo4j" }); + let result = await session.executeRead(tx => { + return tx.run(giveInfoByGeneId, { id: 'ncbigene:207' }); + }); + let names = result.records.map(row => { + return row.get('m'); + }); + console.log(names); + } catch (error) { + console.error(error); + throw error; + } finally { + await session.close(); + driver.close(); + } + return; } \ No newline at end of file diff --git a/src/neo4j/test-temp-run.js b/src/neo4j/test-temp-run.js index 79bea1ad8..965af9f2d 100644 --- a/src/neo4j/test-temp-run.js +++ b/src/neo4j/test-temp-run.js @@ -1,10 +1,11 @@ -import { test, makeMAPK6Test, makeGeneNodeTest } from './starting-neo4j.js'; +import { read1, test, makeMAPK6Test, makeGeneNodeTest } from './starting-neo4j.js'; async function makeNodeTest() { console.log("Starting makeNodeTest"); //await makeMAPK6Test(); //await makeGeneNodeTest(); - await test(); + //await test(); + await read1(); console.log("Finish makeNodeTest"); } From c2e484e099f90263c016703961d639262ea766b6 Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Tue, 14 Feb 2023 10:40:44 -0500 Subject: [PATCH 20/43] Made addNode, addEdge. addNode works confirmed --- src/neo4j/neo4j-functions.js | 60 ++++++++++++++++++++++++++++++++++++ src/neo4j/test-temp-run.js | 24 +++++++++++++-- 2 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 src/neo4j/neo4j-functions.js diff --git a/src/neo4j/neo4j-functions.js b/src/neo4j/neo4j-functions.js new file mode 100644 index 000000000..aa55468d9 --- /dev/null +++ b/src/neo4j/neo4j-functions.js @@ -0,0 +1,60 @@ +import neo4j from 'neo4j-driver'; +import { giveInfoByGeneId, makeNodeQuery, makeRelationshipQuery } from './query-strings'; + +export async function addNode(params) { + const driver = neo4j.driver('bolt://localhost:7687'); + let session; + try { + session = driver.session({ database: "neo4j" }); + let result = await session.executeWrite(tx => { + return tx.run(makeNodeQuery, params); + }); + } catch (error) { + console.error(error); + throw error; + } finally { + await session.close(); + driver.close(); + } + return; +} + +export async function addEdge(params) { + const driver = neo4j.driver('bolt://localhost:7687'); + let session; + try { + session = driver.session({ database: "neo4j" }); + let result = await session.executeWrite(tx => { + return tx.run(makeRelationshipQuery, params); + }); + } catch (error) { + console.error(error); + throw error; + } finally { + await session.close(); + driver.close(); + } + return; +} + +export async function searchByGeneId(id) { + const driver = neo4j.driver('bolt://localhost:7687'); + let session; + try { + session = driver.session({ database: "neo4j" }); + let result = await session.executeRead(tx => { + return tx.run(giveInfoByGeneId, { id: id }); + }); + let names = result.records.map(row => { + return row.get('m'); + }); + return names; + } catch (error) { + console.error(error); + throw error; + } finally { + await session.close(); + driver.close(); + } + return; +} \ No newline at end of file diff --git a/src/neo4j/test-temp-run.js b/src/neo4j/test-temp-run.js index 965af9f2d..025ac7b7f 100644 --- a/src/neo4j/test-temp-run.js +++ b/src/neo4j/test-temp-run.js @@ -1,6 +1,7 @@ import { read1, test, makeMAPK6Test, makeGeneNodeTest } from './starting-neo4j.js'; +import { addNode, addEdge, searchByGeneId } from './neo4j-functions'; -async function makeNodeTest() { +async function makeNodeTest() { // eslint-disable-line no-unused-vars console.log("Starting makeNodeTest"); //await makeMAPK6Test(); //await makeGeneNodeTest(); @@ -9,4 +10,23 @@ async function makeNodeTest() { console.log("Finish makeNodeTest"); } -makeNodeTest(); \ No newline at end of file +async function testingAddFunctions() { + console.log("Begin test"); + // Add MAPK6 Node + await addNode({ + id: 'ncbigene:5597', factoidId: '598f8bef-f858-4dd0-b1c6-5168a8ae5349', name: 'MAPK6', + type: 'protein', dbId: '5597', dbName: 'NCBI Gene' + }) + + // Add AKT Node + await addNode({ + id: 'ncbigene:207', factoidId: '4081348e-20b8-4bf8-836f-695827a4f9a2', name: 'AKT', + type: 'protein', dbId: '207', dbName: 'NCBI Gene' + }) + + // Add Interaction + + console.log("End test"); +} + +testingAddFunctions(); \ No newline at end of file From 32106158caf9eeb39cb91b86fcd4f0b26f24a9dc Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Tue, 14 Feb 2023 11:09:12 -0500 Subject: [PATCH 21/43] addEdge and searchByGeneId work confirmed --- src/neo4j/neo4j-functions.js | 1 + src/neo4j/query-strings.js | 4 ++-- src/neo4j/test-temp-run.js | 23 +++++++++++++++++------ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/neo4j/neo4j-functions.js b/src/neo4j/neo4j-functions.js index aa55468d9..500878da6 100644 --- a/src/neo4j/neo4j-functions.js +++ b/src/neo4j/neo4j-functions.js @@ -48,6 +48,7 @@ export async function searchByGeneId(id) { let names = result.records.map(row => { return row.get('m'); }); + console.log(names); return names; } catch (error) { console.error(error); diff --git a/src/neo4j/query-strings.js b/src/neo4j/query-strings.js index c994861a0..ecc55bd50 100644 --- a/src/neo4j/query-strings.js +++ b/src/neo4j/query-strings.js @@ -18,8 +18,8 @@ export const makeRelationshipQuery = r.title = $title`; export const giveInfoByGeneId = - `MATCH (n:Gene {id: "ncbigene:207"})<-[r]-(m) + `MATCH (n:Gene {id: $id})<-[r]-(m) RETURN n, r, m UNION - MATCH (m)-[r]->(n:Gene {id: "ncbigene:207"}) + MATCH (n:Gene {id: $id})-[r]->(m) RETURN n, r, m`; \ No newline at end of file diff --git a/src/neo4j/test-temp-run.js b/src/neo4j/test-temp-run.js index 025ac7b7f..414cb3ffd 100644 --- a/src/neo4j/test-temp-run.js +++ b/src/neo4j/test-temp-run.js @@ -3,9 +3,9 @@ import { addNode, addEdge, searchByGeneId } from './neo4j-functions'; async function makeNodeTest() { // eslint-disable-line no-unused-vars console.log("Starting makeNodeTest"); - //await makeMAPK6Test(); - //await makeGeneNodeTest(); - //await test(); + await makeMAPK6Test(); + await makeGeneNodeTest(); + await test(); await read1(); console.log("Finish makeNodeTest"); } @@ -16,16 +16,27 @@ async function testingAddFunctions() { await addNode({ id: 'ncbigene:5597', factoidId: '598f8bef-f858-4dd0-b1c6-5168a8ae5349', name: 'MAPK6', type: 'protein', dbId: '5597', dbName: 'NCBI Gene' - }) + }); // Add AKT Node await addNode({ id: 'ncbigene:207', factoidId: '4081348e-20b8-4bf8-836f-695827a4f9a2', name: 'AKT', type: 'protein', dbId: '207', dbName: 'NCBI Gene' - }) + }); // Add Interaction - + await addEdge({ + id1: 'ncbigene:5597', id2: 'ncbigene:207', id3: '01ef22cc-2a8e-46d4-9060-6bf1c273869b', + type: 'phosphorylation', doi: '10.1126/sciadv.abi6439', pmid: '34767444', + documentId: 'a896d611-affe-4b45-a5e1-9bc560ffceab', + title: 'MAPK6-AKT signaling promotes tumor growth and resistance to mTOR kinase blockade.' + }); + + // Search for MAPK6 + await searchByGeneId("ncbigene:5597"); + // Search for AKT + await searchByGeneId("ncbigene:207"); + console.log("End test"); } From d945a8ef04f7fce6c4647a17c0c979af0668617e Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Tue, 14 Feb 2023 11:20:54 -0500 Subject: [PATCH 22/43] searchByGeneId prints edge info as well as node info --- src/neo4j/neo4j-functions.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/neo4j/neo4j-functions.js b/src/neo4j/neo4j-functions.js index 500878da6..70081e5a9 100644 --- a/src/neo4j/neo4j-functions.js +++ b/src/neo4j/neo4j-functions.js @@ -45,11 +45,14 @@ export async function searchByGeneId(id) { let result = await session.executeRead(tx => { return tx.run(giveInfoByGeneId, { id: id }); }); - let names = result.records.map(row => { + let nodes = result.records.map(row => { return row.get('m'); }); - console.log(names); - return names; + let edges = result.records.map(row => { + return row.get('r'); + }); + console.log(nodes); + console.log(edges); } catch (error) { console.error(error); throw error; From 4c266ebd94bc19f2092ee09f63044d1cf39dd21e Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Tue, 14 Feb 2023 11:39:30 -0500 Subject: [PATCH 23/43] updated addNode: fixed parameters, deleted factoidId --- src/neo4j/neo4j-functions.js | 10 ++++++++-- src/neo4j/query-strings.js | 3 +-- src/neo4j/test-temp-run.js | 10 ++-------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/neo4j/neo4j-functions.js b/src/neo4j/neo4j-functions.js index 70081e5a9..7b69d414b 100644 --- a/src/neo4j/neo4j-functions.js +++ b/src/neo4j/neo4j-functions.js @@ -1,13 +1,19 @@ import neo4j from 'neo4j-driver'; import { giveInfoByGeneId, makeNodeQuery, makeRelationshipQuery } from './query-strings'; -export async function addNode(params) { +export async function addNode(id, name, type, dbId, dbName) { const driver = neo4j.driver('bolt://localhost:7687'); let session; try { session = driver.session({ database: "neo4j" }); let result = await session.executeWrite(tx => { - return tx.run(makeNodeQuery, params); + return tx.run(makeNodeQuery, { + id: id, + name: name, + type: type, + dbId: dbId, + dbName: dbName + }); }); } catch (error) { console.error(error); diff --git a/src/neo4j/query-strings.js b/src/neo4j/query-strings.js index ecc55bd50..566f57ca6 100644 --- a/src/neo4j/query-strings.js +++ b/src/neo4j/query-strings.js @@ -1,7 +1,6 @@ export const makeNodeQuery = `MERGE (gene:Gene {id: $id}) - ON CREATE SET gene.factoidId = $factoidId, - gene.name = $name, + ON CREATE SET gene.name = $name, gene.type = $type, gene.dbId = $dbId, gene.dbName = $dbName diff --git a/src/neo4j/test-temp-run.js b/src/neo4j/test-temp-run.js index 414cb3ffd..8c9a61633 100644 --- a/src/neo4j/test-temp-run.js +++ b/src/neo4j/test-temp-run.js @@ -13,16 +13,10 @@ async function makeNodeTest() { // eslint-disable-line no-unused-vars async function testingAddFunctions() { console.log("Begin test"); // Add MAPK6 Node - await addNode({ - id: 'ncbigene:5597', factoidId: '598f8bef-f858-4dd0-b1c6-5168a8ae5349', name: 'MAPK6', - type: 'protein', dbId: '5597', dbName: 'NCBI Gene' - }); + await addNode('ncbigene:5597', 'MAPK6', 'protein', '5597', 'NCBI Gene'); // Add AKT Node - await addNode({ - id: 'ncbigene:207', factoidId: '4081348e-20b8-4bf8-836f-695827a4f9a2', name: 'AKT', - type: 'protein', dbId: '207', dbName: 'NCBI Gene' - }); + await addNode('ncbigene:207', 'AKT', 'protein', '207', 'NCBI Gene'); // Add Interaction await addEdge({ From ed3ca2ff46fd9ab94965e4c0c0fa4f526cf826bf Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Tue, 14 Feb 2023 11:43:03 -0500 Subject: [PATCH 24/43] updated addNode: deleted dbName and dbId from parameters --- src/neo4j/neo4j-functions.js | 4 +--- src/neo4j/query-strings.js | 2 -- src/neo4j/test-temp-run.js | 4 ++-- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/neo4j/neo4j-functions.js b/src/neo4j/neo4j-functions.js index 7b69d414b..95a43b383 100644 --- a/src/neo4j/neo4j-functions.js +++ b/src/neo4j/neo4j-functions.js @@ -1,7 +1,7 @@ import neo4j from 'neo4j-driver'; import { giveInfoByGeneId, makeNodeQuery, makeRelationshipQuery } from './query-strings'; -export async function addNode(id, name, type, dbId, dbName) { +export async function addNode(id, name, type) { const driver = neo4j.driver('bolt://localhost:7687'); let session; try { @@ -11,8 +11,6 @@ export async function addNode(id, name, type, dbId, dbName) { id: id, name: name, type: type, - dbId: dbId, - dbName: dbName }); }); } catch (error) { diff --git a/src/neo4j/query-strings.js b/src/neo4j/query-strings.js index 566f57ca6..5f4a608c8 100644 --- a/src/neo4j/query-strings.js +++ b/src/neo4j/query-strings.js @@ -2,8 +2,6 @@ export const makeNodeQuery = `MERGE (gene:Gene {id: $id}) ON CREATE SET gene.name = $name, gene.type = $type, - gene.dbId = $dbId, - gene.dbName = $dbName RETURN gene.name`; export const makeRelationshipQuery = diff --git a/src/neo4j/test-temp-run.js b/src/neo4j/test-temp-run.js index 8c9a61633..250fbd0b1 100644 --- a/src/neo4j/test-temp-run.js +++ b/src/neo4j/test-temp-run.js @@ -13,10 +13,10 @@ async function makeNodeTest() { // eslint-disable-line no-unused-vars async function testingAddFunctions() { console.log("Begin test"); // Add MAPK6 Node - await addNode('ncbigene:5597', 'MAPK6', 'protein', '5597', 'NCBI Gene'); + await addNode('ncbigene:5597', 'MAPK6', 'protein'); // Add AKT Node - await addNode('ncbigene:207', 'AKT', 'protein', '207', 'NCBI Gene'); + await addNode('ncbigene:207', 'AKT', 'protein'); // Add Interaction await addEdge({ From 47a5f90719ab4408279fab5a0f2c6c6d0951f66f Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Tue, 14 Feb 2023 12:11:26 -0500 Subject: [PATCH 25/43] updated addEdge: fixed parameters --- src/neo4j/neo4j-functions.js | 17 +++++++++++++++-- src/neo4j/query-strings.js | 13 ++++++------- src/neo4j/test-temp-run.js | 29 +++++++++++------------------ 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/src/neo4j/neo4j-functions.js b/src/neo4j/neo4j-functions.js index 95a43b383..68dbe0053 100644 --- a/src/neo4j/neo4j-functions.js +++ b/src/neo4j/neo4j-functions.js @@ -6,6 +6,7 @@ export async function addNode(id, name, type) { let session; try { session = driver.session({ database: "neo4j" }); + // eslint-disable-next-line no-unused-vars let result = await session.executeWrite(tx => { return tx.run(makeNodeQuery, { id: id, @@ -23,13 +24,25 @@ export async function addNode(id, name, type) { return; } -export async function addEdge(params) { +export async function addEdge(id, type, factoidId, sourceId, targetId, doi, pmid, + factoidDocumentId, articleTitle) { const driver = neo4j.driver('bolt://localhost:7687'); let session; try { session = driver.session({ database: "neo4j" }); + // eslint-disable-next-line no-unused-vars let result = await session.executeWrite(tx => { - return tx.run(makeRelationshipQuery, params); + return tx.run(makeRelationshipQuery, { + id: id, + type: type, + factoidId: factoidId, + sourceId: sourceId, + targetId: targetId, + doi: doi, + pmid: pmid, + factoidDocumentId: factoidDocumentId, + articleTitle: articleTitle + }); }); } catch (error) { console.error(error); diff --git a/src/neo4j/query-strings.js b/src/neo4j/query-strings.js index 5f4a608c8..9875921a0 100644 --- a/src/neo4j/query-strings.js +++ b/src/neo4j/query-strings.js @@ -1,18 +1,17 @@ export const makeNodeQuery = `MERGE (gene:Gene {id: $id}) ON CREATE SET gene.name = $name, - gene.type = $type, - RETURN gene.name`; + gene.type = $type`; export const makeRelationshipQuery = - `MATCH (x:Gene {id: $id1}) - MATCH (y:Gene {id: $id2}) - MERGE (x)-[r:INTERACTION {id: $id3}]->(y) + `MATCH (x:Gene {id: $sourceId}) + MATCH (y:Gene {id: $targetId}) + MERGE (x)-[r:INTERACTION {id: $id}]->(y) ON CREATE SET r.type = $type, r.doi = $doi, r.pmid = $pmid, - r.documentId = $documentId, - r.title = $title`; + r.factoidDocumentId = $factoidDocumentId, + r.articleTitle = $articleTitle`; export const giveInfoByGeneId = `MATCH (n:Gene {id: $id})<-[r]-(m) diff --git a/src/neo4j/test-temp-run.js b/src/neo4j/test-temp-run.js index 250fbd0b1..a41070427 100644 --- a/src/neo4j/test-temp-run.js +++ b/src/neo4j/test-temp-run.js @@ -1,16 +1,6 @@ -import { read1, test, makeMAPK6Test, makeGeneNodeTest } from './starting-neo4j.js'; import { addNode, addEdge, searchByGeneId } from './neo4j-functions'; -async function makeNodeTest() { // eslint-disable-line no-unused-vars - console.log("Starting makeNodeTest"); - await makeMAPK6Test(); - await makeGeneNodeTest(); - await test(); - await read1(); - console.log("Finish makeNodeTest"); -} - -async function testingAddFunctions() { +async function testingFunctions() { console.log("Begin test"); // Add MAPK6 Node await addNode('ncbigene:5597', 'MAPK6', 'protein'); @@ -19,12 +9,15 @@ async function testingAddFunctions() { await addNode('ncbigene:207', 'AKT', 'protein'); // Add Interaction - await addEdge({ - id1: 'ncbigene:5597', id2: 'ncbigene:207', id3: '01ef22cc-2a8e-46d4-9060-6bf1c273869b', - type: 'phosphorylation', doi: '10.1126/sciadv.abi6439', pmid: '34767444', - documentId: 'a896d611-affe-4b45-a5e1-9bc560ffceab', - title: 'MAPK6-AKT signaling promotes tumor growth and resistance to mTOR kinase blockade.' - }); + await addEdge( + '01ef22cc-2a8e-46d4-9060-6bf1c273869b', + 'phosphorylation', + '01ef22cc-2a8e-46d4-9060-6bf1c273869b', + 'ncbigene:5597', 'ncbigene:207', + '10.1126/sciadv.abi6439', '34767444', + 'a896d611-affe-4b45-a5e1-9bc560ffceab', + 'MAPK6-AKT signaling promotes tumor growth and resistance to mTOR kinase blockade.' + ); // Search for MAPK6 await searchByGeneId("ncbigene:5597"); @@ -34,4 +27,4 @@ async function testingAddFunctions() { console.log("End test"); } -testingAddFunctions(); \ No newline at end of file +testingFunctions(); \ No newline at end of file From bf35b32776994d68e793125ea3743b5c71af0a7e Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Tue, 14 Feb 2023 14:28:25 -0500 Subject: [PATCH 26/43] update addNode: delete type parameter --- src/neo4j/neo4j-functions.js | 5 ++--- src/neo4j/query-strings.js | 3 +-- src/neo4j/test-temp-run.js | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/neo4j/neo4j-functions.js b/src/neo4j/neo4j-functions.js index 68dbe0053..64fa14603 100644 --- a/src/neo4j/neo4j-functions.js +++ b/src/neo4j/neo4j-functions.js @@ -1,7 +1,7 @@ import neo4j from 'neo4j-driver'; import { giveInfoByGeneId, makeNodeQuery, makeRelationshipQuery } from './query-strings'; -export async function addNode(id, name, type) { +export async function addNode(id, name) { const driver = neo4j.driver('bolt://localhost:7687'); let session; try { @@ -10,8 +10,7 @@ export async function addNode(id, name, type) { let result = await session.executeWrite(tx => { return tx.run(makeNodeQuery, { id: id, - name: name, - type: type, + name: name }); }); } catch (error) { diff --git a/src/neo4j/query-strings.js b/src/neo4j/query-strings.js index 9875921a0..90f3b79d9 100644 --- a/src/neo4j/query-strings.js +++ b/src/neo4j/query-strings.js @@ -1,7 +1,6 @@ export const makeNodeQuery = `MERGE (gene:Gene {id: $id}) - ON CREATE SET gene.name = $name, - gene.type = $type`; + ON CREATE SET gene.name = $name`; export const makeRelationshipQuery = `MATCH (x:Gene {id: $sourceId}) diff --git a/src/neo4j/test-temp-run.js b/src/neo4j/test-temp-run.js index a41070427..4393cd1cf 100644 --- a/src/neo4j/test-temp-run.js +++ b/src/neo4j/test-temp-run.js @@ -3,10 +3,10 @@ import { addNode, addEdge, searchByGeneId } from './neo4j-functions'; async function testingFunctions() { console.log("Begin test"); // Add MAPK6 Node - await addNode('ncbigene:5597', 'MAPK6', 'protein'); + await addNode('ncbigene:5597', 'MAPK6'); // Add AKT Node - await addNode('ncbigene:207', 'AKT', 'protein'); + await addNode('ncbigene:207', 'AKT'); // Add Interaction await addEdge( From 2f5478caab283eaaa3fb2ce2da6c082a2eff7e79 Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Tue, 14 Feb 2023 14:48:18 -0500 Subject: [PATCH 27/43] sanitized ids to always be lower case --- src/neo4j/neo4j-functions.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/neo4j/neo4j-functions.js b/src/neo4j/neo4j-functions.js index 64fa14603..daf51c508 100644 --- a/src/neo4j/neo4j-functions.js +++ b/src/neo4j/neo4j-functions.js @@ -9,7 +9,7 @@ export async function addNode(id, name) { // eslint-disable-next-line no-unused-vars let result = await session.executeWrite(tx => { return tx.run(makeNodeQuery, { - id: id, + id: id.toLowerCase(), name: name }); }); @@ -32,14 +32,14 @@ export async function addEdge(id, type, factoidId, sourceId, targetId, doi, pmid // eslint-disable-next-line no-unused-vars let result = await session.executeWrite(tx => { return tx.run(makeRelationshipQuery, { - id: id, + id: id.toLowerCase(), type: type, - factoidId: factoidId, - sourceId: sourceId, - targetId: targetId, + factoidId: factoidId.toLowerCase(), + sourceId: sourceId.toLowerCase(), + targetId: targetId.toLowerCase(), doi: doi, pmid: pmid, - factoidDocumentId: factoidDocumentId, + factoidDocumentId: factoidDocumentId.toLowerCase(), articleTitle: articleTitle }); }); From c1dfb2df6eb4604ea0aa4e5f358a1691329a1d2d Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Wed, 15 Feb 2023 10:58:19 -0500 Subject: [PATCH 28/43] driver functions added --- src/neo4j/neo4j-driver.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/neo4j/neo4j-driver.js diff --git a/src/neo4j/neo4j-driver.js b/src/neo4j/neo4j-driver.js new file mode 100644 index 000000000..d4bc7921b --- /dev/null +++ b/src/neo4j/neo4j-driver.js @@ -0,0 +1,17 @@ +import neo4j from 'neo4j-driver'; + +let driver; + +export function initDriver() { + driver = neo4j.driver('bolt://localhost:7687'); + return driver.verifyConnectivity() + .then( () => driver); +} + +export function getDriver() { + return driver; +} + +export function closeDriver() { + return driver && driver.close(); +} From 8827681e2898a5a243ef6f85e28cc758b754f426 Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Wed, 15 Feb 2023 11:14:36 -0500 Subject: [PATCH 29/43] updated addEdge: xref instead of factoidId/factoidDocumentId --- src/neo4j/neo4j-functions.js | 6 ++---- src/neo4j/query-strings.js | 2 +- src/neo4j/test-temp-run.js | 7 ++++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/neo4j/neo4j-functions.js b/src/neo4j/neo4j-functions.js index daf51c508..81e7b2c4c 100644 --- a/src/neo4j/neo4j-functions.js +++ b/src/neo4j/neo4j-functions.js @@ -23,8 +23,7 @@ export async function addNode(id, name) { return; } -export async function addEdge(id, type, factoidId, sourceId, targetId, doi, pmid, - factoidDocumentId, articleTitle) { +export async function addEdge(id, type, sourceId, targetId, xref, doi, pmid, articleTitle) { const driver = neo4j.driver('bolt://localhost:7687'); let session; try { @@ -34,12 +33,11 @@ export async function addEdge(id, type, factoidId, sourceId, targetId, doi, pmid return tx.run(makeRelationshipQuery, { id: id.toLowerCase(), type: type, - factoidId: factoidId.toLowerCase(), sourceId: sourceId.toLowerCase(), targetId: targetId.toLowerCase(), + xref: xref.toLowerCase(), doi: doi, pmid: pmid, - factoidDocumentId: factoidDocumentId.toLowerCase(), articleTitle: articleTitle }); }); diff --git a/src/neo4j/query-strings.js b/src/neo4j/query-strings.js index 90f3b79d9..03de2fa86 100644 --- a/src/neo4j/query-strings.js +++ b/src/neo4j/query-strings.js @@ -7,9 +7,9 @@ export const makeRelationshipQuery = MATCH (y:Gene {id: $targetId}) MERGE (x)-[r:INTERACTION {id: $id}]->(y) ON CREATE SET r.type = $type, + r.xref = $xref, r.doi = $doi, r.pmid = $pmid, - r.factoidDocumentId = $factoidDocumentId, r.articleTitle = $articleTitle`; export const giveInfoByGeneId = diff --git a/src/neo4j/test-temp-run.js b/src/neo4j/test-temp-run.js index 4393cd1cf..3d86b96e4 100644 --- a/src/neo4j/test-temp-run.js +++ b/src/neo4j/test-temp-run.js @@ -12,10 +12,11 @@ async function testingFunctions() { await addEdge( '01ef22cc-2a8e-46d4-9060-6bf1c273869b', 'phosphorylation', - '01ef22cc-2a8e-46d4-9060-6bf1c273869b', - 'ncbigene:5597', 'ncbigene:207', - '10.1126/sciadv.abi6439', '34767444', + 'ncbigene:5597', + 'ncbigene:207', 'a896d611-affe-4b45-a5e1-9bc560ffceab', + '10.1126/sciadv.abi6439', + '34767444', 'MAPK6-AKT signaling promotes tumor growth and resistance to mTOR kinase blockade.' ); From 96a5264207e677e7fe1ec3504a5e91790f67291b Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Wed, 15 Feb 2023 17:13:12 -0500 Subject: [PATCH 30/43] integrated the new driver functions in code --- src/neo4j/neo4j-functions.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/neo4j/neo4j-functions.js b/src/neo4j/neo4j-functions.js index 81e7b2c4c..ad3f53a4f 100644 --- a/src/neo4j/neo4j-functions.js +++ b/src/neo4j/neo4j-functions.js @@ -1,8 +1,10 @@ import neo4j from 'neo4j-driver'; import { giveInfoByGeneId, makeNodeQuery, makeRelationshipQuery } from './query-strings'; +import { closeDriver, getDriver, initDriver } from './neo4j-driver'; export async function addNode(id, name) { - const driver = neo4j.driver('bolt://localhost:7687'); + initDriver(); + const driver = getDriver(); let session; try { session = driver.session({ database: "neo4j" }); @@ -18,13 +20,14 @@ export async function addNode(id, name) { throw error; } finally { await session.close(); - driver.close(); + closeDriver(); } return; } export async function addEdge(id, type, sourceId, targetId, xref, doi, pmid, articleTitle) { - const driver = neo4j.driver('bolt://localhost:7687'); + initDriver(); + const driver = getDriver(); let session; try { session = driver.session({ database: "neo4j" }); @@ -46,13 +49,14 @@ export async function addEdge(id, type, sourceId, targetId, xref, doi, pmid, art throw error; } finally { await session.close(); - driver.close(); + closeDriver(); } return; } export async function searchByGeneId(id) { - const driver = neo4j.driver('bolt://localhost:7687'); + initDriver(); + const driver = getDriver(); let session; try { session = driver.session({ database: "neo4j" }); @@ -72,7 +76,7 @@ export async function searchByGeneId(id) { throw error; } finally { await session.close(); - driver.close(); + closeDriver(); } return; } \ No newline at end of file From 4d36f408f7d1c7d5f9af64a5365a15e61155b2ef Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Wed, 15 Feb 2023 17:16:20 -0500 Subject: [PATCH 31/43] made first test (not yet run successfully) --- test/neo4j/connect-neo4j.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/neo4j/connect-neo4j.js diff --git a/test/neo4j/connect-neo4j.js b/test/neo4j/connect-neo4j.js new file mode 100644 index 000000000..4621818ab --- /dev/null +++ b/test/neo4j/connect-neo4j.js @@ -0,0 +1,37 @@ +//import { config } from 'dotenv'; +import { expect } from 'chai'; +import { closeDriver, getDriver, initDriver } from '../../src/neo4j/neo4j-driver.js'; + +describe('01. Initiate Driver', () => { + //beforeAll(() => config()); + //afterAll(() => closeDriver()); + + it('Should create a driver instance and connect to server', async () => { + await initDriver(); + }); + + it('Driver has been instantiated', () => { + const driver = getDriver(); + expect(driver).toBeDefined(); + + expect(driver.constructor.name).toEqual('Driver'); + }); + + it('Driver can verify connectivity', () => { + const driver = getDriver(); + expect(driver).toBeDefined(); + expect(driver.constructor.name).toEqual('Driver'); + + driver.verifyConnectivity() + .then(() => { + expect(true).toEqual(true); + }) + .catch(e => { + expect(e).toBeUndefined('Unable to verify connectivity'); + }); + }); + + it('Close the Driver', () => { + closeDriver(); + }); +}); \ No newline at end of file From c8f176646a43fbc9df9b291756a7417504470d58 Mon Sep 17 00:00:00 2001 From: "Linda (Jia Wen) Li" Date: Thu, 16 Feb 2023 10:26:29 -0500 Subject: [PATCH 32/43] more work on tests --- .eslintrc.json | 4 ++- {test/neo4j => neo4j-test}/connect-neo4j.js | 3 ++- neo4j-test/example.js | 29 +++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) rename {test/neo4j => neo4j-test}/connect-neo4j.js (91%) create mode 100644 neo4j-test/example.js diff --git a/.eslintrc.json b/.eslintrc.json index a9f862ad9..e983e3663 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -18,6 +18,8 @@ ], "rules": { - "semi": "error" + "semi": "error", + "no-console": "warn", + "no-unused-vars": "warn" } } diff --git a/test/neo4j/connect-neo4j.js b/neo4j-test/connect-neo4j.js similarity index 91% rename from test/neo4j/connect-neo4j.js rename to neo4j-test/connect-neo4j.js index 4621818ab..ab4489ed8 100644 --- a/test/neo4j/connect-neo4j.js +++ b/neo4j-test/connect-neo4j.js @@ -1,6 +1,7 @@ //import { config } from 'dotenv'; import { expect } from 'chai'; -import { closeDriver, getDriver, initDriver } from '../../src/neo4j/neo4j-driver.js'; + +import { closeDriver, getDriver, initDriver } from '../src/neo4j/neo4j-driver.js'; describe('01. Initiate Driver', () => { //beforeAll(() => config()); diff --git a/neo4j-test/example.js b/neo4j-test/example.js new file mode 100644 index 000000000..1f4319a1a --- /dev/null +++ b/neo4j-test/example.js @@ -0,0 +1,29 @@ +describe('Example set of tests', function () { + before(function () { + + }); + + after(function () { + + }); + + beforeEach(function () { + + }); + + afterEach(function () { + + }); + + it('does something', function () { + + }); + + it('does something else', function () { + + }); + + it('does something completely different', function () { + + }); +}); \ No newline at end of file From b00479def6b5b82ea13478da363eb5b4f427c1e5 Mon Sep 17 00:00:00 2001 From: Jeffrey Wong Date: Thu, 16 Feb 2023 17:39:14 -0500 Subject: [PATCH 33/43] Configuration for graph db. --- README.md | 6 ++++++ src/config.js | 7 +++++++ src/neo4j/neo4j-driver.js | 32 +++++++++++++++++++++++++------- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 741de45e4..7f2ad84c7 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,12 @@ AppSignal: - `APPSIGNAL_APP_NAME` : name of this app (e.g. 'Biofactoid') - `APPSIGNAL_APP_ENV` : used to indicate which instance is running (e.g 'master', 'production', 'unstable') +Graph Database: + +- `GRAPHDB_CONN` : The connection string +- `GRAPHDB_USER` : Authentication username +- `GRAPHDB_PASS` : Authentication password + The following environment variables should always be set in production instances: - `NODE_ENV` : set to `production` diff --git a/src/config.js b/src/config.js index 70bdb5624..ace3cd678 100644 --- a/src/config.js +++ b/src/config.js @@ -138,3 +138,10 @@ export const MIN_RELATED_PAPERS = env('MIN_RELATED_PAPERS', 6); // google analytics // google tag manager export const GTM_ID = env('GTM_ID', 'GTM-NV468LC'); + +// Graph Database +export const GRAPHDB_CONN = env('GRAPHDB_CONN', 'bolt://localhost:7687'); +export const GRAPHDB_USER = env('GRAPHDB_USER', undefined); +export const GRAPHDB_PASS = env('GRAPHDB_PASS', undefined); +export const GRAPHDB_DBNAME = env('GRAPHDB_DBNAME', 'factoid'); + diff --git a/src/neo4j/neo4j-driver.js b/src/neo4j/neo4j-driver.js index d4bc7921b..73e22bf97 100644 --- a/src/neo4j/neo4j-driver.js +++ b/src/neo4j/neo4j-driver.js @@ -1,17 +1,35 @@ import neo4j from 'neo4j-driver'; +import { GRAPHDB_CONN, GRAPHDB_USER, GRAPHDB_PASS } from '../config'; let driver; -export function initDriver() { - driver = neo4j.driver('bolt://localhost:7687'); - return driver.verifyConnectivity() - .then( () => driver); +/** + * Initialize the Neo4j driver singleton + * + * @returns Neo4j driver instance + */ +export async function initDriver() { + driver = neo4j.driver( GRAPHDB_CONN, + neo4j.auth.basic( GRAPHDB_USER, GRAPHDB_PASS ) + ); + await driver.verifyConnectivity(); + return driver; } +/** + * Retrieve the Neo4j driver instance + * + * @returns Neo4j driver instance, possibly undefined + */ export function getDriver() { - return driver; + return driver; } -export function closeDriver() { - return driver && driver.close(); +/** + * Close the Neo4j driver instance + * + * @returns Promise + */ +export async function closeDriver() { + return driver && driver.close(); } From 5421cbcbe608ee4e338d6a142411e4227737edfd Mon Sep 17 00:00:00 2001 From: Jeffrey Wong Date: Thu, 16 Feb 2023 17:42:58 -0500 Subject: [PATCH 34/43] Docs --- src/neo4j/neo4j-driver.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/neo4j/neo4j-driver.js b/src/neo4j/neo4j-driver.js index 73e22bf97..eca93f9a9 100644 --- a/src/neo4j/neo4j-driver.js +++ b/src/neo4j/neo4j-driver.js @@ -6,7 +6,7 @@ let driver; /** * Initialize the Neo4j driver singleton * - * @returns Neo4j driver instance + * @returns Promise */ export async function initDriver() { driver = neo4j.driver( GRAPHDB_CONN, @@ -19,7 +19,7 @@ export async function initDriver() { /** * Retrieve the Neo4j driver instance * - * @returns Neo4j driver instance, possibly undefined + * @returns Neo4j driver instance or undefined */ export function getDriver() { return driver; From a90a660275db0bf5a8926f063b95ad79ba4adb1b Mon Sep 17 00:00:00 2001 From: Jeffrey Wong Date: Thu, 16 Feb 2023 17:56:15 -0500 Subject: [PATCH 35/43] Initiate the driver in get --- src/neo4j/neo4j-driver.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/neo4j/neo4j-driver.js b/src/neo4j/neo4j-driver.js index eca93f9a9..f82b8b0fb 100644 --- a/src/neo4j/neo4j-driver.js +++ b/src/neo4j/neo4j-driver.js @@ -6,23 +6,26 @@ let driver; /** * Initialize the Neo4j driver singleton * - * @returns Promise + * @returns Promise resolving to Neo4j Driver instance */ export async function initDriver() { driver = neo4j.driver( GRAPHDB_CONN, neo4j.auth.basic( GRAPHDB_USER, GRAPHDB_PASS ) ); - await driver.verifyConnectivity(); return driver; } /** - * Retrieve the Neo4j driver instance + * Retrieve the Neo4j driver instance, create if not exists * - * @returns Neo4j driver instance or undefined + * @returns Promise resolving to Neo4j Driver instance */ -export function getDriver() { - return driver; +export async function getDriver() { + if( !driver ){ + await initDriver(); + } else { + return driver; + } } /** From fd9f870b8c9d0eb77816872761145ae8f3fdd556 Mon Sep 17 00:00:00 2001 From: Jeffrey Wong Date: Thu, 16 Feb 2023 18:05:57 -0500 Subject: [PATCH 36/43] Tests --- neo4j-test/connect-neo4j.js | 42 ++++++++++++------------------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/neo4j-test/connect-neo4j.js b/neo4j-test/connect-neo4j.js index ab4489ed8..5f69c1417 100644 --- a/neo4j-test/connect-neo4j.js +++ b/neo4j-test/connect-neo4j.js @@ -1,38 +1,22 @@ -//import { config } from 'dotenv'; import { expect } from 'chai'; +import neo4j from 'neo4j-driver'; import { closeDriver, getDriver, initDriver } from '../src/neo4j/neo4j-driver.js'; describe('01. Initiate Driver', () => { - //beforeAll(() => config()); - //afterAll(() => closeDriver()); - it('Should create a driver instance and connect to server', async () => { - await initDriver(); - }); + it('initDriver Should initialize and return a driver', async () => { + const driver = await initDriver(); + expect(driver).an.instanceof(neo4j.Driver); + }); - it('Driver has been instantiated', () => { - const driver = getDriver(); - expect(driver).toBeDefined(); + it('getDriver should initialize and/or return the driver', async () => { + const driver = await getDriver(); + expect(driver).not.to.be.undefined; + }); - expect(driver.constructor.name).toEqual('Driver'); - }); - - it('Driver can verify connectivity', () => { - const driver = getDriver(); - expect(driver).toBeDefined(); - expect(driver.constructor.name).toEqual('Driver'); - - driver.verifyConnectivity() - .then(() => { - expect(true).toEqual(true); - }) - .catch(e => { - expect(e).toBeUndefined('Unable to verify connectivity'); - }); - }); - - it('Close the Driver', () => { - closeDriver(); - }); + it('closeDriver should remove driver instance', async () => { + const driver = await closeDriver(); + expect(driver).to.be.undefined; + }); }); \ No newline at end of file From a166870f6b591a146d25dd3f0a1c62bbd7185688 Mon Sep 17 00:00:00 2001 From: Jeffrey Wong Date: Thu, 16 Feb 2023 18:22:09 -0500 Subject: [PATCH 37/43] Optional config for initDriver --- src/neo4j/neo4j-driver.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/neo4j/neo4j-driver.js b/src/neo4j/neo4j-driver.js index f82b8b0fb..773f2fb20 100644 --- a/src/neo4j/neo4j-driver.js +++ b/src/neo4j/neo4j-driver.js @@ -6,11 +6,13 @@ let driver; /** * Initialize the Neo4j driver singleton * - * @returns Promise resolving to Neo4j Driver instance + * @param {object} config additional configuration + * @returns Promise resolving to Neo4j {@link https://neo4j.com/docs/api/javascript-driver/current/class/lib6/driver.js~Driver.html Driver} instance */ -export async function initDriver() { +export async function initDriver( config = {} ) { driver = neo4j.driver( GRAPHDB_CONN, - neo4j.auth.basic( GRAPHDB_USER, GRAPHDB_PASS ) + neo4j.auth.basic( GRAPHDB_USER, GRAPHDB_PASS ), + config ); return driver; } From b63006d3eae5e2fe537d51c4148f944e1e108363 Mon Sep 17 00:00:00 2001 From: Jeffrey Wong Date: Thu, 16 Feb 2023 18:26:36 -0500 Subject: [PATCH 38/43] The getter should just return the existing driver singleton --- neo4j-test/connect-neo4j.js | 3 ++- src/neo4j/neo4j-driver.js | 12 ++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/neo4j-test/connect-neo4j.js b/neo4j-test/connect-neo4j.js index 5f69c1417..37b848852 100644 --- a/neo4j-test/connect-neo4j.js +++ b/neo4j-test/connect-neo4j.js @@ -11,7 +11,8 @@ describe('01. Initiate Driver', () => { }); it('getDriver should initialize and/or return the driver', async () => { - const driver = await getDriver(); + await initDriver(); + const driver = getDriver(); expect(driver).not.to.be.undefined; }); diff --git a/src/neo4j/neo4j-driver.js b/src/neo4j/neo4j-driver.js index 773f2fb20..77635ce2f 100644 --- a/src/neo4j/neo4j-driver.js +++ b/src/neo4j/neo4j-driver.js @@ -18,16 +18,12 @@ export async function initDriver( config = {} ) { } /** - * Retrieve the Neo4j driver instance, create if not exists + * Retrieve the Neo4j driver instance * - * @returns Promise resolving to Neo4j Driver instance + * @returns The Neo4j Driver instance */ -export async function getDriver() { - if( !driver ){ - await initDriver(); - } else { - return driver; - } +export function getDriver() { + return driver; } /** From aaac9a1056a06198fddae72cf0b584a689f0cddb Mon Sep 17 00:00:00 2001 From: Jeffrey Wong Date: Thu, 16 Feb 2023 18:27:13 -0500 Subject: [PATCH 39/43] Test --- neo4j-test/connect-neo4j.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neo4j-test/connect-neo4j.js b/neo4j-test/connect-neo4j.js index 37b848852..6929904d9 100644 --- a/neo4j-test/connect-neo4j.js +++ b/neo4j-test/connect-neo4j.js @@ -13,7 +13,7 @@ describe('01. Initiate Driver', () => { it('getDriver should initialize and/or return the driver', async () => { await initDriver(); const driver = getDriver(); - expect(driver).not.to.be.undefined; + expect(driver).an.instanceof(neo4j.Driver); }); it('closeDriver should remove driver instance', async () => { From 7360380c0ef55fa01e29afd9d5aa781acb30d61e Mon Sep 17 00:00:00 2001 From: Jeffrey Wong Date: Thu, 16 Feb 2023 18:34:26 -0500 Subject: [PATCH 40/43] init driver is not async --- neo4j-test/connect-neo4j.js | 8 ++++---- src/neo4j/neo4j-driver.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/neo4j-test/connect-neo4j.js b/neo4j-test/connect-neo4j.js index 6929904d9..4c9d13c10 100644 --- a/neo4j-test/connect-neo4j.js +++ b/neo4j-test/connect-neo4j.js @@ -5,13 +5,13 @@ import { closeDriver, getDriver, initDriver } from '../src/neo4j/neo4j-driver.js describe('01. Initiate Driver', () => { - it('initDriver Should initialize and return a driver', async () => { - const driver = await initDriver(); + it('initDriver Should initialize and return a driver', () => { + const driver = initDriver(); expect(driver).an.instanceof(neo4j.Driver); }); - it('getDriver should initialize and/or return the driver', async () => { - await initDriver(); + it('getDriver should initialize and/or return the driver', () => { + initDriver(); const driver = getDriver(); expect(driver).an.instanceof(neo4j.Driver); }); diff --git a/src/neo4j/neo4j-driver.js b/src/neo4j/neo4j-driver.js index 77635ce2f..97580c982 100644 --- a/src/neo4j/neo4j-driver.js +++ b/src/neo4j/neo4j-driver.js @@ -7,9 +7,9 @@ let driver; * Initialize the Neo4j driver singleton * * @param {object} config additional configuration - * @returns Promise resolving to Neo4j {@link https://neo4j.com/docs/api/javascript-driver/current/class/lib6/driver.js~Driver.html Driver} instance + * @returns Neo4j {@link https://neo4j.com/docs/api/javascript-driver/current/class/lib6/driver.js~Driver.html Driver} instance */ -export async function initDriver( config = {} ) { +export function initDriver( config = {} ) { driver = neo4j.driver( GRAPHDB_CONN, neo4j.auth.basic( GRAPHDB_USER, GRAPHDB_PASS ), config From 57a60875972bf9d9f254a9eb1ae458f14676652e Mon Sep 17 00:00:00 2001 From: Jeffrey Wong Date: Thu, 16 Feb 2023 18:35:03 -0500 Subject: [PATCH 41/43] Update test docs --- neo4j-test/connect-neo4j.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neo4j-test/connect-neo4j.js b/neo4j-test/connect-neo4j.js index 4c9d13c10..da5c96492 100644 --- a/neo4j-test/connect-neo4j.js +++ b/neo4j-test/connect-neo4j.js @@ -10,7 +10,7 @@ describe('01. Initiate Driver', () => { expect(driver).an.instanceof(neo4j.Driver); }); - it('getDriver should initialize and/or return the driver', () => { + it('getDriver should return the driver', () => { initDriver(); const driver = getDriver(); expect(driver).an.instanceof(neo4j.Driver); From d1f752af5e1801964f0332dfa37d49c24b01b68a Mon Sep 17 00:00:00 2001 From: Jeffrey Wong Date: Fri, 17 Feb 2023 11:44:57 -0500 Subject: [PATCH 42/43] Drop www host in doi links --- src/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.js b/src/config.js index ace3cd678..d2614c4b1 100644 --- a/src/config.js +++ b/src/config.js @@ -81,7 +81,7 @@ export const CHEBI_LINK_BASE_URL = env('CHEBI_LINK_BASE_URL', 'https://www.ebi.a export const PUBCHEM_LINK_BASE_URL = env('PUBCHEM_LINK_BASE_URL', 'https://pubchem.ncbi.nlm.nih.gov/compound/'); export const NCBI_LINK_BASE_URL = env('NCBI_LINK_BASE_URL', 'https://www.ncbi.nlm.nih.gov/gene/'); export const PUBMED_LINK_BASE_URL = env('PUBMED_LINK_BASE_URL', 'https://pubmed.ncbi.nlm.nih.gov/'); -export const DOI_LINK_BASE_URL = env('DOI_LINK_BASE_URL', 'https://www.doi.org/'); +export const DOI_LINK_BASE_URL = env('DOI_LINK_BASE_URL', 'https://doi.org/'); export const GOOGLE_SCHOLAR_BASE_URL = env('GOOGLE_SCHOLAR_BASE_URL', 'https://scholar.google.com/scholar?q='); export const IDENTIFIERS_ORG_ID_BASE_URL = env('IDENTIFIERS_ORG_ID_BASE_URL', ' https://identifiers.org/'); From adb1ae08fab2139db0a91cf37cca41127c336f14 Mon Sep 17 00:00:00 2001 From: Jeffrey Wong Date: Fri, 17 Feb 2023 13:23:34 -0500 Subject: [PATCH 43/43] 0.22.1 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index e05ec6d71..1f9b410d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "factoid", - "version": "0.22.0", + "version": "0.22.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "factoid", - "version": "0.22.0", + "version": "0.22.1", "license": "MIT", "dependencies": { "@appsignal/express": "^0.5.1", diff --git a/package.json b/package.json index 0ee222129..3442b8815 100644 --- a/package.json +++ b/package.json @@ -137,5 +137,5 @@ "engines": { "node": ">=16.19.0" }, - "version": "0.22.0" + "version": "0.22.1" }