Skip to content

Commit ce8b615

Browse files
MillenniumFalconMechanicNoopDog
authored andcommitted
Added species selection to get matrix journey. Resolves #891. (#972)
* Added species selection to get matrix journey. Resolves #891. * Updated partial query match calculation to exclude mouse. Resolves #891.
1 parent 3add249 commit ce8b615

16 files changed

+768
-37
lines changed

spa/src/app/files/files.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import { HCAGetDataFileSummaryComponent } from "./hca-get-data/hca-get-data-file
5555
import { HCAGetDataSummaryComponent } from "./hca-get-data/hca-get-data-summary/hca-get-data-summary.component";
5656
import { HCAGetManifestComponent } from "./hca-get-data/hca-get-manifest/hca-get-manifest.component";
5757
import { HCAGetMatrixComponent } from "./hca-get-data/hca-get-matrix/hca-get-matrix.component";
58+
import { HCAGetMatrixSpeciesSelectionComponent } from "./hca-get-data/hca-get-matrix-species-selection/hca-get-matrix-species-selection.component";
5859
import { MatrixPartialQueryMatchWarningComponent } from "./hca-get-data/matrix-partial-query-match-warning/matrix-partial-query-match-warning.component";
5960
import { MatrixUrlRequestFormComponent } from "./hca-get-data/matrix-url-request-form/matrix-url-request-form.component";
6061
import { MatrixUrlRequestCompletedComponent } from "./hca-get-data/matrix-url-request-completed/matrix-url-request-completed.component";
@@ -160,6 +161,7 @@ import { TableScroll } from "./table-scroll/table-scroll.component";
160161
HCAGetDataSummaryComponent,
161162
HCAGetManifestComponent,
162163
HCAGetMatrixComponent,
164+
HCAGetMatrixSpeciesSelectionComponent,
163165
HCAProjectComponent,
164166
HCASearchComponent,
165167
HCATableCellComponent,

spa/src/app/files/hca-get-data/download-view-state.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
export enum DownloadViewState {
99
"MANIFEST" = "MANIFEST",
1010
"MATRIX" = "MATRIX",
11+
"MATRIX_SPECIES_SELECTION" = "MATRIX_SPECIES_SELECTION",
1112
"NONE" = "NONE",
1213
"TERRA" = "TERRA"
1314
}

spa/src/app/files/hca-get-data/hca-get-data-downloads/hca-get-data-downloads.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ <h4 class="fontsize-m semi-bold">Create Concatenated Expression Matrix</h4>
2222
<div class="start">
2323
<button class="button secondary"
2424
type="button"
25-
(click)="onStartGetData('MATRIX')"
25+
(click)="onStartGetData(getMatrixDownloadAction())"
2626
[disabled]="!matrixEnabled">Start
2727
</button>
2828
<!--<p class="fontsize-m delimiter">|</p><a><p class="fontsize-m">Help</p></a>-->

