openchemlib-search-wasm 1.2.0 → 2.0.0
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/README.md +148 -0
- package/lib/hex.d.ts +31 -0
- package/lib/hex.d.ts.map +1 -0
- package/lib/hex.js +41 -0
- package/lib/hex.js.map +1 -0
- package/lib/index.d.ts +58 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +83 -7
- package/lib/index.js.map +1 -1
- package/lib/scan.d.ts +37 -7
- package/lib/scan.d.ts.map +1 -1
- package/lib/scan.js +90 -11
- package/lib/scan.js.map +1 -1
- package/lib/strongHash.d.ts +9 -0
- package/lib/strongHash.d.ts.map +1 -0
- package/lib/strongHash.js +56 -0
- package/lib/strongHash.js.map +1 -0
- package/lib/types.d.ts +37 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +11 -0
- package/lib/types.js.map +1 -1
- package/lib/wasm/load.d.ts.map +1 -1
- package/lib/wasm/load.js +9 -1
- package/lib/wasm/load.js.map +1 -1
- package/lib/wasm/log.d.ts +36 -0
- package/lib/wasm/log.d.ts.map +1 -0
- package/lib/wasm/log.js +52 -0
- package/lib/wasm/log.js.map +1 -0
- package/package.json +1 -1
- package/src/hex.ts +43 -0
- package/src/index.ts +147 -5
- package/src/scan.ts +169 -16
- package/src/strongHash.ts +57 -0
- package/src/types.ts +56 -0
- package/src/wasm/load.ts +10 -1
- package/src/wasm/log.ts +66 -0
- package/wasm/data.js +1 -1
- package/wasm/runtime.d.ts +6 -0
package/README.md
CHANGED
|
@@ -37,6 +37,22 @@ getNoStereoHashes(idCodes: string[], options?: HashOptions): BigInt64Array;
|
|
|
37
37
|
// the same, across its tautomers as well
|
|
38
38
|
getNoStereoTautomerHash(idCode: string, options?: HashOptions): bigint;
|
|
39
39
|
getNoStereoTautomerHashes(idCodes: string[], options?: HashOptions): BigInt64Array;
|
|
40
|
+
|
|
41
|
+
// the same two canonical forms as idcodes, for a column that stores the form itself
|
|
42
|
+
getNoStereoIdCode(idCode: string, options?: HashOptions): string;
|
|
43
|
+
getNoStereoIdCodes(idCodes: string[], options?: HashOptions): string[];
|
|
44
|
+
getNoStereoTautomerIdCode(idCode: string, options?: HashOptions): string;
|
|
45
|
+
getNoStereoTautomerIdCodes(idCodes: string[], options?: HashOptions): string[];
|
|
46
|
+
|
|
47
|
+
// a hash as the 16 hex digits that cross an API, and back
|
|
48
|
+
hashToHex(hash: bigint): string;
|
|
49
|
+
hexToHash(hex: string): bigint;
|
|
50
|
+
|
|
51
|
+
// the hash of a canonical idcode you already hold, without canonizing again
|
|
52
|
+
strongHash(idCode: string): bigint;
|
|
53
|
+
|
|
54
|
+
// where OpenChemLib's own diagnostics go; nothing is printed by default
|
|
55
|
+
setLogHandler(handler: LogHandler | null): void;
|
|
40
56
|
```
|
|
41
57
|
|
|
42
58
|
**Give it your objects and it gives them back.** An entry is an idcode or anything carrying one — a
|
|
@@ -144,6 +160,13 @@ const index = getIndex(idCode);
|
|
|
144
160
|
const columns = new BigInt64Array(index.buffer, index.byteOffset, 8);
|
|
145
161
|
```
|
|
146
162
|
|
|
163
|
+
**Pass `byteOffset` and the length, as above.** `getIndexes` returns its views over one shared
|
|
164
|
+
buffer — offsets 0, 64, 128 and so on — so `new BigInt64Array(index.buffer)` is 8 columns only for
|
|
165
|
+
the first molecule and silently reads the first molecule's words for every other one. It is wrong in
|
|
166
|
+
a way nothing reports: the row is written, the index is built, and the screen then misses real hits.
|
|
167
|
+
`getIndex` on its own always sits at offset 0, which is exactly what makes the mistake survive
|
|
168
|
+
testing on one molecule.
|
|
169
|
+
|
|
147
170
|
This is the expensive half of importing a library, and where the biggest speedup is.
|
|
148
171
|
|
|
149
172
|
## Identity hashes
|
|
@@ -189,6 +212,87 @@ molecule OpenChemLib cannot canonize, gets `NO_HASH` (`0n`).
|
|
|
189
212
|
Both take `{ largestFragmentOnly: true }` to strip everything but the largest fragment and
|
|
190
213
|
neutralize it first, so a salt hashes as its parent structure.
|
|
191
214
|
|
|
215
|
+
### The canonical form itself
|
|
216
|
+
|
|
217
|
+
Each hash is OpenChemLib's 64-bit StrongHasher over a canonical idcode, and that idcode is available
|
|
218
|
+
too — `getNoStereoIdCode` and `getNoStereoTautomerIdCode`, with `…IdCodes` batch forms. They are the
|
|
219
|
+
exact strings the hashes hash, computed by the same code, so the two can never disagree.
|
|
220
|
+
|
|
221
|
+
Prefer the hash for a column that is only ever compared: 8 bytes that an integer index handles,
|
|
222
|
+
against around 25 characters for a no-stereo idcode and roughly twice that for a tautomer one. Reach
|
|
223
|
+
for the idcode when you need the canonical form itself — to show it, to hand it to another
|
|
224
|
+
OpenChemLib, or because a 1-in-2^64 collision is not acceptable for what the column decides.
|
|
225
|
+
|
|
226
|
+
**A tautomer idcode is a key, not a structure.** Parsing one back gives a molecule with every
|
|
227
|
+
tautomeric bond normalized and pi-electron counts in its atom labels, not the compound.
|
|
228
|
+
|
|
229
|
+
### Stereochemistry and coordinates
|
|
230
|
+
|
|
231
|
+
These functions canonize with the canonizer told to disregard stereochemistry, rather than by
|
|
232
|
+
stripping stereo from the molecule and canonizing that. The distinction matters because the module
|
|
233
|
+
parses idcodes without inventing coordinates: `stripStereoInformation()` turns an implicit
|
|
234
|
+
double-bond configuration into a cross bond, there is no stereo bond to turn without coordinates, and
|
|
235
|
+
the canonizer then assigns a configuration instead of dropping one. Measured over 400 real idcodes,
|
|
236
|
+
the stripping route disagreed with the answer a caller holding a molecule gets on 6 of them — turning
|
|
237
|
+
an unconfigured double bond into E, and flipping a Z one. So a compound drawn without its
|
|
238
|
+
double-bond stereo keyed differently from the same compound drawn with it, which is the one thing
|
|
239
|
+
these keys exist to prevent.
|
|
240
|
+
|
|
241
|
+
Disregarding stereo in the canonizer agrees with the coordinate-bearing answer on all 400 and costs
|
|
242
|
+
nothing. Inventing coordinates would also agree, and costs 19 times the parse.
|
|
243
|
+
|
|
244
|
+
**This changed the hashes in 2.0.0.** A column of `getNoStereoHash` or `getNoStereoTautomerHash`
|
|
245
|
+
values written by 1.x has to be rebuilt; around 1.5% of them were wrong, and which ones depends on
|
|
246
|
+
whether the molecule had an unconfigured stereogenic double bond.
|
|
247
|
+
|
|
248
|
+
### Bounding the tautomer tail
|
|
249
|
+
|
|
250
|
+
The cost of a tautomer key is set by how many tautomers the molecule has, not by its size, and the
|
|
251
|
+
spread is enormous: over a drug-like fixture the median molecule takes 0.12 ms and one in a hundred
|
|
252
|
+
takes most of a second. `maxTautomers` is the ceiling OpenChemLib stops at, and lowering it bounds
|
|
253
|
+
that tail. `tautomerCounts` says which molecules ran into it — the only signal that a key came from
|
|
254
|
+
a truncated enumeration, and so may not be canonical:
|
|
255
|
+
|
|
256
|
+
```js
|
|
257
|
+
const tautomerCounts = new Int32Array(idCodes.length);
|
|
258
|
+
const maxTautomers = 1000;
|
|
259
|
+
const keys = getNoStereoTautomerIdCodes(idCodes, {
|
|
260
|
+
maxTautomers,
|
|
261
|
+
tautomerCounts,
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
// keys[i] is not canonical where this holds — record it next to the key
|
|
265
|
+
const truncated = (i) => tautomerCounts[i] >= maxTautomers;
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
Measured over 200 fixture idcodes:
|
|
269
|
+
|
|
270
|
+
| `maxTautomers` | median | p99 | slowest | whole batch | truncated |
|
|
271
|
+
| ---------------: | ------: | -----: | ------: | ----------: | --------: |
|
|
272
|
+
| 100000 (default) | 0.12 ms | 807 ms | 969 ms | 1824 ms | 2 |
|
|
273
|
+
| 10000 | 0.06 ms | 46 ms | 63 ms | 135 ms | 2 |
|
|
274
|
+
| 1000 | 0.06 ms | 3 ms | 4 ms | 33 ms | 2 |
|
|
275
|
+
| 100 | 0.06 ms | 1 ms | 1 ms | 17 ms | 8 |
|
|
276
|
+
|
|
277
|
+
At 1000 the slowest molecule is 242x cheaper and the batch 55x, and the same two molecules are
|
|
278
|
+
truncated as at the default — so the ceiling costs nothing on this fixture beyond what the default
|
|
279
|
+
already gave up on. Where it lands for your library is an empirical question: lower it, and count.
|
|
280
|
+
|
|
281
|
+
### Getting both the key and its hash
|
|
282
|
+
|
|
283
|
+
`strongHash` is OpenChemLib's 64-bit hasher, and every `CanonizerUtil` hash is defined as that hasher
|
|
284
|
+
over a canonical idcode. So a caller that wants both forms asks for the idcode and hashes it, rather
|
|
285
|
+
than calling two functions that each canonize:
|
|
286
|
+
|
|
287
|
+
```js
|
|
288
|
+
const idCode = getNoStereoTautomerIdCode(entry);
|
|
289
|
+
const hash = strongHash(idCode); // identical to getNoStereoTautomerHash(entry)
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
That matters because canonizing a generic tautomer is the most expensive thing here: asking for both
|
|
293
|
+
separately costs 9% more on the median molecule and 48% more averaged over a library. It is also how
|
|
294
|
+
a database backfills a hash column from idcodes it already stores, with no chemistry at all.
|
|
295
|
+
|
|
192
296
|
### What they cost
|
|
193
297
|
|
|
194
298
|
On ordinary drug-like molecules the no-stereo hash costs about 52 µs and the tautomer one about
|
|
@@ -205,6 +309,50 @@ Two things follow. Hash a library **in a worker**, never on the main thread. And
|
|
|
205
309
|
identity up to stereochemistry, `getNoStereoHash` is the one to reach for: it is the hash whose cost
|
|
206
310
|
you can predict.
|
|
207
311
|
|
|
312
|
+
### Getting a hash out of a process
|
|
313
|
+
|
|
314
|
+
A hash is a signed 64-bit integer. `JSON.stringify` throws on a `BigInt`, and a JSON number could
|
|
315
|
+
not carry one anyway, so a hash that leaves the process goes as the 16 hex digits of its pattern:
|
|
316
|
+
|
|
317
|
+
```js
|
|
318
|
+
import { hashToHex, hexToHash } from 'openchemlib-search-wasm';
|
|
319
|
+
|
|
320
|
+
hashToHex(getNoStereoTautomerHash(idCode)); // 'eb14b9bc9ab4dd52', always 16 characters
|
|
321
|
+
hexToHash('eb14b9bc9ab4dd52'); // -1507375755561738926n
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
`hash.toString(16)` is not the same thing: it writes `-1` for `-1n`, where the pattern is
|
|
325
|
+
`ffffffffffffffff`, and it pads nothing.
|
|
326
|
+
|
|
327
|
+
Store the hash in an integer column — 8 bytes, and the column indexes as an integer — and let the
|
|
328
|
+
database format it on the way out. SQLite's `printf('%016x', hash)` produces exactly the same
|
|
329
|
+
string, which also keeps a 64-bit value from ever being read into a JavaScript number:
|
|
330
|
+
|
|
331
|
+
```sql
|
|
332
|
+
SELECT printf('%016x', no_stereo_tautomer_hash) AS hash FROM molecules WHERE id = ?;
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
## Diagnostics
|
|
336
|
+
|
|
337
|
+
**Nothing here writes to your console.** The generated TeaVM runtime maps Java's standard output
|
|
338
|
+
onto `console.log`, which is the stream a server writing structured logs is already using. Anything
|
|
339
|
+
OpenChemLib printed would interleave unparsable lines into that log, so Java's two streams are
|
|
340
|
+
routed to a sink that drops them, and a host that wants them says where:
|
|
341
|
+
|
|
342
|
+
```js
|
|
343
|
+
import { setLogHandler } from 'openchemlib-search-wasm';
|
|
344
|
+
|
|
345
|
+
setLogHandler((message, stream) => logger.debug({ stream }, message));
|
|
346
|
+
setLogHandler(null); // back to discarding
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
The handler applies whether or not the module has been instantiated, so it can be set at startup or
|
|
350
|
+
around a single call. It is per module instance, which means per worker.
|
|
351
|
+
|
|
352
|
+
OpenChemLib's one message, `Tautomer count exceeds maximum`, is switched off at its source rather
|
|
353
|
+
than merely dropped here: it built its text with a full extra canonization of the molecule, once per
|
|
354
|
+
molecule it gave up on. `tautomerCounts` says the same thing without the work.
|
|
355
|
+
|
|
208
356
|
## What you actually win
|
|
209
357
|
|
|
210
358
|
Against `openchemlib` 9.25.0, on 409,686 real idcodes, with identical hit counts for every query:
|
package/lib/hex.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
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
ADDED
|
@@ -0,0 +1 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
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
ADDED
|
@@ -0,0 +1 @@
|
|
|
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"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { HashOptions } from './types.ts';
|
|
2
2
|
export { substructureSearch } from './substructureSearch.ts';
|
|
3
|
+
export { setLogHandler } from './wasm/log.ts';
|
|
4
|
+
export { hashToHex, hexToHash } from './hex.ts';
|
|
5
|
+
export { strongHash } from './strongHash.ts';
|
|
3
6
|
export { similaritySearch } from './similaritySearch.ts';
|
|
4
|
-
export { INDEX_WORDS, NO_HASH } from './types.ts';
|
|
7
|
+
export { DEFAULT_MAX_TAUTOMERS, INDEX_WORDS, NO_HASH, NO_ID_CODE, } from './types.ts';
|
|
8
|
+
export type { LogHandler, LogStream } from './wasm/log.ts';
|
|
5
9
|
export type { HashOptions, ResultBuffer, SearchMode, SearchOptions, SearchResult, SearchStep, SimilaritySearchOptions, SimilaritySearchResult, SubstructureSearchOptions, SubstructureSearchResult, TautomerHashOptions, } from './types.ts';
|
|
6
10
|
export { SimilarityResult, SubstructureResult } from './types.ts';
|
|
7
11
|
/**
|
|
@@ -117,4 +121,57 @@ export declare function getNoStereoHash(idCode: string, options?: HashOptions):
|
|
|
117
121
|
* hashed.
|
|
118
122
|
*/
|
|
119
123
|
export declare function getNoStereoHashes(idCodes: string[], options?: HashOptions): BigInt64Array;
|
|
124
|
+
/**
|
|
125
|
+
* Canonizes one idcode to the form OpenChemLib identifies a molecule by up to stereochemistry.
|
|
126
|
+
*
|
|
127
|
+
* This is the string {@link getNoStereoHash} hashes, for a database that stores the canonical form
|
|
128
|
+
* itself. Prefer the hash where the column is only ever compared: it is a signed 64-bit integer, so
|
|
129
|
+
* it stores and indexes in 8 bytes where these idcodes average around 25 characters.
|
|
130
|
+
*
|
|
131
|
+
* ```js
|
|
132
|
+
* getNoStereoIdCode(idCode); // 'gGX`BDdwMT@@'
|
|
133
|
+
* ```
|
|
134
|
+
* @param idCode - The molecule to canonize, as an idcode.
|
|
135
|
+
* @param options - See {@link HashOptions}.
|
|
136
|
+
* @returns Its canonical no-stereo idcode, or `NO_ID_CODE` (`''`) for an idcode that will not parse
|
|
137
|
+
* or a molecule OpenChemLib cannot canonize.
|
|
138
|
+
*/
|
|
139
|
+
export declare function getNoStereoIdCode(idCode: string, options?: HashOptions): string;
|
|
140
|
+
/**
|
|
141
|
+
* Canonizes every idcode to the form OpenChemLib identifies a molecule by up to stereochemistry.
|
|
142
|
+
*
|
|
143
|
+
* See {@link getNoStereoIdCode} for what the form identifies.
|
|
144
|
+
* @param idCodes - The molecules to canonize, as idcodes.
|
|
145
|
+
* @param options - See {@link HashOptions}.
|
|
146
|
+
* @returns One idcode per input, in order, with `NO_ID_CODE` (`''`) for each one that could not be
|
|
147
|
+
* canonized.
|
|
148
|
+
*/
|
|
149
|
+
export declare function getNoStereoIdCodes(idCodes: string[], options?: HashOptions): string[];
|
|
150
|
+
/**
|
|
151
|
+
* Canonizes one idcode to the form OpenChemLib identifies a molecule by up to tautomerism and
|
|
152
|
+
* stereochemistry.
|
|
153
|
+
*
|
|
154
|
+
* This is the string {@link getNoStereoTautomerHash} hashes. It is the generic tautomer's idcode, so
|
|
155
|
+
* it is longer than the molecule's own — around twice it for a molecule with tautomeric sites — and
|
|
156
|
+
* it is not a structure: parsing it back gives a molecule with every tautomeric bond normalized, not
|
|
157
|
+
* the compound. Use it as a key, never as something to draw.
|
|
158
|
+
* @param idCode - The molecule to canonize, as an idcode.
|
|
159
|
+
* @param options - See {@link HashOptions}.
|
|
160
|
+
* @returns Its canonical no-stereo generic-tautomer idcode, or `NO_ID_CODE` (`''`) for an idcode that
|
|
161
|
+
* will not parse or a molecule OpenChemLib cannot canonize.
|
|
162
|
+
*/
|
|
163
|
+
export declare function getNoStereoTautomerIdCode(idCode: string, options?: HashOptions): string;
|
|
164
|
+
/**
|
|
165
|
+
* Canonizes every idcode to the form OpenChemLib identifies a molecule by up to tautomerism and
|
|
166
|
+
* stereochemistry.
|
|
167
|
+
*
|
|
168
|
+
* See {@link getNoStereoTautomerIdCode} for what the form identifies, and
|
|
169
|
+
* {@link getNoStereoTautomerHashes} for what it costs — the canonization is the expensive part, not
|
|
170
|
+
* the hashing, so these cost what those do.
|
|
171
|
+
* @param idCodes - The molecules to canonize, as idcodes.
|
|
172
|
+
* @param options - See {@link HashOptions}.
|
|
173
|
+
* @returns One idcode per input, in order, with `NO_ID_CODE` (`''`) for each one that could not be
|
|
174
|
+
* canonized.
|
|
175
|
+
*/
|
|
176
|
+
export declare function getNoStereoTautomerIdCodes(idCodes: string[], options?: HashOptions): string[];
|
|
120
177
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAG9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EACL,qBAAqB,EACrB,WAAW,EACX,OAAO,EACP,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC3D,YAAY,EACV,WAAW,EACX,YAAY,EACZ,UAAU,EACV,aAAa,EACb,YAAY,EACZ,UAAU,EACV,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAInD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE,CAQ1D;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,WAAgB,GACxB,MAAM,CAiBR;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,GAAE,WAAgB,GACxB,aAAa,CAiBf;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,WAAgB,GACxB,MAAM,CAKR;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,GAAE,WAAgB,GACxB,aAAa,CAKf;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,WAAgB,GACxB,MAAM,CAKR;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,GAAE,WAAgB,GACxB,MAAM,EAAE,CAKV;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,WAAgB,GACxB,MAAM,CAiBR;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,GAAE,WAAgB,GACxB,MAAM,EAAE,CAiBV"}
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { buildIndexes, buildNoStereoHashes, buildNoStereoTautomerHashes, } from "./scan.js";
|
|
2
|
-
import { INDEX_WORDS } from "./types.js";
|
|
1
|
+
import { buildIndexes, buildNoStereoHashes, buildNoStereoIdCodes, buildNoStereoTautomerHashes, buildNoStereoTautomerIdCodes, } from "./scan.js";
|
|
2
|
+
import { DEFAULT_MAX_TAUTOMERS, INDEX_WORDS, NO_ID_CODE } from "./types.js";
|
|
3
3
|
export { substructureSearch } from "./substructureSearch.js";
|
|
4
|
+
export { setLogHandler } from "./wasm/log.js";
|
|
5
|
+
export { hashToHex, hexToHash } from "./hex.js";
|
|
6
|
+
export { strongHash } from "./strongHash.js";
|
|
4
7
|
export { similaritySearch } from "./similaritySearch.js";
|
|
5
|
-
export { INDEX_WORDS, NO_HASH } from "./types.js";
|
|
8
|
+
export { DEFAULT_MAX_TAUTOMERS, INDEX_WORDS, NO_HASH, NO_ID_CODE, } from "./types.js";
|
|
6
9
|
export { SimilarityResult, SubstructureResult } from "./types.js";
|
|
7
10
|
/**
|
|
8
11
|
* Builds the 512-bit FragFp fingerprint of one idcode, as sixteen 32-bit words.
|
|
@@ -74,9 +77,9 @@ export function getIndexes(idCodes) {
|
|
|
74
77
|
* OpenChemLib cannot canonize.
|
|
75
78
|
*/
|
|
76
79
|
export function getNoStereoTautomerHash(idCode, options = {}) {
|
|
77
|
-
const { largestFragmentOnly = false } = options;
|
|
80
|
+
const { largestFragmentOnly = false, tautomerCounts, maxTautomers = DEFAULT_MAX_TAUTOMERS, } = options;
|
|
78
81
|
const result = new BigInt64Array(1);
|
|
79
|
-
buildNoStereoTautomerHashes([idCode], result, largestFragmentOnly, 0, 1);
|
|
82
|
+
buildNoStereoTautomerHashes([idCode], result, largestFragmentOnly, 0, 1, tautomerCounts, maxTautomers);
|
|
80
83
|
return result[0];
|
|
81
84
|
}
|
|
82
85
|
/**
|
|
@@ -97,9 +100,9 @@ export function getNoStereoTautomerHash(idCode, options = {}) {
|
|
|
97
100
|
* hashed.
|
|
98
101
|
*/
|
|
99
102
|
export function getNoStereoTautomerHashes(idCodes, options = {}) {
|
|
100
|
-
const { largestFragmentOnly = false } = options;
|
|
103
|
+
const { largestFragmentOnly = false, tautomerCounts, maxTautomers = DEFAULT_MAX_TAUTOMERS, } = options;
|
|
101
104
|
const result = new BigInt64Array(idCodes.length);
|
|
102
|
-
buildNoStereoTautomerHashes(idCodes, result, largestFragmentOnly, 0, idCodes.length);
|
|
105
|
+
buildNoStereoTautomerHashes(idCodes, result, largestFragmentOnly, 0, idCodes.length, tautomerCounts, maxTautomers);
|
|
103
106
|
return result;
|
|
104
107
|
}
|
|
105
108
|
/**
|
|
@@ -149,4 +152,77 @@ export function getNoStereoHashes(idCodes, options = {}) {
|
|
|
149
152
|
buildNoStereoHashes(idCodes, result, largestFragmentOnly, 0, idCodes.length);
|
|
150
153
|
return result;
|
|
151
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Canonizes one idcode to the form OpenChemLib identifies a molecule by up to stereochemistry.
|
|
157
|
+
*
|
|
158
|
+
* This is the string {@link getNoStereoHash} hashes, for a database that stores the canonical form
|
|
159
|
+
* itself. Prefer the hash where the column is only ever compared: it is a signed 64-bit integer, so
|
|
160
|
+
* it stores and indexes in 8 bytes where these idcodes average around 25 characters.
|
|
161
|
+
*
|
|
162
|
+
* ```js
|
|
163
|
+
* getNoStereoIdCode(idCode); // 'gGX`BDdwMT@@'
|
|
164
|
+
* ```
|
|
165
|
+
* @param idCode - The molecule to canonize, as an idcode.
|
|
166
|
+
* @param options - See {@link HashOptions}.
|
|
167
|
+
* @returns Its canonical no-stereo idcode, or `NO_ID_CODE` (`''`) for an idcode that will not parse
|
|
168
|
+
* or a molecule OpenChemLib cannot canonize.
|
|
169
|
+
*/
|
|
170
|
+
export function getNoStereoIdCode(idCode, options = {}) {
|
|
171
|
+
const { largestFragmentOnly = false } = options;
|
|
172
|
+
const result = [NO_ID_CODE];
|
|
173
|
+
buildNoStereoIdCodes([idCode], result, largestFragmentOnly, 0, 1);
|
|
174
|
+
return result[0];
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Canonizes every idcode to the form OpenChemLib identifies a molecule by up to stereochemistry.
|
|
178
|
+
*
|
|
179
|
+
* See {@link getNoStereoIdCode} for what the form identifies.
|
|
180
|
+
* @param idCodes - The molecules to canonize, as idcodes.
|
|
181
|
+
* @param options - See {@link HashOptions}.
|
|
182
|
+
* @returns One idcode per input, in order, with `NO_ID_CODE` (`''`) for each one that could not be
|
|
183
|
+
* canonized.
|
|
184
|
+
*/
|
|
185
|
+
export function getNoStereoIdCodes(idCodes, options = {}) {
|
|
186
|
+
const { largestFragmentOnly = false } = options;
|
|
187
|
+
const result = new Array(idCodes.length).fill(NO_ID_CODE);
|
|
188
|
+
buildNoStereoIdCodes(idCodes, result, largestFragmentOnly, 0, idCodes.length);
|
|
189
|
+
return result;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Canonizes one idcode to the form OpenChemLib identifies a molecule by up to tautomerism and
|
|
193
|
+
* stereochemistry.
|
|
194
|
+
*
|
|
195
|
+
* This is the string {@link getNoStereoTautomerHash} hashes. It is the generic tautomer's idcode, so
|
|
196
|
+
* it is longer than the molecule's own — around twice it for a molecule with tautomeric sites — and
|
|
197
|
+
* it is not a structure: parsing it back gives a molecule with every tautomeric bond normalized, not
|
|
198
|
+
* the compound. Use it as a key, never as something to draw.
|
|
199
|
+
* @param idCode - The molecule to canonize, as an idcode.
|
|
200
|
+
* @param options - See {@link HashOptions}.
|
|
201
|
+
* @returns Its canonical no-stereo generic-tautomer idcode, or `NO_ID_CODE` (`''`) for an idcode that
|
|
202
|
+
* will not parse or a molecule OpenChemLib cannot canonize.
|
|
203
|
+
*/
|
|
204
|
+
export function getNoStereoTautomerIdCode(idCode, options = {}) {
|
|
205
|
+
const { largestFragmentOnly = false, tautomerCounts, maxTautomers = DEFAULT_MAX_TAUTOMERS, } = options;
|
|
206
|
+
const result = [NO_ID_CODE];
|
|
207
|
+
buildNoStereoTautomerIdCodes([idCode], result, largestFragmentOnly, 0, 1, tautomerCounts, maxTautomers);
|
|
208
|
+
return result[0];
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Canonizes every idcode to the form OpenChemLib identifies a molecule by up to tautomerism and
|
|
212
|
+
* stereochemistry.
|
|
213
|
+
*
|
|
214
|
+
* See {@link getNoStereoTautomerIdCode} for what the form identifies, and
|
|
215
|
+
* {@link getNoStereoTautomerHashes} for what it costs — the canonization is the expensive part, not
|
|
216
|
+
* the hashing, so these cost what those do.
|
|
217
|
+
* @param idCodes - The molecules to canonize, as idcodes.
|
|
218
|
+
* @param options - See {@link HashOptions}.
|
|
219
|
+
* @returns One idcode per input, in order, with `NO_ID_CODE` (`''`) for each one that could not be
|
|
220
|
+
* canonized.
|
|
221
|
+
*/
|
|
222
|
+
export function getNoStereoTautomerIdCodes(idCodes, options = {}) {
|
|
223
|
+
const { largestFragmentOnly = false, tautomerCounts, maxTautomers = DEFAULT_MAX_TAUTOMERS, } = options;
|
|
224
|
+
const result = new Array(idCodes.length).fill(NO_ID_CODE);
|
|
225
|
+
buildNoStereoTautomerIdCodes(idCodes, result, largestFragmentOnly, 0, idCodes.length, tautomerCounts, maxTautomers);
|
|
226
|
+
return result;
|
|
227
|
+
}
|
|
152
228
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,2BAA2B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,EACpB,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAChD,OAA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EACD,CAAC,EACD,cAAc,EACd,YAAY,CACb,CAAC;IACF,OAAO,MAAM,CAAC,CAAC,CAAW,CAAC;AAC7B,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,0BAA0B,CACxC,OAAiB,EACjB,UAAuB,EAAE;IAEzB,MAAM,EACJ,mBAAmB,GAAG,KAAK,EAC3B,cAAc,EACd,YAAY,GAAG,qBAAqB,GACrC,GAAG,OAAO,CAAC;IACZ,MAAM,MAAM,GAAG,IAAI,KAAK,CAAS,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAClE,4BAA4B,CAC1B,OAAO,EACP,MAAM,EACN,mBAAmB,EACnB,CAAC,EACD,OAAO,CAAC,MAAM,EACd,cAAc,EACd,YAAY,CACb,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/lib/scan.d.ts
CHANGED
|
@@ -27,9 +27,8 @@ export declare function checkQuery(mode: SearchMode, idCodeQuery: string): void;
|
|
|
27
27
|
/**
|
|
28
28
|
* Fingerprints `idCodes[from .. to)` into `result`, sixteen words per molecule.
|
|
29
29
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* for a molecule that could not be read.
|
|
30
|
+
* A molecule that cannot be read gets sixteen zeros, which no non-empty query is a subset of, so it
|
|
31
|
+
* is never a false candidate.
|
|
33
32
|
* @param idCodes - The molecules to fingerprint.
|
|
34
33
|
* @param result - The caller's buffer, `16 * idCodes.length` words long.
|
|
35
34
|
* @param from - The first index to fingerprint.
|
|
@@ -40,17 +39,19 @@ export declare function buildIndexes(idCodes: string[], result: Int32Array, from
|
|
|
40
39
|
/**
|
|
41
40
|
* Hashes `idCodes[from .. to)` into `result`, one no-stereo tautomer hash per molecule.
|
|
42
41
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* returns for a molecule it cannot canonize, so the two failures are reported the same way.
|
|
42
|
+
* A molecule that cannot be read gets `NO_HASH`, which is also what OpenChemLib returns for one it
|
|
43
|
+
* cannot canonize, so the two failures are reported the same way.
|
|
46
44
|
* @param idCodes - The molecules to hash.
|
|
47
45
|
* @param result - The caller's buffer, `idCodes.length` entries long.
|
|
48
46
|
* @param largestFragmentOnly - Whether to strip and neutralize down to the largest fragment first.
|
|
49
47
|
* @param from - The first index to hash.
|
|
50
48
|
* @param to - One past the last index to hash.
|
|
49
|
+
* @param tautomerCounts - Filled with how many tautomers each molecule needed; an entry that reached
|
|
50
|
+
* `maxTautomers` is one OpenChemLib stopped early on.
|
|
51
|
+
* @param maxTautomers - The ceiling on that enumeration, which is what bounds the cost.
|
|
51
52
|
* @returns How many molecules were hashed.
|
|
52
53
|
*/
|
|
53
|
-
export declare function buildNoStereoTautomerHashes(idCodes: string[], result: BigInt64Array, largestFragmentOnly: boolean, from: number, to: number): number;
|
|
54
|
+
export declare function buildNoStereoTautomerHashes(idCodes: string[], result: BigInt64Array, largestFragmentOnly: boolean, from: number, to: number, tautomerCounts?: Int32Array, maxTautomers?: number): number;
|
|
54
55
|
/**
|
|
55
56
|
* Hashes `idCodes[from .. to)` into `result`, one no-stereo hash per molecule.
|
|
56
57
|
*
|
|
@@ -64,4 +65,33 @@ export declare function buildNoStereoTautomerHashes(idCodes: string[], result: B
|
|
|
64
65
|
* @returns How many molecules were hashed.
|
|
65
66
|
*/
|
|
66
67
|
export declare function buildNoStereoHashes(idCodes: string[], result: BigInt64Array, largestFragmentOnly: boolean, from: number, to: number): number;
|
|
68
|
+
/**
|
|
69
|
+
* Canonizes `idCodes[from .. to)` into `result`, one no-stereo idcode per molecule.
|
|
70
|
+
*
|
|
71
|
+
* This is the string {@link buildNoStereoHashes} hashes, for a caller that stores the canonical form
|
|
72
|
+
* rather than a 64-bit key. A molecule that cannot be read keeps the `NO_ID_CODE` the caller's array
|
|
73
|
+
* was filled with.
|
|
74
|
+
* @param idCodes - The molecules to canonize.
|
|
75
|
+
* @param result - The caller's array, `idCodes.length` entries long, filled with `NO_ID_CODE`.
|
|
76
|
+
* @param largestFragmentOnly - Whether to strip and neutralize down to the largest fragment first.
|
|
77
|
+
* @param from - The first index to canonize.
|
|
78
|
+
* @param to - One past the last index to canonize.
|
|
79
|
+
* @returns How many molecules were canonized.
|
|
80
|
+
*/
|
|
81
|
+
export declare function buildNoStereoIdCodes(idCodes: string[], result: string[], largestFragmentOnly: boolean, from: number, to: number): number;
|
|
82
|
+
/**
|
|
83
|
+
* Canonizes `idCodes[from .. to)` into `result`, one no-stereo generic-tautomer idcode per molecule.
|
|
84
|
+
*
|
|
85
|
+
* Fails the same way {@link buildNoStereoIdCodes} does.
|
|
86
|
+
* @param idCodes - The molecules to canonize.
|
|
87
|
+
* @param result - The caller's array, `idCodes.length` entries long, filled with `NO_ID_CODE`.
|
|
88
|
+
* @param largestFragmentOnly - Whether to strip and neutralize down to the largest fragment first.
|
|
89
|
+
* @param from - The first index to canonize.
|
|
90
|
+
* @param to - One past the last index to canonize.
|
|
91
|
+
* @param tautomerCounts - Filled with how many tautomers each molecule needed; an entry that reached
|
|
92
|
+
* `maxTautomers` is one OpenChemLib stopped early on.
|
|
93
|
+
* @param maxTautomers - The ceiling on that enumeration, which is what bounds the cost.
|
|
94
|
+
* @returns How many molecules were canonized.
|
|
95
|
+
*/
|
|
96
|
+
export declare function buildNoStereoTautomerIdCodes(idCodes: string[], result: string[], largestFragmentOnly: boolean, from: number, to: number, tautomerCounts?: Int32Array, maxTautomers?: number): number;
|
|
67
97
|
//# 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;
|
|
1
|
+
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../src/scan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,U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