import { getTemplateData } from './templateEnvelopes' import { validateTimeCourseData } from './templateValidators' import type { TimeCourseColumnsAdapterResult, TimeCourseDataFrameAdapterResult, TimeCourseRowsAdapterResult, TimeCourseStepsAdapterResult, TimeCourseTemplate, TimeCourseTemplateData, } from './types' /** @deprecated Scheduled for removal from the core SDK in MINT 1.4; the biology templates move to a dedicated package or the owning plugins. */ export function toTimeCourseRows( template: TimeCourseTemplate | TimeCourseTemplateData ): TimeCourseRowsAdapterResult { const data = getTemplateData(template, 'time-course') validateTimeCourseData(data) const timepoints = new Map(data.timepoints.map(timepoint => [timepoint.id, timepoint])) const conditions = new Map(data.conditions.map(condition => [condition.id, condition])) return data.samples.map(sample => { const timepoint = timepoints.get(sample.timepointId) const condition = conditions.get(sample.conditionId) return { sampleId: sample.sampleId, condition: condition?.name ?? sample.conditionId, timepoint: timepoint?.label ?? sample.timepointId, value: timepoint?.value, unit: timepoint?.unit, replicate: sample.replicate, ...(sample.metadata ?? {}), } }) } /** @deprecated Scheduled for removal from the core SDK in MINT 1.4; the biology templates move to a dedicated package or the owning plugins. */ export function toTimeCourseColumns(): TimeCourseColumnsAdapterResult { return [ { key: 'sampleId', label: 'Sample ID', sortable: true }, { key: 'condition', label: 'Condition', sortable: true }, { key: 'timepoint', label: 'Time Point', sortable: true }, { key: 'value', label: 'Value', sortable: true, align: 'right' }, { key: 'unit', label: 'Unit', sortable: true }, { key: 'replicate', label: 'Replicate', sortable: true, align: 'right' }, ] } /** @deprecated Scheduled for removal from the core SDK in MINT 1.4; the biology templates move to a dedicated package or the owning plugins. */ export function toTimeCourseDataFrame( template: TimeCourseTemplate | TimeCourseTemplateData ): TimeCourseDataFrameAdapterResult { return { data: toTimeCourseRows(template), columns: toTimeCourseColumns(), rowKey: 'sampleId', } } /** @deprecated Scheduled for removal from the core SDK in MINT 1.4; the biology templates move to a dedicated package or the owning plugins. */ export function toTimeCourseSteps( template: TimeCourseTemplate | TimeCourseTemplateData ): TimeCourseStepsAdapterResult { const data = getTemplateData(template, 'time-course') validateTimeCourseData(data) return data.timepoints.map((timepoint, index) => ({ id: timepoint.id, type: 'measurement', name: timepoint.label, description: `${data.conditions.length} condition${data.conditions.length === 1 ? '' : 's'}`, status: 'pending', order: index, parameters: { value: timepoint.value, unit: timepoint.unit, }, })) }