Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/#516' into allfunctionality
Browse files Browse the repository at this point in the history
  • Loading branch information
boriskovar-m2ms committed Feb 1, 2021
2 parents e63dae6 + 5e37e48 commit 60cda62
Show file tree
Hide file tree
Showing 19 changed files with 737 additions and 291 deletions.
14 changes: 9 additions & 5 deletions js/components/datasets/crossReferenceDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export const CrossReferenceDialog = memo(
const complexListAllDatasets = useSelector(state => state.datasetsReducers.complexLists);
const surfaceListAllDatasets = useSelector(state => state.datasetsReducers.surfaceLists);

const removeOfAllSelectedTypes = () => {
const removeOfAllSelectedTypes = skipTracking => {
Object.keys(ligandListAllDatasets).forEach(datasetKey => {
ligandListAllDatasets[datasetKey]?.forEach(moleculeID => {
const foundedMolecule = moleculeList?.find(mol => mol?.molecule?.id === moleculeID);
Expand All @@ -155,7 +155,8 @@ export const CrossReferenceDialog = memo(
stage,
foundedMolecule?.molecule,
colourList[foundedMolecule?.molecule?.id % colourList.length],
datasetKey
datasetKey,
skipTracking
)
);
});
Expand All @@ -168,7 +169,8 @@ export const CrossReferenceDialog = memo(
stage,
foundedMolecule?.molecule,
colourList[foundedMolecule?.molecule?.id % colourList.length],
datasetKey
datasetKey,
skipTracking
)
);
});
Expand All @@ -181,7 +183,8 @@ export const CrossReferenceDialog = memo(
stage,
foundedMolecule?.molecule,
colourList[foundedMolecule?.molecule?.id % colourList.length],
datasetKey
datasetKey,
skipTracking
)
);
});
Expand All @@ -194,7 +197,8 @@ export const CrossReferenceDialog = memo(
stage,
foundedMolecule?.molecule,
colourList[foundedMolecule?.molecule?.id % colourList.length],
datasetKey
datasetKey,
skipTracking
)
);
});
Expand Down
13 changes: 7 additions & 6 deletions js/components/datasets/datasetMoleculeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,16 +296,16 @@ export const DatasetMoleculeList = memo(
surface: removeDatasetSurface
};

