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

Merge branch 'add-all-proteins-from-current-network-only' into 'master'

Add all proteins from current network only

See merge request covid-19/frontend!62
parents ad875bae 74bc8d2c
Branches
Tags
No related merge requests found
......@@ -60,6 +60,38 @@ export class AnalysisService {
}
}
public addAllHostProteins(nodes, proteins) {
const visibleIds = new Set<string>(nodes.getIds());
for (const protein of proteins) {
const nodeId = protein.proteinAc;
const found = visibleIds.has(nodeId) || visibleIds.has('p_' + nodeId);
if (found && !this.inSelection(protein.name)) {
this.addItem({
name: protein.proteinAc,
type: 'Host Protein',
data: protein
});
}
}
}
public addAllViralProteins(nodes, effects) {
const visibleIds = new Set<string>(nodes.getIds());
for (const effect of effects) {
const nodeId = effect.effectId;
const found = visibleIds.has(nodeId) || visibleIds.has('eff_' + effect.effectName + '_' +
effect.datasetName + '_' + effect.virusName);
if (found && !this.inSelection(effect.effectName + '_' +
effect.datasetName + '_' + effect.virusName)) {
this.addItem({
name: effect.effectId,
type: 'Viral Protein',
data: effect
});
}
}
}
resetSelection() {
const oldSelection = this.selectedItems.values();
for (const item of oldSelection) {
......@@ -110,14 +142,14 @@ export class AnalysisService {
// const finishedDate = new Date(task.info.finishedAt);
if (status === 'DONE') {
toastMessage = 'Computation finished succesfully.';
// \n- Algorithm: ${task.info.algorithm}
// \n- Started At: ${startDate.getHours()}:${startDate.getMinutes()}
// \n- Finished At: ${finishedDate.getHours()}:${finishedDate.getMinutes()}`;
// \n- Algorithm: ${task.info.algorithm}
// \n- Started At: ${startDate.getHours()}:${startDate.getMinutes()}
// \n- Finished At: ${finishedDate.getHours()}:${finishedDate.getMinutes()}`;
toastType = 'is-success';
} else if (status === 'FAILED') {
toastMessage = 'Computation failed.';
// \n- Algorithm: ${task.info.algorithm}
// \n- Started At: ${startDate.getHours()}:${startDate.getMinutes()}`;
// \n- Algorithm: ${task.info.algorithm}
// \n- Started At: ${startDate.getHours()}:${startDate.getMinutes()}`;
toastType = 'is-danger';
}
......@@ -128,7 +160,7 @@ export class AnalysisService {
pauseOnHover: true,
type: toastType,
position: 'top-center',
animate: { in: 'fadeIn', out: 'fadeOut' }
animate: {in: 'fadeIn', out: 'fadeOut'}
});
}
......
......@@ -29,6 +29,9 @@ interface Scored {
})
export class AnalysisWindowComponent implements OnInit, OnChanges {
constructor(private http: HttpClient, public analysis: AnalysisService) {
}
@Input() token: string | null = null;
@Output() tokenChange = new EventEmitter<string | null>();
......@@ -47,14 +50,17 @@ export class AnalysisWindowComponent implements OnInit, OnChanges {
public showDrugs = false;
public tab = 'network';
private proteins: any;
public effects: any;
public tableDrugs: Array<Drug & Scored> = [];
public tableProteins: Array<Protein & Scored> = [];
public tableViralProteins: Array<ViralProtein & Scored> = [];
public tableNormalize = false;
public tableHasScores = false;
constructor(private http: HttpClient, public analysis: AnalysisService) {
}
@Output() visibleItems: EventEmitter<any> = new EventEmitter();
async ngOnInit() {
}
......@@ -186,6 +192,15 @@ export class AnalysisWindowComponent implements OnInit, OnChanges {
});
}
}
this.emitVisibleItems(true);
}
public emitVisibleItems(on: boolean) {
if (on) {
this.visibleItems.emit([this.nodeData.nodes, [this.proteins, this.effects]]);
} else {
this.visibleItems.emit(null);
}
}
private async getTask(token: string): Promise<any> {
......@@ -195,6 +210,7 @@ export class AnalysisWindowComponent implements OnInit, OnChanges {
close() {
this.token = null;
this.tokenChange.emit(this.token);
this.emitVisibleItems(false);
}
discard() {
......@@ -256,6 +272,8 @@ export class AnalysisWindowComponent implements OnInit, OnChanges {
const nodeAttributes = result.nodeAttributes || [];
this.proteins = [];
this.effects = [];
for (let i = 0; i < result.networks.length; i++) {
const network = result.networks[i];
......@@ -264,9 +282,12 @@ export class AnalysisWindowComponent implements OnInit, OnChanges {
const isSeed = attributes.isSeed || {};
const scores = attributes.scores || {};
const details = attributes.details || {};
for (const node of network.nodes) {
if (nodeTypes[node] === 'host') {
this.proteins.push(details[node]);
} else if (nodeTypes[node] === 'virus') {
this.effects.push(details[node]);
}
nodes.push(this.mapNode(node, nodeTypes[node] || this.inferNodeType(node), isSeed[node], scores[node], details[node]));
}
......
......@@ -187,7 +187,9 @@
<div class="analysis-view" *ngIf="selectedAnalysisToken">
<app-analysis-window [(token)]="selectedAnalysisToken"
(showDetailsChange)="showDetails = $event[0]; changeInfo($event[1])"></app-analysis-window>
(showDetailsChange)="showDetails = $event[0]; changeInfo($event[1])"
(visibleItems)="analysisWindowChanged($event)"
></app-analysis-window>
</div>
</div>
......@@ -398,7 +400,7 @@
</i>
</div>
<footer class="card-footer">
<a (click)="addAllHostProteins()" class="card-footer-item has-text-success">
<a (click)="analysis.addAllHostProteins(currentViewNodes, currentViewProteins)" class="card-footer-item has-text-success">
<span class="icon">
<i class="fa fa-plus"></i>
</span>
......@@ -406,7 +408,7 @@
Host Proteins
</span>
</a>
<a (click)="addAllViralProteins()" class="card-footer-item has-text-success">
<a (click)="analysis.addAllViralProteins(currentViewNodes, currentViewEffects)" class="card-footer-item has-text-success">
<span class="icon">
<i class="fa fa-plus"></i>
</span>
......
......@@ -47,7 +47,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
public edges: any;
private network: any;
private nodeData: { nodes: any, edges: any } = {nodes: null, edges: null};
public nodeData: { nodes: any, edges: any } = {nodes: null, edges: null};
private dumpPositions = false;
public physicsEnabled = false;
......@@ -61,6 +61,10 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
public currentDataset = [];
private screenshotArray = [0];
public currentViewProteins: Protein[];
public currentViewEffects: ViralProtein[];
public currentViewNodes: Node[];
public datasetItems: Array<{ id: string, label: string, datasets: string, data: Array<[string, string]> }> = [
{
id: 'All (TUM & Krogan)',
......@@ -321,6 +325,10 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
data: effect
});
});
this.currentViewNodes = this.nodeData.nodes;
this.currentViewProteins = this.proteins;
this.currentViewEffects = this.effects;
}
public async filterNodes() {
......@@ -457,32 +465,6 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
};
}
public addAllHostProteins() {
const visibleIds = new Set<string>(this.nodeData.nodes.getIds());
for (const protein of this.proteinData.proteins) {
const nodeId = `p_${protein.proteinAc}`;
const found = visibleIds.has(nodeId);
if (found && !this.analysis.inSelection(protein.name)) {
this.analysis.addItem({name: protein.proteinAc, type: 'Host Protein', data: protein});
}
}
}
public addAllViralProteins() {
const visibleIds = new Set<string>(this.nodeData.nodes.getIds());
for (const effect of this.proteinData.effects) {
const nodeId = `eff_${effect.effectName + '_' + effect.datasetName + '_' + effect.virusName}`;
const found = visibleIds.has(nodeId);
if (found && !this.analysis.inSelection(effect.effectName + '_' + effect.datasetName + '_' + effect.virusName)) {
this.analysis.addItem({
name: effect.effectId,
type: 'Viral Protein',
data: effect
});
}
}
}
public toCanvas() {
this.screenshotArray.forEach((key, index) => {
const elem = document.getElementById(index.toString());
......@@ -496,4 +478,15 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
});
}
analysisWindowChanged($event: any) {
if ($event) {
this.currentViewNodes = $event[0];
this.currentViewProteins = $event[1][0];
this.currentViewEffects = $event[1][1];
} else {
this.currentViewNodes = this.nodeData.nodes;
this.currentViewProteins = this.proteins;
this.currentViewEffects = this.effects;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment