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

add group name to groupName

parent 6eda522b
No related branches found
No related tags found
No related merge requests found
<div *ngIf="wrapper"> <div *ngIf="wrapper">
<div> <div>
<p *ngIf="wrapper.data.label" [ngClass]="{'text-normal':smallStyle}"> <p *ngIf="wrapper.data.detailShowLabel && wrapper.data.label" [ngClass]="{'text-normal':smallStyle}">
<b><span>Label:</span></b> <b><span>Label:</span></b>
<span class="is-capitalized"> {{ wrapper.data.label }}</span> <span class="is-capitalized"> {{ wrapper.data.label }}</span>
</p> </p>
...@@ -18,9 +18,9 @@ ...@@ -18,9 +18,9 @@
<span class="is-capitalized"> {{ wrapper.data.drugId }}</span> <span class="is-capitalized"> {{ wrapper.data.drugId }}</span>
</a> </a>
</p> </p>
<p *ngIf="wrapper.data.group" [ngClass]="{'text-normal':smallStyle}"> <p *ngIf="wrapper.data.groupName" [ngClass]="{'text-normal':smallStyle}">
<b><span>Group:</span></b> <b><span>Group:</span></b>
<span class="is-capitalized"> {{ wrapper.data.group }}</span> <span class="is-capitalized"> {{ wrapper.data.groupName }}</span>
</p> </p>
<p *ngIf="wrapper.data.uniprotAc" [ngClass]="{'text-normal':smallStyle}"> <p *ngIf="wrapper.data.uniprotAc" [ngClass]="{'text-normal':smallStyle}">
<b><span>Access:</span></b> <b><span>Access:</span></b>
......
// export interface NodeGroup {
// fill: string;
// }
//
// export interface EdgeGroup {
// color: string;
// }
export interface NodeGroup { export interface NodeGroup {
name: string; groupName: string;
color: string; color: string;
shape: 'circle' | 'triangle' | 'star' | 'square' | 'image'; shape: 'circle' | 'triangle' | 'star' | 'square' | 'image';
type: 'gene' | 'protein' | 'drug'; type?: string;
image?: string; image?: string;
detailShowLabel?: boolean;
} }
export interface EdgeGroup { export interface EdgeGroup {
name: string; groupName: string;
color: string; color: string;
// see https://visjs.github.io/vis-network/docs/network/edges.html // see https://visjs.github.io/vis-network/docs/network/edges.html
dashes?: false | Array<number>; dashes?: false | Array<number>;
...@@ -54,6 +47,10 @@ export interface IConfig { ...@@ -54,6 +47,10 @@ export interface IConfig {
identifier?: Identifier; identifier?: Identifier;
} }
/**
* Provide default values
*/
export const defaultConfig: IConfig = { export const defaultConfig: IConfig = {
legendUrl: '', // 'https://exbio.wzw.tum.de/covex/assets/leg1.png' show legend image if set, otherwise default legend legendUrl: '', // 'https://exbio.wzw.tum.de/covex/assets/leg1.png' show legend image if set, otherwise default legend
legendClass: 'legend', legendClass: 'legend',
...@@ -77,19 +74,21 @@ export const defaultConfig: IConfig = { ...@@ -77,19 +74,21 @@ export const defaultConfig: IConfig = {
interactionProteinProtein: 'STRING', interactionProteinProtein: 'STRING',
nodeGroups: { nodeGroups: {
default: { default: {
name: 'Default Group', // this default group is used for default node group values
groupName: 'Default Node Group',
color: 'yellow', color: 'yellow',
shape: 'triangle', shape: 'triangle',
type: 'protein', type: 'protein',
detailShowLabel: false,
}, },
protein: { default_protein: {
name: 'Resulting Proteins', groupName: 'Resulting Proteins',
color: 'red', color: 'red',
shape: 'circle', shape: 'circle',
type: 'protein', type: 'protein',
}, },
drug: { default_drug: {
name: 'Possible Drugs', groupName: 'Possible Drugs',
color: 'green', color: 'green',
shape: 'star', shape: 'star',
type: 'drug', type: 'drug',
...@@ -97,8 +96,10 @@ export const defaultConfig: IConfig = { ...@@ -97,8 +96,10 @@ export const defaultConfig: IConfig = {
}, },
edgeGroups: { edgeGroups: {
default: { default: {
name: 'Edgy edges', // this default group is used for default edge group values
color: 'black' groupName: 'Default Edge Group',
color: 'black',
dashes: false
} }
}, },
}; };
...@@ -8,6 +8,7 @@ export interface Node { ...@@ -8,6 +8,7 @@ export interface Node {
uniprotAc?: string; uniprotAc?: string;
ensg?: Array<string>; ensg?: Array<string>;
group?: string; group?: string;
groupName?: string;
color?: string; color?: string;
shape?: string; shape?: string;
interactions?: Node[]; interactions?: Node[];
...@@ -172,6 +173,7 @@ export interface Wrapper { ...@@ -172,6 +173,7 @@ export interface Wrapper {
color?: string; color?: string;
interactions?: any; interactions?: any;
group?: string; group?: string;
groupName?: string;
uniprotAc?: string; uniprotAc?: string;
expressionLevel?: number; expressionLevel?: number;
x?: number; x?: number;
...@@ -181,6 +183,7 @@ export interface Wrapper { ...@@ -181,6 +183,7 @@ export interface Wrapper {
inTrial?: boolean; inTrial?: boolean;
inLiterature?: boolean; inLiterature?: boolean;
trialLinks?: string[]; trialLinks?: string[];
detailShowLabel?: boolean;
}; };
} }
......
...@@ -53,13 +53,6 @@ export class ProteinNetwork { ...@@ -53,13 +53,6 @@ export class ProteinNetwork {
} }
let node = JSON.parse(JSON.stringify(config.nodeGroups[group])); let node = JSON.parse(JSON.stringify(config.nodeGroups[group]));
// remove group name
delete node.name
// node.name is actually group name since it comes from the group configuration
// this property is already stored in the wrapper object
// instead, node.name should reflect the actual node name
// "node.name = customNode.name";
// update the node with custom node properties, including values fetched from backend // update the node with custom node properties, including values fetched from backend
node = { node = {
... node, ... node,
...@@ -67,6 +60,7 @@ export class ProteinNetwork { ...@@ -67,6 +60,7 @@ export class ProteinNetwork {
} }
// label is only used for network visualization // label is only used for network visualization
console.log(customNode)
node.label = customNode.label ? customNode.label : customNode.id; node.label = customNode.label ? customNode.label : customNode.id;
if (node.image) { if (node.image) {
......
...@@ -13,7 +13,6 @@ import { ...@@ -13,7 +13,6 @@ import {
Tissue Tissue
} from '../../interfaces'; } from '../../interfaces';
import {ProteinNetwork} from '../../main-network'; import {ProteinNetwork} from '../../main-network';
import {HttpClient} from '@angular/common/http';
import {AnalysisService} from '../../services/analysis/analysis.service'; import {AnalysisService} from '../../services/analysis/analysis.service';
import {OmnipathControllerService} from '../../services/omnipath-controller/omnipath-controller.service'; import {OmnipathControllerService} from '../../services/omnipath-controller/omnipath-controller.service';
import html2canvas from 'html2canvas'; import html2canvas from 'html2canvas';
...@@ -38,6 +37,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -38,6 +37,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
private networkJSON = '{"nodes": [], "edges": []}'; private networkJSON = '{"nodes": [], "edges": []}';
// set default config on init
public myConfig: IConfig = JSON.parse(JSON.stringify(defaultConfig)); public myConfig: IConfig = JSON.parse(JSON.stringify(defaultConfig));
@Input() @Input()
...@@ -53,11 +53,17 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -53,11 +53,17 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
for (const key of Object.keys(configObj)) { for (const key of Object.keys(configObj)) {
if (key === 'nodeGroups' ) { if (key === 'nodeGroups' ) {
this.setConfigNodeGroup(key, configObj[key]); this.setConfigNodeGroup(key, configObj[key]);
// dont set the key here, will be set in function
continue;
} else if (key === 'edgeGroups') { } else if (key === 'edgeGroups') {
this.setConfigEdgeGroup(key, configObj[key]) this.setConfigEdgeGroup(key, configObj[key])
// dont set the key here, will be set in function
continue;
} }
else if (key === 'interactions') { else if (key === 'interactions') {
this.getInteractions(); this.getInteractions();
// dont set the key here, will be set in function
continue;
} else if (key === 'showLeftSidebar') { } else if (key === 'showLeftSidebar') {
if (configObj[key]) { if (configObj[key]) {
// shrink main column // shrink main column
...@@ -343,30 +349,54 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -343,30 +349,54 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
} }
/** /**
* Function to set the node group attribute in config * Function to set the node group attribute in config
* Handles setting defaults * Validates input NodeGroups and handles setting defaults
* @param key * @param key
* @param values * @param values
*/ */
public setConfigNodeGroup(key: string, values: Array<NodeGroup>) { public setConfigNodeGroup(key: string, nodeGroups: Array<NodeGroup>) {
this.myConfig[key] = {...this.myConfig[key], ...values}; console.log(Object.keys(nodeGroups).length)
if (nodeGroups === undefined || !Object.keys(nodeGroups).length) {
// if node groups are not set or empty, use default edge group(s)
this.myConfig[key] = defaultConfig.nodeGroups;
// stop if nodeGroups do not contain any information
return
}
// make sure all keys are set
Object.entries(nodeGroups).forEach(([key, value]) => {
if (!('detailShowLabel' in value)) {
// use detailShowLabel default value if not set
value['detailShowLabel'] = defaultConfig.nodeGroups.default.detailShowLabel;
}
})
// override default edge groups
this.myConfig[key] = nodeGroups;
console.log(nodeGroups)
} }
/** /**
* Function to set the edge group attribute in config * Function to set the edge group attribute in config
* Handles setting defaults * Validates input EdgeGroups and handles setting defaults
* @param key * @param key
* @param values * @param values
*/ */
public setConfigEdgeGroup(key: string, edgeGroups: Array<EdgeGroup>) { public setConfigEdgeGroup(key: string, edgeGroups: Array<EdgeGroup>) {
if (edgeGroups === undefined || !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
return
}
// make sure all keys are set // make sure all keys are set
Object.entries(edgeGroups).forEach(([key, value]) => { Object.entries(edgeGroups).forEach(([key, value]) => {
if (!('dashes' in value)) { if (!('dashes' in value)) {
// dashes defaults to 'false' if not set // use dashes default value if not set
value['dashes'] = false; value['dashes'] = defaultConfig.edgeGroups.default.dashes;
} }
}) })
this.myConfig[key] = {...this.myConfig[key], ...edgeGroups}; // override default node groups
this.myConfig[key] = edgeGroups;
} }
public toCanvas() { public toCanvas() {
......
...@@ -38,10 +38,9 @@ ...@@ -38,10 +38,9 @@
<network-expander id="netexp1" <network-expander id="netexp1"
config='{ config='{
"nodeGroups": {"0.5": {"type": "gene", "color": "rgb(204, 255, 51)", "name": "0.5", "shape": "circle"}, "patient_group": {"type": "patient", "color": "red", "name": "patient group", "shape": "circle"}, "2.0": {"type": "gene", "color": "rgb(51, 204, 51)", "name": "2.0", "shape": "circle"}, "-2.0": {"type": "gene", "color": "rgb(255, 0, 0)", "name": "-2.0", "shape": "circle"}}, "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", "name": "Custom Group", "dashes": [1, 2]}}, "edgeGroups": {"dashes": {"color": "black", "groupName": "Dashes Group", "dashes": [1, 2]}},
"identifier": "symbol", "identifier": "symbol"
"legendUrl": "https://exbio.wzw.tum.de/covex/assets/leg1.png"
}' }'
network='{ network='{
"nodes": [{"id": "TP53", "group": "0.5"}, {"id": "C5", "group": "0.5"}, {"id": "Patient", "group": "patient_group"}, {"label": "PTEN", "id": "PTEN", "group": 0.5}], "nodes": [{"id": "TP53", "group": "0.5"}, {"id": "C5", "group": "0.5"}, {"id": "Patient", "group": "patient_group"}, {"label": "PTEN", "id": "PTEN", "group": 0.5}],
......
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