@@ -37,7 +37,7 @@ export default function DashboardLayout({
3737 setRDKit ( rdkitWorker ) ;
3838 setPyodide ( pyodideWorker ) ;
3939 if ( ligand . length < 1 ) {
40- pushNotification ( { "message" : "Data Loading Done!" } ) ;
40+ pushNotification ( { "message" : "Data Loading Done!" } ) ;
4141 router . push ( "/tools/load_data" ) ;
4242 }
4343 } , [ ] ) ;
@@ -55,66 +55,93 @@ export default function DashboardLayout({
5555 } , [ notifications ] ) ;
5656
5757
58- if ( rdkit ) {
59- rdkit . onmessage = ( event ) => {
60- const { message, id, error, ...data } = event . data ;
58+ if ( rdkit ) {
59+ rdkit . onmessage = ( event ) => {
60+ const { message, id, error, ...data } = event . data ;
6161
62- // Handle simple string messages (progress, etc.)
63- if ( message && typeof message === 'string' ) {
64- pushNotification ( { message, autoClose : true , duration : 2000 , id : id || undefined } ) ;
65- return ;
66- }
67-
68- // Handle errors
69- if ( error ) {
70- pushNotification ( { message : `Error: ${ error } ` , type : 'error' } ) ;
71- rdkit . terminate ( ) ;
72- return ;
73- }
62+ // Handle simple string messages (progress, etc.)
63+ if ( message && typeof message === 'string' ) {
64+ pushNotification ( { message, autoClose : true , duration : 2000 , id : id || undefined } ) ;
65+ return ;
66+ }
7467
75- // Handle function results
76- if ( id && data . function ) {
77- switch ( data . function ) {
78- case 'fingerprint' :
79- if ( data . settings ) {
80- localStorage . setItem ( "fingerprint" , data . settings . fingerprint ) ;
81- localStorage . setItem ( "path" , data . settings . radius . toString ( ) ) ;
82- localStorage . setItem ( "nBits" , data . settings . nBits . toString ( ) ) ;
83- }
84- pushNotification ( { message : "Molecule Pre-processing Done! Going to Activity Distribution Tool..." } ) ;
85- setTimeout ( ( ) => {
68+ // Handle errors
69+ if ( error ) {
70+ pushNotification ( { message : `Error: ${ error } ` , type : 'error' } ) ;
71+ rdkit . terminate ( ) ;
72+ return ;
73+ }
74+ // Handle function results
75+ if ( id && data . function ) {
76+
77+ switch ( data . function ) {
78+ case 'fingerprint' :
79+ if ( data . settings ) {
80+ localStorage . setItem ( "fingerprint" , data . settings . fingerprint ) ;
81+ localStorage . setItem ( "path" , data . settings . radius . toString ( ) ) ;
82+ localStorage . setItem ( "nBits" , data . settings . nBits . toString ( ) ) ;
83+ }
84+ pushNotification ( { message : "Molecule Pre-processing Done! Going to Activity Distribution Tool..." } ) ;
85+ setTimeout ( ( ) => {
86+ setLigand ( data . data ) ;
87+ setTarget ( { ...target , activity_columns : data . activity_columns , pre_processed : true } ) ;
88+ router . push ( "/tools/activity" ) ;
89+ } , 200 ) ;
90+ break ;
91+
92+ case 'mma' :
93+ pushNotification ( { message : "Massive Molecular Analysis Done! Going to Scaffold Analysis Tool..." } ) ;
94+ setTarget ( { ...target , scaffCores : data . data } ) ;
95+ break ;
96+
97+ case 'tanimoto' :
98+ pushNotification ( { message : "Tanimoto Similarity Calculation Done!" } ) ;
8699 setLigand ( data . data ) ;
87- setTarget ( { ...target , activity_columns : data . activity_columns , pre_processed : true } ) ;
88- router . push ( "/tools/activity" ) ;
89- } , 200 ) ;
90- break ;
91-
92- case 'mma' :
93- pushNotification ( { message : "Massive Molecular Analysis Done! Going to Scaffold Analysis Tool..." } ) ;
94- setTarget ( { ...target , scaffCores : data . data } ) ;
95- break ;
96-
97- case 'tanimoto' :
98- pushNotification ( { message : "Tanimoto Similarity Calculation Done!" } ) ;
99- setLigand ( data . data ) ;
100- break ;
101-
102- case 'only_fingerprint' :
103- setLigand ( data . results ) ;
104- pushNotification ( { message : "Fingerprints generated successfully!" } ) ;
105- break ;
106-
107- case 'substructure_search' :
108- setLigand ( data . results ) ;
109- pushNotification ( { message : `Found ${ data . results . length } matching substructures` } ) ;
110- break ;
111-
112- default :
113- console . warn ( 'Unknown function:' , data . function ) ;
100+ break ;
101+
102+ case 'only_fingerprint' :
103+ // if (data.id.includes("ml_screen_")) {
104+ // // Handle ML screen fingerprints
105+ // if (data.function === "only_fingerprint") {
106+ // let mol_fp = data.results.map(x => x["fingerprint"]);
107+ // pyodide.postMessage({
108+ // id: "job-123",
109+ // opts: target.machine_learning_inference_type === "regression" ? 1 : 2,
110+ // fp: mol_fp,
111+ // func: "ml-screen"
112+ // })
113+ // pyodide.onmessage = async (event) => {
114+ // console.log("Received message from Pyodide:", event.data);
115+ // if (event.data.success == "ok") {
116+ // let fp_mols = event.data.results;
117+ // newScreenData = await newScreenData.map((x, i) => {
118+ // x["predictions"] = fp_mols[i];
119+ // return x
120+ // });
121+ // setScreenData(newScreenData);
122+ // pushNotification({ message: "ML Model run complete" });
123+ // }
124+ // }
125+ // }
126+ // }
127+ setLigand ( data . results ) ;
128+ pushNotification ( { message : "Fingerprints generated successfully!" } ) ;
129+ break ;
130+
131+ case 'substructure_search' :
132+ setLigand ( data . results ) ;
133+ pushNotification ( { message : `Found ${ data . results . length } matching substructures` } ) ;
134+ break ;
135+ case 'scaffold_network' :
136+ pushNotification ( { message : "Scaffold Network Generation Done!" } ) ;
137+ setTarget ( { ...target , scaffold_network : data . data } ) ;
138+ break ;
139+ default :
140+ console . warn ( 'Unknown function:' , data . function ) ;
141+ }
114142 }
115- }
116- } ;
117- }
143+ } ;
144+ }
118145
119146
120147 if ( pyodide ) {
0 commit comments