@platforma-open/milaboratories.sequence-properties.model 1.1.1

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.
@@ -0,0 +1,22 @@
1
+ import { PlDataTableStateV2, PlRef } from "@platforma-sdk/model";
2
+
3
+ //#region src/types.d.ts
4
+ type BlockData = {
5
+ inputAnchor?: PlRef;
6
+ tableState: PlDataTableStateV2;
7
+ defaultBlockLabel?: string;
8
+ };
9
+ type BlockArgs = {
10
+ inputAnchor: PlRef;
11
+ };
12
+ type WorkflowMode = "peptide" | "antibody_tcr_universal" | "antibody_tcr_legacy_bulk" | "antibody_tcr_legacy_sc";
13
+ type WorkflowReceptor = "IG" | "TCRAB" | "TCRGD";
14
+ type WorkflowInfo = {
15
+ mode?: WorkflowMode;
16
+ receptor?: WorkflowReceptor;
17
+ coverageTier?: "full_chain" | "cdr3_only" | "partial" | "peptide";
18
+ messages: string[];
19
+ };
20
+ //#endregion
21
+ export { BlockArgs, BlockData, WorkflowInfo, WorkflowMode, WorkflowReceptor };
22
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;;KAEY,SAAA;EACV,WAAA,GAAc,KAAA;EACd,UAAA,EAAY,kBAAA;EAIZ,iBAAA;AAAA;AAAA,KAGU,SAAA;EACV,WAAA,EAAa,KAAA;AAAA;AAAA,KAGH,YAAA;AAAA,KAMA,gBAAA;AAAA,KAEA,YAAA;EACV,IAAA,GAAO,YAAA;EACP,QAAA,GAAW,gBAAA;EACX,YAAA;EACA,QAAA;AAAA"}
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@platforma-open/milaboratories.sequence-properties.model",
3
+ "version": "1.1.1",
4
+ "description": "Block model",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "sources": "./src/index.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./dist/*": "./dist/*"
15
+ },
16
+ "dependencies": {
17
+ "@milaboratories/helpers": "^1.14.1",
18
+ "@platforma-sdk/model": "1.69.0"
19
+ },
20
+ "devDependencies": {
21
+ "@milaboratories/ts-builder": "1.3.2",
22
+ "@milaboratories/ts-configs": "1.2.3",
23
+ "@platforma-sdk/block-tools": "2.7.16"
24
+ },
25
+ "peerDependencies": {
26
+ "@types/node": "*",
27
+ "typescript": "*"
28
+ },
29
+ "scripts": {
30
+ "fmt": "ts-builder format",
31
+ "watch": "ts-builder build --target block-model --watch",
32
+ "build": "ts-builder build --target block-model && block-tools build-model",
33
+ "check": "ts-builder check --target block-model"
34
+ }
35
+ }
@@ -0,0 +1,6 @@
1
+ import { createPlDataTableStateV2, DataModelBuilder } from "@platforma-sdk/model";
2
+ import type { BlockData } from "./types";
3
+
4
+ export const blockDataModel = new DataModelBuilder().from<BlockData>("Ver_2026_04_28").init(() => ({
5
+ tableState: createPlDataTableStateV2(),
6
+ }));
package/src/index.ts ADDED
@@ -0,0 +1,103 @@
1
+ import type { ColumnSource, InferOutputsType } from "@platforma-sdk/model";
2
+ import {
3
+ Annotation,
4
+ ArrayColumnProvider,
5
+ BlockModelV3,
6
+ createPlDataTableV3,
7
+ } from "@platforma-sdk/model";
8
+ import { blockDataModel } from "./dataModel";
9
+ import type { BlockArgs, WorkflowInfo } from "./types";
10
+
11
+ export type { BlockArgs, BlockData, WorkflowInfo, WorkflowMode, WorkflowReceptor } from "./types";
12
+ export { blockDataModel } from "./dataModel";
13
+
14
+ const inputAnchorSpecs = [
15
+ // Peptide mode — universal naming
16
+ {
17
+ axes: [{ name: "pl7.app/sampleId" }, { name: "pl7.app/variantKey" }],
18
+ annotations: { "pl7.app/isAnchor": "true" },
19
+ },
20
+ // Antibody/TCR — legacy MiXCR bulk (cloneId per spec; clonotypeKey per current MiXCR output)
21
+ {
22
+ axes: [{ name: "pl7.app/sampleId" }, { name: "pl7.app/vdj/cloneId" }],
23
+ annotations: { "pl7.app/isAnchor": "true" },
24
+ },
25
+ {
26
+ axes: [{ name: "pl7.app/sampleId" }, { name: "pl7.app/vdj/clonotypeKey" }],
27
+ annotations: { "pl7.app/isAnchor": "true" },
28
+ },
29
+ // Antibody/TCR — legacy MiXCR single-cell
30
+ {
31
+ axes: [{ name: "pl7.app/sampleId" }, { name: "pl7.app/vdj/scClonotypeKey" }],
32
+ annotations: { "pl7.app/isAnchor": "true" },
33
+ },
34
+ ];
35
+
36
+ export const platforma = BlockModelV3.create(blockDataModel)
37
+ .args<BlockArgs>((data) => {
38
+ if (data.inputAnchor === undefined) {
39
+ throw new Error("Select an input dataset");
40
+ }
41
+ return {
42
+ inputAnchor: data.inputAnchor,
43
+ };
44
+ })
45
+ .output("inputOptions", (ctx) =>
46
+ ctx.resultPool.getOptions(inputAnchorSpecs, { refsWithEnrichments: true }),
47
+ )
48
+ .output("inputSpec", (ctx) =>
49
+ ctx.data.inputAnchor ? ctx.resultPool.getPColumnSpecByRef(ctx.data.inputAnchor) : undefined,
50
+ )
51
+ .output("info", (ctx) => ctx.outputs?.resolve("info")?.getDataAsJson<WorkflowInfo>())
52
+ .output("isRunning", (ctx) => ctx.outputs?.getIsReadyOrError() === false)
53
+ .output("processingLog", (ctx) => ctx.outputs?.resolve("processingLog")?.getLogHandle())
54
+ .outputWithStatus("propertiesTable", (ctx) => {
55
+ if (ctx.data.inputAnchor === undefined) return undefined;
56
+ const ownCols = ctx.outputs?.resolve("propertiesPf")?.getPColumns();
57
+ if (ownCols === undefined) return undefined;
58
+
59
+ // Build sources explicitly: upstream cols from the result pool minus
60
+ // anything traced back to this block, plus this block's own cols from
61
+ // `propertiesPf`. The workflow also publishes `exports.properties` —
62
+ // a blockId-stamped score-only variant for downstream consumers like
63
+ // Lead Selection — into the result pool. Filtering by trace excludes
64
+ // it here so score cols don't duplicate the propertiesPf variant.
65
+ const upstreamCols = ctx.resultPool.selectColumns(
66
+ (spec) =>
67
+ !spec.annotations?.[Annotation.Trace]?.includes("milaboratories.sequence-properties"),
68
+ );
69
+ const sources: ColumnSource[] = [
70
+ new ArrayColumnProvider(upstreamCols),
71
+ new ArrayColumnProvider(ownCols),
72
+ ];
73
+
74
+ return createPlDataTableV3(ctx, {
75
+ tableState: ctx.data.tableState,
76
+ columns: {
77
+ sources,
78
+ anchors: { main: ctx.data.inputAnchor },
79
+ selector: { mode: "enrichment" },
80
+ },
81
+ // UX policy (not in spec): default-show only this block's columns;
82
+ // demote upstream cols to optional to keep the table uncluttered.
83
+ // This block's cols fall through unmatched and keep the visibility
84
+ // stamped at workflow-time (`pl7.app/table/visibility`).
85
+ displayOptions: {
86
+ visibility: [
87
+ {
88
+ match: (spec) =>
89
+ !spec.annotations?.[Annotation.Trace]?.includes(
90
+ "milaboratories.sequence-properties",
91
+ ) && spec.annotations?.["pl7.app/isLinkerColumn"] !== "true",
92
+ visibility: "optional",
93
+ },
94
+ ],
95
+ },
96
+ });
97
+ })
98
+ .title(() => "Sequence Properties")
99
+ .subtitle((ctx) => ctx.data.defaultBlockLabel ?? "")
100
+ .sections(() => [{ type: "link" as const, href: "/" as const, label: "Main" }])
101
+ .done();
102
+
103
+ export type BlockOutputs = InferOutputsType<typeof platforma>;
package/src/types.ts ADDED
@@ -0,0 +1,29 @@
1
+ import type { PlDataTableStateV2, PlRef } from "@platforma-sdk/model";
2
+
3
+ export type BlockData = {
4
+ inputAnchor?: PlRef;
5
+ tableState: PlDataTableStateV2;
6
+ // UI-only state. Tracks the selected input dataset's label so the block
7
+ // subtitle can reflect it — populated by the UI watcher in app.ts. Not
8
+ // projected into BlockArgs because the workflow does not consume it.
9
+ defaultBlockLabel?: string;
10
+ };
11
+
12
+ export type BlockArgs = {
13
+ inputAnchor: PlRef;
14
+ };
15
+
16
+ export type WorkflowMode =
17
+ | "peptide"
18
+ | "antibody_tcr_universal"
19
+ | "antibody_tcr_legacy_bulk"
20
+ | "antibody_tcr_legacy_sc";
21
+
22
+ export type WorkflowReceptor = "IG" | "TCRAB" | "TCRGD";
23
+
24
+ export type WorkflowInfo = {
25
+ mode?: WorkflowMode;
26
+ receptor?: WorkflowReceptor;
27
+ coverageTier?: "full_chain" | "cdr3_only" | "partial" | "peptide";
28
+ messages: string[];
29
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "@milaboratories/ts-configs/tsconfig.node.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "outDir": "./dist",
6
+ "rootDir": "./src"
7
+ },
8
+ "include": ["src/**/*"],
9
+ "exclude": ["node_modules"]
10
+ }