diff --git a/app/scripts/nmr-cli/Dockerfile b/app/scripts/nmr-cli/Dockerfile index fc31fb6..1b19de7 100644 --- a/app/scripts/nmr-cli/Dockerfile +++ b/app/scripts/nmr-cli/Dockerfile @@ -1,7 +1,7 @@ # build the image ` docker build --tag nmr-cli . ` # run the container ` docker run -it nmr-cli bash ` -FROM mcr.microsoft.com/playwright:v1.53.0-jammy +FROM mcr.microsoft.com/playwright:v1.54.1-jammy SHELL ["/bin/bash", "-o", "pipefail", "-c"] diff --git a/app/scripts/nmr-cli/package-lock.json b/app/scripts/nmr-cli/package-lock.json index 91b878c..f3447c7 100644 --- a/app/scripts/nmr-cli/package-lock.json +++ b/app/scripts/nmr-cli/package-lock.json @@ -9,18 +9,19 @@ "version": "1.0.0", "license": "ISC", "dependencies": { + "@zakodium/nmrium-core": "^0.1.3", + "@zakodium/nmrium-core-plugins": "^0.1.4", "axios": "^1.10.0", "filelist-utils": "^1.11.3", - "nmr-load-save": "^3.6.0", "nmr-processing": "^19.0.0", - "playwright": "^1.53.0", + "playwright": "^1.54.1", "yargs": "^18.0.0" }, "bin": { "nmr-cli": "build/index.js" }, "devDependencies": { - "@types/node": "^24.0.3", + "@types/node": "^24.0.14", "@types/yargs": "^17.0.33", "ts-node": "^10.9.2", "typescript": "^5.8.3" @@ -106,37 +107,12 @@ "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", "dev": true }, - "node_modules/@types/d3-color": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/@types/d3-color/-/d3-color-3.1.3.tgz", - "integrity": "sha512-iO90scth9WAbmgv7ogoq57O9YpKmFBbmoEoCHDB2xMBY0+/KVrqAaCDyCE16dUspeOvIxFFRI+0sEtqDqy2b4A==" - }, - "node_modules/@types/d3-interpolate": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@types/d3-interpolate/-/d3-interpolate-3.0.4.tgz", - "integrity": "sha512-mgLPETlrpVV1YRJIglr4Ez47g7Yxjl1lj7YKsiMCb27VJH9W8NVM6Bb9d8kkpG/uAQS5AmbA48q2IAolKKo1MA==", - "dependencies": { - "@types/d3-color": "*" - } - }, - "node_modules/@types/lodash": { - "version": "4.17.16", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.16.tgz", - "integrity": "sha512-HX7Em5NYQAXKW+1T+FiuG27NGwzJfCX3s1GjOa7ujxZa52kjJLOr4FUxT+giF6Tgxv1e+/czV/iTtBw27WTU9g==" - }, - "node_modules/@types/lodash.merge": { - "version": "4.6.9", - "resolved": "https://registry.npmjs.org/@types/lodash.merge/-/lodash.merge-4.6.9.tgz", - "integrity": "sha512-23sHDPmzd59kUgWyKGiOMO2Qb9YtqRO/x4IhkgNUiPQ1+5MUVqi6bCZeq9nBJ17msjIMbEIO5u+XW4Kz6aGUhQ==", - "dependencies": { - "@types/lodash": "*" - } - }, "node_modules/@types/node": { - "version": "24.0.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-24.0.3.tgz", - "integrity": "sha512-R4I/kzCYAdRLzfiCabn9hxWfbuHS573x+r0dJMkkzThEa7pbrcDWK+9zu3e7aBOouf+rQAciqPFMnxwr0aWgKg==", + "version": "24.0.14", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.0.14.tgz", + "integrity": "sha512-4zXMWD91vBLGRtHK3YbIoFMia+1nqEz72coM42C5ETjnNCa/heoj7NT1G67iAfOqMmcfhuCZ4uNpyz8EjlAejw==", "dev": true, + "license": "MIT", "dependencies": { "undici-types": "~7.8.0" } @@ -156,6 +132,92 @@ "integrity": "sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==", "dev": true }, + "node_modules/@zakodium/nmrium-core": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@zakodium/nmrium-core/-/nmrium-core-0.1.3.tgz", + "integrity": "sha512-bizm794rvhRdyxSvu6hbRbPo3XkvvVr8/gl8eIXzMjfjBJ7dQYDJxECzSxt1dqSosAXEImXaQPH6VgzlOgv5Og==", + "license": "CC-BY-NC-SA-4.0", + "dependencies": { + "cheminfo-types": "^1.8.1", + "fifo-logger": "^1.0.0", + "filelist-utils": "^1.11.3", + "is-any-array": "^2.0.1", + "lodash.merge": "^4.6.2", + "ml-spectra-processing": "^14.12.0", + "nmr-correlation": "^2.3.5" + } + }, + "node_modules/@zakodium/nmrium-core-plugins": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/@zakodium/nmrium-core-plugins/-/nmrium-core-plugins-0.1.4.tgz", + "integrity": "sha512-OwfMGkSNIAslXSBAOjHIZGdgxKakJZk+xiMYTQuODMCGJyR9OnKceM7XqZJ6Kz6HeTzZTDrRt3E40Wis2JGkVw==", + "license": "CC-BY-NC-SA-4.0", + "dependencies": { + "@zakodium/nmrium-core": "^0.1.3", + "cheminfo-types": "^1.8.1", + "convert-to-jcamp": "^5.4.11", + "filelist-utils": "^1.11.3", + "gyromagnetic-ratio": "^2.0.0", + "is-any-array": "^2.0.1", + "jcampconverter": "^11.0.3", + "linear-sum-assignment": "^1.0.7", + "lodash.merge": "^4.6.2", + "ml-spectra-processing": "^14.12.0", + "nmr-processing": "^19.0.0", + "nmredata": "^1.0.1", + "openchemlib": "^9.2.0", + "openchemlib-utils": "^8.1.1", + "sdf-parser": "^7.0.4" + } + }, + "node_modules/@zakodium/nmrium-core-plugins/node_modules/get-value": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/get-value/-/get-value-4.0.1.tgz", + "integrity": "sha512-QTDzwunK3V+VlJJlL0BlCzebAaE8OSlUC+UVd80PiekTw1gpzQSb3cfEQB2LYFWr1lbWfbdqL4pjAoJDPCLxhQ==", + "license": "MIT" + }, + "node_modules/@zakodium/nmrium-core-plugins/node_modules/gyromagnetic-ratio": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/gyromagnetic-ratio/-/gyromagnetic-ratio-2.0.0.tgz", + "integrity": "sha512-LrpOHxgnxo0+yqtmA+1FUyl9RkvhTCiIiIPGzo8Yn6TXz6OiY5CJ5k5IqThF61qnkbC+fe6q3kF67OI6d0HyjQ==", + "license": "MIT" + }, + "node_modules/@zakodium/nmrium-core-plugins/node_modules/nmredata": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/nmredata/-/nmredata-1.0.1.tgz", + "integrity": "sha512-vw4cuMj6hr6q73TGf83E4hcZ8UEr+VIFigKvhju+R4v1Z2m+K7oNrxp80ImN917ZGqFQ4gHOub842iFaGhoLJg==", + "license": "MIT", + "dependencies": { + "filelist-utils": "^1.11.3", + "jszip": "^3.10.1", + "openchemlib": "^9.1.1", + "openchemlib-utils": "^8.1.1" + } + }, + "node_modules/@zakodium/nmrium-core-plugins/node_modules/openchemlib": { + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/openchemlib/-/openchemlib-9.6.0.tgz", + "integrity": "sha512-SAMLSwOQTCDNpfNu/WTQpzLMYTRj/xwetMPRoAGHeR2J162RP/OI6vHpVcC7L4V7ThMW3ZhMf7GdH04yndmHtw==", + "license": "BSD-3-Clause" + }, + "node_modules/@zakodium/nmrium-core-plugins/node_modules/openchemlib-utils": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/openchemlib-utils/-/openchemlib-utils-8.2.0.tgz", + "integrity": "sha512-QrF/9gCNQ0uB4WTku9N3mvorCyt6fuAI9e73BaXfd6h4+uz9nbqvJNQpM39Z5m8Cz9Zd0geq7o7zRneX6BEXMA==", + "license": "MIT", + "dependencies": { + "atom-sorter": "^2.2.0", + "ensure-string": "^1.2.0", + "get-value": "^4.0.1", + "ml-floyd-warshall": "^3.0.1", + "ml-matrix": "^6.12.1", + "papaparse": "^5.5.3", + "sdf-parser": "^7.0.4" + }, + "peerDependencies": { + "openchemlib": ">=9.3.0" + } + }, "node_modules/acorn": { "version": "8.14.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.1.tgz", @@ -245,19 +307,6 @@ "resolved": "https://registry.npmjs.org/binary-search/-/binary-search-1.3.6.tgz", "integrity": "sha512-nbE1WxOTTrUWIfsfZ4aHGYu5DOuNkbxGokjV6Z2kxfJK3uaAb8zNK1muzOeipoLHZjInT4Br88BHpzevc681xA==" }, - "node_modules/brukerconverter": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/brukerconverter/-/brukerconverter-8.0.3.tgz", - "integrity": "sha512-SLDPH+fD5zTp9qb9NESTT1xWFI6mN4yWT5tdSROPbdCD6zgv6F8fb4VRbyWw0fHs//HH2/8PRFkPd5LejiXcwg==", - "dependencies": { - "cheminfo-types": "^1.8.1", - "filelist-utils": "^1.11.2", - "iobuffer": "^5.3.2", - "is-any-array": "^2.0.1", - "jcampconverter": "^11.0.1", - "ml-spectra-processing": "^14.9.2" - } - }, "node_modules/call-bind-apply-helpers": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", @@ -578,17 +627,6 @@ "node": ">= 0.4" } }, - "node_modules/get-value": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/get-value/-/get-value-3.0.1.tgz", - "integrity": "sha512-mKZj9JLQrwMBtj5wxi6MH8Z5eSKaERpAwjg43dPtlGI1ZVEgH/qC7T8/6R2OBSUA+zzHBZgICsVJaEIV2tKTDA==", - "dependencies": { - "isobject": "^3.0.1" - }, - "engines": { - "node": ">=6.0" - } - }, "node_modules/gopd": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", @@ -600,11 +638,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/gyromagnetic-ratio": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/gyromagnetic-ratio/-/gyromagnetic-ratio-1.2.1.tgz", - "integrity": "sha512-cOkHEsIwHNKe8v/wED9NWa8wvzLx0rpBarUrEpvzdgECMpVQzrLJkaFYsdSxnhaUtWX4uNFxX01PJeFayDCpVA==" - }, "node_modules/has-symbols": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", @@ -664,11 +697,6 @@ "node": ">= 0.10" } }, - "node_modules/iobuffer": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/iobuffer/-/iobuffer-5.4.0.tgz", - "integrity": "sha512-DRebOWuqDvxunfkNJAlc3IzWIPD5xVxwUNbHr7xKB8E6aLJxIPfNX3CoMJghcFjpv6RWQsrcJbghtEwSPoJqMA==" - }, "node_modules/is-any-array": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-any-array/-/is-any-array-2.0.1.tgz", @@ -679,14 +707,6 @@ "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" }, - "node_modules/isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/isutf8": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/isutf8/-/isutf8-4.0.1.tgz", @@ -696,24 +716,30 @@ } }, "node_modules/jcampconverter": { - "version": "11.0.1", - "resolved": "https://registry.npmjs.org/jcampconverter/-/jcampconverter-11.0.1.tgz", - "integrity": "sha512-8i01PC5WhUMH9H2AIssOhqSJpgjftJFQ2MUcYSgqKzy3QemQ8D7M960Ab+jba0wO4ThWYSp1xKMBmoL6zuEYQA==", + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/jcampconverter/-/jcampconverter-11.0.3.tgz", + "integrity": "sha512-vnm7QjVb5RMf8BFmGa0XzHW+fbI2ESpIPiZc+9brB4XVteYoZOwp2Mprx0vZfJYitK8CEHOY2aLAwDr9XV72Yw==", + "license": "CC-BY-NC-SA-4.0", "dependencies": { "cheminfo-types": "^1.8.1", "dynamic-typing": "^1.0.1", "ensure-string": "^1.2.0", - "gyromagnetic-ratio": "^1.2.1", - "ml-array-median": "^1.1.6" + "gyromagnetic-ratio": "^2.0.0", + "ml-array-median": "^1.1.6", + "openchemlib": "^9.2.0" } }, - "node_modules/jeolconverter": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/jeolconverter/-/jeolconverter-1.0.4.tgz", - "integrity": "sha512-p4MwOtP5QcBqvdr4jha0fQiOcArRf6K8CwwElpaG7chbmBuEf2FQpZj5QFP9VJQa3I1C3U3tzw5bM+QG388sWQ==", - "dependencies": { - "iobuffer": "^5.3.2" - } + "node_modules/jcampconverter/node_modules/gyromagnetic-ratio": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/gyromagnetic-ratio/-/gyromagnetic-ratio-2.0.0.tgz", + "integrity": "sha512-LrpOHxgnxo0+yqtmA+1FUyl9RkvhTCiIiIPGzo8Yn6TXz6OiY5CJ5k5IqThF61qnkbC+fe6q3kF67OI6d0HyjQ==", + "license": "MIT" + }, + "node_modules/jcampconverter/node_modules/openchemlib": { + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/openchemlib/-/openchemlib-9.6.0.tgz", + "integrity": "sha512-SAMLSwOQTCDNpfNu/WTQpzLMYTRj/xwetMPRoAGHeR2J162RP/OI6vHpVcC7L4V7ThMW3ZhMf7GdH04yndmHtw==", + "license": "BSD-3-Clause" }, "node_modules/jszip": { "version": "3.10.1", @@ -1114,159 +1140,6 @@ "ml-peak-shape-generator": "^4.1.4" } }, - "node_modules/nmr-load-save": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/nmr-load-save/-/nmr-load-save-3.6.0.tgz", - "integrity": "sha512-qwZ54C9CqzZrGfzU6VX9FiaEKGYiXkOg5u3MXQk+4VY7/xDFwilh2EE7A7gIabP1Z7VU3GeOwBSLwjrtBZz4sA==", - "deprecated": "See @zakodium/nmrium-core and @zakodium/nmrium-core-plugins", - "dependencies": { - "@lukeed/uuid": "^2.0.1", - "@types/lodash.merge": "^4.6.9", - "brukerconverter": "^8.0.3", - "cheminfo-types": "^1.8.1", - "convert-to-jcamp": "^5.4.11", - "fifo-logger": "^1.0.0", - "filelist-utils": "^1.11.3", - "gyromagnetic-ratio": "^1.2.1", - "is-any-array": "^2.0.1", - "jcampconverter": "^11.0.1", - "jeolconverter": "^1.0.4", - "linear-sum-assignment": "^1.0.7", - "lodash.merge": "^4.6.2", - "ml-spectra-processing": "^14.10.0", - "nmr-correlation": "^2.3.5", - "nmr-processing": "^17.1.1", - "nmredata": "^0.9.11", - "openchemlib": "^8.19.0", - "openchemlib-utils": "^6.6.0", - "sdf-parser": "^7.0.4", - "varian-converter": "^2.0.1" - } - }, - "node_modules/nmr-load-save/node_modules/d3-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/d3-color/-/d3-color-2.0.0.tgz", - "integrity": "sha512-SPXi0TSKPD4g9tw0NMZFnR95XVgUZiBH+uUTqQuDu1OsE2zomHU7ho0FISciaPvosimixwHFl3WHLGabv6dDgQ==" - }, - "node_modules/nmr-load-save/node_modules/d3-interpolate": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/d3-interpolate/-/d3-interpolate-2.0.1.tgz", - "integrity": "sha512-c5UhwwTs/yybcmTpAVqwSFl6vrQ8JZJoT5F7xNFK9pymv5C0Ymcc9/LIJHtYIggg/yS9YHw8i8O8tgb9pupjeQ==", - "dependencies": { - "d3-color": "1 - 2" - } - }, - "node_modules/nmr-load-save/node_modules/get-value": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/get-value/-/get-value-4.0.1.tgz", - "integrity": "sha512-QTDzwunK3V+VlJJlL0BlCzebAaE8OSlUC+UVd80PiekTw1gpzQSb3cfEQB2LYFWr1lbWfbdqL4pjAoJDPCLxhQ==" - }, - "node_modules/nmr-load-save/node_modules/ml-gsd": { - "version": "12.1.8", - "resolved": "https://registry.npmjs.org/ml-gsd/-/ml-gsd-12.1.8.tgz", - "integrity": "sha512-vcy8e1xPJ9fe2GFKMMpttzQUDxgPdo6KLTPU55lfPedL0WH9WRuIxRLbUwLbhYmB2/ZwAhzIspXcxjPCwhtsgA==", - "dependencies": { - "@lukeed/uuid": "^2.0.1", - "cheminfo-types": "^1.7.3", - "ml-peak-shape-generator": "^4.1.4", - "ml-savitzky-golay-generalized": "^4.2.0", - "ml-spectra-fitting": "^4.2.4", - "ml-spectra-processing": "^14.5.3" - } - }, - "node_modules/nmr-load-save/node_modules/ml-levenberg-marquardt": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/ml-levenberg-marquardt/-/ml-levenberg-marquardt-4.1.3.tgz", - "integrity": "sha512-CuR8mg1IIgb5IuDkdJBpnHmx+r6FpRDDPvYhAGq+4WVMLw/lu44P6PniyCrdvk1PNBmxVXN/LwBDMpQ/VaWhgA==", - "dependencies": { - "is-any-array": "^2.0.0", - "ml-matrix": "^6.10.4" - } - }, - "node_modules/nmr-load-save/node_modules/ml-signal-processing": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/ml-signal-processing/-/ml-signal-processing-1.2.0.tgz", - "integrity": "sha512-hLJLrEq7a8Jx+VlXr1zZ8ApUb8EFwPgRacvNQL7LF7BH24uReJbRJVH8tL29ZGrQV4kJ9dxdmiZk+lbnvuhR1g==", - "dependencies": { - "baselines": "^1.1.9", - "cheminfo-types": "^1.8.1", - "ml-gsd": "^12.1.8", - "ml-savitzky-golay-generalized": "^4.2.0", - "ml-spectra-processing": "^14.6.2" - } - }, - "node_modules/nmr-load-save/node_modules/ml-spectra-fitting": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/ml-spectra-fitting/-/ml-spectra-fitting-4.2.4.tgz", - "integrity": "sha512-iq6yHKqovLeBA1+Lwzhjz3fqDz6j9vR+p5MgNUyO9yfRUOC6YrMfuesopZv7Gj/SuvGGjNWgR3z8XCjjPonedg==", - "dependencies": { - "cheminfo-types": "^1.7.2", - "ml-array-max": "^1.2.4", - "ml-direct": "^1.0.0", - "ml-levenberg-marquardt": "^4.1.3", - "ml-peak-shape-generator": "^4.1.4", - "ml-spectra-processing": "^14.2.0" - } - }, - "node_modules/nmr-load-save/node_modules/nmr-processing": { - "version": "17.3.1", - "resolved": "https://registry.npmjs.org/nmr-processing/-/nmr-processing-17.3.1.tgz", - "integrity": "sha512-W2BDtxiPOTidZJfvKWfK/7S5vcP847Hj54oemhnXxY8kzETg9M9b1ndnqULGNECeeapEdSvwOAKlKEph8hjrcg==", - "dependencies": { - "@lukeed/uuid": "^2.0.1", - "@types/d3-color": "^3.1.3", - "@types/d3-interpolate": "^3.0.4", - "binary-search": "^1.3.6", - "d3-color": "^2.0.0", - "d3-interpolate": "^2.0.1", - "gyromagnetic-ratio": "^1.2.1", - "is-any-array": "^2.0.1", - "linear-sum-assignment": "^1.0.7", - "ml-airpls": "^2.0.0", - "ml-convolution": "^2.0.0", - "ml-direct": "^1.0.0", - "ml-gsd": "^12.1.8", - "ml-hclust": "^3.1.0", - "ml-levenberg-marquardt": "^4.1.3", - "ml-matrix": "^6.12.1", - "ml-matrix-convolution": "^1.0.0", - "ml-matrix-peaks-finder": "^1.0.0", - "ml-peak-shape-generator": "^4.1.4", - "ml-regression-base": "^4.0.0", - "ml-regression-exponential": "^3.0.2", - "ml-regression-polynomial": "^3.0.1", - "ml-regression-simple-linear": "^3.0.1", - "ml-savitzky-golay-generalized": "^4.2.0", - "ml-signal-processing": "^1.2.0", - "ml-simple-clustering": "^0.1.0", - "ml-sparse-matrix": "^2.1.0", - "ml-spectra-processing": "^14.11.0", - "ml-tree-set": "^0.1.1", - "multiplet-analysis": "^2.1.5", - "nmr-correlation": "^2.3.5", - "numeral": "^2.0.6", - "openchemlib-utils": "^6.7.0", - "spectrum-generator": "^8.1.0" - } - }, - "node_modules/nmr-load-save/node_modules/nmr-processing/node_modules/openchemlib-utils": { - "version": "6.7.0", - "resolved": "https://registry.npmjs.org/openchemlib-utils/-/openchemlib-utils-6.7.0.tgz", - "integrity": "sha512-NxSNqnntIVBdBDKG0eAiqUsVE5N6xOeoif0EIktMRTjWtakRxFq5VR1CniBnwPA6J8MYY8D7wolRYWn/3Cu3+Q==", - "dependencies": { - "@lukeed/uuid": "^2.0.1", - "atom-sorter": "^2.2.0", - "ensure-string": "^1.2.0", - "get-value": "^4.0.1", - "ml-floyd-warshall": "^3.0.1", - "ml-matrix": "^6.12.1", - "papaparse": "^5.5.2", - "sdf-parser": "^7.0.4" - }, - "peerDependencies": { - "openchemlib": ">=8.18.1" - } - }, "node_modules/nmr-processing": { "version": "19.0.0", "resolved": "https://registry.npmjs.org/nmr-processing/-/nmr-processing-19.0.0.tgz", @@ -1338,17 +1211,6 @@ "openchemlib": ">=9.0.0" } }, - "node_modules/nmredata": { - "version": "0.9.11", - "resolved": "https://registry.npmjs.org/nmredata/-/nmredata-0.9.11.tgz", - "integrity": "sha512-eaql8S2eGh22lrAungs3a7+PthuFHIs5Y6q6/oeg4fxRQiENVkdNXeJ+zFm/+BSX1z4nnmCCNl2MiRyB2ZxLEg==", - "dependencies": { - "filelist-utils": "^1.11.0", - "jszip": "^3.10.1", - "openchemlib": "^8.14.0", - "openchemlib-utils": "^6.1.0" - } - }, "node_modules/num-sort": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/num-sort/-/num-sort-2.1.0.tgz", @@ -1368,38 +1230,6 @@ "node": "*" } }, - "node_modules/openchemlib": { - "version": "8.19.0", - "resolved": "https://registry.npmjs.org/openchemlib/-/openchemlib-8.19.0.tgz", - "integrity": "sha512-MLt6rFzVIcQ7MWBUu1htKlnA7SDIBkzYSXlIjZ4eVJ36RJBA81TIn7pkhSNoclWNVjVnMoIVXd1su1PbN25S/A==" - }, - "node_modules/openchemlib-utils": { - "version": "6.6.0", - "resolved": "https://registry.npmjs.org/openchemlib-utils/-/openchemlib-utils-6.6.0.tgz", - "integrity": "sha512-t8tsV0qAB28HE/mnE4F9YZjwlnnGaaqeYTPDjd1m5r2g5pGJEYY9Zt09MI1YWoLU/jNElYdb8LsGkO7zlwLoIQ==", - "dependencies": { - "@lukeed/uuid": "^2.0.1", - "atom-sorter": "^2.2.0", - "ensure-string": "^1.2.0", - "get-value": "^3.0.1", - "ml-floyd-warshall": "^3.0.1", - "ml-matrix": "^6.12.0", - "papaparse": "^5.5.2", - "sdf-parser": "^6.0.1" - }, - "peerDependencies": { - "openchemlib": ">=8.18.1" - } - }, - "node_modules/openchemlib-utils/node_modules/sdf-parser": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/sdf-parser/-/sdf-parser-6.0.1.tgz", - "integrity": "sha512-QorgjqiqTzodCMmYkWYkYJ9nBnOL3w3mWOE9BB1SATUfkFvLOSxHaeZAnJxrHlRkfI7+q3+FsvZOS2OTN74lNA==", - "dependencies": { - "dynamic-typing": "^1.0.0", - "ensure-string": "^1.2.0" - } - }, "node_modules/pako": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz", @@ -1411,11 +1241,12 @@ "integrity": "sha512-5QvjGxYVjxO59MGU2lHVYpRWBBtKHnlIAcSe1uNFCkkptUh63NFRj0FJQm7nR67puEruUci/ZkjmEFrjCAyP4A==" }, "node_modules/playwright": { - "version": "1.53.0", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.53.0.tgz", - "integrity": "sha512-ghGNnIEYZC4E+YtclRn4/p6oYbdPiASELBIYkBXfaTVKreQUYbMUYQDwS12a8F0/HtIjr/CkGjtwABeFPGcS4Q==", + "version": "1.54.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.54.1.tgz", + "integrity": "sha512-peWpSwIBmSLi6aW2auvrUtf2DqY16YYcCMO8rTVx486jKmDTJg7UAhyrraP98GB8BoPURZP8+nxO7TSd4cPr5g==", + "license": "Apache-2.0", "dependencies": { - "playwright-core": "1.53.0" + "playwright-core": "1.54.1" }, "bin": { "playwright": "cli.js" @@ -1428,9 +1259,10 @@ } }, "node_modules/playwright-core": { - "version": "1.53.0", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.53.0.tgz", - "integrity": "sha512-mGLg8m0pm4+mmtB7M89Xw/GSqoNC+twivl8ITteqvAndachozYe2ZA7srU6uleV1vEdAHYqjq+SV8SNxRRFYBw==", + "version": "1.54.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.54.1.tgz", + "integrity": "sha512-Nbjs2zjj0htNhzgiy5wu+3w09YetDx5pkrpI/kZotDlDUaYk0HVA5xrBVPdow4SAUIlhgKcJeJg4GRKW6xHusA==", + "license": "Apache-2.0", "bin": { "playwright-core": "cli.js" }, @@ -1576,6 +1408,7 @@ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", "dev": true, + "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -1606,16 +1439,6 @@ "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", "dev": true }, - "node_modules/varian-converter": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/varian-converter/-/varian-converter-2.0.1.tgz", - "integrity": "sha512-bvOZ74Zs/Hbht7GDCC6Z/jQOrCyczjItfT5KOJsAG4Ty3MQBvjHf16GwuuWpBnmNRUezLjZ2v+bSS/wVyPXYQQ==", - "dependencies": { - "filelist-utils": "^1.11.0", - "iobuffer": "^5.3.2", - "ml-spectra-processing": "^14.2.0" - } - }, "node_modules/wrap-ansi": { "version": "9.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.0.tgz", diff --git a/app/scripts/nmr-cli/package.json b/app/scripts/nmr-cli/package.json index 71d0510..b63a679 100644 --- a/app/scripts/nmr-cli/package.json +++ b/app/scripts/nmr-cli/package.json @@ -15,15 +15,16 @@ "nmr-cli": "./build/index.js" }, "dependencies": { + "@zakodium/nmrium-core": "^0.1.3", + "@zakodium/nmrium-core-plugins": "^0.1.4", "axios": "^1.10.0", "filelist-utils": "^1.11.3", - "nmr-load-save": "^3.6.0", "nmr-processing": "^19.0.0", - "playwright": "^1.53.0", + "playwright": "^1.54.1", "yargs": "^18.0.0" }, "devDependencies": { - "@types/node": "^24.0.3", + "@types/node": "^24.0.14", "@types/yargs": "^17.0.33", "ts-node": "^10.9.2", "typescript": "^5.8.3" diff --git a/app/scripts/nmr-cli/src/index.ts b/app/scripts/nmr-cli/src/index.ts index 4d85eda..95b810d 100755 --- a/app/scripts/nmr-cli/src/index.ts +++ b/app/scripts/nmr-cli/src/index.ts @@ -3,7 +3,7 @@ import yargs, { type Argv, type CommandModule, type Options } from 'yargs' import { loadSpectrumFromURL, loadSpectrumFromFilePath } from './prase-spectra' import { generateSpectrumFromPublicationString } from './publication-string' import { parsePredictionCommand } from './prediction/parsePredictionCommand' -import { hideBin } from 'yargs/helpers'; +import { hideBin } from 'yargs/helpers' const usageMessage = ` Usage: nmr-cli [options] @@ -126,4 +126,4 @@ yargs(hideBin(process.argv)) .command(parsePredictionCommand) .showHelpOnFail(true) .help() - .parse() \ No newline at end of file + .parse() diff --git a/app/scripts/nmr-cli/src/prase-spectra.ts b/app/scripts/nmr-cli/src/prase-spectra.ts index b107ecc..39937b1 100644 --- a/app/scripts/nmr-cli/src/prase-spectra.ts +++ b/app/scripts/nmr-cli/src/prase-spectra.ts @@ -1,129 +1,130 @@ -import { join, isAbsolute } from "path"; -import { type NmriumState, read } from "nmr-load-save"; -import { fileCollectionFromWebSource, fileCollectionFromPath } from "filelist-utils"; -import playwright from 'playwright'; - +import { join, isAbsolute } from 'path' +import { type NmriumState } from '@zakodium/nmrium-core' +import init from '@zakodium/nmrium-core-plugins' +import { + fileCollectionFromWebSource, + fileCollectionFromPath, +} from 'filelist-utils' +import playwright from 'playwright' interface Snapshot { - image: string, - id: string; + image: string + id: string } +const core = init() function generateNMRiumURL() { - const baseURL = process.env['BASE_NMRIUM_URL'] || ''; - const url = new URL(baseURL) - url.searchParams.append('workspace', "embedded") - return url.toString() + const baseURL = process.env['BASE_NMRIUM_URL'] || '' + const url = new URL(baseURL) + url.searchParams.append('workspace', 'embedded') + return url.toString() } - async function captureSpectraViewAsBase64(nmriumState: Partial) { - const { data: { spectra } = { spectra: [] }, version } = nmriumState; - const browser = await playwright.chromium.launch() - const context = await browser.newContext(playwright.devices['Desktop Chrome HiDPI']) - const page = await context.newPage() - - const url = generateNMRiumURL() - - await page.goto(url) + const { data: { spectra } = { spectra: [] }, version } = nmriumState + const browser = await playwright.chromium.launch() + const context = await browser.newContext( + playwright.devices['Desktop Chrome HiDPI'] + ) + const page = await context.newPage() - await page.locator('text=Loading').waitFor({ state: 'hidden' }); + const url = generateNMRiumURL() - let snapshots: Snapshot[] = [] + await page.goto(url) - for (const spectrum of spectra || []) { - const spectrumObject = { - version, - data: { - spectra: [{ ...spectrum }], - } + await page.locator('text=Loading').waitFor({ state: 'hidden' }) - } + let snapshots: Snapshot[] = [] - // convert typed array to array - const stringObject = JSON.stringify(spectrumObject, (key, value: unknown) => { - return ArrayBuffer.isView(value) ? Array.from(value as unknown as Iterable) : value - }) + for (const spectrum of spectra || []) { + const spectrumObject = { + version, + data: { + spectra: [{ ...spectrum }], + }, + } - // load the spectrum into NMRium using the custom event - await page.evaluate( - ` + // convert typed array to array + const stringObject = JSON.stringify( + spectrumObject, + (key, value: unknown) => { + return ArrayBuffer.isView(value) + ? Array.from(value as unknown as Iterable) + : value + } + ) + + // load the spectrum into NMRium using the custom event + await page.evaluate( + ` window.postMessage({ type: "nmr-wrapper:load", data:{data: ${stringObject},type:"nmrium"}}, '*'); ` - ) - - //wait for NMRium process and load spectra - await page.locator('text=Loading').waitFor({ state: 'hidden' }); - - // take a snapshot for the spectrum - try { - const snapshot = await page.locator('#nmrSVG .container').screenshot() - - snapshots.push({ - image: snapshot.toString('base64'), - id: spectrum.id, - }) - } catch (e) { - console.log(e) - } - } + ) - await context.close() - await browser.close() + //wait for NMRium process and load spectra + await page.locator('text=Loading').waitFor({ state: 'hidden' }) - return snapshots; -} + // take a snapshot for the spectrum + try { + const snapshot = await page.locator('#nmrSVG .container').screenshot() -async function loadSpectrumFromURL(url: string, enableSnapshot = false) { - const { pathname: relativePath, origin: baseURL } = new URL(url); - const source = { - entries: [ - { - relativePath, - } - ], - baseURL - }; - const fileCollection = await fileCollectionFromWebSource(source, {}); - - const { - nmriumState: { data, version }, - } = await read(fileCollection); - - let images: Snapshot[] = [] - - if (enableSnapshot) { - images = await captureSpectraViewAsBase64({ data, version }); + snapshots.push({ + image: snapshot.toString('base64'), + id: spectrum.id, + }) + } catch (e) { + console.log(e) } + } + await context.close() + await browser.close() - return { data, version, images }; + return snapshots } +async function loadSpectrumFromURL(url: string, enableSnapshot = false) { + const { pathname: relativePath, origin: baseURL } = new URL(url) + const source = { + entries: [ + { + relativePath, + }, + ], + baseURL, + } + const fileCollection = await fileCollectionFromWebSource(source, {}) + + const { + nmriumState: { data, version }, + } = await core.read(fileCollection) + + let images: Snapshot[] = [] + + if (enableSnapshot) { + images = await captureSpectraViewAsBase64({ data, version }) + } + + return { data, version, images } +} async function loadSpectrumFromFilePath(path: string, enableSnapshot = false) { - const dirPath = isAbsolute(path) ? path : join(process.cwd(), path) + const dirPath = isAbsolute(path) ? path : join(process.cwd(), path) - const fileCollection = await fileCollectionFromPath(dirPath, {}); + const fileCollection = await fileCollectionFromPath(dirPath, {}) - const { - nmriumState: { data, version } - } = await read(fileCollection); + const { + nmriumState: { data, version }, + } = await core.read(fileCollection) - let images: Snapshot[] = [] + let images: Snapshot[] = [] - if (enableSnapshot) { - images = await captureSpectraViewAsBase64({ data, version }); - } + if (enableSnapshot) { + images = await captureSpectraViewAsBase64({ data, version }) + } - - return { data, version, images }; + return { data, version, images } } - -export { - loadSpectrumFromFilePath, - loadSpectrumFromURL -}; - +export { loadSpectrumFromFilePath, loadSpectrumFromURL } diff --git a/app/scripts/nmr-cli/src/prediction/parsePredictionCommand.ts b/app/scripts/nmr-cli/src/prediction/parsePredictionCommand.ts index 635fc39..d8160b3 100644 --- a/app/scripts/nmr-cli/src/prediction/parsePredictionCommand.ts +++ b/app/scripts/nmr-cli/src/prediction/parsePredictionCommand.ts @@ -1,248 +1,249 @@ import { Argv, CommandModule, Options } from 'yargs' import { - generatePredictedSpectrumData, - GenerateSpectrumOptions, - ShiftsItem, + generatePredictedSpectrumData, + GenerateSpectrumOptions, + ShiftsItem, } from './generatePredictedSpectrumData' import { v4 } from '@lukeed/uuid' -import { CURRENT_EXPORT_VERSION } from 'nmr-load-save' +import { CURRENT_EXPORT_VERSION } from '@zakodium/nmrium-core' + import https from 'https' import axios from 'axios' interface PredictionParameters { - molText: string - id: number - type: string - shifts: string - solvent: string - nucleus: string + molText: string + id: number + type: string + shifts: string + solvent: string + nucleus: string } const predictionOptions: { [key in keyof GenerateSpectrumOptions]: Options } = { - from: { - type: 'number', - description: 'From in (ppm)', - }, - to: { - type: 'number', - description: 'To in (ppm)', - }, - nbPoints: { - type: 'number', - description: 'Number of points', - default: 2 ** 18, // 256k points - }, - lineWidth: { - type: 'number', - description: 'Line width', - default: 1, - }, - frequency: { - type: 'number', - description: 'NMR frequency (MHz)', - default: 400, - }, - tolerance: { - type: 'number', - description: 'Tolerance', - default: 0.001, - }, - peakShape: { - alias: 'ps', - type: 'string', - description: 'Peak shape algorithm', - default: 'lorentzian', - choices: ['gaussian', 'lorentzian'], - }, + from: { + type: 'number', + description: 'From in (ppm)', + }, + to: { + type: 'number', + description: 'To in (ppm)', + }, + nbPoints: { + type: 'number', + description: 'Number of points', + default: 2 ** 18, // 256k points + }, + lineWidth: { + type: 'number', + description: 'Line width', + default: 1, + }, + frequency: { + type: 'number', + description: 'NMR frequency (MHz)', + default: 400, + }, + tolerance: { + type: 'number', + description: 'Tolerance', + default: 0.001, + }, + peakShape: { + alias: 'ps', + type: 'string', + description: 'Peak shape algorithm', + default: 'lorentzian', + choices: ['gaussian', 'lorentzian'], + }, } as const const nmrOptions: { [key in keyof PredictionParameters]: Options } = { - id: { - alias: 'i', - type: 'number', - description: 'Input ID', - default: 1, - }, - type: { - alias: 't', - type: 'string', - description: 'NMR type', - default: 'nmr;1H;1d', - choices: ['nmr;1H;1d', 'nmr;13C;1d'], - }, - shifts: { - alias: 's', - type: 'string', - description: 'Chemical shifts', - default: '1', - }, - solvent: { - type: 'string', - description: 'NMR solvent', - default: 'Dimethylsulphoxide-D6 (DMSO-D6, C2D6SO)', - choices: [ - 'Any', - 'Chloroform-D1 (CDCl3)', - 'Dimethylsulphoxide-D6 (DMSO-D6, C2D6SO)', - 'Methanol-D4 (CD3OD)', - 'Deuteriumoxide (D2O)', - 'Acetone-D6 ((CD3)2CO)', - 'TETRACHLORO-METHANE (CCl4)', - 'Pyridin-D5 (C5D5N)', - 'Benzene-D6 (C6D6)', - 'neat', - 'Tetrahydrofuran-D8 (THF-D8, C4D4O)', - ], - }, - molText: { - alias: 'm', - type: 'string', - description: 'MOL file content', - requiresArg: true, - }, - nucleus: { - alias: 'n', - type: 'string', - description: 'Predicted nucleus', - requiresArg: true, - choices: ['1H', '13C'], - }, + id: { + alias: 'i', + type: 'number', + description: 'Input ID', + default: 1, + }, + type: { + alias: 't', + type: 'string', + description: 'NMR type', + default: 'nmr;1H;1d', + choices: ['nmr;1H;1d', 'nmr;13C;1d'], + }, + shifts: { + alias: 's', + type: 'string', + description: 'Chemical shifts', + default: '1', + }, + solvent: { + type: 'string', + description: 'NMR solvent', + default: 'Dimethylsulphoxide-D6 (DMSO-D6, C2D6SO)', + choices: [ + 'Any', + 'Chloroform-D1 (CDCl3)', + 'Dimethylsulphoxide-D6 (DMSO-D6, C2D6SO)', + 'Methanol-D4 (CD3OD)', + 'Deuteriumoxide (D2O)', + 'Acetone-D6 ((CD3)2CO)', + 'TETRACHLORO-METHANE (CCl4)', + 'Pyridin-D5 (C5D5N)', + 'Benzene-D6 (C6D6)', + 'neat', + 'Tetrahydrofuran-D8 (THF-D8, C4D4O)', + ], + }, + molText: { + alias: 'm', + type: 'string', + description: 'MOL file content', + requiresArg: true, + }, + nucleus: { + alias: 'n', + type: 'string', + description: 'Predicted nucleus', + requiresArg: true, + choices: ['1H', '13C'], + }, } as const interface PredictionResponseItem { - id: number - type: string - statistics: { - accept: number - warning: number - reject: number - missing: number - total: number - } - shifts: ShiftsItem[] + id: number + type: string + statistics: { + accept: number + warning: number + reject: number + missing: number + total: number + } + shifts: ShiftsItem[] } interface PredictionResponse { - result: PredictionResponseItem[] + result: PredictionResponseItem[] } async function predictNMR(options: PredictionArgs): Promise { - const url = process.env['NMR_PREDICTION_URL'] - - if (!url) { - throw new Error('Environment variable NMR_PREDICTION_URL is not defined.') + const url = process.env['NMR_PREDICTION_URL'] + + if (!url) { + throw new Error('Environment variable NMR_PREDICTION_URL is not defined.') + } + + try { + new URL(url).toString() + } catch { + throw new Error(`Invalid URL in NMR_PREDICTION_URL: "${url}"`) + } + + try { + const { + id, + type, + shifts, + solvent, + from, + to, + nbPoints = 2 ** 18, // 256K + frequency = 400, + lineWidth = 1, + tolerance = 0.001, + molText, + nucleus, + peakShape = 'lorentzian', + } = options + + const payload: any = { + inputs: [ + { + id, + type, + shifts, + solvent, + }, + ], + moltxt: molText.replaceAll(/\\n/g, '\n'), } - try { - new URL(url).toString() - } catch { - throw new Error(`Invalid URL in NMR_PREDICTION_URL: "${url}"`) + const httpsAgent = new https.Agent({ + rejectUnauthorized: false, + }) + + // Axios POST request with httpsAgent + const response = await axios.post(url, payload, { + headers: { + 'Content-Type': 'application/json', + }, + httpsAgent, + }) + + const responseResult: PredictionResponse = response.data + const spectra = [] + + for (const result of responseResult.result) { + const name = v4() + const data = generatePredictedSpectrumData(result.shifts, { + from, + to, + nbPoints, + lineWidth, + frequency, + tolerance, + peakShape, + }) + + const info = { + isFid: false, + isComplex: false, + dimension: 1, + originFrequency: frequency, + baseFrequency: frequency, + pulseSequence: '', + solvent, + isFt: true, + name, + nucleus, + } + + spectra.push({ + id: v4(), + data, + info, + }) } - try { - const { - id, - type, - shifts, - solvent, - from, - to, - nbPoints = 2 ** 18, // 256K - frequency = 400, - lineWidth = 1, - tolerance = 0.001, - molText, - nucleus, - peakShape = "lorentzian", - } = options - - const payload: any = { - inputs: [ - { - id, - type, - shifts, - solvent, - }, - ], - moltxt: molText.replaceAll(/\\n/g, '\n'), - } - - const httpsAgent = new https.Agent({ - rejectUnauthorized: false, - }) - - // Axios POST request with httpsAgent - const response = await axios.post(url, payload, { - headers: { - 'Content-Type': 'application/json', - }, - httpsAgent, - }) - - const responseResult: PredictionResponse = response.data - const spectra = [] - - for (const result of responseResult.result) { - const name = v4() - const data = generatePredictedSpectrumData(result.shifts, { - from, - to, - nbPoints, - lineWidth, - frequency, - tolerance, - peakShape, - }) - - const info = { - isFid: false, - isComplex: false, - dimension: 1, - originFrequency: frequency, - baseFrequency: frequency, - pulseSequence: '', - solvent, - isFt: true, - name, - nucleus, - } - - spectra.push({ - id: v4(), - data, - info, - }) - } - - const nmrium = { data: { spectra }, version: CURRENT_EXPORT_VERSION } - console.log(JSON.stringify(nmrium, null, 2)) - } catch (error) { - console.error( - 'Error:', - error instanceof Error ? error.message : String(error) - ) - - if (axios.isAxiosError(error) && error.response) { - console.error('Response data:', error.response.data) - } else if (error instanceof Error && error.cause) { - console.error('Network Error:', error.cause) - } + const nmrium = { data: { spectra }, version: CURRENT_EXPORT_VERSION } + console.log(JSON.stringify(nmrium, null, 2)) + } catch (error) { + console.error( + 'Error:', + error instanceof Error ? error.message : String(error) + ) + + if (axios.isAxiosError(error) && error.response) { + console.error('Response data:', error.response.data) + } else if (error instanceof Error && error.cause) { + console.error('Network Error:', error.cause) } + } } type PredictionArgs = PredictionParameters & GenerateSpectrumOptions // Define the prediction string command export const parsePredictionCommand: CommandModule<{}, PredictionArgs> = { - command: ['predict', 'p'], - describe: 'Predict NMR spectrum from mol text', - builder: (yargs: Argv<{}>): Argv => { - return yargs.options({ - ...nmrOptions, - ...predictionOptions, - }) as Argv - }, - handler: async argv => { - await predictNMR(argv) - }, + command: ['predict', 'p'], + describe: 'Predict NMR spectrum from mol text', + builder: (yargs: Argv<{}>): Argv => { + return yargs.options({ + ...nmrOptions, + ...predictionOptions, + }) as Argv + }, + handler: async argv => { + await predictNMR(argv) + }, } diff --git a/app/scripts/nmr-cli/src/publication-string.ts b/app/scripts/nmr-cli/src/publication-string.ts index 4251843..3133a53 100644 --- a/app/scripts/nmr-cli/src/publication-string.ts +++ b/app/scripts/nmr-cli/src/publication-string.ts @@ -1,73 +1,76 @@ -import { resurrect, rangesToXY, type NMRRangeWithIntegration } from 'nmr-processing'; -import { v4 } from '@lukeed/uuid'; -import { CURRENT_EXPORT_VERSION } from 'nmr-load-save'; +import { + resurrect, + rangesToXY, + type NMRRangeWithIntegration, +} from 'nmr-processing' +import { v4 } from '@lukeed/uuid' +import { CURRENT_EXPORT_VERSION } from '@zakodium/nmrium-core' import { castToArray } from './utilities/castToArray' - interface Info { - nucleus: string; solvent: string; name: string + nucleus: string + solvent: string + name: string } function generateSpectrumFromRanges( - ranges: NMRRangeWithIntegration[], - info: Info, + ranges: NMRRangeWithIntegration[], + info: Info ) { - const { nucleus, solvent, name = null } = info; - - const frequency = 400; - try { - const { x, y } = rangesToXY(ranges, { - nucleus, - frequency, - nbPoints: 2 ** 17, - }); + const { nucleus, solvent, name = null } = info - const info = { - isFid: false, - isComplex: false, - dimension: 1, - nucleus, - originFrequency: frequency, - baseFrequency: frequency, - pulseSequence: '', - solvent, - isFt: true, - name, - }; + const frequency = 400 + try { + const { x, y } = rangesToXY(ranges, { + nucleus, + frequency, + nbPoints: 2 ** 17, + }) - const spectrum = - { - id: v4(), - data: { x: castToArray(x), im: undefined, re: castToArray(y) }, - info, - ranges: { - values: ranges, options: { - sum: 100, - isSumConstant: false, - sumAuto: false - } - }, - }; + const info = { + isFid: false, + isComplex: false, + dimension: 1, + nucleus, + originFrequency: frequency, + baseFrequency: frequency, + pulseSequence: '', + solvent, + isFt: true, + name, + } - return { data: { spectra: [spectrum] }, version: CURRENT_EXPORT_VERSION }; - } catch (error) { - console.log(error); + const spectrum = { + id: v4(), + data: { x: castToArray(x), im: undefined, re: castToArray(y) }, + info, + ranges: { + values: ranges, + options: { + sum: 100, + isSumConstant: false, + sumAuto: false, + }, + }, } -} + return { data: { spectra: [spectrum] }, version: CURRENT_EXPORT_VERSION } + } catch (error) { + console.log(error) + } +} -function generateSpectrumFromPublicationString( - publicationString: string -) { - const { - ranges, - info: { nucleus, solvent = '' }, - parts, - } = resurrect(publicationString); - return generateSpectrumFromRanges( - ranges, - { nucleus, solvent, name: parts[0] }, - ); +function generateSpectrumFromPublicationString(publicationString: string) { + const { + ranges, + info: { nucleus, solvent = '' }, + parts, + } = resurrect(publicationString) + return generateSpectrumFromRanges(ranges, { + nucleus, + solvent, + name: parts[0], + }) } export { generateSpectrumFromPublicationString } diff --git a/app/scripts/nmr-cli/src/utilities/castToArray.ts b/app/scripts/nmr-cli/src/utilities/castToArray.ts index 6cd3a48..bb2482e 100644 --- a/app/scripts/nmr-cli/src/utilities/castToArray.ts +++ b/app/scripts/nmr-cli/src/utilities/castToArray.ts @@ -1,3 +1,3 @@ export function castToArray(value: Float64Array | number[]): number[] { - return ArrayBuffer.isView(value) ? Array.from(value) : value -} \ No newline at end of file + return ArrayBuffer.isView(value) ? Array.from(value) : value +} diff --git a/app/scripts/nmr-cli/tsconfig.json b/app/scripts/nmr-cli/tsconfig.json index 3365620..45db58d 100644 --- a/app/scripts/nmr-cli/tsconfig.json +++ b/app/scripts/nmr-cli/tsconfig.json @@ -5,13 +5,8 @@ "strict": true, "esModuleInterop": true, "outDir": "./build", - "skipLibCheck": true, + "skipLibCheck": true }, - "include": [ - "src/**/*.ts" - ], - "exclude": [ - "node_modules", - "dist" - ] -} \ No newline at end of file + "include": ["src/**/*.ts"], + "exclude": ["node_modules", "dist"] +}