Skip to content
Snippets Groups Projects
Commit a5efbbba authored by Maiykol's avatar Maiykol
Browse files

unpack changes analysis result which contain input network; save complete...

unpack changes analysis result which contain input network; save complete configuration in backend in order to restore configuration when revisiting the page
parent 622a6fc4
No related branches found
No related tags found
No related merge requests found
Pipeline #11019 failed
...@@ -329,16 +329,16 @@ ...@@ -329,16 +329,16 @@
</a> </a>
</div> </div>
<p-table *ngIf="tableProteins.length > 0" selectionMode="multiple" <p-table *ngIf="tableProteins.length > 0" selectionMode="multiple"
[value]="tableProteins" [selection]="tableSelectedProteins" dataKey="proteinAc" [value]="tableProteins" [selection]="tableSelectedProteins" dataKey="uniprotAc"
(selectionChange)="tableProteinSelection($event)"> (selectionChange)="tableProteinSelection($event)">
<ng-template pTemplate="header"> <ng-template pTemplate="header">
<tr> <tr>
<th class="checkbox-col"> <th class="checkbox-col">
<p-tableHeaderCheckbox></p-tableHeaderCheckbox> <p-tableHeaderCheckbox></p-tableHeaderCheckbox>
</th> </th>
<th [pSortableColumn]="'proteinAc'"> <th [pSortableColumn]="'uniprotAc'">
UniProt Code UniProt Code
<p-sortIcon [field]="'proteinAc'"></p-sortIcon> <p-sortIcon [field]="'uniprotAc'"></p-sortIcon>
</th> </th>
<th [pSortableColumn]="'name'"> <th [pSortableColumn]="'name'">
Gene Gene
...@@ -367,7 +367,7 @@ ...@@ -367,7 +367,7 @@
<td> <td>
<p-tableCheckbox [value]="e"></p-tableCheckbox> <p-tableCheckbox [value]="e"></p-tableCheckbox>
</td> </td>
<td><a href="https://www.uniprot.org/uniprot/{{ e.proteinAc }}" target="_blank">{{ e.proteinAc }}</a></td> <td><a href="https://www.uniprot.org/uniprot/{{ e.uniprotAc }}" target="_blank">{{ e.uniprotAc }}</a></td>
<td>{{e.name}}</td> <td>{{e.name}}</td>
<td>{{e.proteinName}}</td> <td>{{e.proteinName}}</td>
<td *ngIf="tableHasScores">{{e.score | number}}</td> <td *ngIf="tableHasScores">{{e.score | number}}</td>
......
...@@ -379,56 +379,33 @@ export class AnalysisPanelComponent implements OnInit, OnChanges { ...@@ -379,56 +379,33 @@ export class AnalysisPanelComponent implements OnInit, OnChanges {
const details = attributes.details || {}; const details = attributes.details || {};
const wrappers: { [key: string]: Wrapper } = {}; const wrappers: { [key: string]: Wrapper } = {};
for (const node of network.nodes) { for (const node of network.nodes) {
// backend converts object keys to PascalCase: p_123 --> p123
if (nodeTypes[node] === 'protein') { const nodeObjectKey = node.split('_').join('')
this.proteins.push(details[node]); if (nodeTypes[nodeObjectKey] === 'protein') {
wrappers[node] = getWrapperFromNode(details[node]); this.proteins.push(details[nodeObjectKey]);
} else if (nodeTypes[node] === 'drug') { wrappers[node] = getWrapperFromNode(details[nodeObjectKey]);
wrappers[node] = getWrapperFromDrug(details[node]); } else if (nodeTypes[nodeObjectKey] === 'drug') {
} wrappers[node] = getWrapperFromDrug(details[nodeObjectKey]);
nodes.push(this.mapNode(this.inferNodeType(node), details[node], isSeed[node], scores[node]));
} }
nodes.push(this.mapNode(this.inferNodeType(node), wrappers[node], isSeed[nodeObjectKey], scores[nodeObjectKey]));
}
for (const edge of network.edges) { for (const edge of network.edges) {
edges.push(this.mapEdge(edge, 'protein-protein', wrappers)); edges.push(this.mapEdge(edge, 'protein-protein', wrappers));
} }
return { return {
nodes, nodes,
edges, edges,
}; };
} }
private mapNode(nodeType: WrapperType, details: Node, isSeed?: boolean, score?: number): any { private mapNode(nodeType: WrapperType, wrapper: Wrapper, isSeed?: boolean, score?: number): any {
/*let nodeLabel;
// let wrapper: Wrapper;
let drugType;
let drugInTrial;*/
/*if (nodeType === 'protein') {
const protein = details as Node;
// wrapper = getWrapperFromNode(protein);
nodeLabel = protein.name;
if (!protein.name) {
nodeLabel = protein.id;
}
} else if (nodeType === 'drug') {
// const drug = details as Drug;
// wrapper = getWrapperFromDrug(drug);
drugType = drug.status;
drugInTrial = drug.inTrial;
if (drugType === 'approved') {
nodeLabel = drug.name;
} else {
nodeLabel = drug.drugId;
}
}*/
const wrapper = getWrapperFromNode(details)
const node = NetworkSettings.getNodeStyle('gene', isSeed, this.analysis.inSelection(wrapper)); const node = NetworkSettings.getNodeStyle('gene', isSeed, this.analysis.inSelection(wrapper));
node.id = details.id; node.id = wrapper.id;
node.label = details.name; node.label = wrapper.data.name;
node.nodeType = nodeType; node.nodeType = nodeType;
node.isSeed = isSeed; node.isSeed = isSeed;
node.wrapper = details; node.wrapper = wrapper;
return node; return node;
} }
...@@ -500,7 +477,8 @@ export class AnalysisPanelComponent implements OnInit, OnChanges { ...@@ -500,7 +477,8 @@ export class AnalysisPanelComponent implements OnInit, OnChanges {
} }
for (const interaction of edges) { for (const interaction of edges) {
const edge = {from: interaction.proteinAc, to: interaction.drugId}; console.log(interaction)
const edge = {from: interaction.uniprotAc, to: interaction.drugId};
this.drugEdges.push(this.mapEdge(edge, 'to-drug')); this.drugEdges.push(this.mapEdge(edge, 'to-drug'));
} }
this.nodeData.nodes.add(Array.from(this.drugNodes.values())); this.nodeData.nodes.add(Array.from(this.drugNodes.values()));
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<ng-template ng-option-tmp let-item="item"> <ng-template ng-option-tmp let-item="item">
<b *ngIf="item.type == 'protein'"> {{item.data.name}}</b> <b *ngIf="item.type == 'protein'"> {{item.data.name}}</b>
<span><small *ngIf="item.type === 'protein'">Host Protein</small> | </span> <span><small *ngIf="item.type === 'protein'">Host Protein</small> | </span>
<span *ngIf="item.type == 'protein'"><small>AC: <b>{{item.data.proteinAc}}</b></small> </span> <span *ngIf="item.type == 'protein'"><small>AC: <b>{{item.data.uniprotAc}}</b></small> </span>
</ng-template> </ng-template>
</ng-select> </ng-select>
</div> </div>
...@@ -11,6 +11,7 @@ import { ...@@ -11,6 +11,7 @@ import {
TRUSTRANK TRUSTRANK
} from '../../services/analysis/analysis.service'; } from '../../services/analysis/analysis.service';
import {Wrapper} from '../../interfaces'; import {Wrapper} from '../../interfaces';
import { IConfig } from 'src/app/config';
@Component({ @Component({
selector: 'app-launch-analysis', selector: 'app-launch-analysis',
...@@ -25,6 +26,8 @@ export class LaunchAnalysisComponent implements OnInit, OnChanges { ...@@ -25,6 +26,8 @@ export class LaunchAnalysisComponent implements OnInit, OnChanges {
public target: 'drug' | 'drug-target'; public target: 'drug' | 'drug-target';
@Input() @Input()
public inputNetwork: {nodes: any, edges: any}; public inputNetwork: {nodes: any, edges: any};
@Input()
public config: IConfig;
@Output() @Output()
public showChange = new EventEmitter<boolean>(); public showChange = new EventEmitter<boolean>();
...@@ -103,15 +106,17 @@ export class LaunchAnalysisComponent implements OnInit, OnChanges { ...@@ -103,15 +106,17 @@ export class LaunchAnalysisComponent implements OnInit, OnChanges {
public async startTask() { public async startTask() {
const parameters: any = { const parameters: any = {
seeds: this.analysis.getSelection().map((item) => item.data.netexId), seeds: this.analysis.getSelection().map((item) => item.data.netexId),
config: this.config,
input_network: this.inputNetwork
}; };
parameters.target_or_drugs = this.target === 'drug' ? 'drug' : 'protein'; parameters.target = this.target === 'drug' ? 'drug' : 'drug-target';
// pass network data to reconstruct network in analysis result to connect non-proteins to results // pass network data to reconstruct network in analysis result to connect non-proteins to results
// drop interactions in nodes beforehand to no cause cyclic error, information is contained in edges // drop interactions in nodes beforehand to no cause cyclic error, information is contained in edges
this.inputNetwork.nodes.forEach(node => { this.inputNetwork.nodes.forEach(node => {
delete node.interactions delete node.interactions
}); });
parameters.input_network = this.inputNetwork; console.log(this.inputNetwork)
if (this.algorithm === 'trustrank') { if (this.algorithm === 'trustrank') {
parameters.damping_factor = this.trustrankDampingFactor; parameters.damping_factor = this.trustrankDampingFactor;
......
...@@ -98,10 +98,14 @@ export function getNodeId(node: Node) { ...@@ -98,10 +98,14 @@ export function getNodeId(node: Node) {
/** /**
* Returns backend_id of Gene object * Returns backend_id of Gene object
*/ */
return node.id.toString(); if ('netexId' in node) {
return node['netexId']
} else {
return node.id
}
} }
export function getGeneNodeId(gene: Node) { export function getId(gene: Node) {
/** /**
* Returns the network node id based on a given gene * Returns the network node id based on a given gene
*/ */
...@@ -115,7 +119,7 @@ export function getWrapperFromNode(gene: Node): Wrapper { ...@@ -115,7 +119,7 @@ export function getWrapperFromNode(gene: Node): Wrapper {
*/ */
return { return {
id: getNodeId(gene), id: getNodeId(gene),
nodeId: getGeneNodeId(gene), nodeId: getNodeId(gene),
type: 'gene', type: 'gene',
data: gene, data: gene,
}; };
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<app-launch-analysis [(show)]="showAnalysisDialog" <app-launch-analysis [(show)]="showAnalysisDialog"
[target]="analysisDialogTarget" [target]="analysisDialogTarget"
[config]="myConfig"
[inputNetwork]="{nodes:proteins, edges:edges}"> [inputNetwork]="{nodes:proteins, edges:edges}">
</app-launch-analysis> </app-launch-analysis>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment