@platforma-open/milaboratories.immune-assay-data.model 1.0.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.
- package/.turbo/turbo-build.log +31 -0
- package/CHANGELOG.md +7 -0
- package/dist/bundle.js +6148 -0
- package/dist/bundle.js.map +1 -0
- package/dist/index.cjs +100 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +97 -0
- package/dist/index.d.ts +97 -0
- package/dist/index.js +98 -0
- package/dist/index.js.map +1 -0
- package/dist/model.json +1 -0
- package/eslint.config.mjs +4 -0
- package/package.json +40 -0
- package/src/index.ts +151 -0
- package/tsconfig.json +16 -0
- package/vite.config.mts +20 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ImportFileHandle,
|
|
3
|
+
InferOutputsType,
|
|
4
|
+
PlDataTableState,
|
|
5
|
+
PlRef,
|
|
6
|
+
SUniversalPColumnId,
|
|
7
|
+
} from '@platforma-sdk/model';
|
|
8
|
+
import {
|
|
9
|
+
BlockModel,
|
|
10
|
+
createPlDataTableV2,
|
|
11
|
+
} from '@platforma-sdk/model';
|
|
12
|
+
|
|
13
|
+
type Settings = {
|
|
14
|
+
coverageThreshold: number; // fraction of aligned residues required
|
|
15
|
+
coverageMode: 0 | 1 | 2 | 3 | 4 | 5; // MMseqs2 coverage modes
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type ImportColumnInfo = {
|
|
19
|
+
header: string;
|
|
20
|
+
type: 'Int' | 'Double' | 'String';
|
|
21
|
+
/** If this column is a sequence column, the type of the sequence */
|
|
22
|
+
sequenceType?: 'nucleotide' | 'aminoacid';
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type BlockArgs = {
|
|
26
|
+
datasetRef?: PlRef;
|
|
27
|
+
targetRef?: SUniversalPColumnId;
|
|
28
|
+
fileHandle?: ImportFileHandle;
|
|
29
|
+
fileExtension?: string;
|
|
30
|
+
importColumns?: ImportColumnInfo[];
|
|
31
|
+
sequenceColumnHeader?: string;
|
|
32
|
+
settings: Settings;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type UiState = {
|
|
36
|
+
title: string;
|
|
37
|
+
fileImportError?: string;
|
|
38
|
+
tableState: PlDataTableState;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const model = BlockModel.create()
|
|
42
|
+
|
|
43
|
+
.withArgs<BlockArgs>({
|
|
44
|
+
settings: {
|
|
45
|
+
coverageMode: 2, // default to coverage of clone,
|
|
46
|
+
coverageThreshold: 0.95, // default value matching MMseqs2 default
|
|
47
|
+
},
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
.withUiState<UiState>({
|
|
51
|
+
title: 'Immune Assay Data',
|
|
52
|
+
tableState: {
|
|
53
|
+
gridState: {},
|
|
54
|
+
},
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
.argsValid((ctx) =>
|
|
58
|
+
ctx.args.datasetRef !== undefined
|
|
59
|
+
&& ctx.args.fileHandle !== undefined
|
|
60
|
+
&& ctx.args.importColumns !== undefined
|
|
61
|
+
&& ctx.args.sequenceColumnHeader !== undefined
|
|
62
|
+
&& ctx.args.targetRef !== undefined
|
|
63
|
+
&& ctx.uiState.fileImportError === undefined,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
.output('datasetOptions', (ctx) =>
|
|
67
|
+
ctx.resultPool.getOptions([{
|
|
68
|
+
axes: [
|
|
69
|
+
{ name: 'pl7.app/sampleId' },
|
|
70
|
+
{ name: 'pl7.app/vdj/clonotypeKey' },
|
|
71
|
+
],
|
|
72
|
+
annotations: { 'pl7.app/isAnchor': 'true' },
|
|
73
|
+
}, {
|
|
74
|
+
axes: [
|
|
75
|
+
{ name: 'pl7.app/sampleId' },
|
|
76
|
+
{ name: 'pl7.app/vdj/scClonotypeKey' },
|
|
77
|
+
],
|
|
78
|
+
annotations: { 'pl7.app/isAnchor': 'true' },
|
|
79
|
+
}], { refsWithEnrichments: true }),
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
.output('targetOptions', (ctx) => {
|
|
83
|
+
const ref = ctx.args.datasetRef;
|
|
84
|
+
if (ref === undefined) return undefined;
|
|
85
|
+
|
|
86
|
+
const isSingleCell = ctx.resultPool.getPColumnSpecByRef(ref)?.axesSpec[1].name === 'pl7.app/vdj/scClonotypeKey';
|
|
87
|
+
const sequenceMatchers = [];
|
|
88
|
+
const allowedFeatures = ['CDR1', 'CDR2', 'CDR3', 'FR1', 'FR2',
|
|
89
|
+
'FR3', 'FR4', 'VDJRegion'];
|
|
90
|
+
for (const feature of allowedFeatures) {
|
|
91
|
+
if (isSingleCell) {
|
|
92
|
+
sequenceMatchers.push({
|
|
93
|
+
axes: [{ anchor: 'main', idx: 1 }],
|
|
94
|
+
name: 'pl7.app/vdj/sequence',
|
|
95
|
+
domain: {
|
|
96
|
+
'pl7.app/vdj/feature': feature,
|
|
97
|
+
'pl7.app/vdj/scClonotypeChain/index': 'primary',
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
} else {
|
|
101
|
+
sequenceMatchers.push({
|
|
102
|
+
axes: [{ anchor: 'main', idx: 1 }],
|
|
103
|
+
name: 'pl7.app/vdj/sequence',
|
|
104
|
+
domain: {
|
|
105
|
+
'pl7.app/vdj/feature': feature,
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return ctx.resultPool.getCanonicalOptions(
|
|
112
|
+
{ main: ref },
|
|
113
|
+
sequenceMatchers,
|
|
114
|
+
{
|
|
115
|
+
ignoreMissingDomains: true,
|
|
116
|
+
labelOps: {
|
|
117
|
+
includeNativeLabel: true,
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
.output(
|
|
123
|
+
'dataImportHandle',
|
|
124
|
+
(ctx) => ctx.outputs?.resolve('dataImportHandle')?.getImportProgress(),
|
|
125
|
+
{ isActive: true },
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
.output('table', (ctx) => {
|
|
129
|
+
const cols = ctx.outputs?.resolve('table')?.getPColumns();
|
|
130
|
+
if (cols === undefined)
|
|
131
|
+
return undefined;
|
|
132
|
+
|
|
133
|
+
return createPlDataTableV2(
|
|
134
|
+
ctx,
|
|
135
|
+
cols,
|
|
136
|
+
(_) => true,
|
|
137
|
+
ctx.uiState.tableState,
|
|
138
|
+
);
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
.output('isRunning', (ctx) => ctx.outputs?.getIsReadyOrError() === false)
|
|
142
|
+
|
|
143
|
+
.title((ctx) => ctx.uiState.title)
|
|
144
|
+
|
|
145
|
+
.sections((_ctx) => ([
|
|
146
|
+
{ type: 'link', href: '/', label: 'Main' },
|
|
147
|
+
]))
|
|
148
|
+
|
|
149
|
+
.done();
|
|
150
|
+
|
|
151
|
+
export type BlockOutputs = InferOutputsType<typeof model>;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2022",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"outDir": "./dist",
|
|
9
|
+
"rootDir": "./src",
|
|
10
|
+
"sourceMap": true,
|
|
11
|
+
"declaration": true
|
|
12
|
+
},
|
|
13
|
+
"types": [],
|
|
14
|
+
"include": ["src/**/*"],
|
|
15
|
+
"exclude": ["node_modules", "dist"]
|
|
16
|
+
}
|
package/vite.config.mts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
build: {
|
|
5
|
+
emptyOutDir: false,
|
|
6
|
+
lib: {
|
|
7
|
+
entry: 'src/index.ts',
|
|
8
|
+
name: 'model',
|
|
9
|
+
fileName: (format) => `my-lib.${format}.js`
|
|
10
|
+
},
|
|
11
|
+
minify: false,
|
|
12
|
+
sourcemap: true,
|
|
13
|
+
rollupOptions: {
|
|
14
|
+
output: {
|
|
15
|
+
format: 'iife',
|
|
16
|
+
entryFileNames: 'bundle.js'
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|