@bio-rs/biors-wasm 0.47.4

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 ADDED
@@ -0,0 +1,48 @@
1
+ # biors-wasm
2
+
3
+ WebAssembly/JavaScript bindings for [bio-rs](https://github.com/bio-rs/bio-rs) core biological sequence processing.
4
+
5
+ ## Usage
6
+
7
+ ```javascript
8
+ import init, {
9
+ parseFasta,
10
+ validateFasta,
11
+ tokenize,
12
+ buildModelInputWithPolicy,
13
+ runWorkflow,
14
+ } from "@bio-rs/biors-wasm";
15
+
16
+ await init();
17
+
18
+ const fastaText = ">seq1\nACDE\n>seq2\nFGHI\n";
19
+ const bytes = new TextEncoder().encode(fastaText);
20
+
21
+ const parsed = parseFasta(bytes);
22
+ const validated = validateFasta(bytes, "protein");
23
+ const tokenized = tokenize(parsed, "protein-20");
24
+ const modelInput = buildModelInputWithPolicy(tokenized.records, 8, 0, "fixed_length");
25
+ const workflow = runWorkflow({
26
+ fastaBytes: bytes,
27
+ maxLength: 8,
28
+ padding: "fixed_length",
29
+ padTokenId: 0,
30
+ });
31
+ ```
32
+
33
+ ## Development
34
+
35
+ ```bash
36
+ # Check compilation
37
+ cargo check -p biors-wasm --target wasm32-unknown-unknown
38
+
39
+ # Build for bundlers
40
+ wasm-pack build packages/rust/biors-wasm --target bundler
41
+
42
+ # Run browser tests
43
+ wasm-pack test --headless --chrome packages/rust/biors-wasm
44
+ ```
45
+
46
+ ## License
47
+
48
+ MIT OR Apache-2.0
@@ -0,0 +1,176 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export interface FastaRecord {
5
+ id: string;
6
+ sequence: string;
7
+ }
8
+
9
+
10
+
11
+ export interface ModelInputRecord {
12
+ id: string;
13
+ input_ids: number[];
14
+ attention_mask: number[];
15
+ truncated: boolean;
16
+ }
17
+
18
+ export interface ModelInputOutput {
19
+ policy: {
20
+ max_length: number;
21
+ pad_token_id: number;
22
+ padding: "fixed_length" | "no_padding";
23
+ };
24
+ records: ModelInputRecord[];
25
+ }
26
+
27
+
28
+
29
+ export interface ResidueIssue {
30
+ residue: string;
31
+ position: number;
32
+ }
33
+
34
+
35
+
36
+ export interface SequenceKindCounts {
37
+ protein: number;
38
+ dna: number;
39
+ rna: number;
40
+ }
41
+
42
+
43
+
44
+ export interface SequenceValidationIssue {
45
+ symbol: string;
46
+ position: number;
47
+ kind: "protein" | "dna" | "rna";
48
+ code: "ambiguous_symbol" | "invalid_symbol";
49
+ message: string;
50
+ }
51
+
52
+
53
+
54
+ export interface TokenizedRecord {
55
+ id: string;
56
+ tokens: number[];
57
+ length: number;
58
+ alphabet: string;
59
+ valid: boolean;
60
+ warnings: ResidueIssue[];
61
+ errors: ResidueIssue[];
62
+ }
63
+
64
+ export interface TokenizeOutput {
65
+ inputIds: number[][];
66
+ attentionMask: number[][];
67
+ ids: string[];
68
+ records: TokenizedRecord[];
69
+ }
70
+
71
+
72
+
73
+ export interface ValidatedSequence {
74
+ id: string;
75
+ sequence: string;
76
+ kind: "protein" | "dna" | "rna";
77
+ alphabet: string;
78
+ valid: boolean;
79
+ warnings: SequenceValidationIssue[];
80
+ errors: SequenceValidationIssue[];
81
+ }
82
+
83
+
84
+
85
+ export interface ValidationReport {
86
+ records: number;
87
+ valid_records: number;
88
+ warning_count: number;
89
+ error_count: number;
90
+ kind_counts: SequenceKindCounts;
91
+ sequences: ValidatedSequence[];
92
+ }
93
+
94
+
95
+
96
+ export interface WorkflowConfig {
97
+ fastaBytes: Uint8Array;
98
+ kind?: "auto" | "protein" | "dna" | "rna";
99
+ profile?: "protein-20" | "protein-20-special";
100
+ maxLength: number;
101
+ padding?: "fixed_length" | "no_padding";
102
+ padTokenId?: number;
103
+ }
104
+
105
+ export interface WorkflowReadinessIssue {
106
+ code: string;
107
+ id: string;
108
+ warning_count: number;
109
+ error_count: number;
110
+ message: string;
111
+ }
112
+
113
+ export interface WorkflowOutput {
114
+ workflow: string;
115
+ model_ready: boolean;
116
+ validation: ValidationReport;
117
+ tokenization: {
118
+ summary: {
119
+ records: number;
120
+ total_length: number;
121
+ valid_records: number;
122
+ warning_count: number;
123
+ error_count: number;
124
+ };
125
+ records: TokenizedRecord[];
126
+ };
127
+ model_input: ModelInputOutput | null;
128
+ readiness_issues: WorkflowReadinessIssue[];
129
+ provenance: {
130
+ biors_core_version: string;
131
+ invocation: {
132
+ command: string;
133
+ arguments: string[];
134
+ };
135
+ input_hash: string;
136
+ normalization: string;
137
+ validation_alphabet: string;
138
+ tokenizer: {
139
+ name: string;
140
+ vocab_size: number;
141
+ unknown_token_id: number;
142
+ unknown_token_policy: string;
143
+ };
144
+ model_input_policy: {
145
+ max_length: number;
146
+ pad_token_id: number;
147
+ padding: string;
148
+ };
149
+ hashes: {
150
+ vocabulary_sha256: string;
151
+ output_data_sha256: string;
152
+ };
153
+ };
154
+ }
155
+
156
+
157
+
158
+ export function buildModelInput(tokenized: any, max_length: number): any;
159
+
160
+ export function buildModelInputWithPolicy(tokenized: any, max_length: number, pad_token_id: number, padding: string): any;
161
+
162
+ export function init_panic_hook(): void;
163
+
164
+ /**
165
+ * Parse FASTA bytes into an array of sequence records.
166
+ */
167
+ export function parseFasta(bytes: Uint8Array): any;
168
+
169
+ export function runWorkflow(config: any): any;
170
+
171
+ export function tokenize(records: any, profile: string): any;
172
+
173
+ /**
174
+ * Validate FASTA bytes and return a structured validation report.
175
+ */
176
+ export function validateFasta(bytes: Uint8Array, kind: string): any;
package/biors_wasm.js ADDED
@@ -0,0 +1,9 @@
1
+ /* @ts-self-types="./biors_wasm.d.ts" */
2
+ import * as wasm from "./biors_wasm_bg.wasm";
3
+ import { __wbg_set_wasm } from "./biors_wasm_bg.js";
4
+
5
+ __wbg_set_wasm(wasm);
6
+ wasm.__wbindgen_start();
7
+ export {
8
+ buildModelInput, buildModelInputWithPolicy, init_panic_hook, parseFasta, runWorkflow, tokenize, validateFasta
9
+ } from "./biors_wasm_bg.js";
Binary file
package/index.d.ts ADDED
@@ -0,0 +1,44 @@
1
+ // index.d.ts
2
+ // Hand-written public TypeScript declarations for @bio-rs/biors-wasm.
3
+ // Re-exports and refines the auto-generated wasm-pack types.
4
+
5
+ export {
6
+ parseFasta,
7
+ validateFasta,
8
+ tokenize,
9
+ buildModelInput,
10
+ buildModelInputWithPolicy,
11
+ runWorkflow,
12
+ default as init,
13
+ } from "./biors_wasm.js";
14
+
15
+ export type {
16
+ FastaRecord,
17
+ SequenceValidationIssue,
18
+ ValidatedSequence,
19
+ SequenceKindCounts,
20
+ ValidationReport,
21
+ ResidueIssue,
22
+ TokenizedRecord,
23
+ TokenizeOutput,
24
+ ModelInputRecord,
25
+ ModelInputOutput,
26
+ WorkflowConfig,
27
+ WorkflowReadinessIssue,
28
+ WorkflowOutput,
29
+ } from "./biors_wasm.d.ts";
30
+
31
+ // Refine function signatures for consumers
32
+ declare module "./biors_wasm.js" {
33
+ export function parseFasta(bytes: Uint8Array): FastaRecord[];
34
+ export function validateFasta(bytes: Uint8Array, kind: string): ValidationReport;
35
+ export function tokenize(records: FastaRecord[], profile: string): TokenizeOutput;
36
+ export function buildModelInput(tokenized: TokenizedRecord[], maxLength: number): ModelInputOutput;
37
+ export function buildModelInputWithPolicy(
38
+ tokenized: TokenizedRecord[],
39
+ maxLength: number,
40
+ padTokenId: number,
41
+ padding: "fixed_length" | "no_padding"
42
+ ): ModelInputOutput;
43
+ export function runWorkflow(config: WorkflowConfig): WorkflowOutput;
44
+ }
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@bio-rs/biors-wasm",
3
+ "type": "module",
4
+ "description": "WebAssembly bindings for bio-rs biological sequence processing",
5
+ "version": "0.47.4",
6
+ "license": "MIT OR Apache-2.0",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/bio-rs/bio-rs.git",
10
+ "directory": "packages/rust/biors-wasm"
11
+ },
12
+ "files": [
13
+ "biors_wasm_bg.wasm",
14
+ "biors_wasm.js",
15
+ "biors_wasm.d.ts",
16
+ "index.d.ts",
17
+ "README.md"
18
+ ],
19
+ "main": "biors_wasm.js",
20
+ "types": "index.d.ts",
21
+ "sideEffects": false,
22
+ "keywords": [
23
+ "bioinformatics",
24
+ "protein",
25
+ "tokenizer",
26
+ "wasm",
27
+ "rust"
28
+ ],
29
+ "module": "biors_wasm.js"
30
+ }