Skip to content

Commit 13a315e

Browse files
- checkpoint
1 parent a5b8cca commit 13a315e

File tree

2 files changed

+105
-28
lines changed

2 files changed

+105
-28
lines changed

js/components/datasets/datasetMoleculeList.js

+90-22
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ import {
8686
import { LockVisibleCompoundsDialog } from './lockVisibleCompoundsDialog';
8787
import { size } from 'lodash';
8888
import { Circle } from '@mui/icons-material';
89+
import {
90+
addComplex,
91+
addHitProtein,
92+
addSurface,
93+
removeComplex,
94+
removeHitProtein,
95+
removeSurface
96+
} from '../preview/molecule/redux/dispatchActions';
8997

9098
const useStyles = makeStyles(theme => ({
9199
container: {
@@ -433,10 +441,10 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
433441
const surfaceListDataset = useSelector(state => state.datasetsReducers.surfaceLists[datasetID]);
434442
// #1249 dataset molecules currently could use side observation molecule for some renders
435443

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);
444+
// const { proteinList, complexList, surfaceList } = useSelector(state => getLHSVisibleListsForRHS(state, datasetID));
445+
const proteinList = useSelector(state => state.selectionReducers.proteinList);
446+
const complexList = useSelector(state => state.selectionReducers.complexList);
447+
const surfaceList = useSelector(state => state.selectionReducers.surfaceList);
440448
const allMoleculesList = useSelector(state => state.apiReducers.all_mol_lists);
441449

442450
// const [selectedMolecules, setSelectedMolecules] = useState([]);
@@ -513,6 +521,20 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
513521
surface: removeDatasetSurface
514522
};
515523

524+
const addLHSType = {
525+
ligand: addDatasetLigand,
526+
protein: addHitProtein,
527+
complex: addComplex,
528+
surface: addSurface
529+
};
530+
531+
const removeLHSType = {
532+
ligand: removeDatasetLigand,
533+
protein: removeHitProtein,
534+
complex: removeComplex,
535+
surface: removeSurface
536+
};
537+
516538
// TODO: "currentMolecules" do not need to correspondent to selections in {type}List
517539
// TODO: so this could lead to inconsistend behaviour while scrolling
518540
// TODO: maybe change "currentMolecules.forEach" to "{type}List.forEach"
@@ -524,12 +546,24 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
524546
if ((type === 'protein' || type === 'complex') && !molecule.pdb_info) {
525547
continue;
526548
}
527-
dispatch(removeType[type](stage, molecule, colourList[molecule.id % colourList.length], datasetID, skipTracking));
549+
if (type === 'ligand') {
550+
dispatch(
551+
removeType[type](stage, molecule, colourList[molecule.id % colourList.length], datasetID, skipTracking)
552+
);
553+
} else {
554+
if (molecule.site_observation_code) {
555+
const lhsMol = allMoleculesList.find(mol => mol.code === molecule.site_observation_code);
556+
if (lhsMol) {
557+
dispatch(removeLHSType[type](stage, lhsMol, colourList[molecule.id % colourList.length], skipTracking));
558+
}
559+
} else if (molecule.isCustomPdb) {
560+
dispatch(
561+
removeType[type](stage, molecule, colourList[molecule.id % colourList.length], datasetID, skipTracking)
562+
);
563+
}
564+
}
528565
}
529-
// lockedMolecules.forEach(cid => {
530-
// let molecule = getCompoundForId(cid);
531-
// dispatch(removeType[type](stage, molecule, colourList[molecule.id % colourList.length], datasetID, skipTracking));
532-
// });
566+
533567
selectedAll.current = false;
534568
};
535569

@@ -544,20 +578,54 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
544578
if ((type === 'protein' || type === 'complex') && !molecule.pdb_info) {
545579
continue;
546580
}
547-
promises.push(
548-
dispatch(
549-
addType[type](stage, molecule, colourList[molecule.id % colourList.length], datasetID, skipTracking)
550-
)
551-
);
581+
if (type === 'ligand') {
582+
promises.push(
583+
dispatch(
584+
addType[type](stage, molecule, colourList[molecule.id % colourList.length], datasetID, skipTracking)
585+
)
586+
);
587+
} else {
588+
if (molecule.site_observation_code) {
589+
const lhsMol = allMoleculesList.find(mol => mol.code === molecule.site_observation_code);
590+
if (lhsMol) {
591+
if (type === 'protein') {
592+
promises.push(
593+
dispatch(
594+
addLHSType[type](
595+
stage,
596+
lhsMol,
597+
colourList[molecule.id % colourList.length],
598+
true,
599+
skipTracking,
600+
undefined,
601+
true
602+
)
603+
)
604+
);
605+
} else if (type === 'complex') {
606+
promises.push(
607+
dispatch(
608+
addLHSType[type](
609+
stage,
610+
lhsMol,
611+
colourList[molecule.id % colourList.length],
612+
skipTracking,
613+
undefined,
614+
true
615+
)
616+
)
617+
);
618+
}
619+
}
620+
} else if (molecule.isCustomPdb) {
621+
promises.push(
622+
dispatch(
623+
addType[type](stage, molecule, colourList[molecule.id % colourList.length], datasetID, skipTracking)
624+
)
625+
);
626+
}
627+
}
552628
}
553-
// lockedMolecules.forEach(cid => {
554-
// let molecule = getCompoundForId(cid);
555-
// promises.push(
556-
// dispatch(
557-
// addType[type](stage, molecule, colourList[molecule.id % colourList.length], datasetID, skipTracking)
558-
// )
559-
// );
560-
// });
561629

