Skip to content

Commit f97cc2a

Browse files
committed
feat: update dataset and file lists to use corresponding data modalities (#4258)
1 parent 2a41e35 commit f97cc2a

File tree

6 files changed

+41
-7
lines changed

6 files changed

+41
-7
lines changed

app/apis/azul/anvil-cmg/common/entities.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export interface BioSampleEntityResponse {
4545
export interface DatasetEntity {
4646
accessible: boolean;
4747
consent_group: (string | null)[];
48+
data_modality: (string | null)[];
4849
dataset_id: string;
4950
description?: string;
5051
registered_identifier: (string | null)[];
@@ -88,7 +89,7 @@ export interface DonorSpecies {
8889
*/
8990
export interface FileEntity {
9091
accessible: boolean;
91-
data_modality: string[];
92+
data_modality: (string | null)[];
9293
date_created: string;
9394
document_id: string;
9495
drs_uri: string;

app/apis/azul/anvil-cmg/common/transformers.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
import {
2323
ActivityEntityResponse,
2424
BioSampleEntityResponse,
25+
DatasetEntityResponse,
2526
DonorEntityResponse,
2627
FileEntityResponse,
2728
LibraryEntityResponse,
@@ -84,6 +85,16 @@ export function getAggregatedBioSampleTypes(
8485
return processAggregatedOrArrayValue(response.biosamples, "biosample_type");
8586
}
8687

88+
/**
89+
* Maps data modality from index/datasets API response.
90+
* @param response - Response model return from index/datasets API.
91+
* @returns a list of data modalities.
92+
*/
93+
export function getDatasetDataModalities(
94+
response: DatasetEntityResponse
95+
): MetadataValue[] {
96+
return processAggregatedOrArrayValue(response.datasets, "data_modality");
97+
}
8798
/**
8899
* Maps dataset-related information, included formatted display text from API response.
89100
* @param response - Response model return from datasets or dataset API endpoints.

app/viewModelBuilders/azul/anvil-cmg/common/viewModelBuilders.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import {
5858
import {
5959
ActivityEntityResponse,
6060
BioSampleEntityResponse,
61+
DatasetEntityResponse,
6162
DonorEntityResponse,
6263
FileEntityResponse,
6364
FileFormat,
@@ -82,6 +83,7 @@ import {
8283
getBioSampleId,
8384
getBioSampleType,
8485
getConsentGroup,
86+
getDatasetDataModalities,
8587
getDatasetDetails,
8688
getDatasetEntryId,
8789
getDocumentId,
@@ -317,6 +319,20 @@ export function buildDatasetAccessibilityBadge(
317319
return { badgeProps, fadeProps };
318320
}
319321

322+
/**
323+
* Build props for dataset data modality NTagCell component from the given datasets response.
324+
* @param response - Response model return from index/datasets API endpoint.
325+
* @returns model to be used as props for the NTagCell component.
326+
*/
327+
export const buildDatasetDataModality = (
328+
response: DatasetEntityResponse
329+
): React.ComponentProps<typeof C.NTagCell> => {
330+
return {
331+
label: getPluralizedMetadataLabel(METADATA_KEY.DATA_MODALITY),
332+
values: getDatasetDataModalities(response),
333+
};
334+
};
335+
320336
/**
321337
* Build props for Markdown component from the given entity response.
322338
* @param datasetsResponse - Response model return from datasets API.

site-config/anvil-cmg/category.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const ANVIL_CMG_CATEGORY_KEY = {
1010
BIOSAMPLE_TYPE: "biosample_type",
1111
DATASET_ACCESSIBLE: "datasets.accessible",
1212
DATASET_CONSENT_GROUP: "datasets.consent_group",
13+
DATASET_DATA_MODALITY: "datasets.data_modality",
1314
DATASET_ID: "dataset_id",
1415
DATASET_REGISTERED_ID: "datasets.registered_identifier",
1516
DATASET_TITLE: "datasets.title",
@@ -19,6 +20,7 @@ export const ANVIL_CMG_CATEGORY_KEY = {
1920
DONOR_ORGANISM_TYPE: "donors.organism_type",
2021
DONOR_PHENOTYPIC_SEX: "donors.phenotypic_sex",
2122
DONOR_REPORTED_ETHNICITY: "donors.reported_ethnicity",
23+
FILE_DATA_MODALITY: "files.data_modality",
2224
FILE_FILE_FORMAT: "files.file_format",
2325
FILE_FILE_NAME: "files.file_name",
2426
FILE_FILE_SIZE: "files.file_size",
@@ -27,10 +29,12 @@ export const ANVIL_CMG_CATEGORY_KEY = {
2729
PREP_MATERIAL_NAME: "prep_material_name",
2830
};
2931

32+
const DATA_MODALITY_LABEL = "Data Modality";
33+
3034
export const ANVIL_CMG_CATEGORY_LABEL = {
3135
ACCESSIBLE: "Access",
3236
ACTIVITY_ACTIVITY_TYPE: "Activity Type",
33-
ACTIVITY_DATA_MODALITY: "Data Modality",
37+
ACTIVITY_DATA_MODALITY: DATA_MODALITY_LABEL,
3438
ACTIVITY_DOCUMENT_ID: "Document Id",
3539
AZUL_FILE_DOWNLOAD: " ",
3640
BIOSAMPLE_ANATOMICAL_SITE: "Anatomical Site",
@@ -39,6 +43,7 @@ export const ANVIL_CMG_CATEGORY_LABEL = {
3943
BIOSAMPLE_TYPE: "BioSample Type",
4044
DATASET_ACCESSIBLE: "Access",
4145
DATASET_CONSENT_GROUP: "Consent Group",
46+
DATASET_DATA_MODALITY: DATA_MODALITY_LABEL,
4247
DATASET_ID: "Dataset Name",
4348
DATASET_REGISTERED_ID: "Identifier",
4449
DATASET_TITLE: "Dataset",
@@ -48,6 +53,7 @@ export const ANVIL_CMG_CATEGORY_LABEL = {
4853
DONOR_ORGANISM_TYPE: "Organism Type",
4954
DONOR_PHENOTYPIC_SEX: "Phenotypic Sex",
5055
DONOR_REPORTED_ETHNICITY: "Reported Ethnicity",
56+
FILE_DATA_MODALITY: DATA_MODALITY_LABEL,
5157
FILE_FILE_FORMAT: "File Format",
5258
FILE_FILE_NAME: "Name",
5359
FILE_FILE_SIZE: "Size",

site-config/anvil-cmg/dev/index/datasetsEntityConfig.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ export const datasetsEntityConfig: EntityConfig<DatasetsResponse> = {
134134
{
135135
componentConfig: {
136136
component: C.NTagCell,
137-
viewBuilder: V.buildDataModality,
137+
viewBuilder: V.buildDatasetDataModality,
138138
} as ComponentConfig<typeof C.NTagCell>,
139-
header: ANVIL_CMG_CATEGORY_LABEL.ACTIVITY_DATA_MODALITY,
140-
id: ANVIL_CMG_CATEGORY_KEY.ACTIVITY_DATA_MODALITY,
139+
header: ANVIL_CMG_CATEGORY_LABEL.DATASET_DATA_MODALITY,
140+
id: ANVIL_CMG_CATEGORY_KEY.DATASET_DATA_MODALITY,
141141
width: { max: "1fr", min: "148px" },
142142
},
143143
],

site-config/anvil-cmg/dev/index/filesEntityConfig.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ export const filesEntityConfig: EntityConfig<FilesResponse> = {
8787
component: C.NTagCell,
8888
viewBuilder: V.buildFileDataModality,
8989
} as ComponentConfig<typeof C.NTagCell>,
90-
header: ANVIL_CMG_CATEGORY_LABEL.ACTIVITY_DATA_MODALITY,
91-
id: ANVIL_CMG_CATEGORY_KEY.ACTIVITY_DATA_MODALITY,
90+
header: ANVIL_CMG_CATEGORY_LABEL.FILE_DATA_MODALITY,
91+
id: ANVIL_CMG_CATEGORY_KEY.FILE_DATA_MODALITY,
9292
width: { max: "1fr", min: "140px" },
9393
},
9494
{

0 commit comments

Comments
 (0)