From 47b7bbe0c057b3b6f3c4f44204ce9f7e7c1e7775 Mon Sep 17 00:00:00 2001 From: Bo Xu Date: Mon, 31 Jan 2022 11:18:46 -0800 Subject: [PATCH] Update bio page data structure (#1429) * Update bio page data structure * lint --- static/js/protein/page.tsx | 8 ++++---- static/js/shared/types.ts | 17 +++++++++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/static/js/protein/page.tsx b/static/js/protein/page.tsx index def351f538..11cdf8d17f 100644 --- a/static/js/protein/page.tsx +++ b/static/js/protein/page.tsx @@ -21,7 +21,7 @@ import axios from "axios"; import React from "react"; -import { GraphNode } from "../shared/types"; +import { GraphNodes } from "../shared/types"; import { drawTissueScoreChart } from "./chart"; interface PagePropType { @@ -30,7 +30,7 @@ interface PagePropType { } interface PageStateType { - data: GraphNode; + data: GraphNodes; } export class Page extends React.Component { @@ -76,14 +76,14 @@ export class Page extends React.Component { return {}; } const result = {}; - for (const neighbour of this.state.data.neighbours) { + for (const neighbour of this.state.data.nodes[0].neighbors) { if (neighbour.property !== "detectedProtein") { continue; } for (const node of neighbour.nodes) { let tissue = null; let score = null; - for (const n of node.neighbours) { + for (const n of node.neighbors) { if (n.property === "humanTissue") { tissue = n.nodes[0].value; } else if (n.property === "proteinExpressionScore") { diff --git a/static/js/shared/types.ts b/static/js/shared/types.ts index dfa1a9c543..b79978565d 100644 --- a/static/js/shared/types.ts +++ b/static/js/shared/types.ts @@ -130,10 +130,19 @@ export interface StatVarSummary { provenanceSummary?: { [provId: string]: ProvenanceSummary }; } +// One node in a Graph. export interface GraphNode { + neighbors: LinkedNodes[]; value: string; - neighbours: { - property: string; - nodes: GraphNode[]; - }[]; +} + +// Linked nodes for a Graph +export interface LinkedNodes { + property: string; + direction: number; + nodes: GraphNode[]; +} + +export interface GraphNodes { + nodes: GraphNode[]; }