Skip to content

Commit 70a5e70

Browse files
- #1261 - initial implementation
1 parent e76b303 commit 70a5e70

File tree

5 files changed

+59
-70
lines changed

5 files changed

+59
-70
lines changed

docker-compose.dev.vector.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ services:
5353
start_period: 10s
5454
web:
5555
container_name: web_dock
56-
image: xchem/fragalysis-stack:latest
56+
# image: xchem/fragalysis-stack:latest
5757
# image: alanbchristie/fragalysis-backend:1187.3
5858
# image: boriskovarm2ms/fragalysis-stack:experiment2
59-
# image: kaliif/fragalysis-backend:latest
59+
image: kaliif/fragalysis-backend:latest
6060
command: /bin/bash /code/launch-stack.sh
6161
volumes:
6262
- ../data/logs:/code/logs/

js/components/preview/molecule/observationCmpList.js

+2-5
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/tags/api/tagsApi.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ export const getCanonConformSites = async targetId => {
5151
});
5252
};
5353

54-
export const getCompoundsLHS = async targetId => {
55-
return api({ url: `${base_url}/api/cmpdimg/?target=${targetId}` }).then(response => {
54+
export const getPoses = async targetId => {
55+
return api({ url: `${base_url}/api/poses/?target=${targetId}` }).then(response => {
5656
if (response?.data) {
5757
return response.data?.results;
5858
}

js/components/preview/tags/modal/tagEditor.js

+16-8
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,18 @@ export const TagEditor = memo(
144144
}
145145

146146
const moleculesToEdit = moleculesToEditIds.map(id => dispatch(getMoleculeForId(id)));
147-
let lhsCmp = null;
148-
if (moleculesToEdit?.length > 0) {
149-
const firstMolToEdit = moleculesToEdit[0];
150-
const cmpId = firstMolToEdit.cmpd;
151-
lhsCmp = lhsCompounds?.find(c => c.origId === cmpId && firstMolToEdit.canon_site_conf === c.canonSiteConf);
152-
}
147+
let poses = [];
148+
moleculesToEdit?.forEach(m => {
149+
const pose = lhsCompounds.find(p => p.site_observations.includes(m.id));
150+
if (pose && !poses.find(p => p.id === pose.id)) {
151+
poses.push(pose);
152+
}
153+
});
154+
// if (moleculesToEdit?.length > 0) {
155+
// const firstMolToEdit = moleculesToEdit[0];
156+
// const cmpId = firstMolToEdit.cmpd;
157+
// lhsCmp = lhsCompounds?.find(c => c.compound === cmpId && firstMolToEdit.canon_site_conf === c.canonSiteConf);
158+
// }
153159
moleculeTags = moleculeTags.sort(compareTagsAsc);
154160
const assignTagEditorOpen = useSelector(state => state.selectionReducers.tagEditorOpened);
155161

@@ -206,7 +212,8 @@ export const TagEditor = memo(
206212
moleculesToEdit.forEach(m => {
207213
let newMol = { ...m };
208214
newMol.tags_set = newMol.tags_set.filter(id => id !== tag.id);
209-
updateCmp(lhsCmp, newMol);
215+
const pose = poses.find(p => p.site_observations.includes(m.id));
216+
updateCmp(pose, newMol);
210217
dispatch(updateMoleculeInMolLists(newMol));
211218
const moleculeTag = getMoleculeTagForTag(moleculeTags, tag.id);
212219

@@ -235,7 +242,8 @@ export const TagEditor = memo(
235242
if (!m.tags_set.some(id => id === tag.id)) {
236243
let newMol = { ...m };
237244
newMol.tags_set.push(tag.id);
238-
updateCmp(lhsCmp, newMol);
245+
const pose = poses.find(p => p.site_observations.includes(m.id));
246+
updateCmp(pose, newMol);
239247
dispatch(updateMoleculeInMolLists(newMol));
240248
const moleculeTag = getMoleculeTagForTag(moleculeTags, tag.id);
241249
let mtObject = molTagObjects.find(mto => mto.tag === tag.tag);

js/components/preview/tags/redux/dispatchActions.js

+37-53
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ import {
3939
getTagCategories,
4040
getCompoundsLHS,
4141
getCanonSites,
42-
getCanonConformSites
42+
getCanonConformSites,
43+
getPoses
4344
} from '../api/tagsApi';
4445
import {
4546
getMoleculeTagForTag,
@@ -126,7 +127,7 @@ export const storeData = data => (dispatch, getState) => {
126127
dispatch(setTagSelectorData(categories, tags));
127128

128129
let allMolecules = [];
129-
data.molecules.forEach(mol => { });
130+
data.molecules.forEach(mol => {});
130131
};
131132

132133
export const updateTagProp = (tag, value, prop) => (dispatch, getState) => {
@@ -192,7 +193,7 @@ export const loadMoleculesAndTagsNew = targetId => async (dispatch, getState) =>
192193
}
193194
const tagCategories = await getTagCategories();
194195
// const canonSitesList = await getCanonSites(targetId);
195-
const canonConformSitest = await getCanonConformSites(targetId);
196+
// const canonConformSitest = await getCanonConformSites(targetId);
196197

197198
const data = await getAllDataNew(targetId);
198199
let allMolecules = [];
@@ -231,59 +232,42 @@ export const loadMoleculesAndTagsNew = targetId => async (dispatch, getState) =>
231232
dispatch(setTagSelectorData(tagCategories, tags));
232233
dispatch(setAllDataLoaded(true));
233234

234-
return getCompoundsLHS(targetId).then(compounds => {
235-
const expandedCompounds = [];
236-
let newIdStart = Math.max(...compounds?.map(c => c.id)) + 1;
237-
compounds?.forEach(c => {
238-
const siteObs = allMolecules.filter(m => m.cmpd === c.id);
239-
const canonConformSites = siteObs?.map(so => {
240-
return {
241-
smiles: so.smiles,
242-
code: so.code,
243-
canon_site_conf: so.canon_site_conf,
244-
canon_site: canonConformSitest.find(ccf => ccf.id === so.canon_site_conf)?.canon_site
245-
};
246-
});
247-
canonConformSites?.forEach(cs => {
248-
let newObject = { ...c };
249-
250-
newObject['smiles'] = cs.smiles;
251-
// newObject['code'] = `${cs.code}/${cs.canon_site}`;
252-
newObject['code'] = `${cs.code}`;
253-
newObject['origId'] = c.id;
254-
newObject['id'] = newIdStart++;
255-
newObject['canonSiteConf'] = cs.canon_site_conf;
256-
newObject['canonSite'] = cs.canon_site;
257-
258-
const associatedObs = siteObs
259-
.filter(
260-
so =>
261-
canonConformSitest.find(ccf => ccf.id === so.canon_site_conf)?.canon_site === newObject.canonSite &&
262-
so.cmpd === c.id
263-
)
264-
.map(so => {
265-
return {
266-
...so,
267-
canon_site: canonConformSitest.find(ccf => ccf.id === so.canon_site_conf)?.canon_site
268-
};
269-
})
270-
.sort((a, b) => {
271-
if (a.code < b.code) {
272-
return -1;
273-
}
274-
if (a.code > b.code) {
275-
return 1;
276-
}
277-
return 0;
278-
});
279-
newObject['associatedObs'] = associatedObs;
235+
return getPoses(targetId).then(poses => {
236+
const modifiedPoses = [];
237+
// let newIdStart = Math.max(...poses?.map(c => c.id)) + 1;
238+
poses?.forEach(pose => {
239+
const siteObs = allMolecules.filter(m => pose.site_observations.includes(m.id));
240+
const firstObs = siteObs[0];
241+
// const canonConformSites = siteObs?.map(so => {
242+
// return {
243+
// smiles: so.smiles,
244+
// code: so.code,
245+
// canon_site_conf: so.canon_site_conf,
246+
// canon_site: canonConformSitest.find(ccf => ccf.id === so.canon_site_conf)?.canon_site
247+
// };
248+
// });
249+
let newObject = { ...pose };
250+
newObject['smiles'] = firstObs?.smiles;
251+
newObject['code'] = `${pose.display_name}`;
252+
// newObject['id'] = newIdStart++;
253+
// newObject['origId'] = pose.id;
254+
newObject['canonSiteConf'] = firstObs?.canon_site_conf;
255+
newObject['canonSite'] = pose.canon_site;
280256

281-
if (!expandedCompounds.find(ec => ec.origId === newObject.origId && ec.canonSite === newObject.canonSite)) {
282-
expandedCompounds.push(newObject);
257+
const associatedObs = siteObs.sort((a, b) => {
258+
if (a.code < b.code) {
259+
return -1;
283260
}
261+
if (a.code > b.code) {
262+
return 1;
263+
}
264+
return 0;
284265
});
266+
newObject['associatedObs'] = associatedObs;
267+
268+
modifiedPoses.push(newObject);
285269
});
286-
expandedCompounds.sort((a, b) => {
270+
modifiedPoses.sort((a, b) => {
287271
if (a.code < b.code) {
288272
return -1;
289273
}
@@ -292,6 +276,6 @@ export const loadMoleculesAndTagsNew = targetId => async (dispatch, getState) =>
292276
}
293277
return 0;
294278
});
295-
dispatch(setLHSCompoundsLIst(expandedCompounds));
279+
dispatch(setLHSCompoundsLIst(modifiedPoses));
296280
});
297281
};

0 commit comments

Comments
 (0)