@@ -39,7 +39,8 @@ import {
39
39
getTagCategories ,
40
40
getCompoundsLHS ,
41
41
getCanonSites ,
42
- getCanonConformSites
42
+ getCanonConformSites ,
43
+ getPoses
43
44
} from '../api/tagsApi' ;
44
45
import {
45
46
getMoleculeTagForTag ,
@@ -126,7 +127,7 @@ export const storeData = data => (dispatch, getState) => {
126
127
dispatch ( setTagSelectorData ( categories , tags ) ) ;
127
128
128
129
let allMolecules = [ ] ;
129
- data . molecules . forEach ( mol => { } ) ;
130
+ data . molecules . forEach ( mol => { } ) ;
130
131
} ;
131
132
132
133
export const updateTagProp = ( tag , value , prop ) => ( dispatch , getState ) => {
@@ -192,7 +193,7 @@ export const loadMoleculesAndTagsNew = targetId => async (dispatch, getState) =>
192
193
}
193
194
const tagCategories = await getTagCategories ( ) ;
194
195
// const canonSitesList = await getCanonSites(targetId);
195
- const canonConformSitest = await getCanonConformSites ( targetId ) ;
196
+ // const canonConformSitest = await getCanonConformSites(targetId);
196
197
197
198
const data = await getAllDataNew ( targetId ) ;
198
199
let allMolecules = [ ] ;
@@ -231,59 +232,42 @@ export const loadMoleculesAndTagsNew = targetId => async (dispatch, getState) =>
231
232
dispatch ( setTagSelectorData ( tagCategories , tags ) ) ;
232
233
dispatch ( setAllDataLoaded ( true ) ) ;
233
234
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 ;
280
256
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 ;
283
260
}
261
+ if ( a . code > b . code ) {
262
+ return 1 ;
263
+ }
264
+ return 0 ;
284
265
} ) ;
266
+ newObject [ 'associatedObs' ] = associatedObs ;
267
+
268
+ modifiedPoses . push ( newObject ) ;
285
269
} ) ;
286
- expandedCompounds . sort ( ( a , b ) => {
270
+ modifiedPoses . sort ( ( a , b ) => {
287
271
if ( a . code < b . code ) {
288
272
return - 1 ;
289
273
}
@@ -292,6 +276,6 @@ export const loadMoleculesAndTagsNew = targetId => async (dispatch, getState) =>
292
276
}
293
277
return 0 ;
294
278
} ) ;
295
- dispatch ( setLHSCompoundsLIst ( expandedCompounds ) ) ;
279
+ dispatch ( setLHSCompoundsLIst ( modifiedPoses ) ) ;
296
280
} ) ;
297
281
} ;
0 commit comments