Skip to content

Commit

Permalink
- checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
boriskovar-m2ms committed Mar 25, 2024
1 parent abc8cc9 commit b1c0f3c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 7 deletions.
22 changes: 15 additions & 7 deletions js/components/datasets/datasetMoleculeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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([]);
Expand Down Expand Up @@ -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,
Expand Down
40 changes: 40 additions & 0 deletions js/components/datasets/redux/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
);

0 comments on commit b1c0f3c

Please sign in to comment.