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.
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Where a key's answer comes from: one of the 512 function bits a record stores, a bit of the FragFp
3
+ * or the screen that holds exactly the same molecules, or a substructure search run when asked.
4
+ */
5
+ export type FunctionKeyTier = 'stored' | 'existingPlane' | 'onDemand';
6
+ /** One named function key: a functional group, a ring, a substituent, a natural product class. */
7
+ export interface FunctionKey {
8
+ /** Stable identifier. */
9
+ id: string;
10
+ /** The name to show. No other key carries it as name or synonym, case aside. */
11
+ name: string;
12
+ /** The other names it answers to, each also unique across the dictionary. */
13
+ synonyms: string[];
14
+ /** A key of {@link getFunctionCategories}. */
15
+ category: string;
16
+ /** A finer group within the category. */
17
+ subcategory: string;
18
+ tier: FunctionKeyTier;
19
+ /** For a `stored` key: its bit in the function words, 0 to 511. */
20
+ plane?: number;
21
+ /** For an `existingPlane` key: the fingerprint holding its bit. */
22
+ fingerprint?: 'fragFp' | 'screen';
23
+ /** For an `existingPlane` key: its bit in that fingerprint, 0 to 511. */
24
+ bit?: number;
25
+ /** The share of the 1,034,054 PubChem molecules it was counted on that hold it. */
26
+ prevalence: number;
27
+ /** Where its definition comes from: keys of {@link getFunctionKeySources}. */
28
+ sources: string[];
29
+ /** The SMARTS it was compiled from, absent for a key given as an idcode. */
30
+ smarts?: string;
31
+ /**
32
+ * Its query fragments, as idcodes: a molecule holds the key when it holds any of them, which is
33
+ * what `substructureSearch(key.fragments, entries)` tests.
34
+ */
35
+ fragments: string[];
36
+ }
37
+ /** A source the dictionary's definitions come from, and the licence they are used under. */
38
+ export interface FunctionKeySource {
39
+ name: string;
40
+ url: string;
41
+ licence: string;
42
+ }
43
+ /** Where a key's bit sits in the 48-word record of `getMoleculeRecords`. */
44
+ export interface RecordBit {
45
+ /** The word of the record: FragFp words first, then the screen, then the function bits. */
46
+ word: number;
47
+ /** The bit within that word. */
48
+ mask: number;
49
+ }
50
+ /** What {@link searchFunctionKeys} takes. */
51
+ export interface SearchFunctionKeysOptions {
52
+ /**
53
+ * Only the keys of this tier.
54
+ * @default every tier
55
+ */
56
+ tier?: FunctionKeyTier;
57
+ /**
58
+ * Only the keys of this category.
59
+ * @default every category
60
+ */
61
+ category?: string;
62
+ /**
63
+ * The most keys to return.
64
+ * @default no limit
65
+ */
66
+ limit?: number;
67
+ }
68
+ /**
69
+ * Returns every function key: the 512 stored ones in bit order, then those equal to a FragFp or
70
+ * screen bit, then those computed on demand, by category and prevalence.
71
+ * @returns The keys. They are shared: do not modify them.
72
+ */
73
+ export declare function getFunctionKeys(): readonly FunctionKey[];
74
+ /**
75
+ * Finds a key by its id, its name or one of its synonyms, case aside.
76
+ * @param nameOrId - What to look up, such as `thioether`, `Boc` or `pyridin_2_one`.
77
+ * @returns The key, or undefined when nothing carries that name.
78
+ */
79
+ export declare function getFunctionKey(nameOrId: string): FunctionKey | undefined;
80
+ /**
81
+ * Finds the keys whose id, name or synonyms hold every word of a text, case aside: an exact name
82
+ * first, then names starting with the text, then the rest, each by prevalence.
83
+ * @param text - Words to look for, such as `aromatic amine` or `lactam`.
84
+ * @param options - Narrows the result; see {@link SearchFunctionKeysOptions}.
85
+ * @returns The matching keys, best first.
86
+ */
87
+ export declare function searchFunctionKeys(text: string, options?: SearchFunctionKeysOptions): FunctionKey[];
88
+ /**
89
+ * Returns the categories keys are grouped in, in display order.
90
+ * @returns Category id to its title, such as `carbonyl` to `Carbonyl groups`.
91
+ */
92
+ export declare function getFunctionCategories(): Readonly<Record<string, string>>;
93
+ /**
94
+ * Returns the sources the definitions come from, with their licences, for attribution.
95
+ * @returns Source id, as a key's `sources` names it, to its name, address and licence.
96
+ */
97
+ export declare function getFunctionKeySources(): Readonly<Record<string, FunctionKeySource>>;
98
+ /**
99
+ * Says where a key's answer sits in a record of `getMoleculeRecords`, so a stored record answers it
100
+ * with one mask test: `(record[word] & mask) !== 0`.
101
+ * @param key - The key.
102
+ * @returns The word and mask, or undefined for a key computed on demand, which a record does not hold.
103
+ */
104
+ export declare function getRecordBit(key: FunctionKey): RecordBit | undefined;
105
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
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,EAAE,CAAC;IACnB,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,eAAe,CAAC;IACtB,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,WAAW,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAClC,yEAAyE;IACzE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,mFAAmF;IACnF,UAAU,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,4EAA4E;IAC5E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,4FAA4F;AAC5F,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,4EAA4E;AAC5E,MAAM,WAAW,SAAS;IACxB,2FAA2F;IAC3F,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,6CAA6C;AAC7C,MAAM,WAAW,yBAAyB;IACxC;;;OAGG;IACH,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAKD;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,SAAS,WAAW,EAAE,CAExD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAYxE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,yBAA8B,GACtC,WAAW,EAAE,CAwBf;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAExE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,QAAQ,CAC/C,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAClC,CAEA;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,WAAW,GAAG,SAAS,GAAG,SAAS,CAapE"}
@@ -0,0 +1,98 @@
1
+ import { INDEX_WORDS } from "../types.js";
2
+ import dictionary from './dictionary.json' with { type: 'json' };
3
+ const KEYS = dictionary.keys;
4
+ let byName;
5
+ /**
6
+ * Returns every function key: the 512 stored ones in bit order, then those equal to a FragFp or
7
+ * screen bit, then those computed on demand, by category and prevalence.
8
+ * @returns The keys. They are shared: do not modify them.
9
+ */
10
+ export function getFunctionKeys() {
11
+ return KEYS;
12
+ }
13
+ /**
14
+ * Finds a key by its id, its name or one of its synonyms, case aside.
15
+ * @param nameOrId - What to look up, such as `thioether`, `Boc` or `pyridin_2_one`.
16
+ * @returns The key, or undefined when nothing carries that name.
17
+ */
18
+ export function getFunctionKey(nameOrId) {
19
+ if (!byName) {
20
+ byName = new Map();
21
+ for (const key of KEYS) {
22
+ for (const name of [key.id, key.name, ...key.synonyms]) {
23
+ if (!byName.has(name.toLowerCase())) {
24
+ byName.set(name.toLowerCase(), key);
25
+ }
26
+ }
27
+ }
28
+ }
29
+ return byName.get(nameOrId.trim().toLowerCase());
30
+ }
31
+ /**
32
+ * Finds the keys whose id, name or synonyms hold every word of a text, case aside: an exact name
33
+ * first, then names starting with the text, then the rest, each by prevalence.
34
+ * @param text - Words to look for, such as `aromatic amine` or `lactam`.
35
+ * @param options - Narrows the result; see {@link SearchFunctionKeysOptions}.
36
+ * @returns The matching keys, best first.
37
+ */
38
+ export function searchFunctionKeys(text, options = {}) {
39
+ const { tier, category, limit = Number.POSITIVE_INFINITY } = options;
40
+ const wanted = text.trim().toLowerCase();
41
+ const words = wanted.split(/\s+/).filter(Boolean);
42
+ const scored = [];
43
+ for (const key of KEYS) {
44
+ if ((tier && key.tier !== tier) ||
45
+ (category && key.category !== category)) {
46
+ continue;
47
+ }
48
+ const names = [key.name, ...key.synonyms].map((name) => name.toLowerCase());
49
+ const haystack = `${key.id.toLowerCase()}\n${names.join('\n')}`;
50
+ if (!words.every((word) => haystack.includes(word)))
51
+ continue;
52
+ const rank = names.includes(wanted)
53
+ ? 0
54
+ : names.some((name) => name.startsWith(wanted))
55
+ ? 1
56
+ : 2;
57
+ scored.push({ key, rank });
58
+ }
59
+ scored.sort((a, b) => a.rank - b.rank || b.key.prevalence - a.key.prevalence);
60
+ return scored.slice(0, limit).map(({ key }) => key);
61
+ }
62
+ /**
63
+ * Returns the categories keys are grouped in, in display order.
64
+ * @returns Category id to its title, such as `carbonyl` to `Carbonyl groups`.
65
+ */
66
+ export function getFunctionCategories() {
67
+ return dictionary.categories;
68
+ }
69
+ /**
70
+ * Returns the sources the definitions come from, with their licences, for attribution.
71
+ * @returns Source id, as a key's `sources` names it, to its name, address and licence.
72
+ */
73
+ export function getFunctionKeySources() {
74
+ return dictionary.sources;
75
+ }
76
+ /**
77
+ * Says where a key's answer sits in a record of `getMoleculeRecords`, so a stored record answers it
78
+ * with one mask test: `(record[word] & mask) !== 0`.
79
+ * @param key - The key.
80
+ * @returns The word and mask, or undefined for a key computed on demand, which a record does not hold.
81
+ */
82
+ export function getRecordBit(key) {
83
+ let base;
84
+ let bit;
85
+ if (key.tier === 'stored' && key.plane !== undefined) {
86
+ base = 2 * INDEX_WORDS;
87
+ bit = key.plane;
88
+ }
89
+ else if (key.tier === 'existingPlane' && key.bit !== undefined) {
90
+ base = key.fingerprint === 'screen' ? INDEX_WORDS : 0;
91
+ bit = key.bit;
92
+ }
93
+ else {
94
+ return undefined;
95
+ }
96
+ return { word: base + (bit >> 5), mask: 1 << (31 - (bit & 31)) };
97
+ }
98
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/functionKeys/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,UAAU,MAAM,mBAAmB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AA0EjE,MAAM,IAAI,GAAG,UAAU,CAAC,IAAqB,CAAC;AAC9C,IAAI,MAA4C,CAAC;AAEjD;;;;GAIG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC7C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACnB,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,KAAK,MAAM,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACvD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,EAAE,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AG,KAAK,SAAS,EAAE,CAAC;QACjE,IAAI,GAAG,GAAG,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;QACtD,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC;IAChB,CAAC;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"}
@@ -0,0 +1,38 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,54 @@
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
@@ -0,0 +1 @@
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/index.d.ts CHANGED
@@ -4,9 +4,11 @@ export { setLogHandler } from './wasm/log.ts';
4
4
  export { hashToHex, hexToHash } from './hex.ts';
