From 48c614a735a8b69ed579cf5418876b1096f610d5 Mon Sep 17 00:00:00 2001 From: Colin Megill Date: Thu, 2 Nov 2017 12:53:23 -0700 Subject: [PATCH] move expression counts func into util --- src/components/app.js | 32 +------------------------------- src/components/graph/util.js | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 31 deletions(-) create mode 100644 src/components/graph/util.js diff --git a/src/components/app.js b/src/components/app.js index c18cd873..584ab33c 100644 --- a/src/components/app.js +++ b/src/components/app.js @@ -41,32 +41,6 @@ class App extends React.Component { } - createExpressionsCountsMap () { - - const CHANGE_ME_MAGIC_GENE_INDEX = 5; - - const expressionsCountsMap = {}; - - /* currently selected gene */ - expressionsCountsMap.geneName = this.state.expressions.data.genes[3]; - - let maxExpressionValue = 0; - - /* create map of expressions for every cell */ - this.state.expressions.data.cells.map((c) => { - /* cellname = 234 */ - expressionsCountsMap[c.cellname] = c["e"][CHANGE_ME_MAGIC_GENE_INDEX]; - /* collect the maximum value as we iterate */ - if (c["e"][CHANGE_ME_MAGIC_GENE_INDEX] > maxExpressionValue) { - maxExpressionValue = c["e"][CHANGE_ME_MAGIC_GENE_INDEX] - } - }) - - expressionsCountsMap.maxValue = maxExpressionValue; - - return expressionsCountsMap; - } - render() { // console.log('app:', this.props, this.state) @@ -86,11 +60,7 @@ class App extends React.Component { {false ? : ""} - + ) } diff --git a/src/components/graph/util.js b/src/components/graph/util.js new file mode 100644 index 00000000..2415ebc1 --- /dev/null +++ b/src/components/graph/util.js @@ -0,0 +1,25 @@ +createExpressionsCountsMap () { + + const CHANGE_ME_MAGIC_GENE_INDEX = 5; + + const expressionsCountsMap = {}; + + /* currently selected gene */ + expressionsCountsMap.geneName = this.state.expressions.data.genes[3]; + + let maxExpressionValue = 0; + + /* create map of expressions for every cell */ + this.state.expressions.data.cells.map((c) => { + /* cellname = 234 */ + expressionsCountsMap[c.cellname] = c["e"][CHANGE_ME_MAGIC_GENE_INDEX]; + /* collect the maximum value as we iterate */ + if (c["e"][CHANGE_ME_MAGIC_GENE_INDEX] > maxExpressionValue) { + maxExpressionValue = c["e"][CHANGE_ME_MAGIC_GENE_INDEX] + } + }) + + expressionsCountsMap.maxValue = maxExpressionValue; + + return expressionsCountsMap; +}