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
......@@ -47,4 +47,4 @@ Thumbs.db
.idea
drugsTone-build
package-lock.json
package-lock.json
\ No newline at end of file
......@@ -329,16 +329,16 @@
</a>
</div>
<p-table *ngIf="tableProteins.length > 0" selectionMode="multiple"
[value]="tableProteins" [selection]="tableSelectedProteins" dataKey="proteinAc"
[value]="tableProteins" [selection]="tableSelectedProteins" dataKey="uniprotAc"
(selectionChange)="tableProteinSelection($event)">
<ng-template pTemplate="header">
<tr>
<th class="checkbox-col">
<p-tableHeaderCheckbox></p-tableHeaderCheckbox>
</th>
<th [pSortableColumn]="'proteinAc'">
<th [pSortableColumn]="'uniprotAc'">
UniProt Code
<p-sortIcon [field]="'proteinAc'"></p-sortIcon>
<p-sortIcon [field]="'uniprotAc'"></p-sortIcon>
</th>
<th [pSortableColumn]="'name'">
Gene
......@@ -367,7 +367,7 @@
<td>
<p-tableCheckbox [value]="e"></p-tableCheckbox>
</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.proteinName}}</td>
<td *ngIf="tableHasScores">{{e.score | number}}</td>
......
......@@ -379,56 +379,33 @@ export class AnalysisPanelComponent implements OnInit, OnChanges {
const details = attributes.details || {};
const wrappers: { [key: string]: Wrapper } = {};
for (const node of network.nodes) {
if (nodeTypes[node] === 'protein') {
this.proteins.push(details[node]);
wrappers[node] = getWrapperFromNode(details[node]);
} else if (nodeTypes[node] === 'drug') {
wrappers[node] = getWrapperFromDrug(details[node]);
// backend converts object keys to PascalCase: p_123 --> p123
const nodeObjectKey = node.split('_').join('')
if (nodeTypes[nodeObjectKey] === 'protein') {
this.proteins.push(details[nodeObjectKey]);
wrappers[node] = getWrapperFromNode(details[nodeObjectKey]);
} 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) {
edges.push(this.mapEdge(edge, 'protein-protein', wrappers));
}
return {
nodes,
edges,
};
}
private mapNode(nodeType: WrapperType, details: Node, 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)
private mapNode(nodeType: WrapperType, wrapper: Wrapper, isSeed?: boolean, score?: number): any {
const node = NetworkSettings.getNodeStyle('gene', isSeed, this.analysis.inSelection(wrapper));
node.id = details.id;
node.label = details.name;
node.id = wrapper.id;
node.label = wrapper.data.name;
node.nodeType = nodeType;
node.isSeed = isSeed;
node.wrapper = details;
node.wrapper = wrapper;
return node;
}
......@@ -500,7 +477,8 @@ export class AnalysisPanelComponent implements OnInit, OnChanges {
}
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.nodeData.nodes.add(Array.from(this.drugNodes.values()));
......
......@@ -4,7 +4,7 @@
<ng-template ng-option-tmp let-item="item">
<b *ngIf="item.type == 'protein'"> {{item.data.name}}</b>
<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-select>
</div>
......@@ -11,6 +11,7 @@ import {
TRUSTRANK
} from '../../services/analysis/analysis.service';
import {Wrapper} from '../../interfaces';
import { IConfig } from 'src/app/config';
@Component({
selector: 'app-launch-analysis',
......@@ -25,6 +26,8 @@ export class LaunchAnalysisComponent implements OnInit, OnChanges {
public target: 'drug' | 'drug-target';
@Input()
public inputNetwork: {nodes: any, edges: any};
@Input()
public config: IConfig;
@Output()
public showChange = new EventEmitter<boolean>();
......@@ -103,15 +106,17 @@ export class LaunchAnalysisComponent implements OnInit, OnChanges {
public async startTask() {
const parameters: any = {
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
// drop interactions in nodes beforehand to no cause cyclic error, information is contained in edges
this.inputNetwork.nodes.forEach(node => {
delete node.interactions
});
parameters.input_network = this.inputNetwork;
console.log(this.inputNetwork)
if (this.algorithm === 'trustrank') {
parameters.damping_factor = this.trustrankDampingFactor;
......
......@@ -98,10 +98,14 @@ export function getNodeId(node: Node) {
/**
* 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
*/
......@@ -115,7 +119,7 @@ export function getWrapperFromNode(gene: Node): Wrapper {
*/
return {
id: getNodeId(gene),
nodeId: getGeneNodeId(gene),
nodeId: getNodeId(gene),
type: 'gene',
data: gene,
};
......
......@@ -3,6 +3,7 @@
<app-launch-analysis [(show)]="showAnalysisDialog"
[target]="analysisDialogTarget"
[config]="myConfig"
[inputNetwork]="{nodes:proteins, edges:edges}">
</app-launch-analysis>
......
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