@kent-tokyo/chematic 0.1.4 → 0.1.9
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 +47 -19
- package/chematic_wasm.d.ts +311 -0
- package/chematic_wasm.js +983 -8
- package/chematic_wasm_bg.wasm +0 -0
- package/package.json +1 -3
- package/chematic_wasm_bg.js +0 -370
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.1.
|
|
8
|
+
"version": "0.1.9",
|
|
9
9
|
"license": "MIT OR Apache-2.0",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -14,14 +14,12 @@
|
|
|
14
14
|
"files": [
|
|
15
15
|
"chematic_wasm_bg.wasm",
|
|
16
16
|
"chematic_wasm.js",
|
|
17
|
-
"chematic_wasm_bg.js",
|
|
18
17
|
"chematic_wasm.d.ts"
|
|
19
18
|
],
|
|
20
19
|
"main": "chematic_wasm.js",
|
|
21
20
|
"homepage": "https://github.com/kent-tokyo/chematic",
|
|
22
21
|
"types": "chematic_wasm.d.ts",
|
|
23
22
|
"sideEffects": [
|
|
24
|
-
"./chematic_wasm.js",
|
|
25
23
|
"./snippets/*"
|
|
26
24
|
],
|
|
27
25
|
"keywords": [
|
package/chematic_wasm_bg.js
DELETED
|
@@ -1,370 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A handle to a parsed molecule. Owns the molecule behind an `Rc` so that
|
|
3
|
-
* it can be cheaply cloned on the JS side without copying atom/bond data.
|
|
4
|
-
*/
|
|
5
|
-
export class MolHandle {
|
|
6
|
-
static __wrap(ptr) {
|
|
7
|
-
const obj = Object.create(MolHandle.prototype);
|
|
8
|
-
obj.__wbg_ptr = ptr;
|
|
9
|
-
MolHandleFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
10
|
-
return obj;
|
|
11
|
-
}
|
|
12
|
-
__destroy_into_raw() {
|
|
13
|
-
const ptr = this.__wbg_ptr;
|
|
14
|
-
this.__wbg_ptr = 0;
|
|
15
|
-
MolHandleFinalization.unregister(this);
|
|
16
|
-
return ptr;
|
|
17
|
-
}
|
|
18
|
-
free() {
|
|
19
|
-
const ptr = this.__destroy_into_raw();
|
|
20
|
-
wasm.__wbg_molhandle_free(ptr, 0);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Number of aromatic rings (all ring atoms aromatic).
|
|
24
|
-
* @returns {number}
|
|
25
|
-
*/
|
|
26
|
-
aromatic_ring_count() {
|
|
27
|
-
const ret = wasm.molhandle_aromatic_ring_count(this.__wbg_ptr);
|
|
28
|
-
return ret >>> 0;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Number of heavy atoms (explicit atoms in the graph; does not count implicit H).
|
|
32
|
-
* @returns {number}
|
|
33
|
-
*/
|
|
34
|
-
atom_count() {
|
|
35
|
-
const ret = wasm.molhandle_atom_count(this.__wbg_ptr);
|
|
36
|
-
return ret >>> 0;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Number of bonds.
|
|
40
|
-
* @returns {number}
|
|
41
|
-
*/
|
|
42
|
-
bond_count() {
|
|
43
|
-
const ret = wasm.molhandle_bond_count(this.__wbg_ptr);
|
|
44
|
-
return ret >>> 0;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Canonical SMILES string.
|
|
48
|
-
* @returns {string}
|
|
49
|
-
*/
|
|
50
|
-
canonical_smiles() {
|
|
51
|
-
let deferred1_0;
|
|
52
|
-
let deferred1_1;
|
|
53
|
-
try {
|
|
54
|
-
const ret = wasm.molhandle_canonical_smiles(this.__wbg_ptr);
|
|
55
|
-
deferred1_0 = ret[0];
|
|
56
|
-
deferred1_1 = ret[1];
|
|
57
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
58
|
-
} finally {
|
|
59
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Monoisotopic (exact) mass.
|
|
64
|
-
* @returns {number}
|
|
65
|
-
*/
|
|
66
|
-
exact_mass() {
|
|
67
|
-
const ret = wasm.molhandle_exact_mass(this.__wbg_ptr);
|
|
68
|
-
return ret;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Molecular formula string (Hill notation: C first, H second, then alphabetical).
|
|
72
|
-
* @returns {string}
|
|
73
|
-
*/
|
|
74
|
-
formula() {
|
|
75
|
-
let deferred1_0;
|
|
76
|
-
let deferred1_1;
|
|
77
|
-
try {
|
|
78
|
-
const ret = wasm.molhandle_formula(this.__wbg_ptr);
|
|
79
|
-
deferred1_0 = ret[0];
|
|
80
|
-
deferred1_1 = ret[1];
|
|
81
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
82
|
-
} finally {
|
|
83
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Fraction of sp3 carbons (Fsp3).
|
|
88
|
-
* @returns {number}
|
|
89
|
-
*/
|
|
90
|
-
fsp3() {
|
|
91
|
-
const ret = wasm.molhandle_fsp3(this.__wbg_ptr);
|
|
92
|
-
return ret;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Number of hydrogen bond acceptors (Lipinski: all N and O atoms).
|
|
96
|
-
* @returns {number}
|
|
97
|
-
*/
|
|
98
|
-
hba_count() {
|
|
99
|
-
const ret = wasm.molhandle_hba_count(this.__wbg_ptr);
|
|
100
|
-
return ret >>> 0;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Number of hydrogen bond donors (N-H or O-H groups).
|
|
104
|
-
* @returns {number}
|
|
105
|
-
*/
|
|
106
|
-
hbd_count() {
|
|
107
|
-
const ret = wasm.molhandle_hbd_count(this.__wbg_ptr);
|
|
108
|
-
return ret >>> 0;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Number of non-hydrogen heavy atoms.
|
|
112
|
-
* @returns {number}
|
|
113
|
-
*/
|
|
114
|
-
heavy_atom_count() {
|
|
115
|
-
const ret = wasm.molhandle_heavy_atom_count(this.__wbg_ptr);
|
|
116
|
-
return ret >>> 0;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Returns `true` if the molecule satisfies Lipinski's Rule of Five.
|
|
120
|
-
* @returns {boolean}
|
|
121
|
-
*/
|
|
122
|
-
lipinski_passes() {
|
|
123
|
-
const ret = wasm.molhandle_lipinski_passes(this.__wbg_ptr);
|
|
124
|
-
return ret !== 0;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Crippen–Wildman octanol/water partition coefficient (LogP).
|
|
128
|
-
* @returns {number}
|
|
129
|
-
*/
|
|
130
|
-
logp_crippen() {
|
|
131
|
-
const ret = wasm.molhandle_logp_crippen(this.__wbg_ptr);
|
|
132
|
-
return ret;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Average molecular weight (Da).
|
|
136
|
-
* @returns {number}
|
|
137
|
-
*/
|
|
138
|
-
molecular_weight() {
|
|
139
|
-
const ret = wasm.molhandle_molecular_weight(this.__wbg_ptr);
|
|
140
|
-
return ret;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Quantitative Estimate of Drug-likeness (QED); range [0, 1].
|
|
144
|
-
* @returns {number}
|
|
145
|
-
*/
|
|
146
|
-
qed() {
|
|
147
|
-
const ret = wasm.molhandle_qed(this.__wbg_ptr);
|
|
148
|
-
return ret;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Number of rotatable bonds.
|
|
152
|
-
* @returns {number}
|
|
153
|
-
*/
|
|
154
|
-
rotatable_bond_count() {
|
|
155
|
-
const ret = wasm.molhandle_rotatable_bond_count(this.__wbg_ptr);
|
|
156
|
-
return ret >>> 0;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Topological polar surface area (Ų).
|
|
160
|
-
* @returns {number}
|
|
161
|
-
*/
|
|
162
|
-
tpsa() {
|
|
163
|
-
const ret = wasm.molhandle_tpsa(this.__wbg_ptr);
|
|
164
|
-
return ret;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
if (Symbol.dispose) MolHandle.prototype[Symbol.dispose] = MolHandle.prototype.free;
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Number of BRICS fragments produced by fragmenting the molecule.
|
|
171
|
-
*
|
|
172
|
-
* Returns 1 if no BRICS-breakable bonds exist (whole molecule is one fragment).
|
|
173
|
-
* @param {MolHandle} mol
|
|
174
|
-
* @returns {number}
|
|
175
|
-
*/
|
|
176
|
-
export function brics_fragment_count(mol) {
|
|
177
|
-
_assertClass(mol, MolHandle);
|
|
178
|
-
const ret = wasm.brics_fragment_count(mol.__wbg_ptr);
|
|
179
|
-
return ret >>> 0;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Compute the ECFP4 fingerprint as a bit-packed byte vector (256 bytes = 2048 bits).
|
|
184
|
-
* @param {MolHandle} mol
|
|
185
|
-
* @returns {Uint8Array}
|
|
186
|
-
*/
|
|
187
|
-
export function ecfp4_bitvec(mol) {
|
|
188
|
-
_assertClass(mol, MolHandle);
|
|
189
|
-
const ret = wasm.ecfp4_bitvec(mol.__wbg_ptr);
|
|
190
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
191
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
192
|
-
return v1;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Parse a SMILES string into a `MolHandle`.
|
|
197
|
-
*
|
|
198
|
-
* Returns a JS error string on parse failure.
|
|
199
|
-
* @param {string} s
|
|
200
|
-
* @returns {MolHandle}
|
|
201
|
-
*/
|
|
202
|
-
export function parse_smiles(s) {
|
|
203
|
-
const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
204
|
-
const len0 = WASM_VECTOR_LEN;
|
|
205
|
-
const ret = wasm.parse_smiles(ptr0, len0);
|
|
206
|
-
if (ret[2]) {
|
|
207
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
208
|
-
}
|
|
209
|
-
return MolHandle.__wrap(ret[0]);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Tanimoto similarity between two molecules using AtomPair fingerprints.
|
|
214
|
-
* @param {MolHandle} a
|
|
215
|
-
* @param {MolHandle} b
|
|
216
|
-
* @returns {number}
|
|
217
|
-
*/
|
|
218
|
-
export function tanimoto_atom_pair(a, b) {
|
|
219
|
-
_assertClass(a, MolHandle);
|
|
220
|
-
_assertClass(b, MolHandle);
|
|
221
|
-
const ret = wasm.tanimoto_atom_pair(a.__wbg_ptr, b.__wbg_ptr);
|
|
222
|
-
return ret;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Tanimoto similarity between two molecules using ECFP4 fingerprints.
|
|
227
|
-
* @param {MolHandle} a
|
|
228
|
-
* @param {MolHandle} b
|
|
229
|
-
* @returns {number}
|
|
230
|
-
*/
|
|
231
|
-
export function tanimoto_ecfp4(a, b) {
|
|
232
|
-
_assertClass(a, MolHandle);
|
|
233
|
-
_assertClass(b, MolHandle);
|
|
234
|
-
const ret = wasm.tanimoto_ecfp4(a.__wbg_ptr, b.__wbg_ptr);
|
|
235
|
-
return ret;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Tanimoto similarity between two molecules using Topological Torsion fingerprints.
|
|
240
|
-
* @param {MolHandle} a
|
|
241
|
-
* @param {MolHandle} b
|
|
242
|
-
* @returns {number}
|
|
243
|
-
*/
|
|
244
|
-
export function tanimoto_torsion(a, b) {
|
|
245
|
-
_assertClass(a, MolHandle);
|
|
246
|
-
_assertClass(b, MolHandle);
|
|
247
|
-
const ret = wasm.tanimoto_torsion(a.__wbg_ptr, b.__wbg_ptr);
|
|
248
|
-
return ret;
|
|
249
|
-
}
|
|
250
|
-
export function __wbg___wbindgen_throw_1506f2235d1bdba0(arg0, arg1) {
|
|
251
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
252
|
-
}
|
|
253
|
-
export function __wbindgen_cast_0000000000000001(arg0, arg1) {
|
|
254
|
-
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
255
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
256
|
-
return ret;
|
|
257
|
-
}
|
|
258
|
-
export function __wbindgen_init_externref_table() {
|
|
259
|
-
const table = wasm.__wbindgen_externrefs;
|
|
260
|
-
const offset = table.grow(4);
|
|
261
|
-
table.set(0, undefined);
|
|
262
|
-
table.set(offset + 0, undefined);
|
|
263
|
-
table.set(offset + 1, null);
|
|
264
|
-
table.set(offset + 2, true);
|
|
265
|
-
table.set(offset + 3, false);
|
|
266
|
-
}
|
|
267
|
-
const MolHandleFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
268
|
-
? { register: () => {}, unregister: () => {} }
|
|
269
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_molhandle_free(ptr, 1));
|
|
270
|
-
|
|
271
|
-
function _assertClass(instance, klass) {
|
|
272
|
-
if (!(instance instanceof klass)) {
|
|
273
|
-
throw new Error(`expected instance of ${klass.name}`);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
278
|
-
ptr = ptr >>> 0;
|
|
279
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
function getStringFromWasm0(ptr, len) {
|
|
283
|
-
return decodeText(ptr >>> 0, len);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
let cachedUint8ArrayMemory0 = null;
|
|
287
|
-
function getUint8ArrayMemory0() {
|
|
288
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
289
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
290
|
-
}
|
|
291
|
-
return cachedUint8ArrayMemory0;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
295
|
-
if (realloc === undefined) {
|
|
296
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
297
|
-
const ptr = malloc(buf.length, 1) >>> 0;
|
|
298
|
-
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
299
|
-
WASM_VECTOR_LEN = buf.length;
|
|
300
|
-
return ptr;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
let len = arg.length;
|
|
304
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
305
|
-
|
|
306
|
-
const mem = getUint8ArrayMemory0();
|
|
307
|
-
|
|
308
|
-
let offset = 0;
|
|
309
|
-
|
|
310
|
-
for (; offset < len; offset++) {
|
|
311
|
-
const code = arg.charCodeAt(offset);
|
|
312
|
-
if (code > 0x7F) break;
|
|
313
|
-
mem[ptr + offset] = code;
|
|
314
|
-
}
|
|
315
|
-
if (offset !== len) {
|
|
316
|
-
if (offset !== 0) {
|
|
317
|
-
arg = arg.slice(offset);
|
|
318
|
-
}
|
|
319
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
320
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
321
|
-
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
322
|
-
|
|
323
|
-
offset += ret.written;
|
|
324
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
WASM_VECTOR_LEN = offset;
|
|
328
|
-
return ptr;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
function takeFromExternrefTable0(idx) {
|
|
332
|
-
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
333
|
-
wasm.__externref_table_dealloc(idx);
|
|
334
|
-
return value;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
338
|
-
cachedTextDecoder.decode();
|
|
339
|
-
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
340
|
-
let numBytesDecoded = 0;
|
|
341
|
-
function decodeText(ptr, len) {
|
|
342
|
-
numBytesDecoded += len;
|
|
343
|
-
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
344
|
-
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
345
|
-
cachedTextDecoder.decode();
|
|
346
|
-
numBytesDecoded = len;
|
|
347
|
-
}
|
|
348
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
const cachedTextEncoder = new TextEncoder();
|
|
352
|
-
|
|
353
|
-
if (!('encodeInto' in cachedTextEncoder)) {
|
|
354
|
-
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
355
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
356
|
-
view.set(buf);
|
|
357
|
-
return {
|
|
358
|
-
read: arg.length,
|
|
359
|
-
written: buf.length
|
|
360
|
-
};
|
|
361
|
-
};
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
let WASM_VECTOR_LEN = 0;
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
let wasm;
|
|
368
|
-
export function __wbg_set_wasm(val) {
|
|
369
|
-
wasm = val;
|
|
370
|
-
}
|