From e2e46cb4c68a8c2a2a92a720de978a8935813815 Mon Sep 17 00:00:00 2001 From: Boris Kovar Date: Thu, 29 Feb 2024 10:32:27 +0100 Subject: [PATCH] - checkpoint --- js/components/datasets/datasetMoleculeList.js | 22 ++++++---- js/components/datasets/redux/selectors.js | 40 +++++++++++++++++++ 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/js/components/datasets/datasetMoleculeList.js b/js/components/datasets/datasetMoleculeList.js index d62441614..be9ebc830 100644 --- a/js/components/datasets/datasetMoleculeList.js +++ b/js/components/datasets/datasetMoleculeList.js @@ -61,7 +61,7 @@ import { } from './redux/actions'; import { DatasetFilter } from './datasetFilter'; import { FilterList, Link, DeleteForever, ArrowUpward, ArrowDownward, Edit } from '@material-ui/icons'; -import { getJoinedMoleculeLists } from './redux/selectors'; +import { getJoinedMoleculeLists, getLHSVisibleListsForRHS } from './redux/selectors'; import { InspirationDialog } from './inspirationDialog'; import { CrossReferenceDialog } from './crossReferenceDialog'; import { AlertModal } from '../common/Modal/AlertModal'; @@ -432,9 +432,11 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => { const complexListDataset = useSelector(state => state.datasetsReducers.complexLists[datasetID]); const surfaceListDataset = useSelector(state => state.datasetsReducers.surfaceLists[datasetID]); // #1249 dataset molecules currently could use side observation molecule for some renders - const proteinList = useSelector(state => state.selectionReducers.proteinList); - const complexList = useSelector(state => state.selectionReducers.complexList); - const surfaceList = useSelector(state => state.selectionReducers.surfaceList); + + const { proteinList, complexList, surfaceList } = useSelector(state => getLHSVisibleListsForRHS(state, datasetID)); + // const proteinList = useSelector(state => state.selectionReducers.proteinList); + // const complexList = useSelector(state => state.selectionReducers.complexList); + // const surfaceList = useSelector(state => state.selectionReducers.surfaceList); const allMoleculesList = useSelector(state => state.apiReducers.all_mol_lists); // const [selectedMolecules, setSelectedMolecules] = useState([]); @@ -485,11 +487,17 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => { }; let isLigandOn = isSelectedTypeOn(ligandList); - let isProteinOn = isSelectedTypeOn(proteinList); - let isComplexOn = isSelectedTypeOn(complexList); + let isProteinOn = isSelectedTypeOn(proteinList) || isSelectedTypeOn(proteinListDataset); + let isComplexOn = isSelectedTypeOn(complexList) || isSelectedTypeOn(complexListDataset); let areArrowsVisible = - isTypeOn(ligandList) || isTypeOn(proteinList) || isTypeOn(complexList) || isTypeOn(surfaceList); + isTypeOn(ligandList) || + isTypeOn(proteinList) || + isTypeOn(complexList) || + isTypeOn(surfaceList) || + isTypeOn(proteinListDataset) || + isTypeOn(complexListDataset) || + isTypeOn(surfaceListDataset); const addType = { ligand: addDatasetLigand, diff --git a/js/components/datasets/redux/selectors.js b/js/components/datasets/redux/selectors.js index 4c33776eb..323839bf0 100644 --- a/js/components/datasets/redux/selectors.js +++ b/js/components/datasets/redux/selectors.js @@ -478,3 +478,43 @@ export const getJoinedMoleculeLists = (datasetID, state) => { return moleculeList; }; + +export const getLHSVisibleListsForRHS = createSelector( + (_, datasetID) => datasetID, + moleculeLists, + proteinList, + complexList, + surfaceList, + (datasetID, molecules, proteins, complexes, surfaces) => { + const result = { proteinList: [], complexList: [], surfaceList: [] }; + + const rhsCompoundsWithLHSReference = {}; + const moleculesOfDataset = molecules[datasetID] || []; + + moleculesOfDataset.forEach(molecule => { + if (molecule.site_observation_code) { + rhsCompoundsWithLHSReference[molecule.id] = molecule; + } + }); + + proteins.forEach(id => { + if (rhsCompoundsWithLHSReference[id]) { + result.proteinList.push(rhsCompoundsWithLHSReference[id].id); + } + }); + + complexes.forEach(id => { + if (rhsCompoundsWithLHSReference[id]) { + result.complexList.push(rhsCompoundsWithLHSReference[id].id); + } + }); + + surfaces.forEach(id => { + if (rhsCompoundsWithLHSReference[id]) { + result.surfaceList.push(rhsCompoundsWithLHSReference[id].id); + } + }); + + return result; + } +);