From bec8a38e9ba816dac0196f213e497d17097e266f Mon Sep 17 00:00:00 2001 From: AndiMajore <andi.majore@googlemail.com> Date: Fri, 24 Sep 2021 17:18:26 +0200 Subject: [PATCH] updating query entries; fixed disorder information; --- .../analysis-panel.component.html | 21 +++ .../analysis-panel.component.ts | 123 +++++++++++++++--- .../info-tile/info-tile.component.html | 29 +++-- .../info-tile/info-tile.component.ts | 11 +- .../network-legend.component.ts | 2 + .../query-tile/query-tile.component.ts | 8 -- .../components/toggle/toggle.component.html | 4 +- src/app/components/toggle/toggle.component.ts | 1 + src/app/interfaces.ts | 14 +- .../explorer-page.component.html | 9 +- .../explorer-page/explorer-page.component.ts | 84 +++++++----- 11 files changed, 229 insertions(+), 77 deletions(-) diff --git a/src/app/components/analysis-panel/analysis-panel.component.html b/src/app/components/analysis-panel/analysis-panel.component.html index 61c25530..5a680644 100644 --- a/src/app/components/analysis-panel/analysis-panel.component.html +++ b/src/app/components/analysis-panel/analysis-panel.component.html @@ -245,6 +245,27 @@ tooltipOff="Display adjacent drugs OFF." [smallStyle]="smallStyle" [value]="adjacentDrugs" (valueChange)="updateAdjacentDrugs($event)"></app-toggle> + <app-toggle + class="footer-buttons network-footer-toolbar-element" + textOn="Disorders (protein)" + textOff="Off" + tooltipOn="Show disorders adjacent to all currently displayed proteins/genes ON." + tooltipOff="Show disorders adjacent to all currently displayed proteins/genes OFF." + [smallStyle]="smallStyle" + [value]="adjacentDisordersProtein" + (valueChange)="updateAdjacentProteinDisorders($event)" + ></app-toggle> + <app-toggle + class="footer-buttons network-footer-toolbar-element" + textOn="Disorders (drugs)" + textOff="Off" + tooltipOn="Show disorders adjacent to all currently displayed drugs ON." + tooltipOff="Show disorders adjacent to all currently displayed drugs OFF." + [smallStyle]="smallStyle" + [value]="adjacentDisordersDrug" + [disabled]="!hasDrugsLoaded()" + (valueChange)="updateAdjacentDrugDisorders($event)" + ></app-toggle> <app-toggle class="footer-buttons network-footer-toolbar-element" textOn="Animation" textOff="Off" tooltipOn="Enable the network animation." diff --git a/src/app/components/analysis-panel/analysis-panel.component.ts b/src/app/components/analysis-panel/analysis-panel.component.ts index 6840a471..afe093d5 100644 --- a/src/app/components/analysis-panel/analysis-panel.component.ts +++ b/src/app/components/analysis-panel/analysis-panel.component.ts @@ -73,7 +73,6 @@ export class AnalysisPanelComponent implements OnInit, OnChanges { @Output() tokenChange = new EventEmitter<string | null>(); @Output() showDetailsChange = new EventEmitter<Wrapper>(); @Output() visibleItems = new EventEmitter<[any[], [Node[], Tissue], NodeInteraction[]]>(); - public task: Task | null = null; public result: any = null; public myConfig: IConfig = JSON.parse(JSON.stringify(defaultConfig)); @@ -90,6 +89,15 @@ export class AnalysisPanelComponent implements OnInit, OnChanges { public adjacentDrugList: Node[] = []; public adjacentDrugEdgesList: Node[] = []; + public adjacentDisordersProtein = false; + public adjacentDisordersDrug = false; + + public adjacentProteinDisorderList: Node[] = []; + public adjacentProteinDisorderEdgesList: Node[] = []; + + public adjacentDrugDisorderList: Node[] = []; + public adjacentDrugDisorderEdgesList: Node[] = []; + public highlightSeeds = false; public seedMap: NodeAttributeMap; @@ -329,7 +337,6 @@ export class AnalysisPanelComponent implements OnInit, OnChanges { this.emitVisibleItems(true); this.setLegendContext(); - } public emitVisibleItems(on: boolean) { @@ -389,6 +396,80 @@ export class AnalysisPanelComponent implements OnInit, OnChanges { } } + + public saveAddNodes(nodeList: Node[]) { + const existing = this.nodeData.nodes.get().map(n => n.id); + const toAdd = nodeList.filter(n => existing.indexOf(n.id) === -1) + this.nodeData.nodes.add(toAdd); + } + + public saveRemoveDisorders(nodeList: Node[]) { + const other = this.adjacentDrugDisorderList === nodeList ? this.adjacentProteinDisorderList : this.adjacentDrugDisorderList + if (other == null) + this.nodeData.nodes.remove(nodeList); + else { + const otherIds = other.map(d => d.id); + const rest = nodeList.filter(d => otherIds.indexOf(d.id) === -1) + this.nodeData.nodes.remove(rest) + } + } + + public updateAdjacentProteinDisorders(bool: boolean) { + this.adjacentDisordersProtein = bool; + if (this.adjacentDisordersProtein) { + this.netex.adjacentDisorders(this.nodeData.nodes, 'proteins').subscribe(response => { + for (const interaction of response.edges) { + const edge = {from: interaction.protein, to: interaction.disorder}; + this.adjacentProteinDisorderEdgesList.push(mapCustomEdge(edge, this.myConfig)); + } + for (const disorder of response.disorders) { + disorder.group = 'defaultDisorder'; + disorder.id = disorder.netexId; + this.adjacentProteinDisorderList.push(mapCustomNode(disorder, this.myConfig)) + } + this.saveAddNodes(this.adjacentProteinDisorderList); + this.nodeData.edges.add(this.adjacentProteinDisorderEdgesList); + this.emitVisibleItems(true); + }); + this.legendContext = this.adjacentDrugs ? 'adjacentDrugsAndDisorders' : 'adjacentDisorders'; + } else { + this.saveRemoveDisorders(this.adjacentProteinDisorderList); + this.nodeData.edges.remove(this.adjacentProteinDisorderEdgesList); + this.adjacentProteinDisorderList = []; + this.adjacentProteinDisorderEdgesList = []; + this.legendContext = this.adjacentDisordersDrug ? this.legendContext : this.adjacentDrugs ? 'adjacentDrugs' : 'explorer'; + this.emitVisibleItems(true); + } + } + + public updateAdjacentDrugDisorders(bool: boolean) { + this.adjacentDisordersDrug = bool; + if (this.adjacentDisordersDrug) { + this.netex.adjacentDisorders(this.nodeData.nodes, 'drugs').subscribe(response => { + for (const interaction of response.edges) { + const edge = {from: interaction.drug, to: interaction.disorder}; + this.adjacentDrugDisorderEdgesList.push(mapCustomEdge(edge, this.myConfig)); + } + for (const disorder of response.disorders) { + disorder.group = 'defaultDisorder'; + disorder.id = disorder.netexId; + this.adjacentDrugDisorderList.push(mapCustomNode(disorder, this.myConfig)); + } + this.saveAddNodes(this.adjacentDrugDisorderList); + this.nodeData.edges.add(this.adjacentDrugDisorderEdgesList); + this.emitVisibleItems(true); + }); + this.legendContext = this.adjacentDrugs ? 'adjacentDrugsAndDisorders' : 'adjacentDisorders'; + } else { + this.saveRemoveDisorders(this.adjacentDrugDisorderList); + this.nodeData.edges.remove(this.adjacentDrugDisorderEdgesList); + this.adjacentDrugDisorderList = []; + this.adjacentDrugDisorderEdgesList = []; + this.legendContext = this.adjacentDisordersProtein ? this.legendContext : this.adjacentDrugs ? 'adjacentDrugs' : 'explorer'; + this.emitVisibleItems(true); + } + } + public downloadLink(view: string): string { return `${environment.backend}task_result/?token=${this.token}&view=${view}&fmt=csv`; } @@ -558,31 +639,39 @@ export class AnalysisPanelComponent implements OnInit, OnChanges { this.setLegendContext(); } + hasDrugsLoaded(): boolean { + if (this.nodeData == null || this.nodeData.nodes == null) + return false; + return this.nodeData.nodes.get().filter((node: Node) => node.drugId && node.netexId.startsWith('dr')).length > 0; + } + public updateAdjacentDrugs(bool: boolean) { this.adjacentDrugs = bool; if (this.adjacentDrugs) { - this.netex.adjacentDrugs(this.myConfig.interactionDrugProtein, this.nodeData.nodes).subscribe(response => { - for (const interaction of response.pdis) { - const edge = {from: interaction.protein, to: interaction.drug}; - this.adjacentDrugEdgesList.push(mapCustomEdge(edge, this.myConfig)); - } - for (const drug of response.drugs) { - drug.group = 'foundDrug'; - drug.id = getDrugNodeId(drug) - this.adjacentDrugList.push(mapCustomNode(drug, this.myConfig)) - } - this.nodeData.nodes.add(this.adjacentDrugList); - this.nodeData.edges.add(this.adjacentDrugEdgesList); + this.netex.adjacentDrugs(this.myConfig.interactionDrugProtein, this.nodeData.nodes).subscribe(response => { + for (const interaction of response.pdis) { + const edge = {from: interaction.protein, to: interaction.drug}; + this.adjacentDrugEdgesList.push(mapCustomEdge(edge, this.myConfig)); + } + for (const drug of response.drugs) { + drug.group = 'foundDrug'; + drug.id = getDrugNodeId(drug) + this.adjacentDrugList.push(mapCustomNode(drug, this.myConfig)) + } + this.nodeData.nodes.add(this.adjacentDrugList); + this.nodeData.edges.add(this.adjacentDrugEdgesList); + this.emitVisibleItems(true); }) + this.legendContext = this.adjacentDisordersDrug || this.adjacentDisordersProtein ? 'adjacentDrugsAndDisorders' : 'adjacentDrugs'; } else { this.nodeData.nodes.remove(this.adjacentDrugList); this.nodeData.edges.remove(this.adjacentDrugEdgesList); this.adjacentDrugList = []; this.adjacentDrugEdgesList = []; + + this.legendContext = this.adjacentDisordersDrug || this.adjacentDisordersProtein ? 'adjacentDisorders' : 'explorer'; + this.emitVisibleItems(true); } - this.setLegendContext() - // emit data to update sidebar information - this.emitVisibleItems(true); } public updatePhysicsEnabled(bool: boolean) { diff --git a/src/app/components/info-tile/info-tile.component.html b/src/app/components/info-tile/info-tile.component.html index 0642dc22..f509cfc2 100644 --- a/src/app/components/info-tile/info-tile.component.html +++ b/src/app/components/info-tile/info-tile.component.html @@ -1,6 +1,7 @@ <div *ngIf="wrapper"> <div> - <p *ngIf="!wrapper.data.drugId && wrapper.data.detailShowLabel && wrapper.data.label" [ngClass]="{'text-normal':smallStyle}"> + <p *ngIf="!wrapper.data.drugId && wrapper.data.detailShowLabel && wrapper.data.label" + [ngClass]="{'text-normal':smallStyle}"> <b><span>Label:</span></b> <span class="is-capitalized"> {{ wrapper.data.label }}</span> </p> @@ -12,16 +13,26 @@ <b><span>Symbol:</span></b> <span class="is-capitalized"> {{ wrapper.data.symbol }}</span> </p> - <p *ngIf="wrapper.data.drugId" [ngClass]="{'text-normal':smallStyle}"> + <p *ngIf="wrapper.data.drugId || wrapper.data.disorderId" [ngClass]="{'text-normal':smallStyle}"> <b><span>Name:</span></b> <span class="is-capitalized"> {{ wrapper.data.label }}</span> </p> + <p *ngIf="wrapper.data.icd10" [ngClass]="{'text-normal': smallStyle}"> + <b><span>ICD10:</span></b> + <span class="is-capitalized"> {{wrapper.data.icd10.length===0 || (wrapper.data.icd10.length ===1 && wrapper.data.icd10[0].length===0) ? '-' : wrapper.data.icd10}}</span> + </p> <p *ngIf="wrapper.data.drugId" [ngClass]="{'text-normal':smallStyle}"> <b><span>DrugBank:</span></b> <a href="https://go.drugbank.com/drugs/{{ wrapper.data.drugId }}" target="_blank"> <span class="is-capitalized"> {{ wrapper.data.drugId }}</span> </a> </p> + <p *ngIf="wrapper.data.disorderId" [ngClass]="{'text-normal':smallStyle}"> + <b><span>Mondo:</span></b> + <a href="https://www.ebi.ac.uk/ols/ontologies/mondo/terms?iri=http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FMONDO_{{writeZeros(7-(''+wrapper.data.disorderId).length)}}{{ wrapper.data.disorderId }}" target="_blank"> + <span class="is-capitalized"> MONDO:{{ wrapper.data.disorderId }}</span> + </a> + </p> <p *ngIf="wrapper.data.groupName" [ngClass]="{'text-normal':smallStyle}"> <b><span>Group:</span></b> <span class="is-capitalized"> {{ wrapper.data.groupName }}</span> @@ -34,7 +45,7 @@ </p> <p *ngIf="wrapper.data.ensg" [ngClass]="{'text-normal':smallStyle}"> <b><span>Ensembl:</span></b> - <a + <a *ngFor="let ensg of wrapper.data.ensg" href="https://www.ensembl.org/Homo_sapiens/Gene/Summary?g={{ ensg }}" target="_blank"> <span class="is-capitalized"> {{ ensg }}</span> @@ -43,12 +54,12 @@ </div> - <app-toggle - *ngIf="wrapper.data.netexId && wrapper.data.netexId.startsWith('p')" - [value]="analysis.inSelection(wrapper)" [smallStyle]="smallStyle" - (valueChange)="$event ? analysis.addItems([wrapper]) : analysis.removeItems([wrapper])" textOn="Seed" - textOff="Off" tooltipOn="Add protein to selection." tooltipOff="Remove protein from selection."></app-toggle> + <app-toggle + *ngIf="wrapper.data.netexId && wrapper.data.netexId.startsWith('p')" + [value]="analysis.inSelection(wrapper)" [smallStyle]="smallStyle" + (valueChange)="$event ? analysis.addItems([wrapper]) : analysis.removeItems([wrapper])" textOn="Seed" + textOff="Off" tooltipOn="Add protein to selection." tooltipOff="Remove protein from selection."></app-toggle> </div> -<div *ngIf="!wrapper" [ngClass]="{'text-normal':smallStyle}" > +<div *ngIf="!wrapper" [ngClass]="{'text-normal':smallStyle}"> Please select a node for further information. </div> diff --git a/src/app/components/info-tile/info-tile.component.ts b/src/app/components/info-tile/info-tile.component.ts index 44bd205e..514b0f72 100644 --- a/src/app/components/info-tile/info-tile.component.ts +++ b/src/app/components/info-tile/info-tile.component.ts @@ -13,7 +13,8 @@ export class InfoTileComponent implements OnInit { @Input() public wrapper: Wrapper; @Input() smallStyle: boolean; - constructor(public analysis: AnalysisService) { } + constructor(public analysis: AnalysisService) { + } ngOnInit(): void { } @@ -31,4 +32,12 @@ export class InfoTileComponent implements OnInit { return url; } + writeZeros(n: number) { + let out = ''; + while (n > 0) { + out += '0'; + n--; + } + return out; + } } diff --git a/src/app/components/network-legend/network-legend.component.ts b/src/app/components/network-legend/network-legend.component.ts index 79c83120..142c0e07 100644 --- a/src/app/components/network-legend/network-legend.component.ts +++ b/src/app/components/network-legend/network-legend.component.ts @@ -16,6 +16,7 @@ export class NetworkLegendComponent implements OnInit { 'explorer': ['foundNode', 'foundDrug', 'seedNode', 'default', 'defaultDisorder'], 'adjacentDrugs': ['foundNode', 'seedNode', 'default', 'defaultDisorder'], 'adjacentDisorders': ['foundDrug', 'foundNode', 'seedNode', 'default'], + 'adjacentDrugsAndDisorders': ['foundNode', 'seedNode', 'default'], 'drugTarget': ['foundDrug', 'seedNode', 'default', 'defaultDisorder'], 'drug': ['seedNode', 'default', 'defaultDisorder'], 'drugTargetAndSeeds': ['foundDrug', 'default', 'defaultDisorder'], @@ -26,6 +27,7 @@ export class NetworkLegendComponent implements OnInit { 'explorer': ['default'], 'adjacentDrugs': ['default'], 'adjacentDisorders': ['default'], + 'adjacentDrugsAndDisorders' :['default'], 'drugTarget': ['default'], 'drug': ['default'], 'drugTargetAndSeeds': ['default'], diff --git a/src/app/components/query-tile/query-tile.component.ts b/src/app/components/query-tile/query-tile.component.ts index 2ffa2b7a..79741256 100644 --- a/src/app/components/query-tile/query-tile.component.ts +++ b/src/app/components/query-tile/query-tile.component.ts @@ -30,32 +30,24 @@ export class QueryTileComponent { if (data.ensg === undefined) { data.ensg = [] } - ; if (data.groupName === undefined) { data.groupName = '' } - ; if (data.type === undefined) { data.type = '' } - ; if (data.symbol === undefined) { data.symbol = '' } - ; if (data.proteinName === undefined) { data.proteinName = '' } - ; if (data.uniprotAc === undefined) { data.uniprotAc = '' } - ; if (data.drugId === undefined) { data.drugId = '' } - ; - return data.symbol.toLowerCase().indexOf(term) > -1 || data.uniprotAc.toLowerCase().indexOf(term) > -1 || data.label.toLowerCase().indexOf(term) > -1 || this.listStartsWith(data.ensg, term) || data.id.toLowerCase().indexOf(term) > -1 || data.proteinName.toLowerCase().indexOf(term) > -1 || data.type.toLowerCase().indexOf(term) > -1 || diff --git a/src/app/components/toggle/toggle.component.html b/src/app/components/toggle/toggle.component.html index cab8b7a9..1ba8d66e 100644 --- a/src/app/components/toggle/toggle.component.html +++ b/src/app/components/toggle/toggle.component.html @@ -1,6 +1,6 @@ <div class="field has-addons"> <p class="control has-tooltip"> - <button class="button is-rounded has-tooltip" [pTooltip]="tooltipOn" [tooltipStyleClass]="'drgstn drgstn-tooltip'" tooltipPosition="top" [class.is-primary]="value" (click)="toggle(true)" [ngClass]="{'switch-small':smallStyle}"> + <button class="button is-rounded has-tooltip" [pTooltip]="tooltipOn" [disabled]="disabled" [tooltipStyleClass]="'drgstn drgstn-tooltip'" tooltipPosition="top" [class.is-primary]="value" (click)="toggle(true)" [ngClass]="{'switch-small':smallStyle}"> <span class="icon is-small"> <i class="fa {{iconOn}}"></i> </span> @@ -8,7 +8,7 @@ </button> </p> <p class="control"> - <button class="button is-rounded has-tooltip" [pTooltip]="tooltipOff" [tooltipStyleClass]="'drgstn drgstn-tooltip'" tooltipPosition="top" [class.is-primary]="!value" (click)="toggle(false)" [ngClass]="{'switch-small':smallStyle}"> + <button class="button is-rounded has-tooltip" [pTooltip]="tooltipOff" [disabled]="disabled" [tooltipStyleClass]="'drgstn drgstn-tooltip'" tooltipPosition="top" [class.is-primary]="!value" (click)="toggle(false)" [ngClass]="{'switch-small':smallStyle}"> <span [ngClass]="{'text-small':smallStyle}">{{textOff}}</span> <span *ngIf="iconOff" class="icon is-small"> <i class="fa {{iconOff}}"></i> diff --git a/src/app/components/toggle/toggle.component.ts b/src/app/components/toggle/toggle.component.ts index 6b396763..a0f7617a 100644 --- a/src/app/components/toggle/toggle.component.ts +++ b/src/app/components/toggle/toggle.component.ts @@ -14,6 +14,7 @@ export class ToggleComponent implements OnInit { @Input() textOff = 'Off'; @Input() tooltipOn: string; @Input() tooltipOff: string; + @Input() disabled = false; @Input() smallStyle: boolean; diff --git a/src/app/interfaces.ts b/src/app/interfaces.ts index 3bebde46..32ab10f6 100644 --- a/src/app/interfaces.ts +++ b/src/app/interfaces.ts @@ -33,7 +33,7 @@ export interface Tissue { } export type legendContext = 'explorer' | 'adjacentDrugs' | 'drug' | 'drugTarget' | -'drugTargetAndSeeds' | 'drugAndSeeds' | 'adjacentDisorders'; +'drugTargetAndSeeds' | 'drugAndSeeds' | 'adjacentDisorders' | 'adjacentDrugsAndDisorders'; /// netexId to expressionlvl export type NodeAttributeMap = { string: number } | {}; @@ -153,16 +153,16 @@ export function getId(gene: Node) { return `${gene.id}`; } -export function getWrapperFromNode(gene: Node): Wrapper { +export function getWrapperFromNode(node: Node): Wrapper { /** * Constructs wrapper interface for gene */ // if node does not have property group, it was custom node from user - gene.group = gene.group ? gene.group : 'default'; - gene.label = gene.label ? gene.label : gene.id + node.group = node.group ? node.group : 'default'; + node.label = node.label ? node.label : node.id return { - id: gene.id, - data: gene, + id: node.id, + data: node, }; } @@ -189,6 +189,8 @@ export interface Wrapper { x?: number; y?: number; drugId?: string; + disorderId?: string; + icd10?: string[]; status?: 'approved' | 'investigational'; inTrial?: boolean; inLiterature?: boolean; diff --git a/src/app/pages/explorer-page/explorer-page.component.html b/src/app/pages/explorer-page/explorer-page.component.html index dc5e1158..fa896d6c 100644 --- a/src/app/pages/explorer-page/explorer-page.component.html +++ b/src/app/pages/explorer-page/explorer-page.component.html @@ -303,8 +303,8 @@ class="footer-buttons network-footer-toolbar-element" textOn="Disorders (protein)" textOff="Off" - tooltipOn="Display adjacent disorders ON." - tooltipOff="Display adjacent disorders OFF." + tooltipOn="Show disorders adjacent to all currently displayed proteins/genes ON." + tooltipOff="Show disorders adjacent to all currently displayed proteins/genes OFF." [smallStyle]="smallStyle" [value]="adjacentDisordersProtein" (valueChange)="updateAdjacentProteinDisorders($event)" @@ -313,10 +313,11 @@ class="footer-buttons network-footer-toolbar-element" textOn="Disorders (drugs)" textOff="Off" - tooltipOn="Display adjacent disorders ON." - tooltipOff="Display adjacent disorders OFF." + tooltipOn="Show disorders adjacent to all currently displayed drugs ON." + tooltipOff="Show disorders adjacent to all currently displayed drugs OFF." [smallStyle]="smallStyle" [value]="adjacentDisordersDrug" + [disabled]="!hasDrugsLoaded()" (valueChange)="updateAdjacentDrugDisorders($event)" ></app-toggle> <app-toggle diff --git a/src/app/pages/explorer-page/explorer-page.component.ts b/src/app/pages/explorer-page/explorer-page.component.ts index 6662d944..ecdf4817 100644 --- a/src/app/pages/explorer-page/explorer-page.component.ts +++ b/src/app/pages/explorer-page/explorer-page.component.ts @@ -152,11 +152,13 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { private dumpPositions = false; public physicsEnabled = false; public adjacentDrugs = false; - public adjacentDisordersProtein = false; - public adjacentDisordersDrug = false; + public adjacentDrugList: Node[] = []; public adjacentDrugEdgesList: Node[] = []; + public adjacentDisordersProtein = false; + public adjacentDisordersDrug = false; + public adjacentProteinDisorderList: Node[] = []; public adjacentProteinDisorderEdgesList: Node[] = []; @@ -458,22 +460,31 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { this.currentViewEdges = this.nodeData.edges; this.queryItems = []; - this.fillQueryItems(this.currentViewNodes); + this.updateQueryItems(); + this.currentViewProteins = this.proteins; + // this.fillQueryItems(this.currentViewNodes); if (this.selectedWrapper) { this.networkInternal.selectNodes([this.selectedWrapper.id]); } } - fillQueryItems(hostProteins: Node[]) { + updateQueryItems() { this.queryItems = []; - hostProteins.forEach((protein) => { + this.currentViewNodes.forEach((protein) => { this.queryItems.push(getWrapperFromNode(protein)); }); - - - this.currentViewProteins = this.proteins; } + // fillQueryItems(hostProteins: Node[]) { + // this.queryItems = []; + // hostProteins.forEach((protein) => { + // this.queryItems.push(getWrapperFromNode(protein)); + // }); + // + // + // this.currentViewProteins = this.proteins; + // } + public queryAction(item: any) { if (item) { this.openSummary(item, true); @@ -492,9 +503,9 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { }); } - public updateAdjacentProteinDisorders(bool: boolean){ + public updateAdjacentProteinDisorders(bool: boolean) { this.adjacentDisordersProtein = bool; - if (this.adjacentDisordersProtein){ + if (this.adjacentDisordersProtein) { this.netex.adjacentDisorders(this.nodeData.nodes, 'proteins').subscribe(response => { for (const interaction of response.edges) { const edge = {from: interaction.protein, to: interaction.disorder}; @@ -507,20 +518,22 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { } this.saveAddNodes(this.adjacentProteinDisorderList); this.nodeData.edges.add(this.adjacentProteinDisorderEdgesList); + this.updateQueryItems(); }); - this.legendContext = 'adjacentDisorders'; - }else { + this.legendContext = this.adjacentDrugs ? 'adjacentDrugsAndDisorders' : 'adjacentDisorders'; + } else { this.saveRemoveDisorders(this.adjacentProteinDisorderList); this.nodeData.edges.remove(this.adjacentProteinDisorderEdgesList); this.adjacentProteinDisorderList = []; this.adjacentProteinDisorderEdgesList = []; - this.legendContext = 'explorer'; + this.legendContext = this.adjacentDisordersDrug ? this.legendContext : this.adjacentDrugs ? 'adjacentDrugs' : 'explorer'; + this.updateQueryItems(); } } - public updateAdjacentDrugDisorders(bool: boolean){ + public updateAdjacentDrugDisorders(bool: boolean) { this.adjacentDisordersDrug = bool; - if (this.adjacentDisordersDrug){ + if (this.adjacentDisordersDrug) { this.netex.adjacentDisorders(this.nodeData.nodes, 'drugs').subscribe(response => { for (const interaction of response.edges) { const edge = {from: interaction.drug, to: interaction.disorder}; @@ -533,33 +546,34 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { } this.saveAddNodes(this.adjacentDrugDisorderList); this.nodeData.edges.add(this.adjacentDrugDisorderEdgesList); + this.updateQueryItems(); }); - this.legendContext = 'adjacentDisorders'; - }else { + this.legendContext = this.adjacentDrugs ? 'adjacentDrugsAndDisorders' : 'adjacentDisorders'; + } else { this.saveRemoveDisorders(this.adjacentDrugDisorderList); this.nodeData.edges.remove(this.adjacentDrugDisorderEdgesList); this.adjacentDrugDisorderList = []; this.adjacentDrugDisorderEdgesList = []; - this.legendContext = 'explorer'; + this.legendContext = this.adjacentDisordersProtein ? this.legendContext : this.adjacentDrugs ? 'adjacentDrugs' : 'explorer'; + this.updateQueryItems(); } } - public saveAddNodes(nodeList: Node[]){ - const existing = this.nodeData.nodes.get().map(n=>n.id); - const toAdd = nodeList.filter(n=>existing.indexOf(n.id)===-1) + public saveAddNodes(nodeList: Node[]) { + const existing = this.nodeData.nodes.get().map(n => n.id); + const toAdd = nodeList.filter(n => existing.indexOf(n.id) === -1) this.nodeData.nodes.add(toAdd); } - public saveRemoveDisorders(nodeList: Node[]){ + public saveRemoveDisorders(nodeList: Node[]) { const other = this.adjacentDrugDisorderList === nodeList ? this.adjacentProteinDisorderList : this.adjacentDrugDisorderList - if(other==null) + if (other == null) this.nodeData.nodes.remove(nodeList); - else{ - const otherIds = other.map(d=>d.id); - const rest = nodeList.filter(d=>otherIds.indexOf(d.id)===-1) + else { + const otherIds = other.map(d => d.id); + const rest = nodeList.filter(d => otherIds.indexOf(d.id) === -1) this.nodeData.nodes.remove(rest) } - } public updateAdjacentDrugs(bool: boolean) { @@ -577,15 +591,17 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { } this.nodeData.nodes.add(this.adjacentDrugList); this.nodeData.edges.add(this.adjacentDrugEdgesList); + this.updateQueryItems(); }) - this.legendContext = 'adjacentDrugs' + this.legendContext = this.adjacentDisordersDrug || this.adjacentDisordersProtein ? 'adjacentDrugsAndDisorders' : 'adjacentDrugs'; } else { this.nodeData.nodes.remove(this.adjacentDrugList); this.nodeData.edges.remove(this.adjacentDrugEdgesList); this.adjacentDrugList = []; this.adjacentDrugEdgesList = []; - this.legendContext = 'explorer' + this.legendContext = this.adjacentDisordersDrug || this.adjacentDisordersProtein ? 'adjacentDisorders' : 'explorer'; + this.updateQueryItems(); } } @@ -706,7 +722,8 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { } // changes for either way (analysis open and close) this.selectedWrapper = null; - this.fillQueryItems(this.currentViewNodes); + this.updateQueryItems(); + // this.fillQueryItems(this.currentViewNodes); } gProfilerLink(): string { @@ -810,7 +827,14 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { this.currentViewSelectedTissue = this.selectedTissue; } + emitTaskEvent(eventObject: object) { this.taskEvent.emit(eventObject); } + + hasDrugsLoaded(): boolean { + if (this.nodeData == null || this.nodeData.nodes == null) + return false; + return this.nodeData.nodes.get().filter((node: Node) => node.drugId && node.netexId.startsWith('dr')).length > 0; + } } -- GitLab