openchemlib-search-wasm 2.1.2 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/LICENSE +451 -25
  2. package/README.md +12 -5
  3. package/lib/functionKeys/index.d.ts +14 -80
  4. package/lib/functionKeys/index.js +3 -98
  5. package/lib/index.d.ts +118 -258
  6. package/lib/index.js +33 -327
  7. package/package.json +24 -32
  8. package/lib/functionKeys/dictionary.json +0 -72071
  9. package/lib/functionKeys/index.d.ts.map +0 -1
  10. package/lib/functionKeys/index.js.map +0 -1
  11. package/lib/functions.d.ts +0 -38
  12. package/lib/functions.d.ts.map +0 -1
  13. package/lib/functions.js +0 -54
  14. package/lib/functions.js.map +0 -1
  15. package/lib/hex.d.ts +0 -31
  16. package/lib/hex.d.ts.map +0 -1
  17. package/lib/hex.js +0 -41
  18. package/lib/hex.js.map +0 -1
  19. package/lib/index.d.ts.map +0 -1
  20. package/lib/index.js.map +0 -1
  21. package/lib/jpath.d.ts +0 -28
  22. package/lib/jpath.d.ts.map +0 -1
  23. package/lib/jpath.js +0 -73
  24. package/lib/jpath.js.map +0 -1
  25. package/lib/records.d.ts +0 -45
  26. package/lib/records.d.ts.map +0 -1
  27. package/lib/records.js +0 -96
  28. package/lib/records.js.map +0 -1
  29. package/lib/runSearch.d.ts +0 -41
  30. package/lib/runSearch.d.ts.map +0 -1
  31. package/lib/runSearch.js +0 -50
  32. package/lib/runSearch.js.map +0 -1
  33. package/lib/scan.d.ts +0 -159
  34. package/lib/scan.d.ts.map +0 -1
  35. package/lib/scan.js +0 -281
  36. package/lib/scan.js.map +0 -1
  37. package/lib/similaritySearch.d.ts +0 -28
  38. package/lib/similaritySearch.d.ts.map +0 -1
  39. package/lib/similaritySearch.js +0 -86
  40. package/lib/similaritySearch.js.map +0 -1
  41. package/lib/strongHash.d.ts +0 -9
  42. package/lib/strongHash.d.ts.map +0 -1
  43. package/lib/strongHash.js +0 -56
  44. package/lib/strongHash.js.map +0 -1
  45. package/lib/substructureSearch.d.ts +0 -29
  46. package/lib/substructureSearch.d.ts.map +0 -1
  47. package/lib/substructureSearch.js +0 -104
  48. package/lib/substructureSearch.js.map +0 -1
  49. package/lib/types.d.ts +0 -308
  50. package/lib/types.d.ts.map +0 -1
  51. package/lib/types.js +0 -52
  52. package/lib/types.js.map +0 -1
  53. package/lib/wasm/load.d.ts +0 -10
  54. package/lib/wasm/load.d.ts.map +0 -1
  55. package/lib/wasm/load.js +0 -50
  56. package/lib/wasm/load.js.map +0 -1
  57. package/lib/wasm/log.d.ts +0 -36
  58. package/lib/wasm/log.d.ts.map +0 -1
  59. package/lib/wasm/log.js +0 -52
  60. package/lib/wasm/log.js.map +0 -1
  61. package/src/functionKeys/index.ts +0 -181
  62. package/src/functions.ts +0 -56
  63. package/src/hex.ts +0 -43
  64. package/src/index.ts +0 -458
  65. package/src/jpath.ts +0 -77
  66. package/src/records.ts +0 -142
  67. package/src/runSearch.ts +0 -99
  68. package/src/scan.ts +0 -441
  69. package/src/similaritySearch.ts +0 -104
  70. package/src/strongHash.ts +0 -57
  71. package/src/substructureSearch.ts +0 -120
  72. package/src/types.ts +0 -403
  73. package/src/wasm/load.ts +0 -59
  74. package/src/wasm/log.ts +0 -66
  75. package/wasm/data.d.ts +0 -2
  76. package/wasm/data.js +0 -3
  77. package/wasm/runtime.d.ts +0 -31
  78. package/wasm/runtime.js +0 -30
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/functionKeys/index.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,eAAe,GAAG,UAAU,CAAC;AAEtE,kGAAkG;AAClG,MAAM,WAAW,WAAW;IAC1B,yBAAyB;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,gFAAgF;IAChF,IAAI,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,QAAQ,EAAE,MAAM,EAA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SAAM,CAAC;QACN,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;AACnE,CAAC"}
@@ -1,38 +0,0 @@
1
- /**
2
- * Builds the 512 function bits of one idcode, as sixteen 32-bit words: bit i is set when any
3
- * fragment of stored function key i is a substructure of the molecule.
4
- *
5
- * The keys are named chemistry — thioether, aromatic ring, uracil, Boc — so a question in words
6
- * becomes bit arithmetic over stored words. Their names, categories and synonyms, and the keys that
7
- * are computed on demand instead, are in the dictionary of `openchemlib-search-wasm/function-keys`.
8
- * A key's bit always agrees with a substructure search for its fragments. The words are laid out
9
- * as {@link getFunctionKeyFragments} shows.
10
- * @param idCode - The molecule to read, as an idcode.
11
- * @returns Sixteen words. An idcode that will not parse gives sixteen zeros.
12
- */
13
- export declare function getFunction(idCode: string): Int32Array;
14
- /**
15
- * Builds the 512 function bits of every idcode, sixteen 32-bit words each.
16
- *
17
- * See {@link getFunction}. Each molecule's FragFp and screen are built too, because a key's fragment
18
- * is only tried on a molecule holding its query words; `getMoleculeRecords` returns all three
19
- * from one parse. The words are written into one buffer and returned as a view per molecule.
20
- * @param idCodes - The molecules to read, as idcodes.
21
- * @returns One sixteen-word view per idcode, in order.
22
- */
23
- export declare function getFunctions(idCodes: string[]): Int32Array[];
24
- /**
25
- * Returns the fragments of the 512 stored function keys, in bit order: bit i of {@link getFunction}
26
- * is set when any fragment of key i is a substructure of the molecule. Bit i sits in word `i >> 5`,
27
- * the first key in the highest bit of word 0:
28
- *
29
- * ```js
30
- * const held = (words, i) => (words[i >> 5] & (1 << (31 - (i & 31)))) !== 0;
31
- * ```
32
- *
33
- * The list is frozen with the module: changing, adding or reordering a key changes every stored
34
- * record, so it only changes in a major release.
35
- * @returns 512 arrays of idcodes, each a key's fragments. The arrays are the caller's own.
36
- */
37
- export declare function getFunctionKeyFragments(): string[][];
38
- //# sourceMappingURL=functions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAItD;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE,CAQ5D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,EAAE,EAAE,CAEpD"}
package/lib/functions.js DELETED
@@ -1,54 +0,0 @@
1
- import { buildFunctions, readFunctionKeys } from "./scan.js";
2
- import { INDEX_WORDS } from "./types.js";
3
- /**
4
- * Builds the 512 function bits of one idcode, as sixteen 32-bit words: bit i is set when any
5
- * fragment of stored function key i is a substructure of the molecule.
6
- *
7
- * The keys are named chemistry — thioether, aromatic ring, uracil, Boc — so a question in words
8
- * becomes bit arithmetic over stored words. Their names, categories and synonyms, and the keys that
9
- * are computed on demand instead, are in the dictionary of `openchemlib-search-wasm/function-keys`.
10
- * A key's bit always agrees with a substructure search for its fragments. The words are laid out
11
- * as {@link getFunctionKeyFragments} shows.
12
- * @param idCode - The molecule to read, as an idcode.
13
- * @returns Sixteen words. An idcode that will not parse gives sixteen zeros.
14
- */
15
- export function getFunction(idCode) {
16
- const result = new Int32Array(INDEX_WORDS);
17
- buildFunctions([idCode], result, 0, 1);
18
- return result;
19
- }
20
- /**
21
- * Builds the 512 function bits of every idcode, sixteen 32-bit words each.
22
- *
23
- * See {@link getFunction}. Each molecule's FragFp and screen are built too, because a key's fragment
24
- * is only tried on a molecule holding its query words; `getMoleculeRecords` returns all three
25
- * from one parse. The words are written into one buffer and returned as a view per molecule.
26
- * @param idCodes - The molecules to read, as idcodes.
27
- * @returns One sixteen-word view per idcode, in order.
28
- */
29
- export function getFunctions(idCodes) {
30
- const all = new Int32Array(idCodes.length * INDEX_WORDS);
31
- buildFunctions(idCodes, all, 0, idCodes.length);
32
- const words = new Array(idCodes.length);
33
- for (let i = 0; i < idCodes.length; i++) {
34
- words[i] = all.subarray(i * INDEX_WORDS, (i + 1) * INDEX_WORDS);
35
- }
36
- return words;
37
- }
38
- /**
39
- * Returns the fragments of the 512 stored function keys, in bit order: bit i of {@link getFunction}
40
- * is set when any fragment of key i is a substructure of the molecule. Bit i sits in word `i >> 5`,
41
- * the first key in the highest bit of word 0:
42
- *
43
- * ```js
44
- * const held = (words, i) => (words[i >> 5] & (1 << (31 - (i & 31)))) !== 0;
45
- * ```
46
- *
47
- * The list is frozen with the module: changing, adding or reordering a key changes every stored
48
- * record, so it only changes in a major release.
49
- * @returns 512 arrays of idcodes, each a key's fragments. The arrays are the caller's own.
50
- */
51
- export function getFunctionKeyFragments() {
52
- return readFunctionKeys();
53
- }
54
- //# sourceMappingURL=functions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"functions.js","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC;IAC3C,cAAc,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACvC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,OAAiB;IAC5C,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,MAAM,GAAG,WAAW,CAAC,CAAC;IACzD,cAAc,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAChD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAa,OAAO,CAAC,MAAM,CAAC,CAAC;IACpD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,GAAG,WAAW,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO,gBAAgB,EAAE,CAAC;AAC5B,CAAC"}
package/lib/hex.d.ts DELETED
@@ -1,31 +0,0 @@
1
- /**
2
- * Formats a hash as the 16 lowercase hex digits of its 64-bit pattern.
3
- *
4
- * A hash is a signed 64-bit integer, which `JSON.stringify` refuses outright — and a JSON number
5
- * could not carry it anyway, since 64 bits does not fit a double. Hex is what crosses an API: it is
6
- * always 16 characters whatever the value, it compares and sorts as a string, and it survives a
7
- * round trip through anything that handles text.
8
- *
9
- * `hash.toString(16)` is not this: it writes `-1` for `-1n`, where the pattern is
10
- * `ffffffffffffffff`, and it pads nothing.
11
- *
12
- * A database that stores the hash in an integer column can format it on the way out instead, and
13
- * SQLite's `printf('%016x', hash)` produces exactly this string.
14
- *
15
- * ```js
16
- * hashToHex(getNoStereoTautomerHash(idCode)); // 'eb14b9bc9ab4dd52'
17
- * ```
18
- * @param hash - The hash to format.
19
- * @returns Its 16 hex digits, lowercase and zero-padded.
20
- */
21
- export declare function hashToHex(hash: bigint): string;
22
- /**
23
- * Reads back what {@link hashToHex} wrote, so a hash that arrived as text can be compared against
24
- * one that was computed, or bound to an integer column.
25
- * @param hex - The 16 hex digits, in either case.
26
- * @returns The signed 64-bit hash.
27
- * @throws {SyntaxError} When the string is not 16 hex digits — a truncated or `0x`-prefixed hash
28
- * would otherwise read as a different, valid-looking value.
29
- */
30
- export declare function hexToHash(hex: string): bigint;
31
- //# sourceMappingURL=hex.d.ts.map
package/lib/hex.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["../src/hex.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK7C"}
package/lib/hex.js DELETED
@@ -1,41 +0,0 @@
1
- /** How many hex digits a 64-bit hash always writes. */
2
- const HASH_HEX_DIGITS = 16;
3
- const HASH_HEX = /^[0-9a-f]{16}$/i;
4
- /**
5
- * Formats a hash as the 16 lowercase hex digits of its 64-bit pattern.
6
- *
7
- * A hash is a signed 64-bit integer, which `JSON.stringify` refuses outright — and a JSON number
8
- * could not carry it anyway, since 64 bits does not fit a double. Hex is what crosses an API: it is
9
- * always 16 characters whatever the value, it compares and sorts as a string, and it survives a
10
- * round trip through anything that handles text.
11
- *
12
- * `hash.toString(16)` is not this: it writes `-1` for `-1n`, where the pattern is
13
- * `ffffffffffffffff`, and it pads nothing.
14
- *
15
- * A database that stores the hash in an integer column can format it on the way out instead, and
16
- * SQLite's `printf('%016x', hash)` produces exactly this string.
17
- *
18
- * ```js
19
- * hashToHex(getNoStereoTautomerHash(idCode)); // 'eb14b9bc9ab4dd52'
20
- * ```
21
- * @param hash - The hash to format.
22
- * @returns Its 16 hex digits, lowercase and zero-padded.
23
- */
24
- export function hashToHex(hash) {
25
- return BigInt.asUintN(64, hash).toString(16).padStart(HASH_HEX_DIGITS, '0');
26
- }
27
- /**
28
- * Reads back what {@link hashToHex} wrote, so a hash that arrived as text can be compared against
29
- * one that was computed, or bound to an integer column.
30
- * @param hex - The 16 hex digits, in either case.
31
- * @returns The signed 64-bit hash.
32
- * @throws {SyntaxError} When the string is not 16 hex digits — a truncated or `0x`-prefixed hash
33
- * would otherwise read as a different, valid-looking value.
34
- */
35
- export function hexToHash(hex) {
36
- if (!HASH_HEX.test(hex)) {
37
- throw new SyntaxError(`not a 16-digit hex hash: ${JSON.stringify(hex)}`);
38
- }
39
- return BigInt.asIntN(64, BigInt(`0x${hex}`));
40
- }
41
- //# sourceMappingURL=hex.js.map
package/lib/hex.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"hex.js","sourceRoot":"","sources":["../src/hex.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B,MAAM,QAAQ,GAAG,iBAAiB,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,MAAM,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,WAAW,CAAC,4BAA4B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC3E,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC;AAC/C,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAG9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OA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}
package/lib/jpath.d.ts DELETED
@@ -1,28 +0,0 @@
1
- /**
2
- * Reads the idcode every entry carries, following a jpath.
3
- *
4
- * The jpath is the dot-separated form the rest of the ecosystem uses (`get-jpaths`,
5
- * `derived-props`): `idCode`, `molecule.idCode`, `spectra.0.idCode`. A numeric segment indexes an
6
- * array, because `array['0']` and `array[0]` are the same property.
7
- *
8
- * The path is split once and walked with a plain loop per entry, so a scan of 400,000 entries costs
9
- * one string split rather than 400,000 of them.
10
- * @param entries - The entries to read.
11
- * @param jpath - Where the idcode sits in each entry.
12
- * @returns One idcode per entry, in order. An entry with no string at the jpath gives an empty
13
- * string, which the scan reports as unparsable like any other idcode it cannot read.
14
- * @throws {Error} If no entry at all has a string there, which means the jpath is wrong rather than
15
- * the data.
16
- */
17
- export declare function readIdCodes(entries: readonly unknown[], jpath: string): string[];
18
- /**
19
- * Turns whatever the caller passed into the array of idcodes the scan reads.
20
- *
21
- * An array of idcodes is used as it is — that is the hot path a worker scanning a decoded chunk
22
- * takes, and copying it would allocate one reference per molecule for nothing.
23
- * @param entries - Idcodes, or entries carrying one at `jpath`.
24
- * @param jpath - Where the idcode sits in an entry.
25
- * @returns The idcodes to scan.
26
- */
27
- export declare function toIdCodes(entries: readonly unknown[], jpath: string): string[];
28
- //# sourceMappingURL=jpath.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jpath.d.ts","sourceRoot":"","sources":["../src/jpath.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,SAAS,OAAO,EAAE,EAC3B,KAAK,EAAE,MAAM,GACZ,MAAM,EAAE,CAuCV;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,SAAS,OAAO,EAAE,EAC3B,KAAK,EAAE,MAAM,GACZ,MAAM,EAAE,CAIV"}
package/lib/jpath.js DELETED
@@ -1,73 +0,0 @@
1
- /**
2
- * Reads the idcode every entry carries, following a jpath.
3
- *
4
- * The jpath is the dot-separated form the rest of the ecosystem uses (`get-jpaths`,
5
- * `derived-props`): `idCode`, `molecule.idCode`, `spectra.0.idCode`. A numeric segment indexes an
6
- * array, because `array['0']` and `array[0]` are the same property.
7
- *
8
- * The path is split once and walked with a plain loop per entry, so a scan of 400,000 entries costs
9
- * one string split rather than 400,000 of them.
10
- * @param entries - The entries to read.
11
- * @param jpath - Where the idcode sits in each entry.
12
- * @returns One idcode per entry, in order. An entry with no string at the jpath gives an empty
13
- * string, which the scan reports as unparsable like any other idcode it cannot read.
14
- * @throws {Error} If no entry at all has a string there, which means the jpath is wrong rather than
15
- * the data.
16
- */
17
- export function readIdCodes(entries, jpath) {
18
- const segments = jpath.split('.');
19
- const idCodes = new Array(entries.length);
20
- let found = 0;
21
- if (segments.length === 1) {
22
- const key = segments[0];
23
- for (let i = 0; i < entries.length; i++) {
24
- const value = entries[i]?.[key];
25
- if (typeof value === 'string') {
26
- idCodes[i] = value;
27
- found++;
28
- }
29
- else {
30
- idCodes[i] = '';
31
- }
32
- }
33
- }
34
- else {
35
- for (let i = 0; i < entries.length; i++) {
36
- let value = entries[i];
37
- for (const segment of segments) {
38
- if (value === null || value === undefined)
39
- break;
40
- value = value[segment];
41
- }
42
- if (typeof value === 'string') {
43
- idCodes[i] = value;
44
- found++;
45
- }
46
- else {
47
- idCodes[i] = '';
48
- }
49
- }
50
- }
51
- if (found === 0 && entries.length > 0) {
52
- throw new Error(`no entry holds a string at jpath "${jpath}": pass the jpath option if the idcode is` +
53
- ' somewhere else');
54
- }
55
- return idCodes;
56
- }
57
- /**
58
- * Turns whatever the caller passed into the array of idcodes the scan reads.
59
- *
60
- * An array of idcodes is used as it is — that is the hot path a worker scanning a decoded chunk
61
- * takes, and copying it would allocate one reference per molecule for nothing.
62
- * @param entries - Idcodes, or entries carrying one at `jpath`.
63
- * @param jpath - Where the idcode sits in an entry.
64
- * @returns The idcodes to scan.
65
- */
66
- export function toIdCodes(entries, jpath) {
67
- if (entries.length === 0)
68
- return [];
69
- if (typeof entries[0] === 'string')
70
- return entries;
71
- return readIdCodes(entries, jpath);
72
- }
73
- //# sourceMappingURL=jpath.js.map
package/lib/jpath.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"jpath.js","sourceRoot":"","sources":["../src/jpath.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,WAAW,CACzB,OAA2B,EAC3B,KAAa;IAEb,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,MAAM,OAAO,GAAG,IAAI,KAAK,CAAS,OAAO,CAAC,MAAM,CAAC,CAAC;IAClD,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAW,CAAC;QAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACxC,MAAM,KAAK,GAAI,OAAO,CAAC,CAAC,CAAoC,EAAE,CAAC,GAAG,CAAC,CAAC;YACpE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9B,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;gBACnB,KAAK,EAAE,CAAC;YACV,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;YAClB,CAAC;QACH,CAAC;IACH,CAAC;SAAM,CAAC;QACN,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACxC,IAAI,KAAK,GAAY,OAAO,CAAC,CAAC,CAAC,CAAC;YAChC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;gBAC/B,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;oBAAE,MAAM;gBACjD,KAAK,GAAI,KAAiC,CAAC,OAAO,CAAC,CAAC;YACtD,CAAC;YACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9B,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;gBACnB,KAAK,EAAE,CAAC;YACV,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;YAClB,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,KAAK,KAAK,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CACb,qCAAqC,KAAK,2CAA2C;YACnF,iBAAiB,CACpB,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CACvB,OAA2B,EAC3B,KAAa;IAEb,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACpC,IAAI,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,QAAQ;QAAE,OAAO,OAA8B,CAAC;IAC1E,OAAO,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AACrC,CAAC"}
package/lib/records.d.ts DELETED
@@ -1,45 +0,0 @@
1
- import type { MoleculeRecords, MoleculeRecordsOptions, MoleculeSizes } from './types.ts';
2
- /**
3
- * Computes everything a molecule table stores about each idcode, parsing each one once: the
4
- * canonical idcode, the FragFp, the screen and the function bits, the atom count and the relative
5
- * weight, and the no-stereo and tautomer hashes.
6
- *
7
- * Each value is the one the dedicated function returns — `getIndexes`, `getScreens`, `getFunctions`,
8
- * `getNoStereoHashes`, `getNoStereoTautomerHashes` — with one deliberate exception: a molecule
9
- * whose tautomer enumeration reached `maxTautomers` gets its no-stereo hash as its tautomer hash,
10
- * because a key from a truncated enumeration depends on where it stopped and is not canonical.
11
- * `tautomerCounts` says which molecules those are.
12
- *
13
- * ```js
14
- * const records = getMoleculeRecords(idCodes, { maxTautomers: 5000 });
15
- * const words = records.words.subarray(48 * i, 48 * (i + 1)); // FragFp, screen, functions
16
- * ```
17
- * @param idCodes - The molecules to read, as idcodes.
18
- * @param options - See {@link MoleculeRecordsOptions}.
19
- * @returns One entry per idcode in each array, in input order. A molecule that cannot be read gets
20
- * `NO_ID_CODE`, zeros, 0 atoms, a `NaN` weight, `NO_HASH` and a tautomer count of 0, and does not
21
- * cost the others in the batch.
22
- */
23
- export declare function getMoleculeRecords(idCodes: string[], options?: MoleculeRecordsOptions): MoleculeRecords;
24
- /**
25
- * Reads the atom count and the relative weight of each idcode — exactly the `atomCounts` and
26
- * `weights` of {@link getMoleculeRecords}, and nothing else, so it costs one parse and one formula
27
- * per molecule.
28
- * @param idCodes - The molecules to read, as idcodes.
29
- * @returns One entry per idcode in each array, in input order: 0 atoms and a `NaN` weight for a
30
- * molecule that cannot be read.
31
- */
32
- export declare function getMoleculeSizes(idCodes: string[]): MoleculeSizes;
33
- /**
34
- * The fewest atoms a molecule needs to contain the query: its atoms once the exclude groups are
35
- * removed, plain hydrogens aside. Each of them maps onto a distinct atom of any match, so a molecule
36
- * whose atom count is below the floor cannot match and needs no substructure test.
37
- *
38
- * Wildcards and atom lists count — each still takes an atom of the match. A plain hydrogen does not,
39
- * because it may match an implicit one; a deuterium or a tritium does.
40
- * @param idCodeQuery - The query, as an idcode; read as a fragment whatever its own fragment flag.
41
- * @returns The floor, or 0 for a query with no atoms.
42
- * @throws {Error} If the query cannot be parsed.
43
- */
44
- export declare function getQueryAtomFloor(idCodeQuery: string): number;
45
- //# sourceMappingURL=records.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../src/records.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,sBAAsB,EACtB,aAAa,EACd,MAAM,YAAY,CAAC;AAWpB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,GAAE,sBAA2B,GACnC,eAAe,CAgCjB;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,aAAa,CAuBjE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAQ7D"}
package/lib/records.js DELETED
@@ -1,96 +0,0 @@
1
- import { recoveringFromTraps } from "./scan.js";
2
- import { DEFAULT_MAX_TAUTOMERS, NO_HASH, NO_ID_CODE, RECORD_WORDS, } from "./types.js";
3
- import { loadOCL } from "./wasm/load.js";
4
- const { Search } = await loadOCL();
5
- /**
6
- * Computes everything a molecule table stores about each idcode, parsing each one once: the
7
- * canonical idcode, the FragFp, the screen and the function bits, the atom count and the relative
8
- * weight, and the no-stereo and tautomer hashes.
9
- *
10
- * Each value is the one the dedicated function returns — `getIndexes`, `getScreens`, `getFunctions`,
11
- * `getNoStereoHashes`, `getNoStereoTautomerHashes` — with one deliberate exception: a molecule
12
- * whose tautomer enumeration reached `maxTautomers` gets its no-stereo hash as its tautomer hash,
13
- * because a key from a truncated enumeration depends on where it stopped and is not canonical.
14
- * `tautomerCounts` says which molecules those are.
15
- *
16
- * ```js
17
- * const records = getMoleculeRecords(idCodes, { maxTautomers: 5000 });
18
- * const words = records.words.subarray(48 * i, 48 * (i + 1)); // FragFp, screen, functions
19
- * ```
20
- * @param idCodes - The molecules to read, as idcodes.
21
- * @param options - See {@link MoleculeRecordsOptions}.
22
- * @returns One entry per idcode in each array, in input order. A molecule that cannot be read gets
23
- * `NO_ID_CODE`, zeros, 0 atoms, a `NaN` weight, `NO_HASH` and a tautomer count of 0, and does not
24
- * cost the others in the batch.
25
- */
26
- export function getMoleculeRecords(idCodes, options = {}) {
27
- const { maxTautomers = DEFAULT_MAX_TAUTOMERS } = options;
28
- const count = idCodes.length;
29
- const records = {
30
- idCodes: new Array(count).fill(NO_ID_CODE),
31
- words: new Int32Array(count * RECORD_WORDS),
32
- atomCounts: new Int32Array(count),
33
- weights: new Float64Array(count).fill(Number.NaN),
34
- noStereoHashes: new BigInt64Array(count),
35
- tautomerHashes: new BigInt64Array(count),
36
- tautomerCounts: new Int32Array(count),
37
- };
38
- recoveringFromTraps((from, to) => Search.getMoleculeRecords(idCodes, records.idCodes, records.words, records.atomCounts, records.weights, records.noStereoHashes, records.tautomerHashes, records.tautomerCounts, maxTautomers, from, to), (index) => markUnreadable(records, index), 0, count);
39
- return records;
40
- }
41
- /**
42
- * Reads the atom count and the relative weight of each idcode — exactly the `atomCounts` and
43
- * `weights` of {@link getMoleculeRecords}, and nothing else, so it costs one parse and one formula
44
- * per molecule.
45
- * @param idCodes - The molecules to read, as idcodes.
46
- * @returns One entry per idcode in each array, in input order: 0 atoms and a `NaN` weight for a
47
- * molecule that cannot be read.
48
- */
49
- export function getMoleculeSizes(idCodes) {
50
- const count = idCodes.length;
51
- const sizes = {
52
- atomCounts: new Int32Array(count),
53
- weights: new Float64Array(count).fill(Number.NaN),
54
- };
55
- recoveringFromTraps((from, to) => Search.getMoleculeSizes(idCodes, sizes.atomCounts, sizes.weights, from, to), (index) => {
56
- sizes.atomCounts[index] = 0;
57
- sizes.weights[index] = Number.NaN;
58
- }, 0, count);
59
- return sizes;
60
- }
61
- /**
62
- * The fewest atoms a molecule needs to contain the query: its atoms once the exclude groups are
63
- * removed, plain hydrogens aside. Each of them maps onto a distinct atom of any match, so a molecule
64
- * whose atom count is below the floor cannot match and needs no substructure test.
65
- *
66
- * Wildcards and atom lists count — each still takes an atom of the match. A plain hydrogen does not,
67
- * because it may match an implicit one; a deuterium or a tritium does.
68
- * @param idCodeQuery - The query, as an idcode; read as a fragment whatever its own fragment flag.
69
- * @returns The floor, or 0 for a query with no atoms.
70
- * @throws {Error} If the query cannot be parsed.
71
- */
72
- export function getQueryAtomFloor(idCodeQuery) {
73
- try {
74
- return Search.getQueryAtomFloor(idCodeQuery);
75
- }
76
- catch (error) {
77
- throw new Error(`"${idCodeQuery}" is not a valid query idcode`, {
78
- cause: error,
79
- });
80
- }
81
- }
82
- /**
83
- * Writes the "could not read this" record of one molecule over whatever a trap left there.
84
- * @param records - The records being filled.
85
- * @param index - The molecule's position.
86
- */
87
- function markUnreadable(records, index) {
88
- records.idCodes[index] = NO_ID_CODE;
89
- records.words.fill(0, index * RECORD_WORDS, (index + 1) * RECORD_WORDS);
90
- records.atomCounts[index] = 0;
91
- records.weights[index] = Number.NaN;
92
- records.noStereoHashes[index] = NO_HASH;
93
- records.tautomerHashes[index] = NO_HASH;
94
- records.tautomerCounts[index] = 0;
95
- }
96
- //# sourceMappingURL=records.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"records.js","sourceRoot":"","sources":["../src/records.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAMhD,OAAO,EACL,qBAAqB,EACrB,OAAO,EACP,UAAU,EACV,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,OAAO,EAAE,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAiB,EACjB,UAAkC,EAAE;IAEpC,MAAM,EAAE,YAAY,GAAG,qBAAqB,EAAE,GAAG,OAAO,CAAC;IACzD,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC;IAC7B,MAAM,OAAO,GAAoB;QAC/B,OAAO,EAAE,IAAI,KAAK,CAAS,KAAK,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC;QAClD,KAAK,EAAE,IAAI,UAAU,CAAC,KAAK,GAAG,YAAY,CAAC;QAC3C,UAAU,EAAE,IAAI,UAAU,CAAC,KAAK,CAAC;QACjC,OAAO,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O,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC;IACpC,CAAC,EACD,CAAC,EACD,KAAK,CACN,CAAC;IACF,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iBAAiB,CAAC,WAAmB;IACnD,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,IAAI,WAAW,+BAA+B,EAAE;YAC9D,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,cAAc,CAAC,OAAwB,EAAE,KAAa;IAC7D,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC;IACpC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,GAAG,YAAY,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC;IACxE,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC;IACpC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC;IACxC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC;IACxC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACpC,CAAC"}
@@ -1,41 +0,0 @@
1
- import type { ResultBuffer, SearchMode, SearchStep } from './types.ts';
2
- /** What a mode does with the entries a step just wrote. */
3
- export interface StepTally {
4
- /** Matches counted so far. */
5
- matched: number;
6
- /** Idcodes that could not be parsed. */
7
- unparsable: number;
8
- }
9
- export interface RunSearchParams {
10
- mode: SearchMode;
11
- idCodeQuery: string;
12
- idCodes: string[];
13
- /** The buffer the scan fills, already reset to the mode's "not yet" value. */
14
- result: ResultBuffer;
15
- /** Updated as the scan goes, and read back into the returned counts. */
16
- tally: StepTally;
17
- /**
18
- * Tallies `result[from .. to)` into `tally`, collecting whatever the mode collects.
19
- * @returns True when the scan has everything it was asked for and should stop.
20
- */
21
- collectRange: (from: number, to: number) => boolean;
22
- stepSize: number | undefined;
23
- onStep: ((step: SearchStep) => boolean | void) | undefined;
24
- /** True when the mode can stop before the end, so the scan must be cut into steps. */
25
- stoppable: boolean;
26
- }
27
- /**
28
- * Drives a scan, one step at a time, and reports it.
29
- *
30
- * A step is a single call into WebAssembly over a range of the array. Cutting the scan up is free —
31
- * 800 chunked calls measure the same as one call over the whole corpus — so the only reason to do
32
- * it is to hear about the scan or to stop it, and a search that wants neither runs as one call.
33
- * @param params - The mode, the query, the buffer to fill and what to do with each step.
34
- * @returns How far the scan got, how long it took and whether it stopped early.
35
- */
36
- export declare function runSearch(params: RunSearchParams): {
37
- processed: number;
38
- elapsed: number;
39
- stopped: boolean;
40
- };
41
- //# sourceMappingURL=runSearch.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runSearch.d.ts","sourceRoot":"","sources":["../src/runSearch.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AASvE,2DAA2D;AAC3D,MAAM,WAAW,SAAS;IACxB,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,UAAU,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,8EAA8E;IAC9E,MAAM,EAAE,YAAY,CAAC;IACrB,wEAAwE;IACxE,KAAK,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC;IACpD,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC;IAC3D,sFAAsF;IACtF,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG;IAClD,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB,CAgDA"}
package/lib/runSearch.js DELETED
@@ -1,50 +0,0 @@
1
- import { checkQuery, scanRange } from "./scan.js";
2
- /**
3
- * How many entries one step covers when the caller asked to hear about the scan but did not say how
4
- * often. Sized from the measured cost of a molecule — ~22 µs to match a fragment, ~947 µs to build
5
- * a fingerprint — so a step lands near 100 ms either way.
6
- */
7
- const DEFAULT_STEP = { substructure: 4096, similarity: 128 };
8
- /**
9
- * Drives a scan, one step at a time, and reports it.
10
- *
11
- * A step is a single call into WebAssembly over a range of the array. Cutting the scan up is free —
12
- * 800 chunked calls measure the same as one call over the whole corpus — so the only reason to do
13
- * it is to hear about the scan or to stop it, and a search that wants neither runs as one call.
14
- * @param params - The mode, the query, the buffer to fill and what to do with each step.
15
- * @returns How far the scan got, how long it took and whether it stopped early.
16
- */
17
- export function runSearch(params) {
18
- const { mode, idCodeQuery, idCodes, result, tally, collectRange, onStep, stepSize, stoppable, } = params;
19
- checkQuery(mode, idCodeQuery);
20
- const total = idCodes.length;
21
- const stepped = onStep !== undefined || stoppable;
22
- const step = Math.max(1, stepSize ?? (stepped ? DEFAULT_STEP[mode] : total));
23
- const started = performance.now();
24
- let processed = 0;
25
- let stopped = false;
26
- while (processed < total) {
27
- const to = Math.min(processed + step, total);
28
- scanRange(mode, idCodeQuery, idCodes, result, processed, to);
29
- const enough = collectRange(processed, to);
30
- processed = to;
31
- if (enough) {
32
- stopped = processed < total;
33
- break;
34
- }
35
- const goOn = onStep?.({
36
- result,
37
- processed,
38
- total,
39
- matched: tally.matched,
40
- unparsable: tally.unparsable,
41
- elapsed: performance.now() - started,
42
- });
43
- if (goOn === false) {
44
- stopped = processed < total;
45
- break;
46
- }
47
- }
48
- return { processed, elapsed: performance.now() - started, stopped };
49
- }
50
- //# sourceMappingURL=runSearch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runSearch.js","sourceRoot":"","sources":["../src/runSearch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGlD;;;;GAIG;AACH,MAAM,YAAY,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC;AA6B7D;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CAAC,MAAuB;IAK/C,MAAM,EACJ,IAAI,EACJ,WAAW,EACX,OAAO,EACP,MAAM,EACN,KAAK,EACL,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,SAAS,GACV,GAAG,MAAM,CAAC;IAEX,UAAU,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAE9B,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC;IAC7B,MAAM,OAAO,GAAG,MAAM,KAAK,SAAS,IAAI,SAAS,CAAC;IAClD,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAE7E,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAClC,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,OAAO,GAAG,KAAK,CAAC;IAEpB,OAAO,SAAS,GAAG,KAAK,EAAE,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