@morscherlab/mint-sdk 1.0.0-rc.2 → 1.0.0-rc.4

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.
Files changed (178) hide show
  1. package/dist/components/AppSidebar.vue.d.ts +3 -3
  2. package/dist/components/ControlWorkspaceView.vue.d.ts +3 -3
  3. package/dist/components/DoseDesignWorkspaceView.vue.d.ts +1 -1
  4. package/dist/components/PluginWorkspaceView.vue.d.ts +3 -3
  5. package/dist/components/index.js +2 -2
  6. package/dist/{components-BhK-dW99.js → components-DafPc4rM.js} +3 -3
  7. package/dist/{components-BhK-dW99.js.map → components-DafPc4rM.js.map} +1 -1
  8. package/dist/composables/controlComponentBindings.d.ts +7 -0
  9. package/dist/composables/controlSchemaAdapters.d.ts +20 -0
  10. package/dist/composables/controlSchemaFormFields.d.ts +3 -0
  11. package/dist/composables/controlSchemaLayout.d.ts +7 -0
  12. package/dist/composables/controlSchemaNormalize.d.ts +15 -0
  13. package/dist/composables/controlSchemaUtils.d.ts +9 -0
  14. package/dist/composables/controlWorkspaceOptions.d.ts +2 -0
  15. package/dist/composables/index.js +3 -3
  16. package/dist/composables/useControlSchema.d.ts +4 -30
  17. package/dist/composables/useControlWorkspace.d.ts +5 -0
  18. package/dist/{composables-Bg7CFuNz.js → composables-BMkPQhVK.js} +2 -2
  19. package/dist/{composables-Bg7CFuNz.js.map → composables-BMkPQhVK.js.map} +1 -1
  20. package/dist/index.js +4 -4
  21. package/dist/install.js +2 -2
  22. package/dist/templates/adapters.d.ts +14 -47
  23. package/dist/templates/assayLookups.d.ts +3 -0
  24. package/dist/templates/assayMatrixAdapters.d.ts +6 -0
  25. package/dist/templates/assayMatrixBuilder.d.ts +2 -0
  26. package/dist/templates/assayNormalizers.d.ts +4 -0
  27. package/dist/templates/builderDefaults.d.ts +1 -0
  28. package/dist/templates/builderIdUtils.d.ts +4 -0
  29. package/dist/templates/builderPresetControls.d.ts +10 -0
  30. package/dist/templates/builderReadUtils.d.ts +8 -0
  31. package/dist/templates/builders.d.ts +26 -67
  32. package/dist/templates/calibrationCurveAdapters.d.ts +4 -0
  33. package/dist/templates/calibrationCurveBuilder.d.ts +2 -0
  34. package/dist/templates/calibrationNormalizers.d.ts +5 -0
  35. package/dist/templates/componentBindingCatalog.d.ts +25 -0
  36. package/dist/templates/componentBindingHelpers.d.ts +17 -0
  37. package/dist/templates/componentDoseResponseProps.d.ts +3 -0
  38. package/dist/templates/componentGenericProps.d.ts +8 -0
  39. package/dist/templates/componentPlateHelpers.d.ts +5 -0
  40. package/dist/templates/componentPlateMapProps.d.ts +3 -0
  41. package/dist/templates/componentPropsFactory.d.ts +3 -0
  42. package/dist/templates/componentQpcrPlateProps.d.ts +3 -0
  43. package/dist/templates/componentTargetResolvers.d.ts +5 -0
  44. package/dist/templates/componentTemplateProps.d.ts +3 -0
  45. package/dist/templates/controlSchemaClone.d.ts +4 -0
  46. package/dist/templates/controlSchemaConstants.d.ts +10 -0
  47. package/dist/templates/controlSchemaMerge.d.ts +3 -0
  48. package/dist/templates/controlSchemaTargets.d.ts +17 -0
  49. package/dist/templates/controlSchemaTypes.d.ts +4 -0
  50. package/dist/templates/controlSchemas.d.ts +4 -4
  51. package/dist/templates/defaultBioTemplateBuilder.d.ts +2 -0
  52. package/dist/templates/doseResponseAdapters.d.ts +4 -0
  53. package/dist/templates/doseResponseBuilder.d.ts +2 -0
  54. package/dist/templates/elisaAssayCollectionBuilder.d.ts +2 -0
  55. package/dist/templates/flowCytometryAssayCollectionBuilder.d.ts +2 -0
  56. package/dist/templates/flowCytometryPanelBuilder.d.ts +2 -0
  57. package/dist/templates/flowNormalizers.d.ts +8 -0
  58. package/dist/templates/flowPanelAdapters.d.ts +4 -0
  59. package/dist/templates/index.js +1 -1
  60. package/dist/templates/instrumentRunAdapterHelpers.d.ts +8 -0
  61. package/dist/templates/instrumentRunAdapters.d.ts +8 -0
  62. package/dist/templates/instrumentRunBuilder.d.ts +2 -0
  63. package/dist/templates/lcmsBatchCollectionBuilder.d.ts +2 -0
  64. package/dist/templates/plateGeometry.d.ts +4 -0
  65. package/dist/templates/plateMapAdapters.d.ts +3 -0
  66. package/dist/templates/plateMapBuilder.d.ts +2 -0
  67. package/dist/templates/presetControlSchemas.d.ts +534 -0
  68. package/dist/templates/protocolAdapters.d.ts +5 -0
  69. package/dist/templates/protocolNormalizers.d.ts +6 -0
  70. package/dist/templates/protocolStepsBuilder.d.ts +2 -0
  71. package/dist/templates/qpcrAdapters.d.ts +5 -0
  72. package/dist/templates/qpcrExpressionCollectionBuilder.d.ts +2 -0
  73. package/dist/templates/qpcrPlateBuilder.d.ts +2 -0
  74. package/dist/templates/reagentAdapters.d.ts +5 -0
  75. package/dist/templates/reagentListBuilder.d.ts +2 -0
  76. package/dist/templates/runNormalizers.d.ts +10 -0
  77. package/dist/templates/sampleNormalizers.d.ts +4 -0
  78. package/dist/templates/samplePrepAdapters.d.ts +4 -0
  79. package/dist/templates/samplePrepBuilder.d.ts +2 -0
  80. package/dist/templates/sampleSheetAdapters.d.ts +5 -0
  81. package/dist/templates/sampleSheetBuilder.d.ts +2 -0
  82. package/dist/templates/targetedMetabolomicsCollectionBuilder.d.ts +2 -0
  83. package/dist/templates/targetedMetabolomicsHelpers.d.ts +5 -0
  84. package/dist/templates/templateControlSchemas.d.ts +400 -0
  85. package/dist/templates/templateEnvelopes.d.ts +9 -0
  86. package/dist/templates/templatePackCollectionBuilder.d.ts +2 -0
  87. package/dist/templates/templatePresetCollectionBuilder.d.ts +18 -0
  88. package/dist/templates/templateValidators.d.ts +13 -0
  89. package/dist/templates/timeCourseAdapters.d.ts +5 -0
  90. package/dist/templates/timeCourseBuilder.d.ts +2 -0
  91. package/dist/templates/wellPlateScreenCollectionBuilder.d.ts +2 -0
  92. package/dist/templates/westernBlotAssayCollectionBuilder.d.ts +2 -0
  93. package/dist/{templates-BorLR_7p.js → templates-bUAWMn5L.js} +3574 -3428
  94. package/dist/templates-bUAWMn5L.js.map +1 -0
  95. package/dist/{useProtocolTemplates-n6AJqSqv.js → useProtocolTemplates-QZtHFFH2.js} +2 -2
  96. package/dist/{useProtocolTemplates-n6AJqSqv.js.map → useProtocolTemplates-QZtHFFH2.js.map} +1 -1
  97. package/package.json +1 -1
  98. package/src/composables/controlComponentBindings.ts +80 -0
  99. package/src/composables/controlSchemaAdapters.ts +196 -0
  100. package/src/composables/controlSchemaFormFields.ts +61 -0
  101. package/src/composables/controlSchemaLayout.ts +59 -0
  102. package/src/composables/controlSchemaNormalize.ts +101 -0
  103. package/src/composables/controlSchemaUtils.ts +36 -0
  104. package/src/composables/controlWorkspaceOptions.ts +21 -0
  105. package/src/composables/useControlSchema.ts +51 -628
  106. package/src/composables/useControlWorkspace.ts +207 -0
  107. package/src/templates/adapters.ts +89 -930
  108. package/src/templates/assayLookups.ts +33 -0
  109. package/src/templates/assayMatrixAdapters.ts +78 -0
  110. package/src/templates/assayMatrixBuilder.ts +59 -0
  111. package/src/templates/assayNormalizers.ts +34 -0
  112. package/src/templates/builderDefaults.ts +11 -0
  113. package/src/templates/builderIdUtils.ts +20 -0
  114. package/src/templates/builderPresetControls.ts +165 -0
  115. package/src/templates/builderReadUtils.ts +57 -0
  116. package/src/templates/builders.ts +122 -2350
  117. package/src/templates/calibrationCurveAdapters.ts +59 -0
  118. package/src/templates/calibrationCurveBuilder.ts +99 -0
  119. package/src/templates/calibrationNormalizers.ts +60 -0
  120. package/src/templates/componentBindingCatalog.ts +90 -0
  121. package/src/templates/componentBindingHelpers.ts +93 -0
  122. package/src/templates/componentBindings.ts +12 -461
  123. package/src/templates/componentDoseResponseProps.ts +42 -0
  124. package/src/templates/componentGenericProps.ts +77 -0
  125. package/src/templates/componentPlateHelpers.ts +29 -0
  126. package/src/templates/componentPlateMapProps.ts +32 -0
  127. package/src/templates/componentPropsFactory.ts +21 -0
  128. package/src/templates/componentQpcrPlateProps.ts +28 -0
  129. package/src/templates/componentTargetResolvers.ts +69 -0
  130. package/src/templates/componentTemplateProps.ts +78 -0
  131. package/src/templates/controlSchemaClone.ts +32 -0
  132. package/src/templates/controlSchemaConstants.ts +11 -0
  133. package/src/templates/controlSchemaMerge.ts +40 -0
  134. package/src/templates/controlSchemaTargets.ts +87 -0
  135. package/src/templates/controlSchemaTypes.ts +20 -0
  136. package/src/templates/controlSchemas.ts +22 -704
  137. package/src/templates/defaultBioTemplateBuilder.ts +124 -0
  138. package/src/templates/doseResponseAdapters.ts +45 -0
  139. package/src/templates/doseResponseBuilder.ts +44 -0
  140. package/src/templates/elisaAssayCollectionBuilder.ts +62 -0
  141. package/src/templates/flowCytometryAssayCollectionBuilder.ts +41 -0
  142. package/src/templates/flowCytometryPanelBuilder.ts +53 -0
  143. package/src/templates/flowNormalizers.ts +58 -0
  144. package/src/templates/flowPanelAdapters.ts +58 -0
  145. package/src/templates/instrumentRunAdapterHelpers.ts +94 -0
  146. package/src/templates/instrumentRunAdapters.ts +163 -0
  147. package/src/templates/instrumentRunBuilder.ts +97 -0
  148. package/src/templates/lcmsBatchCollectionBuilder.ts +38 -0
  149. package/src/templates/plateGeometry.ts +62 -0
  150. package/src/templates/plateMapAdapters.ts +36 -0
  151. package/src/templates/plateMapBuilder.ts +43 -0
  152. package/src/templates/presetControlSchemas.ts +258 -0
  153. package/src/templates/protocolAdapters.ts +69 -0
  154. package/src/templates/protocolNormalizers.ts +37 -0
  155. package/src/templates/protocolStepsBuilder.ts +36 -0
  156. package/src/templates/qpcrAdapters.ts +104 -0
  157. package/src/templates/qpcrExpressionCollectionBuilder.ts +33 -0
  158. package/src/templates/qpcrPlateBuilder.ts +96 -0
  159. package/src/templates/reagentAdapters.ts +77 -0
  160. package/src/templates/reagentListBuilder.ts +30 -0
  161. package/src/templates/runNormalizers.ts +63 -0
  162. package/src/templates/sampleNormalizers.ts +58 -0
  163. package/src/templates/samplePrepAdapters.ts +63 -0
  164. package/src/templates/samplePrepBuilder.ts +51 -0
  165. package/src/templates/sampleSheetAdapters.ts +75 -0
  166. package/src/templates/sampleSheetBuilder.ts +23 -0
  167. package/src/templates/targetedMetabolomicsCollectionBuilder.ts +79 -0
  168. package/src/templates/targetedMetabolomicsHelpers.ts +102 -0
  169. package/src/templates/templateControlSchemas.ts +320 -0
  170. package/src/templates/templateEnvelopes.ts +137 -0
  171. package/src/templates/templatePackCollectionBuilder.ts +23 -0
  172. package/src/templates/templatePresetCollectionBuilder.ts +139 -0
  173. package/src/templates/templateValidators.ts +414 -0
  174. package/src/templates/timeCourseAdapters.ts +73 -0
  175. package/src/templates/timeCourseBuilder.ts +64 -0
  176. package/src/templates/wellPlateScreenCollectionBuilder.ts +36 -0
  177. package/src/templates/westernBlotAssayCollectionBuilder.ts +68 -0
  178. package/dist/templates-BorLR_7p.js.map +0 -1
@@ -0,0 +1,51 @@
1
+ import { idFromName } from './builderIdUtils'
2
+ import { normalizeSamplePrepStep } from './sampleNormalizers'
3
+ import { createTemplateEnvelope } from './templateEnvelopes'
4
+ import { validateSamplePrepData } from './templateValidators'
5
+ import type {
6
+ CreateSamplePrepTemplateOptions,
7
+ SamplePrepStep,
8
+ SamplePrepTemplate,
9
+ SamplePrepTemplateData,
10
+ } from './types'
11
+
12
+ export function createSamplePrepTemplate(
13
+ options: CreateSamplePrepTemplateOptions
14
+ ): SamplePrepTemplate {
15
+ const prepType = options.prepType ?? 'extraction'
16
+ const volumeUnit = options.volumeUnit ?? 'uL'
17
+ const steps: SamplePrepStep[] = []
18
+ let order = 1
19
+
20
+ for (const [index, sample] of options.samples.entries()) {
21
+ if (typeof sample !== 'string') {
22
+ const step = normalizeSamplePrepStep(sample, prepType, volumeUnit, order, index)
23
+ steps.push(step)
24
+ order = Math.max(order, step.order + 1)
25
+ continue
26
+ }
27
+ const sourceSampleId = idFromName(sample, `sample-${index + 1}`)
28
+ steps.push({
29
+ id: `${sourceSampleId}-prep`,
30
+ order,
31
+ type: prepType,
32
+ name: `Prepare ${sample}`,
33
+ sourceSampleId,
34
+ destinationSampleId: `${sourceSampleId}-prepared`,
35
+ inputVolume: options.inputVolume,
36
+ outputVolume: options.outputVolume,
37
+ volumeUnit,
38
+ status: 'planned',
39
+ metadata: {},
40
+ })
41
+ order += 1
42
+ }
43
+
44
+ const data: SamplePrepTemplateData = {
45
+ protocolName: options.protocolName ?? 'Sample preparation',
46
+ steps,
47
+ metadata: options.metadata ?? {},
48
+ }
49
+ validateSamplePrepData(data)
50
+ return createTemplateEnvelope('sample-prep', data, options.metadata ?? {})
51
+ }
@@ -0,0 +1,75 @@
1
+ import type {
2
+ DataFrameColumn,
3
+ SelectOption,
4
+ } from '../types'
5
+ import { getTemplateData } from './templateEnvelopes'
6
+ import { validateSampleSheetData } from './templateValidators'
7
+ import type {
8
+ SampleColumnsAdapterResult,
9
+ SampleDataFrameAdapterResult,
10
+ SampleOptionsAdapterResult,
11
+ SampleRowsAdapterResult,
12
+ SampleSheetTemplate,
13
+ SampleSheetTemplateData,
14
+ } from './types'
15
+
16
+ export function toSampleRows(
17
+ template: SampleSheetTemplate | SampleSheetTemplateData
18
+ ): SampleRowsAdapterResult {
19
+ const data = getTemplateData(template, 'sample-sheet')
20
+ validateSampleSheetData(data)
21
+ return data.samples.map(sample => ({
22
+ sampleId: sample.sampleId,
23
+ name: sample.name,
24
+ group: sample.group,
25
+ batch: sample.batch,
26
+ replicate: sample.replicate,
27
+ plateId: sample.plateId,
28
+ wellId: sample.wellId,
29
+ ...(sample.metadata ?? {}),
30
+ }))
31
+ }
32
+
33
+ export function toSampleColumns(
34
+ template: SampleSheetTemplate | SampleSheetTemplateData
35
+ ): SampleColumnsAdapterResult {
36
+ const data = getTemplateData(template, 'sample-sheet')
37
+ validateSampleSheetData(data)
38
+ return data.columns.map((column): DataFrameColumn<Record<string, unknown>> => ({
39
+ key: sampleColumnKey(column.id),
40
+ label: column.label,
41
+ sortable: true,
42
+ align: column.type === 'number' || column.type === 'integer' ? 'right' : 'left',
43
+ }))
44
+ }
45
+
46
+ export function toSampleDataFrame(
47
+ template: SampleSheetTemplate | SampleSheetTemplateData
48
+ ): SampleDataFrameAdapterResult {
49
+ return {
50
+ data: toSampleRows(template),
51
+ columns: toSampleColumns(template),
52
+ rowKey: 'sampleId',
53
+ }
54
+ }
55
+
56
+ export function toSampleOptions(
57
+ template: SampleSheetTemplate | SampleSheetTemplateData
58
+ ): SampleOptionsAdapterResult {
59
+ const data = getTemplateData(template, 'sample-sheet')
60
+ validateSampleSheetData(data)
61
+ return data.samples.map((sample): SelectOption<string> => ({
62
+ value: sample.sampleId,
63
+ label: sample.name ?? sample.sampleId,
64
+ description: [sample.group, sample.batch].filter(Boolean).join(' / ') || undefined,
65
+ }))
66
+ }
67
+
68
+ function sampleColumnKey(columnId: string): string {
69
+ const aliases: Record<string, string> = {
70
+ sample_id: 'sampleId',
71
+ plate_id: 'plateId',
72
+ well_id: 'wellId',
73
+ }
74
+ return aliases[columnId] ?? columnId
75
+ }
@@ -0,0 +1,23 @@
1
+ import { normalizeSampleRecord } from './sampleNormalizers'
2
+ import { createTemplateEnvelope } from './templateEnvelopes'
3
+ import { validateSampleSheetData } from './templateValidators'
4
+ import type {
5
+ CreateSampleSheetTemplateOptions,
6
+ SampleSheetTemplate,
7
+ SampleSheetTemplateData,
8
+ } from './types'
9
+
10
+ export function createSampleSheetTemplate(
11
+ options: CreateSampleSheetTemplateOptions
12
+ ): SampleSheetTemplate {
13
+ const data: SampleSheetTemplateData = {
14
+ samples: options.samples.map(normalizeSampleRecord),
15
+ columns: options.columns ?? [
16
+ { id: 'sampleId', label: 'Sample ID', type: 'string', required: true, groupable: false },
17
+ { id: 'name', label: 'Name', type: 'string', required: false, groupable: false },
18
+ ],
19
+ groups: options.groups ?? [],
20
+ }
21
+ validateSampleSheetData(data)
22
+ return createTemplateEnvelope('sample-sheet', data, options.metadata ?? {})
23
+ }
@@ -0,0 +1,79 @@
1
+ import { createAssayMatrixTemplate } from './assayMatrixBuilder'
2
+ import { createCalibrationCurveTemplate } from './calibrationCurveBuilder'
3
+ import { createInstrumentRunTemplate } from './instrumentRunBuilder'
4
+ import { createReagentListTemplate } from './reagentListBuilder'
5
+ import { createSamplePrepTemplate } from './samplePrepBuilder'
6
+ import { createSampleSheetTemplate } from './sampleSheetBuilder'
7
+ import { presetSampleRecords } from './sampleNormalizers'
8
+ import {
9
+ firstFeatureName,
10
+ normalizeInternalStandardReagents,
11
+ normalizeMetaboliteFeatures,
12
+ targetedMetabolomicsRunItems,
13
+ } from './targetedMetabolomicsHelpers'
14
+ import { createTemplateCollection } from './templateEnvelopes'
15
+ import type {
16
+ CreateTargetedMetabolomicsCollectionOptions,
17
+ TemplateCollectionEnvelope,
18
+ } from './types'
19
+
20
+ export function createTargetedMetabolomicsCollection(
21
+ options: CreateTargetedMetabolomicsCollectionOptions = {}
22
+ ): TemplateCollectionEnvelope {
23
+ const sampleRecords = presetSampleRecords(options.samples ?? ['S001', 'S002'])
24
+ const responseUnit = options.responseUnit ?? 'peak area ratio'
25
+ const concentrationUnit = options.concentrationUnit ?? 'uM'
26
+ const metaboliteFeatures = normalizeMetaboliteFeatures(
27
+ options.metabolites ?? ['Glucose', 'Lactate', 'Pyruvate'],
28
+ responseUnit,
29
+ )
30
+ const sampleSheet = createSampleSheetTemplate({ samples: sampleRecords })
31
+ const samplePrep = createSamplePrepTemplate({
32
+ samples: sampleRecords.map(sample => sample.sampleId),
33
+ prepType: options.prepType ?? 'extraction',
34
+ protocolName: 'Metabolomics sample preparation',
35
+ outputVolume: options.outputVolume ?? 50,
36
+ metadata: { assay: 'targeted-metabolomics' },
37
+ })
38
+ const reagents = createReagentListTemplate({
39
+ reagents: normalizeInternalStandardReagents(
40
+ options.internalStandards ?? ['Stable isotope internal standard mix'],
41
+ ),
42
+ metadata: { assay: 'targeted-metabolomics' },
43
+ })
44
+ const calibrationCurve = createCalibrationCurveTemplate({
45
+ concentrations: options.standardConcentrations ?? [0.1, 1, 10, 100],
46
+ analyte: options.calibrationAnalyte ?? firstFeatureName(metaboliteFeatures, 'Metabolite panel'),
47
+ unit: concentrationUnit,
48
+ responseUnit,
49
+ model: 'linear-weighted-1-x',
50
+ includeQc: options.includeQc,
51
+ metadata: { assay: 'targeted-metabolomics' },
52
+ })
53
+ const instrumentRun = createInstrumentRunTemplate({
54
+ items: targetedMetabolomicsRunItems(
55
+ sampleRecords,
56
+ calibrationCurve.data.points,
57
+ options.includeQc !== false,
58
+ ),
59
+ method: options.method ?? 'Targeted metabolomics',
60
+ instrument: options.instrument ?? 'LC-MS',
61
+ includeBlanks: false,
62
+ includeQc: false,
63
+ metadata: { assay: 'targeted-metabolomics' },
64
+ })
65
+ const assayMatrix = createAssayMatrixTemplate({
66
+ samples: sampleRecords.map(sample => ({
67
+ sampleId: sample.sampleId,
68
+ name: sample.name,
69
+ group: sample.group,
70
+ metadata: sample.metadata ?? {},
71
+ })),
72
+ features: metaboliteFeatures,
73
+ metadata: { assay: 'targeted-metabolomics', responseUnit },
74
+ })
75
+ return createTemplateCollection(
76
+ [sampleSheet, samplePrep, reagents, instrumentRun, calibrationCurve, assayMatrix],
77
+ { preset: 'targeted-metabolomics', ...(options.metadata ?? {}) }
78
+ )
79
+ }
@@ -0,0 +1,102 @@
1
+ import type {
2
+ AssayFeature,
3
+ CalibrationPoint,
4
+ InstrumentRunItemInput,
5
+ ReagentTemplateInput,
6
+ SampleRecord,
7
+ } from './types'
8
+ import {
9
+ normalizeAssayFeature,
10
+ normalizeReagent,
11
+ } from './assayNormalizers'
12
+ import { idFromName } from './builderIdUtils'
13
+
14
+ export function normalizeMetaboliteFeatures(
15
+ metabolites: Array<string | AssayFeature>,
16
+ responseUnit: string,
17
+ ): AssayFeature[] {
18
+ return metabolites.map((metabolite, index) => {
19
+ if (typeof metabolite === 'string') {
20
+ return {
21
+ id: idFromName(metabolite, `metabolite-${index + 1}`),
22
+ name: metabolite,
23
+ type: 'metabolite',
24
+ unit: responseUnit,
25
+ metadata: { quantitation: 'targeted' },
26
+ }
27
+ }
28
+
29
+ const feature = normalizeAssayFeature(metabolite)
30
+ return {
31
+ ...feature,
32
+ type: feature.type ?? 'metabolite',
33
+ unit: feature.unit ?? responseUnit,
34
+ metadata: {
35
+ quantitation: 'targeted',
36
+ ...feature.metadata,
37
+ },
38
+ }
39
+ })
40
+ }
41
+
42
+ export function normalizeInternalStandardReagents(
43
+ internalStandards: Array<string | ReagentTemplateInput>,
44
+ ): ReagentTemplateInput[] {
45
+ return internalStandards.map((standard, index) => {
46
+ if (typeof standard === 'string') {
47
+ return {
48
+ id: idFromName(standard, `internal-standard-${index + 1}`),
49
+ name: standard,
50
+ kind: 'compound',
51
+ metadata: { role: 'internal-standard' },
52
+ }
53
+ }
54
+
55
+ const reagent = normalizeReagent(standard)
56
+ return {
57
+ ...reagent,
58
+ kind: standard.kind ?? 'compound',
59
+ metadata: {
60
+ role: 'internal-standard',
61
+ ...reagent.metadata,
62
+ },
63
+ }
64
+ })
65
+ }
66
+
67
+ export function targetedMetabolomicsRunItems(
68
+ samples: SampleRecord[],
69
+ calibrationPoints: CalibrationPoint[],
70
+ includeQc: boolean,
71
+ ): InstrumentRunItemInput[] {
72
+ const calibrationItems = calibrationPoints
73
+ .filter(point => point.role !== 'qc' || includeQc)
74
+ .filter(point => point.role === 'blank' || point.role === 'standard' || point.role === 'qc')
75
+ .map((point): InstrumentRunItemInput => ({
76
+ id: `${point.id}-run`,
77
+ kind: calibrationRunItemKind(point.role),
78
+ name: point.level,
79
+ metadata: {
80
+ concentration: point.concentration,
81
+ unit: point.unit,
82
+ role: point.role,
83
+ },
84
+ }))
85
+
86
+ const sampleItems = samples.map((sample): InstrumentRunItemInput => ({
87
+ sampleId: sample.sampleId,
88
+ name: sample.name ?? sample.sampleId,
89
+ kind: 'sample',
90
+ }))
91
+
92
+ return [...calibrationItems, ...sampleItems]
93
+ }
94
+
95
+ export function firstFeatureName(features: AssayFeature[], fallback: string): string {
96
+ return features.find(feature => feature.name)?.name ?? fallback
97
+ }
98
+
99
+ function calibrationRunItemKind(role: CalibrationPoint['role']): 'blank' | 'standard' | 'qc' {
100
+ if (role === 'blank' || role === 'standard' || role === 'qc') return role
101
+ return 'standard'
102
+ }
@@ -0,0 +1,320 @@
1
+ import {
2
+ CONCENTRATION_UNITS,
3
+ ICONS,
4
+ PLATE_FORMAT_OPTIONS,
5
+ } from './controlSchemaConstants'
6
+ import type {
7
+ BioTemplateControlSchema,
8
+ } from './controlSchemaTypes'
9
+ import type {
10
+ TemplateId,
11
+ } from './types'
12
+
13
+ export const templateControlSchemas = {
14
+ 'plate-map': {
15
+ plateName: {
16
+ label: 'Plate name',
17
+ default: 'Plate 1',
18
+ section: 'layout',
19
+ sectionLabel: 'Layout',
20
+ sectionSubtitle: 'Plate geometry',
21
+ view: 'design',
22
+ sidebar: { icon: ICONS.plate, iconColor: '#6366f1', iconBg: '#e0e7ff' },
23
+ },
24
+ plateFormat: {
25
+ label: 'Format',
26
+ default: 96,
27
+ options: PLATE_FORMAT_OPTIONS,
28
+ section: 'layout',
29
+ view: 'design',
30
+ },
31
+ sampleNames: {
32
+ type: 'tags',
33
+ label: 'Samples',
34
+ default: ['Control', 'Treatment'],
35
+ section: 'samples',
36
+ sectionLabel: 'Samples',
37
+ sectionSubtitle: 'Groups and legend',
38
+ view: 'design',
39
+ sidebar: { icon: ICONS.samples, iconColor: '#10b981', iconBg: '#d1fae5' },
40
+ },
41
+ },
42
+ 'sample-sheet': {
43
+ sampleCount: {
44
+ type: 'number',
45
+ label: 'Sample count',
46
+ default: 2,
47
+ min: 1,
48
+ max: 10000,
49
+ section: 'samples',
50
+ sectionLabel: 'Samples',
51
+ sectionSubtitle: 'Metadata table',
52
+ view: 'design',
53
+ sidebar: { icon: ICONS.samples, iconColor: '#10b981', iconBg: '#d1fae5' },
54
+ },
55
+ includeGroups: {
56
+ label: 'Include groups',
57
+ default: true,
58
+ section: 'samples',
59
+ view: 'design',
60
+ },
61
+ includeBatch: {
62
+ label: 'Include batch',
63
+ default: false,
64
+ section: 'columns',
65
+ sectionLabel: 'Columns',
66
+ view: 'design',
67
+ sidebar: { icon: ICONS.table, iconColor: '#0ea5e9', iconBg: '#e0f2fe' },
68
+ },
69
+ },
70
+ 'sample-prep': {
71
+ prepType: {
72
+ label: 'Prep type',
73
+ default: 'extraction',
74
+ options: ['extraction', 'dilution', 'normalization', 'transfer', 'quench', 'custom'],
75
+ section: 'protocol',
76
+ sectionLabel: 'Protocol',
77
+ sectionSubtitle: 'Prep workflow',
78
+ view: 'design',
79
+ sidebar: { icon: ICONS.run, iconColor: '#f97316', iconBg: '#ffedd5' },
80
+ },
81
+ volumeUnit: {
82
+ label: 'Volume unit',
83
+ default: 'uL',
84
+ options: ['uL', 'mL'],
85
+ section: 'protocol',
86
+ view: 'design',
87
+ },
88
+ outputVolume: {
89
+ type: 'number',
90
+ label: 'Output volume',
91
+ default: 50,
92
+ min: 0,
93
+ section: 'protocol',
94
+ view: 'design',
95
+ },
96
+ },
97
+ 'dose-response': {
98
+ unit: {
99
+ label: 'Dose unit',
100
+ default: 'uM',
101
+ options: CONCENTRATION_UNITS,
102
+ section: 'dose',
103
+ sectionLabel: 'Dose Design',
104
+ sectionSubtitle: 'Concentration series',
105
+ view: 'design',
106
+ sidebar: { icon: ICONS.dose, iconColor: '#8b5cf6', iconBg: '#ede9fe' },
107
+ },
108
+ replicates: {
109
+ type: 'number',
110
+ label: 'Replicates',
111
+ default: 3,
112
+ min: 1,
113
+ max: 24,
114
+ section: 'dose',
115
+ view: 'design',
116
+ },
117
+ includePlateLayout: {
118
+ label: 'Create plate layout',
119
+ default: true,
120
+ section: 'layout',
121
+ sectionLabel: 'Layout',
122
+ sectionSubtitle: 'Well assignment',
123
+ view: 'design',
124
+ sidebar: { icon: ICONS.plate, iconColor: '#6366f1', iconBg: '#e0e7ff', defaultOpen: false },
125
+ },
126
+ },
127
+ 'calibration-curve': {
128
+ analyte: {
129
+ label: 'Analyte',
130
+ default: 'Analyte',
131
+ section: 'standards',
132
+ sectionLabel: 'Standards',
133
+ sectionSubtitle: 'Curve setup',
134
+ view: 'analysis',
135
+ sidebar: { icon: ICONS.dose, iconColor: '#8b5cf6', iconBg: '#ede9fe' },
136
+ },
137
+ model: {
138
+ label: 'Model',
139
+ default: 'linear',
140
+ options: ['linear', 'linear-weighted-1-x', 'linear-weighted-1-x2', 'quadratic', 'four-parameter-logistic'],
141
+ section: 'fit',
142
+ sectionLabel: 'Fit',
143
+ view: 'analysis',
144
+ sidebar: { icon: ICONS.settings, iconColor: '#6366f1', iconBg: '#e0e7ff' },
145
+ },
146
+ minRSquared: {
147
+ type: 'number',
148
+ label: 'Minimum R squared',
149
+ default: 0.99,
150
+ min: 0,
151
+ max: 1,
152
+ props: { step: 0.001 },
153
+ section: 'fit',
154
+ view: 'analysis',
155
+ },
156
+ },
157
+ 'time-course': {
158
+ timeUnit: {
159
+ label: 'Time unit',
160
+ default: 'hour',
161
+ options: ['second', 'minute', 'hour', 'day', 'week'],
162
+ section: 'schedule',
163
+ sectionLabel: 'Schedule',
164
+ sectionSubtitle: 'Sampling timeline',
165
+ view: 'design',
166
+ sidebar: { icon: ICONS.run, iconColor: '#0ea5e9', iconBg: '#e0f2fe' },
167
+ },
168
+ replicates: {
169
+ type: 'number',
170
+ label: 'Replicates',
171
+ default: 3,
172
+ min: 1,
173
+ max: 24,
174
+ section: 'samples',
175
+ sectionLabel: 'Samples',
176
+ view: 'design',
177
+ sidebar: { icon: ICONS.samples, iconColor: '#10b981', iconBg: '#d1fae5' },
178
+ },
179
+ },
180
+ 'protocol-steps': {
181
+ defaultDuration: {
182
+ type: 'number',
183
+ label: 'Default duration',
184
+ default: 30,
185
+ min: 0,
186
+ section: 'protocol',
187
+ sectionLabel: 'Protocol',
188
+ sectionSubtitle: 'Step defaults',
189
+ view: 'design',
190
+ sidebar: { icon: ICONS.run, iconColor: '#f97316', iconBg: '#ffedd5' },
191
+ props: { suffix: 'min' },
192
+ },
193
+ editable: {
194
+ label: 'Editable timeline',
195
+ default: true,
196
+ section: 'protocol',
197
+ view: 'design',
198
+ },
199
+ },
200
+ 'assay-matrix': {
201
+ featureType: {
202
+ label: 'Feature type',
203
+ default: 'metabolite',
204
+ options: ['metabolite', 'protein', 'gene', 'cell', 'compound', 'readout', 'other'],
205
+ section: 'features',
206
+ sectionLabel: 'Features',
207
+ sectionSubtitle: 'Measurement matrix',
208
+ view: 'analysis',
209
+ sidebar: { icon: ICONS.table, iconColor: '#0ea5e9', iconBg: '#e0f2fe' },
210
+ },
211
+ normalizeValues: {
212
+ label: 'Normalize values',
213
+ default: false,
214
+ section: 'analysis',
215
+ sectionLabel: 'Analysis',
216
+ view: 'analysis',
217
+ sidebar: { icon: ICONS.settings, iconColor: '#6366f1', iconBg: '#e0e7ff', defaultOpen: false },
218
+ },
219
+ },
220
+ 'reagent-list': {
221
+ reagentKind: {
222
+ label: 'Reagent kind',
223
+ default: 'reagent',
224
+ options: ['compound', 'antibody', 'primer', 'enzyme', 'buffer', 'media', 'kit', 'reagent', 'other'],
225
+ section: 'inventory',
226
+ sectionLabel: 'Inventory',
227
+ sectionSubtitle: 'Reagent metadata',
228
+ view: 'design',
229
+ sidebar: { icon: ICONS.table, iconColor: '#10b981', iconBg: '#d1fae5' },
230
+ },
231
+ trackStock: {
232
+ label: 'Track stock level',
233
+ default: true,
234
+ section: 'inventory',
235
+ view: 'design',
236
+ },
237
+ },
238
+ 'flow-cytometry-panel': {
239
+ markers: {
240
+ type: 'tags',
241
+ label: 'Markers',
242
+ default: ['CD3', 'CD4', 'CD8'],
243
+ section: 'panel',
244
+ sectionLabel: 'Panel',
245
+ sectionSubtitle: 'Markers and controls',
246
+ view: 'design',
247
+ sidebar: { icon: ICONS.table, iconColor: '#0ea5e9', iconBg: '#e0f2fe' },
248
+ },
249
+ instrument: {
250
+ label: 'Instrument',
251
+ default: 'Flow cytometer',
252
+ section: 'panel',
253
+ sectionLabel: 'Panel',
254
+ sectionSubtitle: 'Markers and controls',
255
+ view: 'design',
256
+ sidebar: { icon: ICONS.settings, iconColor: '#6366f1', iconBg: '#e0e7ff' },
257
+ },
258
+ includeDefaultControls: {
259
+ label: 'Default controls',
260
+ default: true,
261
+ section: 'panel',
262
+ view: 'design',
263
+ },
264
+ },
265
+ 'instrument-run': {
266
+ instrument: {
267
+ label: 'Instrument',
268
+ default: 'LC-MS',
269
+ options: ['LC-MS', 'GC-MS', 'Orbitrap', 'Triple quadrupole', 'Plate reader', 'Other'],
270
+ section: 'acquisition',
271
+ sectionLabel: 'Acquisition',
272
+ sectionSubtitle: 'Run queue',
273
+ view: 'run',
274
+ sidebar: { icon: ICONS.run, iconColor: '#ef4444', iconBg: '#fee2e2' },
275
+ },
276
+ method: {
277
+ label: 'Method',
278
+ default: 'Default method',
279
+ section: 'acquisition',
280
+ view: 'run',
281
+ },
282
+ includeQc: {
283
+ label: 'Include QC',
284
+ default: true,
285
+ section: 'quality',
286
+ sectionLabel: 'Quality Control',
287
+ view: 'run',
288
+ sidebar: { icon: ICONS.settings, iconColor: '#6366f1', iconBg: '#e0e7ff', defaultOpen: false },
289
+ },
290
+ },
291
+ 'qpcr-plate': {
292
+ chemistry: {
293
+ label: 'Chemistry',
294
+ default: 'sybr',
295
+ options: ['sybr', 'taqman', 'probe', 'evagreen', 'other'],
296
+ section: 'assay',
297
+ sectionLabel: 'Assay',
298
+ sectionSubtitle: 'qPCR setup',
299
+ view: 'design',
300
+ sidebar: { icon: ICONS.plate, iconColor: '#6366f1', iconBg: '#e0e7ff' },
301
+ },
302
+ replicates: {
303
+ type: 'number',
304
+ label: 'Replicates',
305
+ default: 3,
306
+ min: 1,
307
+ max: 12,
308
+ section: 'assay',
309
+ view: 'design',
310
+ },
311
+ includeNoTemplateControls: {
312
+ label: 'No-template controls',
313
+ default: true,
314
+ section: 'controls',
315
+ sectionLabel: 'Controls',
316
+ view: 'design',
317
+ sidebar: { icon: ICONS.settings, iconColor: '#8b5cf6', iconBg: '#ede9fe', defaultOpen: false },
318
+ },
319
+ },
320
+ } satisfies Record<TemplateId, BioTemplateControlSchema>