BINANA.worker.ts 971 Bytes
Newer Older
jdurrant's avatar
jdurrant committed
1
2
3
4
5
6
7
8
9
10
11
import * as binana from "./binana/binana";

self.onmessage = function(e) {

    // import * as binana from './binana/binana.js';

    let pdbtxt = e.data[0];
    let ligtxt = e.data[1];
    let binanaParams = e.data[2];

    // Save to the fake file system
jdurrant's avatar
jdurrant committed
12
13
    binana["fs"]["save_file"]("receptor.pdb", pdbtxt);
    binana["fs"]["save_file"]("ligand.pdb", ligtxt);
jdurrant's avatar
jdurrant committed
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

    let params = ["-receptor", "receptor.pdb", "-ligand", "ligand.pdb"];

    const binanaParamNames = Object.keys(binanaParams);
    const binanaParamNamesLen = binanaParamNames.length;
    for (let i = 0; i < binanaParamNamesLen; i++) {
        const binanaParamName = binanaParamNames[i];
        const paramVal = binanaParams[binanaParamName];
        params.push("-" + binanaParamName);
        params.push(paramVal);
    }

    binana["run"](params);

    // Get the json output.
jdurrant's avatar
jdurrant committed
29
    let json = binana["fs"]["load_file"]("./ligand_receptor_output.json");
jdurrant's avatar
jdurrant committed
30
31
32
33

    // @ts-ignore
    postMessage(json);
}