-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
114 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,60 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { CellTypeTableData, ColorMap } from '../models/create-visualization-page-types'; | ||
import { z } from 'zod'; | ||
|
||
@Injectable() | ||
export abstract class CellTypeDataService { | ||
abstract getCellTypeData(): Promise<CellTypeTableData[]>; | ||
import { ColorMap } from '../models/create-visualization-page-types'; | ||
|
||
abstract getColorMap(): Promise<ColorMap>; | ||
export interface CellTypeTableData { | ||
x: number; | ||
y: number; | ||
cellType: string; | ||
z?: number; | ||
ontologyId?: string; | ||
} | ||
|
||
const CELL_TYPE_DATA = z | ||
.object({ | ||
x: z.number(), | ||
y: z.number(), | ||
z: z.number().optional(), | ||
Cell_Type: z.string(), | ||
Ontology_ID: z.string().optional(), | ||
}) | ||
.array(); | ||
|
||
export type CellTypeData = z.infer<typeof CELL_TYPE_DATA>; | ||
|
||
const COLOR_MAP_DATA = z | ||
.object({ | ||
cell: z.string(), | ||
R: z.number(), | ||
G: z.number(), | ||
B: z.number(), | ||
}) | ||
.array(); | ||
|
||
export type ColorMapData = z.infer<typeof COLOR_MAP_DATA>; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class CellTypeDataService { | ||
getCellTypeData(cellTypeData: CellTypeData): CellTypeTableData[] { | ||
return cellTypeData.map((row) => { | ||
return { | ||
x: row.x, | ||
y: row.y, | ||
z: row.z, | ||
cellType: row.Cell_Type, | ||
ontologyId: row.Ontology_ID, | ||
}; | ||
}); | ||
} | ||
|
||
getColorMap(colorMapData: ColorMapData): ColorMap { | ||
const result: ColorMap = {}; | ||
colorMapData.forEach((row) => { | ||
result[row.cell] = [row.R, row.G, row.B]; | ||
}); | ||
return result; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.