@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,163 @@
1
+ import type {
2
+ ProtocolStep,
3
+ ScheduleEvent,
4
+ } from '../types'
5
+ import { getTemplateData } from './templateEnvelopes'
6
+ import { validateInstrumentRunData } from './templateValidators'
7
+ import type {
8
+ InstrumentRunColumnsAdapterResult,
9
+ InstrumentRunDataFrameAdapterResult,
10
+ InstrumentRunRowsAdapterResult,
11
+ InstrumentRunScheduleEventsAdapterResult,
12
+ InstrumentRunStepsAdapterResult,
13
+ InstrumentRunTemplate,
14
+ InstrumentRunTemplateData,
15
+ } from './types'
16
+ import {
17
+ addMinutes,
18
+ dateFromMetadata,
19
+ instrumentRunScheduleColor,
20
+ instrumentRunScheduleStatus,
21
+ instrumentRunStepStatus,
22
+ instrumentRunStepType,
23
+ } from './instrumentRunAdapterHelpers'
24
+
25
+ export function toInstrumentRunRows(
26
+ template: InstrumentRunTemplate | InstrumentRunTemplateData
27
+ ): InstrumentRunRowsAdapterResult {
28
+ const data = getTemplateData(template, 'instrument-run')
29
+ validateInstrumentRunData(data)
30
+ const methods = new Map(data.methods.map(method => [method.id, method]))
31
+ return [...data.items]
32
+ .sort((a, b) => a.order - b.order)
33
+ .map(item => {
34
+ const method = methods.get(item.methodId)
35
+ return {
36
+ id: item.id,
37
+ order: item.order,
38
+ kind: item.kind,
39
+ sampleId: item.sampleId,
40
+ name: item.name ?? item.sampleId ?? item.kind,
41
+ method: method?.name ?? item.methodId,
42
+ vial: item.vial,
43
+ plateId: item.plateId,
44
+ wellId: item.wellId,
45
+ injectionVolume: item.injectionVolume,
46
+ expectedDurationMin: item.expectedDurationMin,
47
+ status: item.status,
48
+ instrument: data.instrument ?? method?.instrument,
49
+ ...(item.metadata ?? {}),
50
+ }
51
+ })
52
+ }
53
+
54
+ export function toInstrumentRunColumns(): InstrumentRunColumnsAdapterResult {
55
+ return [
56
+ { key: 'order', label: 'Order', sortable: true, align: 'right' },
57
+ { key: 'kind', label: 'Kind', sortable: true },
58
+ { key: 'sampleId', label: 'Sample ID', sortable: true },
59
+ { key: 'name', label: 'Name', sortable: true },
60
+ { key: 'method', label: 'Method', sortable: true },
61
+ { key: 'vial', label: 'Vial', sortable: true },
62
+ { key: 'wellId', label: 'Well', sortable: true },
63
+ { key: 'injectionVolume', label: 'Injection', sortable: true, align: 'right' },
64
+ { key: 'expectedDurationMin', label: 'Duration', sortable: true, align: 'right' },
65
+ { key: 'status', label: 'Status', sortable: true },
66
+ { key: 'instrument', label: 'Instrument', sortable: true },
67
+ ]
68
+ }
69
+
70
+ export function toInstrumentRunDataFrame(
71
+ template: InstrumentRunTemplate | InstrumentRunTemplateData
72
+ ): InstrumentRunDataFrameAdapterResult {
73
+ return {
74
+ data: toInstrumentRunRows(template),
75
+ columns: toInstrumentRunColumns(),
76
+ rowKey: 'id',
77
+ }
78
+ }
79
+
80
+ /** Convert an instrument-run template into ExperimentTimeline protocol steps for acquisition queue previews. */
81
+ export function toInstrumentRunSteps(
82
+ template: InstrumentRunTemplate | InstrumentRunTemplateData
83
+ ): InstrumentRunStepsAdapterResult {
84
+ const data = getTemplateData(template, 'instrument-run')
85
+ validateInstrumentRunData(data)
86
+ const methods = new Map(data.methods.map(method => [method.id, method]))
87
+ return [...data.items]
88
+ .sort((a, b) => a.order - b.order)
89
+ .map((item): ProtocolStep => {
90
+ const method = methods.get(item.methodId)
91
+ const name = item.name ?? item.sampleId ?? item.kind
92
+ return {
93
+ id: item.id,
94
+ type: instrumentRunStepType(item.kind),
95
+ name,
96
+ description: [
97
+ item.kind,
98
+ method?.name,
99
+ item.vial ? `Vial ${item.vial}` : undefined,
100
+ item.wellId ? `Well ${item.wellId}` : undefined,
101
+ ]
102
+ .filter(Boolean)
103
+ .join(' / '),
104
+ duration: item.expectedDurationMin,
105
+ status: instrumentRunStepStatus(item.status),
106
+ parameters: {
107
+ kind: item.kind,
108
+ sampleId: item.sampleId,
109
+ methodId: item.methodId,
110
+ method: method?.name,
111
+ vial: item.vial,
112
+ plateId: item.plateId,
113
+ wellId: item.wellId,
114
+ injectionVolume: item.injectionVolume,
115
+ instrument: data.instrument ?? method?.instrument,
116
+ },
117
+ order: item.order,
118
+ }
119
+ })
120
+ }
121
+
122
+ /** Convert an instrument-run template into readonly ScheduleCalendar events ordered by run queue timing. */
123
+ export function toInstrumentRunScheduleEvents(
124
+ template: InstrumentRunTemplate | InstrumentRunTemplateData
125
+ ): InstrumentRunScheduleEventsAdapterResult {
126
+ const data = getTemplateData(template, 'instrument-run')
127
+ validateInstrumentRunData(data)
128
+ const methods = new Map(data.methods.map(method => [method.id, method]))
129
+ let cursor = dateFromMetadata(data.metadata, ['scheduledStart', 'runStart', 'start', 'startedAt'])
130
+ ?? new Date('2024-01-01T08:00:00.000Z')
131
+
132
+ return [...data.items]
133
+ .sort((a, b) => a.order - b.order)
134
+ .map((item): ScheduleEvent => {
135
+ const method = methods.get(item.methodId)
136
+ const start = dateFromMetadata(item.metadata, ['scheduledStart', 'start', 'startedAt']) ?? cursor
137
+ const end = dateFromMetadata(item.metadata, ['scheduledEnd', 'end', 'completedAt'])
138
+ ?? addMinutes(start, Math.max(item.expectedDurationMin ?? 10, 1))
139
+ cursor = end
140
+
141
+ return {
142
+ id: item.id,
143
+ title: item.name ?? item.sampleId ?? item.kind,
144
+ start: start.toISOString(),
145
+ end: end.toISOString(),
146
+ color: instrumentRunScheduleColor(item.kind),
147
+ status: instrumentRunScheduleStatus(item.status),
148
+ draggable: false,
149
+ resizable: false,
150
+ metadata: {
151
+ kind: item.kind,
152
+ sampleId: item.sampleId,
153
+ methodId: item.methodId,
154
+ method: method?.name,
155
+ vial: item.vial,
156
+ plateId: item.plateId,
157
+ wellId: item.wellId,
158
+ injectionVolume: item.injectionVolume,
159
+ instrument: data.instrument ?? method?.instrument,
160
+ },
161
+ }
162
+ })
163
+ }
@@ -0,0 +1,97 @@
1
+ import { idFromName } from './builderIdUtils'
2
+ import {
3
+ normalizeInstrumentMethod,
4
+ normalizeInstrumentRunItem,
5
+ } from './runNormalizers'
6
+ import { createTemplateEnvelope } from './templateEnvelopes'
7
+ import { validateInstrumentRunData } from './templateValidators'
8
+ import type {
9
+ CreateInstrumentRunTemplateOptions,
10
+ InstrumentRunItem,
11
+ InstrumentRunTemplate,
12
+ InstrumentRunTemplateData,
13
+ } from './types'
14
+
15
+ export function createInstrumentRunTemplate(
16
+ options: CreateInstrumentRunTemplateOptions
17
+ ): InstrumentRunTemplate {
18
+ const method = typeof options.method === 'string' || options.method === undefined
19
+ ? {
20
+ id: idFromName(options.method ?? 'Default method', 'method-1'),
21
+ name: options.method ?? 'Default method',
22
+ instrument: options.instrument,
23
+ metadata: {},
24
+ }
25
+ : normalizeInstrumentMethod(options.method, options.instrument)
26
+ const items: InstrumentRunItem[] = []
27
+ let order = 1
28
+
29
+ if (options.includeBlanks !== false) {
30
+ items.push({
31
+ id: 'blank-start',
32
+ order,
33
+ kind: 'blank',
34
+ name: 'Blank start',
35
+ methodId: method.id,
36
+ status: 'planned',
37
+ metadata: {},
38
+ })
39
+ order += 1
40
+ }
41
+
42
+ if (options.includeQc !== false) {
43
+ items.push({
44
+ id: 'qc-start',
45
+ order,
46
+ kind: 'qc',
47
+ name: 'QC start',
48
+ methodId: method.id,
49
+ status: 'planned',
50
+ metadata: {},
51
+ })
52
+ order += 1
53
+ }
54
+
55
+ for (const [index, item] of options.items.entries()) {
56
+ if (typeof item !== 'string') {
57
+ const normalized = normalizeInstrumentRunItem(item, method.id, order, index)
58
+ items.push(normalized)
59
+ order = Math.max(order, normalized.order + 1)
60
+ continue
61
+ }
62
+ const sampleId = idFromName(item, `sample-${index + 1}`)
63
+ items.push({
64
+ id: `${sampleId}-run`,
65
+ order,
66
+ kind: 'sample',
67
+ sampleId,
68
+ name: item,
69
+ methodId: method.id,
70
+ status: 'planned',
71
+ metadata: {},
72
+ })
73
+ order += 1
74
+ }
75
+
76
+ if (options.includeQc !== false) {
77
+ items.push({
78
+ id: 'qc-end',
79
+ order,
80
+ kind: 'qc',
81
+ name: 'QC end',
82
+ methodId: method.id,
83
+ status: 'planned',
84
+ metadata: {},
85
+ })
86
+ }
87
+
88
+ const data: InstrumentRunTemplateData = {
89
+ runId: 'run-1',
90
+ instrument: options.instrument,
91
+ methods: [method],
92
+ items,
93
+ metadata: options.metadata ?? {},
94
+ }
95
+ validateInstrumentRunData(data)
96
+ return createTemplateEnvelope('instrument-run', data, options.metadata ?? {})
97
+ }
@@ -0,0 +1,38 @@
1
+ import { createAssayMatrixTemplate } from './assayMatrixBuilder'
2
+ import { createInstrumentRunTemplate } from './instrumentRunBuilder'
3
+ import { createSampleSheetTemplate } from './sampleSheetBuilder'
4
+ import { presetSampleRecords } from './sampleNormalizers'
5
+ import { createTemplateCollection } from './templateEnvelopes'
6
+ import type {
7
+ CreateLcmsBatchCollectionOptions,
8
+ TemplateCollectionEnvelope,
9
+ } from './types'
10
+
11
+ export function createLcmsBatchCollection(
12
+ options: CreateLcmsBatchCollectionOptions = {}
13
+ ): TemplateCollectionEnvelope {
14
+ const sampleRecords = presetSampleRecords(options.samples ?? ['S001', 'S002'])
15
+ const sampleSheet = createSampleSheetTemplate({ samples: sampleRecords })
16
+ const instrumentRun = createInstrumentRunTemplate({
17
+ items: sampleRecords.map(sample => ({
18
+ sampleId: sample.sampleId,
19
+ name: sample.name ?? sample.sampleId,
20
+ })),
21
+ method: options.method ?? 'Default method',
22
+ instrument: options.instrument ?? 'LC-MS',
23
+ includeQc: options.includeQc,
24
+ })
25
+ const assayMatrix = createAssayMatrixTemplate({
26
+ samples: sampleRecords.map(sample => ({
27
+ sampleId: sample.sampleId,
28
+ name: sample.name,
29
+ group: sample.group,
30
+ metadata: sample.metadata ?? {},
31
+ })),
32
+ features: options.features ?? ['Glucose', 'Lactate'],
33
+ })
34
+ return createTemplateCollection(
35
+ [sampleSheet, instrumentRun, assayMatrix],
36
+ { preset: 'lcms-batch', ...(options.metadata ?? {}) }
37
+ )
38
+ }
@@ -0,0 +1,62 @@
1
+ import type { WellPlateFormat } from '../types'
2
+
3
+ const PLATE_DIMENSIONS: Record<number, readonly [number, number]> = {
4
+ 6: [2, 3],
5
+ 12: [3, 4],
6
+ 24: [4, 6],
7
+ 48: [6, 8],
8
+ 54: [6, 9],
9
+ 96: [8, 12],
10
+ 384: [16, 24],
11
+ }
12
+
13
+ export function wellIdsForFormat(format: number): string[] {
14
+ const dimensions = PLATE_DIMENSIONS[format]
15
+ if (!dimensions) {
16
+ throw new Error(`Unsupported plate format '${format}'.`)
17
+ }
18
+ const [rows, cols] = dimensions
19
+ return Array.from({ length: rows }, (_, row) =>
20
+ Array.from({ length: cols }, (_col, col) => `${rowLabel(row)}${col + 1}`)
21
+ ).flat()
22
+ }
23
+
24
+ export function assertWellInFormat(wellId: string, format: number): void {
25
+ const dimensions = PLATE_DIMENSIONS[format]
26
+ if (!dimensions) {
27
+ throw new Error(`Unsupported plate format '${format}'.`)
28
+ }
29
+ const match = /^([A-Z]+)([1-9][0-9]*)$/.exec(wellId.toUpperCase())
30
+ if (!match) {
31
+ throw new Error(`Invalid well id '${wellId}'.`)
32
+ }
33
+ const row = rowIndex(match[1])
34
+ const col = Number(match[2]) - 1
35
+ const [rows, cols] = dimensions
36
+ if (row < 0 || col < 0 || row >= rows || col >= cols) {
37
+ throw new Error(`Well '${wellId}' is outside a ${format}-well plate.`)
38
+ }
39
+ }
40
+
41
+ export function readPlateFormat(value: unknown, fallback: WellPlateFormat): WellPlateFormat {
42
+ const parsed = typeof value === 'number'
43
+ ? value
44
+ : typeof value === 'string'
45
+ ? Number(value)
46
+ : Number.NaN
47
+ return parsed in PLATE_DIMENSIONS ? (parsed as WellPlateFormat) : fallback
48
+ }
49
+
50
+ function rowLabel(index: number): string {
51
+ let label = ''
52
+ let current = index
53
+ while (true) {
54
+ label = String.fromCharCode(65 + (current % 26)) + label
55
+ current = Math.floor(current / 26) - 1
56
+ if (current < 0) return label
57
+ }
58
+ }
59
+
60
+ function rowIndex(label: string): number {
61
+ return [...label].reduce((value, char) => value * 26 + char.charCodeAt(0) - 64, 0) - 1
62
+ }
@@ -0,0 +1,36 @@
1
+ import type {
2
+ PlateMapEditorState,
3
+ } from '../types'
4
+ import { getTemplateData } from './templateEnvelopes'
5
+ import { validatePlateMapData } from './templateValidators'
6
+ import type {
7
+ PlateMapEditorAdapterResult,
8
+ PlateMapTemplate,
9
+ PlateMapTemplateData,
10
+ WellMapAdapterResult,
11
+ } from './types'
12
+
13
+ export function toPlateMapEditorState(
14
+ template: PlateMapTemplate | PlateMapTemplateData
15
+ ): PlateMapEditorAdapterResult {
16
+ const data = getTemplateData(template, 'plate-map')
17
+ validatePlateMapData(data)
18
+ const activePlateId = data.activePlateId ?? data.plates[0].id
19
+ return {
20
+ plates: data.plates,
21
+ activePlateId,
22
+ samples: data.samples,
23
+ selectedWells: data.selectedWells ?? [],
24
+ activeSampleId: data.activeSampleId,
25
+ } satisfies PlateMapEditorState
26
+ }
27
+
28
+ export function toWellPlateWells(
29
+ template: PlateMapTemplate | PlateMapTemplateData,
30
+ plateId?: string
31
+ ): WellMapAdapterResult {
32
+ const state = toPlateMapEditorState(template)
33
+ const plate = state.plates.find(candidate => candidate.id === (plateId ?? state.activePlateId))
34
+ ?? state.plates[0]
35
+ return plate.wells
36
+ }
@@ -0,0 +1,43 @@
1
+ import { DEFAULT_SAMPLE_COLORS } from './builderDefaults'
2
+ import { sampleIdFromName } from './builderIdUtils'
3
+ import { createTemplateEnvelope } from './templateEnvelopes'
4
+ import type {
5
+ CreatePlateMapTemplateOptions,
6
+ PlateMapTemplate,
7
+ TemplateSample,
8
+ } from './types'
9
+
10
+ export function createPlateMapTemplate(
11
+ options: CreatePlateMapTemplateOptions = {}
12
+ ): PlateMapTemplate {
13
+ const {
14
+ id = 'plate-1',
15
+ name = 'Plate 1',
16
+ format = 96,
17
+ samples = [],
18
+ metadata = {},
19
+ } = options
20
+
21
+ const sampleDefinitions = samples.map((sample, index): TemplateSample => {
22
+ if (typeof sample !== 'string') return sample
23
+ return {
24
+ id: sampleIdFromName(sample, index),
25
+ name: sample,
26
+ color: DEFAULT_SAMPLE_COLORS[index % DEFAULT_SAMPLE_COLORS.length],
27
+ }
28
+ })
29
+
30
+ return createTemplateEnvelope('plate-map', {
31
+ plates: [
32
+ {
33
+ id,
34
+ name,
35
+ format,
36
+ wells: {},
37
+ },
38
+ ],
39
+ samples: sampleDefinitions,
40
+ activePlateId: id,
41
+ selectedWells: [],
42
+ }, metadata)
43
+ }
@@ -0,0 +1,258 @@
1
+ import {
2
+ CONCENTRATION_UNITS,
3
+ ICONS,
4
+ PLATE_FORMAT_OPTIONS,
5
+ } from './controlSchemaConstants'
6
+ import type {
7
+ BioTemplateControlSchema,
8
+ } from './controlSchemaTypes'
9
+ import {
10
+ templateControlSchemas,
11
+ } from './templateControlSchemas'
12
+ import type {
13
+ TemplatePresetId,
14
+ } from './types'
15
+
16
+ export const presetControlSchemas = {
17
+ 'wellplate-screen': {
18
+ ...templateControlSchemas['plate-map'],
19
+ ...templateControlSchemas['dose-response'],
20
+ sampleNames: {
21
+ ...templateControlSchemas['plate-map'].sampleNames,
22
+ default: ['Control', 'Treatment'],
23
+ },
24
+ },
25
+ 'qpcr-expression': {
26
+ sampleNames: {
27
+ type: 'tags',
28
+ label: 'Samples',
29
+ default: ['Control', 'Treatment'],
30
+ section: 'samples',
31
+ sectionLabel: 'Samples',
32
+ sectionSubtitle: 'Expression groups',
33
+ view: 'design',
34
+ sidebar: { icon: ICONS.samples, iconColor: '#10b981', iconBg: '#d1fae5' },
35
+ },
36
+ targets: {
37
+ type: 'tags',
38
+ label: 'Targets',
39
+ default: ['ACTB', 'GAPDH'],
40
+ section: 'assay',
41
+ sectionLabel: 'Assay',
42
+ view: 'design',
43
+ sidebar: { icon: ICONS.plate, iconColor: '#6366f1', iconBg: '#e0e7ff' },
44
+ },
45
+ ...templateControlSchemas['qpcr-plate'],
46
+ },
47
+ 'lcms-batch': {
48
+ sampleNames: {
49
+ type: 'tags',
50
+ label: 'Samples',
51
+ default: ['S001', 'S002'],
52
+ section: 'samples',
53
+ sectionLabel: 'Samples',
54
+ sectionSubtitle: 'Batch samples',
55
+ view: 'run',
56
+ sidebar: { icon: ICONS.samples, iconColor: '#10b981', iconBg: '#d1fae5' },
57
+ },
58
+ featureNames: {
59
+ type: 'tags',
60
+ label: 'Features',
61
+ default: ['Glucose', 'Lactate'],
62
+ section: 'features',
63
+ sectionLabel: 'Features',
64
+ view: 'analysis',
65
+ sidebar: { icon: ICONS.table, iconColor: '#0ea5e9', iconBg: '#e0f2fe' },
66
+ },
67
+ ...templateControlSchemas['instrument-run'],
68
+ ...templateControlSchemas['assay-matrix'],
69
+ },
70
+ 'targeted-metabolomics': {
71
+ sampleNames: {
72
+ type: 'tags',
73
+ label: 'Samples',
74
+ default: ['S001', 'S002'],
75
+ section: 'samples',
76
+ sectionLabel: 'Samples',
77
+ sectionSubtitle: 'Unknowns and QC pool',
78
+ view: 'run',
79
+ sidebar: { icon: ICONS.samples, iconColor: '#10b981', iconBg: '#d1fae5' },
80
+ },
81
+ metaboliteNames: {
82
+ type: 'tags',
83
+ label: 'Metabolites',
84
+ default: ['Glucose', 'Lactate', 'Pyruvate'],
85
+ section: 'features',
86
+ sectionLabel: 'Metabolites',
87
+ sectionSubtitle: 'Quantitation panel',
88
+ view: 'analysis',
89
+ sidebar: { icon: ICONS.table, iconColor: '#0ea5e9', iconBg: '#e0f2fe' },
90
+ },
91
+ internalStandards: {
92
+ type: 'tags',
93
+ label: 'Internal standards',
94
+ default: ['Stable isotope internal standard mix'],
95
+ section: 'standards',
96
+ sectionLabel: 'Standards',
97
+ sectionSubtitle: 'Calibration and internal standards',
98
+ view: 'analysis',
99
+ sidebar: { icon: ICONS.dose, iconColor: '#8b5cf6', iconBg: '#ede9fe' },
100
+ },
101
+ standardConcentrations: {
102
+ type: 'tags',
103
+ label: 'Calibration levels',
104
+ default: ['0.1', '1', '10', '100'],
105
+ section: 'standards',
106
+ view: 'analysis',
107
+ },
108
+ concentrationUnit: {
109
+ label: 'Concentration unit',
110
+ default: 'uM',
111
+ options: CONCENTRATION_UNITS,
112
+ section: 'standards',
113
+ view: 'analysis',
114
+ },
115
+ responseUnit: {
116
+ label: 'Response unit',
117
+ default: 'peak area ratio',
118
+ section: 'readout',
119
+ sectionLabel: 'Readout',
120
+ view: 'analysis',
121
+ sidebar: { icon: ICONS.table, iconColor: '#0ea5e9', iconBg: '#e0f2fe' },
122
+ },
123
+ instrument: {
124
+ ...templateControlSchemas['instrument-run'].instrument,
125
+ default: 'LC-MS',
126
+ },
127
+ method: {
128
+ ...templateControlSchemas['instrument-run'].method,
129
+ default: 'Targeted metabolomics',
130
+ },
131
+ prepType: {
132
+ ...templateControlSchemas['sample-prep'].prepType,
133
+ default: 'extraction',
134
+ },
135
+ outputVolume: templateControlSchemas['sample-prep'].outputVolume,
136
+ includeQc: templateControlSchemas['instrument-run'].includeQc,
137
+ },
138
+ 'elisa-assay': {
139
+ sampleNames: {
140
+ type: 'tags',
141
+ label: 'Samples',
142
+ default: ['Control', 'Treatment'],
143
+ section: 'samples',
144
+ sectionLabel: 'Samples',
145
+ sectionSubtitle: 'Unknowns and controls',
146
+ view: 'design',
147
+ sidebar: { icon: ICONS.samples, iconColor: '#10b981', iconBg: '#d1fae5' },
148
+ },
149
+ analyte: {
150
+ label: 'Analyte',
151
+ default: 'Analyte',
152
+ section: 'standards',
153
+ sectionLabel: 'Standards',
154
+ sectionSubtitle: 'Calibration setup',
155
+ view: 'analysis',
156
+ sidebar: { icon: ICONS.dose, iconColor: '#8b5cf6', iconBg: '#ede9fe' },
157
+ },
158
+ standardConcentrations: {
159
+ type: 'tags',
160
+ label: 'Standards',
161
+ default: ['1000', '100', '10', '1'],
162
+ section: 'standards',
163
+ view: 'analysis',
164
+ },
165
+ unit: {
166
+ label: 'Concentration unit',
167
+ default: 'pg/mL',
168
+ options: ['pg/mL', 'ng/mL', 'ug/mL', 'nM', 'uM'],
169
+ section: 'standards',
170
+ view: 'analysis',
171
+ },
172
+ responseUnit: {
173
+ label: 'Response unit',
174
+ default: 'OD450',
175
+ section: 'readout',
176
+ sectionLabel: 'Readout',
177
+ view: 'analysis',
178
+ sidebar: { icon: ICONS.table, iconColor: '#0ea5e9', iconBg: '#e0f2fe' },
179
+ },
180
+ plateName: {
181
+ label: 'Plate name',
182
+ default: 'ELISA plate',
183
+ section: 'layout',
184
+ sectionLabel: 'Layout',
185
+ sectionSubtitle: 'Plate geometry',
186
+ view: 'design',
187
+ sidebar: { icon: ICONS.plate, iconColor: '#6366f1', iconBg: '#e0e7ff' },
188
+ },
189
+ plateFormat: {
190
+ label: 'Format',
191
+ default: 96,
192
+ options: PLATE_FORMAT_OPTIONS,
193
+ section: 'layout',
194
+ view: 'design',
195
+ },
196
+ },
197
+ 'flow-cytometry-assay': {
198
+ sampleNames: {
199
+ type: 'tags',
200
+ label: 'Samples',
201
+ default: ['Control', 'Treatment'],
202
+ section: 'samples',
203
+ sectionLabel: 'Samples',
204
+ sectionSubtitle: 'Assay groups',
205
+ view: 'design',
206
+ sidebar: { icon: ICONS.samples, iconColor: '#10b981', iconBg: '#d1fae5' },
207
+ },
208
+ markers: {
209
+ ...templateControlSchemas['flow-cytometry-panel'].markers,
210
+ default: ['CD3', 'CD4', 'CD8'],
211
+ },
212
+ featureNames: {
213
+ type: 'tags',
214
+ label: 'Readouts',
215
+ default: ['CD3+ cells', 'CD4+ cells', 'CD8+ cells'],
216
+ section: 'features',
217
+ sectionLabel: 'Readouts',
218
+ sectionSubtitle: 'Assay matrix columns',
219
+ view: 'analysis',
220
+ sidebar: { icon: ICONS.table, iconColor: '#0ea5e9', iconBg: '#e0f2fe' },
221
+ },
222
+ instrument: {
223
+ ...templateControlSchemas['flow-cytometry-panel'].instrument,
224
+ default: 'Flow cytometer',
225
+ },
226
+ includeDefaultControls: templateControlSchemas['flow-cytometry-panel'].includeDefaultControls,
227
+ },
228
+ 'western-blot-assay': {
229
+ sampleNames: {
230
+ type: 'tags',
231
+ label: 'Samples',
232
+ default: ['Control', 'Treatment'],
233
+ section: 'samples',
234
+ sectionLabel: 'Samples',
235
+ sectionSubtitle: 'Blot lanes and groups',
236
+ view: 'design',
237
+ sidebar: { icon: ICONS.samples, iconColor: '#10b981', iconBg: '#d1fae5' },
238
+ },
239
+ targets: {
240
+ type: 'tags',
241
+ label: 'Targets',
242
+ default: ['Target protein'],
243
+ section: 'assay',
244
+ sectionLabel: 'Assay',
245
+ sectionSubtitle: 'Protein targets',
246
+ view: 'design',
247
+ sidebar: { icon: ICONS.table, iconColor: '#0ea5e9', iconBg: '#e0f2fe' },
248
+ },
249
+ loadingControl: {
250
+ label: 'Loading control',
251
+ default: 'ACTB',
252
+ section: 'normalization',
253
+ sectionLabel: 'Normalization',
254
+ view: 'analysis',
255
+ sidebar: { icon: ICONS.settings, iconColor: '#6366f1', iconBg: '#e0e7ff' },
256
+ },
257
+ },
258
+ } satisfies Record<TemplatePresetId, BioTemplateControlSchema>