openchemlib-search-wasm 2.0.0 → 2.1.1

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.
package/lib/records.js ADDED
@@ -0,0 +1,96 @@
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
@@ -0,0 +1 @@
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,EAAE,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG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C,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"}
package/lib/scan.d.ts CHANGED
@@ -36,6 +36,47 @@ export declare function checkQuery(mode: SearchMode, idCodeQuery: string): void;
36
36
  * @returns How many molecules were parsed and fingerprinted.
37
37
  */
38
38
  export declare function buildIndexes(idCodes: string[], result: Int32Array, from: number, to: number): number;
39
+ /**
40
+ * Screens `idCodes[from .. to)` into `result`, sixteen words per molecule.
41
+ *
42
+ * Fails like {@link buildIndexes}: sixteen zeros for an idcode the WASM side cannot read.
43
+ * @param idCodes - The molecules to screen.
44
+ * @param result - The caller's buffer, `16 * idCodes.length` words long.
45
+ * @param from - The first index to screen.
46
+ * @param to - One past the last index to screen.
47
+ * @returns How many molecules were parsed and screened.
48
+ */
49
+ export declare function buildScreens(idCodes: string[], result: Int32Array, from: number, to: number): number;
50
+ /**
51
+ * Builds the function bits of `idCodes[from .. to)` into `result`, sixteen words per molecule.
52
+ *
53
+ * Fails like {@link buildIndexes}: sixteen zeros for an idcode the WASM side cannot read.
54
+ * @param idCodes - The molecules to read.
55
+ * @param result - The caller's buffer, `16 * idCodes.length` words long.
56
+ * @param from - The first index to read.
57
+ * @param to - One past the last index to read.
58
+ * @returns How many molecules were parsed and read.
59
+ */
60
+ export declare function buildFunctions(idCodes: string[], result: Int32Array, from: number, to: number): number;
61
+ /**
62
+ * Reads the fragments of the 512 stored function keys, in bit order.
63
+ * @returns Per key, its fragment idcodes.
64
+ */
65
+ export declare function readFunctionKeys(): string[][];
66
+ /**
67
+ * Builds what every molecule a query matches has: its FragFp words, or its screen words.
68
+ * @param kind - `'index'` for the FragFp words, `'screen'` for the screen words.
69
+ * @param idCodeQuery - The query, as an idcode.
70
+ * @returns Sixteen words.
71
+ * @throws {Error} If the query cannot be parsed.
72
+ */
73
+ export declare function buildQueryWords(kind: 'index' | 'screen', idCodeQuery: string): Int32Array;
74
+ /**
75
+ * Reads the key fragments behind the bits of the FragFp words, or of the screen words.
76
+ * @param kind - `'index'` for FragFp's keys, `'screen'` for the screen's.
77
+ * @returns 512 idcodes, in bit order.
78
+ */
79
+ export declare function readKeys(kind: 'index' | 'screen'): string[];
39
80
  /**
40
81
  * Hashes `idCodes[from .. to)` into `result`, one no-stereo tautomer hash per molecule.
41
82
  *
@@ -94,4 +135,25 @@ export declare function buildNoStereoIdCodes(idCodes: string[], result: string[]
94
135
  * @returns How many molecules were canonized.
95
136
  */
96
137
  export declare function buildNoStereoTautomerIdCodes(idCodes: string[], result: string[], largestFragmentOnly: boolean, from: number, to: number, tautomerCounts?: Int32Array, maxTautomers?: number): number;