562630
await Promise.all(promises);
563631
})

js/components/datasets/datasetMoleculeView/datasetMoleculeView.js

+15-6
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,11 @@ const DatasetMoleculeView = memo(
544544
};
545545

546546
const removeSelectedProtein = (skipTracking = false) => {
547-
// dispatch(removeDatasetHitProtein(stage, data, colourToggle, datasetID, skipTracking));
548-
dispatch(removeHitProtein(stage, pdbData, colourToggle, skipTracking));
547+
if (data.isCustomPdb) {
548+
dispatch(removeDatasetHitProtein(stage, data, colourToggle, datasetID, skipTracking));
549+
} else {
550+
dispatch(removeHitProtein(stage, pdbData, colourToggle, skipTracking));
551+
}
549552
selectedAll.current = false;
550553
};
551554

@@ -581,8 +584,11 @@ const DatasetMoleculeView = memo(
581584
};
582585

583586
const removeSelectedComplex = (skipTracking = false) => {
584-
// dispatch(removeDatasetComplex(stage, data, colourToggle, datasetID, skipTracking));
585-
dispatch(removeComplex(stage, pdbData, colourToggle, skipTracking));
587+
if (data.isCustomPdb) {
588+
dispatch(removeDatasetComplex(stage, data, colourToggle, datasetID, skipTracking));
589+
} else {
590+
dispatch(removeComplex(stage, pdbData, colourToggle, skipTracking));
591+
}
586592
selectedAll.current = false;
587593
};
588594

@@ -618,8 +624,11 @@ const DatasetMoleculeView = memo(
618624
};
619625

620626
const removeSelectedSurface = () => {
621-
// dispatch(removeDatasetSurface(stage, data, colourToggle, datasetID));
622-
dispatch(removeSurface(stage, pdbData, colourToggle));
627+
if (data.isCustomPdb) {
628+
dispatch(removeDatasetSurface(stage, data, colourToggle, datasetID));
629+
} else {
630+
dispatch(removeSurface(stage, pdbData, colourToggle));
631+
}
623632
selectedAll.current = false;
624633
};
625634

0 commit comments

Comments
 (0)