Skip to content

Commit 00388f7

Browse files
Fran McDadeFran McDade
authored andcommitted
Make Donor Count sortable. Resolves #858.
1 parent 33731c0 commit 00388f7

10 files changed

+219
-127
lines changed

spa/src/app/files/hca-table-projects/hca-table-projects.component.spec.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ describe("HCATableProjectsComponent", () => {
6262

6363
const INDEX_PROTOCOL_OBJECT_0 = 0;
6464

65+
const COLUMN_TITLE_DONORCOUNT = "Donor Count";
6566
const COLUMN_TITLE_TOTALCELLS = "Cell Count Estimate";
6667
const COLUMN_TITLE_WORKFLOW = "Analysis Protocol";
6768

69+
const COLUMN_NAME_DONORCOUNT = "donorCount";
6870
const COLUMN_NAME_TOTALCELLS = "totalCells";
6971
const COLUMN_NAME_WORKFLOW = "workflow";
7072

@@ -487,6 +489,36 @@ describe("HCATableProjectsComponent", () => {
487489
expect(findColumnCellComponent(INDEX_TABLE_ROW_SINGLE_VALUES, COLUMN_NAME_WORKFLOW, COMPONENT_NAME_HCA_CONTENT_UNSPECIFIED_DASH)).toBe(null);
488490
});
489491

492+
/**
493+
* Confirm donorCount column labeled as "Donor Count" is displayed.
494+
*/
495+
it(`should display column "Donor Count"`, () => {
496+
497+
testStore.pipe
498+
.and.returnValues(
499+
of(PROJECTS_TABLE_MODEL.data),
500+
of(PROJECTS_TABLE_MODEL.data),
501+
of(PROJECTS_TABLE_MODEL.loading),
502+
of(PROJECTS_TABLE_MODEL.pagination),
503+
of(PROJECTS_TABLE_MODEL.termCountsByFacetName),
504+
of(DEFAULT_FILE_SUMMARY),
505+
of(new Map()), // project matrix URLs
506+
of({
507+
status: ProjectTSVUrlRequestStatus.NOT_STARTED // selectProjectTSVUrlsByProjectId inside ProjectTSVDownloadComponent
508+
})
509+
);
510+
511+
component.selectedProjectIds = [];
512+
513+
// Trigger change detection so template updates accordingly
514+
fixture.detectChanges();
515+
516+
const columnHeaderDE = findHeader(COLUMN_NAME_DONORCOUNT);
517+
518+
// Confirm column title is displayed
519+
expect(columnHeaderDE.nativeElement.innerText).toEqual(COLUMN_TITLE_DONORCOUNT);
520+
});
521+
490522
/**
491523
* Confirm totalCells column labeled as "Cell Count Estimate" is displayed.
492524
*/

spa/src/app/files/hca-table-projects/project-row-mapper.mock.ts

Lines changed: 47 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -99,23 +99,24 @@ export const PROJECT_ROW_SINGLE_VALUES =
9999
"cellLines": [],
100100
"donorOrganisms": [
101101
{
102-
"id": [
103-
"420508"
102+
"biologicalSex": [
103+
"male"
104104
],
105+
"disease": [
106+
"x"
107+
],
108+
"donorCount": 15,
105109
"genusSpecies": [
106110
"Mus musculus"
107111
],
112+
"id": [
113+
"420508"
114+
],
108115
"organismAge": [
109116
"56"
110117
],
111118
"organismAgeUnit": [
112119
"day"
113-
],
114-
"biologicalSex": [
115-
"male"
116-
],
117-
"disease": [
118-
"x"
119120
]
120121
}
121122
],
@@ -283,24 +284,28 @@ export const PROJECT_ROW_MULTIPLE_VALUES_SINGLE_OBJECT =
283284
"cellLines": [],
284285
"donorOrganisms": [
285286
{
287+
"biologicalSex": [
288+
"male",
289+
"female"
290+
],
291+
"disease": ["H syndrome", "normal"],
292+
"donorCount": 12,
293+
"genusSpecies": [
294+
"Mus musculus",
295+
"Homo sapiens"
296+
],
286297
"id": [
287298
"420508",
288299
"123456"
289300
],
290-
"genusSpecies": [
291-
"Mus musculus"
292-
],
293301
"organismAge": [
294-
"56"
302+
"56",
303+
"44"
295304
],
296305
"organismAgeUnit": [
297306
"day",
298307
"week"
299-
],
300-
"biologicalSex": [
301-
"male"
302-
],
303-
"disease": null
308+
]
304309
}
305310
],
306311
"organoids": [],
@@ -524,46 +529,47 @@ export const PROJECT_ROW_VALUES_ACROSS_MULTIPLE_OBJECTS =
524529
"cellLines": [],
525530
"donorOrganisms": [
526531
{
527-
"id": [
528-
"420508"
532+
"biologicalSex": [
533+
"male"
529534
],
535+
"disease": ["normal"],
536+
"donorCount": 8,
530537
"genusSpecies": [
531538
"Mus musculus"
532539
],
540+
"id": [
541+
"420508"
542+
],
533543
"organismAge": [
534544
"56"
535545
],
536546
"organismAgeUnit": [
537-
"day",
538-
"week"
539-
],
540-
"biologicalSex": [
541-
"male"
542-
],
543-
"disease": null
547+
"day"
548+
]
544549
},
545550
{
546-
"id": [
551+
"biologicalSex": [
547552
"x",
548553
"y"
549554
],
550-
"genusSpecies": [
555+
"disease": [
551556
"x",
552557
"y"
553558
],
554-
"organismAge": [
559+
"donorCount": 3,
560+
"genusSpecies": [
555561
"x",
556562
"y"
557563
],
558-
"organismAgeUnit": [
564+
"id": [
559565
"x",
560566
"y"
561567
],
562-
"biologicalSex": [
568+
"organismAge": [
563569
"x",
564570
"y"
565571
],
566-
"disease": [
572+
"organismAgeUnit": [
567573
"x",
568574
"y"
569575
]
@@ -679,12 +685,13 @@ export const PROJECT_ROW_EMPTY_ARRAY_VALUES =
679685
"cellLines": [],
680686
"donorOrganisms": [
681687
{
682-
"id": [],
688+
"biologicalSex": [],
689+
"disease": [],
683690
"genusSpecies": [],
691+
"donorCount": 1,
692+
"id": [],
684693
"organismAge": [],
685-
"organismAgeUnit": [],
686-
"biologicalSex": [],
687-
"disease": []
694+
"organismAgeUnit": []
688695
}
689696
],
690697
"organoids": [],
@@ -757,12 +764,13 @@ export const PROJECT_ROW_NULL_VALUES =
757764
],
758765
"donorOrganisms": [
759766
{
760-
"id": null,
767+
"biologicalSex": null,
768+
"disease": null,
769+
"donorCount": null,
761770
"genusSpecies": null,
771+
"id": null,
762772
"organismAge": null,
763773
"organismAgeUnit": null,
764-
"biologicalSex": null,
765-
"disease": null
766774
}
767775
],
768776
"organoids": null,

spa/src/app/files/hca-table-projects/project-row-mapper.spec.ts

Lines changed: 50 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -67,49 +67,6 @@ describe("ProjectRowMapper:", () => {
6767
})
6868
});
6969

70-
/**
71-
* A null project summary should map donor count to "Unspecified".
72-
*/
73-
it(`should map donor count of null project summary to "Unspecified"`, (done: DoneFn) => {
74-
75-
dataSource = new EntitiesDataSource<ProjectRowMapper>(of([PROJECT_ROW_NULL_VALUES]), ProjectRowMapper);
76-
dataSource.connect().subscribe((rows) => {
77-
78-
const mappedProject = rows[0];
79-
expect(mappedProject.donorCount).toEqual(0);
80-
done();
81-
})
82-
});
83-
84-
/**
85-
* Donor count, when specified, should be mapped
86-
*/
87-
it("should map donor count", (done: DoneFn) => {
88-
89-
const projectToMap = PROJECT_ROW_SINGLE_VALUES;
90-
dataSource = new EntitiesDataSource<ProjectRowMapper>(of([projectToMap]), ProjectRowMapper);
91-
dataSource.connect().subscribe((rows) => {
92-
93-
const mappedProject = rows[0];
94-
expect(mappedProject.donorCount).toEqual(projectToMap.donorOrganisms[0].id.length);
95-
done();
96-
})
97-
});
98-
99-
/**
100-
* A null donor count should be mapped to "Unspecified"
101-
*/
102-
it(`should map null donor count to "Unspecified"`, (done: DoneFn) => {
103-
104-
dataSource = new EntitiesDataSource<ProjectRowMapper>(of([PROJECT_ROW_NULL_VALUES]), ProjectRowMapper);
105-
dataSource.connect().subscribe((rows) => {
106-
107-
const mappedProject = rows[0];
108-
expect(mappedProject.donorCount).toEqual(0);
109-
done();
110-
})
111-
});
112-
11370
/**
11471
* Entry ID should be mapped
11572
*/
@@ -230,11 +187,11 @@ describe("ProjectRowMapper:", () => {
230187
});
231188

232189
/**
233-
* An age unit value that is an empty array should be mapped to "Unspecified"
190+
* A null project short name should be mapped to "Unspecified"
234191
*/
235-
it(`should map an empty age unit array to "Unspecified"`, (done: DoneFn) => {
192+
it(`should map null project short name to "Unspecified"`, (done: DoneFn) => {
236193

237-
dataSource = new EntitiesDataSource<ProjectRowMapper>(of([PROJECT_ROW_EMPTY_ARRAY_VALUES]), ProjectRowMapper);
194+
dataSource = new EntitiesDataSource<ProjectRowMapper>(of([PROJECT_ROW_NULL_VALUES]), ProjectRowMapper);
238195
dataSource.connect().subscribe((rows) => {
239196

240197
const mappedProject = rows[0];
@@ -244,11 +201,56 @@ describe("ProjectRowMapper:", () => {
244201
});
245202

246203
/**
247-
* A null project short name should be mapped to "Unspecified"
204+
* Donor count, when specified, should be included in mapping.
248205
*/
249-
it(`should map null project short name to "Unspecified"`, (done: DoneFn) => {
206+
it("should map donor count", (done: DoneFn) => {
207+
208+
const projectToMap = PROJECT_ROW_SINGLE_VALUES;
209+
dataSource = new EntitiesDataSource<ProjectRowMapper>(of([projectToMap]), ProjectRowMapper);
210+
dataSource.connect().subscribe((rows) => {
211+
212+
const mappedProject = rows[0];
213+
expect(mappedProject.donorCount).toEqual(projectToMap.donorOrganisms[0].donorCount);
214+
done();
215+
})
216+
});
217+
218+
/**
219+
* Donor count across multiple projects should be rolled up and mapped
220+
*/
221+
it("should roll up and map donor count values across multiple projects", (done: DoneFn) => {
222+
223+
const projectToMap = PROJECT_ROW_VALUES_ACROSS_MULTIPLE_OBJECTS;
224+
dataSource = new EntitiesDataSource<ProjectRowMapper>(of([projectToMap]), ProjectRowMapper);
225+
dataSource.connect().subscribe((rows) => {
226+
227+
const mappedProject = rows[0];
228+
const expectedValue = mapMultipleValues(projectToMap.donorOrganisms, "donorCount");
229+
expect(mappedProject.donorCount).toEqual(expectedValue);
230+
done();
231+
})
232+
});
233+
234+
/**
235+
* A null donor count should be mapped to "Unspecified"
236+
*/
237+
it(`should map null donor count to "Unspecified"`, (done: DoneFn) => {
250238

251239
dataSource = new EntitiesDataSource<ProjectRowMapper>(of([PROJECT_ROW_NULL_VALUES]), ProjectRowMapper);
240+
dataSource.connect().subscribe((rows) => {
241+
242+
const mappedProject = rows[0];
243+
expect(mappedProject.donorCount).toEqual("Unspecified");
244+
done();
245+
})
246+
});
247+
248+
/**
249+
* An age unit value that is an empty array should be mapped to "Unspecified"
250+
*/
251+
it(`should map an empty age unit array to "Unspecified"`, (done: DoneFn) => {
252+
253+
dataSource = new EntitiesDataSource<ProjectRowMapper>(of([PROJECT_ROW_EMPTY_ARRAY_VALUES]), ProjectRowMapper);
252254
dataSource.connect().subscribe((rows) => {
253255

254256
const mappedProject = rows[0];

spa/src/app/files/hca-table-projects/project-row-mapper.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export class ProjectRowMapper extends FileTypeSummariesRowMapper {
2727
public mapRow(): EntityRow {
2828

2929
return Object.assign({}, super.mapRow(), {
30-
donorCount: (((this.row.donorOrganisms || [])[0] || {}).id || []).length, // Donor count is the number of IDs in the id field of donor organisms
3130
entryId: this.row.entryId,
3231
projectShortname: getUnspecifiedIfNullValue(this.projects.projectShortname)
3332
});

spa/src/app/files/hca-table-projects/project-row.model.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { EntityRow } from "../table/entity-row.model";
1010
import { FileTypeSummariesRow } from "../table/file-type-summaries-row.model";
1111

1212
export interface ProjectRow extends EntityRow, FileTypeSummariesRow {
13-
donorCount: number;
1413
entryId: string;
1514
projectShortname: string;
1615
}

0 commit comments

Comments
 (0)