| |
|
|
| import { |
| sendResponseToMainThread, |
| waitForDataFromMainThread, |
| } from "@/Core/WebWorkers/WorkerHelper"; |
| |
|
|
| |
| |
| importScripts("fpocketweb/FpocketWeb.min.js"); |
|
|
| |
| |
| |
| |
| |
| |
| function numConvert(s: string): number { |
| return parseFloat(s.split(":")[1].replace("\t", "").trim()); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| function extraInfoTableData(infoTxt: string): any[] { |
| const data = infoTxt.split("\n\n"); |
| const items = []; |
| for (let i = 0; i < data.length; i++) { |
| const tmp = data[i].split("\n"); |
| if (tmp.length > 1) { |
| items.push({ |
| |
| Score: numConvert(tmp[1]), |
| Druggability: numConvert(tmp[2]), |
| "Alpha Spheres": numConvert(tmp[3]), |
| "Total SASA": numConvert(tmp[4]), |
| "Polar SASA": numConvert(tmp[5]), |
| "Apolar SASA": numConvert(tmp[6]), |
| Volume: numConvert(tmp[7]), |
| "Mean Local Hydrophobic Density": numConvert(tmp[8]), |
| "Mean Alpha Sphere Radius": numConvert(tmp[9]), |
| "Mean Alpha Sphere Solvent Access": numConvert(tmp[10]), |
| "Apolar Alpha Sphere Proportion": numConvert(tmp[11]), |
| "Hydrophobicity Score": numConvert(tmp[12]), |
| "Volume Score": numConvert(tmp[13]), |
| "Polarity Score": numConvert(tmp[14]), |
| "Charge Score": numConvert(tmp[15]), |
| "Proportion of Polar Atoms": numConvert(tmp[16]), |
| "Alpha Sphere Density": numConvert(tmp[17]), |
| "Center of Mass, Alpha Sphere Max Distance": numConvert( |
| tmp[18] |
| ), |
| Flexibility: numConvert(tmp[19]), |
| }); |
| } |
| } |
| return items; |
| } |
|
|
| waitForDataFromMainThread() |
| .then((paramsBatch: any[]) => { |
| const responsePromises: Promise<any>[] = []; |
|
|
| for (const params of paramsBatch) { |
| const fPocketParams = params.userArgs; |
|
|
| |
| |
| |
|
|
| responsePromises.push( |
| new Promise((resolve) => { |
| FpocketWeb.start( |
| fPocketParams, |
| params.pdbName, |
| params.pdbContents, |
|
|
| |
| ( |
| outPdbFileTxt: string, |
| stdOut: string, |
| stdErr: string, |
| infoTxt: string |
| ) => { |
| resolve({ |
| outPdbFileTxt, |
| stdOut, |
| stdErr, |
| pocketProps: extraInfoTableData(infoTxt), |
| }); |
| }, |
|
|
| |
| (errObj: any) => { |
| resolve({ |
| error: errObj["message"], |
| }); |
| }, |
|
|
| "fpocketweb/" |
| |
| ); |
| }) |
| ); |
| } |
|
|
| return Promise.all(responsePromises); |
| }) |
| .then((responses: any[]) => { |
| sendResponseToMainThread(responses); |
| return; |
| }) |
| .catch((err: Error) => { |
| throw err; |
| }); |
|
|