Skip to content

Commit

Permalink
#48 fix count of compounds
Browse files Browse the repository at this point in the history
  • Loading branch information
tibor-postek-m2ms committed Mar 2, 2020
1 parent 3da0e7f commit 12139a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
4 changes: 3 additions & 1 deletion js/components/preview/molecule/moleculeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
18 changes: 6 additions & 12 deletions js/components/preview/molecule/molecules_helpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { OBJECT_TYPE } from '../../nglView/constants';
import { isEmpty } from 'lodash';

export const generateMolecule = (id, sdf_info) => {
return {
Expand Down Expand Up @@ -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;
};

0 comments on commit 12139a7

Please sign in to comment.