@@ -86,6 +86,14 @@ import {
86
86
import { LockVisibleCompoundsDialog } from './lockVisibleCompoundsDialog' ;
87
87
import { size } from 'lodash' ;
88
88
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' ;
89
97
90
98
const useStyles = makeStyles ( theme => ( {
91
99
container : {
@@ -433,10 +441,10 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
433
441
const surfaceListDataset = useSelector ( state => state . datasetsReducers . surfaceLists [ datasetID ] ) ;
434
442
// #1249 dataset molecules currently could use side observation molecule for some renders
435
443
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 ) ;
440
448
const allMoleculesList = useSelector ( state => state . apiReducers . all_mol_lists ) ;
441
449
442
450
// const [selectedMolecules, setSelectedMolecules] = useState([]);
@@ -513,6 +521,20 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
513
521
surface : removeDatasetSurface
514
522
} ;
515
523
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
+
516
538
// TODO: "currentMolecules" do not need to correspondent to selections in {type}List
517
539
// TODO: so this could lead to inconsistend behaviour while scrolling
518
540
// TODO: maybe change "currentMolecules.forEach" to "{type}List.forEach"
@@ -524,12 +546,24 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
524
546
if ( ( type === 'protein' || type === 'complex' ) && ! molecule . pdb_info ) {
525
547
continue ;
526
548
}
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
+ }
528
565
}
529
- // lockedMolecules.forEach(cid => {
530
- // let molecule = getCompoundForId(cid);
531
- // dispatch(removeType[type](stage, molecule, colourList[molecule.id % colourList.length], datasetID, skipTracking));
532
- // });
566
+
533
567
selectedAll . current = false ;
534
568
} ;
535
569
@@ -544,20 +578,54 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
544
578
if ( ( type === 'protein' || type === 'complex' ) && ! molecule . pdb_info ) {
545
579
continue ;
546
580
}
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
+ }
552
628
}
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
- // });
561
629
562
630
await Promise . all ( promises ) ;
563
631
} )
0 commit comments