From 003acdc36994160ad0adcfb3931352ad17fc200d Mon Sep 17 00:00:00 2001
From: Julian Matschinske <julian@vyze.ai>
Date: Thu, 26 Nov 2020 17:27:40 +0100
Subject: [PATCH] Replace 'host' with 'protein', remove more virus stuff

---
 src/app/analysis.service.ts                   | 12 ++------
 .../analysis-panel.component.ts               | 14 ++++-----
 .../info-tile/info-tile.component.html        | 13 +-------
 .../query-tile/query-tile.component.html      |  8 ++---
 .../launch-analysis.component.html            | 16 +---------
 .../launch-analysis.component.ts              |  7 -----
 src/app/interfaces.ts                         |  4 +--
 src/app/network-settings.ts                   | 30 +++++--------------
 .../explorer-page.component.html              | 12 +++-----
 .../explorer-page/explorer-page.component.ts  |  4 +--
 10 files changed, 28 insertions(+), 92 deletions(-)

diff --git a/src/app/analysis.service.ts b/src/app/analysis.service.ts
index 780307fd..23ce8084 100644
--- a/src/app/analysis.service.ts
+++ b/src/app/analysis.service.ts
@@ -160,7 +160,7 @@ export class AnalysisService {
     const newSelection = [];
     nodes.forEach((node) => {
       const wrapper: Wrapper = node.wrapper;
-      if (wrapper.type === 'host' || wrapper.type === 'virus') {
+      if (wrapper.type === 'protein') {
         if (!this.inSelection(wrapper)) {
           newSelection.push(wrapper);
         }
@@ -204,15 +204,7 @@ export class AnalysisService {
   }
 
   public removeAllHostProteins() {
-    const items: Wrapper[] = Array.from(this.selectedItems.values()).filter(p => p.type === 'host');
-    for (const wrapper of items) {
-      this.selectedItems.delete(wrapper.nodeId);
-    }
-    this.selectListSubject.next({items, selected: false});
-  }
-
-  public removeAllViralProteins() {
-    const items: Wrapper[] = Array.from(this.selectedItems.values()).filter(p => p.type === 'virus');
+    const items: Wrapper[] = Array.from(this.selectedItems.values()).filter(p => p.type === 'protein');
     for (const wrapper of items) {
       this.selectedItems.delete(wrapper.nodeId);
     }
diff --git a/src/app/components/analysis-panel/analysis-panel.component.ts b/src/app/components/analysis-panel/analysis-panel.component.ts
index db253571..ca204933 100644
--- a/src/app/components/analysis-panel/analysis-panel.component.ts
+++ b/src/app/components/analysis-panel/analysis-panel.component.ts
@@ -255,7 +255,7 @@ export class AnalysisPanelComponent implements OnInit, OnChanges {
             const proteinSelection = this.tableSelectedProteins;
             const viralProteinSelection = this.tableSelectedViralProteins;
             for (const item of items) {
-              if (item.type === 'host') {
+              if (item.type === 'protein') {
                 // TODO: Refactor!
                 const found = proteinSelection.findIndex((i) => getProteinNodeId(i) === item.nodeId);
                 const tableItem = this.tableProteins.find((i) => getProteinNodeId(i) === item.nodeId);
@@ -293,7 +293,7 @@ export class AnalysisPanelComponent implements OnInit, OnChanges {
             const proteinSelection = [];
             const viralProteinSelection = [];
             for (const item of items) {
-              if (item.type === 'host') {
+              if (item.type === 'protein') {
                 const tableItem = this.tableProteins.find((i) => getProteinNodeId(i) === item.nodeId);
                 if (tableItem) {
                   proteinSelection.push(tableItem);
@@ -369,12 +369,10 @@ export class AnalysisPanelComponent implements OnInit, OnChanges {
   }
 
   public inferNodeType(nodeId: string): WrapperType {
-    if (nodeId.indexOf('-') !== -1 || nodeId.indexOf('_') !== -1) {
-      return 'virus';
-    } else if (nodeId.startsWith('DB')) {
+    if (nodeId.startsWith('DB')) {
       return 'drug';
     }
-    return 'host';
+    return 'protein';
   }
 
   public createNetwork(result: any): { edges: any[], nodes: any[] } {
@@ -393,7 +391,7 @@ export class AnalysisPanelComponent implements OnInit, OnChanges {
     const details = attributes.details || {};
     const wrappers: { [key: string]: Wrapper } = {};
     for (const node of network.nodes) {
-      if (nodeTypes[node] === 'host') {
+      if (nodeTypes[node] === 'protein') {
         this.proteins.push(details[node]);
         wrappers[node] = getWrapperFromProtein(details[node]);
       } else if (nodeTypes[node] === 'drug') {
@@ -417,7 +415,7 @@ export class AnalysisPanelComponent implements OnInit, OnChanges {
     let wrapper: Wrapper;
     let drugType;
     let drugInTrial;
-    if (nodeType === 'host') {
+    if (nodeType === 'protein') {
       const protein = details as Protein;
       wrapper = getWrapperFromProtein(protein);
       nodeLabel = protein.name;
diff --git a/src/app/components/info-tile/info-tile.component.html b/src/app/components/info-tile/info-tile.component.html
index 26cbec22..9d64bd44 100644
--- a/src/app/components/info-tile/info-tile.component.html
+++ b/src/app/components/info-tile/info-tile.component.html
@@ -1,5 +1,5 @@
 <div *ngIf="wrapper">
-  <div *ngIf="wrapper.type === 'host'">
+  <div *ngIf="wrapper.type === 'protein'">
     <p>
       <b><span>Gene Name: </span></b>
       {{ wrapper.data.name }}
@@ -20,17 +20,6 @@
       {{ wrapper.data.expressionLevel|number }}
     </p>
   </div>
-  <div *ngIf="wrapper.type === 'virus'">
-    <p>
-      <b><span>Virus:</span></b>
-      {{ wrapper.data.virusName.replace('V', 'V-') }}
-      <span class="icon is-small"><i class="fas fa-virus"></i></span>
-    </p>
-    <p>
-      <b><span>Effect: </span></b>
-      {{ wrapper.data.effectName }}
-    </p>
-  </div>
   <div *ngIf="wrapper.type === 'drug'">
     <p>
       <b><span>Name: </span></b>
diff --git a/src/app/components/query-tile/query-tile.component.html b/src/app/components/query-tile/query-tile.component.html
index 93bdd628..b053d67c 100644
--- a/src/app/components/query-tile/query-tile.component.html
+++ b/src/app/components/query-tile/query-tile.component.html
@@ -2,11 +2,9 @@
   <ng-select [items]="queryItems" bindLabel="backendId" bindValue="data" [virtualScroll]="true" class="custom"
              placeholder="Search..." [hideSelected]="true" [searchFn]="querySearch" (change)="select($event)" data-tooltip="Find proteins in the network.">
     <ng-template ng-option-tmp let-item="item">
-      <b *ngIf="item.type == 'host'"> {{item.data.name}}</b>
-      <b *ngIf="item.type == 'virus'"> {{item.data.effectName}}</b> <br/>
-      <span><small *ngIf="item.type === 'virus'">Viral Protein</small><small *ngIf="item.type === 'host'">Host Protein</small> | </span>
-      <span *ngIf="item.type == 'host'"><small>AC: <b>{{item.data.proteinAc}}</b></small> </span>
-      <span *ngIf="item.type == 'virus'"><small><b>{{item.data.virusName.replace('V', 'V-')}}</b></small></span>
+      <b *ngIf="item.type == 'protein'"> {{item.data.name}}</b>
+      <span><small *ngIf="item.type === 'protein'">Host Protein</small> | </span>
+      <span *ngIf="item.type == 'protein'"><small>AC: <b>{{item.data.proteinAc}}</b></small> </span>
     </ng-template>
   </ng-select>
 </div>
diff --git a/src/app/dialogs/launch-analysis/launch-analysis.component.html b/src/app/dialogs/launch-analysis/launch-analysis.component.html
index 3fee026f..e2ec0268 100644
--- a/src/app/dialogs/launch-analysis/launch-analysis.component.html
+++ b/src/app/dialogs/launch-analysis/launch-analysis.component.html
@@ -13,13 +13,6 @@
       <button (click)="close()" class="delete" aria-label="close"></button>
     </header>
     <section class="modal-card-body">
-      <div *ngIf="target === 'drug' && hasBaits">
-        <div class="notification is-warning warning">
-          You have selected <i class="fa fa-virus"></i> viral proteins.
-          When finding drugs, make sure you have selected <i class="fa fa-dna"></i> host proteins only.
-        </div>
-      </div>
-
       <div *ngIf="!analysis.canLaunchTask()">
         <div class="notification is-warning warning">
           You can only run {{maxTasks}} tasks at once. Please wait for one of them to finish or delete it from the task
@@ -381,13 +374,6 @@
       </div>
 
       <div *ngIf="algorithm==='keypathwayminer'">
-        <div *ngIf="hasBaits">
-          <div class="notification is-warning warning">
-            You have selected <i class="fa fa-virus"></i> viral proteins.
-            If you want to use KeyPathwayMiner, please remove them because it cannot process them.
-          </div>
-        </div>
-
         <div class="field">
           <label class="label" for="keypathwayminer-k">Additional proteins</label>
           <div class="control">
@@ -511,7 +497,7 @@
     <footer class="modal-card-foot">
       <button (click)="startTask(); close()" class="button is-success is-rounded has-tooltip"
               data-tooltip="Run the analysis."
-              [disabled]="(target === 'drug' && hasBaits) || !analysis.canLaunchTask() || (algorithm === 'keypathwayminer' && hasBaits)">
+              [disabled]="!analysis.canLaunchTask()">
         <span class="icon">
           <i class="fa fa-rocket"></i>
         </span>
diff --git a/src/app/dialogs/launch-analysis/launch-analysis.component.ts b/src/app/dialogs/launch-analysis/launch-analysis.component.ts
index 077516b7..6e42901d 100644
--- a/src/app/dialogs/launch-analysis/launch-analysis.component.ts
+++ b/src/app/dialogs/launch-analysis/launch-analysis.component.ts
@@ -9,7 +9,6 @@ import {
   QuickAlgorithmType,
   TRUSTRANK
 } from '../../analysis.service';
-import {Dataset} from '../../interfaces';
 
 @Component({
   selector: 'app-launch-analysis',
@@ -74,15 +73,9 @@ export class LaunchAnalysisComponent implements OnInit, OnChanges {
   public multisteinerMaxDeg = 0;
   public multisteinerHubPenalty = 0.0;
 
-  public hasBaits;
-
   public maxTasks = MAX_TASKS;
 
   constructor(public analysis: AnalysisService) {
-    this.hasBaits = !!analysis.getSelection().find((i) => i.type === 'virus');
-    analysis.subscribeList(() => {
-      this.hasBaits = !!analysis.getSelection().find((i) => i.type === 'virus');
-    });
   }
 
   ngOnInit(): void {
diff --git a/src/app/interfaces.ts b/src/app/interfaces.ts
index 3e5bcc41..230bb223 100644
--- a/src/app/interfaces.ts
+++ b/src/app/interfaces.ts
@@ -92,7 +92,7 @@ export function getWrapperFromProtein(protein: Protein): Wrapper {
   return {
     backendId: getProteinBackendId(protein),
     nodeId: getProteinNodeId(protein),
-    type: 'host',
+    type: 'protein',
     data: protein,
   };
 }
@@ -106,7 +106,7 @@ export function getWrapperFromDrug(drug: Drug): Wrapper {
   };
 }
 
-export type WrapperType = 'host' | 'virus' | 'drug';
+export type WrapperType = 'protein' | 'drug';
 
 export interface Wrapper {
   backendId: string;
diff --git a/src/app/network-settings.ts b/src/app/network-settings.ts
index e74902c2..83a622c3 100644
--- a/src/app/network-settings.ts
+++ b/src/app/network-settings.ts
@@ -80,20 +80,16 @@ export class NetworkSettings {
   private static drugInTrialShape = 'triangle';
 
   static getNodeSize(wrapperType: WrapperType) {
-    if (wrapperType === 'host') {
+    if (wrapperType === 'protein') {
       return this.hostSize;
-    } else if (wrapperType === 'virus') {
-      return this.virusSize;
     } else if (wrapperType === 'drug') {
       return this.drugSize;
     }
   }
 
   static getNodeShape(wrapperType: WrapperType, drugInTrial?: boolean) {
-    if (wrapperType === 'host') {
+    if (wrapperType === 'protein') {
       return this.hostShape;
-    } else if (wrapperType === 'virus') {
-      return this.virusShape;
     } else if (wrapperType === 'drug') {
       if (drugInTrial) {
         return this.drugInTrialShape;
@@ -125,13 +121,11 @@ export class NetworkSettings {
     }
   }
 
-  static getColor(color: 'host' | 'virus' | 'approvedDrug' | 'unapprovedDrug' | 'hostFont' | 'virusFont' | 'drugFont' |
+  static getColor(color: 'protein' | 'approvedDrug' | 'unapprovedDrug' | 'hostFont' | 'virusFont' | 'drugFont' |
     'nonSeedHost' | 'nonSeedVirus' | 'selectedForAnalysis' | 'selectedForAnalysisText' |
     'edgeHostVirus' | 'edgeHostVirusHighlight' | 'edgeHostDrug' | 'edgeHostDrugHighlight') {
-    if (color === 'host') {
+    if (color === 'protein') {
       return this.hostColor;
-    } else if (color === 'virus') {
-      return this.virusColor;
     } else if (color === 'approvedDrug') {
       return this.approvedDrugColor;
     } else if (color === 'unapprovedDrug') {
@@ -158,10 +152,8 @@ export class NetworkSettings {
   }
 
   static getFont(wrapperType: WrapperType, drugInTrial?: boolean) {
-    if (wrapperType === 'host') {
+    if (wrapperType === 'protein') {
       return {color: this.hostFontColor, size: this.hostFontSize};
-    } else if (wrapperType === 'virus') {
-      return {color: this.virusFontColor, size: this.virusFontSize};
     } else if (wrapperType === 'drug') {
       if (!drugInTrial) {
         return {color: this.drugFontColor, size: this.drugFontSize};
@@ -188,20 +180,12 @@ export class NetworkSettings {
     nodeShape = NetworkSettings.getNodeShape(nodeType);
     nodeSize = NetworkSettings.getNodeSize(nodeType);
     nodeFont = NetworkSettings.getFont(nodeType);
-    if (nodeType === 'host') {
+    if (nodeType === 'protein') {
       nodeColor = NetworkSettings.getColor(nodeType);
-      nodeFont = NetworkSettings.getFont('host');
+      nodeFont = NetworkSettings.getFont('protein');
       if (!isSeed) {
         nodeColor = NetworkSettings.getColor('nonSeedHost');
       }
-    } else if (nodeType === 'virus') {
-      nodeColor = NetworkSettings.getColor(nodeType);
-      if (nodeType === 'virus') {
-        nodeFont = NetworkSettings.getFont('virus');
-        if (!isSeed) {
-          nodeColor = NetworkSettings.getColor('nonSeedVirus');
-        }
-      }
     } else if (nodeType === 'drug') {
       if (drugType === 'approved') {
         nodeColor = NetworkSettings.getColor('approvedDrug');
diff --git a/src/app/pages/explorer-page/explorer-page.component.html b/src/app/pages/explorer-page/explorer-page.component.html
index 7dd2fdc8..9130e3e1 100644
--- a/src/app/pages/explorer-page/explorer-page.component.html
+++ b/src/app/pages/explorer-page/explorer-page.component.html
@@ -171,15 +171,13 @@
         <p class="card-header-title">
           <span class="icon">
             <i *ngIf="!selectedWrapper" class="fas fa-info" aria-hidden="true"></i>
-            <i *ngIf="selectedWrapper && selectedWrapper.type === 'host'" class="fas fa-dna" aria-hidden="true"></i>
-            <i *ngIf="selectedWrapper && selectedWrapper.type === 'virus'" class="fas fa-virus" aria-hidden="true"></i>
+            <i *ngIf="selectedWrapper && selectedWrapper.type === 'protein'" class="fas fa-dna" aria-hidden="true"></i>
             <i *ngIf="selectedWrapper && selectedWrapper.type === 'drug'" class="fas fa-capsules"
                aria-hidden="true"></i>
           </span>
           <span *ngIf="!selectedWrapper">No item selected</span>
           <span *ngIf="selectedWrapper">
-            <span *ngIf="selectedWrapper.type === 'host'">Host Protein</span>
-            <span *ngIf="selectedWrapper.type === 'virus'">Viral Protein</span>
+            <span *ngIf="selectedWrapper.type === 'protein'">Host Protein</span>
             <span *ngIf="selectedWrapper.type === 'drug'">Drug</span>
           </span>
         </p>
@@ -408,12 +406,10 @@
             <tr *ngFor="let p of analysis.getSelection()">
               <td>
                  <span class="icon">
-                    <i class="fa fa-dna" *ngIf="p.type == 'host'"></i>
-                    <i class="fa fa-virus" *ngIf="p.type =='virus'"></i>
+                    <i class="fa fa-dna" *ngIf="p.type == 'protein'"></i>
                   </span>
               </td>
-              <td *ngIf="p.type == 'virus'">{{p.data.effectName}}</td>
-              <td *ngIf="p.type == 'host'">{{p.data.name}}</td>
+              <td *ngIf="p.type == 'protein'">{{p.data.name}}</td>
               <td>
                 <button (click)="analysis.removeItems([p])" class="button is-small is-danger is-outlined has-tooltip"
                         data-tooltip="Remove from selection.">
diff --git a/src/app/pages/explorer-page/explorer-page.component.ts b/src/app/pages/explorer-page/explorer-page.component.ts
index d42cf733..b8a20738 100644
--- a/src/app/pages/explorer-page/explorer-page.component.ts
+++ b/src/app/pages/explorer-page/explorer-page.component.ts
@@ -299,7 +299,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
 
   private mapHostProteinToNode(hostProtein: Protein): any {
     const wrapper = getWrapperFromProtein(hostProtein);
-    const node = NetworkSettings.getNodeStyle('host', true, this.analysis.inSelection(wrapper));
+    const node = NetworkSettings.getNodeStyle('protein', true, this.analysis.inSelection(wrapper));
     let nodeLabel = hostProtein.name;
     if (hostProtein.name.length === 0) {
       nodeLabel = hostProtein.proteinAc;
@@ -365,7 +365,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
 
   gProfilerLink(): string {
     const queryString = this.analysis.getSelection()
-      .filter(wrapper => wrapper.type === 'host')
+      .filter(wrapper => wrapper.type === 'protein')
       .map(wrapper => wrapper.data.proteinAc)
       .join('%0A');
     return 'http://biit.cs.ut.ee/gprofiler/gost?' +
-- 
GitLab