Skip to content

Commit

Permalink
Merge pull request #219 from m2ms/#451
Browse files Browse the repository at this point in the history
#451 Compounds are not displayed for a vector
  • Loading branch information
boriskovar-m2ms authored Nov 11, 2020
2 parents aee00b7 + 95701a3 commit 245c8f6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
5 changes: 2 additions & 3 deletions js/components/preview/molecule/redux/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ import { setCompoundImage } from '../../summary/redux/actions';
import { noCompoundImage } from '../../summary/redux/reducer';
import { getMoleculeOfCurrentVector } from '../../../../reducers/selection/selectors';
import { resetCurrentCompoundsSettings } from '../../compounds/redux/actions';
import {selectMoleculeGroup} from '../../moleculeGroups/redux/dispatchActions';
import {setDirectAccess, setDirectAccessProcessed} from '../../../../reducers/api/actions';
import { selectMoleculeGroup } from '../../moleculeGroups/redux/dispatchActions';
import { setDirectAccess, setDirectAccessProcessed } from '../../../../reducers/api/actions';

/**
* Convert the JSON into a list of arrow objects
Expand Down Expand Up @@ -442,5 +442,4 @@ export const applyDirectSelection = (stage, stageSummaryView) => (dispatch, getS
// dispatch(setDirectAccess({}));
dispatch(setDirectAccessProcessed(true));
}

};
1 change: 1 addition & 0 deletions js/reducers/api/selectors.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const getMoleculeList = state => state.apiReducers.molecule_list;
export const getAllMoleculeList = state => state.apiReducers.all_mol_lists;
12 changes: 7 additions & 5 deletions js/reducers/selection/selectors.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createSelector } from 'reselect';
import { getMoleculeList } from '../api/selectors';
import { getAllMoleculeList } from '../api/selectors';

const getCurrentCompoundClass = state => state.previewReducers.compounds.currentCompoundClass;
const getVectorList = state => state.selectionReducers.vector_list;
Expand All @@ -10,14 +10,16 @@ const getCompoundsOfVectors = state => state.selectionReducers.compoundsOfVector
export const getMoleculeOfCurrentVector = createSelector(
getCurrentVector,
getVectorList,
getMoleculeList,
getAllMoleculeList,
(selectedVectorSmile, vectorList, moleculeList) => {
if (selectedVectorSmile !== null && vectorList && moleculeList) {
const foundedVector = vectorList.find(vector => vector.name.includes(selectedVectorSmile));
if (foundedVector) {
for (const molecule in moleculeList) {
if (moleculeList.hasOwnProperty(molecule)) {
if (molecule.id === foundedVector.moleculeId) {
for (const moleculeProperty in moleculeList) {
if (moleculeList.hasOwnProperty(moleculeProperty)) {
let molecules = moleculeList[moleculeProperty];
let molecule = molecules.find(m => m.id === foundedVector.moleculeId);
if (molecule) {
return molecule;
}
}
Expand Down

0 comments on commit 245c8f6

Please sign in to comment.