@bio-rs/biors-wasm 0.51.0 → 0.53.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 +20 -0
- package/biors_wasm.d.ts +77 -0
- package/biors_wasm.js +1 -1
- package/biors_wasm_bg.js +51 -0
- package/biors_wasm_bg.wasm +0 -0
- package/biors_wasm_bg.wasm.d.ts +8 -4
- package/index.d.ts +16 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,9 +6,13 @@ WebAssembly/JavaScript bindings for [bio-rs](https://github.com/bio-rs/bio-rs) c
|
|
|
6
6
|
|
|
7
7
|
```javascript
|
|
8
8
|
import {
|
|
9
|
+
browserExecutionPolicy,
|
|
10
|
+
inspectBrowserFile,
|
|
11
|
+
validateBrowserFile,
|
|
9
12
|
parseFasta,
|
|
10
13
|
validateFasta,
|
|
11
14
|
tokenize,
|
|
15
|
+
tokenizeBrowserFile,
|
|
12
16
|
buildModelInputWithPolicy,
|
|
13
17
|
runWorkflow,
|
|
14
18
|
} from "@bio-rs/biors-wasm";
|
|
@@ -33,8 +37,24 @@ const dnaWorkflow = runWorkflow({
|
|
|
33
37
|
profile: "dna-iupac",
|
|
34
38
|
maxLength: 8,
|
|
35
39
|
});
|
|
40
|
+
|
|
41
|
+
const policy = browserExecutionPolicy();
|
|
42
|
+
const fileInput = {
|
|
43
|
+
name: "protein.fasta",
|
|
44
|
+
format: "fasta",
|
|
45
|
+
bytes,
|
|
46
|
+
kind: "protein",
|
|
47
|
+
profile: "protein-20",
|
|
48
|
+
};
|
|
49
|
+
const inspected = inspectBrowserFile(fileInput);
|
|
50
|
+
const browserValidation = validateBrowserFile(fileInput);
|
|
51
|
+
const browserTokens = tokenizeBrowserFile(fileInput);
|
|
36
52
|
```
|
|
37
53
|
|
|
54
|
+
The browser helpers are local-first by contract: they accept caller-owned
|
|
55
|
+
`Uint8Array` input, enforce the documented size policy, do not call `fetch`, do
|
|
56
|
+
not upload input data, and do not persist records.
|
|
57
|
+
|
|
38
58
|
## Development
|
|
39
59
|
|
|
40
60
|
```bash
|
package/biors_wasm.d.ts
CHANGED
|
@@ -155,12 +155,85 @@ export interface WorkflowOutput {
|
|
|
155
155
|
|
|
156
156
|
|
|
157
157
|
|
|
158
|
+
export type BrowserBioFormat = "fasta" | "fastq" | "pdb" | "smiles";
|
|
159
|
+
|
|
160
|
+
export interface BrowserFileInput {
|
|
161
|
+
bytes: Uint8Array;
|
|
162
|
+
name?: string;
|
|
163
|
+
format?: BrowserBioFormat;
|
|
164
|
+
kind?: "auto" | "protein" | "dna" | "rna";
|
|
165
|
+
profile?: "protein-20" | "protein-20-special" | "dna-iupac" | "dna-iupac-special" | "rna-iupac" | "rna-iupac-special";
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface BrowserExecutionPolicy {
|
|
169
|
+
schema_version: "biors.browser_tooling.v0";
|
|
170
|
+
execution_mode: "wasm_local";
|
|
171
|
+
network_access: "none";
|
|
172
|
+
uploads_input_data: false;
|
|
173
|
+
external_model_calls: false;
|
|
174
|
+
persistence: "caller_controlled";
|
|
175
|
+
max_input_bytes: number;
|
|
176
|
+
warning_input_bytes: number;
|
|
177
|
+
streaming: {
|
|
178
|
+
supported: false;
|
|
179
|
+
behavior: string;
|
|
180
|
+
caller_guidance: string;
|
|
181
|
+
};
|
|
182
|
+
supported_validation_formats: BrowserBioFormat[];
|
|
183
|
+
supported_tokenization_formats: "fasta"[];
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export interface BrowserFileDescriptor {
|
|
187
|
+
name?: string;
|
|
188
|
+
format: BrowserBioFormat;
|
|
189
|
+
size_bytes: number;
|
|
190
|
+
content_sha256: string;
|
|
191
|
+
input_hash?: string;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export interface BrowserFileWarning {
|
|
195
|
+
code: string;
|
|
196
|
+
message: string;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export interface BrowserFileInspection {
|
|
200
|
+
schema_version: "biors.browser_tooling.v0";
|
|
201
|
+
file: BrowserFileDescriptor;
|
|
202
|
+
accepted: boolean;
|
|
203
|
+
warnings: BrowserFileWarning[];
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export interface BrowserValidationOutput {
|
|
207
|
+
schema_version: "biors.browser_tooling.v0";
|
|
208
|
+
file: BrowserFileDescriptor;
|
|
209
|
+
report: unknown;
|
|
210
|
+
warnings: BrowserFileWarning[];
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface BrowserTokenizationOutput {
|
|
214
|
+
schema_version: "biors.browser_tooling.v0";
|
|
215
|
+
file: BrowserFileDescriptor;
|
|
216
|
+
tokenization: TokenizeOutput;
|
|
217
|
+
model_input_policy_hint: {
|
|
218
|
+
max_length_required: boolean;
|
|
219
|
+
supported_padding: Array<"fixed_length" | "no_padding">;
|
|
220
|
+
note: string;
|
|
221
|
+
};
|
|
222
|
+
warnings: BrowserFileWarning[];
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
export function browserExecutionPolicy(): any;
|
|
228
|
+
|
|
158
229
|
export function buildModelInput(tokenized: any, max_length: number): any;
|
|
159
230
|
|
|
160
231
|
export function buildModelInputWithPolicy(tokenized: any, max_length: number, pad_token_id: number, padding: string): any;
|
|
161
232
|
|
|
162
233
|
export function init_panic_hook(): void;
|
|
163
234
|
|
|
235
|
+
export function inspectBrowserFile(input: any): any;
|
|
236
|
+
|
|
164
237
|
/**
|
|
165
238
|
* Parse FASTA bytes into an array of sequence records.
|
|
166
239
|
*/
|
|
@@ -170,6 +243,10 @@ export function runWorkflow(config: any): any;
|
|
|
170
243
|
|
|
171
244
|
export function tokenize(records: any, profile: string): any;
|
|
172
245
|
|
|
246
|
+
export function tokenizeBrowserFile(input: any): any;
|
|
247
|
+
|
|
248
|
+
export function validateBrowserFile(input: any): any;
|
|
249
|
+
|
|
173
250
|
/**
|
|
174
251
|
* Validate FASTA bytes and return a structured validation report.
|
|
175
252
|
*/
|
package/biors_wasm.js
CHANGED
|
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./biors_wasm_bg.js";
|
|
|
5
5
|
__wbg_set_wasm(wasm);
|
|
6
6
|
wasm.__wbindgen_start();
|
|
7
7
|
export {
|
|
8
|
-
buildModelInput, buildModelInputWithPolicy, init_panic_hook, parseFasta, runWorkflow, tokenize, validateFasta
|
|
8
|
+
browserExecutionPolicy, buildModelInput, buildModelInputWithPolicy, init_panic_hook, inspectBrowserFile, parseFasta, runWorkflow, tokenize, tokenizeBrowserFile, validateBrowserFile, validateFasta
|
|
9
9
|
} from "./biors_wasm_bg.js";
|
package/biors_wasm_bg.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @returns {any}
|
|
3
|
+
*/
|
|
4
|
+
export function browserExecutionPolicy() {
|
|
5
|
+
const ret = wasm.browserExecutionPolicy();
|
|
6
|
+
if (ret[2]) {
|
|
7
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
8
|
+
}
|
|
9
|
+
return takeFromExternrefTable0(ret[0]);
|
|
10
|
+
}
|
|
11
|
+
|
|
1
12
|
/**
|
|
2
13
|
* @param {any} tokenized
|
|
3
14
|
* @param {number} max_length
|
|
@@ -32,6 +43,18 @@ export function init_panic_hook() {
|
|
|
32
43
|
wasm.init_panic_hook();
|
|
33
44
|
}
|
|
34
45
|
|
|
46
|
+
/**
|
|
47
|
+
* @param {any} input
|
|
48
|
+
* @returns {any}
|
|
49
|
+
*/
|
|
50
|
+
export function inspectBrowserFile(input) {
|
|
51
|
+
const ret = wasm.inspectBrowserFile(input);
|
|
52
|
+
if (ret[2]) {
|
|
53
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
54
|
+
}
|
|
55
|
+
return takeFromExternrefTable0(ret[0]);
|
|
56
|
+
}
|
|
57
|
+
|
|
35
58
|
/**
|
|
36
59
|
* Parse FASTA bytes into an array of sequence records.
|
|
37
60
|
* @param {Uint8Array} bytes
|
|
@@ -74,6 +97,30 @@ export function tokenize(records, profile) {
|
|
|
74
97
|
return takeFromExternrefTable0(ret[0]);
|
|
75
98
|
}
|
|
76
99
|
|
|
100
|
+
/**
|
|
101
|
+
* @param {any} input
|
|
102
|
+
* @returns {any}
|
|
103
|
+
*/
|
|
104
|
+
export function tokenizeBrowserFile(input) {
|
|
105
|
+
const ret = wasm.tokenizeBrowserFile(input);
|
|
106
|
+
if (ret[2]) {
|
|
107
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
108
|
+
}
|
|
109
|
+
return takeFromExternrefTable0(ret[0]);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @param {any} input
|
|
114
|
+
* @returns {any}
|
|
115
|
+
*/
|
|
116
|
+
export function validateBrowserFile(input) {
|
|
117
|
+
const ret = wasm.validateBrowserFile(input);
|
|
118
|
+
if (ret[2]) {
|
|
119
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
120
|
+
}
|
|
121
|
+
return takeFromExternrefTable0(ret[0]);
|
|
122
|
+
}
|
|
123
|
+
|
|
77
124
|
/**
|
|
78
125
|
* Validate FASTA bytes and return a structured validation report.
|
|
79
126
|
* @param {Uint8Array} bytes
|
|
@@ -91,6 +138,10 @@ export function validateFasta(bytes, kind) {
|
|
|
91
138
|
}
|
|
92
139
|
return takeFromExternrefTable0(ret[0]);
|
|
93
140
|
}
|
|
141
|
+
export function __wbg___wbindgen_is_null_52ff4ec04186736f(arg0) {
|
|
142
|
+
const ret = arg0 === null;
|
|
143
|
+
return ret;
|
|
144
|
+
}
|
|
94
145
|
export function __wbg___wbindgen_is_undefined_29a43b4d42920abd(arg0) {
|
|
95
146
|
const ret = arg0 === undefined;
|
|
96
147
|
return ret;
|
package/biors_wasm_bg.wasm
CHANGED
|
Binary file
|
package/biors_wasm_bg.wasm.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
-
export const
|
|
5
|
-
export const
|
|
6
|
-
export const
|
|
7
|
-
export const
|
|
4
|
+
export const browserExecutionPolicy: () => [number, number, number];
|
|
5
|
+
export const inspectBrowserFile: (a: any) => [number, number, number];
|
|
6
|
+
export const validateBrowserFile: (a: any) => [number, number, number];
|
|
7
|
+
export const tokenizeBrowserFile: (a: any) => [number, number, number];
|
|
8
8
|
export const parseFasta: (a: number, b: number) => [number, number, number];
|
|
9
9
|
export const validateFasta: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
10
|
+
export const buildModelInput: (a: any, b: number) => [number, number, number];
|
|
11
|
+
export const buildModelInputWithPolicy: (a: any, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
10
12
|
export const tokenize: (a: any, b: number, c: number) => [number, number, number];
|
|
13
|
+
export const runWorkflow: (a: any) => [number, number, number];
|
|
14
|
+
export const init_panic_hook: () => void;
|
|
11
15
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
12
16
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
13
17
|
export const __wbindgen_exn_store: (a: number) => void;
|
package/index.d.ts
CHANGED
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
// Re-exports and refines the auto-generated wasm-pack types.
|
|
4
4
|
|
|
5
5
|
export {
|
|
6
|
+
browserExecutionPolicy,
|
|
7
|
+
inspectBrowserFile,
|
|
6
8
|
parseFasta,
|
|
9
|
+
validateBrowserFile,
|
|
7
10
|
validateFasta,
|
|
8
11
|
tokenize,
|
|
12
|
+
tokenizeBrowserFile,
|
|
9
13
|
buildModelInput,
|
|
10
14
|
buildModelInputWithPolicy,
|
|
11
15
|
runWorkflow,
|
|
@@ -25,13 +29,25 @@ export type {
|
|
|
25
29
|
WorkflowConfig,
|
|
26
30
|
WorkflowReadinessIssue,
|
|
27
31
|
WorkflowOutput,
|
|
32
|
+
BrowserBioFormat,
|
|
33
|
+
BrowserFileInput,
|
|
34
|
+
BrowserExecutionPolicy,
|
|
35
|
+
BrowserFileDescriptor,
|
|
36
|
+
BrowserFileWarning,
|
|
37
|
+
BrowserFileInspection,
|
|
38
|
+
BrowserValidationOutput,
|
|
39
|
+
BrowserTokenizationOutput,
|
|
28
40
|
} from "./biors_wasm.d.ts";
|
|
29
41
|
|
|
30
42
|
// Refine function signatures for consumers
|
|
31
43
|
declare module "./biors_wasm.js" {
|
|
44
|
+
export function browserExecutionPolicy(): BrowserExecutionPolicy;
|
|
45
|
+
export function inspectBrowserFile(input: BrowserFileInput): BrowserFileInspection;
|
|
46
|
+
export function validateBrowserFile(input: BrowserFileInput): BrowserValidationOutput;
|
|
32
47
|
export function parseFasta(bytes: Uint8Array): FastaRecord[];
|
|
33
48
|
export function validateFasta(bytes: Uint8Array, kind: string): ValidationReport;
|
|
34
49
|
export function tokenize(records: FastaRecord[], profile: string): TokenizeOutput;
|
|
50
|
+
export function tokenizeBrowserFile(input: BrowserFileInput): BrowserTokenizationOutput;
|
|
35
51
|
export function buildModelInput(tokenized: TokenizedRecord[], maxLength: number): ModelInputOutput;
|
|
36
52
|
export function buildModelInputWithPolicy(
|
|
37
53
|
tokenized: TokenizedRecord[],
|
package/package.json
CHANGED