@platforma-open/milaboratories.immune-assay-data.model 1.5.1 → 1.5.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platforma-open/milaboratories.immune-assay-data.model",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "description": "Block model",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -15,13 +15,13 @@
15
15
  "./dist/model.json": "./dist/model.json"
16
16
  },
17
17
  "dependencies": {
18
- "@platforma-sdk/model": "1.51.6",
19
- "@milaboratories/graph-maker": "1.1.211"
18
+ "@platforma-sdk/model": "1.53.3",
19
+ "@milaboratories/graph-maker": "1.1.216"
20
20
  },
21
21
  "devDependencies": {
22
- "@milaboratories/ts-builder": "1.2.2",
22
+ "@milaboratories/ts-builder": "1.2.4",
23
23
  "@milaboratories/ts-configs": "1.2.0",
24
- "@platforma-sdk/block-tools": "2.6.29",
24
+ "@platforma-sdk/block-tools": "2.6.36",
25
25
  "@platforma-sdk/eslint-config": "1.2.0",
26
26
  "eslint": "^9.25.1",
27
27
  "typescript": "~5.6.3",
package/src/index.ts CHANGED
@@ -1,14 +1,23 @@
1
1
  import type {
2
+ DataInfo,
2
3
  ImportFileHandle,
4
+ PColumn,
5
+ PColumnSpec,
6
+ PColumnValues,
3
7
  PlDataTableStateV2,
8
+ PlMultiSequenceAlignmentModel,
4
9
  PlRef,
10
+ RenderCtxLegacy,
5
11
  SUniversalPColumnId,
12
+ TreeNodeAccessor,
6
13
  } from '@platforma-sdk/model';
7
14
  import {
8
15
  BlockModel,
16
+ createPFrameForGraphs,
9
17
  createPlDataTableStateV2,
10
18
  createPlDataTableV2,
11
19
  } from '@platforma-sdk/model';
20
+ import { getDefaultBlockLabel } from './label';
12
21
 
13
22
  type Settings = {
14
23
  coverageThreshold: number; // fraction of aligned residues required
@@ -39,12 +48,47 @@ export type BlockArgs = {
39
48
  export type UiState = {
40
49
  fileImportError?: string;
41
50
  tableState: PlDataTableStateV2;
51
+ alignmentModel: PlMultiSequenceAlignmentModel;
42
52
  };
43
53
 
54
+ type Column = PColumn<DataInfo<TreeNodeAccessor> | TreeNodeAccessor | PColumnValues>;
55
+
56
+ type Columns = {
57
+ props: Column[];
58
+ };
59
+
60
+ function getColumns(ctx: RenderCtxLegacy<BlockArgs, UiState>): Columns | undefined {
61
+ const anchor = ctx.args.datasetRef;
62
+ if (anchor === undefined)
63
+ return undefined;
64
+
65
+ const anchorSpec = ctx.resultPool.getPColumnSpecByRef(anchor);
66
+ if (anchorSpec === undefined)
67
+ return undefined;
68
+
69
+ // all clone properties
70
+ const props = (ctx.resultPool.getAnchoredPColumns(
71
+ { main: anchor },
72
+ [
73
+ {
74
+ axes: [{ anchor: 'main', idx: 1 }],
75
+ },
76
+ ]) ?? [])
77
+ .filter((p) => p.spec.annotations?.['pl7.app/sequence/isAnnotation'] !== 'true');
78
+
79
+ return {
80
+ props: props,
81
+ };
82
+ }
83
+
44
84
  export const model = BlockModel.create()
45
85
 
46
86
  .withArgs<BlockArgs>({
47
- defaultBlockLabel: '',
87
+ defaultBlockLabel: getDefaultBlockLabel({
88
+ similarityType: 'alignment-score',
89
+ identity: 0.9,
90
+ coverageThreshold: 0.95,
91
+ }),
48
92
  customBlockLabel: '',
49
93
  settings: {
50
94
  coverageThreshold: 0.95, // default value matching MMseqs2 default
@@ -56,6 +100,7 @@ export const model = BlockModel.create()
56
100
 
57
101
  .withUiState<UiState>({
58
102
  tableState: createPlDataTableStateV2(),
103
+ alignmentModel: {},
59
104
  })
60
105
 
61
106
  .argsValid((ctx) =>
@@ -143,6 +188,48 @@ export const model = BlockModel.create()
143
188
  );
144
189
  })
145
190
 
191
+ .output('pf', (ctx) => {
192
+ if (ctx.outputs?.resolve('emptyResults')?.getDataAsJson<boolean>()) {
193
+ return undefined;
194
+ }
195
+ const cols = ctx.outputs?.resolve('table')?.getPColumns();
196
+ if (cols === undefined)
197
+ return undefined;
198
+
199
+ return createPFrameForGraphs(ctx, cols);
200
+ })
201
+
202
+ .output('assaySequenceSpec', (ctx): PColumnSpec | undefined => {
203
+ if (ctx.outputs?.resolve('emptyResults')?.getDataAsJson<boolean>()) {
204
+ return undefined;
205
+ }
206
+ const cols = ctx.outputs?.resolve('table')?.getPColumns();
207
+ if (cols === undefined)
208
+ return undefined;
209
+ // Return only sequence column
210
+ return cols.find((c) => c.spec.name === 'pl7.app/vdj/sequence'
211
+ && c.spec.axesSpec[0].name === 'pl7.app/vdj/assay/sequenceId')?.spec;
212
+ })
213
+
214
+ .output('msaPf', (ctx) => {
215
+ if (ctx.outputs?.resolve('emptyResults')?.getDataAsJson<boolean>()) {
216
+ return undefined;
217
+ }
218
+ const cols = ctx.outputs?.resolve('table')?.getPColumns();
219
+ if (cols === undefined)
220
+ return undefined;
221
+
222
+ const msaCols = ctx.outputs?.resolve('assayLinkerPframe')?.getPColumns();
223
+ if (!msaCols) return undefined;
224
+
225
+ const columns = getColumns(ctx);
226
+ if (columns === undefined) {
227
+ return undefined;
228
+ }
229
+
230
+ return createPFrameForGraphs(ctx, [...msaCols, ...cols, ...columns.props]);
231
+ })
232
+
146
233
  .output('isRunning', (ctx) => ctx.outputs?.getIsReadyOrError() === false)
147
234
 
148
235
  .title(() => 'Immune Assay Data')
@@ -154,3 +241,5 @@ export const model = BlockModel.create()
154
241
  ]))
155
242
 
156
243
  .done(2);
244
+
245
+ export { getDefaultBlockLabel } from './label';
package/src/label.ts ADDED
@@ -0,0 +1,27 @@
1
+ export function getDefaultBlockLabel(data: {
2
+ fileName?: string;
3
+ similarityType: 'alignment-score' | 'sequence-identity';
4
+ identity: number;
5
+ coverageThreshold: number;
6
+ }) {
7
+ const parts: string[] = [];
8
+
9
+ // Add file name if available
10
+ if (data.fileName) {
11
+ parts.push(data.fileName);
12
+ }
13
+
14
+ // Add similarity type label
15
+ const similarityLabel = data.similarityType === 'alignment-score' ? 'BLOSUM' : 'Exact Match';
16
+ if (similarityLabel) {
17
+ parts.push(similarityLabel);
18
+ }
19
+
20
+ // Add identity threshold
21
+ parts.push(`ident:${data.identity}`);
22
+
23
+ // Add coverage threshold
24
+ parts.push(`cov:${data.coverageThreshold}`);
25
+
26
+ return parts.filter(Boolean).join(', ');
27
+ }