diff --git a/src/app/components/analysis-panel/analysis-panel.component.ts b/src/app/components/analysis-panel/analysis-panel.component.ts index ef9bd867d30bcb7fabb596cfefdbf8e1d8af32b8..f52cdb3bab8de54e849af28c9febcc38ce9868ea 100644 --- a/src/app/components/analysis-panel/analysis-panel.component.ts +++ b/src/app/components/analysis-panel/analysis-panel.component.ts @@ -186,7 +186,7 @@ export class AnalysisPanelComponent implements OnInit, OnChanges, AfterViewInit // Create const {nodes, edges} = this.createNetwork(this.result); - this.analysis.inputNetwork = {nodes: nodes, edges: edges}; + this.networkHandler.activeNetwork.inputNetwork = {nodes: nodes, edges: edges}; this.nodeData.nodes = new vis.DataSet(nodes); this.nodeData.edges = new vis.DataSet(edges); const container = this.networkHandler.activeNetwork.networkEl.nativeElement; @@ -353,7 +353,6 @@ export class AnalysisPanelComponent implements OnInit, OnChanges, AfterViewInit this.analysis.switchSelection('main'); this.token = null; this.tokenChange.emit(this.token); - this.analysis.inputNetwork = {}; this.emitVisibleItems(false); } @@ -455,8 +454,8 @@ export class AnalysisPanelComponent implements OnInit, OnChanges, AfterViewInit for (const edge of network.edges) { const e = mapCustomEdge(edge, this.myConfig) - e.from = e.from[0] === 'p' ? nodeIdMap[e.from] : e.from - e.to = e.to[0] === 'p' ? nodeIdMap[e.to] : e.to + e.from = e.from[0] === 'p' && nodeIdMap[e.from] ? nodeIdMap[e.from] : e.from + e.to = e.to[0] === 'p' && nodeIdMap[e.to] ? nodeIdMap[e.to] : e.to const hash = e.from + "_" + e.to; if (uniqEdges.indexOf(hash) === -1) { uniqEdges.push(hash); diff --git a/src/app/components/network/network.component.ts b/src/app/components/network/network.component.ts index 0d19651c7243e33712d22ef043271b6381e90e4a..c24c4ac148cdc04a70575e4a3b299d28769e76c8 100644 --- a/src/app/components/network/network.component.ts +++ b/src/app/components/network/network.component.ts @@ -15,7 +15,7 @@ import { NodeInteraction, Tissue, Wrapper, - NetworkType + NetworkType, NetworkData } from '../../interfaces'; import {AnalysisService} from 'src/app/services/analysis/analysis.service'; import {NetworkSettings} from 'src/app/network-settings'; @@ -39,6 +39,7 @@ export class NetworkComponent implements OnInit { @ViewChild('networkWithLegend', {static: false}) networkWithLegendEl: ElementRef; public networkInternal: any = null; + public inputNetwork: NetworkData = {nodes: [], edges: []}; public selectedWrapper: Wrapper | null = null; diff --git a/src/app/dialogs/launch-analysis/launch-analysis.component.ts b/src/app/dialogs/launch-analysis/launch-analysis.component.ts index 000a267386f49afc9183f19cbb44aa2f777e3df4..88be689732e895380f53e92beff89f398ac83bc6 100644 --- a/src/app/dialogs/launch-analysis/launch-analysis.component.ts +++ b/src/app/dialogs/launch-analysis/launch-analysis.component.ts @@ -8,6 +8,7 @@ import { } from '../../services/analysis/analysis.service'; import { Algorithm, AlgorithmType, QuickAlgorithmType } from 'src/app/interfaces'; import { DrugstoneConfigService } from 'src/app/services/drugstone-config/drugstone-config.service'; +import {NetworkHandlerService} from "../../services/network-handler/network-handler.service"; @Component({ selector: 'app-launch-analysis', @@ -76,7 +77,7 @@ export class LaunchAnalysisComponent implements OnInit, OnChanges { public maxTasks = MAX_TASKS; - constructor(public analysis: AnalysisService, public drugstoneConfig: DrugstoneConfigService) { + constructor(public analysis: AnalysisService, public drugstoneConfig: DrugstoneConfigService, public networkHandler: NetworkHandlerService) { } ngOnInit(): void { @@ -112,7 +113,7 @@ export class LaunchAnalysisComponent implements OnInit, OnChanges { const parameters: any = { seeds: seedsFiltered, config: this.drugstoneConfig.config, - input_network: this.analysis.inputNetwork + input_network: this.networkHandler.activeNetwork.inputNetwork }; parameters.ppi_dataset = this.drugstoneConfig.config.interactionProteinProtein; parameters.pdi_dataset = this.drugstoneConfig.config.interactionDrugProtein; @@ -123,7 +124,7 @@ export class LaunchAnalysisComponent implements OnInit, OnChanges { // 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 // @ts-ignore - this.analysis.inputNetwork.nodes.forEach(node => { + this.networkHandler.activeNetwork.inputNetwork.nodes.forEach(node => { delete node.interactions }); diff --git a/src/app/interfaces.ts b/src/app/interfaces.ts index ad8239419668f2eca0fa9f28a433a3b0edb6d725..215f50184303032584bced176d14727dc252a3ed 100644 --- a/src/app/interfaces.ts +++ b/src/app/interfaces.ts @@ -38,6 +38,11 @@ export interface NodeData { edges: any; } +export interface NetworkData { + nodes: any[], + edges: NetworkEdge[] +} + export type NodeType= 'protein' | 'drug' | 'disorder' | 'other' export type NetworkType = 'explorer' | 'analysis' diff --git a/src/app/pages/explorer-page/explorer-page.component.ts b/src/app/pages/explorer-page/explorer-page.component.ts index ec14260692117b308afc9dc994dbf216cb5c4505..7aeea73551c329ddd134d974e9332c9917da9f0f 100644 --- a/src/app/pages/explorer-page/explorer-page.component.ts +++ b/src/app/pages/explorer-page/explorer-page.component.ts @@ -105,8 +105,8 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { public proteinData: ProteinNetwork; - public proteins: Node[]; - public edges: NodeInteraction[]; + // public proteins: Node[]; + // public edges: NodeInteraction[]; // this will store the vis Dataset public nodeData: { nodes: any, edges: any } = {nodes: null, edges: null}; @@ -261,7 +261,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { this.networkHandler.activeNetwork.selectedWrapper = null; // getNetwork synchronizes the input network with the database await this.getNetwork(); - this.proteinData = new ProteinNetwork(this.proteins, this.edges); + this.proteinData = new ProteinNetwork(this.networkHandler.activeNetwork.inputNetwork.nodes,this.networkHandler.activeNetwork.inputNetwork.edges); if (this.networkHandler.activeNetwork.networkPositions) { this.proteinData.updateNodePositions(this.networkHandler.activeNetwork.networkPositions); @@ -367,7 +367,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { this.networkHandler.activeNetwork.queryItems = []; this.networkHandler.activeNetwork.updateQueryItems(); - this.networkHandler.activeNetwork.currentViewProteins = this.proteins; + this.networkHandler.activeNetwork.currentViewProteins = this.networkHandler.activeNetwork.inputNetwork.nodes; // this.fillQueryItems(this.currentViewNodes); if (this.networkHandler.activeNetwork.selectedWrapper) { this.networkHandler.activeNetwork.networkInternal.selectNodes([this.networkHandler.activeNetwork.selectedWrapper.id]); @@ -423,9 +423,9 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { }); // remove edges without endpoints network.edges = edges; - this.analysis.inputNetwork = network; - this.proteins = network.nodes; - this.edges = network.edges; + this.networkHandler.activeNetwork.inputNetwork = network; + // this.proteins = network.nodes; + // this.edges = network.edges; } private setWindowWidth(width: number) { @@ -577,13 +577,13 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { getNodes() :any { if (this.selectedAnalysisToken && this.analysisPanel) return this.analysisPanel.getResultNodes() - return this.proteins + return this.networkHandler.activeNetwork.inputNetwork.nodes; } getEdges() :any { if(this.selectedAnalysisToken && this.analysisPanel) return this.analysisPanel.getResultEdges() - return this.edges + return this.networkHandler.activeNetwork.inputNetwork.edges } @@ -591,12 +591,12 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { this.taskEvent.emit(eventObject); } - //TODO check if used - setInputNetwork(network: any) { - if (network == null) - this.analysis.inputNetwork = { nodes: this.proteins, edges: this.edges } - else - this.analysis.inputNetwork = network; - } - + // //TODO check if used + // setInputNetwork(network: any) { + // if (network == null) + // this.analysis.inputNetwork = { nodes: this.proteins, edges: this.edges } + // else + // this.analysis.inputNetwork = network; + // } +// } diff --git a/src/app/services/analysis/analysis.service.ts b/src/app/services/analysis/analysis.service.ts index d7d1ac16779d0f1feca1862323b7e7d0c409bbb1..6dc4122af83f861a1fddb59c324cb74a97ad4cad 100644 --- a/src/app/services/analysis/analysis.service.ts +++ b/src/app/services/analysis/analysis.service.ts @@ -243,11 +243,10 @@ export class AnalysisService { }) } const target = ['connect', 'connectSelected'].includes(algorithm) ? 'drug-target' : 'drug' - const parameters: any = { seeds: seeds, config: this.drugstoneConfig.config, - input_network: this.inputNetwork, + input_network: this.networkHandler.activeNetwork.inputNetwork, ppi_dataset: this.drugstoneConfig.config.interactionProteinProtein, pdi_dataset: this.drugstoneConfig.config.interactionDrugProtein, target: target, diff --git a/src/index.html b/src/index.html index 0831745eaeef868b11880c6c65770753bf72a2e3..480b4ecaa2effa0c8c32b1810e45259e19b2a5e9 100644 --- a/src/index.html +++ b/src/index.html @@ -92,9 +92,9 @@ <drugst-one id="netexp1" pluginId="2" - groups='{"nodeGroups":{"important":{"type":"gene","color":"#ff881f","font":{"color":"#000000"},"groupName":"Important Gene","shape":"star"},"gene":{"type":"gene","color":"#4da300","font":{"color":"#f0f0f0"},"groupName":"Gene","shape":"circle"}}}' + groups='{"nodeGroups":{"patient":{"type":"patient","color":"#000000","font":{"color":"#000000"},"groupName":"Patient","shape":"image","image":"https://static.thenounproject.com/png/22780-200.png"},"condition":{"type":"condition","color":"#000000","font":{"color":"#000000"},"groupName":"Condition","shape":"text"},"important":{"type":"gene","color":"#ff881f","font":{"color":"#000000"},"groupName":"Important Gene","shape":"star"},"gene":{"type":"gene","color":"#4da300","font":{"color":"#f0f0f0"},"groupName":"Gene","shape":"circle"},"foundDrug":{"type":"drug","color":"#F12590","font":{"color":"#000000"},"groupName":"Drug","shape":"diamond"}},"edgeGroups":{"genotype":{"color":"#000000","groupName":"Relevant Gene"},"has-condition":{"color":"#000000","groupName":"Has Condition","dashes":[2,2]},"default":{"color":"#000000","groupName":"default edge"},"ggi":{"color":"#000000","groupName":"Interaction","dashes":[3,2]}}}' config='{"showSimpleAnalysis": true, "licensedDatasets": false, "physicsOn":false,"identifier":"symbol","title":"Breast cancer example network","nodeShadow":true,"edgeShadow":false,"autofillEdges":true,"showLegend":true}' - network='{"nodes":[{"id":"FOXP3","label":"FOXP3","group":"gene"},{"id":"ATM","label":"ATM","group":"gene","x":289,"y":242},{"id":"BARD1","label":"BARD1","group":"gene","x":44,"y":250},{"id":"BRCA1","label":"BRCA1","group":"gene","x":466,"y":576},{"id":"BRCA2","label":"BRCA2","group":"gene","x":507,"y":285},{"id":"BRIP1","label":"BRIP1","group":"gene","x":54,"y":474},{"id":"CHEK2","label":"CHEK2","group":"gene","x":216,"y":590},{"id":"CDH1","label":"CDH1","group":"gene","x":320,"y":-57},{"id":"NF1","label":"NF1","group":"gene","x":481,"y":111},{"id":"NBN","label":"NBN","group":"gene","x":-57,"y":314},{"id":"PALB2","label":"PALB2","group":"gene","x":450,"y":190},{"id":"PTEN","label":"PTEN","group":"important","x":305,"y":494},{"id":"RAD51C","label":"RAD51C","group":"gene","x":182,"y":-90},{"id":"RAD51D","label":"RAD51D","group":"gene","x":368,"y":73},{"id":"STK11","label":"STK11","group":"gene","x":686,"y":330},{"id":"TP53","label":"TP53","group":"important","x":333,"y":316}]}' + network='{"nodes":[{"id": "FOXP3"},{"id":"patient-1","group":"patient","x":592,"y":446},{"id":"patient-2","group":"patient","x":235,"y":87},{"id":"patient-3","group":"patient","x":105,"y":369},{"id":"ATM","label":"ATM","group":"gene","x":289,"y":242},{"id":"BARD1","label":"BARD1","group":"gene","x":44,"y":250},{"id":"BRCA1","label":"BRCA1","group":"gene","x":466,"y":576},{"id":"BRCA2","label":"BRCA2","group":"gene","x":507,"y":285},{"id":"BRIP1","label":"BRIP1","group":"gene","x":54,"y":474},{"id":"CHEK2","label":"CHEK2","group":"gene","x":216,"y":590},{"id":"CDH1","label":"CDH1","group":"gene","x":320,"y":-57},{"id":"NF1","label":"NF1","group":"gene","x":481,"y":111},{"id":"NBN","label":"NBN","group":"gene","x":-57,"y":314},{"id":"PALB2","label":"PALB2","group":"gene","x":450,"y":190},{"id":"PTEN","label":"PTEN","group":"important","x":305,"y":494},{"id":"RAD51C","label":"RAD51C","group":"gene","x":182,"y":-90},{"id":"RAD51D","label":"RAD51D","group":"gene","x":368,"y":73},{"id":"STK11","label":"STK11","group":"gene","x":686,"y":330},{"id":"TP53","label":"TP53","group":"important","x":333,"y":316},{"id":"subtype-1","label":"Subtype 1","group":"condition","x":556,"y":171},{"id":"subtype-2","label":"Subtype 2","group":"condition","x":-87,"y":221}],"edges":[{"from":"BRCA1","to":"BRCA2","group":"ggi"},{"from":"ATM","to":"BARD1","group":"ggi"},{"from":"BRCA1","to":"CHEK2","group":"ggi"},{"from":"RAD51C","to":"RAD51D","group":"ggi"},{"from":"STK11","to":"TP53","group":"ggi"},{"from":"TP53","to":"PALB2","group":"ggi"},{"from":"TP53","to":"RAD51D","group":"ggi"},{"from":"TP53","to":"NF1","group":"ggi"},{"from":"TP53","to":"BRCA1","group":"ggi"},{"from":"TP53","to":"BRCA2","group":"ggi"},{"from":"PTEN","to":"BRCA1","group":"ggi"},{"from":"PTEN","to":"BRCA2","group":"ggi"},{"from":"TP53","to":"PTEN","group":"ggi"},{"from":"ATM","to":"PTEN","group":"ggi"},{"from":"CDH1","to":"RAD51D","group":"ggi"},{"from":"CDH1","to":"PALB2","group":"ggi"},{"from":"NBN","to":"BRIP1","group":"ggi"},{"from":"BRIP1","to":"PTEN","group":"ggi"},{"from":"patient-1","to":"BRCA1","group":"genotype"},{"from":"patient-1","to":"TP53","group":"genotype"},{"from":"patient-1","to":"BRCA2","group":"genotype"},{"from":"patient-1","to":"PTEN","group":"genotype"},{"from":"patient-2","to":"TP53","group":"genotype"},{"from":"patient-2","to":"NF1","group":"genotype"},{"from":"patient-2","to":"BARD1","group":"genotype"},{"from":"patient-3","to":"TP53","group":"genotype"},{"from":"patient-3","to":"PTEN","group":"genotype"},{"from":"patient-3","to":"NBN","group":"genotype"},{"from":"patient-1","to":"subtype-1","group":"has-condition"},{"from":"patient-2","to":"subtype-1","group":"has-condition"},{"from":"patient-3","to":"subtype-2","group":"has-condition"}]}' > </drugst-one> diff --git a/src/stylesheets/styles.scss b/src/stylesheets/styles.scss index b66ee420cc7706d1dd94fda0da6034ff5dbd494d..e87b019eb20bd6a5f06cf100ec7ca8b5d3870b23 100644 --- a/src/stylesheets/styles.scss +++ b/src/stylesheets/styles.scss @@ -228,10 +228,15 @@ padding-right: 0; padding-left: 0; } + .card-header { padding: 0 0; line-height: 18px; } + + div.legend, tr.list-item { + line-height: calc(35px / 2); + } } .row > * {