Skip to content

Commit f5b27c6

Browse files
FE support for poses (#425)
* #1403 fixed timer when services are not available * #1389 applied tag.hidden logic, reduced autohide time for tags toasts to 5 seconds * Squashed commit of the following: commit 7511b57 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Apr 23 08:27:24 2024 +0200 - finished #1348 commit 6074d79 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Wed Apr 17 09:50:06 2024 +0200 - #1348 - fixed cases when all pdbs are missing commit 49f0ae8 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Wed Apr 10 13:41:50 2024 +0200 - checkpoint commit 13a315e Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Wed Apr 3 12:30:06 2024 +0200 - checkpoint commit a5b8cca Merge: 34b75f7 756a25b Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Mar 25 12:24:01 2024 +0100 Merge branch '#1348' of https://github.com/m2ms/fragalysis-frontend into #1348 commit 34b75f7 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Mar 12 12:35:21 2024 +0100 - latest backend commit 1308cb2 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 1ee15e7 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit a033b68 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 7149081 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 623de4f Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Mar 12 09:48:51 2024 +0100 - using official backend version commit eec204c Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 12:16:45 2024 +0100 - checkpoint commit dbc93a7 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 10:27:08 2024 +0100 - checkpoint commit b933243 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 4a0e171 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 634ed03 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 6e65fae Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 1bff7bf Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 07f21b6 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 021366e Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 36f87b4 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 87e765a Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Mar 12 12:35:21 2024 +0100 - latest backend commit 72c94f0 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 224ca23 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 36f03f8 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 8072920 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit e319056 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Mar 12 09:48:51 2024 +0100 - using official backend version commit 187e7f3 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 12:16:45 2024 +0100 - checkpoint commit b6aa0a4 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 10:27:08 2024 +0100 - checkpoint commit fccf976 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 965be5e Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit b01cdbf Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit e04fbf2 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 5d64c26 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit dbb155c Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit b1c0f3c Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Thu Feb 29 10:32:27 2024 +0100 - checkpoint commit abc8cc9 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 2ef004a Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 756a25b Merge: f686ef4 f474ff6 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Thu Mar 14 10:00:02 2024 +0100 Merge branch '#1348' of https://github.com/m2ms/fragalysis-frontend into #1348 commit f686ef4 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Mar 12 12:35:21 2024 +0100 - latest backend commit df6209c Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit f5a842f Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 83ffccc Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 0ecff35 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit d3a90c7 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Mar 12 09:48:51 2024 +0100 - using official backend version commit 50800b9 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 12:16:45 2024 +0100 - checkpoint commit 2af18fd Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 10:27:08 2024 +0100 - checkpoint commit cd75a27 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit c485389 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 96296e9 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 760152b Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 8a30204 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 6235e9c Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit e2e46cb Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Thu Feb 29 10:32:27 2024 +0100 - checkpoint commit 8176514 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 6aa5108 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit f474ff6 Merge: 56c0b85 e728f49 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Thu Mar 14 08:30:00 2024 +0100 Merge branch '#1348' of https://github.com/m2ms/fragalysis-frontend into #1348 # Conflicts: # js/components/preview/tags/details/tagDetails.js commit 56c0b85 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit a185933 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 09c97b5 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit c6d0738 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 72f36b0 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Thu Feb 29 10:32:27 2024 +0100 - checkpoint commit 971799d Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 1bb5326 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit e728f49 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Mar 12 12:35:21 2024 +0100 - latest backend commit 125b8d4 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit 0e41551 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 8cf43e0 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit d336352 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint commit 2fb59dc Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Mar 12 09:48:51 2024 +0100 - using official backend version commit 9439f5d Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Thu Mar 7 13:59:03 2024 +0100 - partial fix for purple release for #1370 commit 4ff5f94 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Thu Mar 7 10:10:41 2024 +0100 - implemented #1376 - also fixed bug in download structures dialog where only first download got added to the dropdown menu commit 66a98f3 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Wed Mar 6 09:47:12 2024 +0100 - implemented #1361 - improvements for #1354 commit 8a193a5 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Mar 5 13:24:11 2024 +0100 - cleanup for #1354 commit bb3bf3b Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Mar 5 13:21:32 2024 +0100 - updated message for #1354 commit a3dc819 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Mar 5 13:05:12 2024 +0100 - first implementation of #1354 commit 4121519 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Mar 5 08:17:49 2024 +0100 - implemented #1357 commit 4d96ff4 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Mar 4 10:07:06 2024 +0100 - implemented changes requested in #1326 commit 03158be Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Mar 4 08:45:22 2024 +0100 - fixed problem with tags not visually updating on observations commit 8765a3c Author: matej <matej.vavrek@m2ms.sk> Date: Mon Feb 26 21:36:12 2024 +0100 #1341 "pin" edit tag row outside of tag list commit 6db8b22 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Thu Feb 29 10:32:27 2024 +0100 - checkpoint commit 027eaf0 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 12:16:45 2024 +0100 - checkpoint commit 7407dbd Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 10:27:08 2024 +0100 - checkpoint commit c13628b Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Feb 27 09:23:04 2024 +0100 - checkpoint commit e39721c Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Feb 26 08:42:49 2024 +0100 - checkpoint * - using official backend now * Squashed commit of the following: commit 8fe886a Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Wed May 15 09:00:04 2024 +0200 Squashed commit of the following: commit 6813219 Author: matej <matej.vavrek@m2ms.sk> Date: Mon Apr 29 07:38:30 2024 +0200 #1261 added icon for "Manage grouping" button commit a665ed5 Author: matej <matej.vavrek@m2ms.sk> Date: Sun Apr 28 23:23:25 2024 +0200 #1261 added buttons into observation dialog for later poses handling commit 70a5e70 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Mon Apr 29 09:20:46 2024 +0200 - #1261 - initial implementation --------- Co-authored-by: matej <matej.vavrek@m2ms.sk>
1 parent 67200eb commit f5b27c6

17 files changed

+610
-98
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { api } from '../../../../utils/api';
2+
import { base_url } from '../../../routes/constants';
3+
4+
const POSE_ERROR_LABEL_TRANSLATOR = {
5+
id: 'Identificator of the pose',
6+
display_name: 'Display name of the pose',
7+
canon_site: 'Canonical site of the pose',
8+
compound: 'Compound of the pose',
9+
main_site_observation: 'Main observation of the pose',
10+
site_observations: 'All observations of the pose',
11+
main_site_observation_cmpd_code: 'Main observation compound code'
12+
};
13+
14+
export const updatePoseApi = async pose => {
15+
return api({ url: `${base_url}/api/poses/${pose.id}/`, method: 'PATCH', data: pose });
16+
};
17+
18+
export const createPoseApi = async pose => {
19+
return api({ url: `${base_url}/api/poses/`, method: 'POST', data: pose }).then(response => response.data);
20+
};
21+
22+
export const createPoseErrorMessage = error => {
23+
let result = null;
24+
25+
if (error?.response?.data) {
26+
const fields = Object.keys(error.response.data);
27+
const errorMessages = [];
28+
let i = 0;
29+
30+
fields.forEach(field => {
31+
if (Array.isArray(error.response.data[field])) {
32+
const arrayOfErrors = error.response.data[field];
33+
if (arrayOfErrors.length > 0) {
34+
errorMessages[i++] = `${POSE_ERROR_LABEL_TRANSLATOR[field]}:` + '\n';
35+
}
36+
arrayOfErrors.forEach(errorMsg => {
37+
errorMessages[i++] = errorMsg + '\n';
38+
});
39+
}
40+
});
41+
42+
if (errorMessages) {
43+
result = errorMessages.join('');
44+
}
45+
}
46+
47+
return result;
48+
};

js/components/preview/molecule/moleculeList.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ export const MoleculeList = memo(({ hideProjects }) => {
295295
const categories = useSelector(state => state.apiReducers.categoryList);
296296

297297
const proteinsHasLoaded = useSelector(state => state.nglReducers.proteinsHasLoaded);
298-
const currentActionList = useSelector(state => state.trackingReducers.current_actions_list);
299298

300299
const [predefinedFilter, setPredefinedFilter] = useState(filter !== undefined ? filter.predefined : DEFAULT_FILTER);
301300

js/components/preview/molecule/moleculeView/moleculeView.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,15 @@ const useStyles = makeStyles(theme => ({
164164
textOverflow: 'ellipsis',
165165
lineHeight: '1.45'
166166
},
167+
moleculeTitleLabelMainObs: {
168+
...theme.typography.button,
169+
overflow: 'hidden',
170+
whiteSpace: 'nowrap',
171+
textOverflow: 'ellipsis',
172+
lineHeight: '1.45',
173+
fontWeight: '900',
174+
fontStyle: 'italic'
175+
},
167176
checkbox: {
168177
padding: 0
169178
},
@@ -367,6 +376,7 @@ const MoleculeView = memo(
367376
const hasAdditionalInformation = I;
368377

369378
const allMolecules = useSelector(state => state.apiReducers.all_mol_lists);
379+
const allPoses = useSelector(state => state.apiReducers.lhs_compounds_list);
370380

371381
//for some reason when tags are changed for this molecule the data are stale so I need to retrieve them from list of all molecules
372382
data = allMolecules.filter(mol => mol.id === data.id)[0];
@@ -384,6 +394,8 @@ const MoleculeView = memo(
384394

385395
const colourToggle = getRandomColor(data);
386396

397+
const pose = useMemo(() => allPoses.find(p => p.id === data.pose), [allPoses, data]);
398+
387399
const getCalculatedProps = useCallback(
388400
() => [
389401
// { name: moleculeProperty.mw, value: data.mw ?? 0 },
@@ -1020,7 +1032,11 @@ const MoleculeView = memo(
10201032
e.preventDefault();
10211033
setNameCopied(moleculeTitle);
10221034
}}
1023-
className={classes.moleculeTitleLabel}
1035+
className={
1036+
data.id === pose?.main_site_observation
1037+
? classes.moleculeTitleLabelMainObs
1038+
: classes.moleculeTitleLabel
1039+
}
10241040
>
10251041
{moleculeTitleTruncated}
10261042
</div>

js/components/preview/molecule/observationCmpList.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ export const ObservationCmpList = memo(({ hideProjects }) => {
701701
let filteredLHSCompoundsList = useMemo(() => {
702702
const compounds = [];
703703
lhsCompoundsList.forEach(compound => {
704-
const molsForCmp = joinedMoleculeLists.some(molecule => molecule.cmpd === compound.origId);
704+
const molsForCmp = joinedMoleculeLists.some(molecule => molecule.cmpd === compound.compound);
705705
if (molsForCmp && compound.associatedObs.some(obs => joinedMoleculeLists.some(mol => mol.id === obs.id))) {
706706
compounds.push(compound);
707707
}
@@ -712,7 +712,7 @@ export const ObservationCmpList = memo(({ hideProjects }) => {
712712
useEffect(() => {
713713
if (isObservationDialogOpen && observationsForLHSCmp?.length > 0) {
714714
const cmpId = observationsForLHSCmp[0].cmpd;
715-
const cmp = filteredLHSCompoundsList.find(c => c.origId === cmpId);
715+
const cmp = filteredLHSCompoundsList.find(c => c.compound === cmpId);
716716
if (!cmp) {
717717
dispatch(setObservationsForLHSCmp([]));
718718
dispatch(setOpenObservationsDialog(false));
@@ -1214,9 +1214,6 @@ export const ObservationCmpList = memo(({ hideProjects }) => {
12141214
>
12151215
{filteredLHSCompoundsList.map((data, index, array) => {
12161216
const molsForCmp = data.associatedObs;
1217-
// const selected = allSelectedMolecules.some(
1218-
// molecule => molecule.cmpd === data.origId && molecule.canon_site_conf === data.canonSiteConf
1219-
// );
12201217
const selected = allSelectedMolecules.some(molecule =>
12211218
data.associatedObs.some(obs => obs.id === molecule.id)
12221219
);

js/components/preview/molecule/observationCmpView/observationCmpView.js

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ import {
4343
removeFromMolListToEdit,
4444
setOpenObservationsDialog,
4545
setObservationsForLHSCmp,
46-
setIsLHSCmpTagEdit
46+
setIsLHSCmpTagEdit,
47+
setPoseIdForObservationsDialog
4748
} from '../../../../reducers/selection/actions';
4849
import { moleculeProperty } from '../helperConstants';
4950
import { centerOnLigandByMoleculeID } from '../../../../reducers/ngl/dispatchActions';
@@ -387,15 +388,23 @@ const ObservationCmpView = memo(
387388
const { getNglView } = useContext(NglContext);
388389
const stage = getNglView(VIEWS.MAJOR_VIEW) && getNglView(VIEWS.MAJOR_VIEW).stage;
389390

390-
const getFirstObservation = useCallback(() => {
391+
const poseIdForObservationsDialog = useSelector(state => state.selectionReducers.poseIdForObservationsDialog);
392+
393+
useEffect(() => {
394+
if (isObservationDialogOpen && poseIdForObservationsDialog === currentID) {
395+
dispatch(setObservationsForLHSCmp(observations));
396+
}
397+
}, [observations, isObservationDialogOpen, dispatch, poseIdForObservationsDialog, currentID]);
398+
399+
const getMainObservation = useCallback(() => {
391400
let result = null;
392401

393-
if (observations && observations.length > 0) {
394-
result = observations[0];
402+
if (observations && observations.length > 0 && data.main_site_observation) {
403+
result = observations.find(o => o.id === data.main_site_observation);
395404
}
396405

397406
return result;
398-
}, [observations]);
407+
}, [data, observations]);
399408

400409
const getAllObservationsSelectedInList = list => {
401410
let result = [];
@@ -481,7 +490,7 @@ const ObservationCmpView = memo(
481490
const disableMoleculeNglControlButtons =
482491
useSelector(state => state.previewReducers.molecule.disableNglControlButtons[currentID]) || {};
483492

484-
const colourToggle = getRandomColor(getFirstObservation());
493+
const colourToggle = getRandomColor(getMainObservation());
485494

486495
const getCalculatedProps = useCallback(
487496
() => [
@@ -808,11 +817,11 @@ const ObservationCmpView = memo(
808817

809818
// componentDidMount
810819
useEffect(() => {
811-
const obs = getFirstObservation();
820+
const obs = getMainObservation();
812821
dispatch(getMolImage(obs.id, MOL_TYPE.HIT, imageWidth, imageHeight)).then(i => {
813822
setImg_data(i);
814823
});
815-
}, [data.id, data.smiles, imageHeight, imageWidth, dispatch, getFirstObservation]);
824+
}, [data.id, data.smiles, imageHeight, imageWidth, dispatch, getMainObservation]);
816825

817826
useEffect(() => {
818827
dispatch(getQualityInformation(data));
@@ -846,7 +855,7 @@ const ObservationCmpView = memo(
846855
// }
847856
dispatch(
848857
withDisabledMoleculeNglControlButton(currentID, 'ligand', async () => {
849-
const firstObs = getFirstObservation();
858+
const firstObs = getMainObservation();
850859
if (firstObs) {
851860
const color = getRandomColor(firstObs);
852861
await dispatch(addLigand(stage, firstObs, color, false, true, skipTracking));
@@ -898,7 +907,7 @@ const ObservationCmpView = memo(
898907
// }
899908
dispatch(
900909
withDisabledMoleculeNglControlButton(currentID, 'protein', async () => {
901-
const firstObs = getFirstObservation();
910+
const firstObs = getMainObservation();
902911
if (firstObs) {
903912
const color = getRandomColor(firstObs);
904913
await dispatch(addHitProtein(stage, firstObs, color, true, skipTracking));
@@ -938,7 +947,7 @@ const ObservationCmpView = memo(
938947
const addNewComplex = (skipTracking = false) => {
939948
dispatch(
940949
withDisabledMoleculeNglControlButton(currentID, 'complex', async () => {
941-
const firstObs = getFirstObservation();
950+
const firstObs = getMainObservation();
942951
if (firstObs) {
943952
const color = getRandomColor(firstObs);
944953
await dispatch(addComplex(stage, firstObs, color, skipTracking));
@@ -977,7 +986,7 @@ const ObservationCmpView = memo(
977986
const addNewSurface = () => {
978987
dispatch(
979988
withDisabledMoleculeNglControlButton(currentID, 'surface', async () => {
980-
const firstObs = getFirstObservation();
989+
const firstObs = getMainObservation();
981990
if (firstObs) {
982991
const color = getRandomColor(firstObs);
983992
await dispatch(addSurface(stage, firstObs, color));
@@ -1056,7 +1065,7 @@ const ObservationCmpView = memo(
10561065
const addNewQuality = () => {
10571066
dispatch(
10581067
withDisabledMoleculeNglControlButton(currentID, 'ligand', async () => {
1059-
const firstObs = getFirstObservation();
1068+
const firstObs = getMainObservation();
10601069
if (firstObs) {
10611070
const color = getRandomColor(firstObs);
10621071
await dispatch(addQuality(stage, firstObs, color));
@@ -1083,7 +1092,7 @@ const ObservationCmpView = memo(
10831092
const addNewVector = () => {
10841093
dispatch(
10851094
withDisabledMoleculeNglControlButton(currentID, 'vector', async () => {
1086-
const firstObs = getFirstObservation();
1095+
const firstObs = getMainObservation();
10871096
if (firstObs) {
10881097
await dispatch(addVector(stage, firstObs));
10891098
}
@@ -1185,7 +1194,8 @@ const ObservationCmpView = memo(
11851194
const result = e.target.checked;
11861195
if (result) {
11871196
if (observations?.length > 0) {
1188-
dispatch(appendToMolListToEdit(observations[0].id));
1197+
const mainObs = getMainObservation();
1198+
mainObs && dispatch(appendToMolListToEdit(mainObs.id));
11891199
}
11901200
// dispatch(appendToObsCmpListToEdit(currentID));
11911201
} else {
@@ -1233,7 +1243,7 @@ const ObservationCmpView = memo(
12331243
variant="outlined"
12341244
className={classes.myLocationButton}
12351245
onClick={() => {
1236-
dispatch(centerOnLigandByMoleculeID(stage, getFirstObservation()?.id));
1246+
dispatch(centerOnLigandByMoleculeID(stage, getMainObservation()?.id));
12371247
}}
12381248
disabled={false || !isLigandOn}
12391249
>
@@ -1427,6 +1437,7 @@ const ObservationCmpView = memo(
14271437
dispatch(setObservationsForLHSCmp(observations));
14281438
}
14291439
dispatch(setOpenObservationsDialog(!isObservationDialogOpen));
1440+
dispatch(setPoseIdForObservationsDialog(data.id));
14301441

14311442
if (setRef) {
14321443
setRef(ref.current);

0 commit comments

Comments
 (0)