moorhen 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/baby-gru/CootWorker.js +1071 -0
- package/baby-gru/darkly.css +12 -0
- package/baby-gru/flatly.css +12 -0
- package/baby-gru/keyboard-blank.svg +3126 -0
- package/baby-gru/monomers/a/A.cif +271 -0
- package/baby-gru/monomers/a/ALA.cif +164 -0
- package/baby-gru/monomers/a/ARG.cif +252 -0
- package/baby-gru/monomers/a/ASN.cif +192 -0
- package/baby-gru/monomers/a/ASP.cif +178 -0
- package/baby-gru/monomers/c/C.cif +255 -0
- package/baby-gru/monomers/c/CIT.cif +167 -0
- package/baby-gru/monomers/c/CYS.cif +169 -0
- package/baby-gru/monomers/d/DA.cif +266 -0
- package/baby-gru/monomers/d/DC.cif +250 -0
- package/baby-gru/monomers/d/DG.cif +271 -0
- package/baby-gru/monomers/d/DT.cif +256 -0
- package/baby-gru/monomers/e/EDO.cif +108 -0
- package/baby-gru/monomers/g/G.cif +276 -0
- package/baby-gru/monomers/g/GLN.cif +208 -0
- package/baby-gru/monomers/g/GLU.cif +194 -0
- package/baby-gru/monomers/g/GLY.cif +138 -0
- package/baby-gru/monomers/g/GOL.cif +134 -0
- package/baby-gru/monomers/h/HIS.cif +215 -0
- package/baby-gru/monomers/h/HOH.cif +55 -0
- package/baby-gru/monomers/i/ILE.cif +213 -0
- package/baby-gru/monomers/l/LEU.cif +213 -0
- package/baby-gru/monomers/l/LYS.cif +228 -0
- package/baby-gru/monomers/m/MET.cif +201 -0
- package/baby-gru/monomers/m/MSE.cif +201 -0
- package/baby-gru/monomers/n/NA.cif +30 -0
- package/baby-gru/monomers/p/PHE.cif +233 -0
- package/baby-gru/monomers/p/PO4.cif +86 -0
- package/baby-gru/monomers/p/PRO.cif +188 -0
- package/baby-gru/monomers/s/SER.cif +169 -0
- package/baby-gru/monomers/s/SO4.cif +86 -0
- package/baby-gru/monomers/t/THR.cif +186 -0
- package/baby-gru/monomers/t/TRP.cif +263 -0
- package/baby-gru/monomers/t/TYR.cif +238 -0
- package/baby-gru/monomers/u/U.cif +248 -0
- package/baby-gru/monomers/v/VAL.cif +197 -0
- package/baby-gru/pixmaps/MoorhenLogo.png +0 -0
- package/baby-gru/pixmaps/add-alt-conf.svg +127 -0
- package/baby-gru/pixmaps/add-peptide-1.svg +257 -0
- package/baby-gru/pixmaps/atom-at-pointer.svg +91 -0
- package/baby-gru/pixmaps/auto-fit-rotamer.svg +118 -0
- package/baby-gru/pixmaps/cis-trans.svg +392 -0
- package/baby-gru/pixmaps/delete.svg +94 -0
- package/baby-gru/pixmaps/diff-map.png +0 -0
- package/baby-gru/pixmaps/drag.svg +253 -0
- package/baby-gru/pixmaps/edit-chi.svg +303 -0
- package/baby-gru/pixmaps/flip-peptide.svg +169 -0
- package/baby-gru/pixmaps/jed-flip-reverse.svg +286 -0
- package/baby-gru/pixmaps/map.svg +114 -0
- package/baby-gru/pixmaps/mutate.svg +111 -0
- package/baby-gru/pixmaps/rama-plot-gly-normal.png +0 -0
- package/baby-gru/pixmaps/rama-plot-gly-outlier.png +0 -0
- package/baby-gru/pixmaps/rama-plot-other-normal.png +0 -0
- package/baby-gru/pixmaps/rama-plot-other-outlier.png +0 -0
- package/baby-gru/pixmaps/rama-plot-pro-normal.png +0 -0
- package/baby-gru/pixmaps/rama-plot-pro-outlier.png +0 -0
- package/baby-gru/pixmaps/rama2_all.png +0 -0
- package/baby-gru/pixmaps/rama2_gly.png +0 -0
- package/baby-gru/pixmaps/rama2_ileval.png +0 -0
- package/baby-gru/pixmaps/rama2_non_gly_pro.png +0 -0
- package/baby-gru/pixmaps/rama2_non_gly_pro_pre_pro_ileval.png +0 -0
- package/baby-gru/pixmaps/rama2_pre_pro.png +0 -0
- package/baby-gru/pixmaps/rama2_pro.png +0 -0
- package/baby-gru/pixmaps/refine-1.svg +140 -0
- package/baby-gru/pixmaps/rigid-body.svg +124 -0
- package/baby-gru/pixmaps/rotamers.svg +78 -0
- package/baby-gru/pixmaps/rtz.svg +281 -0
- package/baby-gru/pixmaps/side-chain-180.svg +129 -0
- package/baby-gru/pixmaps/spin-view.svg +104 -0
- package/baby-gru/pixmaps/temperature.svg +92 -0
- package/baby-gru/tutorials/NUT.cif +453 -0
- package/baby-gru/tutorials/legend.html +3 -0
- package/baby-gru/tutorials/moorhen-tutorial-map-number-1.mtz +0 -0
- package/baby-gru/tutorials/moorhen-tutorial-map-number-2.mtz +0 -0
- package/baby-gru/tutorials/moorhen-tutorial-map-number-3.mtz +0 -0
- package/baby-gru/tutorials/moorhen-tutorial-map-number-4.mtz +0 -0
- package/baby-gru/tutorials/moorhen-tutorial-structure-number-1.pdb +2211 -0
- package/baby-gru/tutorials/moorhen-tutorial-structure-number-2.pdb +2018 -0
- package/baby-gru/tutorials/moorhen-tutorial-structure-number-3.pdb +1090 -0
- package/baby-gru/tutorials/moorhen-tutorial-structure-number-4.pdb +2801 -0
- package/baby-gru/wasm/RDKit_minimal.js +21 -0
- package/baby-gru/wasm/RDKit_minimal.wasm +0 -0
- package/baby-gru/wasm/cif_pdb_worker.js +33 -0
- package/baby-gru/wasm/coot_env_web.js +5 -0
- package/baby-gru/wasm/crystallography_worker.js +610 -0
- package/baby-gru/wasm/mini_rsr_worker.js +72 -0
- package/baby-gru/wasm/monid_to_pdb_worker.js +253 -0
- package/baby-gru/wasm/moorhen.data +246292 -0
- package/baby-gru/wasm/moorhen.js +21 -0
- package/baby-gru/wasm/moorhen.wasm +0 -0
- package/baby-gru/wasm/moorhen.worker.js +1 -0
- package/baby-gru/wasm/mtz_arraybuffer_worker.js +59 -0
- package/baby-gru/wasm/mtz_worker.js +45 -0
- package/baby-gru/wasm/nma_worker.js +103 -0
- package/baby-gru/wasm/papaparse.min.js +7 -0
- package/baby-gru/wasm/pdb_worker.js +282 -0
- package/baby-gru/wasm/smiles_to_pdb_worker.js +252 -0
- package/baby-gru/wasm/superpose_worker.js +144 -0
- package/baby-gru/wasm/web_example.js +21 -0
- package/baby-gru/wasm/web_example.wasm +0 -0
- package/moorhen.css +418 -0
- package/package.json +176 -0
|
@@ -0,0 +1,1071 @@
|
|
|
1
|
+
importScripts('./wasm/moorhen.js')
|
|
2
|
+
importScripts('./wasm/web_example.js')
|
|
3
|
+
|
|
4
|
+
let cootModule;
|
|
5
|
+
let molecules_container;
|
|
6
|
+
let ccp4Module;
|
|
7
|
+
|
|
8
|
+
const guid = () => {
|
|
9
|
+
var d = Date.now();
|
|
10
|
+
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
11
|
+
var r = (d + Math.random() * 16) % 16 | 0;
|
|
12
|
+
d = Math.floor(d / 16);
|
|
13
|
+
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
|
|
14
|
+
});
|
|
15
|
+
return uuid;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let print = (stuff) => {
|
|
19
|
+
console.log(stuff)
|
|
20
|
+
postMessage({ consoleMessage: JSON.stringify(stuff) })
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const instancedMeshToMeshData = (instanceMesh, perm, toSpheres = false, maxZSize = 10000.) => {
|
|
24
|
+
//maxZSize is arguably a hack to deal with overlong bonds. It is set to 5 incall to this function.
|
|
25
|
+
|
|
26
|
+
let totIdxs = []
|
|
27
|
+
let totPos = []
|
|
28
|
+
let totNorm = []
|
|
29
|
+
let totInstance_sizes = []
|
|
30
|
+
let totInstance_colours = []
|
|
31
|
+
let totInstance_origins = []
|
|
32
|
+
let totInstance_orientations = []
|
|
33
|
+
let totInstanceUseColours = []
|
|
34
|
+
let totInstancePrimTypes = []
|
|
35
|
+
|
|
36
|
+
const geom = instanceMesh.geom
|
|
37
|
+
const markup = instanceMesh.markup
|
|
38
|
+
const geomSize = geom.size()
|
|
39
|
+
for (let i = 0; i < geomSize; i++) {
|
|
40
|
+
let thisToSpheres = toSpheres;
|
|
41
|
+
let thisIdxs = []
|
|
42
|
+
let thisPos = []
|
|
43
|
+
let thisNorm = []
|
|
44
|
+
let thisInstance_sizes = []
|
|
45
|
+
let thisInstance_colours = []
|
|
46
|
+
let thisInstance_origins = []
|
|
47
|
+
let thisInstance_orientations = []
|
|
48
|
+
const inst = geom.get(i);
|
|
49
|
+
if (inst.name === "spherical-atoms") thisToSpheres = true;
|
|
50
|
+
const vertices = inst.vertices;
|
|
51
|
+
const triangles = inst.triangles;
|
|
52
|
+
const trianglesSize = triangles.size()
|
|
53
|
+
for (let i = 0; i < trianglesSize; i++) {
|
|
54
|
+
const triangle = triangles.get(i)
|
|
55
|
+
const idxs = triangle.point_id
|
|
56
|
+
if (perm) {
|
|
57
|
+
thisIdxs.push(idxs[0])
|
|
58
|
+
thisIdxs.push(idxs[2])
|
|
59
|
+
thisIdxs.push(idxs[1])
|
|
60
|
+
} else {
|
|
61
|
+
thisIdxs.push(idxs[0])
|
|
62
|
+
thisIdxs.push(idxs[1])
|
|
63
|
+
thisIdxs.push(idxs[2])
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
triangles.delete()
|
|
67
|
+
|
|
68
|
+
const verticesSize = vertices.size()
|
|
69
|
+
for (let i = 0; i < verticesSize; i++) {
|
|
70
|
+
const vert = vertices.get(i);
|
|
71
|
+
const vertPos = vert.pos
|
|
72
|
+
thisPos.push(vertPos[0])
|
|
73
|
+
thisPos.push(vertPos[1])
|
|
74
|
+
thisPos.push(vertPos[2])
|
|
75
|
+
const vertNormal = vert.normal
|
|
76
|
+
thisNorm.push(vertNormal[0])
|
|
77
|
+
thisNorm.push(vertNormal[1])
|
|
78
|
+
thisNorm.push(vertNormal[2])
|
|
79
|
+
vert.delete()
|
|
80
|
+
}
|
|
81
|
+
vertices.delete()
|
|
82
|
+
|
|
83
|
+
const As = inst.instancing_data_A;
|
|
84
|
+
const Asize = As.size();
|
|
85
|
+
|
|
86
|
+
if (Asize > 0) {
|
|
87
|
+
for (let j = 0; j < Asize; j++) {
|
|
88
|
+
const inst_data = As.get(j)
|
|
89
|
+
|
|
90
|
+
const instDataPosition = inst_data.position
|
|
91
|
+
thisInstance_origins.push(instDataPosition[0])
|
|
92
|
+
thisInstance_origins.push(instDataPosition[1])
|
|
93
|
+
thisInstance_origins.push(instDataPosition[2])
|
|
94
|
+
|
|
95
|
+
const instDataColour = inst_data.colour
|
|
96
|
+
thisInstance_colours.push(instDataColour[0])
|
|
97
|
+
thisInstance_colours.push(instDataColour[1])
|
|
98
|
+
thisInstance_colours.push(instDataColour[2])
|
|
99
|
+
thisInstance_colours.push(instDataColour[3])
|
|
100
|
+
|
|
101
|
+
const instDataSize = inst_data.size
|
|
102
|
+
thisInstance_sizes.push(instDataSize[0])
|
|
103
|
+
thisInstance_sizes.push(instDataSize[1])
|
|
104
|
+
thisInstance_sizes.push(instDataSize[2])
|
|
105
|
+
|
|
106
|
+
thisInstance_orientations.push(...[
|
|
107
|
+
1.0, 0.0, 0.0, 0.0,
|
|
108
|
+
0.0, 1.0, 0.0, 0.0,
|
|
109
|
+
0.0, 0.0, 1.0, 0.0,
|
|
110
|
+
0.0, 0.0, 0.0, 1.0,
|
|
111
|
+
])
|
|
112
|
+
|
|
113
|
+
inst_data.delete()
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
As.delete()
|
|
117
|
+
|
|
118
|
+
const Bs = inst.instancing_data_B;
|
|
119
|
+
const Bsize = Bs.size();
|
|
120
|
+
if (Bsize > 0) {
|
|
121
|
+
for (let j = 0; j < Bsize; j++) {
|
|
122
|
+
const inst_data = Bs.get(j)
|
|
123
|
+
|
|
124
|
+
const instDataSize = inst_data.size
|
|
125
|
+
if (instDataSize[2] > maxZSize) continue;
|
|
126
|
+
thisInstance_sizes.push(instDataSize[0])
|
|
127
|
+
thisInstance_sizes.push(instDataSize[1])
|
|
128
|
+
thisInstance_sizes.push(instDataSize[2])
|
|
129
|
+
|
|
130
|
+
const instDataPosition = inst_data.position
|
|
131
|
+
thisInstance_origins.push(instDataPosition[0])
|
|
132
|
+
thisInstance_origins.push(instDataPosition[1])
|
|
133
|
+
thisInstance_origins.push(instDataPosition[2])
|
|
134
|
+
|
|
135
|
+
const instDataColour = inst_data.colour
|
|
136
|
+
thisInstance_colours.push(instDataColour[0])
|
|
137
|
+
thisInstance_colours.push(instDataColour[1])
|
|
138
|
+
thisInstance_colours.push(instDataColour[2])
|
|
139
|
+
thisInstance_colours.push(instDataColour[3])
|
|
140
|
+
|
|
141
|
+
const instDataOrientation = inst_data.orientation
|
|
142
|
+
|
|
143
|
+
thisInstance_orientations.push(instDataOrientation[0][0])
|
|
144
|
+
thisInstance_orientations.push(instDataOrientation[0][1])
|
|
145
|
+
thisInstance_orientations.push(instDataOrientation[0][2])
|
|
146
|
+
thisInstance_orientations.push(instDataOrientation[0][3])
|
|
147
|
+
|
|
148
|
+
thisInstance_orientations.push(instDataOrientation[1][0])
|
|
149
|
+
thisInstance_orientations.push(instDataOrientation[1][1])
|
|
150
|
+
thisInstance_orientations.push(instDataOrientation[1][2])
|
|
151
|
+
thisInstance_orientations.push(instDataOrientation[1][3])
|
|
152
|
+
|
|
153
|
+
thisInstance_orientations.push(instDataOrientation[2][0])
|
|
154
|
+
thisInstance_orientations.push(instDataOrientation[2][1])
|
|
155
|
+
thisInstance_orientations.push(instDataOrientation[2][2])
|
|
156
|
+
thisInstance_orientations.push(instDataOrientation[2][3])
|
|
157
|
+
|
|
158
|
+
thisInstance_orientations.push(instDataOrientation[3][0])
|
|
159
|
+
thisInstance_orientations.push(instDataOrientation[3][1])
|
|
160
|
+
thisInstance_orientations.push(instDataOrientation[3][2])
|
|
161
|
+
thisInstance_orientations.push(instDataOrientation[3][3])
|
|
162
|
+
|
|
163
|
+
inst_data.delete()
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
Bs.delete()
|
|
167
|
+
inst.delete()
|
|
168
|
+
|
|
169
|
+
totNorm.push(thisNorm)
|
|
170
|
+
totPos.push(thisPos)
|
|
171
|
+
totIdxs.push(thisIdxs)
|
|
172
|
+
totInstance_sizes.push(thisInstance_sizes)
|
|
173
|
+
totInstance_origins.push(thisInstance_origins)
|
|
174
|
+
totInstance_orientations.push(thisInstance_orientations)
|
|
175
|
+
totInstance_colours.push(thisInstance_colours)
|
|
176
|
+
totInstanceUseColours.push(true)
|
|
177
|
+
if (thisToSpheres)
|
|
178
|
+
totInstancePrimTypes.push("PERFECT_SPHERES")
|
|
179
|
+
else
|
|
180
|
+
totInstancePrimTypes.push("TRIANGLES")
|
|
181
|
+
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
geom.delete()
|
|
185
|
+
const simpleMeshData = simpleMeshToMeshData(markup) // simpleMeshToMeshData should do the "delete"
|
|
186
|
+
instanceMesh.delete()
|
|
187
|
+
|
|
188
|
+
if (simpleMeshData.idx_tri.length > 0 && simpleMeshData.idx_tri[0].length > 0 && simpleMeshData.idx_tri[0][0].length > 0) {
|
|
189
|
+
if (toSpheres) {
|
|
190
|
+
return {
|
|
191
|
+
prim_types: [totInstancePrimTypes, simpleMeshData.prim_types[0]],
|
|
192
|
+
idx_tri: [totIdxs, simpleMeshData.idx_tri[0]],
|
|
193
|
+
vert_tri: [totInstance_origins, simpleMeshData.vert_tri[0]],
|
|
194
|
+
norm_tri: [totNorm, simpleMeshData.norm_tri[0]],
|
|
195
|
+
col_tri: [totInstance_colours, simpleMeshData.col_tri[0]],
|
|
196
|
+
instance_use_colors: [totInstanceUseColours, null],
|
|
197
|
+
instance_sizes: [totInstance_sizes, null],
|
|
198
|
+
instance_origins: [totInstance_origins, null],
|
|
199
|
+
instance_orientations: [totInstance_orientations, null]
|
|
200
|
+
}
|
|
201
|
+
} else {
|
|
202
|
+
return {
|
|
203
|
+
prim_types: [totInstancePrimTypes, simpleMeshData.prim_types[0]],
|
|
204
|
+
idx_tri: [totIdxs, simpleMeshData.idx_tri[0]],
|
|
205
|
+
vert_tri: [totPos, simpleMeshData.vert_tri[0]],
|
|
206
|
+
norm_tri: [totNorm, simpleMeshData.norm_tri[0]],
|
|
207
|
+
col_tri: [totInstance_colours, simpleMeshData.col_tri[0]],
|
|
208
|
+
instance_use_colors: [totInstanceUseColours, null],
|
|
209
|
+
instance_sizes: [totInstance_sizes, null],
|
|
210
|
+
instance_origins: [totInstance_origins, null],
|
|
211
|
+
instance_orientations: [totInstance_orientations, null]
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
} else {
|
|
215
|
+
return {
|
|
216
|
+
prim_types: [totInstancePrimTypes],
|
|
217
|
+
idx_tri: [totIdxs],
|
|
218
|
+
vert_tri: [totPos],
|
|
219
|
+
norm_tri: [totNorm],
|
|
220
|
+
col_tri: [totInstance_colours],
|
|
221
|
+
instance_use_colors: [totInstanceUseColours],
|
|
222
|
+
instance_sizes: [totInstance_sizes],
|
|
223
|
+
instance_origins: [totInstance_origins],
|
|
224
|
+
instance_orientations: [totInstance_orientations]
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const simpleMeshToMeshData = (simpleMesh, perm) => {
|
|
230
|
+
const vertices = simpleMesh.vertices;
|
|
231
|
+
const triangles = simpleMesh.triangles;
|
|
232
|
+
let totIdxs = [];
|
|
233
|
+
let totPos = [];
|
|
234
|
+
let totNorm = [];
|
|
235
|
+
let totCol = [];
|
|
236
|
+
|
|
237
|
+
const trianglesSize = triangles.size()
|
|
238
|
+
for (let i = 0; i < trianglesSize; i++) {
|
|
239
|
+
const triangle = triangles.get(i)
|
|
240
|
+
const idxs = triangle.point_id;
|
|
241
|
+
if (perm)
|
|
242
|
+
totIdxs.push(...[idxs[0], idxs[2], idxs[1]]);
|
|
243
|
+
else
|
|
244
|
+
totIdxs.push(...idxs);
|
|
245
|
+
}
|
|
246
|
+
triangles.delete()
|
|
247
|
+
|
|
248
|
+
const verticesSize = vertices.size()
|
|
249
|
+
for (let i = 0; i < verticesSize; i++) {
|
|
250
|
+
const vert = vertices.get(i);
|
|
251
|
+
const vertPos = vert.pos
|
|
252
|
+
const vertNormal = vert.normal
|
|
253
|
+
const vertColor = vert.color
|
|
254
|
+
totPos.push(...vertPos);
|
|
255
|
+
if (perm)
|
|
256
|
+
totNorm.push(...[-vertNormal[0], -vertNormal[1], -vertNormal[2]]);
|
|
257
|
+
else
|
|
258
|
+
totNorm.push(...vertNormal);
|
|
259
|
+
totCol.push(...vertColor);
|
|
260
|
+
vert.delete()
|
|
261
|
+
}
|
|
262
|
+
vertices.delete()
|
|
263
|
+
|
|
264
|
+
simpleMesh.delete()
|
|
265
|
+
|
|
266
|
+
return {
|
|
267
|
+
prim_types: [["TRIANGLES"]],
|
|
268
|
+
idx_tri: [[totIdxs]],
|
|
269
|
+
vert_tri: [[totPos]],
|
|
270
|
+
norm_tri: [[totNorm]],
|
|
271
|
+
col_tri: [[totCol]]
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const SuperposeResultsToJSArray = (superposeResults) => {
|
|
276
|
+
const alignmentInfo = superposeResults.alignment_info
|
|
277
|
+
return {
|
|
278
|
+
referenceSequence: superposeResults.alignment.first,
|
|
279
|
+
movingSequence: superposeResults.alignment.second,
|
|
280
|
+
supperposeInfo: superposeResults.suppose_info,
|
|
281
|
+
validationData: validationDataToJSArray(alignmentInfo)
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const colourRulesToJSArray = (colourRulesArray) => {
|
|
286
|
+
let returnResult = []
|
|
287
|
+
const colourRulesSize = colourRulesArray.size()
|
|
288
|
+
for (let i = 0; i < colourRulesSize; i++) {
|
|
289
|
+
const rule = colourRulesArray.get(i)
|
|
290
|
+
returnResult.push(rule)
|
|
291
|
+
}
|
|
292
|
+
colourRulesArray.delete()
|
|
293
|
+
return returnResult;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const floatArrayToJSArray = (floatArray) => {
|
|
297
|
+
let returnResult = []
|
|
298
|
+
const floatArraySize = floatArray.size()
|
|
299
|
+
for (let i = 0; i < floatArraySize; i++) {
|
|
300
|
+
const f = floatArray.get(i)
|
|
301
|
+
returnResult.push(f);
|
|
302
|
+
}
|
|
303
|
+
floatArray.delete()
|
|
304
|
+
return returnResult;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const mapMoleculeCentreInfoToJSObject = (mapMoleculeCentreInfo) => {
|
|
308
|
+
//Takes a coot::util::map_molecule_centre_info and returns a javascript object that resembles it
|
|
309
|
+
//Disposes of the coordOrth
|
|
310
|
+
const updatedCentre = mapMoleculeCentreInfo.updated_centre
|
|
311
|
+
let returnResult = {
|
|
312
|
+
updated_centre: [
|
|
313
|
+
updatedCentre.x(),
|
|
314
|
+
updatedCentre.y(),
|
|
315
|
+
updatedCentre.z()],
|
|
316
|
+
success: mapMoleculeCentreInfo.success,
|
|
317
|
+
suggested_contour_level: mapMoleculeCentreInfo.suggested_contour_level
|
|
318
|
+
}
|
|
319
|
+
updatedCentre.delete()
|
|
320
|
+
return returnResult;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const intArrayToJSArray = (intArray) => {
|
|
324
|
+
let returnResult = []
|
|
325
|
+
const intArraySize = intArray.size()
|
|
326
|
+
for (let i = 0; i < intArraySize; i++) {
|
|
327
|
+
const f = intArray.get(i)
|
|
328
|
+
returnResult.push(f);
|
|
329
|
+
}
|
|
330
|
+
intArray.delete()
|
|
331
|
+
return returnResult;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const stringArrayToJSArray = (stringArray) => {
|
|
335
|
+
let returnResult = []
|
|
336
|
+
const stringArraySize = stringArray.size()
|
|
337
|
+
for (let i = 0; i < stringArraySize; i++) {
|
|
338
|
+
const s = stringArray.get(i)
|
|
339
|
+
returnResult.push(s);
|
|
340
|
+
}
|
|
341
|
+
stringArray.delete()
|
|
342
|
+
return returnResult;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const symmetryToJSData = (symmetryDataPair) => {
|
|
346
|
+
let result = []
|
|
347
|
+
const symmetryData = symmetryDataPair.first
|
|
348
|
+
const symmetryMatrices = symmetryDataPair.second
|
|
349
|
+
const cell = symmetryData.cell
|
|
350
|
+
const symm_trans = symmetryData.symm_trans
|
|
351
|
+
const symmetrySize = symm_trans.size()
|
|
352
|
+
|
|
353
|
+
for (let i = 0; i < symmetrySize; i++) {
|
|
354
|
+
const currentSymmetry = symm_trans.get(i)
|
|
355
|
+
const symTransT = currentSymmetry.first
|
|
356
|
+
const cellTranslation = currentSymmetry.second
|
|
357
|
+
const currentSymmMat = symmetryMatrices.get(i)
|
|
358
|
+
|
|
359
|
+
result.push({
|
|
360
|
+
x: symTransT.x(),
|
|
361
|
+
y: symTransT.y(),
|
|
362
|
+
z: symTransT.z(),
|
|
363
|
+
asString: symTransT.symm_as_string,
|
|
364
|
+
isym: symTransT.isym(),
|
|
365
|
+
us: cellTranslation.us,
|
|
366
|
+
ws: cellTranslation.ws,
|
|
367
|
+
vs: cellTranslation.vs,
|
|
368
|
+
matrix: currentSymmMat
|
|
369
|
+
})
|
|
370
|
+
symTransT.delete()
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
cell.delete()
|
|
374
|
+
symm_trans.delete()
|
|
375
|
+
symmetryMatrices.delete()
|
|
376
|
+
symmetryData.delete()
|
|
377
|
+
return result
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
const mmrrccStatsToJSArray = (mmrrccStats) => {
|
|
381
|
+
const parseStats = (stats) => {
|
|
382
|
+
let result = []
|
|
383
|
+
const residueSpecs = stats.keys()
|
|
384
|
+
const mapSize = residueSpecs.size()
|
|
385
|
+
for (let i = 0; i < mapSize; i++) {
|
|
386
|
+
const residueSpec = residueSpecs.get(i)
|
|
387
|
+
const densityCorrStat = stats.get(residueSpec)
|
|
388
|
+
result.push({
|
|
389
|
+
resNum: residueSpec.res_no,
|
|
390
|
+
insCode: residueSpec.ins_code,
|
|
391
|
+
modelNumber: residueSpec.model_number,
|
|
392
|
+
chainId: residueSpec.chain_id,
|
|
393
|
+
n: densityCorrStat.n,
|
|
394
|
+
correlation: densityCorrStat.correlation()
|
|
395
|
+
})
|
|
396
|
+
residueSpec.delete()
|
|
397
|
+
densityCorrStat.delete()
|
|
398
|
+
}
|
|
399
|
+
residueSpecs.delete()
|
|
400
|
+
return result
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
const first = mmrrccStats.first
|
|
404
|
+
const second = mmrrccStats.second
|
|
405
|
+
|
|
406
|
+
const returnResult = {
|
|
407
|
+
"All atoms": parseStats(first),
|
|
408
|
+
"Side-chains": parseStats(second)
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
first.delete()
|
|
412
|
+
second.delete()
|
|
413
|
+
return returnResult
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
const residueSpecToJSArray = (residueSpecs) => {
|
|
417
|
+
let returnResult = []
|
|
418
|
+
const residuesSize = residueSpecs.size()
|
|
419
|
+
for (let ic = 0; ic < residuesSize; ic++) {
|
|
420
|
+
const residue = residueSpecs.get(ic)
|
|
421
|
+
returnResult.push({
|
|
422
|
+
resNum: residue.res_no,
|
|
423
|
+
insCode: residue.ins_code,
|
|
424
|
+
modelNumber: residue.model_number,
|
|
425
|
+
chainId: residue.chain_id
|
|
426
|
+
})
|
|
427
|
+
residue.delete()
|
|
428
|
+
}
|
|
429
|
+
residueSpecs.delete()
|
|
430
|
+
return returnResult
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
const validationDataToJSArray = (validationData, chainID = null) => {
|
|
434
|
+
let returnResult = []
|
|
435
|
+
const cviv = validationData.cviv
|
|
436
|
+
const chainSize = cviv.size()
|
|
437
|
+
for (let chainIndex = 0; chainIndex < chainSize; chainIndex++) {
|
|
438
|
+
const chain = cviv.get(chainIndex)
|
|
439
|
+
if (chainID !== null && chain.chain_id !== chainID) {
|
|
440
|
+
// pass
|
|
441
|
+
} else {
|
|
442
|
+
const resInfo = chain.rviv;
|
|
443
|
+
const resInfoSize = resInfo.size()
|
|
444
|
+
for (let ir = 0; ir < resInfoSize; ir++) {
|
|
445
|
+
const residue = resInfo.get(ir)
|
|
446
|
+
const residueSpec = residue.residue_spec
|
|
447
|
+
returnResult.push({
|
|
448
|
+
chainId: residueSpec.chain_id,
|
|
449
|
+
insCode: residueSpec.ins_code,
|
|
450
|
+
seqNum: residueSpec.res_no,
|
|
451
|
+
restype: "UNK",
|
|
452
|
+
value: residue.function_value
|
|
453
|
+
})
|
|
454
|
+
residue.delete()
|
|
455
|
+
residueSpec.delete()
|
|
456
|
+
}
|
|
457
|
+
resInfo.delete()
|
|
458
|
+
}
|
|
459
|
+
chain.delete()
|
|
460
|
+
}
|
|
461
|
+
cviv.delete()
|
|
462
|
+
validationData.delete()
|
|
463
|
+
return returnResult
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
const linesBoxToJSArray = (BoxData) => {
|
|
467
|
+
let envdata = []
|
|
468
|
+
const segments = BoxData.line_segments;
|
|
469
|
+
const nSeg = segments.size()
|
|
470
|
+
for (let i = 0; i < nSeg; i++) {
|
|
471
|
+
let thisEnvdata = []
|
|
472
|
+
const segsI = segments.get(i)
|
|
473
|
+
const nSegI = segsI.size()
|
|
474
|
+
for (let j = 0; j < nSegI; j++) {
|
|
475
|
+
const seg = segsI.get(j)
|
|
476
|
+
const start = seg.getStart()
|
|
477
|
+
const end = seg.getFinish()
|
|
478
|
+
const ampl = seg.amplitude()
|
|
479
|
+
const startJS = { x: start.x(), y: start.y(), z: start.z() }
|
|
480
|
+
const endJS = { x: end.x(), y: end.y(), z: end.z() }
|
|
481
|
+
thisEnvdata.push({
|
|
482
|
+
start: startJS,
|
|
483
|
+
end: endJS,
|
|
484
|
+
dist: ampl,
|
|
485
|
+
})
|
|
486
|
+
start.delete()
|
|
487
|
+
end.delete()
|
|
488
|
+
seg.delete()
|
|
489
|
+
}
|
|
490
|
+
segsI.delete()
|
|
491
|
+
envdata.push(thisEnvdata)
|
|
492
|
+
}
|
|
493
|
+
segments.delete()
|
|
494
|
+
BoxData.delete()
|
|
495
|
+
|
|
496
|
+
return envdata
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
const vectorHBondToJSArray = (HBondData) => {
|
|
500
|
+
let hbdata = []
|
|
501
|
+
const hbondDataSize = HBondData.size()
|
|
502
|
+
for (let ib = 0; ib < hbondDataSize; ib++) {
|
|
503
|
+
const hb = HBondData.get(ib)
|
|
504
|
+
hbdata.push({
|
|
505
|
+
hb_hydrogen: hb.hb_hydrogen,
|
|
506
|
+
donor: hb.donor,
|
|
507
|
+
acceptor: hb.acceptor,
|
|
508
|
+
donor_neigh: hb.donor_neigh,
|
|
509
|
+
acceptor_neigh: hb.acceptor_neigh,
|
|
510
|
+
angle_1: hb.angle_1,
|
|
511
|
+
angle_2: hb.angle_2,
|
|
512
|
+
angle_3: hb.angle_3,
|
|
513
|
+
dist: hb.dist,
|
|
514
|
+
ligand_atom_is_donor: hb.ligand_atom_is_donor,
|
|
515
|
+
hydrogen_is_ligand_atom: hb.hydrogen_is_ligand_atom,
|
|
516
|
+
bond_has_hydrogen_flag: hb.bond_has_hydrogen_flag,
|
|
517
|
+
})
|
|
518
|
+
}
|
|
519
|
+
HBondData.delete()
|
|
520
|
+
return hbdata
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
const interestingPlaceDataToJSArray = (interestingPlaceData) => {
|
|
524
|
+
let returnResult = [];
|
|
525
|
+
const interestingPlaceDataSize = interestingPlaceData.size()
|
|
526
|
+
for (let ir = 0; ir < interestingPlaceDataSize; ir++) {
|
|
527
|
+
const residue = interestingPlaceData.get(ir)
|
|
528
|
+
const residueSpec = residue.residue_spec
|
|
529
|
+
returnResult.push({
|
|
530
|
+
chainId: residueSpec.chain_id,
|
|
531
|
+
insCode: residueSpec.ins_code,
|
|
532
|
+
seqNum: residueSpec.res_no,
|
|
533
|
+
featureType: residue.feature_type,
|
|
534
|
+
featureValue: residue.feature_value,
|
|
535
|
+
buttonLabel: residue.button_label,
|
|
536
|
+
badness: residue.badness,
|
|
537
|
+
coordX: residue.x,
|
|
538
|
+
coordY: residue.y,
|
|
539
|
+
coordZ: residue.z
|
|
540
|
+
})
|
|
541
|
+
residue.delete()
|
|
542
|
+
residueSpec.delete()
|
|
543
|
+
}
|
|
544
|
+
interestingPlaceData.delete()
|
|
545
|
+
return returnResult
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
const ramachandranDataToJSArray = (ramachandraData, chainID) => {
|
|
549
|
+
let returnResult = [];
|
|
550
|
+
const ramachandraDataSize = ramachandraData.size()
|
|
551
|
+
for (let ir = 0; ir < ramachandraDataSize; ir++) {
|
|
552
|
+
const residue = ramachandraData.get(ir)
|
|
553
|
+
const phiPsi = residue.phi_psi
|
|
554
|
+
if (phiPsi.chain_id === chainID) {
|
|
555
|
+
returnResult.push({
|
|
556
|
+
chainId: phiPsi.chain_id,
|
|
557
|
+
insCode: phiPsi.ins_code,
|
|
558
|
+
seqNum: phiPsi.residue_number,
|
|
559
|
+
restype: residue.residue_name,
|
|
560
|
+
isOutlier: !residue.is_allowed_flag,
|
|
561
|
+
phi: phiPsi.phi(),
|
|
562
|
+
psi: phiPsi.psi(),
|
|
563
|
+
is_pre_pro: residue.residue_name === 'PRO'
|
|
564
|
+
})
|
|
565
|
+
}
|
|
566
|
+
residue.delete()
|
|
567
|
+
phiPsi.delete()
|
|
568
|
+
}
|
|
569
|
+
ramachandraData.delete()
|
|
570
|
+
return returnResult
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
const simpleMeshToLineMeshData = (simpleMesh, normalLighting) => {
|
|
574
|
+
const vertices = simpleMesh.vertices;
|
|
575
|
+
const triangles = simpleMesh.triangles;
|
|
576
|
+
let totIdxs = [];
|
|
577
|
+
let totPos = [];
|
|
578
|
+
let totNorm = [];
|
|
579
|
+
let totCol = [];
|
|
580
|
+
|
|
581
|
+
const trianglesSize = triangles.size()
|
|
582
|
+
for (let i = 0; i < trianglesSize; i++) {
|
|
583
|
+
const triangle = triangles.get(i)
|
|
584
|
+
const idxs = triangle.point_id;
|
|
585
|
+
totIdxs.push(...[idxs[0], idxs[1], idxs[0], idxs[2], idxs[1], idxs[2]]);
|
|
586
|
+
}
|
|
587
|
+
triangles.delete()
|
|
588
|
+
|
|
589
|
+
const verticesSize = vertices.size()
|
|
590
|
+
for (let i = 0; i < verticesSize; i++) {
|
|
591
|
+
const vert = vertices.get(i);
|
|
592
|
+
totPos.push(...vert.pos);
|
|
593
|
+
totNorm.push(...vert.normal);
|
|
594
|
+
totCol.push(...vert.color);
|
|
595
|
+
vert.delete()
|
|
596
|
+
}
|
|
597
|
+
vertices.delete()
|
|
598
|
+
|
|
599
|
+
simpleMesh.delete()
|
|
600
|
+
|
|
601
|
+
if (normalLighting)
|
|
602
|
+
return { prim_types: [["NORMALLINES"]], useIndices: [[true]], idx_tri: [[totIdxs]], vert_tri: [[totPos]], additional_norm_tri: [[totNorm]], norm_tri: [[totNorm]], col_tri: [[totCol]] };
|
|
603
|
+
else
|
|
604
|
+
return { prim_types: [["LINES"]], useIndices: [[true]], idx_tri: [[totIdxs]], vert_tri: [[totPos]], norm_tri: [[totNorm]], col_tri: [[totCol]] };
|
|
605
|
+
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
const read_pdb = (coordData, name) => {
|
|
609
|
+
const theGuid = guid()
|
|
610
|
+
cootModule.FS_createDataFile(".", `${theGuid}.pdb`, coordData, true, true);
|
|
611
|
+
const tempFilename = `./${theGuid}.pdb`
|
|
612
|
+
const molNo = molecules_container.read_pdb(tempFilename)
|
|
613
|
+
cootModule.FS_unlink(tempFilename)
|
|
614
|
+
return molNo
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
const auto_open_mtz = (mtzData) => {
|
|
618
|
+
const theGuid = guid()
|
|
619
|
+
const asUint8Array = new Uint8Array(mtzData)
|
|
620
|
+
cootModule.FS_createDataFile(".", `${theGuid}.mtz`, asUint8Array, true, true);
|
|
621
|
+
const tempFilename = `./${theGuid}.mtz`
|
|
622
|
+
const result = molecules_container.auto_read_mtz(tempFilename)
|
|
623
|
+
cootModule.FS_unlink(tempFilename)
|
|
624
|
+
return result
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
const read_dictionary = (coordData, associatedMolNo) => {
|
|
628
|
+
const theGuid = guid()
|
|
629
|
+
cootModule.FS_createDataFile(".", `${theGuid}.cif`, coordData, true, true);
|
|
630
|
+
const tempFilename = `./${theGuid}.cif`
|
|
631
|
+
const returnVal = molecules_container.import_cif_dictionary(tempFilename, associatedMolNo)
|
|
632
|
+
cootModule.FS_unlink(tempFilename)
|
|
633
|
+
return returnVal
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
function base64ToArrayBuffer(base64) {
|
|
637
|
+
var binary_string = window.atob(base64);
|
|
638
|
+
var len = binary_string.length;
|
|
639
|
+
var bytes = new Uint8Array(len);
|
|
640
|
+
for (var i = 0; i < len; i++) {
|
|
641
|
+
bytes[i] = binary_string.charCodeAt(i);
|
|
642
|
+
}
|
|
643
|
+
return bytes.buffer;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
const replace_molecule_by_model_from_file = (imol, coordData) => {
|
|
647
|
+
const theGuid = guid()
|
|
648
|
+
const tempFilename = `./${theGuid}.pdb`
|
|
649
|
+
cootModule.FS_createDataFile(".", tempFilename, coordData, true, true)
|
|
650
|
+
const result = molecules_container.replace_molecule_by_model_from_file(imol, tempFilename)
|
|
651
|
+
cootModule.FS_unlink(tempFilename)
|
|
652
|
+
return result
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
const replace_map_by_mtz_from_file = (imol, mtzData, selectedColumns) => {
|
|
656
|
+
const theGuid = guid()
|
|
657
|
+
const tempFilename = `./${theGuid}.mtz`
|
|
658
|
+
const asUint8Array = new Uint8Array(mtzData)
|
|
659
|
+
cootModule.FS_createDataFile(".", tempFilename, asUint8Array, true, true);
|
|
660
|
+
const readMtzArgs = [imol, tempFilename, selectedColumns.F, selectedColumns.PHI, "", false]
|
|
661
|
+
const result = molecules_container.replace_map_by_mtz_from_file(...readMtzArgs)
|
|
662
|
+
cootModule.FS_unlink(tempFilename)
|
|
663
|
+
return result
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
const new_positions_for_residue_atoms = (molToUpDate, residues) => {
|
|
667
|
+
let success = 0
|
|
668
|
+
const movedResidueVector = new cootModule.Vectormoved_residue_t()
|
|
669
|
+
residues.forEach(atoms => {
|
|
670
|
+
if (atoms.length > 0) {
|
|
671
|
+
const cidFields = atoms[0].label.split('/')
|
|
672
|
+
let [resNoStr, insCode] = cidFields[3].split(".")
|
|
673
|
+
insCode = insCode ? insCode : ""
|
|
674
|
+
const movedResidue = new cootModule.moved_residue_t(cidFields[2], parseInt(resNoStr), insCode)
|
|
675
|
+
atoms.forEach(atom => {
|
|
676
|
+
const movedAtom = new cootModule.moved_atom_t(atom.name, atom.alt_loc, atom.x, atom.y, atom.z, -1)
|
|
677
|
+
movedResidue.add_atom(movedAtom)
|
|
678
|
+
movedAtom.delete()
|
|
679
|
+
})
|
|
680
|
+
movedResidueVector.push_back(movedResidue)
|
|
681
|
+
movedResidue.delete()
|
|
682
|
+
}
|
|
683
|
+
})
|
|
684
|
+
const thisSuccess = molecules_container.new_positions_for_atoms_in_residues(molToUpDate, movedResidueVector)
|
|
685
|
+
success += thisSuccess
|
|
686
|
+
movedResidueVector.delete()
|
|
687
|
+
return success
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
const read_mtz = (mapData, name, selectedColumns) => {
|
|
691
|
+
const theGuid = guid()
|
|
692
|
+
const asUint8Array = new Uint8Array(mapData)
|
|
693
|
+
cootModule.FS_createDataFile(".", `${theGuid}.mtz`, asUint8Array, true, true);
|
|
694
|
+
const tempFilename = `./${theGuid}.mtz`
|
|
695
|
+
const read_mtz_args = [tempFilename, selectedColumns.F,
|
|
696
|
+
selectedColumns.PHI, "", false, selectedColumns.isDifference]
|
|
697
|
+
const molNo = molecules_container.read_mtz(...read_mtz_args)
|
|
698
|
+
cootModule.FS_unlink(tempFilename)
|
|
699
|
+
return molNo
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
const associate_data_mtz_file_with_map = (iMol, mtzData, F, SIGF, FREE) => {
|
|
703
|
+
const asUint8Array = new Uint8Array(mtzData.data)
|
|
704
|
+
cootModule.FS_createDataFile(".", `${mtzData.fileName}.mtz`, asUint8Array, true, true);
|
|
705
|
+
const mtzFilename = `./${mtzData.fileName}.mtz`
|
|
706
|
+
const args = [iMol, mtzFilename, F, SIGF, FREE]
|
|
707
|
+
molecules_container.associate_data_mtz_file_with_map(...args)
|
|
708
|
+
return mtzFilename
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
const read_ccp4_map = (mapData, name, isDiffMap) => {
|
|
712
|
+
const theGuid = guid()
|
|
713
|
+
const asUint8Array = new Uint8Array(mapData)
|
|
714
|
+
cootModule.FS_createDataFile(".", `${theGuid}.map`, asUint8Array, true, true);
|
|
715
|
+
const tempFilename = `./${theGuid}.map`
|
|
716
|
+
const read_map_args = [tempFilename, isDiffMap]
|
|
717
|
+
const molNo = molecules_container.read_ccp4_map(...read_map_args)
|
|
718
|
+
cootModule.FS_unlink(tempFilename)
|
|
719
|
+
return molNo
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
const doColourTest = (imol) => {
|
|
723
|
+
console.log('DEBUG: Start test...')
|
|
724
|
+
|
|
725
|
+
const colours = {
|
|
726
|
+
0: { cid: '//A/1-10/', rgb: [255., 0., 0.] },
|
|
727
|
+
1: { cid: '//A/11-20/', rgb: [0., 255., 0.] },
|
|
728
|
+
2: { cid: '//A/21-30/', rgb: [0., 0., 255.] },
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
let colourMap = new cootModule.MapIntFloat3()
|
|
732
|
+
for (const key in Object.keys(colours)) {
|
|
733
|
+
colourMap[key] = colours[key].rgb
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
let indexedResiduesVec = new cootModule.VectorStringUInt_pair()
|
|
737
|
+
for (const key in Object.keys(colours)) {
|
|
738
|
+
const i = { first: colours[key].cid, second: parseInt(key) }
|
|
739
|
+
indexedResiduesVec.push_back(i)
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
console.log('DEBUG: Running molecules_container.set_user_defined_bond_colours')
|
|
743
|
+
molecules_container.set_user_defined_bond_colours(imol, colourMap)
|
|
744
|
+
console.log('DEBUG: Running molecules_container.set_user_defined_atom_colour_by_residue')
|
|
745
|
+
molecules_container.set_user_defined_atom_colour_by_residue(imol, indexedResiduesVec)
|
|
746
|
+
|
|
747
|
+
indexedResiduesVec.delete()
|
|
748
|
+
colourMap.delete()
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
onmessage = function (e) {
|
|
752
|
+
if (e.data.message === 'CootInitialize') {
|
|
753
|
+
|
|
754
|
+
createRSRModule({
|
|
755
|
+
locateFile: (file) => `./wasm/${file}`,
|
|
756
|
+
onRuntimeInitialized: () => { },
|
|
757
|
+
mainScriptUrlOrBlob: "moorhen.js",
|
|
758
|
+
print: print,
|
|
759
|
+
printErr: print,
|
|
760
|
+
})
|
|
761
|
+
.then((returnedModule) => {
|
|
762
|
+
postMessage({ consoleMessage: 'Initialized molecules_container', message: e.data.message, messageId: e.data.messageId })
|
|
763
|
+
cootModule = returnedModule;
|
|
764
|
+
molecules_container = new cootModule.molecules_container_js(false)
|
|
765
|
+
molecules_container.set_show_timings(false)
|
|
766
|
+
molecules_container.fill_rotamer_probability_tables()
|
|
767
|
+
molecules_container.set_map_sampling_rate(1.7)
|
|
768
|
+
cootModule.FS.mkdir("COOT_BACKUP");
|
|
769
|
+
})
|
|
770
|
+
.catch((e) => {
|
|
771
|
+
console.log(e)
|
|
772
|
+
print(e);
|
|
773
|
+
});
|
|
774
|
+
|
|
775
|
+
createCCP4Module({
|
|
776
|
+
locateFile: (file) => `./wasm/${file}`,
|
|
777
|
+
onRuntimeInitialized: () => { },
|
|
778
|
+
mainScriptUrlOrBlob: "web_example.js",
|
|
779
|
+
print: print,
|
|
780
|
+
printErr: print,
|
|
781
|
+
})
|
|
782
|
+
.then((returnedModule) => {
|
|
783
|
+
ccp4Module = returnedModule;
|
|
784
|
+
})
|
|
785
|
+
.catch((e) => {
|
|
786
|
+
console.log(e)
|
|
787
|
+
print(e);
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
else if (e.data.message === 'get_atoms') {
|
|
792
|
+
const theGuid = guid()
|
|
793
|
+
const tempFilename = `./${theGuid}.pdb`
|
|
794
|
+
if (e.data.format === 'pdb') {
|
|
795
|
+
molecules_container.writePDBASCII(e.data.molNo, tempFilename)
|
|
796
|
+
} else if (e.data.format === 'mmcif') {
|
|
797
|
+
molecules_container.writeCIFASCII(e.data.molNo, tempFilename)
|
|
798
|
+
} else {
|
|
799
|
+
console.log(`Unrecognised format... ${e.data.format}`)
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
const pdbData = cootModule.FS.readFile(tempFilename, { encoding: 'utf8' });
|
|
803
|
+
cootModule.FS_unlink(tempFilename)
|
|
804
|
+
postMessage({
|
|
805
|
+
messageId: e.data.messageId,
|
|
806
|
+
myTimeStamp: e.data.myTimeStamp,
|
|
807
|
+
consoleMessage: `Fetched coordinates of molecule ${e.data.molNo}`,
|
|
808
|
+
message: e.data.message,
|
|
809
|
+
result: { molNo: e.data.molNo, pdbData: pdbData }
|
|
810
|
+
})
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
else if (e.data.message === 'get_mtz_data') {
|
|
814
|
+
const mtzData = cootModule.FS.readFile(e.data.fileName, { encoding: 'binary' });
|
|
815
|
+
postMessage({
|
|
816
|
+
messageId: e.data.messageId,
|
|
817
|
+
myTimeStamp: e.data.myTimeStamp,
|
|
818
|
+
consoleMessage: `Fetched mtz data for map ${e.data.molNo}`,
|
|
819
|
+
message: e.data.message,
|
|
820
|
+
result: { molNo: e.data.molNo, mtzData: mtzData }
|
|
821
|
+
})
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
else if (e.data.message === 'get_map') {
|
|
825
|
+
const theGuid = guid()
|
|
826
|
+
const tempFilename = `./${theGuid}.map`
|
|
827
|
+
molecules_container.writeCCP4Map(e.data.molNo, tempFilename)
|
|
828
|
+
|
|
829
|
+
const mapData = cootModule.FS.readFile(tempFilename, { encoding: 'binary' });
|
|
830
|
+
cootModule.FS_unlink(tempFilename)
|
|
831
|
+
postMessage({
|
|
832
|
+
messageId: e.data.messageId,
|
|
833
|
+
myTimeStamp: e.data.myTimeStamp,
|
|
834
|
+
consoleMessage: `Fetched map of map ${e.data.molNo}`,
|
|
835
|
+
message: e.data.message,
|
|
836
|
+
result: { molNo: e.data.molNo, mapData: mapData.buffer }
|
|
837
|
+
})
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
else if (e.data.message === 'read_mtz') {
|
|
841
|
+
try {
|
|
842
|
+
const theGuid = guid()
|
|
843
|
+
cootModule.FS_createDataFile(".", `${theGuid}.mtz`, e.data.data, true, true, true);
|
|
844
|
+
const tempFilename = `./${theGuid}.mtz`
|
|
845
|
+
const molNo = molecules_container.read_mtz(tempFilename, 'FWT', 'PHWT', "", false, false)
|
|
846
|
+
cootModule.FS_unlink(tempFilename)
|
|
847
|
+
postMessage({
|
|
848
|
+
messageId: e.data.messageId,
|
|
849
|
+
myTimeStamp: e.data.myTimeStamp,
|
|
850
|
+
consoleMessage: `Read map MTZ as molecule ${molNo}`,
|
|
851
|
+
message: e.data.message,
|
|
852
|
+
result: { molNo: molNo, name: e.data.name }
|
|
853
|
+
})
|
|
854
|
+
}
|
|
855
|
+
catch (err) {
|
|
856
|
+
print(err)
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
else if (e.data.message === 'get_rama') {
|
|
861
|
+
const theGuid = guid()
|
|
862
|
+
const tempFilename = `./${theGuid}.pdb`
|
|
863
|
+
molecules_container.writePDBASCII(e.data.molNo, tempFilename)
|
|
864
|
+
const result = cootModule.getRamachandranData(tempFilename, e.data.chainId);
|
|
865
|
+
cootModule.FS_unlink(tempFilename)
|
|
866
|
+
let resInfo = [];
|
|
867
|
+
for (let ir = 0; ir < result.size(); ir++) {
|
|
868
|
+
const cppres = result.get(ir);
|
|
869
|
+
//TODO - Is there a nicer way to do this?
|
|
870
|
+
const jsres = { chainId: cppres.chainId, insCode: cppres.insCode, seqNum: cppres.seqNum, restype: cppres.restype, phi: cppres.phi, psi: cppres.psi, isOutlier: cppres.isOutlier, is_pre_pro: cppres.is_pre_pro };
|
|
871
|
+
resInfo.push(jsres);
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
postMessage({
|
|
875
|
+
messageId: e.data.messageId,
|
|
876
|
+
myTimeStamp: e.data.myTimeStamp,
|
|
877
|
+
messageTag: "result",
|
|
878
|
+
result: resInfo,
|
|
879
|
+
})
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
else if (e.data.message === 'copy_fragment') {
|
|
883
|
+
const newmolNo = molecules_container.copy_fragment_using_residue_range(e.data.molNo, e.data.chainId, e.data.res_no_start, e.data.res_no_end)
|
|
884
|
+
|
|
885
|
+
postMessage({
|
|
886
|
+
messageId: e.data.messageId,
|
|
887
|
+
myTimeStamp: e.data.myTimeStamp,
|
|
888
|
+
messageTag: "result",
|
|
889
|
+
result: newmolNo,
|
|
890
|
+
})
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
else if (e.data.message === 'delete') {
|
|
894
|
+
const result = molecules_container.close_molecule(e.data.molNo)
|
|
895
|
+
|
|
896
|
+
postMessage({
|
|
897
|
+
messageId: e.data.messageId,
|
|
898
|
+
myTimeStamp: e.data.myTimeStamp,
|
|
899
|
+
messageTag: "result",
|
|
900
|
+
result: result,
|
|
901
|
+
})
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
else if (e.data.message === 'delete_file_name') {
|
|
905
|
+
const result = cootModule.FS_unlink(e.data.fileName)
|
|
906
|
+
|
|
907
|
+
postMessage({
|
|
908
|
+
messageId: e.data.messageId,
|
|
909
|
+
myTimeStamp: e.data.myTimeStamp,
|
|
910
|
+
messageTag: "result",
|
|
911
|
+
result: result,
|
|
912
|
+
})
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
if (e.data.message === 'coot_command') {
|
|
916
|
+
const { returnType, command, commandArgs, messageId } = e.data
|
|
917
|
+
try {
|
|
918
|
+
|
|
919
|
+
const timeMainThreadToWorker = `Message from main thread to worker took ${Date.now() - e.data.myTimeStamp} ms (${command}) - (${messageId.slice(0, 5)})`
|
|
920
|
+
|
|
921
|
+
let startTime = new Date()
|
|
922
|
+
|
|
923
|
+
/* A debug message to show tht commands are reachng CootWorker
|
|
924
|
+
postMessage({ consoleMessage: `Received ${command} with args ${commandArgs}` })
|
|
925
|
+
*/
|
|
926
|
+
|
|
927
|
+
/* Here a block of "shims"
|
|
928
|
+
* over time want to reduce these to none
|
|
929
|
+
*/
|
|
930
|
+
let cootResult
|
|
931
|
+
if (command === 'shim_read_pdb') {
|
|
932
|
+
cootResult = read_pdb(...commandArgs)
|
|
933
|
+
}
|
|
934
|
+
else if (command === 'shim_new_positions_for_residue_atoms') {
|
|
935
|
+
cootResult = new_positions_for_residue_atoms(...commandArgs)
|
|
936
|
+
}
|
|
937
|
+
else if (command === 'shim_read_mtz') {
|
|
938
|
+
cootResult = read_mtz(...commandArgs)
|
|
939
|
+
}
|
|
940
|
+
else if (command === 'shim_auto_open_mtz') {
|
|
941
|
+
cootResult = auto_open_mtz(...commandArgs)
|
|
942
|
+
}
|
|
943
|
+
else if (command === 'shim_read_ccp4_map') {
|
|
944
|
+
cootResult = read_ccp4_map(...commandArgs)
|
|
945
|
+
}
|
|
946
|
+
else if (command === 'shim_read_dictionary') {
|
|
947
|
+
cootResult = read_dictionary(...commandArgs)
|
|
948
|
+
}
|
|
949
|
+
else if (command === 'shim_associate_data_mtz_file_with_map') {
|
|
950
|
+
cootResult = associate_data_mtz_file_with_map(...commandArgs)
|
|
951
|
+
}
|
|
952
|
+
else if (command === 'shim_replace_molecule_by_model_from_file') {
|
|
953
|
+
cootResult = replace_molecule_by_model_from_file(...commandArgs)
|
|
954
|
+
}
|
|
955
|
+
else if (command === 'shim_replace_map_by_mtz_from_file') {
|
|
956
|
+
cootResult = replace_map_by_mtz_from_file(...commandArgs)
|
|
957
|
+
}
|
|
958
|
+
else if (command === 'shim_do_colour_test') {
|
|
959
|
+
cootResult = doColourTest(...commandArgs)
|
|
960
|
+
}
|
|
961
|
+
else if (command === 'shim_smiles_to_pdb') {
|
|
962
|
+
cootResult = cootModule.SmilesToPDB(...commandArgs)
|
|
963
|
+
}
|
|
964
|
+
else {
|
|
965
|
+
cootResult = molecules_container[command](...commandArgs)
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
let endTime = new Date()
|
|
969
|
+
let timeDiff = endTime - startTime
|
|
970
|
+
const timelibcootAPI = `libcootAPI command ${command} took ${timeDiff} ms - (${messageId.slice(0, 5)})`
|
|
971
|
+
let returnResult;
|
|
972
|
+
startTime = new Date()
|
|
973
|
+
|
|
974
|
+
switch (returnType) {
|
|
975
|
+
case 'instanced_mesh_perm':
|
|
976
|
+
returnResult = instancedMeshToMeshData(cootResult, true)
|
|
977
|
+
break;
|
|
978
|
+
case 'symmetry':
|
|
979
|
+
returnResult = symmetryToJSData(cootResult)
|
|
980
|
+
break;
|
|
981
|
+
case 'mmrrcc_stats':
|
|
982
|
+
returnResult = mmrrccStatsToJSArray(cootResult)
|
|
983
|
+
break;
|
|
984
|
+
case 'colour_rules':
|
|
985
|
+
returnResult = colourRulesToJSArray(cootResult)
|
|
986
|
+
break;
|
|
987
|
+
case 'instanced_mesh_perfect_spheres':
|
|
988
|
+
returnResult = instancedMeshToMeshData(cootResult, false, true)
|
|
989
|
+
break;
|
|
990
|
+
case 'instanced_mesh':
|
|
991
|
+
returnResult = instancedMeshToMeshData(cootResult, false, false, 5)
|
|
992
|
+
break;
|
|
993
|
+
case 'mesh_perm':
|
|
994
|
+
returnResult = simpleMeshToMeshData(cootResult, true)
|
|
995
|
+
break;
|
|
996
|
+
case 'mesh':
|
|
997
|
+
returnResult = simpleMeshToMeshData(cootResult)
|
|
998
|
+
break;
|
|
999
|
+
case 'lit_lines_mesh':
|
|
1000
|
+
returnResult = simpleMeshToLineMeshData(cootResult, true)
|
|
1001
|
+
break;
|
|
1002
|
+
case 'lines_mesh':
|
|
1003
|
+
returnResult = simpleMeshToLineMeshData(cootResult, false)
|
|
1004
|
+
break;
|
|
1005
|
+
case 'float_array':
|
|
1006
|
+
returnResult = floatArrayToJSArray(cootResult)
|
|
1007
|
+
break;
|
|
1008
|
+
case 'int_array':
|
|
1009
|
+
returnResult = intArrayToJSArray(cootResult)
|
|
1010
|
+
break;
|
|
1011
|
+
case 'map_molecule_centre_info_t':
|
|
1012
|
+
returnResult = mapMoleculeCentreInfoToJSObject(cootResult)
|
|
1013
|
+
break;
|
|
1014
|
+
case 'string_array':
|
|
1015
|
+
returnResult = stringArrayToJSArray(cootResult)
|
|
1016
|
+
break;
|
|
1017
|
+
case 'residue_specs':
|
|
1018
|
+
returnResult = residueSpecToJSArray(cootResult)
|
|
1019
|
+
break;
|
|
1020
|
+
case 'ramachandran_data':
|
|
1021
|
+
returnResult = ramachandranDataToJSArray(cootResult, e.data.chainID)
|
|
1022
|
+
break;
|
|
1023
|
+
case 'validation_data':
|
|
1024
|
+
returnResult = validationDataToJSArray(cootResult, e.data.chainID)
|
|
1025
|
+
break;
|
|
1026
|
+
case 'interesting_places_data':
|
|
1027
|
+
returnResult = interestingPlaceDataToJSArray(cootResult)
|
|
1028
|
+
break;
|
|
1029
|
+
case 'superpose_results':
|
|
1030
|
+
returnResult = SuperposeResultsToJSArray(cootResult)
|
|
1031
|
+
break
|
|
1032
|
+
case 'generic_3d_lines_bonds_box':
|
|
1033
|
+
returnResult = linesBoxToJSArray(cootResult)
|
|
1034
|
+
break;
|
|
1035
|
+
case 'vector_hbond':
|
|
1036
|
+
returnResult = vectorHBondToJSArray(cootResult)
|
|
1037
|
+
break;
|
|
1038
|
+
case 'status_instanced_mesh_pair':
|
|
1039
|
+
returnResult = { status: cootResult.first, mesh: instancedMeshToMeshData(cootResult.second, false, false, 5) }
|
|
1040
|
+
break;
|
|
1041
|
+
case 'status':
|
|
1042
|
+
default:
|
|
1043
|
+
returnResult = cootResult
|
|
1044
|
+
break;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
endTime = new Date()
|
|
1048
|
+
timeDiff = endTime - startTime
|
|
1049
|
+
const timeconvertingWASMJS = `conversion of output of ${command} to JS data took ${timeDiff} ms - (${messageId.slice(0, 5)})`
|
|
1050
|
+
|
|
1051
|
+
postMessage({
|
|
1052
|
+
timelibcootAPI, timeconvertingWASMJS, timeMainThreadToWorker,
|
|
1053
|
+
messageId, messageSendTime: Date.now(),
|
|
1054
|
+
consoleMessage: `Completed ${command} in ${Date.now() - e.data.myTimeStamp} ms`,
|
|
1055
|
+
result: { status: 'Completed', result: returnResult }
|
|
1056
|
+
})
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
catch (err) {
|
|
1060
|
+
console.log(err)
|
|
1061
|
+
postMessage({
|
|
1062
|
+
messageId: e.data.messageId,
|
|
1063
|
+
myTimeStamp: e.data.myTimeStamp,
|
|
1064
|
+
message: e.data.message,
|
|
1065
|
+
consoleMessage: `EXCEPTION RAISED IN ${command}, ${err}`,
|
|
1066
|
+
result: { status: 'Exception' }
|
|
1067
|
+
})
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
}
|