138
+ /**
139
+ * Runs a ranged WASM call, and redoes the range one molecule at a time if it traps.
140
+ *
141
+ * A malformed idcode makes OpenChemLib's bit-stream parser read past its input, which WebAssembly
142
+ * traps on — the same trap {@link scanRange} recovers from. The Java guard catches an empty or
143
+ * non-ASCII idcode, but a malformed ASCII one reaches the parser and traps there, which would
144
+ * otherwise lose every molecule in the range including the good ones. The trap leaves the module
145
+ * usable, and a per-molecule call costs what a batched one does because the 512 key fragments are
146
+ * parsed once for the module's lifetime, so redoing the range singly costs nothing that was not
147
+ * already going to be spent.
148
+ *
149
+ * There is no cap on the failures: these functions promise a per-molecule "could not read this"
150
+ * answer rather than an exception, so an array that is entirely garbage yields one of those per
151
+ * entry.
152
+ * @param call - Runs the WASM call over a range, returning how many molecules it handled.
153
+ * @param markUnreadable - Writes the "could not read this" answer for one molecule.
154
+ * @param from - The first index to handle.
155
+ * @param to - One past the last index to handle.
156
+ * @returns How many molecules were handled.
157
+ */
158
+ export declare function recoveringFromTraps(call: (from: number, to: number) => number, markUnreadable: (index: number) => void, from: number, to: number): number;
97
159
  //# sourceMappingURL=scan.d.ts.map
