From 53041a7d7c6a71186534d17a2670b5615cb661a5 Mon Sep 17 00:00:00 2001 From: Drew Diamantoukos Date: Tue, 20 Nov 2018 11:47:16 -0500 Subject: [PATCH] Added fallback for gene colors --- .gitignore | 6 +++--- src/main.js | 30 ++++++++++++++++++------------ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 46f6919..3aa4596 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ node_modules -dist -lib -datasets + +datasets/**/*.npz +*.hdf5 yarn-error.log .DS_STORE \ No newline at end of file diff --git a/src/main.js b/src/main.js index 9e46d51..7220a04 100644 --- a/src/main.js +++ b/src/main.js @@ -15,6 +15,7 @@ import SmoothingImputation from './smoothing_imputation.js'; import StickyNote from './stickyNote.js'; import { colorpicker_setup } from './colorpicker_layout.js'; +import { getData } from './file_helper'; import { settings_setup, collapse_settings } from './settings_script.js'; import { postMessageToParent } from './util.js'; @@ -126,14 +127,19 @@ const loadData = async () => { }; const getColorBarFromAjax = async args => { - const python_data = await $.ajax({ - data: { base_dir: graph_directory }, - type: 'POST', - url: 'cgi-bin/load_counts.py', - }); - - const result = await ColorBar.create(python_data); - return result; + try { + const python_data = await $.ajax({ + data: { base_dir: graph_directory }, + type: 'POST', + url: 'cgi-bin/load_counts.py', + }); + const result = await ColorBar.create(python_data); + return result; + } catch (e) { + const geneData = await getData('genes', 'txt'); + const result = await ColorBar.create(geneData); + return result; + } }; loadData() @@ -225,7 +231,7 @@ const setupUserInterface = async () => { }); }; -const setCategorySelection = (categories) => { +const setCategorySelection = categories => { if (categories) { const cat_label_list = colorBar.categorical_coloring_data.Sample.label_list; for (let i = 0; i < forceLayout.all_nodes.length; i++) { @@ -239,9 +245,9 @@ const setCategorySelection = (categories) => { } } } -} +}; -const setIndexSelection = (indices) => { +const setIndexSelection = indices => { if (indices) { for (let i = 0; i < forceLayout.all_outlines.length; i++) { forceLayout.all_outlines[i].selected = false; @@ -253,4 +259,4 @@ const setIndexSelection = (indices) => { forceLayout.all_outlines[coordinateIndex].alpha = forceLayout.all_nodes[coordinateIndex].alpha; } } -} +};