+
{
+ e.preventDefault();
+ setNameCopied(moleculeTitle);
+ }}
+ >
{moleculeTitle}
diff --git a/js/components/datasets/lockVisibleCompoundsDialog.js b/js/components/datasets/lockVisibleCompoundsDialog.js
index af986d62e..d13f50724 100644
--- a/js/components/datasets/lockVisibleCompoundsDialog.js
+++ b/js/components/datasets/lockVisibleCompoundsDialog.js
@@ -44,27 +44,27 @@ export const LockVisibleCompoundsDialog = forwardRef(
if (currentCmp) {
let cmpsToLock = dispatch(getAllVisibleButNotLockedCompounds(datasetId));
if (cmpsToLock && cmpsToLock.length > 0) {
- dispatch(lockCompounds(datasetId, cmpsToLock, currentCmp.id));
+ dispatch(lockCompounds(datasetId, cmpsToLock, currentCmp));
}
} else {
let cmpsToLock = dispatch(getAllVisibleButNotLockedCompounds(datasetId));
//we need to skip first element if we came here from global arrows
if (cmpsToLock && cmpsToLock.length > 0) {
- const firstCmpId = cmpsToLock[0];
- dispatch(lockCompounds(datasetId, cmpsToLock, firstCmpId));
+ const firstCmp = cmpsToLock[0];
+ dispatch(lockCompounds(datasetId, cmpsToLock, firstCmp));
}
}
} else {
if (currentCmp) {
let cmpsToLock = dispatch(getAllVisibleButNotLockedSelectedCompounds());
if (cmpsToLock && cmpsToLock.length > 0) {
- dispatch(lockSelectedCompounds(cmpsToLock, currentCmp.id));
+ dispatch(lockSelectedCompounds(cmpsToLock, { datasetID: currentCmp.computed_set, molecule: currentCmp }));
}
} else {
let cmpsToLock = dispatch(getAllVisibleButNotLockedSelectedCompounds());
if (cmpsToLock && cmpsToLock.length > 0) {
- const firstCmpId = cmpsToLock[0];
- dispatch(lockSelectedCompounds(cmpsToLock, firstCmpId));
+ const firstCmp = cmpsToLock[0];
+ dispatch(lockSelectedCompounds(cmpsToLock, firstCmp));
}
}
}
diff --git a/js/components/datasets/redux/actions.js b/js/components/datasets/redux/actions.js
index c172a9860..715bde06f 100644
--- a/js/components/datasets/redux/actions.js
+++ b/js/components/datasets/redux/actions.js
@@ -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, molecule) => ({
+ type: constants.SET_SELECTED_COMPOUNDS_ITERATOR,
+ payload: { datasetID, molecule }
+});
+
export const setLigandList = function(datsetID, ligandList) {
return {
type: constants.SET_LIGAND_LIST,
@@ -579,4 +589,3 @@ export const setUpdatedDatasets = updatedDataset => ({
type: constants.SET_UPDATED_DATASETS,
payload: { updatedDataset }
});
-
diff --git a/js/components/datasets/redux/constants.js b/js/components/datasets/redux/constants.js
index 99e1aab10..1fdfcbd64 100644
--- a/js/components/datasets/redux/constants.js
+++ b/js/components/datasets/redux/constants.js
@@ -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;
diff --git a/js/components/datasets/redux/dispatchActions.js b/js/components/datasets/redux/dispatchActions.js
index fa9135242..6e6aaf515 100644
--- a/js/components/datasets/redux/dispatchActions.js
+++ b/js/components/datasets/redux/dispatchActions.js
@@ -35,7 +35,9 @@ import {
enableDatasetMoleculeNglControlButton,
setArrowUpDown,
removeDataset,
- appendCompoundToSelectedCompoundsByDataset
+ appendCompoundToSelectedCompoundsByDataset,
+ setDatasetIterator,
+ setSelectedCompoundsIterator
} from './actions';
import { base_url } from '../../routes/constants';
import {
@@ -66,7 +68,10 @@ import {
addLigand,
addDensity,
addDensityCustomView,
- hideAllSelectedMolecules
+ hideAllSelectedMolecules,
+ removeHitProtein,
+ removeComplex,
+ removeSurface
} from '../../preview/molecule/redux/dispatchActions';
import { OBJECT_TYPE } from '../../nglView/constants';
import { getRepresentationsByType } from '../../nglView/generatingObjects';
@@ -299,10 +304,18 @@ export const loadDatasetCompoundsWithScores = (datasetsToLoad = null) => (dispat
// -----> add 'site_observation_code' to molecules whereas '/compound-molecules' has more molecule info so far, can be removed later
const compondMolecules = await api({ url: `${base_url}/api/compound-molecules/?compound_set=${dataset.id}` });
const compondMoleculesMap = {};
- compondMolecules.data.results.forEach(molecule => compondMoleculesMap[molecule.name] = molecule.site_observation_code);
+ compondMolecules.data.results.forEach(
+ molecule =>
+ (compondMoleculesMap[molecule.name] = {
+ site_observation_code: molecule.site_observation_code,
+ pdb_info: molecule.pdb_info
+ })
+ );
response.data.results.forEach(molecule => {
if (compondMoleculesMap.hasOwnProperty(molecule.name)) {
- molecule['site_observation_code'] = compondMoleculesMap[molecule.name];
+ molecule['site_observation_code'] = compondMoleculesMap[molecule.name].site_observation_code;
+ molecule['pdb_info'] = compondMoleculesMap[molecule.name].pdb_info;
+ molecule['isCustomPdb'] = !!!compondMoleculesMap[molecule.name].site_observation_code;
}
});
// <-----
@@ -578,42 +591,112 @@ export const autoHideDatasetDialogsOnScroll = ({ inspirationDialogRef, crossRefe
}
};
+export const getObservationForLHSReference = rhsCompound => (dispatch, getState) => {
+ let result = null;
+
+ if (!rhsCompound?.isCustomPdb && rhsCompound.site_observation_code) {
+ const state = getState();
+ const allLHSMols = state.apiReducers.all_mol_lists;
+ result = allLHSMols.find(mol => mol.code === rhsCompound.site_observation_code);
+ }
+
+ return result;
+};
+
+export const getRHSCmpReferencingLHSObservation = (obsId, obsReferenceToSkip = null) => (dispatch, getState) => {
+ let result = { obs: null, cmp: null };
+
+ const state = getState();
+ const lhsObservations = state.apiReducers.all_mol_lists;
+ const obs = lhsObservations.find(mol => mol.id === obsId);
+
+ if (obs?.code !== obsReferenceToSkip) {
+ const currentMolecules = state.datasetsReducers.moleculeLists;
+ const datasetIds = Object.keys(currentMolecules);
+ for (let i = 0; i < datasetIds.length; i++) {
+ const datasetID = datasetIds[i];
+ const molecules = currentMolecules[datasetID];
+ const found = molecules.find(mol => mol.site_observation_code === obs.code);
+ if (found) {
+ result = { obs: obs, cmp: found };
+ break;
+ }
+ }
+ }
+
+ return result;
+};
+
export const clearCompoundView = (cmp, datasetID, stage, skipTracking) => (dispatch, getState) => {
const state = getState();
- const ligandList = state.datasetsReducers.ligandLists[datasetID];
- const proteinList = state.datasetsReducers.proteinLists[datasetID];
- const complexList = state.datasetsReducers.complexLists[datasetID];
- const surfaceList = state.datasetsReducers.surfaceLists[datasetID];
+ let dataToUse = null;
+
+ let ligandList = state.datasetsReducers.ligandLists[datasetID];
+ let proteinList = [];
+ let complexList = [];
+ let surfaceList = [];
+
+ if (cmp.isCustomPdb) {
+ dataToUse = cmp;
+
+ proteinList = state.datasetsReducers.proteinLists[datasetID];
+ complexList = state.datasetsReducers.complexLists[datasetID];
+ surfaceList = state.datasetsReducers.surfaceLists[datasetID];
+ } else {
+ dataToUse = dispatch(getObservationForLHSReference(cmp));
+
+ proteinList = state.selectionReducers.proteinList;
+ complexList = state.selectionReducers.complexList;
+ surfaceList = state.selectionReducers.surfaceList;
+ }
- if (ligandList?.includes(cmp.id)) {
+ if (ligandList?.includes(dataToUse.id)) {
dispatch(removeDatasetLigand(stage, cmp, getRandomColor(cmp), datasetID, skipTracking));
}
- if (proteinList?.includes(cmp.id)) {
- dispatch(removeDatasetHitProtein(stage, cmp, getRandomColor(cmp), datasetID, skipTracking));
+ if (proteinList?.includes(dataToUse.id)) {
+ if (dataToUse.isCustomPdb) {
+ dispatch(removeDatasetHitProtein(stage, cmp, getRandomColor(cmp), datasetID, skipTracking));
+ } else {
+ dispatch(removeHitProtein(stage, dataToUse, getRandomColor(cmp), skipTracking));
+ }
}
- if (complexList?.includes(cmp.id)) {
- dispatch(removeDatasetComplex(stage, cmp, getRandomColor(cmp), datasetID, skipTracking));
+ if (complexList?.includes(dataToUse.id)) {
+ if (dataToUse.isCustomPdb) {
+ dispatch(removeDatasetComplex(stage, cmp, getRandomColor(cmp), datasetID, skipTracking));
+ } else {
+ dispatch(removeComplex(stage, dataToUse, getRandomColor(cmp), skipTracking));
+ }
}
- if (surfaceList?.includes(cmp.id)) {
- dispatch(removeDatasetSurface(stage, cmp, getRandomColor(cmp), datasetID, skipTracking));
+ if (surfaceList?.includes(dataToUse.id)) {
+ if (dataToUse.isCustomPdb) {
+ dispatch(removeDatasetSurface(stage, cmp, getRandomColor(cmp), datasetID, skipTracking));
+ } else {
+ dispatch(removeSurface(stage, dataToUse, getRandomColor(cmp)));
+ }
}
};
-export const removeSelectedDatasetMolecules = (stage, skipTracking, skipMolecules = {}) => (dispatch, getState) => {
+export const removeSelectedDatasetMolecules = (stage, skipTracking, currentCmp = null, skipMolecules = {}) => (
+ dispatch,
+ getState
+) => {
const state = getState();
const datasets = state.datasetsReducers.datasets;
const currentMolecules = state.datasetsReducers.moleculeLists;
if (datasets) {
+ let proteinList = [];
+ let complexList = [];
+ let surfaceList = [];
datasets.forEach(dataset => {
const datasetID = dataset.id;
const ligandList = state.datasetsReducers.ligandLists[datasetID];
- const proteinList = state.datasetsReducers.proteinLists[datasetID];
- const complexList = state.datasetsReducers.complexLists[datasetID];
- const surfaceList = state.datasetsReducers.surfaceLists[datasetID];
+ proteinList = state.datasetsReducers.proteinLists[datasetID];
+ complexList = state.datasetsReducers.complexLists[datasetID];
+ surfaceList = state.datasetsReducers.surfaceLists[datasetID];
const molecules = currentMolecules[datasetID].filter(molecule => {
return !skipMolecules[datasetID]?.includes(molecule.id);
@@ -652,6 +735,33 @@ export const removeSelectedDatasetMolecules = (stage, skipTracking, skipMolecule
}
});
});
+
+ proteinList = state.selectionReducers.proteinList;
+ complexList = state.selectionReducers.complexList;
+ surfaceList = state.selectionReducers.surfaceList;
+
+ const obsReferenceToSkip = currentCmp ? currentCmp.site_observation_code : '';
+
+ proteinList.forEach(obsId => {
+ const { obs, cmp } = dispatch(getRHSCmpReferencingLHSObservation(obsId, obsReferenceToSkip));
+ if (obs) {
+ dispatch(removeHitProtein(stage, obs, getRandomColor(cmp), skipTracking));
+ }
+ });
+
+ complexList.forEach(obsId => {
+ const { obs, cmp } = dispatch(getRHSCmpReferencingLHSObservation(obsId, obsReferenceToSkip));
+ if (obs) {
+ dispatch(removeComplex(stage, obs, getRandomColor(cmp), skipTracking));
+ }
+ });
+
+ surfaceList.forEach(obsId => {
+ const { obs, cmp } = dispatch(getRHSCmpReferencingLHSObservation(obsId, obsReferenceToSkip));
+ if (obs) {
+ dispatch(removeSurface(stage, obs, getRandomColor(cmp)));
+ }
+ });
}
};
@@ -666,11 +776,6 @@ const flattenInspirationsList = (inspirations, skipMolecules) => {
}
});
});
- // skipMolecules.forEach(molecule => {
- // if (!inspirationsToSkip.hasOwnProperty(molecule.id)) {
- // inspirationsToSkip[molecule.id] = molecule;
- // }
- // });
Object.keys(inspirations).forEach(molId => {
const molecules = inspirations[molId];
@@ -744,10 +849,16 @@ const moveSelectedDatasetMoleculeInspirationsSettings = (data, newItemData, stag
);
};
-export const lockSelectedCompounds = (selectedCompounds, skipCmpId = 0) => (dispatch, getState) => {
+export const lockSelectedCompounds = (selectedCompounds, skipCmp = null) => (dispatch, getState) => {
let filteredCompounds = [...selectedCompounds];
- if (skipCmpId) {
- filteredCompounds = selectedCompounds.filter(item => item.molecule.id !== skipCmpId);
+ if (skipCmp) {
+ filteredCompounds = selectedCompounds.filter(item => {
+ let result = true;
+ if (item.molecule.id === skipCmp.molecule.id && item.datasetID === skipCmp.datasetID) {
+ result = false;
+ }
+ return result;
+ });
}
filteredCompounds?.forEach(item => {
@@ -759,22 +870,22 @@ export const lockSelectedCompounds = (selectedCompounds, skipCmpId = 0) => (disp
});
};
-export const lockCompounds = (datasetID, compoundIds, skipCmpId = 0) => (dispatch, getState) => {
+export const lockCompounds = (datasetID, compoundsToLock, skipCmp = null) => (dispatch, getState) => {
const state = getState();
const compounds = state.datasetsReducers.moleculeLists[datasetID];
- let filteredCompounds = [...compoundIds];
- if (skipCmpId) {
- filteredCompounds = compoundIds.filter(item => item !== skipCmpId);
+ let filteredCompounds = [...compoundsToLock];
+ if (skipCmp) {
+ filteredCompounds = compoundsToLock.filter(item => item.id !== skipCmp.id);
}
- filteredCompounds?.forEach(compoundID => {
- const filteredCIds = compounds.filter(cmp => cmp.id === compoundID);
+ filteredCompounds?.forEach(compound => {
+ const filteredCmps = compounds.filter(cmp => cmp.id === compound.id);
let molName = '';
- if (filteredCIds && filteredCIds.length > 0) {
- molName = filteredCIds[0].name;
+ if (filteredCmps && filteredCmps.length > 0) {
+ molName = filteredCmps[0].name;
}
- dispatch(appendCompoundToSelectedCompoundsByDataset(datasetID, compoundID, molName));
+ dispatch(appendCompoundToSelectedCompoundsByDataset(datasetID, compound.id, molName));
});
};
@@ -809,11 +920,7 @@ export const getAllVisibleButNotLockedSelectedCompounds = (skipDatasetID = '', s
if (datasetID !== skipDatasetID || skipCmpId !== molecule.id) {
const isLocked = dispatch(isCompoundLocked(datasetID, molecule));
if (!isLocked) {
- let isVisible = dispatch(isCompoundVisible(datasetID, molecule.id));
- // isVisible |= state.datasetsReducers.ligandLists[datasetID].includes(molecule.id);
- // isVisible |= state.datasetsReducers.proteinLists[datasetID].includes(molecule.id);
- // isVisible |= state.datasetsReducers.complexLists[datasetID].includes(molecule.id);
- // isVisible |= state.datasetsReducers.surfaceLists[datasetID].includes(molecule.id);
+ let isVisible = dispatch(isCompoundVisible(item));
if (isVisible) {
result.push(item);
@@ -825,15 +932,27 @@ export const getAllVisibleButNotLockedSelectedCompounds = (skipDatasetID = '', s
return result;
};
-export const isCompoundVisible = (datasetID, compoundId) => (dispatch, getState) => {
+export const isCompoundVisible = cmp => (dispatch, getState) => {
let isVisible = false;
const state = getState();
+ const datasetID = cmp.datasetID;
+ const compoundId = cmp.molecule.id;
+ const isCustomPdb = cmp.molecule.isCustomPdb;
+
+ let itemIdToUse = isCustomPdb ? cmp.molecule.id : dispatch(getObservationForLHSReference(cmp.molecule))?.id;
+
isVisible |= state.datasetsReducers.ligandLists[datasetID]?.includes(compoundId);
- isVisible |= state.datasetsReducers.proteinLists[datasetID]?.includes(compoundId);
- isVisible |= state.datasetsReducers.complexLists[datasetID]?.includes(compoundId);
- isVisible |= state.datasetsReducers.surfaceLists[datasetID]?.includes(compoundId);
+ isVisible |= isCustomPdb
+ ? state.datasetsReducers.proteinLists[datasetID]?.includes(itemIdToUse)
+ : state.selectionReducers.proteinList.includes(itemIdToUse);
+ isVisible |= isCustomPdb
+ ? state.datasetsReducers.complexLists[datasetID]?.includes(itemIdToUse)
+ : state.selectionReducers.complexList.includes(itemIdToUse);
+ isVisible |= isCustomPdb
+ ? state.datasetsReducers.surfaceLists[datasetID]?.includes(itemIdToUse)
+ : state.selectionReducers.surfaceList.includes(itemIdToUse);
return isVisible;
};
@@ -842,36 +961,31 @@ export const getAllVisibleButNotLockedCompounds = (datasetID, skipCmpId = 0) =>
let result = [];
const state = getState();
- const lockedCmps = state.datasetsReducers.selectedCompoundsByDataset[datasetID] || [];
-
- result = mergeCompoundIdsList(result, state.datasetsReducers.ligandLists[datasetID]);
- result = mergeCompoundIdsList(result, state.datasetsReducers.proteinLists[datasetID]);
- result = mergeCompoundIdsList(result, state.datasetsReducers.complexLists[datasetID]);
- result = mergeCompoundIdsList(result, state.datasetsReducers.surfaceLists[datasetID]);
-
- result = result.filter(item => !lockedCmps.includes(item));
- if (skipCmpId) {
- result = result.filter(item => item !== skipCmpId);
- }
+ // const lockedCmps = state.datasetsReducers.selectedCompoundsByDataset[datasetID] || [];
+ const datasetCmps = state.datasetsReducers.moleculeLists[datasetID];
- return result;
-};
-
-export const isDatasetCompoundIterrable = (datasetID, compoundID) => (dispatch, getState) => {
- let result = false;
+ datasetCmps.forEach(cmp => {
+ if (skipCmpId !== cmp.id) {
+ const isLocked = dispatch(isCompoundLocked(datasetID, cmp));
+ if (!isLocked) {
+ let isVisible = dispatch(isCompoundVisible({ datasetID, molecule: cmp }));
- if (dispatch(isDatasetCompoundLocked(datasetID, compoundID))) {
- const state = getState();
+ if (isVisible) {
+ result.push(cmp);
+ }
+ }
+ }
+ });
- const L = state.datasetsReducers.ligandLists[datasetID].includes(compoundID);
- const P = state.datasetsReducers.proteinLists[datasetID].includes(compoundID);
- const C = state.datasetsReducers.complexLists[datasetID].includes(compoundID);
- const S = state.datasetsReducers.surfaceLists[datasetID].includes(compoundID);
+ // result = mergeCompoundIdsList(result, state.datasetsReducers.ligandLists[datasetID]);
+ // result = mergeCompoundIdsList(result, state.datasetsReducers.proteinLists[datasetID]);
+ // result = mergeCompoundIdsList(result, state.datasetsReducers.complexLists[datasetID]);
+ // result = mergeCompoundIdsList(result, state.datasetsReducers.surfaceLists[datasetID]);
- result = !(L || P || C || S);
- } else {
- result = true;
- }
+ // result = result.filter(item => !lockedCmps.includes(item));
+ // if (skipCmpId) {
+ // result = result.filter(item => item !== skipCmpId);
+ // }
return result;
};
@@ -1002,8 +1116,10 @@ export const moveSelectedDatasetMoleculeUpDown = (
dispatch(moveSelectedDatasetMoleculeInspirationsSettings(item, newItem, stage, true))
]);
- dispatch(removeSelectedDatasetMolecules(stage, true, { ...lockedCompounds }));
+ dispatch(removeSelectedDatasetMolecules(stage, true, newItem, { ...lockedCompounds }));
dispatch(removeSelectedTypesOfDatasetInspirations([newItem], stage, true, datasetID));
+
+ dispatch(setSelectedCompoundsIterator(newItemDatasetID, newItem));
};
/**
@@ -1028,13 +1144,18 @@ export const moveDatasetMoleculeUpDown = (stage, datasetID, item, newItemDataset
const inspirations = getInspirationsForMol(allInspirations, datasetID, newItem.id);
dispatch(setInspirationMoleculeDataList(inspirations));
dispatch(clearCompoundView(newItem, datasetID, stage, true));
+ console.log('moveDatasetMoleculeUpDown - compounds cleared');
await Promise.all([
dispatch(moveSelectedMoleculeSettings(stage, item, newItem, newItemDatasetID, datasetID, dataValue, true)),
dispatch(moveSelectedDatasetMoleculeInspirationsSettings(item, newItem, stage, true))
]);
- dispatch(removeSelectedDatasetMolecules(stage, true, { [newItemDatasetID]: [newItem.id, ...lockedCompounds] }));
+ dispatch(
+ removeSelectedDatasetMolecules(stage, true, newItem, { [newItemDatasetID]: [newItem.id, ...lockedCompounds] })
+ );
dispatch(removeSelectedTypesOfDatasetInspirations([newItem], stage, true, datasetID));
+
+ dispatch(setDatasetIterator(newItemDatasetID, newItem));
};
export const getInspirationsForMol = (allInspirations, datasetId, molId) => {
@@ -1319,6 +1440,10 @@ export const moveSelectedMoleculeSettings = (
) => (dispatch, getState) => {
const promises = [];
if (newItem && data) {
+ let customPdbData = null;
+ if (!newItem.isCustomPdb) {
+ customPdbData = dispatch(getObservationForLHSReference(newItem));
+ }
if (data.isLigandOn) {
let representations = getRepresentationsByType(data.objectsInView, newItem, OBJECT_TYPE.LIGAND, datasetID);
promises.push(
@@ -1329,27 +1454,59 @@ export const moveSelectedMoleculeSettings = (
}
if (data.isProteinOn) {
let representations = getRepresentationsByType(data.objectsInView, newItem, OBJECT_TYPE.PROTEIN, datasetID);
- promises.push(
- dispatch(
- addDatasetHitProtein(stage, newItem, getRandomColor(newItem), datasetIdOfMolecule, skipTracking, representations)
- )
- );
+ if (newItem.isCustomPdb) {
+ promises.push(
+ dispatch(
+ addDatasetHitProtein(
+ stage,
+ newItem,
+ getRandomColor(newItem),
+ datasetIdOfMolecule,
+ skipTracking,
+ representations
+ )
+ )
+ );
+ } else {
+ promises.push(
+ dispatch(
+ addHitProtein(stage, customPdbData, getRandomColor(newItem), true, skipTracking, representations, true)
+ )
+ );
+ }
}
if (data.isComplexOn) {
let representations = getRepresentationsByType(data.objectsInView, newItem, OBJECT_TYPE.COMPLEX, datasetID);
- promises.push(
- dispatch(
- addDatasetComplex(stage, newItem, getRandomColor(newItem), datasetIdOfMolecule, skipTracking, representations)
- )
- );
+ if (newItem.isCustomPdb) {
+ promises.push(
+ dispatch(
+ addDatasetComplex(
+ stage,
+ newItem,
+ getRandomColor(newItem),
+ datasetIdOfMolecule,
+ skipTracking,
+ representations
+ )
+ )
+ );
+ } else {
+ promises.push(
+ dispatch(addComplex(stage, customPdbData, getRandomColor(newItem), skipTracking, representations, true))
+ );
+ }
}
if (data.isSurfaceOn) {
let representations = getRepresentationsByType(data.objectsInView, newItem, OBJECT_TYPE.SURFACE, datasetID);
- promises.push(
- dispatch(
- addDatasetSurface(stage, newItem, getRandomColor(newItem), datasetIdOfMolecule, skipTracking, representations)
- )
- );
+ if (newItem.isCustomPdb) {
+ promises.push(
+ dispatch(addDatasetSurface(stage, newItem, getRandomColor(newItem), datasetIdOfMolecule, representations))
+ );
+ } else {
+ promises.push(
+ dispatch(addSurface(stage, customPdbData, getRandomColor(newItem), false, representations, true))
+ );
+ }
}
}
return Promise.all(promises);
@@ -1478,3 +1635,32 @@ export const deleteDataset = (datasetID, stage) => async (dispatch, getState) =>
dispatch(removeDataset(datasetID));
console.log('dataset removed from redux store');
};
+
+export const getCurrentDatasetIterator = datasetID => (dispatch, getState) => {
+ let result = null;
+
+ const state = getState();
+ const datasetIterators = state.datasetsReducers.iteratorDatasets;
+ if (datasetIterators.hasOwnProperty(datasetID)) {
+ result = datasetIterators[datasetID];
+ }
+
+ return result;
+};
+
+export const getCurrentSelectedCompoundIterator = () => (dispatch, getState) => {
+ let result = null;
+
+ const state = getState();
+ result = state.datasetsReducers.iteratorSelectedCompounds;
+
+ return result;
+};
+
+export const resetDatasetIterator = datasetID => (dispatch, getState) => {
+ dispatch(setDatasetIterator(datasetID, null));
+};
+
+export const resetSelectedCompoundIterator = () => (dispatch, getState) => {
+ dispatch(setSelectedCompoundsIterator(null, null));
+};
diff --git a/js/components/datasets/redux/reducer.js b/js/components/datasets/redux/reducer.js
index 17d8b52ea..af94f6198 100644
--- a/js/components/datasets/redux/reducer.js
+++ b/js/components/datasets/redux/reducer.js
@@ -79,7 +79,11 @@ export const INITIAL_STATE = {
cmpForLocalLockVisibleCompoundsDialog: null,
askLockCompoundsQuestion: true,
editedColorGroup: null,
- askLockSelectedCompoundsQuestion: true
+ askLockSelectedCompoundsQuestion: true,
+
+ //iterator functionality for dataset tabs and also selected compounds tab
+ iteratorDatasets: {},
+ iteratorSelectedCompounds: null
};
/**
@@ -283,6 +287,28 @@ export const datasetsReducers = (state = INITIAL_STATE, action = {}) => {
case constants.REMOVE_FROM_INSPIRATION_LIST:
return removeFromList(state, 'inspirationLists', action.payload.datasetID, action.payload.itemID);
+ case constants.SET_DATASET_ITERATOR: {
+ if (action.payload.currentCmp) {
+ return {
+ ...state,
+ iteratorDatasets: { ...state.iteratorDatasets, [action.payload.datasetID]: { ...action.payload.currentCmp } }
+ };
+ } else {
+ return {
+ ...state,
+ iteratorDatasets: { ...state.iteratorDatasets, [action.payload.datasetID]: null }
+ };
+ }
+ }
+
+ case constants.SET_SELECTED_COMPOUNDS_ITERATOR: {
+ if (action.payload) {
+ return { ...state, iteratorSelectedCompounds: { ...action.payload } };
+ } else {
+ return { ...state, iteratorSelectedCompounds: null };
+ }
+ }
+
case constants.APPEND_TO_SCORE_DATASET_MAP:
return Object.assign({}, state, {
scoreDatasetMap: {
diff --git a/js/components/datasets/redux/selectors.js b/js/components/datasets/redux/selectors.js
index 4c33776eb..323839bf0 100644
--- a/js/components/datasets/redux/selectors.js
+++ b/js/components/datasets/redux/selectors.js
@@ -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;
+ }
+);
diff --git a/js/components/datasets/selectedCompoundsList.js b/js/components/datasets/selectedCompoundsList.js
index c14cc225c..77cacdfdd 100644
--- a/js/components/datasets/selectedCompoundsList.js
+++ b/js/components/datasets/selectedCompoundsList.js
@@ -33,7 +33,9 @@ import { CrossReferenceDialog } from './crossReferenceDialog';
import {
autoHideDatasetDialogsOnScroll,
getAllVisibleButNotLockedSelectedCompounds,
+ getCurrentSelectedCompoundIterator,
getInspirationsForMol,
+ getObservationForLHSReference,
isCompoundLocked,
isCompoundVisible,
moveDatasetMoleculeUpDown,
@@ -192,15 +194,22 @@ export const SelectedCompoundList = memo(() => {
const canLoadMore = listItemOffset < moleculesObjectIDListOfCompoundsToBuy.length;
const ligandList = useSelector(state => getListOfSelectedLigandOfAllDatasets(state));
- const proteinList = useSelector(state => getListOfSelectedProteinOfAllDatasets(state));
- const complexList = useSelector(state => getListOfSelectedComplexOfAllDatasets(state));
- const surfaceList = useSelector(state => getListOfSelectedSurfaceOfAllDatasets(state));
+ const proteinList = useSelector(state => state.selectionReducers.proteinList);
+ const complexList = useSelector(state => state.selectionReducers.complexList);
+ const surfaceList = useSelector(state => state.selectionReducers.surfaceList);
+
+ const proteinListDataset = useSelector(state => getListOfSelectedProteinOfAllDatasets(state));
+ const complexListDataset = useSelector(state => getListOfSelectedComplexOfAllDatasets(state));
+ const surfaceListDataset = useSelector(state => getListOfSelectedSurfaceOfAllDatasets(state));
const showedCompoundList = useSelector(state => state.previewReducers.compounds.showedCompoundList);
const filteredScoreProperties = useSelector(state => state.datasetsReducers.filteredScoreProperties);
const moleculeLists = useSelector(state => state.datasetsReducers.moleculeLists);
+ const allMoleculesList = useSelector(state => state.apiReducers.all_mol_lists);
+
const compoundsToBuyList = useSelector(state => state.datasetsReducers.compoundsToBuyDatasetMap);
+
let selectedMolecules = [];
Object.keys(compoundsToBuyList).forEach(datasetId => {
const datasetCmpsToBuy = compoundsToBuyList[datasetId] || [];
@@ -266,9 +275,7 @@ export const SelectedCompoundList = memo(() => {
if (moleculesObjectIDListOfCompoundsToBuy) {
for (let i = 0; i < moleculesObjectIDListOfCompoundsToBuy.length; i++) {
const cmp = moleculesObjectIDListOfCompoundsToBuy[i];
- const dataset = cmp.datasetID;
- const molecule = cmp.molecule;
- const isVisible = dispatch(isCompoundVisible(dataset, molecule.id));
+ const isVisible = dispatch(isCompoundVisible(cmp));
if (isVisible) {
result = true;
break;
@@ -276,19 +283,17 @@ export const SelectedCompoundList = memo(() => {
}
}
return result;
- }, [dispatch, moleculesObjectIDListOfCompoundsToBuy]);
- // if (!moleculesObjectIDListOfCompoundsToBuy) {
- // for (let i = 0; i < moleculesObjectIDListOfCompoundsToBuy.length; i++) {
- // const cmp = moleculesObjectIDListOfCompoundsToBuy[i];
- // const dataset = cmp.datasetID;
- // const molecule = cmp.molecule;
- // const isVisible = dispatch(isCompoundVisible(dataset, molecule.id));
- // if (isVisible) {
- // areArrowsVisible = true;
- // break;
- // }
- // }
- // }
+ }, [
+ dispatch,
+ moleculesObjectIDListOfCompoundsToBuy,
+ ligandList,
+ proteinList,
+ complexList,
+ surfaceList,
+ proteinListDataset,
+ complexListDataset,
+ surfaceListDataset
+ ]);
useEffect(() => {
return () => {
@@ -601,13 +606,18 @@ export const SelectedCompoundList = memo(() => {
const getFirstItemForIterationStart = () => {
let result = null;
- for (let i = 0; i < moleculesObjectIDListOfCompoundsToBuy.length; i++) {
- const cmp = moleculesObjectIDListOfCompoundsToBuy[i];
- if (!dispatch(isCompoundLocked(cmp.datasetID, cmp.molecule)) && !isCompoundFromVectorSelector(cmp.molecule)) {
- const isVisible = dispatch(isCompoundVisible(cmp.datasetID, cmp.molecule.id));
- if (isVisible) {
- result = cmp;
- break;
+
+ result = dispatch(getCurrentSelectedCompoundIterator());
+
+ if (!(result.datasetID && result.molecule)) {
+ for (let i = 0; i < moleculesObjectIDListOfCompoundsToBuy.length; i++) {
+ const cmp = moleculesObjectIDListOfCompoundsToBuy[i];
+ if (!dispatch(isCompoundLocked(cmp.datasetID, cmp.molecule)) && !isCompoundFromVectorSelector(cmp.molecule)) {
+ const isVisible = dispatch(isCompoundVisible(cmp));
+ if (isVisible) {
+ result = cmp;
+ break;
+ }
}
}
}
@@ -664,12 +674,28 @@ export const SelectedCompoundList = memo(() => {
const node = getNode(nextItem.molecule?.id);
setScrollToMoleculeId(nextItem.molecule?.id);
+ let firstItemIdToUse = firstItem.molecule?.id;
+ let isCustomPdb = true;
+ if (!firstItem.molecule?.isCustomPdb) {
+ isCustomPdb = false;
+ const obs = dispatch(getObservationForLHSReference(firstItem.molecule));
+ if (obs) {
+ firstItemIdToUse = obs.id;
+ }
+ }
+
let dataValue = {
colourToggle: getRandomColor(firstItem.molecule),
isLigandOn: ligandList.includes(firstItem.molecule?.id),
- isProteinOn: proteinList.includes(firstItem.molecule?.id),
- isComplexOn: complexList.includes(firstItem.molecule?.id),
- isSurfaceOn: surfaceList.includes(firstItem.molecule?.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));
@@ -707,12 +733,28 @@ export const SelectedCompoundList = memo(() => {
const node = getNode(prevItem.molecule?.id);
setScrollToMoleculeId(prevItem.molecule?.id);
+ let firstItemIdToUse = firstItem.molecule?.id;
+ let isCustomPdb = true;
+ if (!firstItem.molecule?.isCustomPdb) {
+ isCustomPdb = false;
+ const obs = dispatch(getObservationForLHSReference(firstItem?.molecule));
+ if (obs) {
+ firstItemIdToUse = obs.id;
+ }
+ }
+
let dataValue = {
colourToggle: getRandomColor(firstItem.molecule),
isLigandOn: ligandList.includes(firstItem.molecule?.id),
- isProteinOn: proteinList.includes(firstItem.molecule?.id),
- isComplexOn: complexList.includes(firstItem.molecule?.id),
- isSurfaceOn: surfaceList.includes(firstItem.molecule?.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));
@@ -936,6 +978,11 @@ export const SelectedCompoundList = memo(() => {
}
const isLocked = dispatch(isCompoundLocked(data.datasetID, data.molecule));
+ const isCustomPdb = data.molecule.isCustomPdb;
+
+ const itemIdToUse = isCustomPdb
+ ? data.molecule.id
+ : dispatch(getObservationForLHSReference(data.molecule))?.id;
// }
return (
isVisible && (
@@ -952,12 +999,12 @@ export const SelectedCompoundList = memo(() => {
previousItemData={index > 0 && array[index - 1]}
nextItemData={index < array?.length && array[index + 1]}
L={isLigandOn}
- P={proteinList.includes(data.molecule.id)}
- C={complexList.includes(data.molecule.id)}
- S={surfaceList.includes(data.molecule.id)}
+ P={isCustomPdb ? proteinListDataset.includes(itemIdToUse) : proteinList.includes(itemIdToUse)}
+ C={isCustomPdb ? complexListDataset.includes(itemIdToUse) : complexList.includes(itemIdToUse)}
+ S={isCustomPdb ? surfaceListDataset.includes(itemIdToUse) : surfaceList.includes(itemIdToUse)}
V={false}
arrowsHidden={false}
- dragDropEnabled
+ dragDropEnabled={false}
shoppingCartColors={shoppingCartColors}
isAddedToShoppingCart={isAddedToShoppingCart}
inSelectedCompoundsList
diff --git a/js/reducers/tracking/dispatchActions.js b/js/reducers/tracking/dispatchActions.js
index 2e5d5ca88..1ababf4f5 100644
--- a/js/reducers/tracking/dispatchActions.js
+++ b/js/reducers/tracking/dispatchActions.js
@@ -3485,7 +3485,7 @@ const handleArrowNavigationActionOfCompound = (action, isSelected, majorViewStag
const qualityListMolecule = data.qualityList;
dispatch(hideAllSelectedMolecules(majorViewStage, molecules, false, true));
- dispatch(removeSelectedDatasetMolecules(majorViewStage, true));
+ dispatch(removeSelectedDatasetMolecules(majorViewStage, true, newItem));
const newDatasetID = (newItem.hasOwnProperty('datasetID') && newItem.datasetID) || datasetID;
const moleculeTitlePrev = newItem && newItem.name;