Skip to content

Commit

Permalink
Fasta datasets support + minor UX fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dbolotin committed Nov 19, 2024
1 parent 4429f3b commit 82e916f
Show file tree
Hide file tree
Showing 15 changed files with 1,063 additions and 737 deletions.
8 changes: 8 additions & 0 deletions .changeset/strange-planets-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@platforma-open/milaboratories.samples-and-data.workflow': minor
'@platforma-open/milaboratories.samples-and-data.model': minor
'@platforma-open/milaboratories.samples-and-data.ui': minor
'@platforma-open/milaboratories.samples-and-data': minor
---

Fasta datasets support + minor UX fixes
17 changes: 16 additions & 1 deletion model/src/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ export type ReadIndices = z.infer<typeof ReadIndices>;
export const FastqFileGroup = z.record(ReadIndex, ImportFileHandleSchema);
export type FastqFileGroup = z.infer<typeof FastqFileGroup>;

export const DatasetContentFasta = z
.object({
type: z.literal('Fasta'),
gzipped: z.boolean(),
data: z.record(
PlId,
ImportFileHandleSchema.nullable() /* null meand sampple is added to the dataset, but file is not yet set */
)
})
.strict();
export type DatasetContentFasta = z.infer<typeof DatasetContentFasta>;

export const DatasetContentFastq = z
.object({
type: z.literal('Fastq'),
Expand Down Expand Up @@ -105,7 +117,8 @@ export type DatasetContentMultilaneFastq = z.infer<typeof DatasetContentMultilan

export const DatasetContent = z.discriminatedUnion('type', [
DatasetContentFastq,
DatasetContentMultilaneFastq
DatasetContentMultilaneFastq,
DatasetContentFasta
]);
export type DatasetContent = z.infer<typeof DatasetContent>;

Expand All @@ -118,6 +131,8 @@ export function Dataset<const ContentType extends z.ZodTypeAny>(content: Content
}

export const DatasetAny = Dataset(DatasetContent);
export const DatasetFasta = Dataset(DatasetContentFasta);
export type DatasetFasta = z.infer<typeof DatasetFasta>;
export const DatasetFastq = Dataset(DatasetContentFastq);
export type DatasetFastq = z.infer<typeof DatasetFastq>;
export const DatasetMultilaneFastq = Dataset(DatasetContentMultilaneFastq);
Expand Down
26 changes: 16 additions & 10 deletions model/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
import {
BlockModel,
getImportProgress,
getResourceField,
ImportFileHandle,
InferHrefType,
type InferOutputsType,
It,
MainOutputs,
mapResourceFields
type InferOutputsType
} from '@platforma-sdk/model';
import { BlockArgs } from './args';

export type BlockUiState = { suggestedImport: boolean };

export const platforma = BlockModel.create<BlockArgs, BlockUiState>()
export const platforma = BlockModel.create()

.initialArgs({
.withArgs<BlockArgs>({
sampleIds: [],
metadata: [],
sampleLabelColumnLabel: 'Sample',
sampleLabels: {},
datasets: []
})

.withUiState<BlockUiState>({ suggestedImport: false })

.output(
'fileImports',
mapResourceFields(getResourceField(MainOutputs, 'fileImports'), getImportProgress(It))
(ctx) =>
Object.fromEntries(
ctx.outputs
?.resolve({ field: 'fileImports', assertFieldType: 'Input' })
?.mapFields((handle, acc) => [handle as ImportFileHandle, acc.getImportProgress()], {
skipUnresolved: true
}) ?? []
),
{ isActive: true }
// mapResourceFields(getResourceField(MainOutputs, 'fileImports'), getImportProgress(It))
)

// .output('exports', (ctx) => {
Expand Down Expand Up @@ -54,4 +61,3 @@ export type Href = InferHrefType<typeof platforma>;
export * from './args';
export * from './helpers';
export { BlockArgs };

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@
"//": {
"pnpm": {
"overrides": {
"@platforma-sdk/ui-vue": "file:/Users/dbolotin/milab/core/platforma/sdk/ui-vue/package.tgz"
"@platforma-sdk/ui-vue": "file:/Users/dbolotin/milab/core/platforma/sdk/ui-vue/package.tgz",
"@milaboratories/pl-middle-layer": "file:/Users/dbolotin/milab/core/platforma/lib/node/pl-middle-layer/package.tgz",
"@milaboratories/pl-model-middle-layer": "file:/Users/dbolotin/milab/core/platforma/lib/model/middle-layer/package.tgz",
"@milaboratories/pl-model-common": "file:/Users/dbolotin/milab/core/platforma/lib/model/common/package.tgz",
"@platforma-sdk/model": "file:/Users/dbolotin/milab/core/platforma/sdk/model/package.tgz",
"@platforma-sdk/test": "file:/Users/dbolotin/milab/core/platforma/sdk/test/package.tgz"
}
}
},
Expand Down
Loading

0 comments on commit 82e916f

Please sign in to comment.