@platforma-open/milaboratories.repertoire-diversity-2.model 1.3.1 → 1.5.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/dist/index.cjs CHANGED
@@ -2,59 +2,76 @@
2
2
 
3
3
  var model$1 = require('@platforma-sdk/model');
4
4
 
5
+ // src/index.ts
6
+
7
+ // src/converters.ts
8
+ var convertMetricsUiToArgs = (metrics) => {
9
+ return metrics.map((metric) => {
10
+ return {
11
+ type: metric.type,
12
+ downsampling: metric.downsampling
13
+ };
14
+ });
15
+ };
16
+
5
17
  // src/index.ts
6
18
  var model = model$1.BlockModel.create().withArgs({
19
+ metrics: []
20
+ }).withUiState({
21
+ blockTitle: "Repertoire Diversity",
22
+ graphState: {
23
+ title: "Repertoire Diversity",
24
+ template: "bar",
25
+ currentTab: null
26
+ },
27
+ tableState: model$1.createPlDataTableStateV2(),
7
28
  metrics: [
8
29
  {
30
+ id: "observed",
9
31
  type: "observed",
10
32
  downsampling: {
11
33
  type: "hypergeometric",
12
34
  valueChooser: "auto"
13
- }
35
+ },
36
+ isExpanded: false
14
37
  },
15
38
  {
39
+ id: "shannonWiener",
16
40
  type: "shannonWiener",
17
41
  downsampling: {
18
42
  type: "hypergeometric",
19
43
  valueChooser: "auto"
20
- }
44
+ },
45
+ isExpanded: false
21
46
  },
22
47
  {
48
+ id: "chao1",
23
49
  type: "chao1",
24
50
  downsampling: {
25
51
  type: "hypergeometric",
26
52
  valueChooser: "auto"
27
- }
53
+ },
54
+ isExpanded: false
28
55
  },
29
56
  {
57
+ id: "gini",
30
58
  type: "gini",
31
59
  downsampling: {
32
60
  type: "hypergeometric",
33
61
  valueChooser: "auto"
34
- }
62
+ },
63
+ isExpanded: false
35
64
  },
36
65
  {
66
+ id: "d50",
37
67
  type: "d50",
38
68
  downsampling: {
39
69
  type: "hypergeometric",
40
70
  valueChooser: "auto"
41
- }
71
+ },
72
+ isExpanded: false
42
73
  }
43
74
  ]
