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

throw helpful errors when node or edges have undefined groups

parent 9a33cf67
No related branches found
No related tags found
No related merge requests found
Pipeline #11032 failed
......@@ -58,7 +58,6 @@
}
function changeConfigStr(config) {
console.log(config);
const netexp = document.getElementById('netexp1');
netexp.setAttribute('config', config);
}
......
......@@ -377,6 +377,7 @@ export class AnalysisPanelComponent implements OnInit, OnChanges {
* For the third case, fall back to a default case which can also be set by user.
*/
public inferNodeGroup(wrapper: Wrapper): string {
console.log(wrapper)
if (wrapper.data.group !== undefined) {
return wrapper.data.group
}
......@@ -408,7 +409,6 @@ export class AnalysisPanelComponent implements OnInit, OnChanges {
}
}
/**
* Maps analysis result returned from database to valid Vis.js network input
*
......@@ -436,7 +436,6 @@ export class AnalysisPanelComponent implements OnInit, OnChanges {
for (const node of network.nodes) {
// backend converts object keys to PascalCase: p_123 --> p123
const nodeObjectKey = node.split('_').join('');
console.log(nodeObjectKey)
if (nodeTypes[nodeObjectKey] === 'protein') {
// node is protein from database, has been mapped on init to backend protein from backend
// or was found during analysis
......@@ -474,6 +473,11 @@ export class AnalysisPanelComponent implements OnInit, OnChanges {
if (typeof group === 'undefined' || typeof config.nodeGroups[group] === 'undefined') {
group = 'default';
}
console.log("node group")
console.log(group)
console.log(config.nodeGroups)
console.log(config.nodeGroups[group]);
const node = JSON.parse(JSON.stringify(config.nodeGroups[group]));
node.id = wrapper.id;
node.label = this.inferNodeLabel(config, wrapper);
......@@ -551,7 +555,6 @@ export class AnalysisPanelComponent implements OnInit, OnChanges {
// }
for (const interaction of edges) {
console.log(interaction)
const edge = {from: interaction.uniprotAc, to: interaction.drugId};
this.drugEdges.push(this.mapEdge(edge, 'protein-drug'));
}
......
......@@ -47,12 +47,12 @@ export class ProteinNetwork {
* @returns
*/
private mapCustomNode(customNode: any, config: IConfig): Node {
let group = customNode.group;
if (typeof group === 'undefined' || typeof config.nodeGroups[group] === 'undefined') {
group = 'default';
if (config.nodeGroups[customNode.group] === undefined) {
throw `Node with id ${customNode.id} has undefined node group ${customNode.group}.`
}
console.log(config.nodeGroups[group])
let node = JSON.parse(JSON.stringify(config.nodeGroups[group]));
let node = JSON.parse(JSON.stringify(config.nodeGroups[customNode.group]));
// update the node with custom node properties, including values fetched from backend
node = {
......@@ -77,18 +77,12 @@ export class ProteinNetwork {
* @returns
*/
private mapCustomEdge(customEdge: NodeInteraction, config: IConfig): any {
let group = customEdge.group;
if (typeof group === 'undefined' || typeof config.edgeGroups[group] === 'undefined') {
group = 'default';
}
let edge = JSON.parse(JSON.stringify(config.edgeGroups[group]));
console.log("edge")
console.log(edge)
console.log("customEdge")
console.log(customEdge)
if (config.edgeGroups[customEdge.group] === undefined) {
throw `Edge "from ${customEdge.from}" - "to ${customEdge.to}" has undefined edge group ${customEdge.group}.`
}
let edge = JSON.parse(JSON.stringify(config.edgeGroups[customEdge.group]));
edge = {
...edge,
......
......@@ -384,7 +384,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
* @param values
*/
public setConfigEdgeGroup(key: string, edgeGroups: Array<EdgeGroup>) {
if (edgeGroups === undefined || !edgeGroups.length) {
if (edgeGroups === undefined || !Object.keys(edgeGroups).length) {
// if edge groups are not set or empty, use default edge group(s)
this.myConfig[key] = defaultConfig.edgeGroups;
// stop if edgeGroups do not contain any information
......
......@@ -38,22 +38,13 @@
<network-expander id="netexp1"
config='{
"nodeGroups":{
"0.5":{"type":"gene","color":"#CCFF33FF","groupName":"0.5","shape":"circle"},
"1.5":{"type":"gene","color":"#66FF33FF","groupName":"1.5","shape":"circle"},
"2.0":{"type":"gene","color":"#33CC33FF","groupName":"2.0","shape":"circle"},
"patient_group":{"type":"gene","color":"#FF0000FF","groupName":"-2.0","shape":"circle"}
},
"edgeGroups":{
"custom":{"color":"black","groupName":"Custom Group"}
},
"identifier":"symbol",
"legendUrl":"https://exbio.wzw.tum.de/covex/assets/leg1.png"
"nodeGroups": {"0.5": {"type": "gene", "color": "rgb(204, 255, 51)", "groupName": "0.5", "shape": "circle"}, "patient_group": {"type": "patient", "color": "red", "groupName": "patient group", "shape": "circle"}},
"edgeGroups": {"dashes": {"color": "black", "groupName": "Dashes Group", "dashes": [1, 2]}},
"identifier": "symbol"
}'
network='{
"nodes": [{"id": "TP53", "group": "0.5"}, {"id": "C5", "group": "0.5"}, {"id": "Patient", "group": "patient_group"}, {"label": "PTEN", "id": "PTEN", "group": 0.5}],
"edges":[]
"edges": [{"from": "TP53","to": "C5","group": "dashes", "label": "this is a label", "title": "this is a title"}]
}'
style="height: 100%; width: 100vw; display: block;"
></network-expander>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment