Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snapshots refactor and mint incremental #464

Merged
merged 10 commits into from
Dec 6, 2024
5 changes: 1 addition & 4 deletions docker-compose.dev.vector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,11 @@ services:
OIDC_RP_CLIENT_SECRET: ${OIDC_RP_CLIENT_SECRET}
OIDC_RP_CLIENT_ID: 'fragalysis-local'
OIDC_RENEW_ID_TOKEN_EXPIRY_MINUTES: 210
ISPYB_HOST: ispybdbproxy.diamond.ac.uk
# ISPYB_HOST: ispybdbproxy.diamond.ac.uk
ISPYB_PORT: 4306
ISPYB_USER: ${ISPYB_USER}
ISPYB_PASSWORD: ${ISPYB_PASSWORD}
SECURITY_CONNECTOR: ssh_ispyb
SSH_HOST: ssh.diamond.ac.uk
SSH_USER: ${SSH_USER}
SSH_PASSWORD: ${SSH_PASSWORD}
LOGGING_FRAMEWORK_ROOT_LEVEL: DEBUG
AUTHENTICATE_UPLOAD: 'False'
CELERY_TASK_ALWAYS_EAGER: 'True'
Expand Down
6 changes: 3 additions & 3 deletions js/components/datasets/customDatasetList.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export const CustomDatasetList = memo(({ dataset, hideProjects, isActive }) => {
dispatch(clearDatasetSettings(dataset.id));
}
}
return () => {
dispatch(clearDatasetSettings(dataset?.id));
};
// return () => {
// dispatch(clearDatasetSettings(dataset?.id));
// };
}, [dataset, dispatch, isActive, isLoadingMoleculeList]);

