Skip to content
Snippets Groups Projects
Commit 1fddb2fb authored by Julian Matschinske's avatar Julian Matschinske
Browse files

Add select only option

parent ef21a48e
No related branches found
No related tags found
No related merge requests found
......@@ -82,7 +82,7 @@ export class AnalysisService {
});
}
public addItems(wrappers: Wrapper[]) {
public addItems(wrappers: Wrapper[]): number {
const addedWrappers: Wrapper[] = [];
for (const wrapper of wrappers) {
if (!this.inSelection(wrapper)) {
......@@ -91,6 +91,7 @@ export class AnalysisService {
}
}
this.selectListSubject.next({items: addedWrappers, selected: true});
return addedWrappers.length;
}
public removeItems(wrappers: Wrapper[]) {
......@@ -103,7 +104,7 @@ export class AnalysisService {
this.selectListSubject.next({items: removedWrappers, selected: false});
}
public addVisibleHostProteins(nodes, proteins) {
public addVisibleHostProteins(nodes, proteins): number {
const items: Wrapper[] = [];
const visibleIds = new Set<string>(nodes.getIds());
for (const protein of proteins) {
......@@ -115,9 +116,10 @@ export class AnalysisService {
}
}
this.selectListSubject.next({items, selected: true});
return items.length;
}
public addVisibleViralProteins(nodes, viralProteins) {
public addVisibleViralProteins(nodes, viralProteins): number {
const items: Wrapper[] = [];
const visibleIds = new Set<string>(nodes.getIds());
for (const viralProtein of viralProteins) {
......@@ -129,6 +131,7 @@ export class AnalysisService {
}
}
this.selectListSubject.next({items, selected: true});
return items.length;
}
public removeAllHostProteins() {
......
......@@ -9,10 +9,24 @@
<button (click)="close()" class="delete" aria-label="close"></button>
</header>
<section class="modal-card-body">
<div class="notification is-success" *ngIf="itemsAdded.length > 0">
{{itemsAdded.length}} host proteins have been added to the selection.
<div class="notification is-success" *ngIf="addedCount > 0">
{{addedCount}} host proteins have been added to the selection.
<div *ngIf="itemsFound.length > addedCount && !selectOnly">
{{itemsFound.length - addedCount}} proteins have already been selected before.
</div>
<div *ngIf="itemsFound.length > addedCount && selectOnly">
{{itemsFound.length - addedCount}} proteins either have been selected already or did not appear in the current graph.
</div>
</div>
<div class="notification is-warning" *ngIf="itemsFound.length > 0 && addedCount === 0">
<div *ngIf="itemsFound.length > addedCount && !selectOnly">
{{itemsFound.length - addedCount}} proteins have already been selected before.
</div>
<div *ngIf="itemsFound.length > addedCount && selectOnly">
{{itemsFound.length - addedCount}} proteins either have been selected already or did not appear in the current graph.
</div>
</div>
<div class="notification is-warning" *ngIf="notFound.length > 0">
<div class="notification is-danger" *ngIf="notFound.length > 0">
The following {{notFound.length}} Uniprot IDs could not be found and have been ignored:
<ul><li class="not-found" *ngFor="let nf of notFound">{{nf}}</li></ul>
</div>
......@@ -28,7 +42,7 @@
</section>
<footer class="modal-card-foot">
<button (click)="addProteins();" class="button is-success is-rounded has-tooltip"
data-tooltip="Add list of proteins to the selection."
data-tooltip="Add all to the selection."
[disabled]="proteins.length === 0">
<span class="icon">
<i class="fa fa-plus"></i>
......@@ -37,6 +51,16 @@
Add
</span>
</button>
<button (click)="addVisibleProteins();" class="button is-success is-rounded has-tooltip"
data-tooltip="Add to selection if they appear in the current network."
[disabled]="proteins.length === 0">
<span class="icon">
<i class="fas fa-expand"></i>
</span>
<span>
Select
</span>
</button>
<button (click)="close()" class="button is-rounded has-tooltip" data-tooltip="Close the current window.">Close
</button>
</footer>
......
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {environment} from '../../../environments/environment';
import {getWrapperFromProtein, Wrapper} from '../../interfaces';
import {getWrapperFromProtein, Protein, Wrapper} from '../../interfaces';
import {AnalysisService} from '../../analysis.service';
@Component({
......@@ -15,11 +15,15 @@ export class CustomProteinsComponent implements OnInit {
public show = false;
@Output()
public showChange = new EventEmitter<boolean>();
@Input()
public visibleNodes: Array<any> = [];
public textList = '';
public proteins: Array<string> = [];
public notFound: Array<string> = [];
public itemsAdded: Array<Wrapper> = [];
public itemsFound: Array<Wrapper> = [];
public addedCount = 0;
public selectOnly = false;
constructor(private http: HttpClient, private analysis: AnalysisService) { }
......@@ -28,23 +32,49 @@ export class CustomProteinsComponent implements OnInit {
public close() {
this.show = false;
this.textList = '';
this.proteins = [];
this.notFound = [];
this.itemsFound = [];
this.showChange.emit(this.show);
this.addedCount = 0;
this.selectOnly = false;
}
public async addProteins() {
this.notFound = [];
this.itemsAdded = [];
this.itemsFound = [];
const proteins = this.proteins;
this.changeTextList('');
const result = await this.http.post<any>(`${environment.backend}query_proteins/`, proteins).toPromise();
this.notFound = result.notFound;
const details = result.details;
const items = [];
for (const detail of details) {
items.push(getWrapperFromProtein(detail));
}
this.itemsFound = items;
this.addedCount = this.analysis.addItems(items);
this.selectOnly = false;
}
public async addVisibleProteins() {
this.notFound = [];
this.itemsFound = [];
const proteins = this.proteins;
this.changeTextList('');
const result = await this.http.post<any>(`${environment.backend}query_proteins/`, proteins).toPromise();
this.notFound = result.notFound;
const details = result.details;
const proteinItems = [];
const items = [];
for (const detail of details) {
proteinItems.push(detail as Protein);
items.push(getWrapperFromProtein(detail));
}
this.itemsAdded = items;
this.analysis.addItems(items);
this.itemsFound = items;
this.addedCount = this.analysis.addVisibleHostProteins(this.visibleNodes, proteinItems);
this.selectOnly = true;
}
public changeTextList(textList) {
......
......@@ -4,7 +4,7 @@
[dataset]="selectedDataset.backendId">
</app-launch-analysis>
<app-custom-proteins [(show)]="showCustomProteinsDialog">
<app-custom-proteins [(show)]="showCustomProteinsDialog" [visibleNodes]="currentViewNodes">
</app-custom-proteins>
<div class="covex explorer">
......@@ -433,7 +433,7 @@
Host Proteins
</span>
</a>
<a (click)="analysis.addVisibleViralProteins(currentViewNodes, currentViewEffects)"
<a (click)="analysis.addVisibleViralProteins(currentViewNodes, currentViewViralProteins)"
class="card-footer-item has-text-success" data-tooltip="Add all visible viral proteins.">
<span class="icon">
<i class="fa fa-eye"></i>
......
......@@ -67,8 +67,8 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
public currentDataset = [];
public currentViewProteins: Protein[];
public currentViewEffects: ViralProtein[];
public currentViewNodes: Node[];
public currentViewViralProteins: ViralProtein[];
public currentViewNodes: any[];
public datasetItems: Dataset[] = [
{
......@@ -306,7 +306,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
this.currentViewNodes = this.nodeData.nodes;
this.currentViewProteins = this.proteins;
this.currentViewEffects = this.effects;
this.currentViewViralProteins = this.effects;
}
public async filterNodes() {
......@@ -459,11 +459,11 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
if ($event) {
this.currentViewNodes = $event[0];
this.currentViewProteins = $event[1][0];
this.currentViewEffects = $event[1][1];
this.currentViewViralProteins = $event[1][1];
} else {
this.currentViewNodes = this.nodeData.nodes;
this.currentViewProteins = this.proteins;
this.currentViewEffects = this.effects;
this.currentViewViralProteins = this.effects;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment