Skip to content

Commit

Permalink
- fixed RHS for #1239
Browse files Browse the repository at this point in the history
  • Loading branch information
boriskovar-m2ms committed Dec 7, 2023
1 parent 5f0d1a3 commit e79b49f
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 41 deletions.
33 changes: 27 additions & 6 deletions js/components/datasets/datasetMoleculeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,18 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
// TODO: maybe change "currentMolecules.forEach" to "{type}List.forEach"

const removeSelectedType = (type, skipTracking) => {
lockedMolecules.forEach(cid => {
for (const cid of lockedMolecules) {
let molecule = getCompoundForId(cid);
//this is dumb... I know but this original mechanism using eval and array of functions is even dumber
if ((type === 'protein' || type === 'complex') && !molecule.pdb_info) {
continue;
}
dispatch(removeType[type](stage, molecule, colourList[molecule.id % colourList.length], datasetID, skipTracking));
});
}
// lockedMolecules.forEach(cid => {
// let molecule = getCompoundForId(cid);
// dispatch(removeType[type](stage, molecule, colourList[molecule.id % colourList.length], datasetID, skipTracking));
// });
selectedAll.current = false;
};

Expand All @@ -497,14 +505,26 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
withDisabledDatasetMoleculesNglControlButtons([datasetID], lockedMolecules, type, async () => {
const promises = [];

lockedMolecules.forEach(cid => {
for (const cid of lockedMolecules) {
let molecule = getCompoundForId(cid);
//this is dumb... I know but this original mechanism using eval and array of functions is even dumber
if ((type === 'protein' || type === 'complex') && !molecule.pdb_info) {
continue;
}
promises.push(
dispatch(
addType[type](stage, molecule, colourList[molecule.id % colourList.length], datasetID, skipTracking)
)
);
});
}
// lockedMolecules.forEach(cid => {
// let molecule = getCompoundForId(cid);
// promises.push(
// dispatch(
// addType[type](stage, molecule, colourList[molecule.id % colourList.length], datasetID, skipTracking)
// )
// );
// });

await Promise.all(promises);
})
Expand Down Expand Up @@ -934,8 +954,9 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
{filterSettings.priorityOrder.map(attr => (
<Grid item key={`Mol-Tooltip-${attr}`}>
<Tooltip
title={`${filterProperties[attr].minValue}-${filterProperties[attr].maxValue} ${filterProperties[attr].order === 1 ? '\u2191' : '\u2193'
}`}
title={`${filterProperties[attr].minValue}-${filterProperties[attr].maxValue} ${
filterProperties[attr].order === 1 ? '\u2191' : '\u2193'
}`}
placement="top"
>
<Chip size="small" label={attr} className={classes.propertyChip} />
Expand Down
100 changes: 70 additions & 30 deletions js/components/datasets/datasetMoleculeView/datasetMoleculeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,8 @@ const DatasetMoleculeView = memo(

const colourToggle = getRandomColor(data);

const isPdbAvailable = !!(data && data.pdb_info);

const [moleculeTooltipOpen, setMoleculeTooltipOpen] = useState(false);
const moleculeImgRef = useRef(null);

Expand Down Expand Up @@ -1002,8 +1004,8 @@ const DatasetMoleculeView = memo(

setCalledFromAll();
onLigand(true);
onProtein(true);
onComplex(true);
isPdbAvailable && onProtein(true);
isPdbAvailable && onComplex(true);
setLoadingAll(false);
}}
disabled={
Expand All @@ -1013,9 +1015,13 @@ const DatasetMoleculeView = memo(
}
>
A
{loadingAll && <CircularProgress className={classNames(classes.buttonLoadingOverlay, {
[classes.buttonSelectedLoadingOverlay]: hasAllValuesOn || hasSomeValuesOn
})} />}
{loadingAll && (
<CircularProgress
className={classNames(classes.buttonLoadingOverlay, {
[classes.buttonSelectedLoadingOverlay]: hasAllValuesOn || hasSomeValuesOn
})}
/>
)}
</Button>
</Grid>
</Tooltip>
Expand All @@ -1033,9 +1039,13 @@ const DatasetMoleculeView = memo(
disabled={disableL || disableMoleculeNglControlButtons.ligand}
>
L
{loadingLigand && <CircularProgress className={classNames(classes.buttonLoadingOverlay, {
[classes.buttonSelectedLoadingOverlay]: isLigandOn
})} />}
{loadingLigand && (
<CircularProgress
className={classNames(classes.buttonLoadingOverlay, {
[classes.buttonSelectedLoadingOverlay]: isLigandOn
})}
/>
)}
</Button>
</Grid>
</Tooltip>
Expand All @@ -1050,12 +1060,21 @@ const DatasetMoleculeView = memo(
dispatch(setAskLockCompoundsQuestion(true));
onProtein();
}}
disabled={isFromVectorSelector || disableP || disableMoleculeNglControlButtons.protein}
disabled={
isFromVectorSelector ||
disableP ||
disableMoleculeNglControlButtons.protein ||
!isPdbAvailable
}
>
P
{loadingProtein && <CircularProgress className={classNames(classes.buttonLoadingOverlay, {
[classes.buttonSelectedLoadingOverlay]: isProteinOn
})} />}
{loadingProtein && (
<CircularProgress
className={classNames(classes.buttonLoadingOverlay, {
[classes.buttonSelectedLoadingOverlay]: isProteinOn
})}
/>
)}
</Button>
</Grid>
</Tooltip>
Expand All @@ -1071,12 +1090,21 @@ const DatasetMoleculeView = memo(
dispatch(setAskLockCompoundsQuestion(true));
onComplex();
}}
disabled={isFromVectorSelector || disableC || disableMoleculeNglControlButtons.complex}
disabled={
isFromVectorSelector ||
disableC ||
disableMoleculeNglControlButtons.complex ||
!isPdbAvailable
}
>
C
{loadingComplex && <CircularProgress className={classNames(classes.buttonLoadingOverlay, {
[classes.buttonSelectedLoadingOverlay]: isComplexOn
})} />}
{loadingComplex && (
<CircularProgress
className={classNames(classes.buttonLoadingOverlay, {
[classes.buttonSelectedLoadingOverlay]: isComplexOn
})}
/>
)}
</Button>
</Grid>
</Tooltip>
Expand All @@ -1091,12 +1119,16 @@ const DatasetMoleculeView = memo(
dispatch(setAskLockCompoundsQuestion(true));
onSurface();
}}
disabled={isFromVectorSelector || disableMoleculeNglControlButtons.surface}
disabled={isFromVectorSelector || disableMoleculeNglControlButtons.surface || !isPdbAvailable}
>
S
{loadingSurface && <CircularProgress className={classNames(classes.buttonLoadingOverlay, {
[classes.buttonSelectedLoadingOverlay]: isSurfaceOn
})} />}
{loadingSurface && (
<CircularProgress
className={classNames(classes.buttonLoadingOverlay, {
[classes.buttonSelectedLoadingOverlay]: isSurfaceOn
})}
/>
)}
</Button>
</Grid>
</Tooltip>
Expand Down Expand Up @@ -1129,9 +1161,13 @@ const DatasetMoleculeView = memo(
disabled={isFromVectorSelector}
>
F
{loadingInspiration && <CircularProgress className={classNames(classes.buttonLoadingOverlay, {
[classes.buttonSelectedLoadingOverlay]: isAnyInspirationOn
})} />}
{loadingInspiration && (
<CircularProgress
className={classNames(classes.buttonLoadingOverlay, {
[classes.buttonSelectedLoadingOverlay]: isAnyInspirationOn
})}
/>
)}
</Button>
</Grid>
</Tooltip>
Expand All @@ -1156,9 +1192,13 @@ const DatasetMoleculeView = memo(
disabled={isFromVectorSelector}
>
X
{loadingReference && <CircularProgress className={classNames(classes.buttonLoadingOverlay, {
// [classes.buttonSelectedLoadingOverlay]: isAnyInspirationOn
})} />}
{loadingReference && (
<CircularProgress
className={classNames(classes.buttonLoadingOverlay, {
// [classes.buttonSelectedLoadingOverlay]: isAnyInspirationOn
})}
/>
)}
</Button>
</Grid>
</Tooltip>
Expand Down Expand Up @@ -1203,10 +1243,10 @@ const DatasetMoleculeView = memo(
null}
</Grid>
)) || (
<Grid item className={classes.rightBorder}>
-
</Grid>
)}
<Grid item className={classes.rightBorder}>
-
</Grid>
)}
</Tooltip>
);
})}
Expand Down
10 changes: 5 additions & 5 deletions js/components/nglView/generatingObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const generateMoleculeObject = (data, colourToggle, datasetID) => ({
name: `${data.code || data.name}_${OBJECT_TYPE.LIGAND}${datasetID ? '_' + datasetID : ''}`,
OBJECT_TYPE: OBJECT_TYPE.LIGAND,
colour: colourToggle,
sdf_info: data.ligand_mol_file,
sdf_info: data.ligand_mol_file || data.sdf_info,
moleculeId: data.id,
selectionType: SELECTION_TYPE.LIGAND
});
Expand Down Expand Up @@ -96,7 +96,7 @@ export const generateHitProteinObject = (data, colourToggle, base_url, datasetID
return {
name: `${data.code || data.name}_${OBJECT_TYPE.HIT_PROTEIN}${datasetID ? '_' + datasetID : ''}`,
OBJECT_TYPE: OBJECT_TYPE.HIT_PROTEIN,
sdf_info: data.ligand_mol_file,
sdf_info: data.ligand_mol_file || data.sdf_info,
colour: colourToggle,
prot_url,
moleculeId: data.id,
Expand All @@ -121,7 +121,7 @@ export const generateComplexObject = (data, colourToggle, base_url, datasetID) =
return {
name: `${data.code || data.name}_${OBJECT_TYPE.COMPLEX}${datasetID ? '_' + datasetID : ''}`,
OBJECT_TYPE: OBJECT_TYPE.COMPLEX,
sdf_info: data.ligand_mol_file,
sdf_info: data.ligand_mol_file || data.sdf_info,
colour: colourToggle,
prot_url,
moleculeId: data.id,
Expand All @@ -145,7 +145,7 @@ export const generateSurfaceObject = (data, colourToggle, base_url, datasetID) =
return {
name: `${data.code || data.name}_${OBJECT_TYPE.SURFACE}${datasetID ? '_' + datasetID : ''}`,
OBJECT_TYPE: OBJECT_TYPE.SURFACE,
sdf_info: data.ligand_mol_file,
sdf_info: data.ligand_mol_file || data.sdf_info,
colour: colourToggle,
prot_url,
moleculeId: data.id,
Expand Down Expand Up @@ -199,7 +199,7 @@ export const generateDensityObject = (data, colourToggle, base_url, isWireframeS
return {
name: `${data.code || data.name}_${OBJECT_TYPE.DENSITY}`,
OBJECT_TYPE: OBJECT_TYPE.DENSITY,
sdf_info: data.ligand_mol_file,
sdf_info: data.ligand_mol_file || data.sdf_info,
event_url,
sigmaa_url,
diff_url,
Expand Down

0 comments on commit e79b49f

Please sign in to comment.