immunum 0.9.2 → 1.1.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 CHANGED
@@ -1,6 +1,8 @@
1
- # immunum
1
+ ![Immunum Logo](https://raw.githubusercontent.com/ENPICOM/immunum/master/docs/assets/immunum_logotype.svg)
2
2
 
3
- High-performance antibody and TCR sequence numbering in Rust, Python, and WebAssembly.
3
+ Immunum is a high-performance antibody and TCR sequence numbering tool for Rust, Python, Polars and JS/TS.
4
+
5
+ Try it in your browser: [interactive demo](https://immunum.enpicom.com/demo/).
4
6
 
5
7
  [![Crates.io](https://img.shields.io/crates/v/immunum)](https://crates.io/crates/immunum)
6
8
  [![PyPI](https://img.shields.io/pypi/v/immunum)](https://pypi.org/project/immunum/)
@@ -16,7 +18,7 @@ High-performance antibody and TCR sequence numbering in Rust, Python, and WebAss
16
18
  Available as:
17
19
 
18
20
  - **Rust crate** — core library and CLI
19
- - **Python package** — via PyPI (`pip install immunum`), with a [Polars](https://pola.rs) plugin for vectorized batch processing
21
+ - **Python package** — with a [Polars](https://pola.rs) plugin for vectorized batch processing
20
22
  - **npm package** — for Node.js and browsers
21
23
 
22
24
  ### Supported chains
@@ -28,13 +30,15 @@ Available as:
28
30
  | IGL (lambda) | TRD (delta) |
29
31
  | | TRG (gamma) |
30
32
 
33
+ Chain codes: `H` (IGH), `K` (IGK), `L` (IGL), `A` (TRA), `B` (TRB), `D` (TRD), `G` (TRG).
34
+
35
+ Chain type is automatically detected by aligning against all loaded chains and selecting the best match.
36
+
31
37
  ### Numbering schemes
32
38
 
33
39
  - **IMGT** — all 7 chain types
34
40
  - **Kabat** — antibody chains (IGH, IGK, IGL)
35
41
 
36
- Chain type is automatically detected by aligning against all loaded chains and selecting the best match.
37
-
38
42
  ## Table of Contents
39
43
 
40
44
  - [Python](#python)
@@ -46,6 +50,7 @@ Chain type is automatically detected by aligning against all loaded chains and s
46
50
  - [Installation](#installation-1)
47
51
  - [Usage](#usage)
48
52
  - [Rust](#rust)
53
+ - [Installation](#installation-2)
49
54
  - [Usage](#usage-1)
50
55
  - [CLI](#cli)
51
56
  - [Options](#options)
@@ -99,8 +104,6 @@ assert result.cdr3 == 'AREGTTGKPIGAFAH'
99
104
  assert result.fr4 == 'WGQGTLVTVSS'
100
105
  ```
101
106
 
102
- Chains: `"H"` (heavy), `"K"` (kappa), `"L"` (lambda), `"A"` (TRA), `"B"` (TRB), `"G"` (TRG), `"D"` (TRD).
103
-
104
107
  ### Polars plugin
105
108
 
106
109
  For batch processing, `immunum.polars` registers elementwise Polars expressions:
@@ -138,9 +141,7 @@ npm install immunum
138
141
  ### Usage
139
142
 
140
143
  ```js
141
- import init, { Annotator } from "immunum";
142
-
143
- await init(); // load the wasm module
144
+ const { Annotator } = require("immunum");
144
145
 
145
146
  const annotator = new Annotator(["H", "K", "L"], "imgt");
146
147
 
@@ -148,18 +149,27 @@ const sequence =
148
149
  "QVQLVQSGAEVKRPGSSVTVSCKASGGSFSTYALSWVRQAPGRGLEWMGGVIPLLTITNYAPRFQGRITITADRSTSTAYLELNSLRPEDTAVYYCAREGTTGKPIGAFAHWGQGTLVTVSS";
149
150
 
150
151
  const result = annotator.number(sequence);
151
- console.log(result.chain); // "H"
152
+ console.log(result.chain); // "H"
152
153
  console.log(result.confidence); // 0.97
153
- console.log(result.numbering); // { "1": "E", "2": "V", ... }
154
+ console.log(result.numbering); // { "1": "Q", "2": "V", ... }
154
155
 
155
156
  const segments = annotator.segment(sequence);
156
- console.log(segments.cdr3);
157
+ console.log(segments.cdr3); // "AREGTTGKPIGAFAH"
157
158
 
158
159
  annotator.free(); // or use `using annotator = new Annotator(...)` with explicit resource management
159
160
  ```
160
161
 
161
162
  ## Rust
162
163
 
164
+ ### Installation
165
+
166
+ Add to `Cargo.toml`:
167
+
168
+ ```toml
169
+ [dependencies]
170
+ immunum = "0.9"
171
+ ```
172
+
163
173
  ### Usage
164
174
 
165
175
  ```rust
@@ -174,20 +184,14 @@ let annotator = Annotator::new(
174
184
  let sequence = "QVQLVQSGAEVKRPGSSVTVSCKASGGSFSTYALSWVRQAPGRGLEWMGGVIPLLTITNYAPRFQGRITITADRSTSTAYLELNSLRPEDTAVYYCAREGTTGKPIGAFAHWGQGTLVTVSS";
175
185
 
176
186
  let result = annotator.number(sequence).unwrap();
177
-
178
187
  println!("Chain: {}", result.chain); // IGH
179
188
  println!("Confidence: {:.2}", result.confidence);
180
-
181
189
  for (aa, pos) in sequence.chars().zip(result.positions.iter()) {
182
190
  println!("{} -> {}", aa, pos);
183
191
  }
184
- ```
185
-
186
- Add to `Cargo.toml`:
187
192
 
188
- ```toml
189
- [dependencies]
190
- immunum = "0.9"
193
+ let segments = annotator.segment(sequence).unwrap();
194
+ println!("CDR3: {}", segments.cdr3);
191
195
  ```
192
196
 
193
197
  ## CLI
package/immunum.d.ts CHANGED
@@ -1,34 +1,45 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
- /** Numbered residues keyed by IMGT/Kabat position string (e.g. `"112A"`). */
5
- export type Numbering = Record<string, string>;
4
+ /**
5
+ * Ordered position → residue map, iterated in IMGT-correct order.
6
+ * Keys are position strings (e.g. `"112A"`) and values are single-character residues.
7
+ */
8
+ export type Numbering = Map<string, string>;
6
9
 
7
- /** Result returned by {@link Annotator.number}. */
10
+ /** Result returned by {@link Annotator.number}. On failure, chain/scheme/confidence/numbering/query_start/query_end are null and error contains the reason. */
8
11
  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;
12
+ /** Detected chain type: `"H"`, `"K"`, `"L"`, `"A"`, `"B"`, `"G"`, or `"D"`. Null on failure. */
13
+ chain: string | null;
14
+ /** Numbering scheme used: `"imgt"` or `"kabat"`. Null on failure. */
15
+ scheme: string | null;
16
+ /** Alignment confidence score between 0 and 1. Null on failure. */
17
+ confidence: number | null;
18
+ /** Position-to-residue mapping for the aligned region. Null on failure. */
19
+ numbering: Numbering | null;
20
+ /** 0-indexed start of the aligned region in the input sequence (inclusive). Null on failure. */
21
+ query_start: number | null;
22
+ /** 0-indexed end of the aligned region in the input sequence (inclusive). Null on failure. */
23
+ query_end: number | null;
24
+ /** Error message if numbering failed, null on success. */
25
+ error: string | null;
17
26
  }
18
27
 
19
- /** FR/CDR segments returned by {@link Annotator.segment}. */
28
+ /** FR/CDR segments returned by {@link Annotator.segment}. On failure, all region fields are absent and error contains the reason. */
20
29
  export interface SegmentationResult {
21
- fr1: string;
22
- cdr1: string;
23
- fr2: string;
24
- cdr2: string;
25
- fr3: string;
26
- cdr3: string;
27
- fr4: string;
30
+ fr1?: string;
31
+ cdr1?: string;
32
+ fr2?: string;
33
+ cdr2?: string;
34
+ fr3?: string;
35
+ cdr3?: string;
36
+ fr4?: string;
28
37
  /** Residues before FR1 (non-canonical N-terminal extension). */
29
- prefix: string;
38
+ prefix?: string;
30
39
  /** Residues after FR4 (non-canonical C-terminal extension). */
31
- postfix: string;
40
+ postfix?: string;
41
+ /** Error message if segmentation failed, null on success. */
42
+ error: string | null;
32
43
  }
33
44
 
34
45
  /**
@@ -62,4 +73,5 @@ export class Annotator {
62
73
  constructor(chains: string[], scheme: string, min_confidence?: number | null);
63
74
  number(sequence: string): NumberingResult;
64
75
  segment(sequence: string): SegmentationResult;
76
+
65
77
  }
package/immunum.js CHANGED
@@ -40,10 +40,7 @@ class Annotator {
40
40
  const ptr0 = passStringToWasm0(sequence, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
41
41
  const len0 = WASM_VECTOR_LEN;
42
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]);
43
+ return ret;
47
44
  }
48
45
  /**
49
46
  * @param {string} sequence
@@ -53,10 +50,7 @@ class Annotator {
53
50
  const ptr0 = passStringToWasm0(sequence, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
54
51
  const len0 = WASM_VECTOR_LEN;
55
52
  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]);
53
+ return ret;
60
54
  }
61
55
  }
62
56
  if (Symbol.dispose) Annotator.prototype[Symbol.dispose] = Annotator.prototype.free;
@@ -83,6 +77,10 @@ function __wbg_get_imports() {
83
77
  __wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
84
78
  throw new Error(getStringFromWasm0(arg0, arg1));
85
79
  },
80
+ __wbg_new_49d5571bd3f0c4d4: function() {
81
+ const ret = new Map();
82
+ return ret;
83
+ },
86
84
  __wbg_new_ab79df5bd7c26067: function() {
87
85
  const ret = new Object();
88
86
  return ret;
@@ -91,6 +89,10 @@ function __wbg_get_imports() {
91
89
  const ret = Reflect.set(arg0, arg1, arg2);
92
90
  return ret;
93
91
  }, arguments); },
92
+ __wbg_set_bf7251625df30a02: function(arg0, arg1, arg2) {
93
+ const ret = arg0.set(arg1, arg2);
94
+ return ret;
95
+ },
94
96
  __wbindgen_cast_0000000000000001: function(arg0) {
95
97
  // Cast intrinsic for `F64 -> Externref`.
96
98
  const ret = arg0;
package/immunum_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "ENPICOM <dev@enpicom.com>"
5
5
  ],
6
6
  "description": "Fast antibody and T-cell receptor numbering in Rust and Python",
7
- "version": "0.9.2",
7
+ "version": "1.1.0",
8
8
  "license": "MIT",
9
9
  "repository": {
10
10
  "type": "git",