spa/src/app/files/hca-get-data/hca-get-data-downloads/hca-get-data-downloads.component.spec.ts

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe("HCAGetDataDownloadsComponent", () => {
6161
/**
6262
* Confirm is matrix supported loading returns false when matrix is supported.
6363
*/
64-
it("should is matrix supported loading return false when matrix is supported", () => {
64+
it("detects matrix supported loading is false when matrix is supported", () => {
6565

6666
// Confirm is matrix supported loading returns false, when matrix is supported - first execute the
6767
// method and then confirm the returned value is false.
@@ -72,7 +72,7 @@ describe("HCAGetDataDownloadsComponent", () => {
7272
/**
7373
* Confirm is matrix supported loading returns false when matrix is not supported.
7474
*/
75-
it("should is matrix supported loading return false when matrix is not supported", () => {
75+
it("detects matrix supported loading is false when matrix is not supported", () => {
7676

7777
// Confirm is matrix supported loading returns false, when matrix is not supported - first execute the
7878
// method and then confirm the returned value is false.
@@ -83,7 +83,7 @@ describe("HCAGetDataDownloadsComponent", () => {
8383
/**
8484
* Confirm is matrix supported loading returns true when matrix is not yet determined.
8585
*/
86-
it("should is matrix supported loading return true when matrix is not yet determined", () => {
86+
it("detects matrix supported as loading when matrix is not yet determined", () => {
8787

8888
// Confirm is matrix supported loading returns true, when matrix is not yet determined - first execute the
8989
// method and then confirm the returned value is true.
@@ -94,7 +94,7 @@ describe("HCAGetDataDownloadsComponent", () => {
9494
/**
9595
* Confirm "Create Concatenated Expression Matrix" is displayed.
9696
*/
97-
it(`should display "Create Concatenated Expression Matrix"`, () => {
97+
it(`displays "Create Concatenated Expression Matrix"`, () => {
9898

9999
// Confirm "Create Concatenated Expression Matrix" is displayed
100100
expect(isPanelHeaderDisplayed("Create Concatenated Expression Matrix")).toEqual(true);
@@ -103,7 +103,7 @@ describe("HCAGetDataDownloadsComponent", () => {
103103
/**
104104
* Confirm "Request an expression matrix for the selected data from the HCA Matrix service." is displayed when matrix enabled is true.
105105
*/
106-
it(`should display "Request an expression matrix for the selected data from the HCA Matrix service." when matrix enabled is true`, () => {
106+
it(`displays "Request an expression matrix for the selected data from the HCA Matrix service." when matrix enabled is true`, () => {
107107

108108
component.matrixEnabled = true;
109109
fixture.detectChanges();
@@ -115,7 +115,7 @@ describe("HCAGetDataDownloadsComponent", () => {
115115
/**
116116
* Confirm <warning> is not displayed when matrix enabled is true.
117117
*/
118-
it("should not display component warning when matrix enabled is true", () => {
118+
it("hides component warning when matrix enabled is true", () => {
119119

120120
component.matrixEnabled = true;
121121
fixture.detectChanges();
@@ -129,7 +129,7 @@ describe("HCAGetDataDownloadsComponent", () => {
129129
/**
130130
* Confirm matrix start button is not disabled when matrix enabled is true.
131131
*/
132-
it("should matrix start button is not disabled when matrix enabled is true", () => {
132+
it("enables matrix start button when matrix enabled is true", () => {
133133

134134
component.matrixEnabled = true;
135135
fixture.detectChanges();
@@ -144,7 +144,7 @@ describe("HCAGetDataDownloadsComponent", () => {
144144
/**
145145
* Confirm "Request an expression matrix for the selected data from the HCA Matrix service." is not displayed when matrix enabled is false.
146146
*/
147-
it(`should not display "Request an expression matrix for the selected data from the HCA Matrix service." when matrix enabled is false`, () => {
147+
it(`hides "Request an expression matrix for the selected data from the HCA Matrix service." when matrix enabled is false`, () => {
148148

149149
component.matrixEnabled = false;
150150
fixture.detectChanges();
@@ -156,7 +156,7 @@ describe("HCAGetDataDownloadsComponent", () => {
156156
/**
157157
* Confirm <warning> is displayed when matrix enabled is false.
158158
*/
159-
it("should display component warning when matrix enabled is false", () => {
159+
it("displays component warning when matrix enabled is false", () => {
160160

161161
component.matrixEnabled = false;
162162
fixture.detectChanges();
@@ -170,7 +170,7 @@ describe("HCAGetDataDownloadsComponent", () => {
170170
/**
171171
* Confirm matrix start button is disabled when matrix enabled is false.
172172
*/
173-
it("should matrix start button is not disabled when matrix enabled is false", () => {
173+
it("disables matrix start button when matrix enabled is false", () => {
174174

175175
component.matrixEnabled = false;
176176
fixture.detectChanges();
@@ -185,7 +185,7 @@ describe("HCAGetDataDownloadsComponent", () => {
185185
/**
186186
* Confirm "Request a File Manifest (for downloading files via the HCA CLI)" is displayed.
187187
*/
188-
it(`should display "Request a File Manifest (for downloading files via the HCA CLI)"`, () => {
188+
it(`displays "Request a File Manifest (for downloading files via the HCA CLI)"`, () => {
189189

190190
// Confirm "Request a File Manifest (for downloading files via the HCA CLI)" is displayed
191191
expect(isPanelHeaderDisplayed("Request a File Manifest (for downloading files via the HCA CLI)")).toEqual(true);
@@ -194,7 +194,7 @@ describe("HCAGetDataDownloadsComponent", () => {
194194
/**
195195
* Confirm "Export to Terra" is displayed
196196
*/
197-
it(`should display "Export to Terra"`, () => {
197+
it(`displays "Export to Terra"`, () => {
198198

199199
fixture.detectChanges();
200200

@@ -205,7 +205,7 @@ describe("HCAGetDataDownloadsComponent", () => {
205205
/**
206206
* Confirm emit "MATRIX" on click of matrix start button.
207207
*/
208-
it(`should emit "MATRIX" on click of matrix start button`, () => {
208+
it(`emits "MATRIX" on click of matrix start button`, () => {
209209

210210
component.matrixEnabled = true;
211211
fixture.detectChanges();
@@ -225,7 +225,7 @@ describe("HCAGetDataDownloadsComponent", () => {
225225
/**
226226
* Confirm emit "MANIFEST" on click of manifest start button.
227227
*/
228-
it(`should emit "MANIFEST" on click of manifest start button`, () => {
228+
it(`emits "MANIFEST" on click of manifest start button`, () => {
229229

230230
component.matrixEnabled = true;
231231
fixture.detectChanges();
@@ -245,7 +245,7 @@ describe("HCAGetDataDownloadsComponent", () => {
245245
/**
246246
* Confirm emit "TERRA" on click of terra start button.
247247
*/
248-
it(`should emit "TERRA" on click of terra start button`, () => {
248+
it(`emits "TERRA" on click of terra start button`, () => {
249249

250250
component.matrixEnabled = true;
251251
fixture.detectChanges();
@@ -262,6 +262,48 @@ describe("HCAGetDataDownloadsComponent", () => {
262262
expect(selectedDownload).toBe(DownloadViewState.TERRA);
263263
});
264264

265+
/**
266+
* Confirm emit "MATRIX_SPECIES_SELECTION" if matrix species selection is required.
267+
*/
268+
it(`emits "MATRIX_SPECIES_SELECTION" on click of matrix start button when species selection is required`, () => {
269+
270+
component.matrixEnabled = true;
271+
component.matrixSpeciesSelectionRequired = true;
272+
fixture.detectChanges();
273+
274+
let selectedDownload: string;
275+
component.downloadSelected.subscribe((download: string) => selectedDownload = download);
276+
277+
const matrixStartButton = getButtonEl("MATRIX");
278+
279+
// Execute click on terra start button
280+
matrixStartButton.triggerEventHandler("click", null);
281+
282+
// Confirm emit "TERRA"
283+
expect(selectedDownload).toBe(DownloadViewState.MATRIX_SPECIES_SELECTION);
284+
});
285+
286+
/**
287+
* Confirm emit "MATRIX" if matrix species selection is not required.
288+
*/
289+
it(`emits "MATRIX" on click of matrix start button when species selection is not required`, () => {
290+
291+
component.matrixEnabled = true;
292+
component.matrixSpeciesSelectionRequired = false;
293+
fixture.detectChanges();
294+
295+
let selectedDownload: string;
296+
component.downloadSelected.subscribe((download: string) => selectedDownload = download);
297+
298+
const matrixStartButton = getButtonEl("MATRIX");
299+
300+
// Execute click on terra start button
301+
matrixStartButton.triggerEventHandler("click", null);
302+
303+
// Confirm emit "TERRA"
304+
expect(selectedDownload).toBe(DownloadViewState.MATRIX);
305+
});
306+
265307
/**
266308
* Returns button element for specified panel download type.
267309
*

spa/src/app/files/hca-get-data/hca-get-data-downloads/hca-get-data-downloads.component.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Component, ChangeDetectionStrategy, EventEmitter, Output, Input } from
1010

1111
// App dependencies
1212
import { ConfigService } from "../../../config/config.service";
13+
import { DownloadViewState } from "../download-view-state.model";
1314

1415
@Component({
1516
selector: "hca-get-data-downloads",
@@ -25,6 +26,7 @@ export class HCAGetDataDownloadsComponent {
2526

2627
// Inputs
2728
@Input() matrixEnabled: boolean;
29+
@Input() matrixSpeciesSelectionRequired: boolean;
2830

2931
// Outputs
3032
@Output() downloadSelected = new EventEmitter<string>();
@@ -36,6 +38,24 @@ export class HCAGetDataDownloadsComponent {
3638
this.portalURL = this.configService.getPortalURL();
3739
}
3840

41+
/**
42+
* Returns the download action for matrix - either MATRIX_SPECIES_SELECTION if species selection is required for
43+
* the current data, or MATRIX if species selection is not required.
44+
*
45+
* Note, this functionality will no longer be required once deep-linking to download related modes (matrix,
46+
* manifest, terra) is added.
47+
*
48+
* @returns {string}
49+
*/
50+
public getMatrixDownloadAction(): string {
51+
52+
if ( this.matrixSpeciesSelectionRequired ) {
53+
return DownloadViewState.MATRIX_SPECIES_SELECTION;
54+
}
55+
56+
return DownloadViewState.MATRIX;
57+
}
58+
3959
/**
4060
* Returns true if whether matrix is supported or not, is not yet determined.
4161
*

spa/src/app/files/hca-get-data/hca-get-data.component.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,18 @@
1111
<ng-container *ngSwitchDefault>
1212
<div *ngIf="state.matrixSupportedLoaded" [@fadeIn]>
1313
<hca-get-data-downloads [matrixEnabled]="state.matrixSupported"
14-
(downloadSelected)="onDownloadSelected($event)"></hca-get-data-downloads>
14+
[matrixSpeciesSelectionRequired]="state.matrixSpeciesSelectionRequired"
15+
(downloadSelected)="onDownloadSelected($event, state.fileFacets)"></hca-get-data-downloads>
1516
</div>
1617
<div class="spinner-container" *ngIf="!state.matrixSupportedLoaded">
1718
<mat-spinner *ngIf="true"
1819
class="hca-spinner hca-spinner-grey"
1920
diameter="32"></mat-spinner>
2021
</div>
2122
</ng-container>
23+
<hca-get-matrix-species-selection *ngSwitchCase="'MATRIX_SPECIES_SELECTION'"
24+
[speciesFileFacet]="getSpeciesFileFacet(state.fileFacets)"
25+
(speciesSelected)="onDownloadSelected('MATRIX')"></hca-get-matrix-species-selection>
2226
<hca-get-matrix *ngSwitchCase="'MATRIX'"></hca-get-matrix>
2327
<hca-get-manifest *ngSwitchCase="'MANIFEST'"></hca-get-manifest>
2428
<hca-export-to-terra *ngSwitchCase="'TERRA'"></hca-export-to-terra>

spa/src/app/files/hca-get-data/hca-get-data.component.ts

Lines changed: 66 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ export class HCAGetDataComponent implements OnInit {
6262
private store: Store<AppState>) {
6363
}
6464

65-
/**
66-
* Public API
67-
*/
68-
6965
/**
7066
* Returns null value for EntitySpec, no need for an active tab.
7167
*
@@ -88,16 +84,37 @@ export class HCAGetDataComponent implements OnInit {
8884
return [{key: selectedEntity.key, displayName: displayName}];
8985
}
9086

87+
/**
88+
* Find and return the species facet from the species set of facets.
89+
*
90+
* @param {FileFacet[]} fileFacets
91+
* @returns {FileFacet}
92+
*/
93+
public getSpeciesFileFacet(fileFacets: FileFacet[]): FileFacet {
94+
95+
return fileFacets.find(facet => facet.name === FileFacetName.GENUS_SPECIES);
96+
}
97+
98+
/**
99+
* Returns the page title.
100+
*
101+
* @returns {string}
102+
*/
91103
public getTitle(): string {
104+
105+
if ( this.viewState === DownloadViewState.MANIFEST ) {
106+
return "Request File Manifest";
107+
}
108+
109+
if ( this.viewState === DownloadViewState.TERRA ) {
110+
return "Export to Terra";
111+
}
112+
113+
if ( this.viewState === DownloadViewState.MATRIX || DownloadViewState.MATRIX_SPECIES_SELECTION ) {
114+
return "Request Expression Matrix";
115+
}
92116

93-
let downloadTitle = this.viewState === DownloadViewState.MANIFEST ?
94-
"Request File Manifest" :
95-
this.viewState === DownloadViewState.TERRA ?
96-
"Export to Terra" :
97-
this.viewState === DownloadViewState.MATRIX ?
98-
"Request Expression Matrix" :
99-
null;
100-
return this.viewState !== DownloadViewState.NONE ? downloadTitle : "Export Data";
117+
return "Export Data";
101118
}
102119

103120
/**
@@ -161,6 +178,40 @@ export class HCAGetDataComponent implements OnInit {
161178
}
162179
}
163180

181+
/**
182+
* Returns true if user must select the set of species to be included in a matrix download.
183+
*
184+
* For the set of species present in the current data:
185+
*
186+
* - one species, human, not selected, species selection required
187+
* - one species, non-human, not selected, species selection required
188+
* - one species, either human or non-human, selected, species selection not required
189+
* - more than one species, none selected, species selection required
190+
* - more than one species, at least one selected (either human or non-human), species selection not required
191+
*
192+
* @returns {boolean}
193+
*/
194+
private isMatrixSpeciesSelectionRequired(fileFacets: FileFacet[]): boolean {
195+
196+
const speciesFileFacet = this.getSpeciesFileFacet(fileFacets);
197+
if ( !speciesFileFacet ) {
198+
return false;
199+
}
200+
201+
const effectiveTerms = speciesFileFacet.getEffectiveTerms();
202+
203+
// There's only one species in our data set, species selection is required if the species is not currently
204+
// selected
205+
if ( effectiveTerms.length === 1 ) {
206+
return !effectiveTerms[0].selected;
207+
}
208+
209+
// There's more than one species in our data set, species selection is required if non species is currently
210+
// selected
211+
const selectedTerms = effectiveTerms.filter(term => term.selected);
212+
return selectedTerms.length === 0;
213+
}
214+
164215
/**
165216
* Returns true if whether matrix is supported or not, has been determined.
166217
*
@@ -225,10 +276,13 @@ export class HCAGetDataComponent implements OnInit {
225276
)
226277
.pipe(
227278
map(([selectedEntity, fileFacets, matrixSupported]) => {
279+
280+
const matrixSpeciesSelectionRequired = this.isMatrixSpeciesSelectionRequired(fileFacets);
228281

229282
return {
230283
selectedEntity,
231284
fileFacets,
285+
matrixSpeciesSelectionRequired,
232286
matrixSupported,
233287
matrixSupportedLoaded: this.isMatrixSupportedLoaded(matrixSupported)
234288
};

spa/src/app/files/hca-get-data/hca-get-data.state.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { FileFacet } from "../shared/file-facet.model";
1313
export interface HCAGetDataState {
1414

1515
fileFacets: FileFacet[];
16+
matrixSpeciesSelectionRequired: boolean;
1617
matrixSupported: boolean;
1718
matrixSupportedLoaded: boolean;
1819
selectedEntity: EntitySpec;

0 commit comments

Comments
 (0)