Skip to content

Commit 688b575

Browse files
frano-mFran McDade
and
Fran McDade
authored
feat: configure file manifest summary (#888) (#3591)
Co-authored-by: Fran McDade <[email protected]>
1 parent 535cf15 commit 688b575

File tree

19 files changed

+859
-342
lines changed

19 files changed

+859
-342
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ export interface ActivityEntityResponse {
1515
activities: ActivityEntity[];
1616
}
1717

18+
/**
19+
* Model of activity type returned from the /index/summary API endpoint.
20+
*/
21+
export interface ActivityType {
22+
count: number;
23+
type: string;
24+
}
25+
1826
/**
1927
* Model of core biosample value returned from the /index/biosamples API endpoint.
2028
*/
@@ -67,6 +75,14 @@ export interface DonorEntityResponse {
6775
donors: DonorEntity[];
6876
}
6977

78+
/**
79+
* Model of donor species returned from the /index/summary API endpoint.
80+
*/
81+
export interface DonorSpecies {
82+
count: number;
83+
species: null; // TODO - when species type is known (currently returns null value).
84+
}
85+
7086
/**
7187
* Model of core file value returned from the /index/files API endpoint.
7288
*/
@@ -98,6 +114,14 @@ export interface LibraryEntity {
98114
prep_material_name: string;
99115
}
100116

117+
/**
118+
* Model of file format returned from the /index/summary API endpoint.
119+
*/
120+
export interface FileFormat {
121+
count: number;
122+
format: string;
123+
}
124+
101125
/**
102126
* Model of singleton array containing core library value returned from the /index/libraries API endpoint.
103127
*/

explorer/app/apis/azul/anvil-cmg/common/responses.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ import {
1010
} from "./aggregatedEntities";
1111
import {
1212
ActivityEntityResponse,
13+
ActivityType,
1314
BioSampleEntityResponse,
1415
DatasetEntityResponse,
1516
DonorEntityResponse,
17+
DonorSpecies,
1618
FileEntityResponse,
19+
FileFormat,
1720
LibraryEntityResponse,
1821
} from "./entities";
1922

@@ -83,3 +86,19 @@ export type LibrariesResponse = AzulHit &
8386
AggregatedDatasetResponse &
8487
AggregatedDonorResponse &
8588
AggregatedFileResponse;
89+
90+
/**
91+
* Model of response returned from /index/summary API endpoint.
92+
*/
93+
export type SummaryResponse = {
94+
activityCount: number;
95+
activityTypes: ActivityType[];
96+
biosampleCount: number;
97+
datasetCount: number;
98+
donorCount: number;
99+
donorDiagnosisDiseases: unknown[]; // TODO - when type is known.
100+
donorDiagnosisPhenotypes: unknown[]; // TODO - when type is known.
101+
donorSpecies: DonorSpecies[];
102+
fileCount: number;
103+
fileFormats: FileFormat[];
104+
};

explorer/app/apis/azul/hca-dcp/common/entities.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ export interface AccessionResponse {
66
namespace: string;
77
}
88

9+
/**
10+
* Model of cell count summary from index/summary API endpoints.
11+
*/
12+
export interface CellCountSummary {
13+
countOfDocsWithOrganType: number;
14+
organType: string[];
15+
totalCellCountByOrgan: number;
16+
}
17+
918
/**
1019
* Model of contributor value in the response from index/projects API endpoint.
1120
*/
@@ -44,6 +53,16 @@ export interface FileResponse {
4453
version: string;
4554
}
4655

56+
/**
57+
* Model of file type summary from index/summary API endpoints.
58+
*/
59+
export interface FileTypeSummary {
60+
count: number;
61+
format: string;
62+
matrixCellCount: number;
63+
totalSize: number;
64+
}
65+
4766
/**
4867
* Model of file "leaf" values in matrix tree response from Azul.
4968
*/
@@ -89,6 +108,14 @@ export interface ProjectsEntityResponse {
89108
projects: ProjectResponse[];
90109
}
91110

111+
/**
112+
* Model of project summary in the response from /index/summary API endpoint.
113+
*/
114+
export interface ProjectSummary {
115+
cellSuspensions: { totalCells: number };
116+
projects: { estimatedCellCount: number };
117+
}
118+
92119
/**
93120
* Model of publication value in the response from index/projects API endpoint.
94121
*/

explorer/app/apis/azul/hca-dcp/common/responses.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ import {
99
AggregatedSpecimensResponse,
1010
} from "./aggregatedEntities";
1111
import {
12+
CellCountSummary,
1213
FilesEntityResponse,
14+
FileTypeSummary,
1315
ProjectsEntityResponse,
16+
ProjectSummary,
1417
SamplesEntityResponse,
1518
} from "./entities";
1619

@@ -54,3 +57,20 @@ export type SamplesResponse = AzulHit &
5457
AggregatedProjectsResponse &
5558
AggregatedProtocolsResponse &
5659
AggregatedSpecimensResponse;
60+
61+
/**
62+
* Model of response returned from /index/summary API endpoint.
63+
*/
64+
export type SummaryResponse = {
65+
cellCountSummaries: CellCountSummary[];
66+
donorCount: number;
67+
fileCount: number;
68+
fileTypeSummaries: FileTypeSummary[];
69+
labCount: number;
70+
organTypes: string[];
71+
projectCount: number;
72+
projects: ProjectSummary[];
73+
speciesCount: number;
74+
specimenCount: number;
75+
totalFileSize: number | string;
76+
};

explorer/app/components/Index/common/utils.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,34 @@
11
import { AzulSummaryResponse } from "@clevercanary/data-explorer-ui/lib/apis/azul/common/entities";
2+
import { FileFormat } from "../../../apis/azul/anvil-cmg/common/entities";
3+
import { ProjectSummary } from "../../../apis/azul/hca-dcp/common/entities";
24

35
/**
46
* Calculates the summary file format count using count values returned for each file format in the summary response.
7+
* TODO review configuration of summary response model and use of this method to calculate file formats.
58
* @param summaryResponse - Response model return from summary API.
69
* @returns count of file formats.
710
*/
811
export function calculateSummaryFileFormatsCount(
912
summaryResponse: AzulSummaryResponse
1013
): number {
11-
return (summaryResponse.fileFormats ?? []).reduce((accum, { count }) => {
12-
return accum + count;
13-
}, 0);
14+
return ((summaryResponse.fileFormats as FileFormat[]) ?? []).reduce(
15+
(accum, { count }) => {
16+
return accum + count;
17+
},
18+
0 as number
19+
);
1420
}
1521

1622
/**
1723
* Calculates the summary total cell count using the estimatedCellCount and totalCells values fom the summary response.
24+
* TODO review configuration of summary response model and use of this method to calculate total cell count.
1825
* @param summaryResponse - Response model return from summary API.
1926
* @returns count of total cell count.
2027
*/
2128
export function calculateSummaryTotalCellCount(
2229
summaryResponse: AzulSummaryResponse
2330
): number {
24-
return (summaryResponse.projects ?? []).reduce(
31+
return ((summaryResponse.projects as ProjectSummary[]) ?? []).reduce(
2532
(accum, { cellSuspensions, projects }) => {
2633
if (
2734
projects &&

explorer/app/components/Index/components/AccessStatusBadge/accessStatusBadge.styles.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ interface AccessStatusBadgeProps {
55
accessible: boolean;
66
}
77

8-
export const AccessStatusBadge = styled(Chip)<AccessStatusBadgeProps>`
8+
export const AccessStatusBadge = styled(Chip, {
9+
shouldForwardProp: (prop) => prop !== "accessible",
10+
})<AccessStatusBadgeProps>`
911
background-color: ${({ accessible, theme }) =>
1012
accessible ? theme.palette.success.light : theme.palette.warning.light};
1113
color: ${({ accessible, theme }) =>

explorer/app/viewModelBuilders/azul/hca-dcp/common/dataSummaryMapper/dataSummaryMapper.ts

Lines changed: 1 addition & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
import { LABEL } from "@clevercanary/data-explorer-ui/lib/apis/azul/common/entities";
22
import { stringifyValues } from "@clevercanary/data-explorer-ui/lib/common/utils";
33
import { Value } from "@clevercanary/data-explorer-ui/lib/components/common/KeyValuePairs/keyValuePairs";
4-
import {
5-
displaySummaryTerms,
6-
listSelectedTermsOfFacet,
7-
} from "@clevercanary/data-explorer-ui/lib/components/Export/components/ExportSummary/common/utils";
84
import { ANCHOR_TARGET } from "@clevercanary/data-explorer-ui/lib/components/Links/common/entities";
95
import { Links } from "@clevercanary/data-explorer-ui/lib/components/Links/links";
106
import { getConfig } from "@clevercanary/data-explorer-ui/lib/config/config";
11-
import { FileManifest } from "@clevercanary/data-explorer-ui/lib/hooks/useFileManifest/common/entities";
127
import { formatCountSize } from "@clevercanary/data-explorer-ui/lib/utils/formatCountSize";
13-
import { formatFileSize } from "@clevercanary/data-explorer-ui/lib/utils/formatFileSize";
14-
import {
15-
HCA_DCP_CATEGORY_KEY,
16-
HCA_DCP_CATEGORY_LABEL,
17-
} from "../../../../../../site-config/hca-dcp/category";
8+
import { HCA_DCP_CATEGORY_KEY } from "../../../../../../site-config/hca-dcp/category";
189
import {
1910
processAggregatedBooleanOrArrayValue,
2011
processAggregatedNumberEntityValue,
@@ -226,87 +217,3 @@ export function mapProjectDataSummary(
226217
details.set(DATA_SUMMARY.DONOR_COUNT, formatCountSize(donorCount)); // Donor Count
227218
return details;
228219
}
229-
230-
/**
231-
* Maps export summary related information, included formatted display text from the given file manifest.
232-
* @param fileManifest - File manifest.
233-
* @returns summaries key-value pairs of data summary and corresponding value.
234-
*/
235-
export function mapExportSummary(
236-
fileManifest: FileManifest
237-
): Map<DATA_SUMMARY | string, string> {
238-
const { filesFacets, fileSummary } = fileManifest;
239-
// Grab summary values.
240-
const donorCount = fileSummary.donorCount;
241-
const donorDisease = listSelectedTermsOfFacet(
242-
filesFacets,
243-
HCA_DCP_CATEGORY_KEY.DONOR_DISEASE
244-
);
245-
const fileCount = fileSummary.fileCount;
246-
const genusSpecies = listSelectedTermsOfFacet(
247-
filesFacets,
248-
HCA_DCP_CATEGORY_KEY.GENUS_SPECIES
249-
);
250-
const libraryConstructionApproach = listSelectedTermsOfFacet(
251-
filesFacets,
252-
HCA_DCP_CATEGORY_KEY.LIBRARY_CONSTRUCTION_METHOD
253-
);
254-
const organ = listSelectedTermsOfFacet(
255-
filesFacets,
256-
HCA_DCP_CATEGORY_KEY.ORGAN
257-
);
258-
const organPart = listSelectedTermsOfFacet(
259-
filesFacets,
260-
HCA_DCP_CATEGORY_KEY.ORGAN_PART
261-
);
262-
const pairedEnd = listSelectedTermsOfFacet(
263-
filesFacets,
264-
HCA_DCP_CATEGORY_KEY.PAIRED_END
265-
);
266-
const projectCount = fileSummary.projectCount;
267-
const specimenCount = fileSummary.specimenCount;
268-
const specimenDisease = listSelectedTermsOfFacet(
269-
filesFacets,
270-
HCA_DCP_CATEGORY_KEY.SPECIMEN_DISEASE
271-
);
272-
const totalCellCount = fileSummary.totalCellCount;
273-
const totalFileSize = fileSummary.totalFileSize;
274-
275-
// Map summary by summary key or display text.
276-
const summaryBySummaryKey = new Map<DATA_SUMMARY | string, string>();
277-
summaryBySummaryKey.set("Estimated Cells", formatCountSize(totalCellCount));
278-
summaryBySummaryKey.set(
279-
HCA_DCP_CATEGORY_LABEL.FILE_SIZE,
280-
formatFileSize(totalFileSize)
281-
);
282-
summaryBySummaryKey.set("Files", formatCountSize(fileCount));
283-
summaryBySummaryKey.set("Projects", formatCountSize(projectCount));
284-
summaryBySummaryKey.set(
285-
DATA_SUMMARY.GENUS_SPECIES,
286-
displaySummaryTerms(genusSpecies)
287-
);
288-
summaryBySummaryKey.set("Donors", formatCountSize(donorCount));
289-
summaryBySummaryKey.set(
290-
DATA_SUMMARY.DONOR_DISEASE,
291-
displaySummaryTerms(donorDisease)
292-
); // Disease Status (Donor)
293-
summaryBySummaryKey.set("Specimens", formatCountSize(specimenCount));
294-
summaryBySummaryKey.set(
295-
DATA_SUMMARY.DISEASE,
296-
displaySummaryTerms(specimenDisease)
297-
); // Disease Status (Specimen)
298-
summaryBySummaryKey.set(DATA_SUMMARY.ORGAN, displaySummaryTerms(organ)); // Anatomical Entity
299-
summaryBySummaryKey.set(
300-
DATA_SUMMARY.ORGAN_PART,
301-
displaySummaryTerms(organPart)
302-
);
303-
summaryBySummaryKey.set(
304-
DATA_SUMMARY.LIBRARY_CONSTRUCTION_APPROACH,
305-
displaySummaryTerms(libraryConstructionApproach)
306-
); // Library Construction Method
307-
summaryBySummaryKey.set(
308-
DATA_SUMMARY.PAIRED_END,
309-
displaySummaryTerms(pairedEnd)
310-
); // Paired End
311-
return summaryBySummaryKey;
312-
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { HCA_DCP_CATEGORY_LABEL } from "../../../../../../site-config/hca-dcp/category";
2+
import { FileSummary, SUMMARY } from "./entities";
3+
4+
export const DEFAULT_SUMMARY: FileSummary = {
5+
donorCount: 0,
6+
fileCount: 0,
7+
fileTypeSummaries: [],
8+
organTypes: [],
9+
projectCount: 0,
10+
specimenCount: 0,
11+
totalCellCount: 0,
12+
totalFileSize: 0,
13+
};
14+
15+
/**
16+
* Display text for summaries.
17+
*/
18+
export const SUMMARY_DISPLAY_TEXT = {
19+
[SUMMARY.DONOR_COUNT]: "Donors",
20+
[SUMMARY.DONOR_DISEASE]: "Disease Status (Donor)",
21+
[SUMMARY.FILE_COUNT]: "Files",
22+
[SUMMARY.GENUS_SPECIES]: "Species",
23+
[SUMMARY.LIBRARY_CONSTRUCTION_APPROACH]:
24+
HCA_DCP_CATEGORY_LABEL.LIBRARY_CONSTRUCTION_METHOD,
25+
[SUMMARY.ORGAN]: HCA_DCP_CATEGORY_LABEL.ANATOMICAL_ENTITY, // anatomical entity
26+
[SUMMARY.ORGAN_PART]: HCA_DCP_CATEGORY_LABEL.ORGAN_PART,
27+
[SUMMARY.PAIRED_END]: HCA_DCP_CATEGORY_LABEL.PAIRED_END,
28+
[SUMMARY.PROJECT_COUNT]: "Projects",
29+
[SUMMARY.SPECIMEN_COUNT]: "Specimens",
30+
[SUMMARY.SPECIMEN_DISEASE]: "Disease Status (Specimen)",
31+
[SUMMARY.TOTAL_CELL_COUNT]: "Estimated Cells",
32+
[SUMMARY.TOTAL_FILE_SIZE]: HCA_DCP_CATEGORY_LABEL.FILE_SIZE,
33+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Model of file summary.
3+
*/
4+
export interface FileSummary {
5+
donorCount: number;
6+
fileCount: number;
7+
fileTypeSummaries: FileTypeSummary[];
8+
organTypes: string[];
9+
projectCount: number;
10+
specimenCount: number;
11+
totalCellCount: number;
12+
totalFileSize: number;
13+
}
14+
15+
/**
16+
* Model of file type summary.
17+
*/
18+
export interface FileTypeSummary {
19+
count: number;
20+
fileType: string;
21+
matrixCellCount: number;
22+
totalSize: number;
23+
}
24+
25+
/**
26+
* Possible set of summaries.
27+
*/
28+
export const enum SUMMARY {
29+
DONOR_COUNT = "DONOR_COUNT",
30+
DONOR_DISEASE = "DONOR_DISEASE",
31+
FILE_COUNT = "FILE_COUNT",
32+
GENUS_SPECIES = "GENUS_SPECIES",
33+
LIBRARY_CONSTRUCTION_APPROACH = "LIBRARY_CONSTRUCTION_APPROACH",
34+
ORGAN = "ORGAN",
35+
ORGAN_PART = "ORGAN_PART",
36+
PAIRED_END = "PAIRED_END",
37+
PROJECT_COUNT = "PROJECT_COUNT",
38+
SPECIMEN_COUNT = "SPECIMEN_COUNT",
39+
SPECIMEN_DISEASE = "SPECIMEN_DISEASE",
40+
TOTAL_CELL_COUNT = "TOTAL_CELL_COUNT",
41+
TOTAL_FILE_SIZE = "TOTAL_FILE_SIZE",
42+
}

0 commit comments

Comments
 (0)