const title = dataset && `${dataset.title} v.${dataset.version}`;
Expand Down
14 changes: 6 additions & 8 deletions js/components/datasets/datasetMoleculeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,6 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {

const searchString = useSelector(state => state.datasetsReducers.searchString);

const currentActionList = useSelector(state => state.trackingReducers.current_actions_list);

const isActiveFilter = !!(filterSettings || {}).active;
const { getNglView } = useContext(NglContext);

Expand Down Expand Up @@ -494,12 +492,12 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
const isSelectedTypeOn = (typeList, isLHSReference) => {
if (typeList) {
if (!isLHSReference) {
return typeList.some(molId => allMolecules.some(mol => mol.id === molId));
return typeList.some(molId => allMolecules?.some(mol => mol.id === molId));
} else {
const molsWithLHSReference = allMolecules.filter(mol => mol.site_observation_code);
const molsWithLHSReference = allMolecules?.filter(mol => mol.site_observation_code);
return typeList.some(molId =>
molsWithLHSReference.some(
mol => mol.site_observation_code === allMoleculesList.find(m => m.id === molId)?.code
mol => mol.site_observation_code === allMoleculesList?.find(m => m.id === molId)?.code
)
);
}
Expand Down Expand Up @@ -563,7 +561,7 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
);
} else {
if (molecule.site_observation_code) {
const lhsMol = allMoleculesList.find(mol => mol.code === molecule.site_observation_code);
const lhsMol = allMoleculesList?.find(mol => mol.code === molecule.site_observation_code);
if (lhsMol) {
dispatch(removeLHSType[type](stage, lhsMol, colourList[molecule.id % colourList.length], skipTracking));
}
Expand Down Expand Up @@ -597,7 +595,7 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
);
} else {
if (molecule.site_observation_code) {
const lhsMol = allMoleculesList.find(mol => mol.code === molecule.site_observation_code);
const lhsMol = allMoleculesList?.find(mol => mol.code === molecule.site_observation_code);
if (lhsMol) {
if (type === 'protein') {
promises.push(
Expand Down Expand Up @@ -1479,7 +1477,7 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
// #1249 dataset molecules currently could use side observation molecule for some renders
let idToFind = data.id;
if (data.site_observation_code) {
const molecule = allMoleculesList.find(mol => mol.code === data.site_observation_code);
const molecule = allMoleculesList?.find(mol => mol.code === data.site_observation_code);
if (molecule) {
idToFind = molecule.id;
}
Expand Down
5 changes: 3 additions & 2 deletions js/components/datasets/inspirationDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export const InspirationDialog = memo(
let rationale = '';
if (datasetID && inspirationLists.hasOwnProperty(datasetID) && inspirationLists[datasetID][0]) {
const moleculeID = inspirationLists[datasetID][0];
const molecule = moleculeLists[datasetID].find(molecule => molecule.id === moleculeID);
const molecule = moleculeLists[datasetID]?.find(molecule => molecule.id === moleculeID);
if (molecule !== undefined) {
rationale = molecule.text_scores.hasOwnProperty('rationale') ? molecule.text_scores.rationale : '';
}
Expand Down Expand Up @@ -194,7 +194,7 @@ export const InspirationDialog = memo(
}, [inspirationMoleculeDataList, searchString]);

const allSelectedMolecules = inspirationMoleculeDataList.filter(
molecule => moleculesToEditIds.includes(molecule.id) /* || molForTagEditId.some(mid => molecule.id === mid)*/
molecule => moleculesToEditIds.includes(molecule?.id) /* || molForTagEditId.some(mid => molecule.id === mid)*/
);

// TODO: refactor from this line (duplicity in datasetMoleculeList.js)
Expand Down Expand Up @@ -451,6 +451,7 @@ export const InspirationDialog = memo(
<div className={classes.content}>
{moleculeList.length > 0 &&
moleculeList.map((molecule, index, array) => {
if (!molecule) return <> </>;
let data = molecule;
data.isInspiration = true;
let previousData = index > 0 && Object.assign({ isInspiration: true }, array[index - 1]);
Expand Down
39 changes: 39 additions & 0 deletions js/components/datasets/redux/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,3 +623,42 @@ export const setUpdatedDatasets = updatedDataset => ({
type: constants.SET_UPDATED_DATASETS,
payload: { updatedDataset }
});

export const setToBeDisplayedListForDataset = (datasetID, toBeDisplayedList) => {
return {
type: constants.SET_TO_BE_DISPLAYED_LIST_DATASET,
toBeDisplayedList: toBeDisplayedList,
datasetID: datasetID
};
};

export const appendToBeDisplayedListForDataset = (datasetID, item) => {
return {
type: constants.APPEND_TO_BE_DISPLAYED_LIST_DATASET,
item: item,
datasetID: datasetID
};
};

export const removeFromToBeDisplayedListForDataset = (datasetID, item) => {
return {
type: constants.REMOVE_FROM_TO_BE_DISPLAYED_LIST_DATASET,
item: item,
datasetID: datasetID
};
};

export const updateInToBeDisplayedListForDataset = (datasetID, item) => {
return {
type: constants.UPDATE_IN_TO_BE_DISPLAYED_LIST_DATASET,
item: item,
datasetID: datasetID
};
};

export const setToBeDisplayedLists = toBeDisplayedLists => {
return {
type: constants.SET_TO_BE_DISPLAYED_LISTS,
toBeDisplayedLists: toBeDisplayedLists
};
};
8 changes: 7 additions & 1 deletion js/components/datasets/redux/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,13 @@ export const constants = {
SET_SELECTED_COMPOUNDS_ITERATOR: prefix + 'SET_SELECTED_COMPOUNDS_ITERATOR',

SET_INSPIRATION_DIALOG_ACTION: prefix + 'SET_INSPIRATION_DIALOG_ACTION',
SET_INSPIRATION_DIALOG_OPENED_FOR_SELECTED_COMPOUND: prefix + 'SET_INSPIRATION_DIALOG_OPENED_FOR_SELECTED_COMPOUND'
SET_INSPIRATION_DIALOG_OPENED_FOR_SELECTED_COMPOUND: prefix + 'SET_INSPIRATION_DIALOG_OPENED_FOR_SELECTED_COMPOUND',

SET_TO_BE_DISPLAYED_LIST_DATASET: prefix + 'SET_TO_BE_DISPLAYED_LIST_DATASET',
APPEND_TO_BE_DISPLAYED_LIST_DATASET: prefix + 'APPEND_TO_BE_DISPLAYED_LIST_DATASET',
REMOVE_FROM_TO_BE_DISPLAYED_LIST_DATASET: prefix + 'REMOVE_FROM_TO_BE_DISPLAYED_LIST_DATASET',
UPDATE_IN_TO_BE_DISPLAYED_LIST_DATASET: prefix + 'UPDATE_IN_TO_BE_DISPLAYED_LIST_DATASET',
SET_TO_BE_DISPLAYED_LISTS: prefix + 'SET_TO_BE_DISPLAYED_LISTS'
};

export const COUNT_OF_VISIBLE_SCORES = 7;
Expand Down
158 changes: 62 additions & 96 deletions js/components/datasets/redux/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ import {
removeDataset,
appendCompoundToSelectedCompoundsByDataset,
setDatasetIterator,
setSelectedCompoundsIterator
setSelectedCompoundsIterator,
appendToBeDisplayedListForDataset,
updateInToBeDisplayedListForDataset
} from './actions';
import { base_url } from '../../routes/constants';
import {
Expand Down Expand Up @@ -75,11 +77,10 @@ import {
} from '../../preview/molecule/redux/dispatchActions';
import { OBJECT_TYPE } from '../../nglView/constants';
import { getRepresentationsByType } from '../../nglView/generatingObjects';
import { selectAllMoleculeList } from '../../preview/molecule/redux/selectors';
import { getCompoundById } from '../../../reducers/tracking/dispatchActionsSwitchSnapshot';
import { getRandomColor } from '../../preview/molecule/utils/color';
import { BreakfastDiningOutlined } from '@mui/icons-material';
import { isCompoundFromVectorSelector } from '../../preview/compounds/redux/dispatchActions';
import { getCompoundById } from '../../../utils/genericDispatchActions';
import { NGL_OBJECTS } from '../../../reducers/ngl/constants';

export const initializeDatasetFilter = datasetID => (dispatch, getState) => {
const state = getState();
Expand All @@ -106,34 +107,26 @@ export const addDatasetHitProtein = (
skipTracking = false,
representations = undefined
) => async dispatch => {
dispatch(appendProteinList(datasetID, generateMoleculeCompoundId(data), skipTracking));
return dispatch(
loadObject({
target: Object.assign(
{ display_div: VIEWS.MAJOR_VIEW },
generateHitProteinObject(data, colourToggle, base_url, datasetID)
),
stage,
previousRepresentations: representations,
orientationMatrix: null
dispatch(
appendToBeDisplayedListForDataset(datasetID, {
type: NGL_OBJECTS.PROTEIN,
id: data.id,
display: true,
representations: representations,
datasetID: datasetID
})
).finally(() => {
const currentOrientation = stage.viewerControls.getOrientation();
dispatch(setOrientation(VIEWS.MAJOR_VIEW, currentOrientation));
});
);
};

export const removeDatasetHitProtein = (stage, data, colourToggle, datasetID, skipTracking = false) => dispatch => {
dispatch(
deleteObject(
Object.assign(
{ display_div: VIEWS.MAJOR_VIEW },
generateHitProteinObject(data, colourToggle, base_url, datasetID)
),
stage
)
updateInToBeDisplayedListForDataset(datasetID, {
id: data.id,
display: false,
type: NGL_OBJECTS.PROTEIN,
datasetID: datasetID
})
);
dispatch(removeFromProteinList(datasetID, generateMoleculeCompoundId(data), skipTracking));
};

export const addDatasetComplex = (
Expand All @@ -144,31 +137,26 @@ export const addDatasetComplex = (
skipTracking = false,
representations = undefined
) => async dispatch => {
dispatch(appendComplexList(datasetID, generateMoleculeCompoundId(data), skipTracking));
return dispatch(
loadObject({
target: Object.assign(
{ display_div: VIEWS.MAJOR_VIEW },
generateComplexObject(data, colourToggle, base_url, datasetID)
),
stage,
previousRepresentations: representations,
orientationMatrix: null
dispatch(
appendToBeDisplayedListForDataset(datasetID, {
type: NGL_OBJECTS.COMPLEX,
id: data.id,
display: true,
representations: representations,
datasetID: datasetID
})
).finally(() => {
const currentOrientation = stage.viewerControls.getOrientation();
dispatch(setOrientation(VIEWS.MAJOR_VIEW, currentOrientation));
});
);
};

export const removeDatasetComplex = (stage, data, colourToggle, datasetID, skipTracking = false) => dispatch => {
dispatch(
deleteObject(
Object.assign({ display_div: VIEWS.MAJOR_VIEW }, generateComplexObject(data, colourToggle, base_url, datasetID)),
stage
)
updateInToBeDisplayedListForDataset(datasetID, {
id: data.id,
display: false,
type: NGL_OBJECTS.COMPLEX,
datasetID: datasetID
})
);
dispatch(removeFromComplexList(datasetID, generateMoleculeCompoundId(data), skipTracking));
};

export const addDatasetSurface = (
Expand All @@ -178,31 +166,26 @@ export const addDatasetSurface = (
datasetID,
representations = undefined
) => async dispatch => {
dispatch(appendSurfaceList(datasetID, generateMoleculeCompoundId(data)));
return dispatch(
loadObject({
target: Object.assign(
{ display_div: VIEWS.MAJOR_VIEW },
generateSurfaceObject(data, colourToggle, base_url, datasetID)
),
stage,
previousRepresentations: representations,
orientationMatrix: null
dispatch(
appendToBeDisplayedListForDataset(datasetID, {
type: NGL_OBJECTS.SURFACE,
id: data.id,
display: true,
representations: representations,
datasetID: datasetID
})
).finally(() => {
const currentOrientation = stage.viewerControls.getOrientation();
dispatch(setOrientation(VIEWS.MAJOR_VIEW, currentOrientation));
});
);
};

export const removeDatasetSurface = (stage, data, colourToggle, datasetID) => dispatch => {
dispatch(
deleteObject(
Object.assign({ display_div: VIEWS.MAJOR_VIEW }, generateSurfaceObject(data, colourToggle, base_url, datasetID)),
stage
)
updateInToBeDisplayedListForDataset(datasetID, {
id: data.id,
display: false,
type: NGL_OBJECTS.SURFACE,
datasetID: datasetID
})
);
dispatch(removeFromSurfaceList(datasetID, generateMoleculeCompoundId(data)));
};

export const addDatasetLigand = (
Expand All @@ -213,43 +196,26 @@ export const addDatasetLigand = (
skipTracking = false,
representations = undefined
) => async (dispatch, getState) => {
dispatch(appendLigandList(datasetID, generateMoleculeCompoundId(data), skipTracking));
console.count(`Grabbed orientation before loading dataset ligand`);
const currentOrientation = stage.viewerControls.getOrientation();
return dispatch(
loadObject({
target: Object.assign({ display_div: VIEWS.MAJOR_VIEW }, generateMoleculeObject(data, colourToggle, datasetID)),
stage,
previousRepresentations: representations,
markAsRightSideLigand: true
dispatch(
appendToBeDisplayedListForDataset(datasetID, {
type: NGL_OBJECTS.LIGAND,
id: data.id,
display: true,
representations: representations,
datasetID: datasetID
})
).finally(() => {
const state = getState();
const skipOrientation = state.trackingReducers.skipOrientationChange;
if (!skipOrientation) {
const ligandOrientation = stage.viewerControls.getOrientation();
dispatch(setOrientation(VIEWS.MAJOR_VIEW, ligandOrientation));

dispatch(appendMoleculeOrientation(getDatasetMoleculeID(datasetID, data?.id), ligandOrientation));

// keep current orientation of NGL View
if (!skipOrientation) {
console.count(`Before applying orientation after loading dataset ligand.`);
stage.viewerControls.orient(currentOrientation);
console.count(`After applying orientation after loading dataset ligand.`);
}
}
});
);
};

export const removeDatasetLigand = (stage, data, colourToggle, datasetID, skipTracking = false) => dispatch => {
dispatch(
deleteObject(
Object.assign({ display_div: VIEWS.MAJOR_VIEW }, generateMoleculeObject(data, undefined, datasetID)),
stage
)
updateInToBeDisplayedListForDataset(datasetID, {
id: data.id,
display: false,
type: NGL_OBJECTS.LIGAND,
datasetID: datasetID
})
);
dispatch(removeFromLigandList(datasetID, generateMoleculeCompoundId(data), skipTracking));
};

export const loadDataSets = targetId => async dispatch => {
Expand Down Expand Up @@ -553,7 +519,7 @@ export const autoHideDatasetDialogsOnScroll = ({ inspirationDialogRef, crossRefe
const state = getState();
const isOpenInspirationDialog = state.datasetsReducers.isOpenInspirationDialog;
const isOpenCrossReferenceDialog = state.datasetsReducers.isOpenCrossReferenceDialog;
const isActionRestoring = state.trackingReducers.isActionRestoring;
const isActionRestoring = false; //state.trackingReducers.isActionRestoring;

const currentBoundingClientRectInspiration =
(inspirationDialogRef.current && inspirationDialogRef.current.getBoundingClientRect()) || null;
Expand Down
Loading