package/lib/scan.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../src/scan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAqB3D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,UAAU,EAChB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EAAE,EACjB,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT,IAAI,CA0BN;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAStE;AAwCD;;;;;;;;;;GAUG;AACH,wBAAg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,MAA8B,GAC3C,MAAM,CAkBR;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EAAE,EACjB,MAAM,EAAE,aAAa,EACrB,mBAAmB,EAAE,OAAO,EAC5B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT,MAAM,CAgBR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EAAE,EACjB,MAAM,EAAE,MAAM,EAAE,EAChB,mBAAmB,EAAE,OAAO,EAC5B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT,MAAM,CAgBR;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,MAAM,EAAE,EACjB,MAAM,EAAE,MAAM,EAAE,EAChB,mBAAmB,EAAE,OAAO,EAC5B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,cAAc,GAAE,UAA2C,EAC3D,YAAY,GAAE,MAA8B,GAC3C,MAAM,CAkBR;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,MAAM,EAC1C,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,EACvC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT,MAAM,CAcR"}
package/lib/scan.js CHANGED
@@ -99,6 +99,74 @@ function firstPending(mode, result, from, to) {
99
99
  export function buildIndexes(idCodes, result, from, to) {
100
100
  return recoveringFromTraps((first, last) => Search.getIndexes(idCodes, result, first, last), (index) => result.fill(0, index * INDEX_WORDS, (index + 1) * INDEX_WORDS), from, to);
101
101
  }
102
+ /**
103
+ * Screens `idCodes[from .. to)` into `result`, sixteen words per molecule.
104
+ *
105
+ * Fails like {@link buildIndexes}: sixteen zeros for an idcode the WASM side cannot read.
106
+ * @param idCodes - The molecules to screen.
107
+ * @param result - The caller's buffer, `16 * idCodes.length` words long.
108
+ * @param from - The first index to screen.
109
+ * @param to - One past the last index to screen.
110
+ * @returns How many molecules were parsed and screened.
111
+ */
112
+ export function buildScreens(idCodes, result, from, to) {
113
+ return Search.getScreens(idCodes, result, from, to);
114
+ }
115
+ /**
116
+ * Builds the function bits of `idCodes[from .. to)` into `result`, sixteen words per molecule.
117
+ *
118
+ * Fails like {@link buildIndexes}: sixteen zeros for an idcode the WASM side cannot read.
119
+ * @param idCodes - The molecules to read.
120
+ * @param result - The caller's buffer, `16 * idCodes.length` words long.
121
+ * @param from - The first index to read.
122
+ * @param to - One past the last index to read.
123
+ * @returns How many molecules were parsed and read.
124
+ */
125
+ export function buildFunctions(idCodes, result, from, to) {
126
+ return recoveringFromTraps((first, last) => Search.getFunctions(idCodes, result, first, last), (index) => result.fill(0, index * INDEX_WORDS, (index + 1) * INDEX_WORDS), from, to);
127
+ }
128
+ /**
129
+ * Reads the fragments of the 512 stored function keys, in bit order.
130
+ * @returns Per key, its fragment idcodes.
131
+ */
132
+ export function readFunctionKeys() {
133
+ return Search.getFunctionKeys()
134
+ .split('\n')
135
+ .map((key) => key.split(' '));
136
+ }
137
+ /**
138
+ * Builds what every molecule a query matches has: its FragFp words, or its screen words.
139
+ * @param kind - `'index'` for the FragFp words, `'screen'` for the screen words.
140
+ * @param idCodeQuery - The query, as an idcode.
141
+ * @returns Sixteen words.
142
+ * @throws {Error} If the query cannot be parsed.
143
+ */
144
+ export function buildQueryWords(kind, idCodeQuery) {
145
+ const result = new Int32Array(INDEX_WORDS);
146
+ try {
147
+ if (kind === 'index') {
148
+ Search.getQueryIndex(idCodeQuery, result);
149
+ }
150
+ else {
151
+ Search.getQueryScreen(idCodeQuery, result);
152
+ }
153
+ }
154
+ catch (error) {
155
+ throw new Error(`"${idCodeQuery}" is not a valid query idcode`, {
156
+ cause: error,
157
+ });
158
+ }
159
+ return result;
160
+ }
161
+ /**
162
+ * Reads the key fragments behind the bits of the FragFp words, or of the screen words.
163
+ * @param kind - `'index'` for FragFp's keys, `'screen'` for the screen's.
164
+ * @returns 512 idcodes, in bit order.
165
+ */
166
+ export function readKeys(kind) {
167
+ const joined = kind === 'index' ? Search.getFragFpKeys() : Search.getScreenKeys();
168
+ return joined.split('\n');
169
+ }
102
170
  /**
103
171
  * Hashes `idCodes[from .. to)` into `result`, one no-stereo tautomer hash per molecule.
104
172
  *
@@ -193,7 +261,7 @@ export function buildNoStereoTautomerIdCodes(idCodes, result, largestFragmentOnl
193
261
  * @param to - One past the last index to handle.
194
262
  * @returns How many molecules were handled.
195
263
  */
196
- function recoveringFromTraps(call, markUnreadable, from, to) {
264
+ export function recoveringFromTraps(call, markUnreadable, from, to) {
197
265
  try {
198
266
  return call(from, to);
199
267
  }
package/lib/scan.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"scan.js","sourceRoot":"","sources":["../src/scan.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,WAAW,EACX,OAAO,EACP,UAAU,EACV,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,qGAAqG;AACrG,0FAA0F;AAC1F,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,OAAO,EAAE,CAAC;AAEnC,kGAAkG;AAClG,8FAA8F;AAC9F,kGAAkG;AAClG,wEAAwE;AACxE,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,SAAS,CACvB,IAAgB,EAChB,WAAmB,EACnB,OAAiB,EACjB,MAAoB,EACpB,IAAY,EACZ,EAAU;IAEV,MAAM,UAAU,GACd,IAAI,KAAK,YAAY;QACnB,CAAC,CAAC,gBAAgB,CAAC,UAAU;QAC7B,CAAC,CAAC,kBAAkB,CAAC,UAAU,CAAC;IACpC,IAAI,MAA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D,IAAI,EACJ,EAAE,CACH,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,4BAA4B,CAC1C,OAAiB,EACjB,MAAgB,EAChB,mBAA4B,EAC5B,IAAY,EACZ,EAAU,EACV,iBAA6B,IAAI,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,EAC3D,eAAuB,qBAAqB;IAE5C,OAAO,mBAAmB,CACxB,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CACd,MAAM,CAAC,0BAA0B,CAC/B,OAAO,EACP,MAAM,EACN,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,KAAK,EACL,IAAI,CACL,EACH,CAAC,KAAK,EAAE,EAAE;QACR,MAAM,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC;IAC7B,CAAC,EACD,IAAI,EACJ,EAAE,CACH,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAA0C,EAC1C,cAAuC,EACvC,IAAY,EACZ,EAAU;IAEV,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACxB,CAAC;IAAC,MAAM,CAAC;QACP,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,KAAK,IAAI,KAAK,GAAG,IAAI,EAAE,KAAK,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC;YAC3C,IAAI,CAAC;gBACH,OAAO,IAAI,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;YACpC,CAAC;YAAC,MAAM,CAAC;gBACP,cAAc,CAAC,KAAK,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import type { SubstructureSearchOptions, SubstructureSearchResult } from './types.ts';
2
2
  /**
3
- * Tests a query fragment against many molecules and returns the ones that contain it.
3
+ * Tests a query fragment, or any of several, against many molecules and returns the ones that
4
+ * contain it.
4
5
  *
5
6
  * The entries are either idcodes or objects carrying one — a database row, a candidate a prescreen
6
7
  * yielded — and what comes back is those same objects, so nothing has to map positions back onto
@@ -10,17 +11,19 @@ import type { SubstructureSearchOptions, SubstructureSearchResult } from './type
10
11
  * The scan is synchronous. `onStep` reports it and can stop it, but the thread is not yielded:
11
12
  * a caller that needs a responsive main thread slices the array across calls, or runs this in a
12
13
  * worker.
13
- * @param idCodeQuery - The query, as an idcode. It is searched as a fragment whatever its own
14
+ * @param idCodeQuery - The query, as an idcode, or several: a molecule then matches when it holds
15
+ * any of them, which is how a function key of `openchemlib-search-wasm/function-keys` is searched
16
+ * (`substructureSearch(key.fragments, entries)`). Each is searched as a fragment whatever its own
14
17
  * fragment flag says, which is what `openchemlib`'s `SSSearcher` does with `setFragment(true)`.
15
18
  * @param entries - The molecules to test: idcodes, or objects holding one at `options.jpath`.
16
19
  * @param options - Where the idcode sits, how many matches are enough, and how to report progress.
17
20
  * @returns The matching entries, their positions, the status buffer and the counts.
18
- * @throws {Error} If the query cannot be parsed, if more than 100 idcodes cannot be, or if no entry
19
- * holds a string at the jpath.
21
+ * @throws {Error} If the query cannot be parsed or is an empty list, if more than 100 idcodes cannot
22
+ * be, or if no entry holds a string at the jpath.
20
23
  * @example
21
24
  * ```js
22
25
  * const { matches } = substructureSearch('gFp@DiTt@@B', rows, { jpath: 'molecule.idCode' });
23
26
  * ```
24
27
  */
25
- export declare function substructureSearch<Entry>(idCodeQuery: string, entries: readonly Entry[], options?: SubstructureSearchOptions): SubstructureSearchResult<Entry>;
28
+ export declare function substructureSearch<Entry>(idCodeQuery: string | readonly string[], entries: readonly Entry[], options?: SubstructureSearchOptions): SubstructureSearchResult<Entry>;
26
29
  //# sourceMappingURL=substructureSearch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"substructureSearch.d.ts","sourceRoot":"","sources":["../src/substructureSearch.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EACtC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,GAAE,yBAA8B,GACtC,wBAAwB,CAAC,KAAK,CAAC,CA6DjC"}
1
+ {"version":3,"file":"substructureSearch.d.ts","sourceRoot":"","sources":["../src/substructureSearch.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EACtC,WAAW,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,EACvC,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,GAAE,yBAA8B,GACtC,wBAAwB,CAAC,KAAK,CAAC,CA6DjC"}
@@ -2,7 +2,8 @@ import { toIdCodes } from "./jpath.js";
2
2
  import { runSearch } from "./runSearch.js";
3
3
  import { SubstructureResult } from "./types.js";
4
4
  /**
5
- * Tests a query fragment against many molecules and returns the ones that contain it.
5
+ * Tests a query fragment, or any of several, against many molecules and returns the ones that
6
+ * contain it.
6
7
  *
7
8
  * The entries are either idcodes or objects carrying one — a database row, a candidate a prescreen
8
9
  * yielded — and what comes back is those same objects, so nothing has to map positions back onto
@@ -12,13 +13,15 @@ import { SubstructureResult } from "./types.js";
12
13
  * The scan is synchronous. `onStep` reports it and can stop it, but the thread is not yielded:
13
14
  * a caller that needs a responsive main thread slices the array across calls, or runs this in a
14
15
  * worker.
15
- * @param idCodeQuery - The query, as an idcode. It is searched as a fragment whatever its own
16
+ * @param idCodeQuery - The query, as an idcode, or several: a molecule then matches when it holds
17
+ * any of them, which is how a function key of `openchemlib-search-wasm/function-keys` is searched
18
+ * (`substructureSearch(key.fragments, entries)`). Each is searched as a fragment whatever its own
16
19
  * fragment flag says, which is what `openchemlib`'s `SSSearcher` does with `setFragment(true)`.
17
20
  * @param entries - The molecules to test: idcodes, or objects holding one at `options.jpath`.
18
21
  * @param options - Where the idcode sits, how many matches are enough, and how to report progress.
19
22
  * @returns The matching entries, their positions, the status buffer and the counts.
20
- * @throws {Error} If the query cannot be parsed, if more than 100 idcodes cannot be, or if no entry
21
- * holds a string at the jpath.
23
+ * @throws {Error} If the query cannot be parsed or is an empty list, if more than 100 idcodes cannot
24
+ * be, or if no entry holds a string at the jpath.
22
25
  * @example
23
26
  * ```js
24
27
  * const { matches } = substructureSearch('gFp@DiTt@@B', rows, { jpath: 'molecule.idCode' });
@@ -51,7 +54,7 @@ export function substructureSearch(idCodeQuery, entries, options = {}) {
51
54
  };
52
55
  const run = runSearch({
53
56
  mode: 'substructure',
54
- idCodeQuery,
57
+ idCodeQuery: joinQueries(idCodeQuery),
55
58
  idCodes,
56
59
  result,
57
60
  tally,
@@ -78,4 +81,24 @@ export function substructureSearch(idCodeQuery, entries, options = {}) {
78
81
  stopped: run.stopped,
79
82
  };
80
83
  }
84
+ /**
85
+ * The query as the WebAssembly side reads it: one idcode, or several joined by `'\n'`, which no
86
+ * idcode contains.
87
+ * @param idCodeQuery - The query, as an idcode or several.
88
+ * @returns The query string.
89
+ * @throws {Error} If the list is empty or an entry holds a line break.
90
+ */
91
+ function joinQueries(idCodeQuery) {
92
+ if (typeof idCodeQuery === 'string')
93
+ return idCodeQuery;
94
+ if (idCodeQuery.length === 0) {
95
+ throw new Error('the query list is empty: give at least one idcode');
96
+ }
97
+ for (const idCode of idCodeQuery) {
98
+ if (idCode.includes('\n')) {
99
+ throw new Error(`"${idCode}" is not a valid query idcode`);
100
+ }
101
+ }
102
+ return idCodeQuery.join('\n');
103
+ }
81
104
  //# sourceMappingURL=substructureSearch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"substructureSearch.js","sourceRoot":"","sources":["../src/substructureSearch.ts"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,CAAC;IACD,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC"}
package/lib/types.d.ts CHANGED
@@ -156,12 +156,32 @@ export interface SimilaritySearchResult<Entry> extends SearchResult<Entry> {
156
156
  /** The shape TeaVM exports from the WasmGC module. Both take a half-open `[from, to)` range. */
157
157
  export interface OCLSearch {
158
158
  Search: {
159
- /** Returns how many molecules in the range contain the fragment. */
159
+ /**
160
+ * Returns how many molecules in the range contain the fragment, or any of the fragments when
161
+ * the query holds several idcodes joined by `'\n'`.
162
+ */
160
163
  ssSearch: (idCodeQuery: string, idCodes: string[], result: Uint8Array, from: number, to: number) => number;
161
164
  /** Returns how many molecules in the range were parsed and compared. */
162
165
  similaritySearch: (idCodeQuery: string, idCodes: string[], result: Float32Array, from: number, to: number) => number;
163
166
  /** Returns how many molecules in the range were parsed and fingerprinted. */
164
167
  getIndexes: (idCodes: string[], result: Int32Array, from: number, to: number) => number;
168
+ /** Returns how many molecules in the range were parsed and screened. */
169
+ getScreens: (idCodes: string[], result: Int32Array, from: number, to: number) => number;
170
+ /** Writes the query's sixteen screen words into `result`. */
171
+ getQueryScreen: (idCodeQuery: string, result: Int32Array) => void;
172
+ /** Writes the query's sixteen FragFp words into `result`. */
173
+ getQueryIndex: (idCodeQuery: string, result: Int32Array) => void;
174
+ /** Returns FragFp's 512 key idcodes, in bit order, joined by `'\n'`. */
175
+ getFragFpKeys: () => string;
176
+ /** Returns the screen's 512 key idcodes, in bit order, joined by `'\n'`. */
177
+ getScreenKeys: () => string;
178
+ /** Returns how many molecules in the range were parsed and read. */
179
+ getFunctions: (idCodes: string[], result: Int32Array, from: number, to: number) => number;
180
+ /**
181
+ * Returns the 512 stored function keys, in bit order, joined by `'\n'`: each key's fragment
182
+ * idcodes joined by a space.
183
+ */
184
+ getFunctionKeys: () => string;
165
185
  /** Returns how many molecules in the range were hashed. */
166
186
  getNoStereoTautomerHashes: (idCodes: string[], result: BigInt64Array, tautomerCounts: Int32Array, largestFragmentOnly: boolean, maxTautomers: number, from: number, to: number) => number;
167
187
  /** Returns how many molecules in the range were hashed. */
@@ -170,10 +190,21 @@ export interface OCLSearch {
170
190
  getNoStereoIdCodes: (idCodes: string[], result: string[], largestFragmentOnly: boolean, from: number, to: number) => number;
171
191
  /** Returns how many molecules in the range were canonized. */
172
192
  getNoStereoTautomerIdCodes: (idCodes: string[], result: string[], tautomerCounts: Int32Array, largestFragmentOnly: boolean, maxTautomers: number, from: number, to: number) => number;
193
+ /** Returns how many molecules in the range were read. */
194
+ getMoleculeRecords: (idCodes: string[], canonical: string[], words: Int32Array, atomCounts: Int32Array, weights: Float64Array, noStereoHashes: BigInt64Array, tautomerHashes: BigInt64Array, tautomerCounts: Int32Array, maxTautomers: number, from: number, to: number) => number;
195
+ /** Returns how many molecules in the range were read. */
196
+ getMoleculeSizes: (idCodes: string[], atomCounts: Int32Array, weights: Float64Array, from: number, to: number) => number;
197
+ /** Returns the query's atom floor. */
198
+ getQueryAtomFloor: (idCodeQuery: string) => number;
173
199
  };
174
200
  }
175
- /** How many 32-bit words one molecule's FragFp fingerprint occupies. */
201
+ /** How many 32-bit words one molecule's FragFp fingerprint, its screen, or its function bits occupy. */
176
202
  export declare const INDEX_WORDS = 16;
203
+ /**
204
+ * How many 32-bit words one molecule's record holds in `getMoleculeRecords`: its FragFp, its screen,
205
+ * then its function bits, {@link INDEX_WORDS} each.
206
+ */
207
+ export declare const RECORD_WORDS: number;
177
208
  /** What every hash function takes. */
178
209
  export interface HashOptions {
179
210
  /**
@@ -207,6 +238,56 @@ export interface HashOptions {
207
238
  }
208
239
  /** {@link HashOptions} under the name the tautomer hashes introduced it with. */
209
240
  export type TautomerHashOptions = HashOptions;
241
+ /** What `getMoleculeRecords` takes. */
242
+ export interface MoleculeRecordsOptions {
243
+ /**
244
+ * The ceiling on the tautomer enumeration. A molecule that reaches it takes its no-stereo hash as
245
+ * its tautomer hash, because a key from a truncated enumeration is not canonical.
246
+ * @default DEFAULT_MAX_TAUTOMERS
247
+ */
248
+ maxTautomers?: number;
249
+ }
250
+ /**
251
+ * Everything a molecule table stores about each molecule, one entry per input idcode, in input
252
+ * order. A molecule whose idcode cannot be read gets `NO_ID_CODE`, 48 zero words, 0 atoms, a `NaN`
253
+ * weight, `NO_HASH` twice and a tautomer count of 0.
254
+ */
255
+ export interface MoleculeRecords {
256
+ /**
257
+ * The canonical idcode, stereochemistry included: what `openchemlib-js` gives for
258
+ * `Molecule.fromIDCode(idCode).getIDCode()`.
259
+ */
260
+ idCodes: string[];
261
+ /**
262
+ * {@link RECORD_WORDS} words per molecule, at `48 * i`: the FragFp (the 16 words of `getIndexes`),
263
+ * the screen (the 16 words of `getScreens`), then the function bits (the 16 words of
264
+ * `getFunctions`).
265
+ */
266
+ words: Int32Array;
267
+ /** `getAllAtoms()` of the molecule parsed without coordinates, explicit hydrogens included. */
268
+ atomCounts: Int32Array;
269
+ /** OpenChemLib's relative molecular weight. */
270
+ weights: Float64Array;
271
+ /** The value of `getNoStereoHashes`. */
272
+ noStereoHashes: BigInt64Array;
273
+ /**
274
+ * The value of `getNoStereoTautomerHashes`, except for a molecule whose enumeration reached
275
+ * `maxTautomers` or could not be canonized: that one gets its no-stereo hash.
276
+ */
277
+ tautomerHashes: BigInt64Array;
278
+ /** How many tautomers were enumerated; at or above `maxTautomers` the enumeration was cut short. */
279
+ tautomerCounts: Int32Array;
280
+ }
281
+ /** The size of each molecule, one entry per input idcode, in input order. */
282
+ export interface MoleculeSizes {
283
+ /**
284
+ * `getAllAtoms()` of the molecule parsed without coordinates, explicit hydrogens included; 0 when
285
+ * the idcode cannot be read.
286
+ */
287
+ atomCounts: Int32Array;
288
+ /** OpenChemLib's relative molecular weight; `NaN` when the idcode cannot be read. */
289
+ weights: Float64Array;
290
+ }
210
291
  /**
211
292
  * The hash of a molecule that has none: its idcode could not be parsed, or OpenChemLib could not
212
293
  * canonize it. A real hash collides with it once in 2^64, so an equality test against it is a
@@ -1 +1 @@
1
- {"version":3,"file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;;GAGG;AACH,eAAO,MAAM,YAAY,QAAkB,CAAC;AAE5C,sCAAsC;AACtC,MAAM,WAAW,WAAW;IAC1B;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;;;;;;;;;OAUG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,UAAU,CAAC;CAC7B;AAED,iFAAiF;AACjF,MAAM,MAAM,mBAAmB,GAAG,WAAW,CAAC;AAE9C,uCAAuC;AACvC,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB;;;;OAIG;IACH,KAAK,EAAE,UAAU,CAAC;IAClB,+FAA+F;IAC/F,UAAU,EAAE,UAAU,CAAC;IACvB,+CAA+C;IAC/C,OAAO,EAAE,YAAY,CAAC;IACtB,wCAAwC;IACxC,cAAc,EAAE,aAAa,CAAC;IAC9B;;;OAGG;IACH,cAAc,EAAE,aAAa,CAAC;IAC9B,oGAAoG;IACpG,cAAc,EAAE,UAAU,CAAC;CAC5B;AAED,6EAA6E;AAC7E,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,UAAU,EAAE,UAAU,CAAC;IACvB,qFAAqF;IACrF,OAAO,EAAE,YAAY,CAAC;CACvB;AAED;;;;GAIG;AACH,eAAO,MAAM,OAAO,KAAK,CAAC;AAE1B;;;;GAIG;AACH,eAAO,MAAM,UAAU,KAAK,CAAC;AAE7B;;;GAGG;AACH,eAAO,MAAM,qBAAqB,SAAU,CAAC"}
package/lib/types.js CHANGED
@@ -25,8 +25,13 @@ export const SimilarityResult = Object.freeze({
25
25
  /** The idcode could not be parsed; nothing was compared. */
26
26
  unparsable: -1,
27
27
  });
28
- /** How many 32-bit words one molecule's FragFp fingerprint occupies. */
28
+ /** How many 32-bit words one molecule's FragFp fingerprint, its screen, or its function bits occupy. */
29
29
  export const INDEX_WORDS = 16;
30
+ /**
31
+ * How many 32-bit words one molecule's record holds in `getMoleculeRecords`: its FragFp, its screen,
32
+ * then its function bits, {@link INDEX_WORDS} each.
33
+ */
34
+ export const RECORD_WORDS = 3 * INDEX_WORDS;
30
35
  /**
31
36
  * The hash of a molecule that has none: its idcode could not be parsed, or OpenChemLib could not
32
37
  * canonize it. A real hash collides with it once in 2^64, so an equality test against it is a
package/lib/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9C,sBAAsB;IACtB,WAAW,EAAE,CAAC;IACd,oDAAoD;IACpD,KAAK,EAAE,CAAC;IACR,wDAAwD;IACxD,OAAO,EAAE,CAAC;IACV,0DAA0D;IAC1D,UAAU,EAAE,CAAC;CACd,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5C,wBAAwB;IACxB,WAAW,EAAE,MAAM,CAAC,GAAG;IACvB,4DAA4D;IAC5D,UAAU,EAAE,CAAC,CAAC;CACf,CAAC,CAAC;AA4MH,wEAAwE;AACxE,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC;AAuC9B;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,EAAE,CAAC;AAE1B;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,CAAC;AAE7B;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9C,sBAAsB;IACtB,WAAW,EAAE,CAAC;IACd,oDAAoD;IACpD,KAAK,EAAE,CAAC;IACR,wDAAwD;IACxD,OAAO,EAAE,CAAC;IACV,0DAA0D;IAC1D,UAAU,EAAE,CAAC;CACd,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5C,wBAAwB;IACxB,WAAW,EAAE,MAAM,CAAC,GAAG;IACvB,4DAA4D;IAC5D,UAAU,EAAE,CAAC,CAAC;CACf,CAAC,CAAC;AAkQH,wGAAwG;AACxG,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC;AAE9B;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAG,WAAW,CAAC;AA4F5C;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,EAAE,CAAC;AAE1B;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,CAAC;AAE7B;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openchemlib-search-wasm",
3
- "version": "2.0.0",
3
+ "version": "2.1.1",
4
4
  "type": "module",
5
5
  "description": "Batch substructure and similarity search over idcodes, with OpenChemLib compiled to WebAssembly",
6
6
  "keywords": [
@@ -28,6 +28,7 @@
28
28
  "benchmark-scan": "node benchmark/scan.mjs",
29
29
  "build": "npm run build-wasm && npm run build-embed",
30
30
  "build-embed": "node build/embed-wasm.mjs",
31
+ "build-function-keys": "node scripts/build-function-keys.mjs",
31
32
  "build-wasm": "node scripts/build-wasm.mjs",
32
33
  "check-types": "tsc --noEmit",
33
34
  "check-wasm": "node scripts/check-wasm.mjs",
@@ -45,10 +46,12 @@
45
46
  "tsc-build": "tsc --project tsconfig.build.json"
46
47
  },
47
48
  "exports": {
48
- ".": "./lib/index.js"
49
+ ".": "./lib/index.js",
50
+ "./function-keys": "./lib/functionKeys/index.js"
49
51
  },
50
52
  "imports": {
51
- "#lib": "./src/index.ts"
53
+ "#lib": "./src/index.ts",
54
+ "#function-keys": "./src/functionKeys/index.ts"
52
55
  },
53
56
  "files": [
54
57
  "lib",