@kent-tokyo/chematic 0.8.1 → 0.10.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 +41 -0
- package/chematic_wasm.d.ts +21 -0
- package/chematic_wasm.js +70 -0
- package/chematic_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,6 +30,10 @@ npm install @kent-tokyo/chematic
|
|
|
30
30
|
- SVG grid layout for multiple molecules
|
|
31
31
|
- Reaction SMILES/SMIRKS parsing and transform
|
|
32
32
|
- Add/remove explicit hydrogens
|
|
33
|
+
- `embed_pipeline_v2_json`: torsion-knowledge-aware 3D embedding + stereo
|
|
34
|
+
verification/repair + policy-gated force field, mirroring the Python
|
|
35
|
+
`Mol.embed_pipeline_v2()` binding — opt-in, not a default 3D API
|
|
36
|
+
([usage](#3d-embedding-embed_pipeline_v2_json))
|
|
33
37
|
|
|
34
38
|
## Usage
|
|
35
39
|
|
|
@@ -96,6 +100,43 @@ const ifg = JSON.parse(identify_functional_groups(mol));
|
|
|
96
100
|
console.log(ifg); // [{"atoms":[1,2,3],"types":"OC=O"}, ...]
|
|
97
101
|
```
|
|
98
102
|
|
|
103
|
+
### 3D embedding (`embed_pipeline_v2_json`)
|
|
104
|
+
|
|
105
|
+
Opt-in — does not change behavior of any existing 3D API (`generate_coords`,
|
|
106
|
+
`generate_and_minimize_*`, etc.), which remain the defaults.
|
|
107
|
+
|
|
108
|
+
```js
|
|
109
|
+
const response = JSON.parse(embed_pipeline_v2_json(mol, JSON.stringify({
|
|
110
|
+
embedSeed: 7,
|
|
111
|
+
maxAttempts: 8,
|
|
112
|
+
embedTimeoutMs: null,
|
|
113
|
+
useExpTorsions: false,
|
|
114
|
+
useSmallRingTorsions: false,
|
|
115
|
+
useMacrocycleTorsions: false,
|
|
116
|
+
useMacrocycle14Bounds: false,
|
|
117
|
+
includeLegacyTorsionHeuristic: false,
|
|
118
|
+
stereoPolicy: "ignore",
|
|
119
|
+
failOnUnevaluableStereo: false,
|
|
120
|
+
forceFieldPolicy: "none",
|
|
121
|
+
forceFieldMaxIterations: 200,
|
|
122
|
+
gateMmff94TorsionOop: false,
|
|
123
|
+
ringTorsionPolicy: "fail_closed",
|
|
124
|
+
totalTimeoutMs: null,
|
|
125
|
+
})));
|
|
126
|
+
// response.ok, response.result / response.error — same shape as
|
|
127
|
+
// Mol.embed_pipeline_v2() in the Python binding.
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Verified working end-to-end under real WASM (both `wasm-pack --target nodejs`
|
|
131
|
+
and `--target web`, the latter being what this package's npm build actually
|
|
132
|
+
uses) — success, typed-failure, and typed-timeout paths all return real
|
|
133
|
+
results. `embedTimeoutMs`/`totalTimeoutMs` use a monotonic clock that's
|
|
134
|
+
portable across native and `wasm32-unknown-unknown`
|
|
135
|
+
([`web-time`](https://crates.io/crates/web-time), backed by
|
|
136
|
+
`Performance.now()` in the browser); this does not claim identical wall-clock
|
|
137
|
+
precision across every JS engine, only that the value is finite, non-negative,
|
|
138
|
+
and enforced correctly on all of them.
|
|
139
|
+
|
|
99
140
|
## Version History
|
|
100
141
|
|
|
101
142
|
**v0.1.94** (2026-06-12):
|
package/chematic_wasm.d.ts
CHANGED
|
@@ -790,6 +790,25 @@ export function ecfp6_bitvec_with_chirality(mol: MolHandle, use_chirality: boole
|
|
|
790
790
|
*/
|
|
791
791
|
export function ecfp_bitvec_custom(mol: MolHandle, radius: number, nbits: number, use_chirality: boolean): Uint8Array;
|
|
792
792
|
|
|
793
|
+
/**
|
|
794
|
+
* Run the opt-in v2 embedding pipeline, applied directly to `mol`'s own atom
|
|
795
|
+
* order (never canonicalizes/reparses -- see the module doc).
|
|
796
|
+
*
|
|
797
|
+
* `config_json` must be an object with exactly the 15 fields `PipelineV2Config`
|
|
798
|
+
* requires (camelCase keys: `embedSeed`, `maxAttempts`, `embedTimeoutMs`,
|
|
799
|
+
* `useExpTorsions`, `useSmallRingTorsions`, `useMacrocycleTorsions`,
|
|
800
|
+
* `useMacrocycle14Bounds`, `includeLegacyTorsionHeuristic`, `stereoPolicy`,
|
|
801
|
+
* `failOnUnevaluableStereo`, `forceFieldPolicy`, `forceFieldMaxIterations`,
|
|
802
|
+
* `gateMmff94TorsionOop`, `ringTorsionPolicy`, `totalTimeoutMs`) -- an unknown
|
|
803
|
+
* field, a missing field, an unknown `stereoPolicy`/`ringTorsionPolicy`/
|
|
804
|
+
* `forceFieldPolicy` string, or a wrong-typed/out-of-range integer all fail
|
|
805
|
+
* closed rather than silently defaulting.
|
|
806
|
+
*
|
|
807
|
+
* Never throws. Always returns a JSON string tagged with `schemaVersion: 1` and
|
|
808
|
+
* `ok: true`/`false` -- see the module doc for both shapes.
|
|
809
|
+
*/
|
|
810
|
+
export function embed_pipeline_v2_json(mol: MolHandle, config_json: string): string;
|
|
811
|
+
|
|
793
812
|
/**
|
|
794
813
|
* Enumerate a combinatorial library from a SMIRKS template and two fragment sets.
|
|
795
814
|
*
|
|
@@ -2073,6 +2092,7 @@ export interface InitOutput {
|
|
|
2073
2092
|
readonly ecfp6_bitvec: (a: number) => [number, number];
|
|
2074
2093
|
readonly ecfp6_bitvec_with_chirality: (a: number, b: number) => [number, number];
|
|
2075
2094
|
readonly ecfp_bitvec_custom: (a: number, b: number, c: number, d: number) => [number, number];
|
|
2095
|
+
readonly embed_pipeline_v2_json: (a: number, b: number, c: number) => [number, number];
|
|
2076
2096
|
readonly enumerate_library_2way: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
2077
2097
|
readonly enumerate_stereo_isomers_json: (a: number) => [number, number, number, number];
|
|
2078
2098
|
readonly enumerate_tautomers_json: (a: number) => [number, number];
|
|
@@ -2292,6 +2312,7 @@ export interface InitOutput {
|
|
|
2292
2312
|
readonly start: () => void;
|
|
2293
2313
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
2294
2314
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
2315
|
+
readonly __externref_table_alloc: () => number;
|
|
2295
2316
|
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
2296
2317
|
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
2297
2318
|
readonly __externref_table_dealloc: (a: number) => void;
|
package/chematic_wasm.js
CHANGED
|
@@ -1886,6 +1886,42 @@ export function ecfp_bitvec_custom(mol, radius, nbits, use_chirality) {
|
|
|
1886
1886
|
return v1;
|
|
1887
1887
|
}
|
|
1888
1888
|
|
|
1889
|
+
/**
|
|
1890
|
+
* Run the opt-in v2 embedding pipeline, applied directly to `mol`'s own atom
|
|
1891
|
+
* order (never canonicalizes/reparses -- see the module doc).
|
|
1892
|
+
*
|
|
1893
|
+
* `config_json` must be an object with exactly the 15 fields `PipelineV2Config`
|
|
1894
|
+
* requires (camelCase keys: `embedSeed`, `maxAttempts`, `embedTimeoutMs`,
|
|
1895
|
+
* `useExpTorsions`, `useSmallRingTorsions`, `useMacrocycleTorsions`,
|
|
1896
|
+
* `useMacrocycle14Bounds`, `includeLegacyTorsionHeuristic`, `stereoPolicy`,
|
|
1897
|
+
* `failOnUnevaluableStereo`, `forceFieldPolicy`, `forceFieldMaxIterations`,
|
|
1898
|
+
* `gateMmff94TorsionOop`, `ringTorsionPolicy`, `totalTimeoutMs`) -- an unknown
|
|
1899
|
+
* field, a missing field, an unknown `stereoPolicy`/`ringTorsionPolicy`/
|
|
1900
|
+
* `forceFieldPolicy` string, or a wrong-typed/out-of-range integer all fail
|
|
1901
|
+
* closed rather than silently defaulting.
|
|
1902
|
+
*
|
|
1903
|
+
* Never throws. Always returns a JSON string tagged with `schemaVersion: 1` and
|
|
1904
|
+
* `ok: true`/`false` -- see the module doc for both shapes.
|
|
1905
|
+
* @param {MolHandle} mol
|
|
1906
|
+
* @param {string} config_json
|
|
1907
|
+
* @returns {string}
|
|
1908
|
+
*/
|
|
1909
|
+
export function embed_pipeline_v2_json(mol, config_json) {
|
|
1910
|
+
let deferred2_0;
|
|
1911
|
+
let deferred2_1;
|
|
1912
|
+
try {
|
|
1913
|
+
_assertClass(mol, MolHandle);
|
|
1914
|
+
const ptr0 = passStringToWasm0(config_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1915
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1916
|
+
const ret = wasm.embed_pipeline_v2_json(mol.__wbg_ptr, ptr0, len0);
|
|
1917
|
+
deferred2_0 = ret[0];
|
|
1918
|
+
deferred2_1 = ret[1];
|
|
1919
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1920
|
+
} finally {
|
|
1921
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1889
1925
|
/**
|
|
1890
1926
|
* Enumerate a combinatorial library from a SMIRKS template and two fragment sets.
|
|
1891
1927
|
*
|
|
@@ -5158,6 +5194,10 @@ export function xlogp3_per_atom_json(mol) {
|
|
|
5158
5194
|
function __wbg_get_imports() {
|
|
5159
5195
|
const import0 = {
|
|
5160
5196
|
__proto__: null,
|
|
5197
|
+
__wbg___wbindgen_is_undefined_c05833b95a3cf397: function(arg0) {
|
|
5198
|
+
const ret = arg0 === undefined;
|
|
5199
|
+
return ret;
|
|
5200
|
+
},
|
|
5161
5201
|
__wbg___wbindgen_string_get_b0ca35b86a603356: function(arg0, arg1) {
|
|
5162
5202
|
const obj = arg1;
|
|
5163
5203
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
@@ -5172,6 +5212,30 @@ function __wbg_get_imports() {
|
|
|
5172
5212
|
__wbg_error_744744ff0c9861e6: function(arg0) {
|
|
5173
5213
|
console.error(arg0);
|
|
5174
5214
|
},
|
|
5215
|
+
__wbg_now_e7c6795a7f81e10f: function(arg0) {
|
|
5216
|
+
const ret = arg0.now();
|
|
5217
|
+
return ret;
|
|
5218
|
+
},
|
|
5219
|
+
__wbg_performance_3fcf6e32a7e1ed0a: function(arg0) {
|
|
5220
|
+
const ret = arg0.performance;
|
|
5221
|
+
return ret;
|
|
5222
|
+
},
|
|
5223
|
+
__wbg_static_accessor_GLOBAL_4ef717fb391d88b7: function() {
|
|
5224
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
5225
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
5226
|
+
},
|
|
5227
|
+
__wbg_static_accessor_GLOBAL_THIS_8d1badc68b5a74f4: function() {
|
|
5228
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
5229
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
5230
|
+
},
|
|
5231
|
+
__wbg_static_accessor_SELF_146583524fe1469b: function() {
|
|
5232
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
5233
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
5234
|
+
},
|
|
5235
|
+
__wbg_static_accessor_WINDOW_f2829a2234d7819e: function() {
|
|
5236
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
5237
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
5238
|
+
},
|
|
5175
5239
|
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
5176
5240
|
// Cast intrinsic for `F64 -> Externref`.
|
|
5177
5241
|
const ret = arg0;
|
|
@@ -5211,6 +5275,12 @@ const MolHandleFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
5211
5275
|
? { register: () => {}, unregister: () => {} }
|
|
5212
5276
|
: new FinalizationRegistry(ptr => wasm.__wbg_molhandle_free(ptr, 1));
|
|
5213
5277
|
|
|
5278
|
+
function addToExternrefTable0(obj) {
|
|
5279
|
+
const idx = wasm.__externref_table_alloc();
|
|
5280
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
5281
|
+
return idx;
|
|
5282
|
+
}
|
|
5283
|
+
|
|
5214
5284
|
function _assertClass(instance, klass) {
|
|
5215
5285
|
if (!(instance instanceof klass)) {
|
|
5216
5286
|
throw new Error(`expected instance of ${klass.name}`);
|
package/chematic_wasm_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"kent-tokyo <kent-tokyo@users.noreply.github.com>"
|
|
6
6
|
],
|
|
7
7
|
"description": "WebAssembly bindings for chematic — use chematic from JavaScript/TypeScript",
|
|
8
|
-
"version": "0.
|
|
8
|
+
"version": "0.10.0",
|
|
9
9
|
"license": "MIT OR Apache-2.0",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|