immunum 0.9.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 ADDED
@@ -0,0 +1,304 @@
1
+ # immunum
2
+
3
+ High-performance antibody and TCR sequence numbering in Rust, Python, and WebAssembly.
4
+
5
+ ## Overview
6
+
7
+ `immunum` is a library for numbering antibody and T-cell receptor (TCR) variable domain sequences. It uses Needleman-Wunsch semi-global alignment against position-specific scoring matrices (PSSM) built from consensus sequences, with BLOSUM62-based substitution scores.
8
+
9
+ Available as:
10
+ - **Rust crate** — core library and CLI
11
+ - **Python package** — via PyPI (`pip install immunum`), with a [Polars](https://pola.rs) plugin for vectorized batch processing
12
+ - **npm package** — WebAssembly build for Node.js and browsers
13
+
14
+ ### Supported chains
15
+
16
+ | Antibody | TCR |
17
+ |----------|-----|
18
+ | IGH (heavy) | TRA (alpha) |
19
+ | IGK (kappa) | TRB (beta) |
20
+ | IGL (lambda) | TRD (delta) |
21
+ | | TRG (gamma) |
22
+
23
+ ### Numbering schemes
24
+
25
+ - **IMGT** — all 7 chain types
26
+ - **Kabat** — antibody chains (IGH, IGK, IGL)
27
+
28
+ Chain type is automatically detected by aligning against all loaded chains and selecting the best match.
29
+
30
+ ## Python
31
+
32
+ ### Installation
33
+
34
+ ```bash
35
+ pip install immunum
36
+ ```
37
+
38
+ ### Numbering
39
+
40
+ ```python
41
+ from immunum import Annotator
42
+
43
+ annotator = Annotator(chains=["H", "K", "L"], scheme="imgt")
44
+
45
+ sequence = "QVQLVQSGAEVKRPGSSVTVSCKASGGSFSTYALSWVRQAPGRGLEWMGGVIPLLTITNYAPRFQGRITITADRSTSTAYLELNSLRPEDTAVYYCAREGTTGKPIGAFAHWGQGTLVTVSS"
46
+
47
+ result = annotator.number(sequence)
48
+ print(result.chain) # H
49
+ print(result.confidence) # 0.97
50
+ print(result.numbering) # {"1": "E", "2": "V", "3": "Q", ...}
51
+ ```
52
+
53
+ ### Segmentation
54
+
55
+ `segment` splits the sequence into FR/CDR regions:
56
+
57
+ ```python
58
+ result = annotator.segment(sequence)
59
+ print(result.fr1) # EVQLVESGGGLVKPGGSLKLSCAAS
60
+ print(result.cdr1) # GFTFSSYAMS
61
+ print(result.fr2) # WVRQAPGKGLEWVS
62
+ print(result.cdr2) # AISGSGGS
63
+ print(result.fr3) # TYYADSVKGRFTISRDNAKN
64
+ print(result.cdr3) # ...
65
+ print(result.fr4) # ...
66
+ ```
67
+
68
+ Chains: `"H"` (heavy), `"K"` (kappa), `"L"` (lambda), `"A"` (TRA), `"B"` (TRB), `"G"` (TRG), `"D"` (TRD).
69
+
70
+ ### Polars plugin
71
+
72
+ For batch processing, `immunum.polars` registers elementwise Polars expressions:
73
+
74
+ ```python
75
+ import polars as pl
76
+ import immunum.polars as ip
77
+
78
+ df = pl.DataFrame({"sequence": [
79
+ "QVQLVQSGAEVKRPGSSVTVSCKASGGSFSTYALSWVRQAPGRGLEWMGGVIPLLTITNYAPRFQGRITITADRSTSTAYLELNSLRPEDTAVYYCAREGTTGKPIGAFAHWGQGTLVTVSS",
80
+ "DIQMTQSPSSLSASVGDRVTITCRASQDVNTAVAWYQQKPGKAPKLLIYSASFLYSGVPSRFSGSRSGTDFTLTISSLQPEDFATYYCQQHYTTPPTFGQGTKVEIK",
81
+ ]})
82
+
83
+ # Add a struct column with chain, scheme, confidence, numbering
84
+ result = df.with_columns(
85
+ ip.number(pl.col("sequence"), chains=["H", "K", "L"], scheme="imgt").alias("numbered")
86
+ )
87
+
88
+ # Add a struct column with FR/CDR segments
89
+ result = df.with_columns(
90
+ ip.segment(pl.col("sequence"), chains=["H", "K", "L"], scheme="imgt").alias("segmented")
91
+ )
92
+ ```
93
+
94
+ The `number` expression returns a struct with fields `chain`, `scheme`, `confidence`, and `numbering` (a struct of position→residue). The `segment` expression returns a struct with fields `fr1`, `cdr1`, `fr2`, `cdr2`, `fr3`, `cdr3`, `fr4`, `prefix`, `postfix`.
95
+
96
+ ## WebAssembly
97
+
98
+ ### Installation
99
+
100
+ ```bash
101
+ npm install immunum
102
+ ```
103
+
104
+ ### Usage
105
+
106
+ ```js
107
+ import init, { Annotator } from "immunum";
108
+
109
+ await init(); // load the wasm module
110
+
111
+ const annotator = new Annotator(["H", "K", "L"], "imgt");
112
+
113
+ const sequence = "QVQLVQSGAEVKRPGSSVTVSCKASGGSFSTYALSWVRQAPGRGLEWMGGVIPLLTITNYAPRFQGRITITADRSTSTAYLELNSLRPEDTAVYYCAREGTTGKPIGAFAHWGQGTLVTVSS";
114
+
115
+ const result = annotator.number(sequence);
116
+ console.log(result.chain); // "H"
117
+ console.log(result.confidence); // 0.97
118
+ console.log(result.numbering); // { "1": "E", "2": "V", ... }
119
+
120
+ const segments = annotator.segment(sequence);
121
+ console.log(segments.cdr3);
122
+
123
+ annotator.free(); // or use `using annotator = new Annotator(...)` with explicit resource management
124
+ ```
125
+
126
+ ## Rust
127
+
128
+ ### Usage
129
+
130
+ ```rust
131
+ use immunum::{Annotator, Chain, Scheme};
132
+
133
+ let annotator = Annotator::new(
134
+ &[Chain::IGH, Chain::IGK, Chain::IGL],
135
+ Scheme::IMGT,
136
+ None, // uses default min_confidence of 0.5
137
+ ).unwrap();
138
+
139
+ let sequence = "QVQLVQSGAEVKRPGSSVTVSCKASGGSFSTYALSWVRQAPGRGLEWMGGVIPLLTITNYAPRFQGRITITADRSTSTAYLELNSLRPEDTAVYYCAREGTTGKPIGAFAHWGQGTLVTVSS";
140
+
141
+ let result = annotator.number(sequence).unwrap();
142
+
143
+ println!("Chain: {}", result.chain); // IGH
144
+ println!("Confidence: {:.2}", result.confidence);
145
+
146
+ for (aa, pos) in sequence.chars().zip(result.positions.iter()) {
147
+ println!("{} -> {}", aa, pos);
148
+ }
149
+ ```
150
+
151
+ ## CLI
152
+
153
+ ```bash
154
+ immunum number [OPTIONS] [INPUT] [OUTPUT]
155
+ ```
156
+
157
+ ### Options
158
+
159
+ | Flag | Description | Default |
160
+ |------|-------------|---------|
161
+ | `-s, --scheme` | Numbering scheme: `imgt` (`i`), `kabat` (`k`) | `imgt` |
162
+ | `-c, --chain` | Chain filter: `h`,`k`,`l`,`a`,`b`,`g`,`d` or groups: `ig`, `tcr`, `all`. Accepts any form (`h`, `heavy`, `igh`), case-insensitive. | `ig` |
163
+ | `-f, --format` | Output format: `tsv`, `json`, `jsonl` | `tsv` |
164
+
165
+ ### Input
166
+
167
+ Accepts a raw sequence, a FASTA file, or stdin (auto-detected):
168
+
169
+ ```bash
170
+ immunum number EVQLVESGGGLVKPGGSLKLSCAASGFTFSSYAMS
171
+ immunum number sequences.fasta
172
+ cat sequences.fasta | immunum number
173
+ immunum number - < sequences.fasta
174
+ ```
175
+
176
+ ### Output
177
+
178
+ Writes to stdout by default, or to a file if a second positional argument is given:
179
+
180
+ ```bash
181
+ immunum number sequences.fasta results.tsv
182
+ immunum number -f json sequences.fasta results.json
183
+ ```
184
+
185
+ ### Examples
186
+
187
+ ```bash
188
+ # Kabat scheme, JSON output
189
+ immunum number -s kabat -f json EVQLVESGGGLVKPGGSLKLSCAASGFTFSSYAMS
190
+
191
+ # All chains (antibody + TCR), JSONL output
192
+ immunum number -c all -f jsonl sequences.fasta
193
+
194
+ # TCR sequences only, save to file
195
+ immunum number -c tcr tcr_sequences.fasta output.tsv
196
+
197
+ # Extract sequences from a TSV column and pipe in (see fixtures/ig.tsv)
198
+ tail -n +2 fixtures/ig.tsv | cut -f2 | immunum number
199
+ awk -F'\t' 'NR==1{for(i=1;i<=NF;i++) if($i=="sequence") c=i} NR>1{print $c}' fixtures/ig.tsv | immunum number
200
+
201
+ # Filter TSV output to CDR3 positions (111-128 in IMGT)
202
+ immunum number sequences.fasta | awk -F'\t' '$4 >= 111 && $4 <= 128'
203
+
204
+ # Filter to heavy chain results only
205
+ immunum number -c all sequences.fasta | awk -F'\t' 'NR==1 || $2=="H"'
206
+
207
+ # Extract CDR3 sequences with jq
208
+ immunum number -f json sequences.fasta | jq '[.[] | {id: .sequence_id, numbering}]'
209
+ ```
210
+
211
+ ## Development
212
+
213
+ To orchestrate a project between cargo and python, we use [`task`](http://taskfile.dev).
214
+ You can install it with:
215
+
216
+ ```bash
217
+ uv tool install go-task-bin
218
+ ```
219
+
220
+ And then run `task` or `task --list-all` to get the full list of available tasks.
221
+
222
+ By default, `dev` profile will be used in all but `behcnmark-*` taks, but you can change it
223
+ via providing `PROFILE=release` to your task.
224
+
225
+ Also, by default, `task` caches results, but you can ignore it by running `task my-task -f`.
226
+
227
+ ### Building local environment
228
+
229
+ ```bash
230
+ # build a dev environment
231
+ task build-local
232
+
233
+ # build a dev environment with --release flag
234
+ task build-local PROFILE=release
235
+ ```
236
+
237
+ ### Testing
238
+
239
+ ```bash
240
+ task test-rust # test only rust code
241
+ task test-python # test only python code
242
+ task test # test all code
243
+ ```
244
+
245
+ ### Linting
246
+
247
+ ```bash
248
+ task format # formats python and rust code
249
+ task lint # runs linting for python and rust
250
+ ```
251
+
252
+ ### Benchmarking
253
+
254
+ There are multiple benchmarks in the repository. For full list, see `task | grep behcmark`:
255
+
256
+ ```bash
257
+ $ task | grep benchmark
258
+ * benchmark-accuracy: Accuracy benchmark across all fixtures (1k sequences, 7 rounds each)
259
+ * benchmark-cli: Behcmark correctness of the CLI tool
260
+ * benchmark-comparison: Speed + correctness benchmark: immunum vs antpack vs anarci (1k IGH sequences)
261
+ * benchmark-scaling: Scaling benchmark: sizes 100..10M (10x steps), 1 round, H/imgt. Pass CLI_ARGS to filter tools, e.g. -- --tools immunum
262
+ * benchmark-speed: Speed benchmark across dataset sizes (100 to 1M sequences, 7 rounds, H/imgt)
263
+ * benchmark-speed-polars: Speed benchmark for immunum polars across all chain/scheme fixtures
264
+ ```
265
+
266
+ ## Project structure
267
+ ```
268
+ src/
269
+ ├── main.rs # CLI binary (immunum number ...)
270
+ ├── lib.rs # Public API
271
+ ├── annotator.rs # Sequence annotation and chain detection
272
+ ├── alignment.rs # Needleman-Wunsch semi-global alignment
273
+ ├── io.rs # Input parsing (FASTA, raw) and output formatting (TSV, JSON, JSONL)
274
+ ├── numbering.rs # Numbering module entry point
275
+ ├── numbering/
276
+ │ ├── imgt.rs # IMGT numbering rules
277
+ │ └── kabat.rs # Kabat numbering rules
278
+ ├── scoring.rs # PSSM and scoring matrices
279
+ ├── types.rs # Core domain types (Chain, Scheme, Position)
280
+ ├── validation.rs # Validation utilities
281
+ ├── error.rs # Error types
282
+ └── bin/
283
+ ├── benchmark.rs # Validation metrics report
284
+ ├── debug_validation.rs # Alignment mismatch visualization
285
+ └── speed_benchmark.rs # Performance benchmarks
286
+ resources/
287
+ └── consensus/ # Consensus sequence CSVs (compiled into scoring matrices)
288
+ fixtures/
289
+ ├── validation/ # ANARCI-numbered reference datasets
290
+ ├── ig.fasta # Example antibody sequences
291
+ └── ig.tsv # Example TSV input
292
+ scripts/ # Python tooling for generating consensus data
293
+ immunum/
294
+ └── _internal.pyi # python stub file for pyo3
295
+ └── polars.py # polars extension module
296
+ └── python.py # python module
297
+ ```
298
+
299
+ ### Design decisions
300
+
301
+ - **Semi-global alignment** forces full query consumption, preventing long CDR3 regions from being treated as trailing gaps.
302
+ - **Anchor positions** at highly conserved FR residues receive 3× gap penalties to stabilize alignment.
303
+ - **FR regions** use alignment-based numbering; **CDR regions** use scheme-specific insertion rules.
304
+ - Scoring matrices are generated at compile time from consensus data via `build.rs`.
package/immunum.d.ts ADDED
@@ -0,0 +1,41 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /** Numbered residues keyed by IMGT/Kabat position string (e.g. `"112A"`). */
5
+ export type Numbering = Record<string, string>;
6
+
7
+ /** Result returned by {@link Annotator.number}. */
8
+ export interface NumberingResult {
9
+ /** Detected chain type: `"H"`, `"K"`, `"L"`, `"A"`, `"B"`, `"G"`, or `"D"`. */
10
+ chain: string;
11
+ /** Numbering scheme used: `"imgt"` or `"kabat"` */
12
+ scheme: string;
13
+ /** Alignment confidence score between 0 and 1. */
14
+ confidence: number;
15
+ /** Position-to-residue mapping for the aligned region. */
16
+ numbering: Numbering;
17
+ }
18
+
19
+ /** FR/CDR segments returned by {@link Annotator.segment}. */
20
+ export interface SegmentationResult {
21
+ fr1: string;
22
+ cdr1: string;
23
+ fr2: string;
24
+ cdr2: string;
25
+ fr3: string;
26
+ cdr3: string;
27
+ fr4: string;
28
+ /** Residues before FR1 (non-canonical N-terminal extension). */
29
+ prefix: string;
30
+ /** Residues after FR4 (non-canonical C-terminal extension). */
31
+ postfix: string;
32
+ }
33
+
34
+ /** Annotator for numbering antibody and TCR sequences. */
35
+ export class Annotator {
36
+ free(): void;
37
+ [Symbol.dispose](): void;
38
+ constructor(chains: string[], scheme: string, min_confidence?: number | null);
39
+ number(sequence: string): NumberingResult;
40
+ segment(sequence: string): SegmentationResult;
41
+ }
package/immunum.js ADDED
@@ -0,0 +1,307 @@
1
+ /* @ts-self-types="./immunum.d.ts" */
2
+
3
+ /**
4
+ * Annotator for numbering sequences
5
+ */
6
+ class Annotator {
7
+ __destroy_into_raw() {
8
+ const ptr = this.__wbg_ptr;
9
+ this.__wbg_ptr = 0;
10
+ AnnotatorFinalization.unregister(this);
11
+ return ptr;
12
+ }
13
+ free() {
14
+ const ptr = this.__destroy_into_raw();
15
+ wasm.__wbg_annotator_free(ptr, 0);
16
+ }
17
+ /**
18
+ * @param {string[]} chains
19
+ * @param {string} scheme
20
+ * @param {number | null} [min_confidence]
21
+ */
22
+ constructor(chains, scheme, min_confidence) {
23
+ const ptr0 = passArrayJsValueToWasm0(chains, wasm.__wbindgen_malloc);
24
+ const len0 = WASM_VECTOR_LEN;
25
+ const ptr1 = passStringToWasm0(scheme, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
26
+ const len1 = WASM_VECTOR_LEN;
27
+ const ret = wasm.annotator_new(ptr0, len0, ptr1, len1, isLikeNone(min_confidence) ? 0x100000001 : Math.fround(min_confidence));
28
+ if (ret[2]) {
29
+ throw takeFromExternrefTable0(ret[1]);
30
+ }
31
+ this.__wbg_ptr = ret[0] >>> 0;
32
+ AnnotatorFinalization.register(this, this.__wbg_ptr, this);
33
+ return this;
34
+ }
35
+ /**
36
+ * @param {string} sequence
37
+ * @returns {any}
38
+ */
39
+ number(sequence) {
40
+ const ptr0 = passStringToWasm0(sequence, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
41
+ const len0 = WASM_VECTOR_LEN;
42
+ const ret = wasm.annotator_number(this.__wbg_ptr, ptr0, len0);
43
+ if (ret[2]) {
44
+ throw takeFromExternrefTable0(ret[1]);
45
+ }
46
+ return takeFromExternrefTable0(ret[0]);
47
+ }
48
+ /**
49
+ * @param {string} sequence
50
+ * @returns {any}
51
+ */
52
+ segment(sequence) {
53
+ const ptr0 = passStringToWasm0(sequence, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
54
+ const len0 = WASM_VECTOR_LEN;
55
+ const ret = wasm.annotator_segment(this.__wbg_ptr, ptr0, len0);
56
+ if (ret[2]) {
57
+ throw takeFromExternrefTable0(ret[1]);
58
+ }
59
+ return takeFromExternrefTable0(ret[0]);
60
+ }
61
+ }
62
+ if (Symbol.dispose) Annotator.prototype[Symbol.dispose] = Annotator.prototype.free;
63
+ exports.Annotator = Annotator;
64
+
65
+ function __wbg_get_imports() {
66
+ const import0 = {
67
+ __proto__: null,
68
+ __wbg___wbindgen_debug_string_5398f5bb970e0daa: function(arg0, arg1) {
69
+ const ret = debugString(arg1);
70
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
71
+ const len1 = WASM_VECTOR_LEN;
72
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
73
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
74
+ },
75
+ __wbg___wbindgen_string_get_395e606bd0ee4427: function(arg0, arg1) {
76
+ const obj = arg1;
77
+ const ret = typeof(obj) === 'string' ? obj : undefined;
78
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
79
+ var len1 = WASM_VECTOR_LEN;
80
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
81
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
82
+ },
83
+ __wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
84
+ throw new Error(getStringFromWasm0(arg0, arg1));
85
+ },
86
+ __wbg_new_ab79df5bd7c26067: function() {
87
+ const ret = new Object();
88
+ return ret;
89
+ },
90
+ __wbg_set_7eaa4f96924fd6b3: function() { return handleError(function (arg0, arg1, arg2) {
91
+ const ret = Reflect.set(arg0, arg1, arg2);
92
+ return ret;
93
+ }, arguments); },
94
+ __wbindgen_cast_0000000000000001: function(arg0) {
95
+ // Cast intrinsic for `F64 -> Externref`.
96
+ const ret = arg0;
97
+ return ret;
98
+ },
99
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
100
+ // Cast intrinsic for `Ref(String) -> Externref`.
101
+ const ret = getStringFromWasm0(arg0, arg1);
102
+ return ret;
103
+ },
104
+ __wbindgen_init_externref_table: function() {
105
+ const table = wasm.__wbindgen_externrefs;
106
+ const offset = table.grow(4);
107
+ table.set(0, undefined);
108
+ table.set(offset + 0, undefined);
109
+ table.set(offset + 1, null);
110
+ table.set(offset + 2, true);
111
+ table.set(offset + 3, false);
112
+ },
113
+ };
114
+ return {
115
+ __proto__: null,
116
+ "./immunum_bg.js": import0,
117
+ };
118
+ }
119
+
120
+ const AnnotatorFinalization = (typeof FinalizationRegistry === 'undefined')
121
+ ? { register: () => {}, unregister: () => {} }
122
+ : new FinalizationRegistry(ptr => wasm.__wbg_annotator_free(ptr >>> 0, 1));
123
+
124
+ function addToExternrefTable0(obj) {
125
+ const idx = wasm.__externref_table_alloc();
126
+ wasm.__wbindgen_externrefs.set(idx, obj);
127
+ return idx;
128
+ }
129
+
130
+ function debugString(val) {
131
+ // primitive types
132
+ const type = typeof val;
133
+ if (type == 'number' || type == 'boolean' || val == null) {
134
+ return `${val}`;
135
+ }
136
+ if (type == 'string') {
137
+ return `"${val}"`;
138
+ }
139
+ if (type == 'symbol') {
140
+ const description = val.description;
141
+ if (description == null) {
142
+ return 'Symbol';
143
+ } else {
144
+ return `Symbol(${description})`;
145
+ }
146
+ }
147
+ if (type == 'function') {
148
+ const name = val.name;
149
+ if (typeof name == 'string' && name.length > 0) {
150
+ return `Function(${name})`;
151
+ } else {
152
+ return 'Function';
153
+ }
154
+ }
155
+ // objects
156
+ if (Array.isArray(val)) {
157
+ const length = val.length;
158
+ let debug = '[';
159
+ if (length > 0) {
160
+ debug += debugString(val[0]);
161
+ }
162
+ for(let i = 1; i < length; i++) {
163
+ debug += ', ' + debugString(val[i]);
164
+ }
165
+ debug += ']';
166
+ return debug;
167
+ }
168
+ // Test for built-in
169
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
170
+ let className;
171
+ if (builtInMatches && builtInMatches.length > 1) {
172
+ className = builtInMatches[1];
173
+ } else {
174
+ // Failed to match the standard '[object ClassName]'
175
+ return toString.call(val);
176
+ }
177
+ if (className == 'Object') {
178
+ // we're a user defined class or Object
179
+ // JSON.stringify avoids problems with cycles, and is generally much
180
+ // easier than looping through ownProperties of `val`.
181
+ try {
182
+ return 'Object(' + JSON.stringify(val) + ')';
183
+ } catch (_) {
184
+ return 'Object';
185
+ }
186
+ }
187
+ // errors
188
+ if (val instanceof Error) {
189
+ return `${val.name}: ${val.message}\n${val.stack}`;
190
+ }
191
+ // TODO we could test for more things here, like `Set`s and `Map`s.
192
+ return className;
193
+ }
194
+
195
+ let cachedDataViewMemory0 = null;
196
+ function getDataViewMemory0() {
197
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
198
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
199
+ }
200
+ return cachedDataViewMemory0;
201
+ }
202
+
203
+ function getStringFromWasm0(ptr, len) {
204
+ ptr = ptr >>> 0;
205
+ return decodeText(ptr, len);
206
+ }
207
+
208
+ let cachedUint8ArrayMemory0 = null;
209
+ function getUint8ArrayMemory0() {
210
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
211
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
212
+ }
213
+ return cachedUint8ArrayMemory0;
214
+ }
215
+
216
+ function handleError(f, args) {
217
+ try {
218
+ return f.apply(this, args);
219
+ } catch (e) {
220
+ const idx = addToExternrefTable0(e);
221
+ wasm.__wbindgen_exn_store(idx);
222
+ }
223
+ }
224
+
225
+ function isLikeNone(x) {
226
+ return x === undefined || x === null;
227
+ }
228
+
229
+ function passArrayJsValueToWasm0(array, malloc) {
230
+ const ptr = malloc(array.length * 4, 4) >>> 0;
231
+ for (let i = 0; i < array.length; i++) {
232
+ const add = addToExternrefTable0(array[i]);
233
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
234
+ }
235
+ WASM_VECTOR_LEN = array.length;
236
+ return ptr;
237
+ }
238
+
239
+ function passStringToWasm0(arg, malloc, realloc) {
240
+ if (realloc === undefined) {
241
+ const buf = cachedTextEncoder.encode(arg);
242
+ const ptr = malloc(buf.length, 1) >>> 0;
243
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
244
+ WASM_VECTOR_LEN = buf.length;
245
+ return ptr;
246
+ }
247
+
248
+ let len = arg.length;
249
+ let ptr = malloc(len, 1) >>> 0;
250
+
251
+ const mem = getUint8ArrayMemory0();
252
+
253
+ let offset = 0;
254
+
255
+ for (; offset < len; offset++) {
256
+ const code = arg.charCodeAt(offset);
257
+ if (code > 0x7F) break;
258
+ mem[ptr + offset] = code;
259
+ }
260
+ if (offset !== len) {
261
+ if (offset !== 0) {
262
+ arg = arg.slice(offset);
263
+ }
264
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
265
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
266
+ const ret = cachedTextEncoder.encodeInto(arg, view);
267
+
268
+ offset += ret.written;
269
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
270
+ }
271
+
272
+ WASM_VECTOR_LEN = offset;
273
+ return ptr;
274
+ }
275
+
276
+ function takeFromExternrefTable0(idx) {
277
+ const value = wasm.__wbindgen_externrefs.get(idx);
278
+ wasm.__externref_table_dealloc(idx);
279
+ return value;
280
+ }
281
+
282
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
283
+ cachedTextDecoder.decode();
284
+ function decodeText(ptr, len) {
285
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
286
+ }
287
+
288
+ const cachedTextEncoder = new TextEncoder();
289
+
290
+ if (!('encodeInto' in cachedTextEncoder)) {
291
+ cachedTextEncoder.encodeInto = function (arg, view) {
292
+ const buf = cachedTextEncoder.encode(arg);
293
+ view.set(buf);
294
+ return {
295
+ read: arg.length,
296
+ written: buf.length
297
+ };
298
+ };
299
+ }
300
+
301
+ let WASM_VECTOR_LEN = 0;
302
+
303
+ const wasmPath = `${__dirname}/immunum_bg.wasm`;
304
+ const wasmBytes = require('fs').readFileSync(wasmPath);
305
+ const wasmModule = new WebAssembly.Module(wasmBytes);
306
+ let wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
307
+ wasm.__wbindgen_start();
Binary file
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "immunum",
3
+ "collaborators": [
4
+ "ENPICOM <dev@enpicom.com>"
5
+ ],
6
+ "description": "Fast antibody and T-cell receptor numbering in Rust and Python",
7
+ "version": "0.9.0",
8
+ "license": "MIT",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/ENPICOM/immunum"
12
+ },
13
+ "files": [
14
+ "immunum_bg.wasm",
15
+ "immunum.js",
16
+ "immunum.d.ts"
17
+ ],
18
+ "main": "immunum.js",
19
+ "homepage": "https://immunum.enpicom.com",
20
+ "types": "immunum.d.ts",
21
+ "keywords": [
22
+ "antibody",
23
+ "numbering",
24
+ "schemes",
25
+ "python",
26
+ "imgt"
27
+ ]
28
+ }