From 0b14d06f97275ef257977164a57209e9b3402f12 Mon Sep 17 00:00:00 2001 From: p3rcypj Date: Fri, 5 Jan 2024 17:51:14 +0000 Subject: [PATCH 01/19] Add support for Typescript on Jest --- .../javascripts/3dbio_viewer/package.json | 17 +++- app/assets/javascripts/3dbio_viewer/yarn.lock | 79 +++++++++++++++---- 2 files changed, 78 insertions(+), 18 deletions(-) diff --git a/app/assets/javascripts/3dbio_viewer/package.json b/app/assets/javascripts/3dbio_viewer/package.json index ef41a68bf..e4caf7d5d 100644 --- a/app/assets/javascripts/3dbio_viewer/package.json +++ b/app/assets/javascripts/3dbio_viewer/package.json @@ -61,6 +61,7 @@ "https-proxy-agent": "^5.0.0", "lnf": "^1.3.10", "prettier": "^2.2.1", + "ts-jest": "^26.5.6", "ts-node": "10.4.0", "typescript": "4.5.4" }, @@ -97,5 +98,19 @@ "includePaths": [ "./node_modules" ] + }, + "jest": { + "transform": { + "^.+\\.tsx?$": "ts-jest" + }, + "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$", + "moduleFileExtensions": [ + "ts", + "tsx", + "js", + "jsx", + "json", + "node" + ] } -} \ No newline at end of file +} diff --git a/app/assets/javascripts/3dbio_viewer/yarn.lock b/app/assets/javascripts/3dbio_viewer/yarn.lock index 69a264a18..863593f07 100644 --- a/app/assets/javascripts/3dbio_viewer/yarn.lock +++ b/app/assets/javascripts/3dbio_viewer/yarn.lock @@ -1599,10 +1599,10 @@ react-is "^16.8.0 || ^17.0.0" react-transition-group "^4.4.0" -"@material-ui/data-grid@^4.0.0-alpha.23": - version "4.0.0-alpha.37" - resolved "https://registry.npmjs.org/@material-ui/data-grid/-/data-grid-4.0.0-alpha.37.tgz#89d907c4e94e6a0db4e89e4f59160f7811546ca2" - integrity sha512-3T2AG31aad/lWLMLwn1XUP4mUf3H9YZES17dGuYByzkRLCXbBZHBTPEnCctWukajzwm+v0KGg3QpwitGoiDAjA== +"@material-ui/data-grid@4.0.0-alpha.35": + version "4.0.0-alpha.35" + resolved "https://registry.yarnpkg.com/@material-ui/data-grid/-/data-grid-4.0.0-alpha.35.tgz#be49d2c15571b46cd570e2172cb6737c6c479de2" + integrity sha512-liyubO6MszF61Ceqx/yMGM0iWPVjg2+yf63m95qUSAp/Q1DyJenWP0XD78YZ1ZCqWbH1LIxJiuHEO+9iqKa7wA== dependencies: "@material-ui/utils" "^5.0.0-alpha.14" clsx "^1.0.4" @@ -3939,6 +3939,13 @@ browserslist@^4.0.0, browserslist@^4.12.0, browserslist@^4.14.5, browserslist@^4 escalade "^3.1.1" node-releases "^1.1.67" +bs-logger@0.x: + version "0.2.6" + resolved "https://registry.yarnpkg.com/bs-logger/-/bs-logger-0.2.6.tgz#eb7d365307a72cf974cc6cda76b68354ad336bd8" + integrity sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog== + dependencies: + fast-json-stable-stringify "2.x" + bser@2.1.1: version "2.1.1" resolved "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz#e6787da20ece9d07998533cfd9de6f5c38f4bc05" @@ -3946,6 +3953,11 @@ bser@2.1.1: dependencies: node-int64 "^0.4.0" +buffer-from@1.x: + version "1.1.2" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" + integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== + buffer-from@^1.0.0: version "1.1.1" resolved "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" @@ -6336,7 +6348,7 @@ fast-glob@^3.1.1: micromatch "^4.0.2" picomatch "^2.2.1" -fast-json-stable-stringify@^2.0.0, fast-json-stable-stringify@^2.1.0: +fast-json-stable-stringify@2.x, fast-json-stable-stringify@^2.0.0, fast-json-stable-stringify@^2.1.0: version "2.1.0" resolved "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== @@ -8272,7 +8284,7 @@ jest-snapshot@^26.6.0, jest-snapshot@^26.6.2: pretty-format "^26.6.2" semver "^7.3.2" -jest-util@^26.6.0, jest-util@^26.6.2: +jest-util@^26.1.0, jest-util@^26.6.0, jest-util@^26.6.2: version "26.6.2" resolved "https://registry.npmjs.org/jest-util/-/jest-util-26.6.2.tgz#907535dbe4d5a6cb4c47ac9b926f6af29576cbc1" integrity sha512-MDW0fKfsn0OI7MS7Euz6h8HNDXVQ0gaM9uW6RjfDmd1DAFcaxX9OqIakHIqhbnmF08Cf2DLDG+ulq8YQQ0Lp0Q== @@ -8448,6 +8460,11 @@ json3@^3.3.2: resolved "https://registry.npmjs.org/json3/-/json3-3.3.3.tgz#7fc10e375fc5ae42c4705a5cc0aa6f62be305b81" integrity sha512-c7/8mbUsKigAbLkD5B010BK4D9LZm7A1pNItkEwiUZRpIN66exu/e7YQWysGun+TRKaJp8MhemM+VkfWv42aCA== +json5@2.x: + version "2.2.3" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" + integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== + json5@^1.0.1: version "1.0.1" resolved "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe" @@ -8822,16 +8839,16 @@ lodash@4.17.19: resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b" integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ== +lodash@4.x, lodash@^4.17.21: + version "4.17.21" + resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" + integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== + "lodash@>=3.5 <5", lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.5: version "4.17.20" resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== -lodash@^4.17.21: - version "4.17.21" - resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== - loglevel@^1.6.8: version "1.7.1" resolved "https://registry.npmjs.org/loglevel/-/loglevel-1.7.1.tgz#005fde2f5e6e47068f935ff28573e125ef72f197" @@ -8892,7 +8909,7 @@ make-dir@^3.0.0, make-dir@^3.0.2: dependencies: semver "^6.0.0" -make-error@^1.1.1: +make-error@1.x, make-error@^1.1.1: version "1.3.6" resolved "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== @@ -9213,6 +9230,11 @@ mixin-deep@^1.2.0: for-in "^1.0.2" is-extendable "^1.0.1" +mkdirp@1.x, mkdirp@^1.0.3, mkdirp@^1.0.4: + version "1.0.4" + resolved "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" + integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== + mkdirp@^0.5.1, mkdirp@^0.5.3, mkdirp@^0.5.5, mkdirp@~0.5.1: version "0.5.5" resolved "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" @@ -9220,11 +9242,6 @@ mkdirp@^0.5.1, mkdirp@^0.5.3, mkdirp@^0.5.5, mkdirp@~0.5.1: dependencies: minimist "^1.2.5" -mkdirp@^1.0.3, mkdirp@^1.0.4: - version "1.0.4" - resolved "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" - integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== - molstar@3.15.0: version "3.15.0" resolved "https://registry.yarnpkg.com/molstar/-/molstar-3.15.0.tgz#3224ff28150c342e53661515a592bdc9fee5928f" @@ -12011,6 +12028,13 @@ semver@7.3.2: resolved "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938" integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ== +semver@7.x: + version "7.5.4" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" + integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== + dependencies: + lru-cache "^6.0.0" + semver@^6.0.0, semver@^6.3.0: version "6.3.0" resolved "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" @@ -13063,6 +13087,22 @@ tryer@^1.0.1: resolved "https://registry.npmjs.org/tryer/-/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8" integrity sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA== +ts-jest@^26.5.6: + version "26.5.6" + resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.5.6.tgz#c32e0746425274e1dfe333f43cd3c800e014ec35" + integrity sha512-rua+rCP8DxpA8b4DQD/6X2HQS8Zy/xzViVYfEs2OQu68tkCuKLV0Md8pmX55+W24uRIyAsf/BajRfxOs+R2MKA== + dependencies: + bs-logger "0.x" + buffer-from "1.x" + fast-json-stable-stringify "2.x" + jest-util "^26.1.0" + json5 "2.x" + lodash "4.x" + make-error "1.x" + mkdirp "1.x" + semver "7.x" + yargs-parser "20.x" + ts-node@10.4.0: version "10.4.0" resolved "https://registry.npmjs.org/ts-node/-/ts-node-10.4.0.tgz#680f88945885f4e6cf450e7f0d6223dd404895f7" @@ -14080,6 +14120,11 @@ yaml@^1.10.0, yaml@^1.7.2: resolved "https://registry.npmjs.org/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e" integrity sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg== +yargs-parser@20.x: + version "20.2.9" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" + integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== + yargs-parser@^13.1.2: version "13.1.2" resolved "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz#130f09702ebaeef2650d54ce6e3e5706f7a4fb38" From f980753338ba8f84c1130139027737c8f34ea8d2 Mon Sep 17 00:00:00 2001 From: p3rcypj Date: Fri, 5 Jan 2024 19:23:29 +0000 Subject: [PATCH 02/19] Add new test: default PdbInfo --- .../__mocks__/d2-ui-components/locales.js | 3 +++ app/assets/javascripts/3dbio_viewer/package.json | 9 +++++++-- .../src/domain/entities/__tests__/PdbInfo.spec.ts | 11 +++++++++++ app/assets/javascripts/3dbio_viewer/yarn.lock | 15 +++++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 app/assets/javascripts/3dbio_viewer/__mocks__/d2-ui-components/locales.js create mode 100644 app/assets/javascripts/3dbio_viewer/src/domain/entities/__tests__/PdbInfo.spec.ts diff --git a/app/assets/javascripts/3dbio_viewer/__mocks__/d2-ui-components/locales.js b/app/assets/javascripts/3dbio_viewer/__mocks__/d2-ui-components/locales.js new file mode 100644 index 000000000..2d6fb8d02 --- /dev/null +++ b/app/assets/javascripts/3dbio_viewer/__mocks__/d2-ui-components/locales.js @@ -0,0 +1,3 @@ +module.exports = { + t: s => s, +}; diff --git a/app/assets/javascripts/3dbio_viewer/package.json b/app/assets/javascripts/3dbio_viewer/package.json index e4caf7d5d..a65754467 100644 --- a/app/assets/javascripts/3dbio_viewer/package.json +++ b/app/assets/javascripts/3dbio_viewer/package.json @@ -37,6 +37,7 @@ "devDependencies": { "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0", + "@testing-library/react-hooks": "^8.0.1", "@testing-library/user-event": "^12.1.10", "@types/axios": "^0.14.0", "@types/classnames": "^2.2.11", @@ -74,7 +75,8 @@ "build": "INLINE_RUNTIME_CHUNK=false react-scripts build && yarn create-build-symlinks", "create-build-symlinks": "ts-node -O '{\"module\":\"commonjs\"}' src/scripts/create-build-symlinks.ts", "lint": "eslint . --ext .ts,.tsx", - "prettify": "prettier \"./src/**/*.{js,jsx,json,css,ts,tsx}\" --write" + "prettify": "prettier \"./src/**/*.{js,jsx,json,css,ts,tsx}\" --write", + "test": "PORT=3001 && jest --testURL http://localhost:$PORT" }, "eslintConfig": { "extends": [ @@ -101,9 +103,12 @@ }, "jest": { "transform": { - "^.+\\.tsx?$": "ts-jest" + "^.+\\.[tj]sx{0,1}?$": "ts-jest" }, "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$", + "transformIgnorePatterns": [ + "/node_modules/(?!@eyeseetea/d2-ui-components)" + ], "moduleFileExtensions": [ "ts", "tsx", diff --git a/app/assets/javascripts/3dbio_viewer/src/domain/entities/__tests__/PdbInfo.spec.ts b/app/assets/javascripts/3dbio_viewer/src/domain/entities/__tests__/PdbInfo.spec.ts new file mode 100644 index 000000000..57f66399b --- /dev/null +++ b/app/assets/javascripts/3dbio_viewer/src/domain/entities/__tests__/PdbInfo.spec.ts @@ -0,0 +1,11 @@ +import { describe, expect, it } from "@jest/globals"; +import { getCompositionRoot } from "../../../compositionRoot"; + +describe("PdbInfo", () => { + it("with PDB 6zow is truthy", async () => { + const compositionRoot = getCompositionRoot(); + const pdbInfo = await compositionRoot.getPdbInfo.execute("6zow").toPromise(); + + expect(pdbInfo).toBeTruthy(); + }); +}); diff --git a/app/assets/javascripts/3dbio_viewer/yarn.lock b/app/assets/javascripts/3dbio_viewer/yarn.lock index 863593f07..f0dc54150 100644 --- a/app/assets/javascripts/3dbio_viewer/yarn.lock +++ b/app/assets/javascripts/3dbio_viewer/yarn.lock @@ -1917,6 +1917,14 @@ lodash "^4.17.15" redent "^3.0.0" +"@testing-library/react-hooks@^8.0.1": + version "8.0.1" + resolved "https://registry.yarnpkg.com/@testing-library/react-hooks/-/react-hooks-8.0.1.tgz#0924bbd5b55e0c0c0502d1754657ada66947ca12" + integrity sha512-Aqhl2IVmLt8IovEVarNDFuJDVWVvhnr9/GCU6UUnrYXwgDFF9h2L2o2P9KBni1AST5sT6riAyoukFLyjQUgD/g== + dependencies: + "@babel/runtime" "^7.12.5" + react-error-boundary "^3.1.0" + "@testing-library/react@^11.1.0": version "11.2.2" resolved "https://registry.npmjs.org/@testing-library/react/-/react-11.2.2.tgz#099c6c195140ff069211143cb31c0f8337bdb7b7" @@ -11189,6 +11197,13 @@ react-dropzone@^11.3.1: file-selector "^0.2.2" prop-types "^15.7.2" +react-error-boundary@^3.1.0: + version "3.1.4" + resolved "https://registry.yarnpkg.com/react-error-boundary/-/react-error-boundary-3.1.4.tgz#255db92b23197108757a888b01e5b729919abde0" + integrity sha512-uM9uPzZJTF6wRQORmSrvOIgt4lJ9MC1sNgEOj2XGsDTRE4kmpWxg7ENK9EWNKJRMAOY9z0MuF4yIfl6gp4sotA== + dependencies: + "@babel/runtime" "^7.12.5" + react-error-overlay@^6.0.8: version "6.0.8" resolved "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.8.tgz#474ed11d04fc6bda3af643447d85e9127ed6b5de" From c5f7c65867e58ed73858c4cbc6859b03e720f67a Mon Sep 17 00:00:00 2001 From: p3rcypj Date: Mon, 8 Jan 2024 09:46:50 +0000 Subject: [PATCH 03/19] Add first test --- app/assets/javascripts/3dbio_viewer/config/fileMock.js | 3 +++ app/assets/javascripts/3dbio_viewer/config/styleMock.js | 3 +++ app/assets/javascripts/3dbio_viewer/package.json | 8 ++++++-- .../src/domain/entities/__tests__/PdbInfo.spec.ts | 9 +++++++-- 4 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 app/assets/javascripts/3dbio_viewer/config/fileMock.js create mode 100644 app/assets/javascripts/3dbio_viewer/config/styleMock.js diff --git a/app/assets/javascripts/3dbio_viewer/config/fileMock.js b/app/assets/javascripts/3dbio_viewer/config/fileMock.js new file mode 100644 index 000000000..e92956518 --- /dev/null +++ b/app/assets/javascripts/3dbio_viewer/config/fileMock.js @@ -0,0 +1,3 @@ +// Turns file imports into dummy objects + +module.exports = "test-file-stub"; diff --git a/app/assets/javascripts/3dbio_viewer/config/styleMock.js b/app/assets/javascripts/3dbio_viewer/config/styleMock.js new file mode 100644 index 000000000..efa0d3ce9 --- /dev/null +++ b/app/assets/javascripts/3dbio_viewer/config/styleMock.js @@ -0,0 +1,3 @@ +// Turns style imports into empty objects + +module.exports = {}; diff --git a/app/assets/javascripts/3dbio_viewer/package.json b/app/assets/javascripts/3dbio_viewer/package.json index a65754467..4d0bbc7a9 100644 --- a/app/assets/javascripts/3dbio_viewer/package.json +++ b/app/assets/javascripts/3dbio_viewer/package.json @@ -107,8 +107,12 @@ }, "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$", "transformIgnorePatterns": [ - "/node_modules/(?!@eyeseetea/d2-ui-components)" + "/node_modules/(?!d2-ui-components)" ], + "moduleNameMapper": { + "\\.(css|scss)$": "/config/styleMock.js", + "\\.(jpg|jpeg|png|svg)$": "/config/fileMock.js" + }, "moduleFileExtensions": [ "ts", "tsx", @@ -118,4 +122,4 @@ "node" ] } -} +} \ No newline at end of file diff --git a/app/assets/javascripts/3dbio_viewer/src/domain/entities/__tests__/PdbInfo.spec.ts b/app/assets/javascripts/3dbio_viewer/src/domain/entities/__tests__/PdbInfo.spec.ts index 57f66399b..7dfe6ac15 100644 --- a/app/assets/javascripts/3dbio_viewer/src/domain/entities/__tests__/PdbInfo.spec.ts +++ b/app/assets/javascripts/3dbio_viewer/src/domain/entities/__tests__/PdbInfo.spec.ts @@ -1,11 +1,16 @@ import { describe, expect, it } from "@jest/globals"; import { getCompositionRoot } from "../../../compositionRoot"; +import { defaultPdbId } from "../../../webapp/pages/app/AppRouter"; describe("PdbInfo", () => { - it("with PDB 6zow is truthy", async () => { + it("with PDB 6zow to be truthy", async () => { const compositionRoot = getCompositionRoot(); - const pdbInfo = await compositionRoot.getPdbInfo.execute("6zow").toPromise(); + const pdbInfo = await compositionRoot.getPdbInfo.execute(defaultPdbId).toPromise(); expect(pdbInfo).toBeTruthy(); }); + // it("with PDB 9zzz rejects", async () => { + // const compositionRoot = getCompositionRoot(); + // expect(compositionRoot.getPdbInfo.execute("9zzz").toPromise()).rejects; + // }); }); From f98c2d10a9c39c87cc344d473d60cf7e94d04860 Mon Sep 17 00:00:00 2001 From: p3rcypj Date: Mon, 8 Jan 2024 10:56:06 +0000 Subject: [PATCH 04/19] Default PDB and EMDB --- .../3dbio_viewer/src/webapp/pages/app/AppRouter.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/3dbio_viewer/src/webapp/pages/app/AppRouter.tsx b/app/assets/javascripts/3dbio_viewer/src/webapp/pages/app/AppRouter.tsx index a255def81..3651f565b 100644 --- a/app/assets/javascripts/3dbio_viewer/src/webapp/pages/app/AppRouter.tsx +++ b/app/assets/javascripts/3dbio_viewer/src/webapp/pages/app/AppRouter.tsx @@ -11,10 +11,13 @@ function AppRouter() { } /> } /> - + ); } +export const defaultPdbId = "6zow"; +export const defaultEmdbId = "EMD-11328"; + export default React.memo(AppRouter); From b7cab48f5b9795c6ef166affd73452d911d74737 Mon Sep 17 00:00:00 2001 From: p3rcypj Date: Mon, 29 Jan 2024 11:05:30 +0000 Subject: [PATCH 05/19] Temporal fix for UniprotID missing --- .../protvista/ApiPdbRepository.ts | 87 ++++++++++--------- .../3dbio_viewer/src/domain/entities/Pdb.ts | 4 +- .../src/domain/entities/PdbInfo.ts | 16 +++- .../src/domain/repositories/PdbRepository.ts | 4 +- .../src/webapp/components/BasicInfoViewer.tsx | 2 +- .../src/webapp/components/ChainInfoViewer.tsx | 16 ++-- .../components/gene-viewer/GeneViewer.tsx | 1 + .../src/webapp/components/ppi/ppi-data.ts | 1 + .../components/protvista/ProtvistaViewer.tsx | 12 +-- .../components/protvista/ProvistaGrouped.tsx | 2 +- .../components/protvista/ToolsButton.tsx | 2 +- .../webapp/components/protvista/Tooltip.tsx | 6 +- .../3dbio_viewer/src/webapp/hooks/use-pdb.ts | 2 +- 13 files changed, 93 insertions(+), 62 deletions(-) diff --git a/app/assets/javascripts/3dbio_viewer/src/data/repositories/protvista/ApiPdbRepository.ts b/app/assets/javascripts/3dbio_viewer/src/data/repositories/protvista/ApiPdbRepository.ts index 93ea97325..7962b3987 100644 --- a/app/assets/javascripts/3dbio_viewer/src/data/repositories/protvista/ApiPdbRepository.ts +++ b/app/assets/javascripts/3dbio_viewer/src/data/repositories/protvista/ApiPdbRepository.ts @@ -81,7 +81,7 @@ interface Data { type DataRequests = { [K in keyof Data]-?: Future }; interface Options { - proteinId: string; + proteinId: Maybe; pdbId: Maybe; chainId: string; } @@ -103,34 +103,33 @@ export class ApiPdbRepository implements PdbRepository { debugVariable({ apiData: data }); const { proteinId } = options; - const variants = getVariants( - data.ebiVariation, - data.mutagenesis, - data.genomicVariantsCNCB, - proteinId - ); + const variants = proteinId + ? getVariants(data.ebiVariation, data.mutagenesis, data.genomicVariantsCNCB, proteinId) + : undefined; // prettier-ignore const fragmentsList = { - featureFragments: on(data.features, features => getFeatureFragments(options.proteinId, features)), - pfamDomainFragments: on(data.pfamAnnotations, pfamAnnotations => getPfamDomainFragments(pfamAnnotations, proteinId)), - smartDomainFragments: on(data.smartAnnotations, smartAnnotations => getSmartDomainFragments(smartAnnotations, proteinId)), - interproFragments: on(data.interproAnnotations, interproAnnotations => getInterproDomainFragments(interproAnnotations, proteinId)), - elmdbFragments: on(data.elmdbUniprot, elmdbUniprot => getElmdbUniprotFragments(elmdbUniprot, proteinId)), - functionalMappingFragments: on(data.cv19Tracks, getFunctionalMappingFragments), structureCoverageFragments: on(data.coverage, coverage => getStructureCoverageFragments(coverage, options.chainId)), - emValidationFragments: on(data.pdbAnnotations, pdbAnnotations => getEmValidationFragments(pdbAnnotations, options.chainId)), - mobiFragments: on(data.mobiUniprot, mobiUniprot => getMobiUniprotFragments(mobiUniprot, proteinId)), - proteomicsFragments: on(data.proteomics, proteomics => getProteomicsFragments(proteomics, proteinId)), - pdbRedoFragments: on(data.pdbRedo, pdbRedo => getPdbRedoFragments(pdbRedo, options.chainId)), - epitomesFragments: on(data.iedb, getEpitomesFragments), - phosphiteFragments: on(data.phosphositeUniprot, phosphositeUniprot => getPhosphiteFragments(phosphositeUniprot, proteinId)), - dbPtmFragments: on(data.dbPtm, dbPtm => getDbPtmFragments(dbPtm, proteinId)), - molprobityFragments: on(data.molprobity, molprobity => getMolprobityFragments(molprobity, options.chainId)), - antigenFragments: on(data.antigenic, antigenic => getAntigenicFragments(antigenic, proteinId)), + // emValidationFragments: on(data.pdbAnnotations, pdbAnnotations => getEmValidationFragments(pdbAnnotations, options.chainId)), + // pdbRedoFragments: on(data.pdbRedo, pdbRedo => getPdbRedoFragments(pdbRedo, options.chainId)), + // molprobityFragments: on(data.molprobity, molprobity => getMolprobityFragments(molprobity, options.chainId)), + // ...(proteinId ? { + // featureFragments: on(data.features, features => getFeatureFragments(proteinId, features)), + // functionalMappingFragments: on(data.cv19Tracks, getFunctionalMappingFragments), + // epitomesFragments: on(data.iedb, getEpitomesFragments), + // pfamDomainFragments: on(data.pfamAnnotations, pfamAnnotations => getPfamDomainFragments(pfamAnnotations, proteinId)), + // smartDomainFragments: on(data.smartAnnotations, smartAnnotations => getSmartDomainFragments(smartAnnotations, proteinId)), + // interproFragments: on(data.interproAnnotations, interproAnnotations => getInterproDomainFragments(interproAnnotations, proteinId)), + // elmdbFragments: on(data.elmdbUniprot, elmdbUniprot => getElmdbUniprotFragments(elmdbUniprot, proteinId)), + // mobiFragments: on(data.mobiUniprot, mobiUniprot => getMobiUniprotFragments(mobiUniprot, proteinId)), + // proteomicsFragments: on(data.proteomics, proteomics => getProteomicsFragments(proteomics, proteinId)), + // phosphiteFragments: on(data.phosphositeUniprot, phosphositeUniprot => getPhosphiteFragments(phosphositeUniprot, proteinId)), + // dbPtmFragments: on(data.dbPtm, dbPtm => getDbPtmFragments(dbPtm, proteinId)), + // antigenFragments: on(data.antigenic, antigenic => getAntigenicFragments(antigenic, proteinId)) + // } : {}), }; - const protein = getProtein(proteinId, data.uniprot); + const protein = proteinId ? getProtein(proteinId, data.uniprot) : undefined; const experiment = on(data.pdbExperiment, pdbExperiment => options.pdbId ? getExperiment(options.pdbId, pdbExperiment) : undefined ); @@ -227,31 +226,35 @@ function getData(options: Options): FutureData> { // Move URLS to each track module? //prettier-ignore - const data$: DataRequests = { - uniprot: getXML(`${routes.uniprot}/uniprotkb/${proteinId}.xml`), - pdbEmdbsEmValidations, - features: getJSON(`${ebiProteinsApiUrl}/features/${proteinId}`), - cv19Tracks: getJSON(`${bioUrl}/cv19_annotations/${proteinId}_annotations.json`), + const data$: Partial = { + //PDBID + pdbSummary: onF(pdbId, pdbId => getJSON(`${ebiBaseUrl}/pdbe/api/pdb/entry/summary/${pdbId}`)), pdbAnnotations: onF(pdbId, pdbId => getJSON(`${pdbAnnotUrl}/all/${pdbId}/${chainId}/?format=json`)), pdbPublications, coverage: onF(pdbId, pdbId => getJSON(`${bioUrl}/api/alignments/Coverage/${pdbId}${chainId}`)), - pdbSummary: onF(pdbId, pdbId => getJSON(`${ebiBaseUrl}/pdbe/api/pdb/entry/summary/${pdbId}`)), - ebiVariation: getJSON(`${ebiProteinsApiUrl}/variation/${proteinId}`), - mobiUniprot: getJSON(`${bioUrl}/api/annotations/mobi/Uniprot/${proteinId}`), - phosphositeUniprot: getJSON(`${bioUrl}/api/annotations/Phosphosite/Uniprot/${proteinId}`), - dbPtm: getJSON(`${bioUrl}/api/annotations/dbptm/Uniprot/${proteinId}`), - pfamAnnotations: getJSON(`${bioUrl}/api/annotations/Pfam/Uniprot/${proteinId}`), - smartAnnotations: getJSON(`${bioUrl}/api/annotations/SMART/Uniprot/${proteinId}`), - interproAnnotations: getJSON(`${bioUrl}/api/annotations/interpro/Uniprot/${proteinId}`), - proteomics: getJSON(`${ebiProteinsApiUrl}/proteomics/${proteinId}`), pdbRedo: onF(pdbId, pdbId => getJSON(`${bioUrl}/api/annotations/PDB_REDO/${pdbId}`)), - iedb: getJSON(`${bioUrl}/api/annotations/IEDB/Uniprot/${proteinId}`), pdbExperiment: onF(pdbId, pdbId => getJSON(`${ebiBaseUrl}/pdbe/api/pdb/entry/experiment/${pdbId}`)), - elmdbUniprot: getJSON(`${bioUrl}/api/annotations/elmdb/Uniprot/${proteinId}`), molprobity: onF(pdbId, pdbId => getJSON(`${bioUrl}/compute/molprobity/${pdbId}`)), - antigenic: getJSON(`${ebiProteinsApiUrl}/antigen/${proteinId}`), - mutagenesis: getJSON(`${bioUrl}/api/annotations/biomuta/Uniprot/${proteinId}`), - genomicVariantsCNCB: getJSON(`${bioUrl}/ws/lrs/features/variants/Genomic_Variants_CNCB/${proteinId}/`), + //UNIPROT + ...(proteinId ? { + uniprot: getXML(`${routes.uniprot}/uniprotkb/${proteinId}.xml`), + pdbEmdbsEmValidations, + features: getJSON(`${ebiProteinsApiUrl}/features/${proteinId}`), + cv19Tracks: getJSON(`${bioUrl}/cv19_annotations/${proteinId}_annotations.json`), + ebiVariation: getJSON(`${ebiProteinsApiUrl}/variation/${proteinId}`), + mobiUniprot: getJSON(`${bioUrl}/api/annotations/mobi/Uniprot/${proteinId}`), + phosphositeUniprot: getJSON(`${bioUrl}/api/annotations/Phosphosite/Uniprot/${proteinId}`), + dbPtm: getJSON(`${bioUrl}/api/annotations/dbptm/Uniprot/${proteinId}`), + pfamAnnotations: getJSON(`${bioUrl}/api/annotations/Pfam/Uniprot/${proteinId}`), + smartAnnotations: getJSON(`${bioUrl}/api/annotations/SMART/Uniprot/${proteinId}`), + interproAnnotations: getJSON(`${bioUrl}/api/annotations/interpro/Uniprot/${proteinId}`), + proteomics: getJSON(`${ebiProteinsApiUrl}/proteomics/${proteinId}`), + iedb: getJSON(`${bioUrl}/api/annotations/IEDB/Uniprot/${proteinId}`), + elmdbUniprot: getJSON(`${bioUrl}/api/annotations/elmdb/Uniprot/${proteinId}`), + antigenic: getJSON(`${ebiProteinsApiUrl}/antigen/${proteinId}`), + mutagenesis: getJSON(`${bioUrl}/api/annotations/biomuta/Uniprot/${proteinId}`), + genomicVariantsCNCB: getJSON(`${bioUrl}/ws/lrs/features/variants/Genomic_Variants_CNCB/${proteinId}/`) + } : {}), ligands, }; diff --git a/app/assets/javascripts/3dbio_viewer/src/domain/entities/Pdb.ts b/app/assets/javascripts/3dbio_viewer/src/domain/entities/Pdb.ts index b47b2a73a..1a55e64db 100644 --- a/app/assets/javascripts/3dbio_viewer/src/domain/entities/Pdb.ts +++ b/app/assets/javascripts/3dbio_viewer/src/domain/entities/Pdb.ts @@ -15,7 +15,7 @@ export interface Pdb { title: Maybe; experiment: Maybe; emdbs: Emdb[]; - protein: Protein; + protein: Maybe; chainId: string; sequence: string; length: number; @@ -108,10 +108,12 @@ export function getEntityLinks(pdb: Pdb, entity: PdbEntity): Link[] { })); } case "uniprot": { + if (!pdb.protein) return []; const proteinId = pdb.protein.id.toUpperCase(); return [{ name: proteinId, url: `https://www.uniprot.org/uniprot/${proteinId}` }]; } case "geneBank": { + if (!pdb.protein) return []; return pdb.protein.genBank ? pdb.protein.genBank?.map(id => ({ name: id ?? "-", diff --git a/app/assets/javascripts/3dbio_viewer/src/domain/entities/PdbInfo.ts b/app/assets/javascripts/3dbio_viewer/src/domain/entities/PdbInfo.ts index 11a2b6349..b5d6bc9f0 100644 --- a/app/assets/javascripts/3dbio_viewer/src/domain/entities/PdbInfo.ts +++ b/app/assets/javascripts/3dbio_viewer/src/domain/entities/PdbInfo.ts @@ -13,7 +13,7 @@ export interface PdbInfo { name: string; shortName: string; chainId: ChainId; - protein: Protein; + protein: Maybe; }>; ligands: Ligand[]; } @@ -45,6 +45,20 @@ export function buildPdbInfo(options: BuildPdbInfoOptions): PdbInfo { .sortBy(obj => obj.chainId) .value(); + if (_.isEmpty(chains) && _.isEmpty(options.proteins)) + return { + ...options, + chains: [ + { + id: "A", + name: "A", + shortName: "A", + chainId: "A", + protein: undefined, + }, + ], + }; + return { ...options, chains }; } diff --git a/app/assets/javascripts/3dbio_viewer/src/domain/repositories/PdbRepository.ts b/app/assets/javascripts/3dbio_viewer/src/domain/repositories/PdbRepository.ts index 9f52c4d91..69e0372c8 100644 --- a/app/assets/javascripts/3dbio_viewer/src/domain/repositories/PdbRepository.ts +++ b/app/assets/javascripts/3dbio_viewer/src/domain/repositories/PdbRepository.ts @@ -9,7 +9,7 @@ export interface PdbRepository { } export interface PdbOptions { - proteinId: ProteinId; + proteinId: Maybe; pdbId: Maybe; - chainId: ChainId; + chainId: Maybe; } diff --git a/app/assets/javascripts/3dbio_viewer/src/webapp/components/BasicInfoViewer.tsx b/app/assets/javascripts/3dbio_viewer/src/webapp/components/BasicInfoViewer.tsx index b9a9135f0..584350120 100644 --- a/app/assets/javascripts/3dbio_viewer/src/webapp/components/BasicInfoViewer.tsx +++ b/app/assets/javascripts/3dbio_viewer/src/webapp/components/BasicInfoViewer.tsx @@ -81,7 +81,7 @@ function getItems(pdb: Pdb) { const resolution = pdb.experiment?.resolution; const items: Item[] = _.compact([ - { name: i18n.t("Organism"), value: pdb.protein.organism }, + pdb.protein ? { name: i18n.t("Organism"), value: pdb.protein.organism } : undefined, { name: i18n.t("Biological function"), isDisabled: true, diff --git a/app/assets/javascripts/3dbio_viewer/src/webapp/components/ChainInfoViewer.tsx b/app/assets/javascripts/3dbio_viewer/src/webapp/components/ChainInfoViewer.tsx index cd1e709f8..0e8e10e1f 100644 --- a/app/assets/javascripts/3dbio_viewer/src/webapp/components/ChainInfoViewer.tsx +++ b/app/assets/javascripts/3dbio_viewer/src/webapp/components/ChainInfoViewer.tsx @@ -52,11 +52,17 @@ const Child: React.FC = props => { function getItems(pdb: Pdb): Item[] { return _.compact([ - { name: i18n.t("Gene Name"), value: pdb.protein.gen }, - { - name: i18n.t("Gene Bank ID"), - value: pdb.protein.genBank ? : "-", - }, + pdb.protein ? { name: i18n.t("Gene Name"), value: pdb.protein.gen } : undefined, + pdb.protein + ? { + name: i18n.t("Gene Bank ID"), + value: pdb.protein.genBank ? ( + + ) : ( + "-" + ), + } + : undefined, { name: i18n.t("Uniprot ID"), value: , diff --git a/app/assets/javascripts/3dbio_viewer/src/webapp/components/gene-viewer/GeneViewer.tsx b/app/assets/javascripts/3dbio_viewer/src/webapp/components/gene-viewer/GeneViewer.tsx index 184975039..c6bf2d405 100644 --- a/app/assets/javascripts/3dbio_viewer/src/webapp/components/gene-viewer/GeneViewer.tsx +++ b/app/assets/javascripts/3dbio_viewer/src/webapp/components/gene-viewer/GeneViewer.tsx @@ -13,6 +13,7 @@ interface GeneViewerProps { export const GeneViewer: React.FC = props => { const { trackDef, pdb } = props; + if (!pdb.protein) throw new Error("No UniprotID to show GeneViewer"); const src = routes.bionotes + `/genomicIFrame?uniprot_acc=${pdb.protein.id.toUpperCase()}`; const title = `${trackDef.name}`; diff --git a/app/assets/javascripts/3dbio_viewer/src/webapp/components/ppi/ppi-data.ts b/app/assets/javascripts/3dbio_viewer/src/webapp/components/ppi/ppi-data.ts index a52c2bd42..24efdee4e 100644 --- a/app/assets/javascripts/3dbio_viewer/src/webapp/components/ppi/ppi-data.ts +++ b/app/assets/javascripts/3dbio_viewer/src/webapp/components/ppi/ppi-data.ts @@ -67,6 +67,7 @@ export interface InfoAlignmentFromNetwork { } export function getInfoAlignmentFromPdb(pdb: Pdb): Maybe { + if (!pdb.protein) return undefined; if (pdb.proteinNetwork) { return { origin: "interactome3d", diff --git a/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/ProtvistaViewer.tsx b/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/ProtvistaViewer.tsx index 97bd16ed4..db5c966b2 100644 --- a/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/ProtvistaViewer.tsx +++ b/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/ProtvistaViewer.tsx @@ -51,17 +51,17 @@ export const ProtvistaViewer: React.FC = props => { const geneName = React.useMemo( () => - pdb.protein.gen - ? i18n.t(" encoded by the gene {{geneName}}", { geneName: pdb.protein.gen }) + pdb.protein?.gen + ? i18n.t(" encoded by the gene {{geneName}}", { geneName: pdb.protein?.gen }) : undefined, [pdb.protein] ); const geneBankEntry = React.useMemo( () => - !_.isEmpty(pdb.protein.genBank) + !_.isEmpty(pdb.protein?.genBank) ? i18n.t(" (GeneBank {{geneBankEntry}})", { - geneBankEntry: pdb.protein.genBank?.join(", "), + geneBankEntry: pdb.protein?.genBank?.join(", "), }) : undefined, [pdb.protein] @@ -71,11 +71,11 @@ export const ProtvistaViewer: React.FC = props => { () => ({ poorQualityRegionMax: _.first(pdb.emdbs)?.emv?.stats?.quartile75, poorQualityRegionMin: _.first(pdb.emdbs)?.emv?.stats?.quartile25, - proteinName: pdb.protein.name, + proteinName: pdb.protein?.name, ligandsAndSmallMoleculesCount, resolution: _.first(pdb.emdbs)?.emv?.stats?.resolutionMedian, chain: pdb.chainId, - chainWithProtein: `${pdb.chainId}${pdb.protein.name ? " - " + pdb.protein.name : ""}`, + chainWithProtein: `${pdb.chainId}${pdb.protein?.name ? " - " + pdb.protein.name : ""}`, uniprotId: getEntityLinks(pdb, "uniprot") .map(link => link.name) .join(", "), diff --git a/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/ProvistaGrouped.tsx b/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/ProvistaGrouped.tsx index 3ae5d39bb..acefec883 100644 --- a/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/ProvistaGrouped.tsx +++ b/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/ProvistaGrouped.tsx @@ -22,7 +22,7 @@ export const ProtvistaGrouped: React.FC = React.memo(() = return ( - {i18n.t("Protein")}: {loader.data.protein.id} | {i18n.t("PDB")}: {loader.data.id} | + {i18n.t("Protein")}: {loader.data.protein?.id} | {i18n.t("PDB")}: {loader.data.id} | {i18n.t("Chain")}: {loader.data.chainId} diff --git a/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/ToolsButton.tsx b/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/ToolsButton.tsx index 67b8d2a0d..96257ecce 100644 --- a/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/ToolsButton.tsx +++ b/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/ToolsButton.tsx @@ -42,7 +42,7 @@ export const ToolsButton: React.FC = props => { return updateLoader( "exportAnnotations", compositionRoot.exportAllAnnotations - .execute({ proteinId: protein.id, pdbId: id, chainId, emdbs }) + .execute({ proteinId: protein?.id, pdbId: id, chainId, emdbs }) .toPromise() ); } diff --git a/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/Tooltip.tsx b/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/Tooltip.tsx index bd5d1b21e..d3ca42e91 100644 --- a/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/Tooltip.tsx +++ b/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/Tooltip.tsx @@ -74,7 +74,11 @@ const Tools: React.FC<{ pdb: Pdb; subtrack: Subtrack; fragment: FragmentP }> = p return ( {link => } diff --git a/app/assets/javascripts/3dbio_viewer/src/webapp/hooks/use-pdb.ts b/app/assets/javascripts/3dbio_viewer/src/webapp/hooks/use-pdb.ts index 4aa393087..16ebeb0a1 100644 --- a/app/assets/javascripts/3dbio_viewer/src/webapp/hooks/use-pdb.ts +++ b/app/assets/javascripts/3dbio_viewer/src/webapp/hooks/use-pdb.ts @@ -52,5 +52,5 @@ export function getPdbOptions( .get(chainId, defaultChain) : defaultChain; - return chain ? { pdbId, proteinId: chain.protein.id, chainId: chain.chainId } : undefined; + return chain ? { pdbId, proteinId: chain.protein?.id, chainId: chain.chainId } : undefined; } From ac9c86d7dfa1fb33ddb99d72dc40126d2223dcf0 Mon Sep 17 00:00:00 2001 From: p3rcypj Date: Mon, 29 Jan 2024 13:42:50 +0000 Subject: [PATCH 06/19] GitHub actions --- .github/workflows/github-actions-demo.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/github-actions-demo.yml diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml new file mode 100644 index 000000000..15a61d6b6 --- /dev/null +++ b/.github/workflows/github-actions-demo.yml @@ -0,0 +1,18 @@ +name: GitHub Actions Demo +run-name: ${{ github.actor }} is testing out GitHub Actions 🚀 +on: [push] +jobs: + Explore-GitHub-Actions: + runs-on: ubuntu-latest + steps: + - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." + - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" + - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." + - name: Check out repository code + uses: actions/checkout@v4 + - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." + - run: echo "🖥️ The workflow is now ready to test your code on the runner." + - name: List files in the repository + run: | + ls ${{ github.workspace }} + - run: echo "🍏 This job's status is ${{ job.status }}." From c7859877ac92e1690bbecf9c5f57ee6363e64b41 Mon Sep 17 00:00:00 2001 From: p3rcypj Date: Mon, 29 Jan 2024 14:21:22 +0000 Subject: [PATCH 07/19] Remove demo, add yarn install yarn build --- .github/workflows/github-actions-demo.yml | 18 ---------------- .github/workflows/node.js.yml | 26 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 18 deletions(-) delete mode 100644 .github/workflows/github-actions-demo.yml create mode 100644 .github/workflows/node.js.yml diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml deleted file mode 100644 index 15a61d6b6..000000000 --- a/.github/workflows/github-actions-demo.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: GitHub Actions Demo -run-name: ${{ github.actor }} is testing out GitHub Actions 🚀 -on: [push] -jobs: - Explore-GitHub-Actions: - runs-on: ubuntu-latest - steps: - - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." - - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" - - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." - - name: Check out repository code - uses: actions/checkout@v4 - - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." - - run: echo "🖥️ The workflow is now ready to test your code on the runner." - - name: List files in the repository - run: | - ls ${{ github.workspace }} - - run: echo "🍏 This job's status is ${{ job.status }}." diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 000000000..6359cb749 --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,26 @@ +name: Yarn CI +on: [push, pull_request] +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [14.x, 16.x, 18.x] + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '16.14.0' + cache: 'npm' + + - name: Install dependencies and build (3dbio_viewer, covid19) + run: | + cd app/assets/javascripts/3dbio_viewer + yarn install + yarn build + cd ../../../../ + cd app/assets/javascripts/covid19 + yarn install + yarn build \ No newline at end of file From c40ea8e3adeeca70349b21af1ae776ec584a7850 Mon Sep 17 00:00:00 2001 From: p3rcypj Date: Mon, 29 Jan 2024 14:28:21 +0000 Subject: [PATCH 08/19] Remove cache --- .github/workflows/node.js.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 6359cb749..92f2a51c9 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -10,10 +10,9 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - name: Set up Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v3 with: node-version: '16.14.0' - cache: 'npm' - name: Install dependencies and build (3dbio_viewer, covid19) run: | From 559d3a60dbd2ea271dbde2a074c9647fd690e76c Mon Sep 17 00:00:00 2001 From: p3rcypj Date: Mon, 29 Jan 2024 14:33:57 +0000 Subject: [PATCH 09/19] Remove strategy matrix --- .github/workflows/node.js.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 92f2a51c9..5e5afed00 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -3,9 +3,7 @@ on: [push, pull_request] jobs: build: runs-on: ubuntu-latest - strategy: - matrix: - node-version: [14.x, 16.x, 18.x] + steps: - name: Checkout repository uses: actions/checkout@v3 @@ -13,7 +11,6 @@ jobs: uses: actions/setup-node@v3 with: node-version: '16.14.0' - - name: Install dependencies and build (3dbio_viewer, covid19) run: | cd app/assets/javascripts/3dbio_viewer From 71a6c07e62e90a0d04ac66c723b9f6d3cddbf753 Mon Sep 17 00:00:00 2001 From: p3rcypj Date: Mon, 29 Jan 2024 14:36:07 +0000 Subject: [PATCH 10/19] To execute on pull_request only --- .github/workflows/node.js.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 5e5afed00..8fbe4d94e 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -1,5 +1,5 @@ name: Yarn CI -on: [push, pull_request] +on: [pull_request] jobs: build: runs-on: ubuntu-latest From 07d3f5067e2616be42bbbfec5872fb0215110349 Mon Sep 17 00:00:00 2001 From: p3rcypj Date: Mon, 29 Jan 2024 14:42:38 +0000 Subject: [PATCH 11/19] Fix temp warnings --- .../protvista/ApiPdbRepository.ts | 60 ++++++++++++++----- .../components/loader-mask/LoaderMask.tsx | 2 +- 2 files changed, 46 insertions(+), 16 deletions(-) diff --git a/app/assets/javascripts/3dbio_viewer/src/data/repositories/protvista/ApiPdbRepository.ts b/app/assets/javascripts/3dbio_viewer/src/data/repositories/protvista/ApiPdbRepository.ts index 7962b3987..c28e697c8 100644 --- a/app/assets/javascripts/3dbio_viewer/src/data/repositories/protvista/ApiPdbRepository.ts +++ b/app/assets/javascripts/3dbio_viewer/src/data/repositories/protvista/ApiPdbRepository.ts @@ -5,27 +5,57 @@ import { PdbRepository } from "../../../domain/repositories/PdbRepository"; import { Future } from "../../../utils/future"; import { getTotalFeaturesLength } from "../../../domain/entities/Track"; import { debugVariable } from "../../../utils/debug"; -import { getEmValidationFragments, PdbAnnotations } from "./tracks/em-validation"; +import { + getEmValidationFragments as _getEmValidationFragments, + PdbAnnotations, +} from "./tracks/em-validation"; import { EbiVariation, GenomicVariantsCNCBResponse, getVariants } from "./tracks/variants"; -import { getPhosphiteFragments, PhosphositeUniprot } from "./tracks/phosphite"; -import { Features, getFeatureFragments } from "./tracks/feature"; +import { + getPhosphiteFragments as _getPhosphiteFragments, + PhosphositeUniprot, +} from "./tracks/phosphite"; +import { Features, getFeatureFragments as _getFeatureFragments } from "./tracks/feature"; import { Coverage, getStructureCoverageFragments } from "./tracks/structure-coverage"; -import { getMobiUniprotFragments, MobiUniprot } from "./tracks/mobi"; -import { Cv19Tracks, getFunctionalMappingFragments } from "./tracks/functional-mapping"; -import { getProteomicsFragments, Proteomics } from "./tracks/proteomics"; -import { getPdbRedoFragments, PdbRedo } from "./tracks/pdb-redo"; -import { getEpitomesFragments, IedbAnnotationsResponse } from "./tracks/epitomes"; +import { getMobiUniprotFragments as _getMobiUniprotFragments, MobiUniprot } from "./tracks/mobi"; +import { + Cv19Tracks, + getFunctionalMappingFragments as _getFunctionalMappingFragments, +} from "./tracks/functional-mapping"; +import { getProteomicsFragments as _getProteomicsFragments, Proteomics } from "./tracks/proteomics"; +import { getPdbRedoFragments as _getPdbRedoFragments, PdbRedo } from "./tracks/pdb-redo"; +import { + getEpitomesFragments as _getEpitomesFragments, + IedbAnnotationsResponse, +} from "./tracks/epitomes"; import { getProtein, UniprotResponse } from "./uniprot"; import { getExperiment, PdbExperiment } from "./ebi-pdbe-api"; import { getTracksFromFragments } from "../../../domain/entities/Fragment2"; -import { getPfamDomainFragments, PfamAnnotations } from "./tracks/pfam-domain"; -import { getSmartDomainFragments, SmartAnnotations } from "./tracks/smart-domain"; -import { getInterproDomainFragments, InterproAnnotations } from "./tracks/interpro-domain"; -import { ElmdbUniprot, getElmdbUniprotFragments } from "./tracks/elmdb"; +import { + getPfamDomainFragments as _getPfamDomainFragments, + PfamAnnotations, +} from "./tracks/pfam-domain"; +import { + getSmartDomainFragments as _getSmartDomainFragments, + SmartAnnotations, +} from "./tracks/smart-domain"; +import { + getInterproDomainFragments as _getInterproDomainFragments, + InterproAnnotations, +} from "./tracks/interpro-domain"; +import { + ElmdbUniprot, + getElmdbUniprotFragments as _getElmdbUniprotFragments, +} from "./tracks/elmdb"; import { getJSON, getValidatedJSON, getXML, RequestError } from "../../request-utils"; -import { DbPtmAnnotations, getDbPtmFragments } from "./tracks/db-ptm"; -import { getMolprobityFragments, MolprobityResponse } from "./molprobity"; -import { AntigenicResponse, getAntigenicFragments } from "./tracks/antigenic"; +import { DbPtmAnnotations, getDbPtmFragments as _getDbPtmFragments } from "./tracks/db-ptm"; +import { + getMolprobityFragments as _getMolprobityFragments, + MolprobityResponse, +} from "./molprobity"; +import { + AntigenicResponse, + getAntigenicFragments as _getAntigenicFragments, +} from "./tracks/antigenic"; import { Variants } from "../../../domain/entities/Variant"; import { emdbsFromPdbUrl, getEmdbsFromMapping, PdbEmdbMapping } from "../mapping"; import { MutagenesisResponse } from "./tracks/mutagenesis"; diff --git a/app/assets/javascripts/3dbio_viewer/src/webapp/components/loader-mask/LoaderMask.tsx b/app/assets/javascripts/3dbio_viewer/src/webapp/components/loader-mask/LoaderMask.tsx index c42bb4aec..49c1aff91 100644 --- a/app/assets/javascripts/3dbio_viewer/src/webapp/components/loader-mask/LoaderMask.tsx +++ b/app/assets/javascripts/3dbio_viewer/src/webapp/components/loader-mask/LoaderMask.tsx @@ -2,7 +2,7 @@ import React from "react"; import { Backdrop, CircularProgress, makeStyles } from "@material-ui/core"; import { Cancel as CancelIcon } from "@material-ui/icons"; import styled from "styled-components"; -import { isDev } from "../../../routes"; +import { isDev as _isDev } from "../../../routes"; interface LoaderProps { open: boolean; From 4fc127287f352122c7d50b39f130aedfa42fb6aa Mon Sep 17 00:00:00 2001 From: p3rcypj Date: Mon, 29 Jan 2024 14:51:12 +0000 Subject: [PATCH 12/19] Update caniuse --- .github/workflows/node.js.yml | 6 ++++-- app/assets/javascripts/3dbio_viewer/yarn.lock | 6 +++--- app/assets/javascripts/covid19/yarn.lock | 6 +++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 8fbe4d94e..2deb79ad4 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -11,12 +11,14 @@ jobs: uses: actions/setup-node@v3 with: node-version: '16.14.0' - - name: Install dependencies and build (3dbio_viewer, covid19) + - name: Install and build (3dbio_viewer) run: | cd app/assets/javascripts/3dbio_viewer yarn install yarn build - cd ../../../../ + - name: Install and build (covid19) + run: | cd app/assets/javascripts/covid19 yarn install + yarn localize yarn build \ No newline at end of file diff --git a/app/assets/javascripts/3dbio_viewer/yarn.lock b/app/assets/javascripts/3dbio_viewer/yarn.lock index f0dc54150..830c8433b 100644 --- a/app/assets/javascripts/3dbio_viewer/yarn.lock +++ b/app/assets/javascripts/3dbio_viewer/yarn.lock @@ -4140,9 +4140,9 @@ caniuse-api@^3.0.0: lodash.uniq "^4.5.0" caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001125, caniuse-lite@^1.0.30001164: - version "1.0.30001486" - resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001486.tgz" - integrity sha512-uv7/gXuHi10Whlj0pp5q/tsK/32J2QSqVRKQhs2j8VsDCjgyruAh/eEXHF822VqO9yT6iZKw3nRwZRSPBE9OQg== + version "1.0.30001581" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001581.tgz" + integrity sha512-whlTkwhqV2tUmP3oYhtNfaWGYHDdS3JYFQBKXxcUR9qqPWsRhFHhoISO2Xnl/g0xyKzht9mI1LZpiNWfMzHixQ== capture-exit@^2.0.0: version "2.0.0" diff --git a/app/assets/javascripts/covid19/yarn.lock b/app/assets/javascripts/covid19/yarn.lock index 1c3805a08..b13e9c441 100644 --- a/app/assets/javascripts/covid19/yarn.lock +++ b/app/assets/javascripts/covid19/yarn.lock @@ -5133,9 +5133,9 @@ caniuse-api@^3.0.0: lodash.uniq "^4.5.0" caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001087, caniuse-lite@^1.0.30001088, caniuse-lite@^1.0.30001125, caniuse-lite@^1.0.30001165, caniuse-lite@^1.0.30001248: - version "1.0.30001473" - resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001473.tgz" - integrity sha512-ewDad7+D2vlyy+E4UJuVfiBsU69IL+8oVmTuZnH5Q6CIUbxNfI50uVpRHbUPDD6SUaN2o0Lh4DhTrvLG/Tn1yg== + version "1.0.30001581" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001581.tgz" + integrity sha512-whlTkwhqV2tUmP3oYhtNfaWGYHDdS3JYFQBKXxcUR9qqPWsRhFHhoISO2Xnl/g0xyKzht9mI1LZpiNWfMzHixQ== capture-exit@^2.0.0: version "2.0.0" From 3f23ea26e3c3a0dda797336eede2231d7c9c5d5c Mon Sep 17 00:00:00 2001 From: p3rcypj Date: Tue, 6 Feb 2024 10:55:33 +0000 Subject: [PATCH 13/19] Revert "Temporal fix for UniprotID missing" This reverts commit b7cab48f5b9795c6ef166affd73452d911d74737. --- .../protvista/ApiPdbRepository.ts | 87 +++++++++---------- .../3dbio_viewer/src/domain/entities/Pdb.ts | 4 +- .../src/domain/entities/PdbInfo.ts | 16 +--- .../src/domain/repositories/PdbRepository.ts | 4 +- .../src/webapp/components/BasicInfoViewer.tsx | 2 +- .../src/webapp/components/ChainInfoViewer.tsx | 16 ++-- .../components/gene-viewer/GeneViewer.tsx | 1 - .../src/webapp/components/ppi/ppi-data.ts | 1 - .../components/protvista/ProtvistaViewer.tsx | 12 +-- .../components/protvista/ProvistaGrouped.tsx | 2 +- .../components/protvista/ToolsButton.tsx | 2 +- .../webapp/components/protvista/Tooltip.tsx | 6 +- .../3dbio_viewer/src/webapp/hooks/use-pdb.ts | 2 +- 13 files changed, 62 insertions(+), 93 deletions(-) diff --git a/app/assets/javascripts/3dbio_viewer/src/data/repositories/protvista/ApiPdbRepository.ts b/app/assets/javascripts/3dbio_viewer/src/data/repositories/protvista/ApiPdbRepository.ts index c28e697c8..ed14f95ff 100644 --- a/app/assets/javascripts/3dbio_viewer/src/data/repositories/protvista/ApiPdbRepository.ts +++ b/app/assets/javascripts/3dbio_viewer/src/data/repositories/protvista/ApiPdbRepository.ts @@ -111,7 +111,7 @@ interface Data { type DataRequests = { [K in keyof Data]-?: Future }; interface Options { - proteinId: Maybe; + proteinId: string; pdbId: Maybe; chainId: string; } @@ -133,33 +133,34 @@ export class ApiPdbRepository implements PdbRepository { debugVariable({ apiData: data }); const { proteinId } = options; - const variants = proteinId - ? getVariants(data.ebiVariation, data.mutagenesis, data.genomicVariantsCNCB, proteinId) - : undefined; + const variants = getVariants( + data.ebiVariation, + data.mutagenesis, + data.genomicVariantsCNCB, + proteinId + ); // prettier-ignore const fragmentsList = { + featureFragments: on(data.features, features => getFeatureFragments(options.proteinId, features)), + pfamDomainFragments: on(data.pfamAnnotations, pfamAnnotations => getPfamDomainFragments(pfamAnnotations, proteinId)), + smartDomainFragments: on(data.smartAnnotations, smartAnnotations => getSmartDomainFragments(smartAnnotations, proteinId)), + interproFragments: on(data.interproAnnotations, interproAnnotations => getInterproDomainFragments(interproAnnotations, proteinId)), + elmdbFragments: on(data.elmdbUniprot, elmdbUniprot => getElmdbUniprotFragments(elmdbUniprot, proteinId)), + functionalMappingFragments: on(data.cv19Tracks, getFunctionalMappingFragments), structureCoverageFragments: on(data.coverage, coverage => getStructureCoverageFragments(coverage, options.chainId)), - // emValidationFragments: on(data.pdbAnnotations, pdbAnnotations => getEmValidationFragments(pdbAnnotations, options.chainId)), - // pdbRedoFragments: on(data.pdbRedo, pdbRedo => getPdbRedoFragments(pdbRedo, options.chainId)), - // molprobityFragments: on(data.molprobity, molprobity => getMolprobityFragments(molprobity, options.chainId)), - // ...(proteinId ? { - // featureFragments: on(data.features, features => getFeatureFragments(proteinId, features)), - // functionalMappingFragments: on(data.cv19Tracks, getFunctionalMappingFragments), - // epitomesFragments: on(data.iedb, getEpitomesFragments), - // pfamDomainFragments: on(data.pfamAnnotations, pfamAnnotations => getPfamDomainFragments(pfamAnnotations, proteinId)), - // smartDomainFragments: on(data.smartAnnotations, smartAnnotations => getSmartDomainFragments(smartAnnotations, proteinId)), - // interproFragments: on(data.interproAnnotations, interproAnnotations => getInterproDomainFragments(interproAnnotations, proteinId)), - // elmdbFragments: on(data.elmdbUniprot, elmdbUniprot => getElmdbUniprotFragments(elmdbUniprot, proteinId)), - // mobiFragments: on(data.mobiUniprot, mobiUniprot => getMobiUniprotFragments(mobiUniprot, proteinId)), - // proteomicsFragments: on(data.proteomics, proteomics => getProteomicsFragments(proteomics, proteinId)), - // phosphiteFragments: on(data.phosphositeUniprot, phosphositeUniprot => getPhosphiteFragments(phosphositeUniprot, proteinId)), - // dbPtmFragments: on(data.dbPtm, dbPtm => getDbPtmFragments(dbPtm, proteinId)), - // antigenFragments: on(data.antigenic, antigenic => getAntigenicFragments(antigenic, proteinId)) - // } : {}), + emValidationFragments: on(data.pdbAnnotations, pdbAnnotations => getEmValidationFragments(pdbAnnotations, options.chainId)), + mobiFragments: on(data.mobiUniprot, mobiUniprot => getMobiUniprotFragments(mobiUniprot, proteinId)), + proteomicsFragments: on(data.proteomics, proteomics => getProteomicsFragments(proteomics, proteinId)), + pdbRedoFragments: on(data.pdbRedo, pdbRedo => getPdbRedoFragments(pdbRedo, options.chainId)), + epitomesFragments: on(data.iedb, getEpitomesFragments), + phosphiteFragments: on(data.phosphositeUniprot, phosphositeUniprot => getPhosphiteFragments(phosphositeUniprot, proteinId)), + dbPtmFragments: on(data.dbPtm, dbPtm => getDbPtmFragments(dbPtm, proteinId)), + molprobityFragments: on(data.molprobity, molprobity => getMolprobityFragments(molprobity, options.chainId)), + antigenFragments: on(data.antigenic, antigenic => getAntigenicFragments(antigenic, proteinId)), }; - const protein = proteinId ? getProtein(proteinId, data.uniprot) : undefined; + const protein = getProtein(proteinId, data.uniprot); const experiment = on(data.pdbExperiment, pdbExperiment => options.pdbId ? getExperiment(options.pdbId, pdbExperiment) : undefined ); @@ -256,35 +257,31 @@ function getData(options: Options): FutureData> { // Move URLS to each track module? //prettier-ignore - const data$: Partial = { - //PDBID - pdbSummary: onF(pdbId, pdbId => getJSON(`${ebiBaseUrl}/pdbe/api/pdb/entry/summary/${pdbId}`)), + const data$: DataRequests = { + uniprot: getXML(`${routes.uniprot}/uniprotkb/${proteinId}.xml`), + pdbEmdbsEmValidations, + features: getJSON(`${ebiProteinsApiUrl}/features/${proteinId}`), + cv19Tracks: getJSON(`${bioUrl}/cv19_annotations/${proteinId}_annotations.json`), pdbAnnotations: onF(pdbId, pdbId => getJSON(`${pdbAnnotUrl}/all/${pdbId}/${chainId}/?format=json`)), pdbPublications, coverage: onF(pdbId, pdbId => getJSON(`${bioUrl}/api/alignments/Coverage/${pdbId}${chainId}`)), + pdbSummary: onF(pdbId, pdbId => getJSON(`${ebiBaseUrl}/pdbe/api/pdb/entry/summary/${pdbId}`)), + ebiVariation: getJSON(`${ebiProteinsApiUrl}/variation/${proteinId}`), + mobiUniprot: getJSON(`${bioUrl}/api/annotations/mobi/Uniprot/${proteinId}`), + phosphositeUniprot: getJSON(`${bioUrl}/api/annotations/Phosphosite/Uniprot/${proteinId}`), + dbPtm: getJSON(`${bioUrl}/api/annotations/dbptm/Uniprot/${proteinId}`), + pfamAnnotations: getJSON(`${bioUrl}/api/annotations/Pfam/Uniprot/${proteinId}`), + smartAnnotations: getJSON(`${bioUrl}/api/annotations/SMART/Uniprot/${proteinId}`), + interproAnnotations: getJSON(`${bioUrl}/api/annotations/interpro/Uniprot/${proteinId}`), + proteomics: getJSON(`${ebiProteinsApiUrl}/proteomics/${proteinId}`), pdbRedo: onF(pdbId, pdbId => getJSON(`${bioUrl}/api/annotations/PDB_REDO/${pdbId}`)), + iedb: getJSON(`${bioUrl}/api/annotations/IEDB/Uniprot/${proteinId}`), pdbExperiment: onF(pdbId, pdbId => getJSON(`${ebiBaseUrl}/pdbe/api/pdb/entry/experiment/${pdbId}`)), + elmdbUniprot: getJSON(`${bioUrl}/api/annotations/elmdb/Uniprot/${proteinId}`), molprobity: onF(pdbId, pdbId => getJSON(`${bioUrl}/compute/molprobity/${pdbId}`)), - //UNIPROT - ...(proteinId ? { - uniprot: getXML(`${routes.uniprot}/uniprotkb/${proteinId}.xml`), - pdbEmdbsEmValidations, - features: getJSON(`${ebiProteinsApiUrl}/features/${proteinId}`), - cv19Tracks: getJSON(`${bioUrl}/cv19_annotations/${proteinId}_annotations.json`), - ebiVariation: getJSON(`${ebiProteinsApiUrl}/variation/${proteinId}`), - mobiUniprot: getJSON(`${bioUrl}/api/annotations/mobi/Uniprot/${proteinId}`), - phosphositeUniprot: getJSON(`${bioUrl}/api/annotations/Phosphosite/Uniprot/${proteinId}`), - dbPtm: getJSON(`${bioUrl}/api/annotations/dbptm/Uniprot/${proteinId}`), - pfamAnnotations: getJSON(`${bioUrl}/api/annotations/Pfam/Uniprot/${proteinId}`), - smartAnnotations: getJSON(`${bioUrl}/api/annotations/SMART/Uniprot/${proteinId}`), - interproAnnotations: getJSON(`${bioUrl}/api/annotations/interpro/Uniprot/${proteinId}`), - proteomics: getJSON(`${ebiProteinsApiUrl}/proteomics/${proteinId}`), - iedb: getJSON(`${bioUrl}/api/annotations/IEDB/Uniprot/${proteinId}`), - elmdbUniprot: getJSON(`${bioUrl}/api/annotations/elmdb/Uniprot/${proteinId}`), - antigenic: getJSON(`${ebiProteinsApiUrl}/antigen/${proteinId}`), - mutagenesis: getJSON(`${bioUrl}/api/annotations/biomuta/Uniprot/${proteinId}`), - genomicVariantsCNCB: getJSON(`${bioUrl}/ws/lrs/features/variants/Genomic_Variants_CNCB/${proteinId}/`) - } : {}), + antigenic: getJSON(`${ebiProteinsApiUrl}/antigen/${proteinId}`), + mutagenesis: getJSON(`${bioUrl}/api/annotations/biomuta/Uniprot/${proteinId}`), + genomicVariantsCNCB: getJSON(`${bioUrl}/ws/lrs/features/variants/Genomic_Variants_CNCB/${proteinId}/`), ligands, }; diff --git a/app/assets/javascripts/3dbio_viewer/src/domain/entities/Pdb.ts b/app/assets/javascripts/3dbio_viewer/src/domain/entities/Pdb.ts index 1a55e64db..b47b2a73a 100644 --- a/app/assets/javascripts/3dbio_viewer/src/domain/entities/Pdb.ts +++ b/app/assets/javascripts/3dbio_viewer/src/domain/entities/Pdb.ts @@ -15,7 +15,7 @@ export interface Pdb { title: Maybe; experiment: Maybe; emdbs: Emdb[]; - protein: Maybe; + protein: Protein; chainId: string; sequence: string; length: number; @@ -108,12 +108,10 @@ export function getEntityLinks(pdb: Pdb, entity: PdbEntity): Link[] { })); } case "uniprot": { - if (!pdb.protein) return []; const proteinId = pdb.protein.id.toUpperCase(); return [{ name: proteinId, url: `https://www.uniprot.org/uniprot/${proteinId}` }]; } case "geneBank": { - if (!pdb.protein) return []; return pdb.protein.genBank ? pdb.protein.genBank?.map(id => ({ name: id ?? "-", diff --git a/app/assets/javascripts/3dbio_viewer/src/domain/entities/PdbInfo.ts b/app/assets/javascripts/3dbio_viewer/src/domain/entities/PdbInfo.ts index b5d6bc9f0..11a2b6349 100644 --- a/app/assets/javascripts/3dbio_viewer/src/domain/entities/PdbInfo.ts +++ b/app/assets/javascripts/3dbio_viewer/src/domain/entities/PdbInfo.ts @@ -13,7 +13,7 @@ export interface PdbInfo { name: string; shortName: string; chainId: ChainId; - protein: Maybe; + protein: Protein; }>; ligands: Ligand[]; } @@ -45,20 +45,6 @@ export function buildPdbInfo(options: BuildPdbInfoOptions): PdbInfo { .sortBy(obj => obj.chainId) .value(); - if (_.isEmpty(chains) && _.isEmpty(options.proteins)) - return { - ...options, - chains: [ - { - id: "A", - name: "A", - shortName: "A", - chainId: "A", - protein: undefined, - }, - ], - }; - return { ...options, chains }; } diff --git a/app/assets/javascripts/3dbio_viewer/src/domain/repositories/PdbRepository.ts b/app/assets/javascripts/3dbio_viewer/src/domain/repositories/PdbRepository.ts index 69e0372c8..9f52c4d91 100644 --- a/app/assets/javascripts/3dbio_viewer/src/domain/repositories/PdbRepository.ts +++ b/app/assets/javascripts/3dbio_viewer/src/domain/repositories/PdbRepository.ts @@ -9,7 +9,7 @@ export interface PdbRepository { } export interface PdbOptions { - proteinId: Maybe; + proteinId: ProteinId; pdbId: Maybe; - chainId: Maybe; + chainId: ChainId; } diff --git a/app/assets/javascripts/3dbio_viewer/src/webapp/components/BasicInfoViewer.tsx b/app/assets/javascripts/3dbio_viewer/src/webapp/components/BasicInfoViewer.tsx index 584350120..b9a9135f0 100644 --- a/app/assets/javascripts/3dbio_viewer/src/webapp/components/BasicInfoViewer.tsx +++ b/app/assets/javascripts/3dbio_viewer/src/webapp/components/BasicInfoViewer.tsx @@ -81,7 +81,7 @@ function getItems(pdb: Pdb) { const resolution = pdb.experiment?.resolution; const items: Item[] = _.compact([ - pdb.protein ? { name: i18n.t("Organism"), value: pdb.protein.organism } : undefined, + { name: i18n.t("Organism"), value: pdb.protein.organism }, { name: i18n.t("Biological function"), isDisabled: true, diff --git a/app/assets/javascripts/3dbio_viewer/src/webapp/components/ChainInfoViewer.tsx b/app/assets/javascripts/3dbio_viewer/src/webapp/components/ChainInfoViewer.tsx index 0e8e10e1f..cd1e709f8 100644 --- a/app/assets/javascripts/3dbio_viewer/src/webapp/components/ChainInfoViewer.tsx +++ b/app/assets/javascripts/3dbio_viewer/src/webapp/components/ChainInfoViewer.tsx @@ -52,17 +52,11 @@ const Child: React.FC = props => { function getItems(pdb: Pdb): Item[] { return _.compact([ - pdb.protein ? { name: i18n.t("Gene Name"), value: pdb.protein.gen } : undefined, - pdb.protein - ? { - name: i18n.t("Gene Bank ID"), - value: pdb.protein.genBank ? ( - - ) : ( - "-" - ), - } - : undefined, + { name: i18n.t("Gene Name"), value: pdb.protein.gen }, + { + name: i18n.t("Gene Bank ID"), + value: pdb.protein.genBank ? : "-", + }, { name: i18n.t("Uniprot ID"), value: , diff --git a/app/assets/javascripts/3dbio_viewer/src/webapp/components/gene-viewer/GeneViewer.tsx b/app/assets/javascripts/3dbio_viewer/src/webapp/components/gene-viewer/GeneViewer.tsx index c6bf2d405..184975039 100644 --- a/app/assets/javascripts/3dbio_viewer/src/webapp/components/gene-viewer/GeneViewer.tsx +++ b/app/assets/javascripts/3dbio_viewer/src/webapp/components/gene-viewer/GeneViewer.tsx @@ -13,7 +13,6 @@ interface GeneViewerProps { export const GeneViewer: React.FC = props => { const { trackDef, pdb } = props; - if (!pdb.protein) throw new Error("No UniprotID to show GeneViewer"); const src = routes.bionotes + `/genomicIFrame?uniprot_acc=${pdb.protein.id.toUpperCase()}`; const title = `${trackDef.name}`; diff --git a/app/assets/javascripts/3dbio_viewer/src/webapp/components/ppi/ppi-data.ts b/app/assets/javascripts/3dbio_viewer/src/webapp/components/ppi/ppi-data.ts index 24efdee4e..a52c2bd42 100644 --- a/app/assets/javascripts/3dbio_viewer/src/webapp/components/ppi/ppi-data.ts +++ b/app/assets/javascripts/3dbio_viewer/src/webapp/components/ppi/ppi-data.ts @@ -67,7 +67,6 @@ export interface InfoAlignmentFromNetwork { } export function getInfoAlignmentFromPdb(pdb: Pdb): Maybe { - if (!pdb.protein) return undefined; if (pdb.proteinNetwork) { return { origin: "interactome3d", diff --git a/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/ProtvistaViewer.tsx b/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/ProtvistaViewer.tsx index db5c966b2..97bd16ed4 100644 --- a/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/ProtvistaViewer.tsx +++ b/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/ProtvistaViewer.tsx @@ -51,17 +51,17 @@ export const ProtvistaViewer: React.FC = props => { const geneName = React.useMemo( () => - pdb.protein?.gen - ? i18n.t(" encoded by the gene {{geneName}}", { geneName: pdb.protein?.gen }) + pdb.protein.gen + ? i18n.t(" encoded by the gene {{geneName}}", { geneName: pdb.protein.gen }) : undefined, [pdb.protein] ); const geneBankEntry = React.useMemo( () => - !_.isEmpty(pdb.protein?.genBank) + !_.isEmpty(pdb.protein.genBank) ? i18n.t(" (GeneBank {{geneBankEntry}})", { - geneBankEntry: pdb.protein?.genBank?.join(", "), + geneBankEntry: pdb.protein.genBank?.join(", "), }) : undefined, [pdb.protein] @@ -71,11 +71,11 @@ export const ProtvistaViewer: React.FC = props => { () => ({ poorQualityRegionMax: _.first(pdb.emdbs)?.emv?.stats?.quartile75, poorQualityRegionMin: _.first(pdb.emdbs)?.emv?.stats?.quartile25, - proteinName: pdb.protein?.name, + proteinName: pdb.protein.name, ligandsAndSmallMoleculesCount, resolution: _.first(pdb.emdbs)?.emv?.stats?.resolutionMedian, chain: pdb.chainId, - chainWithProtein: `${pdb.chainId}${pdb.protein?.name ? " - " + pdb.protein.name : ""}`, + chainWithProtein: `${pdb.chainId}${pdb.protein.name ? " - " + pdb.protein.name : ""}`, uniprotId: getEntityLinks(pdb, "uniprot") .map(link => link.name) .join(", "), diff --git a/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/ProvistaGrouped.tsx b/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/ProvistaGrouped.tsx index acefec883..3ae5d39bb 100644 --- a/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/ProvistaGrouped.tsx +++ b/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/ProvistaGrouped.tsx @@ -22,7 +22,7 @@ export const ProtvistaGrouped: React.FC = React.memo(() = return ( - {i18n.t("Protein")}: {loader.data.protein?.id} | {i18n.t("PDB")}: {loader.data.id} | + {i18n.t("Protein")}: {loader.data.protein.id} | {i18n.t("PDB")}: {loader.data.id} | {i18n.t("Chain")}: {loader.data.chainId} diff --git a/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/ToolsButton.tsx b/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/ToolsButton.tsx index 96257ecce..67b8d2a0d 100644 --- a/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/ToolsButton.tsx +++ b/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/ToolsButton.tsx @@ -42,7 +42,7 @@ export const ToolsButton: React.FC = props => { return updateLoader( "exportAnnotations", compositionRoot.exportAllAnnotations - .execute({ proteinId: protein?.id, pdbId: id, chainId, emdbs }) + .execute({ proteinId: protein.id, pdbId: id, chainId, emdbs }) .toPromise() ); } diff --git a/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/Tooltip.tsx b/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/Tooltip.tsx index d3ca42e91..bd5d1b21e 100644 --- a/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/Tooltip.tsx +++ b/app/assets/javascripts/3dbio_viewer/src/webapp/components/protvista/Tooltip.tsx @@ -74,11 +74,7 @@ const Tools: React.FC<{ pdb: Pdb; subtrack: Subtrack; fragment: FragmentP }> = p return ( {link => } diff --git a/app/assets/javascripts/3dbio_viewer/src/webapp/hooks/use-pdb.ts b/app/assets/javascripts/3dbio_viewer/src/webapp/hooks/use-pdb.ts index 16ebeb0a1..4aa393087 100644 --- a/app/assets/javascripts/3dbio_viewer/src/webapp/hooks/use-pdb.ts +++ b/app/assets/javascripts/3dbio_viewer/src/webapp/hooks/use-pdb.ts @@ -52,5 +52,5 @@ export function getPdbOptions( .get(chainId, defaultChain) : defaultChain; - return chain ? { pdbId, proteinId: chain.protein?.id, chainId: chain.chainId } : undefined; + return chain ? { pdbId, proteinId: chain.protein.id, chainId: chain.chainId } : undefined; } From 065160c48c84ae421bbcf9647b6064271256fec0 Mon Sep 17 00:00:00 2001 From: p3rcypj Date: Tue, 6 Feb 2024 11:05:27 +0000 Subject: [PATCH 14/19] Fix previous commit (fix uniprotid on wrong branch) --- .../protvista/ApiPdbRepository.ts | 64 +++++-------------- .../domain/entities/__tests__/PdbInfo.spec.ts | 11 ++-- 2 files changed, 24 insertions(+), 51 deletions(-) diff --git a/app/assets/javascripts/3dbio_viewer/src/data/repositories/protvista/ApiPdbRepository.ts b/app/assets/javascripts/3dbio_viewer/src/data/repositories/protvista/ApiPdbRepository.ts index ed14f95ff..24cdafda3 100644 --- a/app/assets/javascripts/3dbio_viewer/src/data/repositories/protvista/ApiPdbRepository.ts +++ b/app/assets/javascripts/3dbio_viewer/src/data/repositories/protvista/ApiPdbRepository.ts @@ -5,57 +5,27 @@ import { PdbRepository } from "../../../domain/repositories/PdbRepository"; import { Future } from "../../../utils/future"; import { getTotalFeaturesLength } from "../../../domain/entities/Track"; import { debugVariable } from "../../../utils/debug"; -import { - getEmValidationFragments as _getEmValidationFragments, - PdbAnnotations, -} from "./tracks/em-validation"; +import { getEmValidationFragments, PdbAnnotations } from "./tracks/em-validation"; import { EbiVariation, GenomicVariantsCNCBResponse, getVariants } from "./tracks/variants"; -import { - getPhosphiteFragments as _getPhosphiteFragments, - PhosphositeUniprot, -} from "./tracks/phosphite"; -import { Features, getFeatureFragments as _getFeatureFragments } from "./tracks/feature"; +import { getPhosphiteFragments, PhosphositeUniprot } from "./tracks/phosphite"; +import { Features, getFeatureFragments } from "./tracks/feature"; import { Coverage, getStructureCoverageFragments } from "./tracks/structure-coverage"; -import { getMobiUniprotFragments as _getMobiUniprotFragments, MobiUniprot } from "./tracks/mobi"; -import { - Cv19Tracks, - getFunctionalMappingFragments as _getFunctionalMappingFragments, -} from "./tracks/functional-mapping"; -import { getProteomicsFragments as _getProteomicsFragments, Proteomics } from "./tracks/proteomics"; -import { getPdbRedoFragments as _getPdbRedoFragments, PdbRedo } from "./tracks/pdb-redo"; -import { - getEpitomesFragments as _getEpitomesFragments, - IedbAnnotationsResponse, -} from "./tracks/epitomes"; +import { getMobiUniprotFragments, MobiUniprot } from "./tracks/mobi"; +import { Cv19Tracks, getFunctionalMappingFragments } from "./tracks/functional-mapping"; +import { getProteomicsFragments, Proteomics } from "./tracks/proteomics"; +import { getPdbRedoFragments, PdbRedo } from "./tracks/pdb-redo"; +import { getEpitomesFragments, IedbAnnotationsResponse } from "./tracks/epitomes"; import { getProtein, UniprotResponse } from "./uniprot"; import { getExperiment, PdbExperiment } from "./ebi-pdbe-api"; import { getTracksFromFragments } from "../../../domain/entities/Fragment2"; -import { - getPfamDomainFragments as _getPfamDomainFragments, - PfamAnnotations, -} from "./tracks/pfam-domain"; -import { - getSmartDomainFragments as _getSmartDomainFragments, - SmartAnnotations, -} from "./tracks/smart-domain"; -import { - getInterproDomainFragments as _getInterproDomainFragments, - InterproAnnotations, -} from "./tracks/interpro-domain"; -import { - ElmdbUniprot, - getElmdbUniprotFragments as _getElmdbUniprotFragments, -} from "./tracks/elmdb"; +import { getPfamDomainFragments, PfamAnnotations } from "./tracks/pfam-domain"; +import { getSmartDomainFragments, SmartAnnotations } from "./tracks/smart-domain"; +import { getInterproDomainFragments, InterproAnnotations } from "./tracks/interpro-domain"; +import { ElmdbUniprot, getElmdbUniprotFragments } from "./tracks/elmdb"; import { getJSON, getValidatedJSON, getXML, RequestError } from "../../request-utils"; -import { DbPtmAnnotations, getDbPtmFragments as _getDbPtmFragments } from "./tracks/db-ptm"; -import { - getMolprobityFragments as _getMolprobityFragments, - MolprobityResponse, -} from "./molprobity"; -import { - AntigenicResponse, - getAntigenicFragments as _getAntigenicFragments, -} from "./tracks/antigenic"; +import { DbPtmAnnotations, getDbPtmFragments } from "./tracks/db-ptm"; +import { getMolprobityFragments, MolprobityResponse } from "./molprobity"; +import { AntigenicResponse, getAntigenicFragments } from "./tracks/antigenic"; import { Variants } from "../../../domain/entities/Variant"; import { emdbsFromPdbUrl, getEmdbsFromMapping, PdbEmdbMapping } from "../mapping"; import { MutagenesisResponse } from "./tracks/mutagenesis"; @@ -70,13 +40,13 @@ import { getEmValidations, PdbEmdbEmValidations, RankResponse, - rankResponseC, + rankResponseC } from "../../PdbEmdbEmValidations"; import { getPdbLigand, PdbEntryResponse, pdbEntryResponseC, - PdbLigandsResponse, + PdbLigandsResponse } from "../../PdbLigands"; import { getPublicationsCodec, EntryPublications, getPublications } from "../../PdbPublications"; diff --git a/app/assets/javascripts/3dbio_viewer/src/domain/entities/__tests__/PdbInfo.spec.ts b/app/assets/javascripts/3dbio_viewer/src/domain/entities/__tests__/PdbInfo.spec.ts index 7dfe6ac15..a7cc4bb0c 100644 --- a/app/assets/javascripts/3dbio_viewer/src/domain/entities/__tests__/PdbInfo.spec.ts +++ b/app/assets/javascripts/3dbio_viewer/src/domain/entities/__tests__/PdbInfo.spec.ts @@ -9,8 +9,11 @@ describe("PdbInfo", () => { expect(pdbInfo).toBeTruthy(); }); - // it("with PDB 9zzz rejects", async () => { - // const compositionRoot = getCompositionRoot(); - // expect(compositionRoot.getPdbInfo.execute("9zzz").toPromise()).rejects; - // }); + it("with PDB 9zzz rejects", async () => { + const compositionRoot = getCompositionRoot(); + + const getPdbInfo = compositionRoot.getPdbInfo.execute(defaultPdbId).toPromise(); + + await expect(getPdbInfo).rejects.toEqual({}); + }); }); From be6457eb30b12ad88741c693bc0777aeedf7d8f3 Mon Sep 17 00:00:00 2001 From: p3rcypj Date: Tue, 6 Feb 2024 11:38:26 +0000 Subject: [PATCH 15/19] Add trailing commas --- .../src/data/repositories/protvista/ApiPdbRepository.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/3dbio_viewer/src/data/repositories/protvista/ApiPdbRepository.ts b/app/assets/javascripts/3dbio_viewer/src/data/repositories/protvista/ApiPdbRepository.ts index 24cdafda3..93ea97325 100644 --- a/app/assets/javascripts/3dbio_viewer/src/data/repositories/protvista/ApiPdbRepository.ts +++ b/app/assets/javascripts/3dbio_viewer/src/data/repositories/protvista/ApiPdbRepository.ts @@ -40,13 +40,13 @@ import { getEmValidations, PdbEmdbEmValidations, RankResponse, - rankResponseC + rankResponseC, } from "../../PdbEmdbEmValidations"; import { getPdbLigand, PdbEntryResponse, pdbEntryResponseC, - PdbLigandsResponse + PdbLigandsResponse, } from "../../PdbLigands"; import { getPublicationsCodec, EntryPublications, getPublications } from "../../PdbPublications"; From 02be332c0c9b8ed7a753a4b3a5f85a75f8ae4670 Mon Sep 17 00:00:00 2001 From: Arnau Sanchez Date: Wed, 7 Feb 2024 10:43:56 +0100 Subject: [PATCH 16/19] Fixes for jest to run --- app/assets/javascripts/3dbio_viewer/package.json | 4 ++-- .../src/data/repositories/AnnotationsExportApiRepository.ts | 2 ++ app/assets/javascripts/3dbio_viewer/src/utils/download.ts | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/3dbio_viewer/package.json b/app/assets/javascripts/3dbio_viewer/package.json index 4d0bbc7a9..96da9b701 100644 --- a/app/assets/javascripts/3dbio_viewer/package.json +++ b/app/assets/javascripts/3dbio_viewer/package.json @@ -107,7 +107,7 @@ }, "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$", "transformIgnorePatterns": [ - "/node_modules/(?!d2-ui-components)" + "/node_modules/(?!d2-ui-components|molstar)" ], "moduleNameMapper": { "\\.(css|scss)$": "/config/styleMock.js", @@ -122,4 +122,4 @@ "node" ] } -} \ No newline at end of file +} diff --git a/app/assets/javascripts/3dbio_viewer/src/data/repositories/AnnotationsExportApiRepository.ts b/app/assets/javascripts/3dbio_viewer/src/data/repositories/AnnotationsExportApiRepository.ts index ef518ddda..2c4a39569 100644 --- a/app/assets/javascripts/3dbio_viewer/src/data/repositories/AnnotationsExportApiRepository.ts +++ b/app/assets/javascripts/3dbio_viewer/src/data/repositories/AnnotationsExportApiRepository.ts @@ -10,6 +10,8 @@ import { Future } from "../../utils/future"; import { routes } from "../../routes"; import { getJSON } from "../request-utils"; +declare const Blob: any; + export interface AnnotationsFile { blob: Blob; filename: string; diff --git a/app/assets/javascripts/3dbio_viewer/src/utils/download.ts b/app/assets/javascripts/3dbio_viewer/src/utils/download.ts index 53e99e082..8a13391f5 100644 --- a/app/assets/javascripts/3dbio_viewer/src/utils/download.ts +++ b/app/assets/javascripts/3dbio_viewer/src/utils/download.ts @@ -1,10 +1,12 @@ +declare const Blob: any; + export function downloadFile(options: { filename: string; data: string; mimeType: string }): void { const { filename, data, mimeType } = options; const blob = new Blob([data], { type: mimeType }); const element = document.querySelector("#download") || document.createElement("a"); element.id = "download-file"; - element.href = window.URL.createObjectURL(blob); + element.href = URL.createObjectURL(blob); element.setAttribute("download", filename); element.style.display = "none"; document.body.appendChild(element); @@ -16,7 +18,7 @@ export function downloadBlob(options: { blob: Blob; filename: string }): void { const element = document.querySelector("#download") || document.createElement("a"); element.id = "download-file"; - element.href = window.URL.createObjectURL(blob); + element.href = URL.createObjectURL(blob); element.setAttribute("download", filename); element.style.display = "none"; document.body.appendChild(element); From 1f4500b88e5d6edcb278e8bae3513aa9b9a2a7d0 Mon Sep 17 00:00:00 2001 From: p3rcypj Date: Thu, 8 Feb 2024 11:47:46 +0000 Subject: [PATCH 17/19] Add comment --- .../data/repositories/AnnotationsExportApiRepository.ts | 1 + .../src/domain/entities/__tests__/PdbInfo.spec.ts | 7 ------- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/app/assets/javascripts/3dbio_viewer/src/data/repositories/AnnotationsExportApiRepository.ts b/app/assets/javascripts/3dbio_viewer/src/data/repositories/AnnotationsExportApiRepository.ts index 2c4a39569..a397ae2e8 100644 --- a/app/assets/javascripts/3dbio_viewer/src/data/repositories/AnnotationsExportApiRepository.ts +++ b/app/assets/javascripts/3dbio_viewer/src/data/repositories/AnnotationsExportApiRepository.ts @@ -10,6 +10,7 @@ import { Future } from "../../utils/future"; import { routes } from "../../routes"; import { getJSON } from "../request-utils"; +//Use of "any", due to TS not recognizing Blob as a cross-blob type declare const Blob: any; export interface AnnotationsFile { diff --git a/app/assets/javascripts/3dbio_viewer/src/domain/entities/__tests__/PdbInfo.spec.ts b/app/assets/javascripts/3dbio_viewer/src/domain/entities/__tests__/PdbInfo.spec.ts index a7cc4bb0c..81aedb85c 100644 --- a/app/assets/javascripts/3dbio_viewer/src/domain/entities/__tests__/PdbInfo.spec.ts +++ b/app/assets/javascripts/3dbio_viewer/src/domain/entities/__tests__/PdbInfo.spec.ts @@ -9,11 +9,4 @@ describe("PdbInfo", () => { expect(pdbInfo).toBeTruthy(); }); - it("with PDB 9zzz rejects", async () => { - const compositionRoot = getCompositionRoot(); - - const getPdbInfo = compositionRoot.getPdbInfo.execute(defaultPdbId).toPromise(); - - await expect(getPdbInfo).rejects.toEqual({}); - }); }); From 2c75fd8a73504e0fa3b88058c7a004d949cfef2a Mon Sep 17 00:00:00 2001 From: p3rcypj Date: Thu, 8 Feb 2024 13:19:11 +0000 Subject: [PATCH 18/19] Add yarn test to GitHub actions --- .github/workflows/node.js.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 2deb79ad4..c500f4d4e 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -16,6 +16,7 @@ jobs: cd app/assets/javascripts/3dbio_viewer yarn install yarn build + yarn test - name: Install and build (covid19) run: | cd app/assets/javascripts/covid19 From 89db0bc08bcc296570727837971241f2ec4acea5 Mon Sep 17 00:00:00 2001 From: p3rcypj Date: Thu, 8 Feb 2024 16:57:04 +0000 Subject: [PATCH 19/19] Fix jest slow, routing --- .github/workflows/node.js.yml | 2 +- .../javascripts/3dbio_viewer/package.json | 18 +++++------------- .../domain/entities/__tests__/PdbInfo.spec.ts | 4 +++- .../javascripts/3dbio_viewer/src/routes.ts | 5 +++-- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index c500f4d4e..8d1d7653e 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -16,7 +16,7 @@ jobs: cd app/assets/javascripts/3dbio_viewer yarn install yarn build - yarn test + yarn test:nowatch - name: Install and build (covid19) run: | cd app/assets/javascripts/covid19 diff --git a/app/assets/javascripts/3dbio_viewer/package.json b/app/assets/javascripts/3dbio_viewer/package.json index 09953e333..159396aa2 100644 --- a/app/assets/javascripts/3dbio_viewer/package.json +++ b/app/assets/javascripts/3dbio_viewer/package.json @@ -69,14 +69,15 @@ "scripts": { "start": "react-scripts start", "build-inline": "react-scripts build", + "test": "react-scripts test", + "test:nowatch": "react-scripts test --watchAll=false", "eject": "react-scripts eject", "link-dev": "yarn link @3dbionotes/pdbe-molstar && yarn link @3dbionotes/protvista-pdb", "unlink-dev": "yarn unlink @3dbionotes/pdbe-molstar && yarn unlink @3dbionotes/protvista-pdb && yarn install -f", "build": "INLINE_RUNTIME_CHUNK=false react-scripts build && yarn create-build-symlinks", "create-build-symlinks": "ts-node -O '{\"module\":\"commonjs\"}' src/scripts/create-build-symlinks.ts", "lint": "eslint . --ext .ts,.tsx", - "prettify": "prettier \"./src/**/*.{js,jsx,json,css,ts,tsx}\" --write", - "test": "PORT=3001 && jest --testURL http://localhost:$PORT" + "prettify": "prettier \"./src/**/*.{js,jsx,json,css,ts,tsx}\" --write" }, "eslintConfig": { "extends": [ @@ -105,21 +106,12 @@ "transform": { "^.+\\.[tj]sx{0,1}?$": "ts-jest" }, - "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$", "transformIgnorePatterns": [ "/node_modules/(?!d2-ui-components|molstar)" ], "moduleNameMapper": { "\\.(css|scss)$": "/config/styleMock.js", "\\.(jpg|jpeg|png|svg)$": "/config/fileMock.js" - }, - "moduleFileExtensions": [ - "ts", - "tsx", - "js", - "jsx", - "json", - "node" - ] + } } -} +} \ No newline at end of file diff --git a/app/assets/javascripts/3dbio_viewer/src/domain/entities/__tests__/PdbInfo.spec.ts b/app/assets/javascripts/3dbio_viewer/src/domain/entities/__tests__/PdbInfo.spec.ts index 81aedb85c..3bb813bd6 100644 --- a/app/assets/javascripts/3dbio_viewer/src/domain/entities/__tests__/PdbInfo.spec.ts +++ b/app/assets/javascripts/3dbio_viewer/src/domain/entities/__tests__/PdbInfo.spec.ts @@ -1,12 +1,14 @@ +import axios from "axios"; import { describe, expect, it } from "@jest/globals"; import { getCompositionRoot } from "../../../compositionRoot"; import { defaultPdbId } from "../../../webapp/pages/app/AppRouter"; describe("PdbInfo", () => { it("with PDB 6zow to be truthy", async () => { + axios.defaults.adapter = require("axios/lib/adapters/http"); const compositionRoot = getCompositionRoot(); const pdbInfo = await compositionRoot.getPdbInfo.execute(defaultPdbId).toPromise(); - expect(pdbInfo).toBeTruthy(); + return expect(pdbInfo).toBeTruthy(); }); }); diff --git a/app/assets/javascripts/3dbio_viewer/src/routes.ts b/app/assets/javascripts/3dbio_viewer/src/routes.ts index 8024a9810..cd309a07d 100644 --- a/app/assets/javascripts/3dbio_viewer/src/routes.ts +++ b/app/assets/javascripts/3dbio_viewer/src/routes.ts @@ -1,11 +1,12 @@ /* On DEV, proxy requests (to circumvent CORS) and cache them (see src/setupProxy.js) */ export const isDev = process.env.NODE_ENV === "development"; +const test = process.env.NODE_ENV === "test"; // If empty, use relative requests. export const routes = { - bionotes: isDev ? "/3dbionotes" : "", - bionotesStaging: isDev ? "/rinchen-dos" : "", + bionotes: isDev ? "/3dbionotes" : test ? "https://3dbionotes.cnb.csic.es" : "", + bionotesStaging: isDev ? "/rinchen-dos" : test ? "http://rinchen-dos.cnb.csic.es" : "", ebi: isDev ? "/ebi" : "https://www.ebi.ac.uk", uniprot: isDev ? "/uniprot" : "https://rest.uniprot.org", };