Skip to content

Commit

Permalink
- checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
boriskovar-m2ms committed Apr 10, 2024
1 parent 13a315e commit 49f0ae8
Show file tree
Hide file tree
Showing 7 changed files with 343 additions and 66 deletions.
95 changes: 79 additions & 16 deletions js/components/datasets/datasetMoleculeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ import {
deleteDataset,
getTrackingActions,
moveDatasetMoleculeUpDown,
getAllVisibleButNotLockedCompounds
getAllVisibleButNotLockedCompounds,
getObservationForLHSReference,
getCurrentDatasetIterator,
resetDatasetIterator
} from './redux/dispatchActions';
import {
setAskLockCompoundsQuestion,
Expand All @@ -57,7 +60,8 @@ import {
appendCompoundColorOfDataset,
appendColorToAllCompoundsOfDataset,
removeCompoundColorOfDataset,
removeColorFromAllCompoundsOfDataset
removeColorFromAllCompoundsOfDataset,
setDatasetIterator
} from './redux/actions';
import { DatasetFilter } from './datasetFilter';
import { FilterList, Link, DeleteForever, ArrowUpward, ArrowDownward, Edit } from '@material-ui/icons';
Expand Down Expand Up @@ -637,6 +641,7 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
};

const onButtonToggle = (type, calledFromSelectAll = false) => {
resetIterator();
if (calledFromSelectAll === true && selectedAll.current === true) {
// REDO
if (eval('is' + ucfirst(type) + 'On') === false) {
Expand Down Expand Up @@ -784,6 +789,10 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
lockedMolecules.map(cid => ({ datasetID, molecule: getCompoundForId(cid) }))
);

const resetIterator = () => {
dispatch(resetDatasetIterator(datasetID));
};

// useEffectDebugger(
// () => {},
// [setSortDialogAnchorEl, loadNextMolecules, addMoleculeViewRef, setSelectedMoleculeRef, moveMolecule],
Expand Down Expand Up @@ -851,14 +860,36 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
// );

const getFirstItemForIterationStart = () => {
const firstItem = joinedMoleculeLists.find(
mol =>
(ligandList.includes(mol.id) ||
proteinList.includes(mol.id) ||
complexList.includes(mol.id) ||
surfaceList.includes(mol.id)) &&
!lockedMolecules.includes(mol.id)
);
let firstItem = dispatch(getCurrentDatasetIterator(datasetID));
if (!firstItem) {
firstItem = joinedMoleculeLists.find(mol => {
if (!mol.isCustomPdb) {
const obs = dispatch(getObservationForLHSReference(mol));
if (obs) {
return (
(ligandList.includes(mol.id) ||
proteinList.includes(obs.id) ||
complexList.includes(obs.id) ||
surfaceList.includes(obs.id)) &&
!lockedMolecules.includes(mol.id)
);
} else {
return false;
}
} else {
return (
(ligandList.includes(mol.id) ||
proteinListDataset.includes(mol.id) ||
complexListDataset.includes(mol.id) ||
surfaceListDataset.includes(mol.id)) &&
!lockedMolecules.includes(mol.id)
);
}
});
// if (firstItem) {
// dispatch(setDatasetIterator(datasetID, firstItem));
// }
}

return firstItem;
};
Expand Down Expand Up @@ -892,12 +923,28 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
const node = getNode(nextItem.id);
setScrollToMoleculeId(nextItem.id);

let firstItemIdToUse = firstItem.id;
let isCustomPdb = true;
if (!firstItem.isCustomPdb) {
isCustomPdb = false;
const obs = dispatch(getObservationForLHSReference(firstItem));
if (obs) {
firstItemIdToUse = obs.id;
}
}

let dataValue = {
colourToggle: getRandomColor(firstItem),
isLigandOn: ligandList.includes(firstItem.id),
isProteinOn: proteinList.includes(firstItem.id),
isComplexOn: complexList.includes(firstItem.id),
isSurfaceOn: surfaceList.includes(firstItem.id)
isProteinOn: isCustomPdb
? proteinListDataset.includes(firstItemIdToUse)
: proteinList.includes(firstItemIdToUse),
isComplexOn: isCustomPdb
? complexListDataset.includes(firstItemIdToUse)
: complexList.includes(firstItemIdToUse),
isSurfaceOn: isCustomPdb
? surfaceListDataset.includes(firstItemIdToUse)
: surfaceList.includes(firstItemIdToUse)
};

dispatch(setCrossReferenceCompoundName(moleculeTitleNext));
Expand Down Expand Up @@ -927,12 +974,28 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
const node = getNode(prevItem.id);
setScrollToMoleculeId(prevItem.id);

let firstItemIdToUse = firstItem.id;
let isCustomPdb = true;
if (!firstItem.isCustomPdb) {
isCustomPdb = false;
const obs = dispatch(getObservationForLHSReference(firstItem));
if (obs) {
firstItemIdToUse = obs.id;
}
}

let dataValue = {
colourToggle: getRandomColor(firstItem),
isLigandOn: ligandList.includes(firstItem.id),
isProteinOn: proteinList.includes(firstItem.id),
isComplexOn: complexList.includes(firstItem.id),
isSurfaceOn: surfaceList.includes(firstItem.id)
isProteinOn: isCustomPdb
? proteinListDataset.includes(firstItemIdToUse)
: proteinList.includes(firstItemIdToUse),
isComplexOn: isCustomPdb
? complexListDataset.includes(firstItemIdToUse)
: complexList.includes(firstItemIdToUse),
isSurfaceOn: isCustomPdb
? surfaceListDataset.includes(firstItemIdToUse)
: surfaceList.includes(firstItemIdToUse)
};

dispatch(setCrossReferenceCompoundName(moleculeTitlePrev));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ import {
isCompoundLocked,
getFirstUnlockedSelectedCompoundAfter,
moveSelectedDatasetMoleculeUpDown,
getFirstUnlockedSelectedCompoundBefore
getFirstUnlockedSelectedCompoundBefore,
resetSelectedCompoundIterator,
resetDatasetIterator
} from '../redux/dispatchActions';

import { isAnyInspirationTurnedOn, getFilteredDatasetMoleculeList } from '../redux/selectors';
Expand Down Expand Up @@ -504,6 +506,14 @@ const DatasetMoleculeView = memo(
const current_style =
isLigandOn || isProteinOn || isComplexOn || isSurfaceOn ? selected_style : not_selected_style;

const resetIterator = () => {
if (inSelectedCompoundsList) {
dispatch(resetSelectedCompoundIterator());
} else {
dispatch(resetDatasetIterator(datasetID));
}
};

const addNewLigand = (skipTracking = false) => {
dispatch(
withDisabledDatasetMoleculeNglControlButton(datasetID, currentID, 'ligand', () => {
Expand All @@ -522,6 +532,7 @@ const DatasetMoleculeView = memo(
const [loadingAll, setLoadingAll] = useState(false);
const [loadingLigand, setLoadingLigand] = useState(false);
const onLigand = calledFromSelectAll => {
resetIterator();
setLoadingLigand(true);
if (calledFromSelectAll === true && selectedAll.current === true) {
if (isLigandOn === false) {
Expand Down Expand Up @@ -566,6 +577,7 @@ const DatasetMoleculeView = memo(

const [loadingProtein, setLoadingProtein] = useState(false);
const onProtein = calledFromSelectAll => {
resetIterator();
setLoadingProtein(true);
if (calledFromSelectAll === true && selectedAll.current === true) {
if (isProteinOn === false) {
Expand Down Expand Up @@ -606,6 +618,7 @@ const DatasetMoleculeView = memo(

const [loadingComplex, setLoadingComplex] = useState(false);
const onComplex = calledFromSelectAll => {
resetIterator();
setLoadingComplex(true);
if (calledFromSelectAll === true && selectedAll.current === true) {
if (isComplexOn === false) {
Expand Down Expand Up @@ -646,6 +659,7 @@ const DatasetMoleculeView = memo(

const [loadingSurface, setLoadingSurface] = useState(false);
const onSurface = calledFromSelectAll => {
resetIterator();
setLoadingSurface(true);
if (calledFromSelectAll === true && selectedAll.current === true) {
if (isSurfaceOn === false) {
Expand Down
11 changes: 10 additions & 1 deletion js/components/datasets/redux/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ export const setFilterDialogOpen = filterDialogOpen => ({
payload: filterDialogOpen
});

export const setDatasetIterator = (datasetID, currentCmp) => ({
type: constants.SET_DATASET_ITERATOR,
payload: { datasetID, currentCmp }
});

export const setSelectedCompoundsIterator = (datasetID, currentCmp) => ({
type: constants.SET_SELECTED_COMPOUNDS_ITERATOR,
payload: { datasetID, currentCmp }
});

export const setLigandList = function(datsetID, ligandList) {
return {
type: constants.SET_LIGAND_LIST,
Expand Down Expand Up @@ -579,4 +589,3 @@ export const setUpdatedDatasets = updatedDataset => ({
type: constants.SET_UPDATED_DATASETS,
payload: { updatedDataset }
});

5 changes: 4 additions & 1 deletion js/components/datasets/redux/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ export const constants = {
SET_SELECT_ALL_BUTTON_FOR_DATASET: prefix + 'SET_SELECT_ALL_BUTTON_FOR_DATASET',

SET_COMPOUND_SET: prefix + 'SET_COMPOUND_SET',
SET_UPDATED_DATASETS: prefix + 'SET_UPDATED_DATASETS'
SET_UPDATED_DATASETS: prefix + 'SET_UPDATED_DATASETS',

SET_DATASET_ITERATOR: prefix + 'SET_DATASET_ITERATOR',
SET_SELECTED_COMPOUNDS_ITERATOR: prefix + 'SET_SELECTED_COMPOUNDS_ITERATOR'
};

export const COUNT_OF_VISIBLE_SCORES = 7;
Expand Down
Loading

0 comments on commit 49f0ae8

Please sign in to comment.