Skip to content

Commit

Permalink
Update bio page data structure (#1429)
Browse files Browse the repository at this point in the history
* Update bio page data structure

* lint
  • Loading branch information
shifucun authored Jan 31, 2022
1 parent 407c97f commit 47b7bbe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
8 changes: 4 additions & 4 deletions static/js/protein/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -30,7 +30,7 @@ interface PagePropType {
}

interface PageStateType {
data: GraphNode;
data: GraphNodes;
}

export class Page extends React.Component<PagePropType, PageStateType> {
Expand Down Expand Up @@ -76,14 +76,14 @@ export class Page extends React.Component<PagePropType, PageStateType> {
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") {
Expand Down
17 changes: 13 additions & 4 deletions static/js/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
}

0 comments on commit 47b7bbe

Please sign in to comment.