const removeOfAllSelectedTypesOfInspirations = () => {
const removeOfAllSelectedTypesOfInspirations = skipTracking => {
let molecules = [...getJoinedMoleculeList, ...inspirationMoleculeDataList];
dispatch(hideAllSelectedMolecules(stage, [...molecules]));
dispatch(hideAllSelectedMolecules(stage, [...molecules], false, skipTracking));
};

const removeOfAllSelectedTypes = () => {
dispatch(removeAllSelectedDatasetMolecules(stage));
const removeOfAllSelectedTypes = skipTracking => {
dispatch(removeAllSelectedDatasetMolecules(stage, skipTracking));
};

const moveSelectedMoleculeInspirationsSettings = (data, newItemData) => (dispatch, getState) => {
const moveSelectedMoleculeInspirationsSettings = (data, newItemData, skipTracking) => (dispatch, getState) => {
dispatch(
moveMoleculeInspirationsSettings(
data,
Expand All @@ -317,7 +317,8 @@ export const DatasetMoleculeList = memo(
complexListMolecule,
surfaceListMolecule,
densityListMolecule,
vectorOnListMolecule
vectorOnListMolecule,
skipTracking
)
);
};
Expand Down
97 changes: 32 additions & 65 deletions js/components/datasets/datasetMoleculeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Grid, Button, makeStyles, Tooltip, Checkbox, IconButton } from '@materi
import { ClearOutlined, CheckOutlined } from '@material-ui/icons';
import SVGInline from 'react-svg-inline';
import classNames from 'classnames';
import { VIEWS } from '../../constants/constants';
import { VIEWS, ARROW_TYPE } from '../../constants/constants';
import { NglContext } from '../nglView/nglProvider';
// import { useDisableUserInteraction } from '../helpers/useEnableUserInteracion';
import {
Expand All @@ -21,28 +21,26 @@ import {
addDatasetSurface,
removeDatasetSurface,
clickOnInspirations,
getDatasetMoleculeID
getDatasetMoleculeID,
moveSelectedMoleculeSettings,
getInspirationsForMol
} from './redux/dispatchActions';

import { base_url } from '../routes/constants';
import { api } from '../../utils/api';
import { isAnyInspirationTurnedOn, getFilteredDatasetMoleculeList } from './redux/selectors';
import {
appendMoleculeToCompoundsOfDatasetToBuy,
removeMoleculeFromCompoundsOfDatasetToBuy,
setCrossReferenceCompoundName,
setIsOpenCrossReferenceDialog,
setInspirationFragmentList,
setInspirationMoleculeDataList,
setSelectedAll,
setDeselectedAll
setDeselectedAll,
setArrowUpDown
} from './redux/actions';
import { centerOnLigandByMoleculeID } from '../../reducers/ngl/dispatchActions';
import { ArrowDownward, ArrowUpward, MyLocation } from '@material-ui/icons';
import { isString } from 'lodash';
import { SvgTooltip } from '../common';
import { OBJECT_TYPE } from '../nglView/constants';
import { getRepresentationsByType } from '../nglView/generatingObjects';
import { getMolImage } from '../preview/molecule/redux/dispatchActions';
import { MOL_TYPE } from '../preview/molecule/redux/constants';

Expand Down Expand Up @@ -262,7 +260,11 @@ export const DatasetMoleculeView = memo(
removeOfAllSelectedTypes,
removeOfAllSelectedTypesOfInspirations,
moveSelectedMoleculeInspirationsSettings,
L, P, C, S, V
L,
P,
C,
S,
V
}) => {
const selectedAll = useRef(false);
const currentID = (data && data.id) || undefined;
Expand Down Expand Up @@ -319,18 +321,7 @@ export const DatasetMoleculeView = memo(
dispatch(getMolImage(data.smiles, MOL_TYPE.DATASET, imageHeight, imageWidth)).then(i => {
setImage(i);
});
}, [
C,
currentID,
data,
L,
imageHeight,
imageWidth,
data.smiles,
data.id,
filteredDatasetMoleculeList,
dispatch
]);
}, [C, currentID, data, L, imageHeight, imageWidth, data.smiles, data.id, filteredDatasetMoleculeList, dispatch]);

const svg_image = (
<SVGInline
Expand Down Expand Up @@ -486,27 +477,6 @@ export const DatasetMoleculeView = memo(
return cssClass;
};

const moveSelectedMoleculeSettings = (newItemData, datasetIdOfMolecule) => {
if (newItemData) {
if (isLigandOn) {
let representations = getRepresentationsByType(objectsInView, data, OBJECT_TYPE.LIGAND, datasetID);
dispatch(addDatasetLigand(stage, newItemData, colourToggle, datasetIdOfMolecule, representations));
}
if (isProteinOn) {
let representations = getRepresentationsByType(objectsInView, data, OBJECT_TYPE.PROTEIN, datasetID);
dispatch(addDatasetHitProtein(stage, newItemData, colourToggle, datasetIdOfMolecule, representations));
}
if (isComplexOn) {
let representations = getRepresentationsByType(objectsInView, data, OBJECT_TYPE.COMPLEX, datasetID);
dispatch(addDatasetComplex(stage, newItemData, colourToggle, datasetIdOfMolecule, representations));
}
if (isSurfaceOn) {
let representations = getRepresentationsByType(objectsInView, data, OBJECT_TYPE.SURFACE, datasetID);
dispatch(addDatasetSurface(stage, newItemData, colourToggle, datasetIdOfMolecule, representations));
}
}
};

const scrollToElement = element => {
element.scrollIntoView({
behavior: 'auto',
Expand All @@ -515,31 +485,24 @@ export const DatasetMoleculeView = memo(
});
};

const getInspirationsForMol = (datasetId, molId) => {
let inspirations = [];

if (allInspirations && allInspirations.hasOwnProperty(datasetId) && allInspirations[datasetId].hasOwnProperty(molId)) {
inspirations = allInspirations[datasetId][molId];
}

return inspirations;
};

const handleClickOnDownArrow = () => {
const refNext = ref.current.nextSibling;
scrollToElement(refNext);

removeOfAllSelectedTypes();
removeOfAllSelectedTypesOfInspirations();

const nextItem = (nextItemData.hasOwnProperty('molecule') && nextItemData.molecule) || nextItemData;
const nextDatasetID = (nextItemData.hasOwnProperty('datasetID') && nextItemData.datasetID) || datasetID;
const moleculeTitleNext = nextItem && nextItem.name;

const inspirations = getInspirationsForMol(datasetID, nextItem.id);
let dataValue = { objectsInView, colourToggle, isLigandOn, isProteinOn, isComplexOn, isSurfaceOn };
dispatch(setArrowUpDown(datasetID, data, nextItem, ARROW_TYPE.DOWN, dataValue));

removeOfAllSelectedTypes(true);
removeOfAllSelectedTypesOfInspirations(true);

const inspirations = getInspirationsForMol(allInspirations, datasetID, nextItem.id);
dispatch(setInspirationMoleculeDataList(inspirations));
moveSelectedMoleculeSettings(nextItem, nextDatasetID);
dispatch(moveSelectedMoleculeInspirationsSettings(data, nextItem));
dispatch(moveSelectedMoleculeSettings(stage, data, nextItem, nextDatasetID, datasetID, dataValue, true));
dispatch(moveSelectedMoleculeInspirationsSettings(data, nextItem, true));
dispatch(setCrossReferenceCompoundName(moleculeTitleNext));
if (setRef && ref.current) {
setRef(refNext);
Expand All @@ -550,19 +513,23 @@ export const DatasetMoleculeView = memo(
const refPrevious = ref.current.previousSibling;
scrollToElement(refPrevious);

removeOfAllSelectedTypes();
removeOfAllSelectedTypesOfInspirations();

const previousItem =
(previousItemData.hasOwnProperty('molecule') && previousItemData.molecule) || previousItemData;
const previousDatasetID =
(previousItemData.hasOwnProperty('datasetID') && previousItemData.datasetID) || datasetID;
const moleculeTitlePrev = previousItem && previousItem.name;

const inspirations = getInspirationsForMol(datasetID, previousItem.id);
let dataValue = { objectsInView, colourToggle, isLigandOn, isProteinOn, isComplexOn, isSurfaceOn };
dispatch(setArrowUpDown(datasetID, data, previousItem, ARROW_TYPE.UP, dataValue));

removeOfAllSelectedTypes(true);
removeOfAllSelectedTypesOfInspirations(true);

const inspirations = getInspirationsForMol(allInspirations, datasetID, previousItem.id);
dispatch(setInspirationMoleculeDataList(inspirations));
moveSelectedMoleculeSettings(previousItem, previousDatasetID);
dispatch(moveSelectedMoleculeInspirationsSettings(data, previousItem));
dispatch(moveSelectedMoleculeSettings(stage, data, previousItem, previousDatasetID, datasetID, dataValue, true));

dispatch(moveSelectedMoleculeInspirationsSettings(data, previousItem, true));
dispatch(setCrossReferenceCompoundName(moleculeTitlePrev));
if (setRef && ref.current) {
setRef(refPrevious);
Expand Down Expand Up @@ -755,7 +722,7 @@ export const DatasetMoleculeView = memo(
clickOnInspirations({
datasetID,
currentID,
computed_inspirations: getInspirationsForMol(datasetID, currentID)
computed_inspirations: getInspirationsForMol(allInspirations, datasetID, currentID)
})
);
if (setRef) {
Expand Down
22 changes: 15 additions & 7 deletions js/components/datasets/inspirationDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,37 +208,45 @@ export const InspirationDialog = memo(

const selectMoleculeSite = moleculeGroupSite => {};

const removeOfAllSelectedTypes = () => {
const removeOfAllSelectedTypes = (skipTracking = false) => {
proteinList?.forEach(moleculeID => {
let foundedMolecule = moleculeList?.find(mol => mol.id === moleculeID);
foundedMolecule = foundedMolecule && Object.assign({ isInspiration: true }, foundedMolecule);

dispatch(removeHitProtein(stage, foundedMolecule, colourList[foundedMolecule.id % colourList.length]));
dispatch(
removeHitProtein(stage, foundedMolecule, colourList[foundedMolecule.id % colourList.length], skipTracking)
);
});
complexList?.forEach(moleculeID => {
let foundedMolecule = moleculeList?.find(mol => mol.id === moleculeID);
foundedMolecule = foundedMolecule && Object.assign({ isInspiration: true }, foundedMolecule);
dispatch(removeComplex(stage, foundedMolecule, colourList[foundedMolecule.id % colourList.length]));
dispatch(
removeComplex(stage, foundedMolecule, colourList[foundedMolecule.id % colourList.length], skipTracking)
);
});
ligandList?.forEach(moleculeID => {
let foundedMolecule = moleculeList?.find(mol => mol.id === moleculeID);
foundedMolecule = foundedMolecule && Object.assign({ isInspiration: true }, foundedMolecule);
dispatch(removeLigand(stage, foundedMolecule, colourList[foundedMolecule.id % colourList.length]));
dispatch(removeLigand(stage, foundedMolecule, skipTracking));
});
surfaceList?.forEach(moleculeID => {
let foundedMolecule = moleculeList?.find(mol => mol.id === moleculeID);
foundedMolecule = foundedMolecule && Object.assign({ isInspiration: true }, foundedMolecule);
dispatch(removeSurface(stage, foundedMolecule, colourList[foundedMolecule.id % colourList.length]));
dispatch(
removeSurface(stage, foundedMolecule, colourList[foundedMolecule.id % colourList.length], skipTracking)
);
});
densityList?.forEach(moleculeID => {
let foundedMolecule = moleculeList?.find(mol => mol.id === moleculeID);
foundedMolecule = foundedMolecule && Object.assign({ isInspiration: true }, foundedMolecule);
dispatch(removeDensity(stage, foundedMolecule, colourList[foundedMolecule.id % colourList.length]));
dispatch(
removeDensity(stage, foundedMolecule, colourList[foundedMolecule.id % colourList.length], skipTracking)
);
});
vectorOnList?.forEach(moleculeID => {
let foundedMolecule = moleculeList?.find(mol => mol.id === moleculeID);
foundedMolecule = foundedMolecule && Object.assign({ isInspiration: true }, foundedMolecule);
dispatch(removeVector(stage, foundedMolecule, colourList[foundedMolecule.id % colourList.length]));
dispatch(removeVector(stage, foundedMolecule, skipTracking));
});
};

Expand Down
13 changes: 12 additions & 1 deletion js/components/datasets/redux/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export const setInspirationMoleculeDataList = (moleculeList = []) => ({
payload: moleculeList
});

export const setAllInspirations = (allInspirationsMap) => ({
export const setAllInspirations = allInspirationsMap => ({
type: constants.SET_ALL_INSPIRATIONS,
payload: allInspirationsMap
});
Expand Down Expand Up @@ -368,3 +368,14 @@ export const setDeselectedAllByType = (type, datsetID, items, isCrossReference)
isCrossReference: isCrossReference
}
});

export const setArrowUpDown = (datasetID, item, newItem, arrowType, data) => ({
type: constants.SET_ARROW_UP_DOWN,
payload: {
datasetID,
item: item,
newItem: newItem,
arrowType: arrowType,
data
}
});
3 changes: 2 additions & 1 deletion js/components/datasets/redux/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ export const constants = {
SET_DESELECTED_ALL: prefix + 'SET_DESELECTED_ALL',

SET_SELECTED_ALL_BY_TYPE: prefix + 'SET_SELECTED_ALL_BY_TYPE',
SET_DESELECTED_ALL_BY_TYPE: prefix + 'SET_DESELECTED_ALL_BY_TYPE'
SET_DESELECTED_ALL_BY_TYPE: prefix + 'SET_DESELECTED_ALL_BY_TYPE',
SET_ARROW_UP_DOWN: prefix + 'SET_ARROW_UP_DOWN'
};

export const COUNT_OF_VISIBLE_SCORES = 7;
Expand Down
Loading

0 comments on commit 60cda62

Please sign in to comment.