Skip to content
Snippets Groups Projects
Commit 5a9260d3 authored by Michael Hartung's avatar Michael Hartung
Browse files

load edges from db

parent 0ea5c748
No related branches found
No related tags found
No related merge requests found
......@@ -56,6 +56,7 @@ export interface IConfig {
edgeGroups: { [key: string]: EdgeGroup };
interactionDrugProtein: InteractionDrugProteinDB;
interactionProteinProtein: InteractionProteinProteinDB;
autofillEdges: boolean;
interactions?: InteractionDatabase;
identifier?: Identifier;
nodeShadow?: boolean;
......@@ -93,6 +94,7 @@ export const defaultConfig: IConfig = {
interactionProteinProtein: 'STRING',
nodeShadow: true,
edgeShadow: true,
autofillEdges: true,
nodeGroups: {
// all NodeGroups but the default group must be set, if not provided by the user, they will be taken from here
// IMPORTANT: node color must be hexacode!
......
......@@ -37,6 +37,11 @@ export type legendContext = 'explorer' | 'adjacentDrugs' | 'drug' | 'drugTarget'
/// netexId to expressionlvl
export type NodeAttributeMap = { string: number } | {};
export interface NetexInteraction {
dataset: string;
proteinA: string;
proteinB: string;
}
export interface NodeInteraction {
from: string;
......
import { defaultConfig, IConfig } from './config';
import {NodeInteraction, Node, getProteinNodeId} from './interfaces';
import {NodeInteraction, Node, getProteinNodeId, NetexInteraction} from './interfaces';
import * as merge from 'lodash/fp/merge';
export function getDatasetFilename(dataset: Array<[string, string]>): string {
......@@ -117,3 +117,18 @@ export function mapCustomEdge(customEdge: NodeInteraction, config: IConfig): any
};
return edge;
}
/** Maps netex retrieved edge to network edge object
* Uses the default group for edge objects.
*
* @param customEdge
* @param config
* @returns
*/
export function mapNetexEdge(customEdge: NetexInteraction, config: IConfig): any {
const edge = JSON.parse(JSON.stringify(config.edgeGroups.default));
edge['from'] = customEdge['proteinA'];
edge['to'] = customEdge['proteinB'];
edge['dataset'] = customEdge['dataset'];
return edge;
}
......@@ -18,7 +18,7 @@ import {
Tissue,
Wrapper
} from '../../interfaces';
import {mapCustomEdge, mapCustomNode, ProteinNetwork} from '../../main-network';
import {mapCustomEdge, mapCustomNode, mapNetexEdge, ProteinNetwork} from '../../main-network';
import {AnalysisService} from '../../services/analysis/analysis.service';
import {OmnipathControllerService} from '../../services/omnipath-controller/omnipath-controller.service';
import domtoimage from 'dom-to-image';
......@@ -369,10 +369,19 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
if (this.networkPositions) {
this.proteinData.updateNodePositions(this.networkPositions)
}
this.proteinData.linkNodes();
// TODO do we still need this?
// this.proteinData.linkNodes();
const {nodes, edges} = this.proteinData.mapDataToNetworkInput(this.myConfig);
console.log('nodes', nodes)
console.log('edges', edges)
if (this.myConfig.autofillEdges && nodes.length) {
const netexEdges = await this.netex.fetchEdges(nodes, this.myConfig.interactionProteinProtein);
console.log(netexEdges.map(netexEdge => mapNetexEdge(netexEdge, this.myConfig)))
edges.push(...netexEdges.map(netexEdge => mapNetexEdge(netexEdge, this.myConfig)))
}
this.nodeData.nodes = new vis.DataSet(nodes);
this.nodeData.edges = new vis.DataSet(edges);
const container = this.networkEl.nativeElement;
......
......@@ -4,7 +4,7 @@ import {HttpClient, HttpParams} from '@angular/common/http';
import {AlgorithmType, QuickAlgorithmType} from '../analysis/analysis.service';
import { Observable } from 'rxjs';
import { Tissue, Node, EdgeType} from 'src/app/interfaces';
import { InteractionDrugProteinDB } from 'src/app/config';
import { InteractionDrugProteinDB, InteractionProteinProteinDB } from 'src/app/config';
@Injectable({
providedIn: 'root'
......@@ -115,4 +115,13 @@ export class NetexControllerService {
*/
return this.http.post(`${environment.backend}graph_export/`, graph_data, {responseType: 'text'});
}
public async fetchEdges(nodes: Node[], dataset: InteractionProteinProteinDB): Promise<any> {
/**
* Tries to map every node to a node object in out database
* Returns list of mapped nodes if node was found, otherwise original node to not lose information
*/
const payload = {nodes: nodes, dataset: dataset};
return this.http.post(`${environment.backend}fetch_edges/`, payload).toPromise();
}
}
......@@ -44,14 +44,13 @@
"identifier": "symbol",
"nodeShadow": true,
"edgeShadow": true,
"interactionDrugProtein": "ChEMBL",
"legendUrl": "https://exbio.wzw.tum.de/covex/assets/leg1.png"
"interactionProteinProtein": "APID",
"interactionDrugProtein": "ChEMBL"
}'
network='{
"nodes": [{"id": "TP53", "group": "0.5"}, {"id": "MYC", "group": "pugGroup"}, {"id": "Patient No. 5", "group": "patientgroup"}, {"label": "PTEN", "id": "PTEN", "group": 0.5, "value":"5"}],
"edges": [
{"from": "TP53","to": "C5","group": "xxx", "label": "this is a label", "title": "this is a title"},
{"from": "Patient No. 5","to": "C5","label": "w/o group"}
]
}'
style="height: 100%; width: 100vw; display: block;"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment