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

Merge branch 'add-viral-proteins-to-query' into 'master'

Add viral proteins to query

See merge request covid-19/frontend!34
parents 2139350c c05eb7e2
No related branches found
No related tags found
No related merge requests found
<div class="content"> <div class="content">
<ng-select [items]="queryItems" bindLabel="proteinAc" [virtualScroll]="true" class="custom" <ng-select [items]="queryItems" bindLabel="name" bindValue="data" [virtualScroll]="true" class="custom"
placeholder="Search..." (change)="select($event)"> placeholder="Search..." (change)="select($event)">
<ng-template ng-option-tmp let-item="item">
<b>{{item.name}}</b> <br/>
<span *ngIf="item.type == 'Host Protein'"><small>{{item.type}}</small></span>
<span *ngIf="item.type == 'Viral Protein'"><small>{{item.data.virusName}}</small> | </span>
<span *ngIf="item.type == 'Viral Protein'"><small>{{item.data.datasetName}}</small> </span>
</ng-template>
</ng-select> </ng-select>
</div> </div>
import { Component, Input, Output, EventEmitter } from '@angular/core'; import { Component, Input, Output, EventEmitter } from '@angular/core';
import {Protein} from '../../interfaces'; import {QueryItem} from '../../interfaces';
@Component({ @Component({
selector: 'app-query-component', selector: 'app-query-component',
...@@ -9,11 +9,11 @@ import {Protein} from '../../interfaces'; ...@@ -9,11 +9,11 @@ import {Protein} from '../../interfaces';
export class QueryComponent { export class QueryComponent {
@Output() selectProtein: EventEmitter<Protein> = new EventEmitter(); @Output() selectItem: EventEmitter<any> = new EventEmitter();
@Input() queryItems: Protein[]; @Input() queryItems: QueryItem[];
select(protein) { select(item) {
this.selectProtein.emit(protein); this.selectItem.emit(item);
} }
} }
...@@ -46,3 +46,9 @@ export interface Task { ...@@ -46,3 +46,9 @@ export interface Task {
queueLength: number; queueLength: number;
}; };
} }
export interface QueryItem {
name: string;
type: 'Host Protein' | 'Viral Protein';
data: Protein | ViralProtein;
}
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
<div class="field"> <div class="field">
<div class="control"> <div class="control">
<app-query-component [queryItems]="queryItems" <app-query-component [queryItems]="queryItems"
(selectProtein)="openSummary($event, true)"></app-query-component> (selectItem)="queryAction($event)"></app-query-component>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -6,7 +6,7 @@ import { ...@@ -6,7 +6,7 @@ import {
ViewChild ViewChild
} from '@angular/core'; } from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {ProteinViralInteraction, ViralProtein, Protein} from '../../interfaces'; import {ProteinViralInteraction, ViralProtein, Protein, QueryItem} from '../../interfaces';
import {ProteinNetwork, getDatasetFilename} from '../../main-network'; import {ProteinNetwork, getDatasetFilename} from '../../main-network';
import {HttpClient, HttpParams} from '@angular/common/http'; import {HttpClient, HttpParams} from '@angular/common/http';
import {AnalysisService} from '../../analysis.service'; import {AnalysisService} from '../../analysis.service';
...@@ -15,7 +15,6 @@ import {environment} from '../../../environments/environment'; ...@@ -15,7 +15,6 @@ import {environment} from '../../../environments/environment';
declare var vis: any; declare var vis: any;
@Component({ @Component({
selector: 'app-explorer-page', selector: 'app-explorer-page',
templateUrl: './explorer-page.component.html', templateUrl: './explorer-page.component.html',
...@@ -43,7 +42,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -43,7 +42,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
private dumpPositions = false; private dumpPositions = false;
public physicsEnabled = false; public physicsEnabled = false;
public queryItems = []; public queryItems: QueryItem[] = [];
public showAnalysisDialog = false; public showAnalysisDialog = false;
public selectedAnalysisToken: string | null = null; public selectedAnalysisToken: string | null = null;
...@@ -150,9 +149,15 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -150,9 +149,15 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
if (!coords) { if (!coords) {
return; return;
} }
let zoomScale = null;
if (id.startsWith('eff')) {
zoomScale = 1.0;
} else {
zoomScale = 3.0;
}
this.network.moveTo({ this.network.moveTo({
position: {x: coords.x, y: coords.y}, position: {x: coords.x, y: coords.y},
scale: 1.0, scale: zoomScale,
animation: true, animation: true,
}); });
} }
...@@ -248,7 +253,28 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -248,7 +253,28 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
this.zoomToNode(`pg_${this.currentProteinAc}`); this.zoomToNode(`pg_${this.currentProteinAc}`);
} }
this.queryItems = this.proteins; this.queryItems = [];
this.fillQueryItems(this.proteins, this.effects);
}
fillQueryItems(hostProteins: Protein[], viralProteins: ViralProtein[]) {
this.queryItems = [];
hostProteins.forEach((protein) => {
this.queryItems.push({
name: protein.proteinAc,
type: 'Host Protein',
data: protein
});
});
viralProteins.forEach((effect) => {
this.queryItems.push({
name: effect.effectName,
type: 'Viral Protein',
data: effect
});
});
} }
public async filterNodes() { public async filterNodes() {
...@@ -260,6 +286,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -260,6 +286,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
const showAll = !this.viralProteinCheckboxes.find((eff) => eff.checked); const showAll = !this.viralProteinCheckboxes.find((eff) => eff.checked);
const connectedProteinAcs = new Set<string>(); const connectedProteinAcs = new Set<string>();
const filteredViralProteins = [];
this.viralProteinCheckboxes.forEach((cb) => { this.viralProteinCheckboxes.forEach((cb) => {
const effects: Array<ViralProtein> = []; const effects: Array<ViralProtein> = [];
this.proteinData.effects.forEach((effect) => { this.proteinData.effects.forEach((effect) => {
...@@ -279,6 +306,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -279,6 +306,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
removeIds.add(nodeId); removeIds.add(nodeId);
} }
if (cb.checked || showAll) { if (cb.checked || showAll) {
filteredViralProteins.push(effect);
effect.proteins.forEach((pg) => { effect.proteins.forEach((pg) => {
connectedProteinAcs.add(pg.proteinAc); connectedProteinAcs.add(pg.proteinAc);
}); });
...@@ -304,8 +332,19 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -304,8 +332,19 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
this.nodeData.nodes.remove(Array.from(removeIds.values())); this.nodeData.nodes.remove(Array.from(removeIds.values()));
this.nodeData.nodes.add(Array.from(addNodes.values())); this.nodeData.nodes.add(Array.from(addNodes.values()));
this.fillQueryItems(filteredProteins, filteredViralProteins);
}
public queryAction(item: any) {
if (item) {
if (item.type === 'Host Protein') {
this.openSummary(item.data, true);
} else if (item.type === 'Viral Protein') {
this.zoomToNode(`eff_${item.data.effectName}_${item.data.virusName}_${item.data.datasetName}`
);
}
}
this.queryItems = filteredProteins;
} }
public updatePhysicsEnabled() { public updatePhysicsEnabled() {
......
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