Skip to content

Commit b1c0f3c

Browse files
- checkpoint
1 parent abc8cc9 commit b1c0f3c

File tree

2 files changed

+55
-7
lines changed

2 files changed

+55
-7
lines changed

js/components/datasets/datasetMoleculeList.js

+15-7
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ import {
6161
} from './redux/actions';
6262
import { DatasetFilter } from './datasetFilter';
6363
import { FilterList, Link, DeleteForever, ArrowUpward, ArrowDownward, Edit } from '@material-ui/icons';
64-
import { getJoinedMoleculeLists } from './redux/selectors';
64+
import { getJoinedMoleculeLists, getLHSVisibleListsForRHS } from './redux/selectors';
6565
import { InspirationDialog } from './inspirationDialog';
6666
import { CrossReferenceDialog } from './crossReferenceDialog';
6767
import { AlertModal } from '../common/Modal/AlertModal';
@@ -432,9 +432,11 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
432432
const complexListDataset = useSelector(state => state.datasetsReducers.complexLists[datasetID]);
433433
const surfaceListDataset = useSelector(state => state.datasetsReducers.surfaceLists[datasetID]);
434434
// #1249 dataset molecules currently could use side observation molecule for some renders
435-
const proteinList = useSelector(state => state.selectionReducers.proteinList);
436-
const complexList = useSelector(state => state.selectionReducers.complexList);
437-
const surfaceList = useSelector(state => state.selectionReducers.surfaceList);
435+
436+
const { proteinList, complexList, surfaceList } = useSelector(state => getLHSVisibleListsForRHS(state, datasetID));
437+
// const proteinList = useSelector(state => state.selectionReducers.proteinList);
438+
// const complexList = useSelector(state => state.selectionReducers.complexList);
439+
// const surfaceList = useSelector(state => state.selectionReducers.surfaceList);
438440
const allMoleculesList = useSelector(state => state.apiReducers.all_mol_lists);
439441

440442
// const [selectedMolecules, setSelectedMolecules] = useState([]);
@@ -485,11 +487,17 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
485487
};
486488

487489
let isLigandOn = isSelectedTypeOn(ligandList);
488-
let isProteinOn = isSelectedTypeOn(proteinList);
489-
let isComplexOn = isSelectedTypeOn(complexList);
490+
let isProteinOn = isSelectedTypeOn(proteinList) || isSelectedTypeOn(proteinListDataset);
491+
let isComplexOn = isSelectedTypeOn(complexList) || isSelectedTypeOn(complexListDataset);
490492

491493
let areArrowsVisible =
492-
isTypeOn(ligandList) || isTypeOn(proteinList) || isTypeOn(complexList) || isTypeOn(surfaceList);
494+
isTypeOn(ligandList) ||
495+
isTypeOn(proteinList) ||
496+
isTypeOn(complexList) ||
497+
isTypeOn(surfaceList) ||
498+
isTypeOn(proteinListDataset) ||
499+
isTypeOn(complexListDataset) ||
500+
isTypeOn(surfaceListDataset);
493501

494502
const addType = {
495503
ligand: addDatasetLigand,

js/components/datasets/redux/selectors.js

+40
Original file line numberDiff line numberDiff line change
@@ -478,3 +478,43 @@ export const getJoinedMoleculeLists = (datasetID, state) => {
478478

479479
return moleculeList;
480480
};
481+
482+
export const getLHSVisibleListsForRHS = createSelector(
483+
(_, datasetID) => datasetID,
484+
moleculeLists,
485+
proteinList,
486+
complexList,
487+
surfaceList,
488+
(datasetID, molecules, proteins, complexes, surfaces) => {
489+
const result = { proteinList: [], complexList: [], surfaceList: [] };
490+
491+
const rhsCompoundsWithLHSReference = {};
492+
const moleculesOfDataset = molecules[datasetID] || [];
493+
494+
moleculesOfDataset.forEach(molecule => {
495+
if (molecule.site_observation_code) {
496+
rhsCompoundsWithLHSReference[molecule.id] = molecule;
497+
}
498+
});
499+
500+
proteins.forEach(id => {
501+
if (rhsCompoundsWithLHSReference[id]) {
502+
result.proteinList.push(rhsCompoundsWithLHSReference[id].id);
503+
}
504+
});
505+
506+
complexes.forEach(id => {
507+
if (rhsCompoundsWithLHSReference[id]) {
508+
result.complexList.push(rhsCompoundsWithLHSReference[id].id);
509+
}
510+
});
511+
512+
surfaces.forEach(id => {
513+
if (rhsCompoundsWithLHSReference[id]) {
514+
result.surfaceList.push(rhsCompoundsWithLHSReference[id].id);
515+
}
516+
});
517+
518+
return result;
519+
}
520+
);

0 commit comments

Comments
 (0)