moorhen 0.6.8 → 0.7.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/README.md +6 -17
- package/baby-gru/CootWorker.js +1 -1
- package/baby-gru/CootWorker.ts +124 -51
- package/baby-gru/moorhen.css +65 -1
- package/baby-gru/wasm/moorhen.js +1 -1
- package/baby-gru/wasm/moorhen.wasm +0 -0
- package/baby-gru/wasm/web_example.js +1 -1
- package/baby-gru/wasm/web_example.wasm +0 -0
- package/moorhen.js +8 -8
- package/package.json +1 -1
- package/types/libcoot.d.ts +44 -9
- package/types/main.d.ts +58 -23
- package/types/mgWebGL.d.ts +6 -3
- package/types/moorhen.d.ts +75 -48
package/README.md
CHANGED
|
@@ -15,16 +15,11 @@ The sources of CCP4, Coot, Privateer, FFTW, and GSL are not included. They are d
|
|
|
15
15
|
the `get_sources` script, which is part of the build process of this project.
|
|
16
16
|
|
|
17
17
|
The following libraries/programs are compiled to Web Assembly:
|
|
18
|
-
* libccp4 (
|
|
19
|
-
* clipper (
|
|
20
|
-
* ssm (
|
|
21
|
-
* mmdb2 (
|
|
22
|
-
* ccp4srs (bzr)
|
|
18
|
+
* libccp4 (8.0.0)
|
|
19
|
+
* clipper (2.1)
|
|
20
|
+
* ssm (1.4.0)
|
|
21
|
+
* mmdb2 (2.0.22)
|
|
23
22
|
* gemmi 0.5.8
|
|
24
|
-
* rvapi (bzr)
|
|
25
|
-
* gesamt (bzr)
|
|
26
|
-
* ccp4mg (partial) (bzr)
|
|
27
|
-
* privateer MKIV
|
|
28
23
|
* Coot 1.0 ('gtk3' git branch)
|
|
29
24
|
* fftw 2.1.5
|
|
30
25
|
* gsl 2.7.1
|
|
@@ -45,7 +40,6 @@ Binaries are available on the releases page. Please read the instructions there
|
|
|
45
40
|
**Requirements**
|
|
46
41
|
|
|
47
42
|
* A Bourne-like shell
|
|
48
|
-
* bzr
|
|
49
43
|
* git
|
|
50
44
|
* curl
|
|
51
45
|
* patch
|
|
@@ -79,7 +73,7 @@ This should build all dependencies and then `Moorhen`.
|
|
|
79
73
|
6. To run the Moorhen molecular graphics application:
|
|
80
74
|
`cd baby-gru`
|
|
81
75
|
`npm start`
|
|
82
|
-
And then point a web browser at `http://localhost:
|
|
76
|
+
And then point a web browser at `http://localhost:5173/` .
|
|
83
77
|
|
|
84
78
|
## **Updating**
|
|
85
79
|
|
|
@@ -96,14 +90,9 @@ And then point a web browser at `http://localhost:3000/` .
|
|
|
96
90
|
|
|
97
91
|
## **What else can do with the compiled libraries?**
|
|
98
92
|
|
|
99
|
-
See `example/example.cc` or `checkout/privateer-MKIV/src/privateer.cpp` to see how to create a command line (node) program. The
|
|
100
|
-
latter is quite long and a patched version of the original privateer code. It might be more helpful to look at the patch file
|
|
101
|
-
`patches/privateer-emscripten.patch`. This should show how to patch an existing command line program which reads files to one
|
|
102
|
-
that will work within node.
|
|
103
|
-
|
|
104
93
|
See `coot/moorhen-wrappers.cc` to see use of `EMSCRIPTEN_BINDINGS` to expose Coot methods to the web browser.
|
|
105
94
|
|
|
106
|
-
Any program you write, which uses the *subset* of Coot, Clipper,
|
|
95
|
+
Any program you write, which uses the *subset* of Coot, Clipper, code which this project compiles to WASM, can
|
|
107
96
|
itself be compiled to WASM and used within node or Web Browser. Studying the examples should show you to do I/O, which is
|
|
108
97
|
different in the 2 cases. If you require more classes or methods from the libraries to be exposed to JavaScript, then changes need to be made to
|
|
109
98
|
`coot/moorhen-wrappers.cc`. This should only be necessary for browser usage - in node your whole program can be written in C++.
|
package/baby-gru/CootWorker.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var cootModule,molecules_container,ccp4Module,__assign=this&&this.__assign||function(){return __assign=Object.assign||function(e){for(var a,t=1,r=arguments.length;t<r;t++)for(var s in a=arguments[t])Object.prototype.hasOwnProperty.call(a,s)&&(e[s]=a[s]);return e},__assign.apply(this,arguments)};importScripts("./wasm/moorhen.js"),importScripts("./wasm/web_example.js");var guid=function(){var e=Date.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(a){var t=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===a?t:3&t|8).toString(16)}))},print=function(e){console.log(e),postMessage({consoleMessage:JSON.stringify(e)})},instancedMeshToMeshData=function(e,a,t,r){void 0===t&&(t=!1),void 0===r&&(r=1e4);for(var s=[],o=[],n=[],i=[],c=[],_=[],l=[],u=[],d=[],m=e.geom,p=e.markup,h=m.size(),g=0;g<h;g++){var f=t,v=[],y=[],b=[],S=[],z=[],M=[],T=[],x=m.get(g);"spherical-atoms"===x.name&&(f=!0);for(var A=x.vertices,I=x.triangles,k=I.size(),w=0;w<k;w++){var D=I.get(w).point_id;a?(v.push(D[0]),v.push(D[2]),v.push(D[1])):(v.push(D[0]),v.push(D[1]),v.push(D[2]))}I.delete();for(var J=A.size(),F=0;F<J;F++){var N=A.get(F),C=N.pos;y.push(C[0]),y.push(C[1]),y.push(C[2]);var R=N.normal;b.push(R[0]),b.push(R[1]),b.push(R[2])}A.delete();var E=x.instancing_data_A,O=E.size();if(O>0)for(var U=0;U<O;U++){var P=(H=E.get(U)).position;M.push(P[0]),M.push(P[1]),M.push(P[2]);var L=H.colour;z.push(L[0]),z.push(L[1]),z.push(L[2]),z.push(L[3]);var B=H.size;S.push(B[0]),S.push(B[1]),S.push(B[2]),T.push.apply(T,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),H.delete()}E.delete();var j=x.instancing_data_B,q=j.size();if(q>0)for(U=0;U<q;U++){var H;if(!((B=(H=j.get(U)).size)[2]>r)){S.push(B[0]),S.push(B[1]),S.push(B[2]),P=H.position,M.push(P[0]),M.push(P[1]),M.push(P[2]),L=H.colour,z.push(L[0]),z.push(L[1]),z.push(L[2]),z.push(L[3]);var V=H.orientation;T.push(V[0][0]),T.push(V[0][1]),T.push(V[0][2]),T.push(V[0][3]),T.push(V[1][0]),T.push(V[1][1]),T.push(V[1][2]),T.push(V[1][3]),T.push(V[2][0]),T.push(V[2][1]),T.push(V[2][2]),T.push(V[2][3]),T.push(V[3][0]),T.push(V[3][1]),T.push(V[3][2]),T.push(V[3][3]),H.delete()}}j.delete(),n.push(b),o.push(y),s.push(v),i.push(S),_.push(M),l.push(T),c.push(z),u.push(!0),f?d.push("PERFECT_SPHERES"):d.push("TRIANGLES")}m.delete();var K=simpleMeshToMeshData(p);return K.idx_tri.length>0&&K.idx_tri[0].length>0&&K.idx_tri[0][0].length>0?t?{prim_types:[d,K.prim_types[0]],idx_tri:[s,K.idx_tri[0]],vert_tri:[_,K.vert_tri[0]],norm_tri:[n,K.norm_tri[0]],col_tri:[c,K.col_tri[0]],instance_use_colors:[u,null],instance_sizes:[i,null],instance_origins:[_,null],instance_orientations:[l,null]}:{prim_types:[d,K.prim_types[0]],idx_tri:[s,K.idx_tri[0]],vert_tri:[o,K.vert_tri[0]],norm_tri:[n,K.norm_tri[0]],col_tri:[c,K.col_tri[0]],instance_use_colors:[u,null],instance_sizes:[i,null],instance_origins:[_,null],instance_orientations:[l,null]}:{prim_types:[d],idx_tri:[s],vert_tri:[o],norm_tri:[n],col_tri:[c],instance_use_colors:[u],instance_sizes:[i],instance_origins:[_],instance_orientations:[l]}},simpleMeshToMeshData=function(e,a){void 0===a&&(a=!1);for(var t=e.vertices,r=e.triangles,s=[],o=[],n=[],i=[],c=r.size(),_=0;_<c;_++){var l=r.get(_).point_id;a?s.push.apply(s,[l[0],l[2],l[1]]):s.push.apply(s,l)}r.delete();var u=t.size();for(_=0;_<u;_++){var d=t.get(_),m=d.pos,p=d.normal,h=d.color;o.push.apply(o,m),a?n.push.apply(n,[-p[0],-p[1],-p[2]]):n.push.apply(n,p),i.push.apply(i,h)}return t.delete(),{prim_types:[["TRIANGLES"]],idx_tri:[[s]],vert_tri:[[o]],norm_tri:[[n]],col_tri:[[i]]}},SuperposeResultsToJSArray=function(e){for(var a=e.aligned_pairs,t=a.size(),r=[],s=0;s<t;s++){var o=a.get(s),n=o.first,i=n.residue_spec,c=o.second,_=c.residue_spec,l={reference:{chainId:i.chain_id,insCode:i.ins_code,seqNum:i.res_no,restype:"UNK",value:n.function_value,label:n.label},moving:{chainId:_.chain_id,insCode:_.ins_code,seqNum:_.res_no,restype:"UNK",value:c.function_value,label:c.label}};r.push(l)}return a.delete(),{referenceSequence:e.alignment.first,movingSequence:e.alignment.second,supperposeInfo:e.superpose_info,alignedPairsData:r}},colourRulesToJSArray=function(e){for(var a=[],t=e.size(),r=0;r<t;r++){var s=e.get(r);a.push(s)}return e.delete(),a},stringArrayArrayToJSArray=function(e){for(var a=[],t=e.size(),r=0;r<t;r++){for(var s=e.get(r),o=s.size(),n=[],i=0;i<o;i++){var c=s.get(i);n.push(c)}a.push(n),s.delete()}return e.delete(),a},floatArrayToJSArray=function(e){for(var a=[],t=e.size(),r=0;r<t;r++){var s=e.get(r);a.push(s)}return e.delete(),a},mapMoleculeCentreInfoToJSObject=function(e){var a=e.updated_centre,t={updated_centre:[a.x(),a.y(),a.z()],success:e.success,suggested_radius:e.suggested_radius,suggested_contour_level:e.suggested_contour_level};return a.delete(),t},intArrayToJSArray=function(e){for(var a=[],t=e.size(),r=0;r<t;r++){var s=e.get(r);a.push(s)}return e.delete(),a},stringArrayToJSArray=function(e){for(var a=[],t=e.size(),r=0;r<t;r++){var s=e.get(r);a.push(s)}return e.delete(),a},symmetryToJSData=function(e){for(var a=[],t=e.first,r=e.second,s=t.cell,o=t.symm_trans,n=o.size(),i=0;i<n;i++){var c=o.get(i),_=c.first,l=c.second,u=r.get(i);a.push({x:_.x(),y:_.y(),z:_.z(),asString:_.symm_as_string,isym:_.isym(),us:l.us,ws:l.ws,vs:l.vs,matrix:u}),_.delete()}return s.delete(),o.delete(),r.delete(),a},mmrrccStatsToJSArray=function(e){var a=function(e){for(var a=[],t=e.keys(),r=t.size(),s=0;s<r;s++){var o=t.get(s),n=e.get(o);a.push({resNum:o.res_no,insCode:o.ins_code,modelNumber:o.model_number,chainId:o.chain_id,n:n.n,correlation:n.correlation()}),n.delete()}return t.delete(),a},t=e.first,r=e.second,s={"All atoms":a(t),"Side-chains":a(r)};return t.delete(),r.delete(),s},atomSpecToJSArray=function(e){for(var a=[],t=e.size(),r=0;r<t;r++){var s=e.get(r);a.push({chain_id:s.chain_id,res_no:s.res_no,ins_code:s.ins_code,atom_name:s.atom_name,alt_conf:s.alt_conf,int_user_data:s.int_user_data,float_user_data:s.float_user_data,string_user_data:s.string_user_data,model_number:s.model_number})}return e.delete(),a},residueSpecToJSArray=function(e){for(var a=[],t=e.size(),r=0;r<t;r++){var s=e.get(r);a.push({resNum:s.res_no,insCode:s.ins_code,modelNumber:s.model_number,chainId:s.chain_id})}return e.delete(),a},validationDataToJSArray=function(e,a){void 0===a&&(a=null);for(var t=[],r=e.cviv,s=r.size(),o=0;o<s;o++){var n=r.get(o);if(null!==a&&n.chain_id!==a);else{for(var i=n.rviv,c=i.size(),_=0;_<c;_++){var l=i.get(_),u=l.residue_spec;t.push({chainId:u.chain_id,insCode:u.ins_code,seqNum:u.res_no,restype:"UNK",value:l.function_value})}i.delete()}}return r.delete(),e.delete(),t},linesBoxToJSArray=function(e){for(var a=[],t=e.line_segments,r=t.size(),s=0;s<r;s++){for(var o=[],n=t.get(s),i=n.size(),c=0;c<i;c++){var _=n.get(c),l=_.getStart(),u=_.getFinish(),d=_.amplitude(),m={x:l.x(),y:l.y(),z:l.z()},p={x:u.x(),y:u.y(),z:u.z()};o.push({start:m,end:p,dist:d}),l.delete(),u.delete(),_.delete()}n.delete(),a.push(o)}return t.delete(),a},vectorHBondToJSArray=function(e){for(var a=[],t=e.size(),r=0;r<t;r++){var s=e.get(r);a.push({hb_hydrogen:s.hb_hydrogen,donor:s.donor,acceptor:s.acceptor,donor_neigh:s.donor_neigh,acceptor_neigh:s.acceptor_neigh,angle_1:s.angle_1,angle_2:s.angle_2,angle_3:s.angle_3,dist:s.dist,ligand_atom_is_donor:s.ligand_atom_is_donor,hydrogen_is_ligand_atom:s.hydrogen_is_ligand_atom,bond_has_hydrogen_flag:s.bond_has_hydrogen_flag})}return e.delete(),a},interestingPlaceDataToJSArray=function(e){for(var a=[],t=e.size(),r=0;r<t;r++){var s=e.get(r),o=s.residue_spec;a.push({modelNumber:o.model_number,chainId:o.chain_id,insCode:o.ins_code,resNum:o.res_no,featureType:s.feature_type,featureValue:s.feature_value,buttonLabel:s.button_label,badness:s.badness,coordX:s.x,coordY:s.y,coordZ:s.z})}return e.delete(),a},histogramInfoToJSData=function(e){var a=e.counts;return{counts:intArrayToJSArray(a),bin_width:e.bin_width,base:e.base}},autoReadMtzInfoVectToJSArray=function(e){for(var a=[],t=e.size(),r=0;r<t;r++){var s=e.get(r);a.push({idx:s.idx,F:s.F,phi:s.phi,w:s.w,Rfree:s.Rfree,F_obs:s.F_obs,sigF_obs:s.sigF_obs,weights_used:s.weights_used})}return e.delete(),a},ramachandranDataToJSArray=function(e,a){for(var t=[],r=e.size(),s=0;s<r;s++){var o=e.get(s),n=o.phi_psi;n.chain_id===a&&t.push({chainId:n.chain_id,insCode:n.ins_code,seqNum:n.residue_number,restype:o.residue_name(),isOutlier:!o.is_allowed_flag,phi:n.phi(),psi:n.psi(),is_pre_pro:"PRO"===o.residue_name()}),o.delete(),n.delete()}return e.delete(),t},simpleMeshToLineMeshData=function(e,a){for(var t=e.vertices,r=e.triangles,s=[],o=[],n=[],i=[],c=r.size(),_=0;_<c;_++){var l=r.get(_).point_id;s.push.apply(s,[l[0],l[1],l[0],l[2],l[1],l[2]])}r.delete();var u=t.size();for(_=0;_<u;_++){var d=t.get(_);o.push.apply(o,d.pos),n.push.apply(n,d.normal),i.push.apply(i,d.color)}return t.delete(),a?{prim_types:[["NORMALLINES"]],useIndices:[[!0]],idx_tri:[[s]],vert_tri:[[o]],additional_norm_tri:[[n]],norm_tri:[[n]],col_tri:[[i]]}:{prim_types:[["LINES"]],useIndices:[[!0]],idx_tri:[[s]],vert_tri:[[o]],norm_tri:[[n]],col_tri:[[i]]}},auto_open_mtz=function(e){var a=guid(),t=new Uint8Array(e);cootModule.FS_createDataFile(".","".concat(a,".mtz"),t,!0,!0);var r="./".concat(a,".mtz"),s=molecules_container.auto_read_mtz(r);return cootModule.FS_unlink(r),s},replace_map_by_mtz_from_file=function(e,a,t){var r=guid(),s="./".concat(r,".mtz"),o=new Uint8Array(a);cootModule.FS_createDataFile(".",s,o,!0,!0);var n=[e,s,t.F,t.PHI,"",!1],i=molecules_container.replace_map_by_mtz_from_file.apply(molecules_container,n);return cootModule.FS_unlink(s),i},new_positions_for_residue_atoms=function(e,a){var t=0,r=new cootModule.Vectormoved_residue_t;return a.forEach((function(e){if(e.length>0){var a=e[0].label.split("/"),t=a[3].split("."),s=t[0],o=t[1];o=o||"";var n=new cootModule.moved_residue_t(a[2],parseInt(s),o);e.forEach((function(e){var a=new cootModule.moved_atom_t(e.name,e.alt_loc,e.x,e.y,e.z,-1);n.add_atom(a),a.delete()})),r.push_back(n),n.delete()}})),t+=molecules_container.new_positions_for_atoms_in_residues(e,r),r.delete(),t},read_mtz=function(e,a,t){var r=guid(),s=new Uint8Array(e);cootModule.FS_createDataFile(".","".concat(r,".mtz"),s,!0,!0);var o="./".concat(r,".mtz"),n=[o,t.F,t.PHI,"",!1,t.isDifference],i=molecules_container.read_mtz.apply(molecules_container,n);return cootModule.FS_unlink(o),i},associate_data_mtz_file_with_map=function(e,a,t,r,s){var o=new Uint8Array(a.data);cootModule.FS_createDataFile(".","".concat(a.fileName,".mtz"),o,!0,!0);var n="./".concat(a.fileName,".mtz"),i=[e,n,t,r,s];return molecules_container.associate_data_mtz_file_with_map.apply(molecules_container,i),n},read_ccp4_map=function(e,a,t){var r=guid(),s=new Uint8Array(e),o="";a.endsWith(".map.gz")?o="map.gz":a.endsWith(".mrc.gz")&&(o="mrc.gz"),cootModule.FS_createDataFile(".","".concat(r).concat(o),s,!0,!0);var n="./".concat(r).concat(o),i=[n,t],c=molecules_container.read_ccp4_map.apply(molecules_container,i);return cootModule.FS_unlink(n),c},setUserDefinedBondColours=function(e,a,t){void 0===t&&(t=!1);var r=new cootModule.MapIntFloat3,s=new cootModule.VectorStringUInt_pair;a.forEach((function(e,a){r.set(a+51,e.rgb);var t={first:e.cid,second:a+51};s.push_back(t)})),molecules_container.set_user_defined_bond_colours(e,r),molecules_container.set_user_defined_atom_colour_by_selection(e,s,t),s.delete(),r.delete()},doCootCommand=function(e){var a=e.returnType,t=e.command,r=e.commandArgs,s=e.messageId,o=e.myTimeStamp,n=e.message;try{var i=void 0;switch(t){case"shim_new_positions_for_residue_atoms":i=new_positions_for_residue_atoms.apply(void 0,r);break;case"shim_read_mtz":i=read_mtz.apply(void 0,r);break;case"shim_auto_open_mtz":i=auto_open_mtz.apply(void 0,r);break;case"shim_read_ccp4_map":i=read_ccp4_map.apply(void 0,r);break;case"shim_associate_data_mtz_file_with_map":i=associate_data_mtz_file_with_map.apply(void 0,r);break;case"shim_replace_map_by_mtz_from_file":i=replace_map_by_mtz_from_file.apply(void 0,r);break;case"shim_set_bond_colours":i=setUserDefinedBondColours.apply(void 0,r);break;default:i=molecules_container[t].apply(molecules_container,r)}var c=void 0;switch(a){case"string_array_array":c=stringArrayArrayToJSArray(i);break;case"instanced_mesh_perm":c=instancedMeshToMeshData(i,!0);break;case"histogram_info_t":c=histogramInfoToJSData(i);break;case"symmetry":c=symmetryToJSData(i);break;case"mmrrcc_stats":c=mmrrccStatsToJSArray(i);break;case"colour_rules":c=colourRulesToJSArray(i);break;case"instanced_mesh_perfect_spheres":c=instancedMeshToMeshData(i,!1,!0);break;case"instanced_mesh":c=instancedMeshToMeshData(i,!1,!1,5);break;case"mesh_perm":c=simpleMeshToMeshData(i,!0);break;case"mesh":c=simpleMeshToMeshData(i);break;case"lit_lines_mesh":c=simpleMeshToLineMeshData(i,!0);break;case"lines_mesh":c=simpleMeshToLineMeshData(i,!1);break;case"float_array":c=floatArrayToJSArray(i);break;case"int_array":c=intArrayToJSArray(i);break;case"auto_read_mtz_info_array":c=autoReadMtzInfoVectToJSArray(i);break;case"map_molecule_centre_info_t":c=mapMoleculeCentreInfoToJSObject(i);break;case"string_array":c=stringArrayToJSArray(i);break;case"residue_specs":c=residueSpecToJSArray(i);break;case"atom_specs":c=atomSpecToJSArray(i);break;case"ramachandran_data":c=ramachandranDataToJSArray(i,e.chainID);break;case"validation_data":c=validationDataToJSArray(i,e.chainID);break;case"interesting_places_data":c=interestingPlaceDataToJSArray(i);break;case"superpose_results":c=SuperposeResultsToJSArray(i);break;case"generic_3d_lines_bonds_box":c=linesBoxToJSArray(i);break;case"vector_hbond":c=vectorHBondToJSArray(i);break;case"status_instanced_mesh_pair":c={status:i.first,mesh:instancedMeshToMeshData(i.second,!1,!1,5)};break;case"void":c=null;break;default:c=i}return{messageId:s,messageSendTime:Date.now(),command:t,consoleMessage:"Completed ".concat(t," in ").concat(Date.now()-o," ms"),result:{status:"Completed",result:c}}}catch(e){return console.log(e),{messageId:s,myTimeStamp:o,message:n,consoleMessage:"EXCEPTION RAISED IN ".concat(t,", ").concat(e),result:{status:"Exception"}}}};onmessage=function(e){if("CootInitialize"===e.data.message)createRSRModule({locateFile:function(e){return"./wasm/".concat(e)},onRuntimeInitialized:function(){},mainScriptUrlOrBlob:"moorhen.js",print,printErr:print}).then((function(a){postMessage({consoleMessage:"Initialized molecules_container",message:e.data.message,messageId:e.data.messageId}),(molecules_container=new(cootModule=a).molecules_container_js(!1)).set_show_timings(!1),molecules_container.fill_rotamer_probability_tables(),molecules_container.set_map_sampling_rate(1.7),cootModule.FS.mkdir("COOT_BACKUP")})).catch((function(e){console.log(e),print(e)})),createCCP4Module({locateFile:function(e){return"./wasm/".concat(e)},onRuntimeInitialized:function(){},mainScriptUrlOrBlob:"web_example.js",print,printErr:print}).then((function(e){ccp4Module=e})).catch((function(e){console.log(e),print(e)}));else if("get_mtz_data"===e.data.message){var a=cootModule.FS.readFile(e.data.fileName,{encoding:"binary"});postMessage({messageId:e.data.messageId,myTimeStamp:e.data.myTimeStamp,consoleMessage:"Fetched mtz data for map ".concat(e.data.molNo),message:e.data.message,result:{molNo:e.data.molNo,mtzData:a}})}else if("get_map"===e.data.message){var t=guid(),r="./".concat(t,".map");molecules_container.writeCCP4Map(e.data.molNo,r);var s=cootModule.FS.readFile(r,{encoding:"binary"});cootModule.FS_unlink(r),postMessage({messageId:e.data.messageId,myTimeStamp:e.data.myTimeStamp,consoleMessage:"Fetched map of map ".concat(e.data.molNo),message:e.data.message,result:{molNo:e.data.molNo,mapData:s.buffer}})}else if("delete_file_name"===e.data.message){var o=cootModule.FS_unlink(e.data.fileName);postMessage({messageId:e.data.messageId,myTimeStamp:e.data.myTimeStamp,messageTag:"result",result:o})}else if("coot_command_list"===e.data.message){var n=e.data.commandList.map((function(a){return doCootCommand(__assign(__assign({},e.data),a))}));postMessage({messageId:e.data.messageId,resultList:n})}"coot_command"===e.data.message&&(o=doCootCommand(e.data),postMessage(o))};
|
|
1
|
+
var cootModule,molecules_container,ccp4Module,__assign=this&&this.__assign||function(){return __assign=Object.assign||function(e){for(var a,r=1,t=arguments.length;r<t;r++)for(var o in a=arguments[r])Object.prototype.hasOwnProperty.call(a,o)&&(e[o]=a[o]);return e},__assign.apply(this,arguments)};importScripts("./wasm/moorhen.js"),importScripts("./wasm/web_example.js");var guid=function(){var e=Date.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(a){var r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===a?r:3&r|8).toString(16)}))},print=function(e){console.log(e),postMessage({consoleMessage:JSON.stringify(e)})},instancedMeshToMeshData=function(e,a,r,t){void 0===r&&(r=!1),void 0===t&&(t=1e4);for(var o=[],s=[],n=[],i=[],c=[],l=[],_=[],u=[],d=[],m=e.geom,p=e.markup,h=m.size(),g=0;g<h;g++){var f=r,v=[],y=[],S=[],b=[],M=[],z=[],T=[],A=m.get(g);"spherical-atoms"===A.name&&(f=!0);for(var x=A.vertices,w=A.triangles,F=w.size(),I=0;I<F;I++){var k=w.get(I).point_id;a?(v.push(k[0]),v.push(k[2]),v.push(k[1])):(v.push(k[0]),v.push(k[1]),v.push(k[2]))}w.delete();for(var D=x.size(),J=0;J<D;J++){var C=x.get(J),N=C.pos;y.push(N[0]),y.push(N[1]),y.push(N[2]);var E=C.normal;S.push(E[0]),S.push(E[1]),S.push(E[2])}x.delete();var P=A.instancing_data_A,R=P.size();if(R>0)for(var U=0;U<R;U++){var L=(V=P.get(U)).position;z.push(L[0]),z.push(L[1]),z.push(L[2]);var O=V.colour;M.push(O[0]),M.push(O[1]),M.push(O[2]),M.push(O[3]);var B=V.size;b.push(B[0]),b.push(B[1]),b.push(B[2]),T.push.apply(T,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}P.delete();var j=A.instancing_data_B,H=j.size();if(H>0)for(U=0;U<H;U++){var V;if(!((B=(V=j.get(U)).size)[2]>t)){b.push(B[0]),b.push(B[1]),b.push(B[2]),L=V.position,z.push(L[0]),z.push(L[1]),z.push(L[2]),O=V.colour,M.push(O[0]),M.push(O[1]),M.push(O[2]),M.push(O[3]);var q=V.orientation;T.push(q[0][0]),T.push(q[0][1]),T.push(q[0][2]),T.push(q[0][3]),T.push(q[1][0]),T.push(q[1][1]),T.push(q[1][2]),T.push(q[1][3]),T.push(q[2][0]),T.push(q[2][1]),T.push(q[2][2]),T.push(q[2][3]),T.push(q[3][0]),T.push(q[3][1]),T.push(q[3][2]),T.push(q[3][3])}}j.delete(),n.push(S),s.push(y),o.push(v),i.push(b),l.push(z),_.push(T),c.push(M),u.push(!0),f?d.push("PERFECT_SPHERES"):d.push("TRIANGLES")}m.delete();var G=simpleMeshToMeshData(p);return G.idx_tri.length>0&&G.idx_tri[0].length>0&&G.idx_tri[0][0].length>0?r?{prim_types:[d,G.prim_types[0]],idx_tri:[o,G.idx_tri[0]],vert_tri:[l,G.vert_tri[0]],norm_tri:[n,G.norm_tri[0]],col_tri:[c,G.col_tri[0]],instance_use_colors:[u,null],instance_sizes:[i,null],instance_origins:[l,null],instance_orientations:[_,null]}:{prim_types:[d,G.prim_types[0]],idx_tri:[o,G.idx_tri[0]],vert_tri:[s,G.vert_tri[0]],norm_tri:[n,G.norm_tri[0]],col_tri:[c,G.col_tri[0]],instance_use_colors:[u,null],instance_sizes:[i,null],instance_origins:[l,null],instance_orientations:[_,null]}:{prim_types:[d],idx_tri:[o],vert_tri:[s],norm_tri:[n],col_tri:[c],instance_use_colors:[u],instance_sizes:[i],instance_origins:[l],instance_orientations:[_]}},simpleMeshToMeshData=function(e,a){void 0===a&&(a=!1);var r=performance.now(),t=e.vertices,o=e.triangles,s=t.size(),n=o.size(),i=new Uint32Array(3*n),c=new Float32Array(3*s),l=new Float32Array(3*s),_=new Float32Array(4*s);cootModule.getPositionsFromSimpleMesh2(e,c),cootModule.getColoursFromSimpleMesh2(e,_),a?(cootModule.getReversedNormalsFromSimpleMesh2(e,l),cootModule.getPermutedTriangleIndicesFromSimpleMesh2(e,i)):(cootModule.getNormalsFromSimpleMesh2(e,l),cootModule.getTriangleIndicesFromSimpleMesh2(e,i));var u=performance.now();console.log("DEBUG: SIMPLE MESH TO MESH DATA C++",u-r);var d=c,m=_,p=l,h=i,g=performance.now();return console.log("DEBUG: SIMPLE MESH TO MESH DATA",g-r),t.delete(),o.delete(),{prim_types:[["TRIANGLES"]],idx_tri:[[h]],vert_tri:[[d]],norm_tri:[[p]],col_tri:[[m]]}},SuperposeResultsToJSArray=function(e){for(var a=e.aligned_pairs,r=a.size(),t=[],o=0;o<r;o++){var s=a.get(o),n=s.first,i=n.residue_spec,c=s.second,l=c.residue_spec,_={reference:{chainId:i.chain_id,insCode:i.ins_code,seqNum:i.res_no,restype:"UNK",value:n.function_value,label:n.label},moving:{chainId:l.chain_id,insCode:l.ins_code,seqNum:l.res_no,restype:"UNK",value:c.function_value,label:c.label}};t.push(_)}return a.delete(),{referenceSequence:e.alignment.first,movingSequence:e.alignment.second,supperposeInfo:e.superpose_info,alignedPairsData:t}},colourRulesToJSArray=function(e){for(var a=[],r=e.size(),t=0;t<r;t++){var o=e.get(t);a.push(o)}return e.delete(),a},stringArrayArrayToJSArray=function(e){for(var a=[],r=e.size(),t=0;t<r;t++){for(var o=e.get(t),s=o.size(),n=[],i=0;i<s;i++){var c=o.get(i);n.push(c)}a.push(n),o.delete()}return e.delete(),a},floatArrayToJSArray=function(e){for(var a=[],r=e.size(),t=0;t<r;t++){var o=e.get(t);a.push(o)}return e.delete(),a},mapMoleculeCentreInfoToJSObject=function(e){var a=e.updated_centre,r={updated_centre:[a.x(),a.y(),a.z()],success:e.success,suggested_radius:e.suggested_radius,suggested_contour_level:e.suggested_contour_level};return a.delete(),r},fitLigandInfoArrayToJSArray=function(e){for(var a=[],r=e.size(),t=0;t<r;t++){var o=e.get(t);a.push(__assign({},o))}return e.delete(),a},intArrayToJSArray=function(e){for(var a=[],r=e.size(),t=0;t<r;t++){var o=e.get(t);a.push(o)}return e.delete(),a},stringArrayToJSArray=function(e){for(var a=[],r=e.size(),t=0;t<r;t++){var o=e.get(t);a.push(o)}return e.delete(),a},symmetryToJSData=function(e){for(var a=[],r=e.first,t=e.second,o=r.cell,s=r.symm_trans,n=s.size(),i=0;i<n;i++){var c=s.get(i),l=c.first,_=c.second,u=t.get(i);a.push({x:l.x(),y:l.y(),z:l.z(),asString:l.symm_as_string,isym:l.isym(),us:_.us,ws:_.ws,vs:_.vs,matrix:u}),l.delete()}return o.delete(),s.delete(),t.delete(),a},mmrrccStatsToJSArray=function(e){var a=function(e){for(var a=[],r=e.keys(),t=r.size(),o=0;o<t;o++){var s=r.get(o),n=e.get(s);a.push({resNum:s.res_no,insCode:s.ins_code,modelNumber:s.model_number,chainId:s.chain_id,n:n.n,correlation:n.correlation()}),n.delete()}return r.delete(),a},r=e.first,t=e.second,o={"All atoms":a(r),"Side-chains":a(t)};return r.delete(),t.delete(),o},atomSpecToJSArray=function(e){for(var a=[],r=e.size(),t=0;t<r;t++){var o=e.get(t);a.push({chain_id:o.chain_id,res_no:o.res_no,ins_code:o.ins_code,atom_name:o.atom_name,alt_conf:o.alt_conf,int_user_data:o.int_user_data,float_user_data:o.float_user_data,string_user_data:o.string_user_data,model_number:o.model_number})}return e.delete(),a},residueSpecToJSArray=function(e){for(var a=[],r=e.size(),t=0;t<r;t++){var o=e.get(t);a.push({resNum:o.res_no,insCode:o.ins_code,modelNumber:o.model_number,chainId:o.chain_id,intUserData:o.int_user_data})}return e.delete(),a},stringPairVectorToJSArray=function(e){for(var a=[],r=e.size(),t=0;t<r;t++){var o=e.get(t);a.push({first:o.first,second:o.second})}return e.delete(),a},validationDataToJSArray=function(e,a){void 0===a&&(a=null);for(var r=[],t=e.cviv,o=t.size(),s=0;s<o;s++){var n=t.get(s);if(null!==a&&n.chain_id!==a);else{for(var i=n.rviv,c=i.size(),l=0;l<c;l++){var _=i.get(l),u=_.residue_spec;r.push({chainId:u.chain_id,insCode:u.ins_code,seqNum:u.res_no,restype:"UNK",value:_.function_value})}i.delete()}}return t.delete(),e.delete(),r},linesBoxToJSArray=function(e){for(var a=[],r=e.line_segments,t=r.size(),o=0;o<t;o++){for(var s=[],n=r.get(o),i=n.size(),c=0;c<i;c++){var l=n.get(c),_=l.getStart(),u=l.getFinish(),d=l.amplitude(),m={x:_.x(),y:_.y(),z:_.z()},p={x:u.x(),y:u.y(),z:u.z()};s.push({start:m,end:p,dist:d}),_.delete(),u.delete(),l.delete()}n.delete(),a.push(s)}return r.delete(),a},vectorHBondToJSArray=function(e){for(var a=[],r=e.size(),t=0;t<r;t++){var o=e.get(t);a.push({hb_hydrogen:o.hb_hydrogen,donor:o.donor,acceptor:o.acceptor,donor_neigh:o.donor_neigh,acceptor_neigh:o.acceptor_neigh,angle_1:o.angle_1,angle_2:o.angle_2,angle_3:o.angle_3,dist:o.dist,ligand_atom_is_donor:o.ligand_atom_is_donor,hydrogen_is_ligand_atom:o.hydrogen_is_ligand_atom,bond_has_hydrogen_flag:o.bond_has_hydrogen_flag})}return e.delete(),a},interestingPlaceDataToJSArray=function(e){for(var a=[],r=e.size(),t=0;t<r;t++){var o=e.get(t),s=o.residue_spec;a.push({intUserData:s.int_user_data,modelNumber:s.model_number,chainId:s.chain_id,insCode:s.ins_code,resNum:s.res_no,featureType:o.feature_type,featureValue:o.feature_value,buttonLabel:o.button_label,badness:o.badness,coordX:o.x,coordY:o.y,coordZ:o.z})}return e.delete(),a},histogramInfoToJSData=function(e){var a=e.counts;return{counts:intArrayToJSArray(a),bin_width:e.bin_width,base:e.base}},autoReadMtzInfoVectToJSArray=function(e){for(var a=[],r=e.size(),t=0;t<r;t++){var o=e.get(t);a.push({idx:o.idx,F:o.F,phi:o.phi,w:o.w,Rfree:o.Rfree,F_obs:o.F_obs,sigF_obs:o.sigF_obs,weights_used:o.weights_used})}return e.delete(),a},ramachandranDataToJSArray=function(e,a){for(var r=[],t=e.size(),o=0;o<t;o++){var s=e.get(o),n=s.phi_psi;n.chain_id===a&&r.push({chainId:n.chain_id,insCode:n.ins_code,seqNum:n.residue_number,restype:s.residue_name(),isOutlier:!s.is_allowed_flag,phi:n.phi(),psi:n.psi(),is_pre_pro:"PRO"===s.residue_name()}),s.delete(),n.delete()}return e.delete(),r},vectorPairClipperCoordFloatToJSArray=function(e){for(var a=[],r=e.size(),t=0;t<r;t++){var o=e.get(t),s=o.second,n=o.first,i={x:n.x(),y:n.y(),z:n.z()};n.delete(),a.push({value:s,coord:i})}return e.delete(),a},simpleMeshToLineMeshData=function(e,a){performance.now();var r=e.vertices,t=e.triangles,o=t.size(),s=r.size(),n=new Uint32Array(6*o),i=new Float32Array(3*s),c=new Float32Array(3*s),l=new Float32Array(4*s);cootModule.getLineIndicesFromSimpleMesh2(e,n),cootModule.getPositionsFromSimpleMesh2(e,i),cootModule.getNormalsFromSimpleMesh2(e,c),cootModule.getColoursFromSimpleMesh2(e,l),performance.now();var _=n,u=i,d=c,m=l;return r.delete(),t.delete(),a?{prim_types:[["NORMALLINES"]],useIndices:[[!0]],idx_tri:[[_]],vert_tri:[[u]],additional_norm_tri:[[d]],norm_tri:[[d]],col_tri:[[m]]}:{prim_types:[["LINES"]],useIndices:[[!0]],idx_tri:[[_]],vert_tri:[[u]],norm_tri:[[d]],col_tri:[[m]]}},auto_open_mtz=function(e){var a=guid(),r=new Uint8Array(e);cootModule.FS_createDataFile(".","".concat(a,".mtz"),r,!0,!0);var t="./".concat(a,".mtz"),o=molecules_container.auto_read_mtz(t);return cootModule.FS_unlink(t),o},replace_map_by_mtz_from_file=function(e,a,r){var t=guid(),o="./".concat(t,".mtz"),s=new Uint8Array(a);cootModule.FS_createDataFile(".",o,s,!0,!0);var n=[e,o,r.F,r.PHI,"",!1],i=molecules_container.replace_map_by_mtz_from_file.apply(molecules_container,n);return cootModule.FS_unlink(o),i},new_positions_for_residue_atoms=function(e,a){var r=0,t=new cootModule.Vectormoved_residue_t;return a.forEach((function(e){if(e.length>0){var a=e[0].label.split("/"),r=a[3].split("."),o=r[0],s=r[1];s=s||"";var n=new cootModule.moved_residue_t(a[2],parseInt(o),s);e.forEach((function(e){var a=new cootModule.moved_atom_t(e.name,e.alt_loc,e.x,e.y,e.z,-1);n.add_atom(a),a.delete()})),t.push_back(n),n.delete()}})),r+=molecules_container.new_positions_for_atoms_in_residues(e,t),t.delete(),r},read_mtz=function(e,a,r){var t=guid(),o=new Uint8Array(e);cootModule.FS_createDataFile(".","".concat(t,".mtz"),o,!0,!0);var s="./".concat(t,".mtz"),n=[s,r.F,r.PHI,"",!1,r.isDifference],i=molecules_container.read_mtz.apply(molecules_container,n);return cootModule.FS_unlink(s),i},associate_data_mtz_file_with_map=function(e,a,r,t,o){var s=new Uint8Array(a.data);cootModule.FS_createDataFile(".","".concat(a.fileName,".mtz"),s,!0,!0);var n="./".concat(a.fileName,".mtz"),i=[e,n,r,t,o];return molecules_container.associate_data_mtz_file_with_map.apply(molecules_container,i),n},read_ccp4_map=function(e,a,r){var t=guid(),o=new Uint8Array(e),s="";a.endsWith(".map.gz")?s="map.gz":a.endsWith(".mrc.gz")&&(s="mrc.gz"),cootModule.FS_createDataFile(".","".concat(t).concat(s),o,!0,!0);var n="./".concat(t).concat(s),i=[n,r],c=molecules_container.read_ccp4_map.apply(molecules_container,i);return cootModule.FS_unlink(n),c},setUserDefinedBondColours=function(e,a,r){void 0===r&&(r=!1);var t=new cootModule.MapIntFloat3,o=new cootModule.VectorStringUInt_pair;a.forEach((function(e,a){t.set(a+51,e.rgb);var r={first:e.cid,second:a+51};o.push_back(r)})),molecules_container.set_user_defined_bond_colours(e,t),molecules_container.set_user_defined_atom_colour_by_selection(e,o,r),o.delete(),t.delete()},doCootCommand=function(e){var a=e.returnType,r=e.command,t=e.commandArgs,o=e.messageId,s=e.myTimeStamp,n=e.message;try{var i=void 0;switch(r){case"shim_new_positions_for_residue_atoms":i=new_positions_for_residue_atoms.apply(void 0,t);break;case"shim_read_mtz":i=read_mtz.apply(void 0,t);break;case"shim_auto_open_mtz":i=auto_open_mtz.apply(void 0,t);break;case"shim_read_ccp4_map":i=read_ccp4_map.apply(void 0,t);break;case"shim_associate_data_mtz_file_with_map":i=associate_data_mtz_file_with_map.apply(void 0,t);break;case"shim_replace_map_by_mtz_from_file":i=replace_map_by_mtz_from_file.apply(void 0,t);break;case"shim_set_bond_colours":i=setUserDefinedBondColours.apply(void 0,t);break;default:i=molecules_container[r].apply(molecules_container,t)}var c=void 0;switch(a){case"fit_ligand_info_array":c=fitLigandInfoArrayToJSArray(i);break;case"string_array_array":c=stringArrayArrayToJSArray(i);break;case"instanced_mesh_perm":c=instancedMeshToMeshData(i,!0);break;case"histogram_info_t":c=histogramInfoToJSData(i);break;case"symmetry":c=symmetryToJSData(i);break;case"mmrrcc_stats":c=mmrrccStatsToJSArray(i);break;case"colour_rules":c=colourRulesToJSArray(i);break;case"instanced_mesh_perfect_spheres":c=instancedMeshToMeshData(i,!1,!0);break;case"instanced_mesh":c=instancedMeshToMeshData(i,!1,!1,5);break;case"mesh_perm":c=simpleMeshToMeshData(i,!0);break;case"mesh":c=simpleMeshToMeshData(i);break;case"lit_lines_mesh":c=simpleMeshToLineMeshData(i,!0);break;case"lines_mesh":c=simpleMeshToLineMeshData(i,!1);break;case"float_array":c=floatArrayToJSArray(i);break;case"int_array":c=intArrayToJSArray(i);break;case"auto_read_mtz_info_array":c=autoReadMtzInfoVectToJSArray(i);break;case"map_molecule_centre_info_t":c=mapMoleculeCentreInfoToJSObject(i);break;case"string_array":c=stringArrayToJSArray(i);break;case"residue_specs":c=residueSpecToJSArray(i);break;case"atom_specs":c=atomSpecToJSArray(i);break;case"ramachandran_data":c=ramachandranDataToJSArray(i,e.chainID);break;case"validation_data":c=validationDataToJSArray(i,e.chainID);break;case"interesting_places_data":c=interestingPlaceDataToJSArray(i);break;case"superpose_results":c=SuperposeResultsToJSArray(i);break;case"generic_3d_lines_bonds_box":c=linesBoxToJSArray(i);break;case"vector_hbond":c=vectorHBondToJSArray(i);break;case"status_instanced_mesh_pair":c={status:i.first,mesh:instancedMeshToMeshData(i.second,!1,!1,5)};break;case"string_string_pair_vector":c=stringPairVectorToJSArray(i);break;case"void":c=null;break;case"vector_pair_clipper_coord_float":c=vectorPairClipperCoordFloatToJSArray(i);break;default:c=i}return{messageId:o,messageSendTime:Date.now(),command:r,consoleMessage:"Completed ".concat(r," in ").concat(Date.now()-s," ms"),result:{status:"Completed",result:c}}}catch(e){return console.log(e),{messageId:o,myTimeStamp:s,message:n,consoleMessage:"EXCEPTION RAISED IN ".concat(r,", ").concat(e),result:{status:"Exception"}}}};onmessage=function(e){if("CootInitialize"===e.data.message)createRSRModule({locateFile:function(e){return"./wasm/".concat(e)},onRuntimeInitialized:function(){},mainScriptUrlOrBlob:"moorhen.js",print,printErr:print}).then((function(a){postMessage({consoleMessage:"Initialized molecules_container",message:e.data.message,messageId:e.data.messageId}),(molecules_container=new(cootModule=a).molecules_container_js(!1)).set_show_timings(!1),molecules_container.fill_rotamer_probability_tables(),molecules_container.set_map_sampling_rate(1.7),molecules_container.set_map_is_contoured_with_thread_pool(!0),molecules_container.set_max_number_of_threads(3),cootModule.FS.mkdir("COOT_BACKUP")})).catch((function(e){console.log(e),print(e)})),createCCP4Module({locateFile:function(e){return"./wasm/".concat(e)},onRuntimeInitialized:function(){},mainScriptUrlOrBlob:"web_example.js",print,printErr:print}).then((function(e){ccp4Module=e})).catch((function(e){console.log(e),print(e)}));else if("get_mtz_data"===e.data.message){var a=cootModule.FS.readFile(e.data.fileName,{encoding:"binary"});postMessage({messageId:e.data.messageId,myTimeStamp:e.data.myTimeStamp,consoleMessage:"Fetched mtz data for map ".concat(e.data.molNo),message:e.data.message,result:{molNo:e.data.molNo,mtzData:a}})}else if("get_map"===e.data.message){var r=guid(),t="./".concat(r,".map");molecules_container.writeCCP4Map(e.data.molNo,t);var o=cootModule.FS.readFile(t,{encoding:"binary"});cootModule.FS_unlink(t),postMessage({messageId:e.data.messageId,myTimeStamp:e.data.myTimeStamp,consoleMessage:"Fetched map of map ".concat(e.data.molNo),message:e.data.message,result:{molNo:e.data.molNo,mapData:o.buffer}})}else if("delete_file_name"===e.data.message){var s=cootModule.FS_unlink(e.data.fileName);postMessage({messageId:e.data.messageId,myTimeStamp:e.data.myTimeStamp,messageTag:"result",result:s})}else if("coot_command_list"===e.data.message){var n=e.data.commandList.map((function(a){return doCootCommand(__assign(__assign({},e.data),a))}));postMessage({messageId:e.data.messageId,resultList:n})}"coot_command"===e.data.message&&(s=doCootCommand(e.data),postMessage(s))};
|
package/baby-gru/CootWorker.ts
CHANGED
|
@@ -114,8 +114,6 @@ const instancedMeshToMeshData = (instanceMesh: libcootApi.InstancedMeshT, perm:
|
|
|
114
114
|
0.0, 0.0, 1.0, 0.0,
|
|
115
115
|
0.0, 0.0, 0.0, 1.0,
|
|
116
116
|
])
|
|
117
|
-
|
|
118
|
-
inst_data.delete()
|
|
119
117
|
}
|
|
120
118
|
}
|
|
121
119
|
As.delete()
|
|
@@ -164,8 +162,6 @@ const instancedMeshToMeshData = (instanceMesh: libcootApi.InstancedMeshT, perm:
|
|
|
164
162
|
thisInstance_orientations.push(instDataOrientation[3][1])
|
|
165
163
|
thisInstance_orientations.push(instDataOrientation[3][2])
|
|
166
164
|
thisInstance_orientations.push(instDataOrientation[3][3])
|
|
167
|
-
|
|
168
|
-
inst_data.delete()
|
|
169
165
|
}
|
|
170
166
|
}
|
|
171
167
|
Bs.delete()
|
|
@@ -230,38 +226,47 @@ const instancedMeshToMeshData = (instanceMesh: libcootApi.InstancedMeshT, perm:
|
|
|
230
226
|
}
|
|
231
227
|
|
|
232
228
|
const simpleMeshToMeshData = (simpleMesh: libcootApi.SimpleMeshT, perm: boolean = false): libcootApi.SimpleMeshJS => {
|
|
229
|
+
|
|
230
|
+
const print_timing = true;
|
|
231
|
+
const ts = performance.now()
|
|
232
|
+
|
|
233
233
|
const vertices = simpleMesh.vertices;
|
|
234
234
|
const triangles = simpleMesh.triangles;
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
let totNorm: number[] = [];
|
|
238
|
-
let totCol: number[] = [];
|
|
239
|
-
|
|
235
|
+
|
|
236
|
+
const verticesSize = vertices.size();
|
|
240
237
|
const trianglesSize = triangles.size()
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
238
|
+
|
|
239
|
+
let totIdxs_C = new Uint32Array(trianglesSize*3)
|
|
240
|
+
let totPos_C = new Float32Array(verticesSize*3)
|
|
241
|
+
let totNorm_C = new Float32Array(verticesSize*3)
|
|
242
|
+
let totCol_C = new Float32Array(verticesSize*4)
|
|
243
|
+
|
|
244
|
+
cootModule.getPositionsFromSimpleMesh2(simpleMesh,totPos_C)
|
|
245
|
+
cootModule.getColoursFromSimpleMesh2(simpleMesh,totCol_C)
|
|
246
|
+
|
|
247
|
+
if (perm){
|
|
248
|
+
cootModule.getReversedNormalsFromSimpleMesh2(simpleMesh,totNorm_C)
|
|
249
|
+
cootModule.getPermutedTriangleIndicesFromSimpleMesh2(simpleMesh,totIdxs_C)
|
|
250
|
+
} else {
|
|
251
|
+
cootModule.getNormalsFromSimpleMesh2(simpleMesh,totNorm_C)
|
|
252
|
+
cootModule.getTriangleIndicesFromSimpleMesh2(simpleMesh,totIdxs_C)
|
|
248
253
|
}
|
|
249
|
-
triangles.delete()
|
|
250
254
|
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
totCol.push(...vertColor);
|
|
255
|
+
const tm = performance.now()
|
|
256
|
+
if(print_timing) console.log("DEBUG: SIMPLE MESH TO MESH DATA C++",tm-ts)
|
|
257
|
+
|
|
258
|
+
let totPos = totPos_C
|
|
259
|
+
let totCol = totCol_C
|
|
260
|
+
let totNorm = totNorm_C
|
|
261
|
+
let totIdxs = totIdxs_C
|
|
262
|
+
|
|
263
|
+
if(print_timing) {
|
|
264
|
+
const te = performance.now()
|
|
265
|
+
console.log("DEBUG: SIMPLE MESH TO MESH DATA",te-ts)
|
|
263
266
|
}
|
|
264
|
-
|
|
267
|
+
|
|
268
|
+
vertices.delete();
|
|
269
|
+
triangles.delete();
|
|
265
270
|
|
|
266
271
|
return {
|
|
267
272
|
prim_types: [["TRIANGLES"]],
|
|
@@ -373,6 +378,19 @@ const mapMoleculeCentreInfoToJSObject = (mapMoleculeCentreInfo: libcootApi.MapMo
|
|
|
373
378
|
return returnResult;
|
|
374
379
|
}
|
|
375
380
|
|
|
381
|
+
const fitLigandInfoArrayToJSArray = (fitLigandInfoVec: emscriptem.vector<libcootApi.fitLigandInfo>): libcootApi.fitLigandInfo[] => {
|
|
382
|
+
const result: libcootApi.fitLigandInfo[] = []
|
|
383
|
+
|
|
384
|
+
const fitLigandInfoVecSize = fitLigandInfoVec.size()
|
|
385
|
+
for (let i = 0; i < fitLigandInfoVecSize; i++) {
|
|
386
|
+
const fitLigandInfo = fitLigandInfoVec.get(i)
|
|
387
|
+
result.push({ ...fitLigandInfo })
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
fitLigandInfoVec.delete()
|
|
391
|
+
return result
|
|
392
|
+
}
|
|
393
|
+
|
|
376
394
|
const intArrayToJSArray = (intArray: emscriptem.vector<number>) => {
|
|
377
395
|
let returnResult: number[] = []
|
|
378
396
|
const intArraySize = intArray.size()
|
|
@@ -486,7 +504,7 @@ const atomSpecToJSArray = (atomSpecs: emscriptem.vector<libcootApi.AtomSpecT>):
|
|
|
486
504
|
}
|
|
487
505
|
|
|
488
506
|
const residueSpecToJSArray = (residueSpecs: emscriptem.vector<libcootApi.ResidueSpecT>): libcootApi.ResidueSpecJS[] => {
|
|
489
|
-
let returnResult: { resNum: number; insCode: string; modelNumber: number; chainId: string; }[] = []
|
|
507
|
+
let returnResult: { resNum: number; insCode: string; modelNumber: number; chainId: string; intUserData: number; }[] = []
|
|
490
508
|
const residuesSize = residueSpecs.size()
|
|
491
509
|
for (let ic = 0; ic < residuesSize; ic++) {
|
|
492
510
|
const residue = residueSpecs.get(ic)
|
|
@@ -494,13 +512,25 @@ const residueSpecToJSArray = (residueSpecs: emscriptem.vector<libcootApi.Residue
|
|
|
494
512
|
resNum: residue.res_no,
|
|
495
513
|
insCode: residue.ins_code,
|
|
496
514
|
modelNumber: residue.model_number,
|
|
497
|
-
chainId: residue.chain_id
|
|
515
|
+
chainId: residue.chain_id,
|
|
516
|
+
intUserData: residue.int_user_data
|
|
498
517
|
})
|
|
499
518
|
}
|
|
500
519
|
residueSpecs.delete()
|
|
501
520
|
return returnResult
|
|
502
521
|
}
|
|
503
522
|
|
|
523
|
+
const stringPairVectorToJSArray = (stringPairsVector: emscriptem.vector<libcootApi.PairType<string, string>>) => {
|
|
524
|
+
let result: { first: string; second: string }[] = []
|
|
525
|
+
const stringPairsVectorSize = stringPairsVector.size()
|
|
526
|
+
for (let ic = 0; ic < stringPairsVectorSize; ic++) {
|
|
527
|
+
const data = stringPairsVector.get(ic)
|
|
528
|
+
result.push({first: data.first, second: data.second})
|
|
529
|
+
}
|
|
530
|
+
stringPairsVector.delete()
|
|
531
|
+
return result
|
|
532
|
+
}
|
|
533
|
+
|
|
504
534
|
const validationDataToJSArray = (validationData: libcootApi.ValidationInformationT, chainID: string | null = null): libcootApi.ValidationInformationJS[] => {
|
|
505
535
|
let returnResult: { chainId: string; insCode: string; seqNum: number; restype: string; value: number; }[] = []
|
|
506
536
|
const cviv = validationData.cviv
|
|
@@ -589,6 +619,7 @@ const vectorHBondToJSArray = (HBondData: emscriptem.vector<libcootApi.MoorhenHBo
|
|
|
589
619
|
|
|
590
620
|
const interestingPlaceDataToJSArray = (interestingPlaceData: emscriptem.vector<libcootApi.InterestingPlaceT>): libcootApi.InterestingPlaceDataJS[] => {
|
|
591
621
|
let returnResult: {
|
|
622
|
+
intUserData: number;
|
|
592
623
|
modelNumber: number;
|
|
593
624
|
chainId: string;
|
|
594
625
|
insCode: string;
|
|
@@ -607,6 +638,7 @@ const interestingPlaceDataToJSArray = (interestingPlaceData: emscriptem.vector<l
|
|
|
607
638
|
const residue = interestingPlaceData.get(ir)
|
|
608
639
|
const residueSpec = residue.residue_spec
|
|
609
640
|
returnResult.push({
|
|
641
|
+
intUserData: residueSpec.int_user_data,
|
|
610
642
|
modelNumber: residueSpec.model_number,
|
|
611
643
|
chainId: residueSpec.chain_id,
|
|
612
644
|
insCode: residueSpec.ins_code,
|
|
@@ -690,30 +722,59 @@ const ramachandranDataToJSArray = (ramachandraData: emscriptem.vector<libcootApi
|
|
|
690
722
|
return returnResult
|
|
691
723
|
}
|
|
692
724
|
|
|
725
|
+
const vectorPairClipperCoordFloatToJSArray = (vectorData: emscriptem.vector<{first: libcootApi.CootCartesian; second: number}>): libcootApi.DiffDiffMapPeaksJS => {
|
|
726
|
+
let result: {value: number; coord: { x: number; y: number; z: number }}[] = []
|
|
727
|
+
const vectorSize = vectorData.size()
|
|
728
|
+
for(let i = 0; i < vectorSize; i++) {
|
|
729
|
+
const pair = vectorData.get(i)
|
|
730
|
+
const value = pair.second
|
|
731
|
+
const clipperCoord = pair.first
|
|
732
|
+
const coord = {
|
|
733
|
+
x: clipperCoord.x(),
|
|
734
|
+
y: clipperCoord.y(),
|
|
735
|
+
z: clipperCoord.z(),
|
|
736
|
+
}
|
|
737
|
+
clipperCoord.delete()
|
|
738
|
+
result.push({value, coord})
|
|
739
|
+
}
|
|
740
|
+
vectorData.delete()
|
|
741
|
+
return result
|
|
742
|
+
}
|
|
743
|
+
|
|
693
744
|
const simpleMeshToLineMeshData = (simpleMesh: libcootApi.SimpleMeshT, normalLighting: boolean): libcootApi.SimpleMeshJS => {
|
|
745
|
+
|
|
746
|
+
const print_timing = false;
|
|
747
|
+
const ts = performance.now()
|
|
748
|
+
|
|
694
749
|
const vertices = simpleMesh.vertices;
|
|
695
750
|
const triangles = simpleMesh.triangles;
|
|
696
|
-
let totIdxs: number[] = [];
|
|
697
|
-
let totPos: number[] = [];
|
|
698
|
-
let totNorm: number[] = [];
|
|
699
|
-
let totCol: number[] = [];
|
|
700
|
-
|
|
701
751
|
const trianglesSize = triangles.size()
|
|
702
|
-
for (let i = 0; i < trianglesSize; i++) {
|
|
703
|
-
const triangle = triangles.get(i)
|
|
704
|
-
const idxs = triangle.point_id;
|
|
705
|
-
totIdxs.push(...[idxs[0], idxs[1], idxs[0], idxs[2], idxs[1], idxs[2]]);
|
|
706
|
-
}
|
|
707
|
-
triangles.delete()
|
|
708
|
-
|
|
709
752
|
const verticesSize = vertices.size()
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
753
|
+
|
|
754
|
+
let totIdxs_C = new Uint32Array(trianglesSize*6)
|
|
755
|
+
let totPos_C = new Float32Array(verticesSize*3)
|
|
756
|
+
let totNorm_C = new Float32Array(verticesSize*3)
|
|
757
|
+
let totCol_C = new Float32Array(verticesSize*4)
|
|
758
|
+
cootModule.getLineIndicesFromSimpleMesh2(simpleMesh,totIdxs_C)
|
|
759
|
+
cootModule.getPositionsFromSimpleMesh2(simpleMesh,totPos_C)
|
|
760
|
+
cootModule.getNormalsFromSimpleMesh2(simpleMesh,totNorm_C)
|
|
761
|
+
cootModule.getColoursFromSimpleMesh2(simpleMesh,totCol_C)
|
|
762
|
+
|
|
763
|
+
const tm = performance.now()
|
|
764
|
+
if(print_timing) console.log("DEBUG: SIMPLE MESH TO LINE MESH DATA C++",tm-ts)
|
|
765
|
+
|
|
766
|
+
let totIdxs = totIdxs_C
|
|
767
|
+
let totPos = totPos_C
|
|
768
|
+
let totNorm = totNorm_C
|
|
769
|
+
let totCol = totCol_C
|
|
770
|
+
|
|
771
|
+
if(print_timing) {
|
|
772
|
+
const te = performance.now()
|
|
773
|
+
console.log("SIMPLE MESH TO LINE MESH DATA",te-ts)
|
|
715
774
|
}
|
|
716
|
-
|
|
775
|
+
|
|
776
|
+
vertices.delete();
|
|
777
|
+
triangles.delete();
|
|
717
778
|
|
|
718
779
|
if (normalLighting)
|
|
719
780
|
return { prim_types: [["NORMALLINES"]], useIndices: [[true]], idx_tri: [[totIdxs]], vert_tri: [[totPos]], additional_norm_tri: [[totNorm]], norm_tri: [[totNorm]], col_tri: [[totCol]] };
|
|
@@ -866,6 +927,9 @@ const doCootCommand = (messageData: {
|
|
|
866
927
|
|
|
867
928
|
let returnResult;
|
|
868
929
|
switch (returnType) {
|
|
930
|
+
case 'fit_ligand_info_array':
|
|
931
|
+
returnResult = fitLigandInfoArrayToJSArray(cootResult)
|
|
932
|
+
break;
|
|
869
933
|
case 'string_array_array':
|
|
870
934
|
returnResult = stringArrayArrayToJSArray(cootResult)
|
|
871
935
|
break;
|
|
@@ -944,13 +1008,20 @@ const doCootCommand = (messageData: {
|
|
|
944
1008
|
case 'status_instanced_mesh_pair':
|
|
945
1009
|
returnResult = { status: cootResult.first, mesh: instancedMeshToMeshData(cootResult.second, false, false, 5) }
|
|
946
1010
|
break;
|
|
1011
|
+
case 'string_string_pair_vector':
|
|
1012
|
+
returnResult = stringPairVectorToJSArray(cootResult)
|
|
1013
|
+
break
|
|
947
1014
|
case 'void':
|
|
948
1015
|
returnResult = null
|
|
949
1016
|
break
|
|
1017
|
+
case 'vector_pair_clipper_coord_float':
|
|
1018
|
+
returnResult = vectorPairClipperCoordFloatToJSArray(cootResult)
|
|
1019
|
+
break
|
|
950
1020
|
case 'status':
|
|
951
1021
|
default:
|
|
952
1022
|
returnResult = cootResult
|
|
953
1023
|
break;
|
|
1024
|
+
//cootResult.delete()
|
|
954
1025
|
}
|
|
955
1026
|
|
|
956
1027
|
return {
|
|
@@ -986,7 +1057,9 @@ onmessage = function (e) {
|
|
|
986
1057
|
molecules_container.set_show_timings(false)
|
|
987
1058
|
molecules_container.fill_rotamer_probability_tables()
|
|
988
1059
|
molecules_container.set_map_sampling_rate(1.7)
|
|
989
|
-
|
|
1060
|
+
molecules_container.set_map_is_contoured_with_thread_pool(true)
|
|
1061
|
+
molecules_container.set_max_number_of_threads(3)
|
|
1062
|
+
cootModule.FS.mkdir("COOT_BACKUP")
|
|
990
1063
|
})
|
|
991
1064
|
.catch((e) => {
|
|
992
1065
|
console.log(e)
|
package/baby-gru/moorhen.css
CHANGED
|
@@ -64,6 +64,59 @@ div.darkly text.base {fill:#000!important;}
|
|
|
64
64
|
div.darkly text.start-label {fill:#FFF !important;}
|
|
65
65
|
div.darkly text.end-label {fill:#FFF !important;}
|
|
66
66
|
|
|
67
|
+
.moorhen-hex-input-decorator {
|
|
68
|
+
display: flex;
|
|
69
|
+
align-items: "center";
|
|
70
|
+
justify-content: "center";
|
|
71
|
+
float: left;
|
|
72
|
+
border: 1px solid #ddd;
|
|
73
|
+
border-radius: 4px 0px 0px 4px;
|
|
74
|
+
background: #eee;
|
|
75
|
+
color: #98a1a4;
|
|
76
|
+
outline: none;
|
|
77
|
+
margin: 0.1rem 0 0;
|
|
78
|
+
padding: 0.1rem;
|
|
79
|
+
vertical-align: baseline;
|
|
80
|
+
text-align: center
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.moorhen-hex-input {
|
|
84
|
+
display: block;
|
|
85
|
+
box-sizing: border-box;
|
|
86
|
+
width: 90px;
|
|
87
|
+
margin: 0.1rem 0 0;
|
|
88
|
+
padding: 0.1rem;
|
|
89
|
+
border: 1px solid #ddd;
|
|
90
|
+
border-radius: 0px 4px 4px 0px;
|
|
91
|
+
background: #f0f0f0;
|
|
92
|
+
outline: none;
|
|
93
|
+
font: inherit;
|
|
94
|
+
text-transform: uppercase;
|
|
95
|
+
text-align: center;
|
|
96
|
+
color: #000;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.scene-settings-panel, .scene-settings-panel-flex-between, .scene-settings-panel-flex-center {
|
|
100
|
+
width: 100%;
|
|
101
|
+
height: 100%;
|
|
102
|
+
padding: 0.5rem;
|
|
103
|
+
border-style: solid;
|
|
104
|
+
border-radius: 0.5rem;
|
|
105
|
+
border-color: #ced4da;
|
|
106
|
+
border-width: 1px;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.scene-settings-panel-flex-between {
|
|
110
|
+
justify-content: space-between;
|
|
111
|
+
display: flex;
|
|
112
|
+
flex-direction: column;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.scene-settings-panel-flex-center {
|
|
116
|
+
justify-content: center;
|
|
117
|
+
display: flex;
|
|
118
|
+
}
|
|
119
|
+
|
|
67
120
|
.tab-content{
|
|
68
121
|
height: calc(100% - 3rem);
|
|
69
122
|
}
|
|
@@ -72,11 +125,18 @@ div.darkly text.end-label {fill:#FFF !important;}
|
|
|
72
125
|
height: 3rem;
|
|
73
126
|
}
|
|
74
127
|
|
|
128
|
+
.rama-validation-tool-container-row {
|
|
129
|
+
width: 100%;
|
|
130
|
+
margin: 0;
|
|
131
|
+
padding: 0;
|
|
132
|
+
height: 100%;
|
|
133
|
+
}
|
|
134
|
+
|
|
75
135
|
.big-validation-tool-container-row {
|
|
76
136
|
width: 100%;
|
|
77
137
|
margin: 0;
|
|
78
138
|
padding: 0;
|
|
79
|
-
height: calc(100% -
|
|
139
|
+
height: calc(100% - 6rem);
|
|
80
140
|
}
|
|
81
141
|
|
|
82
142
|
.small-validation-tool-container-row {
|
|
@@ -177,6 +237,10 @@ div.darkly text.end-label {fill:#FFF !important;}
|
|
|
177
237
|
}
|
|
178
238
|
|
|
179
239
|
.moorhen-draggable-card {
|
|
240
|
+
box-shadow: 0px 2px 2px -1px rgba(0,0,0,0.2),0px 3px 5px 0px rgba(0,0,0,0.14),0px 1px 9px 0px rgba(0,0,0,0.12);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.moorhen-draggable-card-focused {
|
|
180
244
|
box-shadow: 0px 3px 5px -1px rgba(0,0,0,0.2),0px 6px 10px 0px rgba(0,0,0,0.14),0px 1px 18px 0px rgba(0,0,0,0.12);
|
|
181
245
|
}
|
|
182
246
|
|