Skip to content
Snippets Groups Projects
Commit 74bc8d2c authored by Julian Späth's avatar Julian Späth Committed by Julian Matschinske
Browse files

Add all proteins from current network only

parent ad875bae
Branches
Tags
No related merge requests found
...@@ -60,6 +60,38 @@ export class AnalysisService { ...@@ -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() { resetSelection() {
const oldSelection = this.selectedItems.values(); const oldSelection = this.selectedItems.values();
for (const item of oldSelection) { for (const item of oldSelection) {
......
...@@ -29,6 +29,9 @@ interface Scored { ...@@ -29,6 +29,9 @@ interface Scored {
}) })
export class AnalysisWindowComponent implements OnInit, OnChanges { export class AnalysisWindowComponent implements OnInit, OnChanges {
constructor(private http: HttpClient, public analysis: AnalysisService) {
}
@Input() token: string | null = null; @Input() token: string | null = null;
@Output() tokenChange = new EventEmitter<string | null>(); @Output() tokenChange = new EventEmitter<string | null>();
...@@ -47,14 +50,17 @@ export class AnalysisWindowComponent implements OnInit, OnChanges { ...@@ -47,14 +50,17 @@ export class AnalysisWindowComponent implements OnInit, OnChanges {
public showDrugs = false; public showDrugs = false;
public tab = 'network'; public tab = 'network';
private proteins: any;
public effects: any;
public tableDrugs: Array<Drug & Scored> = []; public tableDrugs: Array<Drug & Scored> = [];
public tableProteins: Array<Protein & Scored> = []; public tableProteins: Array<Protein & Scored> = [];
public tableViralProteins: Array<ViralProtein & Scored> = []; public tableViralProteins: Array<ViralProtein & Scored> = [];
public tableNormalize = false; public tableNormalize = false;
public tableHasScores = false; public tableHasScores = false;
constructor(private http: HttpClient, public analysis: AnalysisService) { @Output() visibleItems: EventEmitter<any> = new EventEmitter();
}
async ngOnInit() { async ngOnInit() {
} }
...@@ -186,6 +192,15 @@ export class AnalysisWindowComponent implements OnInit, OnChanges { ...@@ -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> { private async getTask(token: string): Promise<any> {
...@@ -195,6 +210,7 @@ export class AnalysisWindowComponent implements OnInit, OnChanges { ...@@ -195,6 +210,7 @@ export class AnalysisWindowComponent implements OnInit, OnChanges {
close() { close() {
this.token = null; this.token = null;
this.tokenChange.emit(this.token); this.tokenChange.emit(this.token);
this.emitVisibleItems(false);
} }
discard() { discard() {
...@@ -256,6 +272,8 @@ export class AnalysisWindowComponent implements OnInit, OnChanges { ...@@ -256,6 +272,8 @@ export class AnalysisWindowComponent implements OnInit, OnChanges {
const nodeAttributes = result.nodeAttributes || []; const nodeAttributes = result.nodeAttributes || [];
this.proteins = [];
this.effects = [];
for (let i = 0; i < result.networks.length; i++) { for (let i = 0; i < result.networks.length; i++) {
const network = result.networks[i]; const network = result.networks[i];
...@@ -264,9 +282,12 @@ export class AnalysisWindowComponent implements OnInit, OnChanges { ...@@ -264,9 +282,12 @@ export class AnalysisWindowComponent implements OnInit, OnChanges {
const isSeed = attributes.isSeed || {}; const isSeed = attributes.isSeed || {};
const scores = attributes.scores || {}; const scores = attributes.scores || {};
const details = attributes.details || {}; const details = attributes.details || {};
for (const node of network.nodes) { 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])); nodes.push(this.mapNode(node, nodeTypes[node] || this.inferNodeType(node), isSeed[node], scores[node], details[node]));
} }
......
...@@ -187,7 +187,9 @@ ...@@ -187,7 +187,9 @@
<div class="analysis-view" *ngIf="selectedAnalysisToken"> <div class="analysis-view" *ngIf="selectedAnalysisToken">
<app-analysis-window [(token)]="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>
</div> </div>
...@@ -398,7 +400,7 @@ ...@@ -398,7 +400,7 @@
</i> </i>
</div> </div>
<footer class="card-footer"> <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"> <span class="icon">
<i class="fa fa-plus"></i> <i class="fa fa-plus"></i>
</span> </span>
...@@ -406,7 +408,7 @@ ...@@ -406,7 +408,7 @@
Host Proteins Host Proteins
</span> </span>
</a> </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"> <span class="icon">
<i class="fa fa-plus"></i> <i class="fa fa-plus"></i>
</span> </span>
......
...@@ -47,7 +47,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -47,7 +47,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
public edges: any; public edges: any;
private network: 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; private dumpPositions = false;
public physicsEnabled = false; public physicsEnabled = false;
...@@ -61,6 +61,10 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -61,6 +61,10 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
public currentDataset = []; public currentDataset = [];
private screenshotArray = [0]; 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]> }> = [ public datasetItems: Array<{ id: string, label: string, datasets: string, data: Array<[string, string]> }> = [
{ {
id: 'All (TUM & Krogan)', id: 'All (TUM & Krogan)',
...@@ -321,6 +325,10 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -321,6 +325,10 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
data: effect data: effect
}); });
}); });
this.currentViewNodes = this.nodeData.nodes;
this.currentViewProteins = this.proteins;
this.currentViewEffects = this.effects;
} }
public async filterNodes() { public async filterNodes() {
...@@ -457,32 +465,6 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -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() { public toCanvas() {
this.screenshotArray.forEach((key, index) => { this.screenshotArray.forEach((key, index) => {
const elem = document.getElementById(index.toString()); const elem = document.getElementById(index.toString());
...@@ -496,4 +478,15 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -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