5
5
  export { strongHash } from './strongHash.ts';
6
6
  export { similaritySearch } from './similaritySearch.ts';
7
- export { DEFAULT_MAX_TAUTOMERS, INDEX_WORDS, NO_HASH, NO_ID_CODE, } from './types.ts';
7
+ export { getMoleculeRecords, getMoleculeSizes, getQueryAtomFloor, } from './records.ts';
8
+ export { getFunction, getFunctionKeyFragments, getFunctions, } from './functions.ts';
9
+ export { DEFAULT_MAX_TAUTOMERS, INDEX_WORDS, NO_HASH, NO_ID_CODE, RECORD_WORDS, } from './types.ts';
8
10
  export type { LogHandler, LogStream } from './wasm/log.ts';
9
- export type { HashOptions, ResultBuffer, SearchMode, SearchOptions, SearchResult, SearchStep, SimilaritySearchOptions, SimilaritySearchResult, SubstructureSearchOptions, SubstructureSearchResult, TautomerHashOptions, } from './types.ts';
11
+ export type { HashOptions, MoleculeRecords, MoleculeRecordsOptions, MoleculeSizes, ResultBuffer, SearchMode, SearchOptions, SearchResult, SearchStep, SimilaritySearchOptions, SimilaritySearchResult, SubstructureSearchOptions, SubstructureSearchResult, TautomerHashOptions, } from './types.ts';
10
12
  export { SimilarityResult, SubstructureResult } from './types.ts';
11
13
  /**
12
14
  * Builds the 512-bit FragFp fingerprint of one idcode, as sixteen 32-bit words.
@@ -44,6 +46,85 @@ export declare function getIndex(idCode: string): Int32Array;
44
46
  * @returns One sixteen-word view per idcode, in order.
45
47
  */
46
48
  export declare function getIndexes(idCodes: string[]): Int32Array[];
49
+ /**
50
+ * Builds the 512-bit screen of one idcode, as sixteen 32-bit words: bit i is set when key i of the
51
+ * screen dictionary is a substructure of the molecule.
52
+ *
53
+ * The screen sits next to the FragFp fingerprint of {@link getIndex}. A molecule is a candidate for
54
+ * a query only if it holds every bit of {@link getQueryIndex} in its fingerprint and every bit of
55
+ * {@link getQueryScreen} in its screen; requiring both lets through about a sixth of the
56
+ * non-matching molecules FragFp alone lets through. The dictionary is 512 OpenChemLib query
57
+ * fragments, matched the way FragFp matches its own keys, and a screen costs about 0.7 times a
58
+ * fingerprint.
59
+ *
60
+ * ```js
61
+ * const isCandidate = (query, molecule) =>
62
+ * query.every((word, i) => (word & molecule[i]) === word);
63
+ * isCandidate(getQueryScreen(query), getScreen(idCode));
64
+ * ```
65
+ * @param idCode - The molecule to screen, as an idcode.
66
+ * @returns Sixteen words. An idcode that will not parse gives sixteen zeros, which no non-empty
67
+ * query screen is a subset of.
68
+ */
69
+ export declare function getScreen(idCode: string): Int32Array;
70
+ /**
71
+ * Builds the 512-bit screen of every idcode, sixteen 32-bit words each.
72
+ *
73
+ * See {@link getScreen}. The screens are written into one buffer and returned as a view per
74
+ * molecule, each 8-byte aligned, as {@link getIndexes} does.
75
+ * @param idCodes - The molecules to screen, as idcodes.
76
+ * @returns One sixteen-word view per idcode, in order.
77
+ */
78
+ export declare function getScreens(idCodes: string[]): Int32Array[];
79
+ /**
80
+ * Builds the screen of a query: the bits every molecule the query matches has in its
81
+ * {@link getScreen} screen.
82
+ *
83
+ * The query is screened on the fragment OpenChemLib's substructure search actually matches, so an
84
+ * exclude group cutting an aromatic ring and the atom ring sizes of the query are taken into account
85
+ * as the search takes them; a query with a "match formal bond order" bond gets no bits.
86
+ * @param idCodeQuery - The query, as an idcode; read as a fragment whatever its own fragment flag.
87
+ * @returns Sixteen words.
88
+ * @throws {Error} If the query cannot be parsed.
89
+ */
90
+ export declare function getQueryScreen(idCodeQuery: string): Int32Array;
91
+ /**
92
+ * Builds the FragFp fingerprint of a query: the bits every molecule the query matches has in its
93
+ * {@link getIndex} fingerprint.
94
+ *
95
+ * It equals OpenChemLib's own query fingerprint, except for the queries that one wrongly rejects
96
+ * true matches of: an exclude group cutting an aromatic ring, or a "match formal bond order" bond
97
+ * (Actelion/openchemlib#177). The first is fingerprinted on the fragment the search matches; the
98
+ * second gets no bits.
99
+ * @param idCodeQuery - The query, as an idcode; read as a fragment whatever its own fragment flag.
100
+ * @returns Sixteen words.
101
+ * @throws {Error} If the query cannot be parsed.
102
+ */
103
+ export declare function getQueryIndex(idCodeQuery: string): Int32Array;
104
+ /**
105
+ * Returns the 512 key fragments of FragFp, in bit order: bit i of {@link getIndex} is set when key i
106
+ * is a substructure of the molecule. They are OpenChemLib's own keys, the list `openchemlib`'s
107
+ * `SSSearcherWithIndex.getKeyIDCode()` returns.
108
+ *
109
+ * Bit i sits in word `i >> 5`, the first key in the highest bit of word 0:
110
+ *
111
+ * ```js
112
+ * const keys = getFragFpKeys();
113
+ * const index = getIndex(idCode);
114
+ * const held = keys.filter((key, i) => index[i >> 5] & (1 << (31 - (i & 31))));
115
+ * ```
116
+ * @returns 512 idcodes, each a query fragment, in bit order. The array is the caller's own.
117
+ */
118
+ export declare function getFragFpKeys(): string[];
119
+ /**
120
+ * Returns the 512 key fragments of the screen, in bit order: bit i of {@link getScreen} is set when
121
+ * key i is a substructure of the molecule. The words are laid out as {@link getFragFpKeys} shows.
122
+ *
123
+ * The list is frozen: changing, adding or reordering a key changes every stored screen, so it only
124
+ * changes in a major release.
125
+ * @returns 512 idcodes, each a query fragment, in bit order. The array is the caller's own.
126
+ */
127
+ export declare function getScreenKeys(): string[];
47
128
  /**
48
129
  * Hashes one idcode to the 64-bit value OpenChemLib identifies a molecule by up to tautomerism and
49
130
  * stereochemistry.
@@ -1 +1 @@
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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AAO,GAAE,WAAgB,GACxB,MAAM,EAAE,CAiBV"}
package/lib/index.js CHANGED
@@ -1,11 +1,13 @@
1
- import { buildIndexes, buildNoStereoHashes, buildNoStereoIdCodes, buildNoStereoTautomerHashes, buildNoStereoTautomerIdCodes, } from "./scan.js";
1
+ import { buildIndexes, buildNoStereoHashes, buildNoStereoIdCodes, buildNoStereoTautomerHashes, buildNoStereoTautomerIdCodes, buildQueryWords, buildScreens, readKeys, } from "./scan.js";
2
2
  import { DEFAULT_MAX_TAUTOMERS, INDEX_WORDS, NO_ID_CODE } from "./types.js";
3
3
  export { substructureSearch } from "./substructureSearch.js";
4
4
  export { setLogHandler } from "./wasm/log.js";
5
5
  export { hashToHex, hexToHash } from "./hex.js";
6
6
  export { strongHash } from "./strongHash.js";
7
7
  export { similaritySearch } from "./similaritySearch.js";
8
- export { DEFAULT_MAX_TAUTOMERS, INDEX_WORDS, NO_HASH, NO_ID_CODE, } from "./types.js";
8
+ export { getMoleculeRecords, getMoleculeSizes, getQueryAtomFloor, } from "./records.js";
9
+ export { getFunction, getFunctionKeyFragments, getFunctions, } from "./functions.js";
10
+ export { DEFAULT_MAX_TAUTOMERS, INDEX_WORDS, NO_HASH, NO_ID_CODE, RECORD_WORDS, } from "./types.js";
9
11
  export { SimilarityResult, SubstructureResult } from "./types.js";
10
12
  /**
11
13
  * Builds the 512-bit FragFp fingerprint of one idcode, as sixteen 32-bit words.
@@ -55,6 +57,105 @@ export function getIndexes(idCodes) {
55
57
  }
56
58
  return indexes;
57
59
  }
60
+ /**
61
+ * Builds the 512-bit screen of one idcode, as sixteen 32-bit words: bit i is set when key i of the
62
+ * screen dictionary is a substructure of the molecule.
63
+ *
64
+ * The screen sits next to the FragFp fingerprint of {@link getIndex}. A molecule is a candidate for
65
+ * a query only if it holds every bit of {@link getQueryIndex} in its fingerprint and every bit of
66
+ * {@link getQueryScreen} in its screen; requiring both lets through about a sixth of the
67
+ * non-matching molecules FragFp alone lets through. The dictionary is 512 OpenChemLib query
68
+ * fragments, matched the way FragFp matches its own keys, and a screen costs about 0.7 times a
69
+ * fingerprint.
70
+ *
71
+ * ```js
72
+ * const isCandidate = (query, molecule) =>
73
+ * query.every((word, i) => (word & molecule[i]) === word);
74
+ * isCandidate(getQueryScreen(query), getScreen(idCode));
75
+ * ```
76
+ * @param idCode - The molecule to screen, as an idcode.
77
+ * @returns Sixteen words. An idcode that will not parse gives sixteen zeros, which no non-empty
78
+ * query screen is a subset of.
79
+ */
80
+ export function getScreen(idCode) {
81
+ const result = new Int32Array(INDEX_WORDS);
82
+ buildScreens([idCode], result, 0, 1);
83
+ return result;
84
+ }
85
+ /**
86
+ * Builds the 512-bit screen of every idcode, sixteen 32-bit words each.
87
+ *
88
+ * See {@link getScreen}. The screens are written into one buffer and returned as a view per
89
+ * molecule, each 8-byte aligned, as {@link getIndexes} does.
90
+ * @param idCodes - The molecules to screen, as idcodes.
91
+ * @returns One sixteen-word view per idcode, in order.
92
+ */
93
+ export function getScreens(idCodes) {
94
+ const all = new Int32Array(idCodes.length * INDEX_WORDS);
95
+ buildScreens(idCodes, all, 0, idCodes.length);
96
+ const screens = new Array(idCodes.length);
97
+ for (let i = 0; i < idCodes.length; i++) {
98
+ screens[i] = all.subarray(i * INDEX_WORDS, (i + 1) * INDEX_WORDS);
99
+ }
100
+ return screens;
101
+ }
102
+ /**
103
+ * Builds the screen of a query: the bits every molecule the query matches has in its
104
+ * {@link getScreen} screen.
105
+ *
106
+ * The query is screened on the fragment OpenChemLib's substructure search actually matches, so an
107
+ * exclude group cutting an aromatic ring and the atom ring sizes of the query are taken into account
108
+ * as the search takes them; a query with a "match formal bond order" bond gets no bits.
109
+ * @param idCodeQuery - The query, as an idcode; read as a fragment whatever its own fragment flag.
110
+ * @returns Sixteen words.
111
+ * @throws {Error} If the query cannot be parsed.
112
+ */
113
+ export function getQueryScreen(idCodeQuery) {
114
+ return buildQueryWords('screen', idCodeQuery);
115
+ }
116
+ /**
117
+ * Builds the FragFp fingerprint of a query: the bits every molecule the query matches has in its
118
+ * {@link getIndex} fingerprint.
119
+ *
120
+ * It equals OpenChemLib's own query fingerprint, except for the queries that one wrongly rejects
121
+ * true matches of: an exclude group cutting an aromatic ring, or a "match formal bond order" bond
122
+ * (Actelion/openchemlib#177). The first is fingerprinted on the fragment the search matches; the
123
+ * second gets no bits.
124
+ * @param idCodeQuery - The query, as an idcode; read as a fragment whatever its own fragment flag.
125
+ * @returns Sixteen words.
126
+ * @throws {Error} If the query cannot be parsed.
127
+ */
128
+ export function getQueryIndex(idCodeQuery) {
129
+ return buildQueryWords('index', idCodeQuery);
130
+ }
131
+ /**
132
+ * Returns the 512 key fragments of FragFp, in bit order: bit i of {@link getIndex} is set when key i
133
+ * is a substructure of the molecule. They are OpenChemLib's own keys, the list `openchemlib`'s
134
+ * `SSSearcherWithIndex.getKeyIDCode()` returns.
135
+ *
136
+ * Bit i sits in word `i >> 5`, the first key in the highest bit of word 0:
137
+ *
138
+ * ```js
139
+ * const keys = getFragFpKeys();
140
+ * const index = getIndex(idCode);
141
+ * const held = keys.filter((key, i) => index[i >> 5] & (1 << (31 - (i & 31))));
142
+ * ```
143
+ * @returns 512 idcodes, each a query fragment, in bit order. The array is the caller's own.
144
+ */
145
+ export function getFragFpKeys() {
146
+ return readKeys('index');
147
+ }
148
+ /**
149
+ * Returns the 512 key fragments of the screen, in bit order: bit i of {@link getScreen} is set when
150
+ * key i is a substructure of the molecule. The words are laid out as {@link getFragFpKeys} shows.
151
+ *
152
+ * The list is frozen: changing, adding or reordering a key changes every stored screen, so it only
153
+ * changes in a major release.
154
+ * @returns 512 idcodes, each a query fragment, in bit order. The array is the caller's own.
155
+ */
156
+ export function getScreenKeys() {
157
+ return readKeys('screen');
158
+ }
58
159
  /**
59
160
  * Hashes one idcode to the 64-bit value OpenChemLib identifies a molecule by up to tautomerism and
60
161
  * stereochemistry.
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],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M,CAAC,CAAC;IAC9E,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,yBAAyB,CACvC,MAAc,EACd,UAAuB,EAAE;IAEzB,MAAM,EACJ,mBAAmB,GAAG,KAAK,EAC3B,cAAc,EACd,YAAY,GAAG,qBAAqB,GACrC,GAAG,OAAO,CAAC;IACZ,MAAM,MAAM,GAAG,CAAC,UAAU,CAAC,CAAC;IAC5B,4BAA4B,CAC1B,CAAC,MAAM,CAAC,EACR,MAAM,EACN,mBAAmB,EACnB,CAAC,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"}
@@ -0,0 +1,45 @@
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
@@ -0,0 +1 @@
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"}