From 12139a7543e0eecf17a6890ea7856077e5d5a686 Mon Sep 17 00:00:00 2001 From: Tibor Postek Date: Wed, 19 Feb 2020 09:22:11 +0100 Subject: [PATCH] #48 fix count of compounds --- js/components/preview/molecule/moleculeView.js | 4 +++- .../preview/molecule/molecules_helpers.js | 18 ++++++------------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/js/components/preview/molecule/moleculeView.js b/js/components/preview/molecule/moleculeView.js index de460b2cf..e3290b712 100644 --- a/js/components/preview/molecule/moleculeView.js +++ b/js/components/preview/molecule/moleculeView.js @@ -195,8 +195,10 @@ const MoleculeView = memo( }), api({ url: `${base_url}/api/vector/${data.id}` }).then(response => { const vectors = response.data.vectors['3d']; - setCmpds(getTotalCountOfCompounds(response.data.vectors)); setCountOfVectors(generateObjectList(vectors).length); + }), + api({ url: `${base_url}/api/graph/${data.id}` }).then(response => { + setCmpds(getTotalCountOfCompounds(response.data.graph)); }) ]).catch(error => { setState(() => { diff --git a/js/components/preview/molecule/molecules_helpers.js b/js/components/preview/molecule/molecules_helpers.js index 6234ac487..e23173933 100644 --- a/js/components/preview/molecule/molecules_helpers.js +++ b/js/components/preview/molecule/molecules_helpers.js @@ -1,5 +1,4 @@ import { OBJECT_TYPE } from '../../nglView/constants'; -import { isEmpty } from 'lodash'; export const generateMolecule = (id, sdf_info) => { return { @@ -45,18 +44,13 @@ export const generateSphere = (data, selected = false) => { }; }; -export const getTotalCountOfCompounds = vectors => { +export const getTotalCountOfCompounds = graph => { let tot_num = 0; - /* TODO Add algorithm for computing count of toto count of compounds - for (var key_to_select in state.to_select) { - if (key_to_select.split('_')[0] === input_mol_key) { - new_this_vector_list[key_to_select] = state.to_select[key_to_select]; - } - } - - Object.keys(vectors).forEach(key => { - tot_num += !isEmpty(vectors[key].addition) || vectors[key].addition ? Object.keys(vectors[key].addition).length : 0; - }); */ + if (graph) { + Object.keys(graph).forEach(key => { + tot_num += graph[key].addition ? Object.keys(graph[key].addition).length : 0; + }); + } return tot_num; };