44
- }).withUiState({
45
- blockTitle: "Repertoire Diversity",
46
- graphState: {
47
- title: "Repertoire Diversity",
48
- template: "bar",
49
- currentTab: null
50
- },
51
- tableState: {
52
- gridState: {},
53
- pTableParams: {
54
- sorting: [],
55
- filters: []
56
- }
57
- }
58
75
  }).argsValid((ctx) => ctx.args.abundanceRef !== void 0).output(
59
76
  "abundanceOptions",
60
77
  (ctx) => ctx.resultPool.getOptions([
@@ -75,7 +92,7 @@ var model = model$1.BlockModel.create().withArgs({
75
92
  if (pCols === void 0) {
76
93
  return void 0;
77
94
  }
78
- return model$1.createPlDataTable(ctx, pCols, ctx.uiState?.tableState);
95
+ return model$1.createPlDataTableV2(ctx, pCols, ctx.uiState.tableState);
79
96
  }).output("pf", (ctx) => {
80
97
  const pCols = ctx.outputs?.resolve("pf")?.getPColumns();
81
98
  if (pCols === void 0) {
@@ -98,6 +115,7 @@ var model = model$1.BlockModel.create().withArgs({
98
115
  { type: "link", href: "/diversityGraph", label: "Diversity Graph" }
99
116
  ]).done();
100
117
 
118
+ exports.convertMetricsUiToArgs = convertMetricsUiToArgs;
101
119
  exports.model = model;
102
120
  //# sourceMappingURL=index.cjs.map
103
121
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["BlockModel","createPlDataTable","createPFrameForGraphs"],"mappings":";;;;;AA4BO,IAAM,KAAQ,GAAAA,kBAAA,CAAW,MAAO,EAAA,CAEpC,QAAoB,CAAA;AAAA,EACnB,OAAS,EAAA;AAAA,IACP;AAAA,MACE,IAAM,EAAA,UAAA;AAAA,MACN,YAAc,EAAA;AAAA,QACZ,IAAM,EAAA,gBAAA;AAAA,QACN,YAAc,EAAA;AAAA;AAChB,KACF;AAAA,IACA;AAAA,MACE,IAAM,EAAA,eAAA;AAAA,MACN,YAAc,EAAA;AAAA,QACZ,IAAM,EAAA,gBAAA;AAAA,QACN,YAAc,EAAA;AAAA;AAChB,KACF;AAAA,IACA;AAAA,MACE,IAAM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,OAAO,iBAAkB;AACpE,CAAC,EAEA,IAAK","file":"index.cjs","sourcesContent":["import type { GraphMakerState } from '@milaboratories/graph-maker';\nimport type { InferOutputsType, PColumnIdAndSpec, PlDataTableState, PlRef } from '@platforma-sdk/model';\nimport { BlockModel, createPFrameForGraphs, createPlDataTable } from '@platforma-sdk/model';\n\nexport type DiversityType = 'chao1' | 'd50' | 'efronThisted' |\n 'observed' | 'shannonWienerIndex' | 'shannonWiener' |\n 'normalizedShannonWiener' | 'inverseSimpson' | 'gini';\n\nexport type Metric = {\n type: DiversityType | undefined;\n downsampling: {\n type?: 'none' | 'top' | 'cumtop' | 'hypergeometric' ;\n valueChooser?: 'min' | 'fixed' | 'max' | 'auto';\n n?: number;\n };\n};\n\nexport type BlockArgs = {\n abundanceRef?: PlRef;\n metrics: Metric[];\n};\n\nexport type UiState = {\n blockTitle: string;\n tableState?: PlDataTableState;\n graphState: GraphMakerState;\n};\n\nexport const model = BlockModel.create()\n\n .withArgs<BlockArgs>({\n metrics: [\n {\n type: 'observed',\n downsampling: {\n type: 'hypergeometric',\n valueChooser: 'auto',\n },\n },\n {\n type: 'shannonWiener',\n downsampling: {\n type: 'hypergeometric',\n valueChooser: 'auto',\n },\n },\n {\n type: 'chao1',\n downsampling: {\n type: 'hypergeometric',\n valueChooser: 'auto',\n },\n },\n {\n type: 'gini',\n downsampling: {\n type: 'hypergeometric',\n valueChooser: 'auto',\n },\n },\n {\n type: 'd50',\n downsampling: {\n type: 'hypergeometric',\n valueChooser: 'auto',\n },\n },\n ],\n })\n\n .withUiState<UiState>({\n blockTitle: 'Repertoire Diversity',\n graphState: {\n title: 'Repertoire Diversity',\n template: 'bar',\n currentTab: null,\n },\n\n tableState: {\n gridState: {},\n pTableParams: {\n sorting: [],\n filters: [],\n },\n },\n })\n\n .argsValid((ctx) => ctx.args.abundanceRef !== undefined)\n\n .output('abundanceOptions', (ctx) =>\n ctx.resultPool.getOptions([{\n axes: [\n { name: 'pl7.app/sampleId' },\n { },\n ],\n annotations: {\n 'pl7.app/isAbundance': 'true',\n 'pl7.app/abundance/normalized': 'false',\n 'pl7.app/abundance/isPrimary': 'true',\n },\n },\n ]),\n )\n\n .output('pt', (ctx) => {\n const pCols = ctx.outputs?.resolve('pf')?.getPColumns();\n if (pCols === undefined) {\n return undefined;\n }\n\n return createPlDataTable(ctx, pCols, ctx.uiState?.tableState);\n })\n\n .output('pf', (ctx) => {\n const pCols = ctx.outputs?.resolve('pf')?.getPColumns();\n if (pCols === undefined) {\n return undefined;\n }\n\n return createPFrameForGraphs(ctx, pCols);\n })\n\n // Return a list of Pcols for plot defaults\n .output('pcols', (ctx) => {\n const pCols = ctx.outputs?.resolve('pf')?.getPColumns();\n\n if (pCols === undefined || pCols.length === 0) {\n return undefined;\n }\n\n return pCols.map(\n (c) =>\n ({\n columnId: c.id,\n spec: c.spec,\n } satisfies PColumnIdAndSpec),\n );\n })\n\n .output('isRunning', (ctx) => ctx.outputs?.getIsReadyOrError() === false)\n\n .title((ctx) => ctx.uiState?.blockTitle ?? 'Repertoire Diversity')\n\n .sections((_) => [\n { type: 'link', href: '/', label: 'Main' },\n { type: 'link', href: '/diversityGraph', label: 'Diversity Graph' },\n ])\n\n .done();\n\nexport type BlockOutputs = InferOutputsType<typeof model>;\n"]}
1
+ {"version":3,"sources":["../src/converters.ts","../src/index.ts"],"names":["BlockModel","createPlDataTableStateV2","createPlDataTableV2","createPFrameForGraphs"],"mappings":";;;;;;;AAEa,IAAA,sBAAA,GAAyB,CAAC,OAAkC,KAAA;AACvE,EAAO,OAAA,OAAA,CAAQ,GAAI,CAAA,CAAC,MAAmB,KAAA;AACrC,IAAO,OAAA;AAAA,MACL,MAAM,MAAO,CAAA,IAAA;AAAA,MACb,cAAc,MAAO,CAAA;AAAA,KACvB;AAAA,GACD,CAAA;AACH;;;AC2BO,IAAM,KAAQ,GAAAA,kBAAA,CAAW,MAAO,EAAA,CACpC,QAAoB,CAAA;AAAA,EACnB,SAAS;AACX,CAAC,EAEA,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AAO,KAAM,CAAA,GAAA;AAAA,IACX,CAAC,CACE,MAAA;AAAA,MACC,UAAU,CAAE,CAAA,EAAA;AAAA,MACZ,MAAM,CAAE,CAAA;AAAA,KACV;AAAA,GACJ;AACF,CAAC,CAAA,CAEA,OAAO,WAAa,EAAA,CAAC,QAAQ,GAAI,CAAA,OAAA,EAAS,mBAAwB,KAAA,KAAK,EAEvE,KAAM,CAAA,CAAC,QAAQ,GAAI,CAAA,OAAA,EAAS,cAAc,sBAAsB,CAAA,CAEhE,QAAS,CAAA,CAAC,CAAM,KAAA;AAAA,EACf,EAAE,IAAM,EAAA,MAAA,EAAQ,IAAM,EAAA,GAAA,EAAK,OAAO,MAAO,EAAA;AAAA,EACzC,EAAE,IAAM,EAAA,MAAA,EAAQ,IAAM,EAAA,iBAAA,EAAmB,OAAO,iBAAkB;AACpE,CAAC,EAEA,IAAK","file":"index.cjs","sourcesContent":["import type { Metric, MetricUI } from './index';\n\nexport const convertMetricsUiToArgs = (metrics: MetricUI[]): Metric[] => {\n return metrics.map((metric): Metric => {\n return {\n type: metric.type,\n downsampling: metric.downsampling,\n };\n });\n};\n","import type { GraphMakerState } from '@milaboratories/graph-maker';\nimport type { InferOutputsType, PColumnIdAndSpec, PlDataTableStateV2, PlRef } from '@platforma-sdk/model';\nimport { BlockModel, createPFrameForGraphs, createPlDataTableStateV2, createPlDataTableV2 } from '@platforma-sdk/model';\n\nexport * from './converters';\n\nexport type DiversityType = 'chao1' | 'd50' | 'efronThisted' |\n 'observed' | 'shannonWienerIndex' | 'shannonWiener' |\n 'normalizedShannonWiener' | 'inverseSimpson' | 'gini';\n\nexport type Metric = {\n type: DiversityType | undefined;\n downsampling: {\n type?: 'none' | 'top' | 'cumtop' | 'hypergeometric' ;\n valueChooser?: 'min' | 'fixed' | 'max' | 'auto';\n n?: number;\n };\n};\n\nexport type MetricUI = Metric & {\n id: string;\n isExpanded?: boolean;\n};\n\nexport type BlockArgs = {\n abundanceRef?: PlRef;\n metrics: Metric[];\n};\n\nexport type UiState = {\n metrics: MetricUI[];\n blockTitle: string;\n tableState: PlDataTableStateV2;\n graphState: GraphMakerState;\n};\n\nexport const model = BlockModel.create()\n .withArgs<BlockArgs>({\n metrics: [],\n })\n\n .withUiState<UiState>({\n blockTitle: 'Repertoire Diversity',\n graphState: {\n title: 'Repertoire Diversity',\n template: 'bar',\n currentTab: null,\n },\n\n tableState: createPlDataTableStateV2(),\n\n metrics: [\n {\n id: 'observed',\n type: 'observed',\n downsampling: {\n type: 'hypergeometric',\n valueChooser: 'auto',\n },\n isExpanded: false,\n },\n {\n id: 'shannonWiener',\n type: 'shannonWiener',\n downsampling: {\n type: 'hypergeometric',\n valueChooser: 'auto',\n },\n isExpanded: false,\n },\n {\n id: 'chao1',\n type: 'chao1',\n downsampling: {\n type: 'hypergeometric',\n valueChooser: 'auto',\n },\n isExpanded: false,\n },\n {\n id: 'gini',\n type: 'gini',\n downsampling: {\n type: 'hypergeometric',\n valueChooser: 'auto',\n },\n isExpanded: false,\n },\n {\n id: 'd50',\n type: 'd50',\n downsampling: {\n type: 'hypergeometric',\n valueChooser: 'auto',\n },\n isExpanded: false,\n },\n ],\n })\n\n .argsValid((ctx) => ctx.args.abundanceRef !== undefined)\n\n .output('abundanceOptions', (ctx) =>\n ctx.resultPool.getOptions([{\n axes: [\n { name: 'pl7.app/sampleId' },\n { },\n ],\n annotations: {\n 'pl7.app/isAbundance': 'true',\n 'pl7.app/abundance/normalized': 'false',\n 'pl7.app/abundance/isPrimary': 'true',\n },\n },\n ]),\n )\n\n .output('pt', (ctx) => {\n const pCols = ctx.outputs?.resolve('pf')?.getPColumns();\n if (pCols === undefined) {\n return undefined;\n }\n\n return createPlDataTableV2(ctx, pCols, ctx.uiState.tableState);\n })\n\n .output('pf', (ctx) => {\n const pCols = ctx.outputs?.resolve('pf')?.getPColumns();\n if (pCols === undefined) {\n return undefined;\n }\n\n return createPFrameForGraphs(ctx, pCols);\n })\n\n // Return a list of Pcols for plot defaults\n .output('pcols', (ctx) => {\n const pCols = ctx.outputs?.resolve('pf')?.getPColumns();\n\n if (pCols === undefined || pCols.length === 0) {\n return undefined;\n }\n\n return pCols.map(\n (c) =>\n ({\n columnId: c.id,\n spec: c.spec,\n } satisfies PColumnIdAndSpec),\n );\n })\n\n .output('isRunning', (ctx) => ctx.outputs?.getIsReadyOrError() === false)\n\n .title((ctx) => ctx.uiState?.blockTitle ?? 'Repertoire Diversity')\n\n .sections((_) => [\n { type: 'link', href: '/', label: 'Main' },\n { type: 'link', href: '/diversityGraph', label: 'Diversity Graph' },\n ])\n\n .done();\n\nexport type BlockOutputs = InferOutputsType<typeof model>;\n"]}
package/dist/index.d.cts CHANGED
@@ -1,7 +1,9 @@
1
1
  import * as _platforma_sdk_model from '@platforma-sdk/model';
2
- import { PlRef, PlDataTableState, InferOutputsType } from '@platforma-sdk/model';
2
+ import { PlRef, PlDataTableStateV2, InferOutputsType } from '@platforma-sdk/model';
3
3
  import { GraphMakerState } from '@milaboratories/graph-maker';
4
4
 
5
+ declare const convertMetricsUiToArgs: (metrics: MetricUI[]) => Metric[];
6
+
5
7
  type DiversityType = 'chao1' | 'd50' | 'efronThisted' | 'observed' | 'shannonWienerIndex' | 'shannonWiener' | 'normalizedShannonWiener' | 'inverseSimpson' | 'gini';
6
8
  type Metric = {
7
9
  type: DiversityType | undefined;
@@ -11,13 +13,18 @@ type Metric = {
11
13
  n?: number;
12
14
  };
13
15
  };
16
+ type MetricUI = Metric & {
17
+ id: string;
18
+ isExpanded?: boolean;
19
+ };
14
20
  type BlockArgs = {
15
21
  abundanceRef?: PlRef;
16
22
  metrics: Metric[];
17
23
  };
18
24
  type UiState = {
25
+ metrics: MetricUI[];
19
26
  blockTitle: string;
20
- tableState?: PlDataTableState;
27
+ tableState: PlDataTableStateV2;
21
28
  graphState: GraphMakerState;
22
29
  };
23
30
  declare const model: _platforma_sdk_model.Platforma<BlockArgs, {
@@ -30,7 +37,11 @@ declare const model: _platforma_sdk_model.Platforma<BlockArgs, {
30
37
  };
31
38
  readonly label: string;
32
39
  }[]>;
33
- pt: _platforma_sdk_model.ValueOrErrors<_platforma_sdk_model.PTableHandle | undefined>;
40
+ pt: _platforma_sdk_model.ValueOrErrors<{
41
+ sourceId: string | null;
42
+ fullTableHandle: _platforma_sdk_model.PTableHandle;
43
+ visibleTableHandle: _platforma_sdk_model.PTableHandle;
44
+ } | undefined>;
34
45
  pf: _platforma_sdk_model.ValueOrErrors<_platforma_sdk_model.PFrameHandle | undefined>;
35
46
  pcols: _platforma_sdk_model.ValueOrErrors<{
36
47
  columnId: _platforma_sdk_model.PObjectId;
@@ -62,4 +73,4 @@ declare const model: _platforma_sdk_model.Platforma<BlockArgs, {
62
73
  }, UiState, "/" | "/diversityGraph">;
63
74
  type BlockOutputs = InferOutputsType<typeof model>;
64
75
 
65
- export { type BlockArgs, type BlockOutputs, type DiversityType, type Metric, type UiState, model };
76
+ export { type BlockArgs, type BlockOutputs, type DiversityType, type Metric, type MetricUI, type UiState, convertMetricsUiToArgs, model };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import * as _platforma_sdk_model from '@platforma-sdk/model';
2
- import { PlRef, PlDataTableState, InferOutputsType } from '@platforma-sdk/model';
2
+ import { PlRef, PlDataTableStateV2, InferOutputsType } from '@platforma-sdk/model';
3
3
  import { GraphMakerState } from '@milaboratories/graph-maker';
4
4
 
5
+ declare const convertMetricsUiToArgs: (metrics: MetricUI[]) => Metric[];
6
+
5
7
  type DiversityType = 'chao1' | 'd50' | 'efronThisted' | 'observed' | 'shannonWienerIndex' | 'shannonWiener' | 'normalizedShannonWiener' | 'inverseSimpson' | 'gini';
6
8
  type Metric = {
7
9
  type: DiversityType | undefined;
@@ -11,13 +13,18 @@ type Metric = {
11
13
  n?: number;
12
14
  };
13
15
  };
16
+ type MetricUI = Metric & {
17
+ id: string;
18
+ isExpanded?: boolean;
19
+ };
14
20
  type BlockArgs = {
15
21
  abundanceRef?: PlRef;
16
22
  metrics: Metric[];
17
23
  };
18
24
  type UiState = {
25
+ metrics: MetricUI[];
19
26
  blockTitle: string;
20
- tableState?: PlDataTableState;
27
+ tableState: PlDataTableStateV2;
21
28
  graphState: GraphMakerState;
22
29
  };
23
30
  declare const model: _platforma_sdk_model.Platforma<BlockArgs, {
@@ -30,7 +37,11 @@ declare const model: _platforma_sdk_model.Platforma<BlockArgs, {
30
37
  };
31
38
  readonly label: string;
32
39
  }[]>;
33
- pt: _platforma_sdk_model.ValueOrErrors<_platforma_sdk_model.PTableHandle | undefined>;
40
+ pt: _platforma_sdk_model.ValueOrErrors<{
41
+ sourceId: string | null;
42
+ fullTableHandle: _platforma_sdk_model.PTableHandle;
43
+ visibleTableHandle: _platforma_sdk_model.PTableHandle;
44
+ } | undefined>;
34
45
  pf: _platforma_sdk_model.ValueOrErrors<_platforma_sdk_model.PFrameHandle | undefined>;
35
46
  pcols: _platforma_sdk_model.ValueOrErrors<{
36
47
  columnId: _platforma_sdk_model.PObjectId;
@@ -62,4 +73,4 @@ declare const model: _platforma_sdk_model.Platforma<BlockArgs, {
62
73
  }, UiState, "/" | "/diversityGraph">;
63
74
  type BlockOutputs = InferOutputsType<typeof model>;
64
75
 
65
- export { type BlockArgs, type BlockOutputs, type DiversityType, type Metric, type UiState, model };
76
+ export { type BlockArgs, type BlockOutputs, type DiversityType, type Metric, type MetricUI, type UiState, convertMetricsUiToArgs, model };
package/dist/index.js CHANGED
@@ -1,58 +1,75 @@
1
- import { BlockModel, createPlDataTable, createPFrameForGraphs } from '@platforma-sdk/model';
1
+ import { BlockModel, createPlDataTableStateV2, createPlDataTableV2, createPFrameForGraphs } from '@platforma-sdk/model';
2
+
3
+ // src/index.ts
4
+
5
+ // src/converters.ts
6
+ var convertMetricsUiToArgs = (metrics) => {
7
+ return metrics.map((metric) => {
8
+ return {
9
+ type: metric.type,
10
+ downsampling: metric.downsampling
11
+ };
12
+ });
13
+ };
2
14
 
3
15
  // src/index.ts
4
16
  var model = BlockModel.create().withArgs({
17
+ metrics: []
18
+ }).withUiState({
19
+ blockTitle: "Repertoire Diversity",
20
+ graphState: {
21
+ title: "Repertoire Diversity",
22
+ template: "bar",
23
+ currentTab: null
24
+ },
25
+ tableState: createPlDataTableStateV2(),
5
26
  metrics: [
6
27
  {
28
+ id: "observed",
7
29
  type: "observed",
8
30
  downsampling: {
9
31
  type: "hypergeometric",
10
32
  valueChooser: "auto"
11
- }
33
+ },
34
+ isExpanded: false
12
35
  },
13
36
  {
37
+ id: "shannonWiener",
14
38
  type: "shannonWiener",
15
39
  downsampling: {
16
40
  type: "hypergeometric",
17
41
  valueChooser: "auto"
18
- }
42
+ },
43
+ isExpanded: false
19
44
  },
20
45
  {
46
+ id: "chao1",
21
47
  type: "chao1",
22
48
  downsampling: {
23
49
  type: "hypergeometric",
24
50
  valueChooser: "auto"
25
- }
51
+ },
52
+ isExpanded: false
26
53
  },
27
54
  {
55
+ id: "gini",
28
56
  type: "gini",
29
57
  downsampling: {
30
58
  type: "hypergeometric",
31
59
  valueChooser: "auto"
32
- }
60
+ },
61
+ isExpanded: false
33
62
  },
34
63
  {
64
+ id: "d50",
35
65
  type: "d50",
36
66
  downsampling: {
37
67
  type: "hypergeometric",
38
68
  valueChooser: "auto"
39
- }
69
+ },
70
+ isExpanded: false
40
71
  }
41
72
  ]
42
- }).withUiState({
43
- blockTitle: "Repertoire Diversity",
44
- graphState: {
45
- title: "Repertoire Diversity",
46
- template: "bar",
47
- currentTab: null
48
- },
49
- tableState: {
50
- gridState: {},
51
- pTableParams: {
52
- sorting: [],
53
- filters: []
54
- }
55
- }
56
73
  }).argsValid((ctx) => ctx.args.abundanceRef !== void 0).output(
57
74
  "abundanceOptions",
58
75
  (ctx) => ctx.resultPool.getOptions([
@@ -73,7 +90,7 @@ var model = BlockModel.create().withArgs({
73
90
  if (pCols === void 0) {
74
91
  return void 0;
75
92
  }
76
- return createPlDataTable(ctx, pCols, ctx.uiState?.tableState);
93
+ return createPlDataTableV2(ctx, pCols, ctx.uiState.tableState);
77
94
  }).output("pf", (ctx) => {
78
95
  const pCols = ctx.outputs?.resolve("pf")?.getPColumns();
79
96
  if (pCols === void 0) {
@@ -96,6 +113,6 @@ var model = BlockModel.create().withArgs({
96
113
  { type: "link", href: "/diversityGraph", label: "Diversity Graph" }
97
114
  ]).done();
98
115
 
99
- export { model };
116
+ export { convertMetricsUiToArgs, model };
100
117
  //# sourceMappingURL=index.js.map
101
118
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AA4BO,IAAM,KAAQ,GAAA,UAAA,CAAW,MAAO,EAAA,CAEpC,QAAoB,CAAA;AAAA,EACnB,OAAS,EAAA;AAAA,IACP;AAAA,MACE,IAAM,EAAA,UAAA;AAAA,MACN,YAAc,EAAA;AAAA,QACZ,IAAM,EAAA,gBAAA;AAAA,QACN,YAAc,EAAA;AAAA;AAChB,KACF;AAAA,IACA;AAAA,MACE,IAAM,EAAA,eAAA;AAAA,MACN,YAAc,EAAA;AAAA,QACZ,IAAM,EAAA,gBAAA;AAAA,QACN,YAAc,EAAA;AAAA;AAChB,KACF;AAAA,IACA;AAAA,MACE,IAAM,EAAA,OAAA;AAAA,MACN,YAAc,EAAA;AAAA,QACZ,IAAM,EAAA,gBAAA;AAAA,QACN,YAAc,EAAA;AAAA;AAChB,KACF;AAAA,IACA;AAAA,MACE,IAAM,EAAA,MAAA;AAAA,MACN,YAAc,EAAA;AAAA,QACZ,IAAM,EAAA,gBAAA;AAAA,QACN,YAAc,EAAA;AAAA;AAChB,KACF;AAAA,IACA;AAAA,MACE,IAAM,EAAA,KAAA;AAAA,MACN,YAAc,EAAA;AAAA,QACZ,IAAM,EAAA,gBAAA;AAAA,QACN,YAAc,EAAA;AAAA;AAChB;AACF;AAEJ,CAAC,EAEA,WAAqB,CAAA;AAAA,EACpB,UAAY,EAAA,sBAAA;AAAA,EACZ,UAAY,EAAA;AAAA,IACV,KAAO,EAAA,sBAAA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AAA,CAAC,GAAQ,KAAA;AACxB,EAAA,MAAM,QAAQ,GAAI,CAAA,OAAA,EAAS,OAAQ,CAAA,IAAI,GAAG,WAAY,EAAA;AAEtD,EAAA,IAAI,KAAU,KAAA,MAAA,IAAa,KAAM,CAAA,MAAA,KAAW,CAAG,EAAA;AAC7C,IAAO,OAAA,MAAA;AAAA;AAGT,EAAA,OAAO,KAAM,CAAA,GAAA;AAAA,IACX,CAAC,CACE,MAAA;AAAA,MACC,UAAU,CAAE,CAAA,EAAA;AAAA,MACZ,MAAM,CAAE,CAAA;AAAA,KACV;AAAA,GACJ;AACF,CAAC,CAAA,CAEA,OAAO,WAAa,EAAA,CAAC,QAAQ,GAAI,CAAA,OAAA,EAAS,mBAAwB,KAAA,KAAK,EAEvE,KAAM,CAAA,CAAC,QAAQ,GAAI,CAAA,OAAA,EAAS,cAAc,sBAAsB,CAAA,CAEhE,QAAS,CAAA,CAAC,CAAM,KAAA;AAAA,EACf,EAAE,IAAM,EAAA,MAAA,EAAQ,IAAM,EAAA,GAAA,EAAK,OAAO,MAAO,EAAA;AAAA,EACzC,EAAE,IAAM,EAAA,MAAA,EAAQ,IAAM,EAAA,iBAAA,EAAmB,OAAO,iBAAkB;AACpE,CAAC,EAEA,IAAK","file":"index.js","sourcesContent":["import type { GraphMakerState } from '@milaboratories/graph-maker';\nimport type { InferOutputsType, PColumnIdAndSpec, PlDataTableState, PlRef } from '@platforma-sdk/model';\nimport { BlockModel, createPFrameForGraphs, createPlDataTable } from '@platforma-sdk/model';\n\nexport type DiversityType = 'chao1' | 'd50' | 'efronThisted' |\n 'observed' | 'shannonWienerIndex' | 'shannonWiener' |\n 'normalizedShannonWiener' | 'inverseSimpson' | 'gini';\n\nexport type Metric = {\n type: DiversityType | undefined;\n downsampling: {\n type?: 'none' | 'top' | 'cumtop' | 'hypergeometric' ;\n valueChooser?: 'min' | 'fixed' | 'max' | 'auto';\n n?: number;\n };\n};\n\nexport type BlockArgs = {\n abundanceRef?: PlRef;\n metrics: Metric[];\n};\n\nexport type UiState = {\n blockTitle: string;\n tableState?: PlDataTableState;\n graphState: GraphMakerState;\n};\n\nexport const model = BlockModel.create()\n\n .withArgs<BlockArgs>({\n metrics: [\n {\n type: 'observed',\n downsampling: {\n type: 'hypergeometric',\n valueChooser: 'auto',\n },\n },\n {\n type: 'shannonWiener',\n downsampling: {\n type: 'hypergeometric',\n valueChooser: 'auto',\n },\n },\n {\n type: 'chao1',\n downsampling: {\n type: 'hypergeometric',\n valueChooser: 'auto',\n },\n },\n {\n type: 'gini',\n downsampling: {\n type: 'hypergeometric',\n valueChooser: 'auto',\n },\n },\n {\n type: 'd50',\n downsampling: {\n type: 'hypergeometric',\n valueChooser: 'auto',\n },\n },\n ],\n })\n\n .withUiState<UiState>({\n blockTitle: 'Repertoire Diversity',\n graphState: {\n title: 'Repertoire Diversity',\n template: 'bar',\n currentTab: null,\n },\n\n tableState: {\n gridState: {},\n pTableParams: {\n sorting: [],\n filters: [],\n },\n },\n })\n\n .argsValid((ctx) => ctx.args.abundanceRef !== undefined)\n\n .output('abundanceOptions', (ctx) =>\n ctx.resultPool.getOptions([{\n axes: [\n { name: 'pl7.app/sampleId' },\n { },\n ],\n annotations: {\n 'pl7.app/isAbundance': 'true',\n 'pl7.app/abundance/normalized': 'false',\n 'pl7.app/abundance/isPrimary': 'true',\n },\n },\n ]),\n )\n\n .output('pt', (ctx) => {\n const pCols = ctx.outputs?.resolve('pf')?.getPColumns();\n if (pCols === undefined) {\n return undefined;\n }\n\n return createPlDataTable(ctx, pCols, ctx.uiState?.tableState);\n })\n\n .output('pf', (ctx) => {\n const pCols = ctx.outputs?.resolve('pf')?.getPColumns();\n if (pCols === undefined) {\n return undefined;\n }\n\n return createPFrameForGraphs(ctx, pCols);\n })\n\n // Return a list of Pcols for plot defaults\n .output('pcols', (ctx) => {\n const pCols = ctx.outputs?.resolve('pf')?.getPColumns();\n\n if (pCols === undefined || pCols.length === 0) {\n return undefined;\n }\n\n return pCols.map(\n (c) =>\n ({\n columnId: c.id,\n spec: c.spec,\n } satisfies PColumnIdAndSpec),\n );\n })\n\n .output('isRunning', (ctx) => ctx.outputs?.getIsReadyOrError() === false)\n\n .title((ctx) => ctx.uiState?.blockTitle ?? 'Repertoire Diversity')\n\n .sections((_) => [\n { type: 'link', href: '/', label: 'Main' },\n { type: 'link', href: '/diversityGraph', label: 'Diversity Graph' },\n ])\n\n .done();\n\nexport type BlockOutputs = InferOutputsType<typeof model>;\n"]}
1
+ {"version":3,"sources":["../src/converters.ts","../src/index.ts"],"names":[],"mappings":";;;;;AAEa,IAAA,sBAAA,GAAyB,CAAC,OAAkC,KAAA;AACvE,EAAO,OAAA,OAAA,CAAQ,GAAI,CAAA,CAAC,MAAmB,KAAA;AACrC,IAAO,OAAA;AAAA,MACL,MAAM,MAAO,CAAA,IAAA;AAAA,MACb,cAAc,MAAO,CAAA;AAAA,KACvB;AAAA,GACD,CAAA;AACH;;;AC2BO,IAAM,KAAQ,GAAA,UAAA,CAAW,MAAO,EAAA,CACpC,QAAoB,CAAA;AAAA,EACnB,SAAS;AACX,CAAC,EAEA,WAAqB,CAAA;AAAA,EACpB,UAAY,EAAA,sBAAA;AAAA,EACZ,UAAY,EAAA;AAAA,IACV,KAAO,EAAA,sBAAA;AAAA,IACP,QAAU,EAAA,KAAA;AAAA,IACV,UAAY,EAAA;AAAA,GACd;AAAA,EAEA,YAAY,wBAAyB,EAAA;AAAA,EAErC,OAAS,EAAA;AAAA,IACP;AAAA,MACE,EAAI,EAAA,UAAA;AAAA,MACJ,IAAM,EAAA,UAAA;AAAA,MACN,YAAc,EAAA;AAAA,QACZ,IAAM,EAAA,gBAAA;AAAA,QACN,YAAc,EAAA;AAAA,OAChB;AAAA,MACA,UAAY,EAAA;AAAA,KACd;AAAA,IACA;AAAA,MACE,EAAI,EAAA,eAAA;AAAA,MACJ,IAAM,EAAA,eAAA;AAAA,MACN,YAAc,EAAA;AAAA,QACZ,IAAM,EAAA,gBAAA;AAAA,QACN,YA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","sourcesContent":["import type { Metric, MetricUI } from './index';\n\nexport const convertMetricsUiToArgs = (metrics: MetricUI[]): Metric[] => {\n return metrics.map((metric): Metric => {\n return {\n type: metric.type,\n downsampling: metric.downsampling,\n };\n });\n};\n","import type { GraphMakerState } from '@milaboratories/graph-maker';\nimport type { InferOutputsType, PColumnIdAndSpec, PlDataTableStateV2, PlRef } from '@platforma-sdk/model';\nimport { BlockModel, createPFrameForGraphs, createPlDataTableStateV2, createPlDataTableV2 } from '@platforma-sdk/model';\n\nexport * from './converters';\n\nexport type DiversityType = 'chao1' | 'd50' | 'efronThisted' |\n 'observed' | 'shannonWienerIndex' | 'shannonWiener' |\n 'normalizedShannonWiener' | 'inverseSimpson' | 'gini';\n\nexport type Metric = {\n type: DiversityType | undefined;\n downsampling: {\n type?: 'none' | 'top' | 'cumtop' | 'hypergeometric' ;\n valueChooser?: 'min' | 'fixed' | 'max' | 'auto';\n n?: number;\n };\n};\n\nexport type MetricUI = Metric & {\n id: string;\n isExpanded?: boolean;\n};\n\nexport type BlockArgs = {\n abundanceRef?: PlRef;\n metrics: Metric[];\n};\n\nexport type UiState = {\n metrics: MetricUI[];\n blockTitle: string;\n tableState: PlDataTableStateV2;\n graphState: GraphMakerState;\n};\n\nexport const model = BlockModel.create()\n .withArgs<BlockArgs>({\n metrics: [],\n })\n\n .withUiState<UiState>({\n blockTitle: 'Repertoire Diversity',\n graphState: {\n title: 'Repertoire Diversity',\n template: 'bar',\n currentTab: null,\n },\n\n tableState: createPlDataTableStateV2(),\n\n metrics: [\n {\n id: 'observed',\n type: 'observed',\n downsampling: {\n type: 'hypergeometric',\n valueChooser: 'auto',\n },\n isExpanded: false,\n },\n {\n id: 'shannonWiener',\n type: 'shannonWiener',\n downsampling: {\n type: 'hypergeometric',\n valueChooser: 'auto',\n },\n isExpanded: false,\n },\n {\n id: 'chao1',\n type: 'chao1',\n downsampling: {\n type: 'hypergeometric',\n valueChooser: 'auto',\n },\n isExpanded: false,\n },\n {\n id: 'gini',\n type: 'gini',\n downsampling: {\n type: 'hypergeometric',\n valueChooser: 'auto',\n },\n isExpanded: false,\n },\n {\n id: 'd50',\n type: 'd50',\n downsampling: {\n type: 'hypergeometric',\n valueChooser: 'auto',\n },\n isExpanded: false,\n },\n ],\n })\n\n .argsValid((ctx) => ctx.args.abundanceRef !== undefined)\n\n .output('abundanceOptions', (ctx) =>\n ctx.resultPool.getOptions([{\n axes: [\n { name: 'pl7.app/sampleId' },\n { },\n ],\n annotations: {\n 'pl7.app/isAbundance': 'true',\n 'pl7.app/abundance/normalized': 'false',\n 'pl7.app/abundance/isPrimary': 'true',\n },\n },\n ]),\n )\n\n .output('pt', (ctx) => {\n const pCols = ctx.outputs?.resolve('pf')?.getPColumns();\n if (pCols === undefined) {\n return undefined;\n }\n\n return createPlDataTableV2(ctx, pCols, ctx.uiState.tableState);\n })\n\n .output('pf', (ctx) => {\n const pCols = ctx.outputs?.resolve('pf')?.getPColumns();\n if (pCols === undefined) {\n return undefined;\n }\n\n return createPFrameForGraphs(ctx, pCols);\n })\n\n // Return a list of Pcols for plot defaults\n .output('pcols', (ctx) => {\n const pCols = ctx.outputs?.resolve('pf')?.getPColumns();\n\n if (pCols === undefined || pCols.length === 0) {\n return undefined;\n }\n\n return pCols.map(\n (c) =>\n ({\n columnId: c.id,\n spec: c.spec,\n } satisfies PColumnIdAndSpec),\n );\n })\n\n .output('isRunning', (ctx) => ctx.outputs?.getIsReadyOrError() === false)\n\n .title((ctx) => ctx.uiState?.blockTitle ?? 'Repertoire Diversity')\n\n .sections((_) => [\n { type: 'link', href: '/', label: 'Main' },\n { type: 'link', href: '/diversityGraph', label: 'Diversity Graph' },\n ])\n\n .done();\n\nexport type BlockOutputs = InferOutputsType<typeof model>;\n"]}