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.
Files changed (106) hide show
  1. package/baby-gru/CootWorker.js +1071 -0
  2. package/baby-gru/darkly.css +12 -0
  3. package/baby-gru/flatly.css +12 -0
  4. package/baby-gru/keyboard-blank.svg +3126 -0
  5. package/baby-gru/monomers/a/A.cif +271 -0
  6. package/baby-gru/monomers/a/ALA.cif +164 -0
  7. package/baby-gru/monomers/a/ARG.cif +252 -0
  8. package/baby-gru/monomers/a/ASN.cif +192 -0
  9. package/baby-gru/monomers/a/ASP.cif +178 -0
  10. package/baby-gru/monomers/c/C.cif +255 -0
  11. package/baby-gru/monomers/c/CIT.cif +167 -0
  12. package/baby-gru/monomers/c/CYS.cif +169 -0
  13. package/baby-gru/monomers/d/DA.cif +266 -0
  14. package/baby-gru/monomers/d/DC.cif +250 -0
  15. package/baby-gru/monomers/d/DG.cif +271 -0
  16. package/baby-gru/monomers/d/DT.cif +256 -0
  17. package/baby-gru/monomers/e/EDO.cif +108 -0
  18. package/baby-gru/monomers/g/G.cif +276 -0
  19. package/baby-gru/monomers/g/GLN.cif +208 -0
  20. package/baby-gru/monomers/g/GLU.cif +194 -0
  21. package/baby-gru/monomers/g/GLY.cif +138 -0
  22. package/baby-gru/monomers/g/GOL.cif +134 -0
  23. package/baby-gru/monomers/h/HIS.cif +215 -0
  24. package/baby-gru/monomers/h/HOH.cif +55 -0
  25. package/baby-gru/monomers/i/ILE.cif +213 -0
  26. package/baby-gru/monomers/l/LEU.cif +213 -0
  27. package/baby-gru/monomers/l/LYS.cif +228 -0
  28. package/baby-gru/monomers/m/MET.cif +201 -0
  29. package/baby-gru/monomers/m/MSE.cif +201 -0
  30. package/baby-gru/monomers/n/NA.cif +30 -0
  31. package/baby-gru/monomers/p/PHE.cif +233 -0
  32. package/baby-gru/monomers/p/PO4.cif +86 -0
  33. package/baby-gru/monomers/p/PRO.cif +188 -0
  34. package/baby-gru/monomers/s/SER.cif +169 -0
  35. package/baby-gru/monomers/s/SO4.cif +86 -0
  36. package/baby-gru/monomers/t/THR.cif +186 -0
  37. package/baby-gru/monomers/t/TRP.cif +263 -0
  38. package/baby-gru/monomers/t/TYR.cif +238 -0
  39. package/baby-gru/monomers/u/U.cif +248 -0
  40. package/baby-gru/monomers/v/VAL.cif +197 -0
  41. package/baby-gru/pixmaps/MoorhenLogo.png +0 -0
  42. package/baby-gru/pixmaps/add-alt-conf.svg +127 -0
  43. package/baby-gru/pixmaps/add-peptide-1.svg +257 -0
  44. package/baby-gru/pixmaps/atom-at-pointer.svg +91 -0
  45. package/baby-gru/pixmaps/auto-fit-rotamer.svg +118 -0
  46. package/baby-gru/pixmaps/cis-trans.svg +392 -0
  47. package/baby-gru/pixmaps/delete.svg +94 -0
  48. package/baby-gru/pixmaps/diff-map.png +0 -0
  49. package/baby-gru/pixmaps/drag.svg +253 -0
  50. package/baby-gru/pixmaps/edit-chi.svg +303 -0
  51. package/baby-gru/pixmaps/flip-peptide.svg +169 -0
  52. package/baby-gru/pixmaps/jed-flip-reverse.svg +286 -0
  53. package/baby-gru/pixmaps/map.svg +114 -0
  54. package/baby-gru/pixmaps/mutate.svg +111 -0
  55. package/baby-gru/pixmaps/rama-plot-gly-normal.png +0 -0
  56. package/baby-gru/pixmaps/rama-plot-gly-outlier.png +0 -0
  57. package/baby-gru/pixmaps/rama-plot-other-normal.png +0 -0
  58. package/baby-gru/pixmaps/rama-plot-other-outlier.png +0 -0
  59. package/baby-gru/pixmaps/rama-plot-pro-normal.png +0 -0
  60. package/baby-gru/pixmaps/rama-plot-pro-outlier.png +0 -0
  61. package/baby-gru/pixmaps/rama2_all.png +0 -0
  62. package/baby-gru/pixmaps/rama2_gly.png +0 -0
  63. package/baby-gru/pixmaps/rama2_ileval.png +0 -0
  64. package/baby-gru/pixmaps/rama2_non_gly_pro.png +0 -0
  65. package/baby-gru/pixmaps/rama2_non_gly_pro_pre_pro_ileval.png +0 -0
  66. package/baby-gru/pixmaps/rama2_pre_pro.png +0 -0
  67. package/baby-gru/pixmaps/rama2_pro.png +0 -0
  68. package/baby-gru/pixmaps/refine-1.svg +140 -0
  69. package/baby-gru/pixmaps/rigid-body.svg +124 -0
  70. package/baby-gru/pixmaps/rotamers.svg +78 -0
  71. package/baby-gru/pixmaps/rtz.svg +281 -0
  72. package/baby-gru/pixmaps/side-chain-180.svg +129 -0
  73. package/baby-gru/pixmaps/spin-view.svg +104 -0
  74. package/baby-gru/pixmaps/temperature.svg +92 -0
  75. package/baby-gru/tutorials/NUT.cif +453 -0
  76. package/baby-gru/tutorials/legend.html +3 -0
  77. package/baby-gru/tutorials/moorhen-tutorial-map-number-1.mtz +0 -0
  78. package/baby-gru/tutorials/moorhen-tutorial-map-number-2.mtz +0 -0
  79. package/baby-gru/tutorials/moorhen-tutorial-map-number-3.mtz +0 -0
  80. package/baby-gru/tutorials/moorhen-tutorial-map-number-4.mtz +0 -0
  81. package/baby-gru/tutorials/moorhen-tutorial-structure-number-1.pdb +2211 -0
  82. package/baby-gru/tutorials/moorhen-tutorial-structure-number-2.pdb +2018 -0
  83. package/baby-gru/tutorials/moorhen-tutorial-structure-number-3.pdb +1090 -0
  84. package/baby-gru/tutorials/moorhen-tutorial-structure-number-4.pdb +2801 -0
  85. package/baby-gru/wasm/RDKit_minimal.js +21 -0
  86. package/baby-gru/wasm/RDKit_minimal.wasm +0 -0
  87. package/baby-gru/wasm/cif_pdb_worker.js +33 -0
  88. package/baby-gru/wasm/coot_env_web.js +5 -0
  89. package/baby-gru/wasm/crystallography_worker.js +610 -0
  90. package/baby-gru/wasm/mini_rsr_worker.js +72 -0
  91. package/baby-gru/wasm/monid_to_pdb_worker.js +253 -0
  92. package/baby-gru/wasm/moorhen.data +246292 -0
  93. package/baby-gru/wasm/moorhen.js +21 -0
  94. package/baby-gru/wasm/moorhen.wasm +0 -0
  95. package/baby-gru/wasm/moorhen.worker.js +1 -0
  96. package/baby-gru/wasm/mtz_arraybuffer_worker.js +59 -0
  97. package/baby-gru/wasm/mtz_worker.js +45 -0
  98. package/baby-gru/wasm/nma_worker.js +103 -0
  99. package/baby-gru/wasm/papaparse.min.js +7 -0
  100. package/baby-gru/wasm/pdb_worker.js +282 -0
  101. package/baby-gru/wasm/smiles_to_pdb_worker.js +252 -0
  102. package/baby-gru/wasm/superpose_worker.js +144 -0
  103. package/baby-gru/wasm/web_example.js +21 -0
  104. package/baby-gru/wasm/web_example.wasm +0 -0
  105. package/moorhen.css +418 -0
  106. package/package.json +176 -0
@@ -0,0 +1,252 @@
1
+ var CCP4Module;
2
+ var RDKit;
3
+
4
+ importScripts('web_example.js','RDKit_minimal.js');
5
+
6
+ createCCP4Module({print(t){postMessage(["output",t])},printErr(t){postMessage(["output",t]);}})
7
+ .then(function(CCP4Mod) {
8
+ CCP4Module = CCP4Mod;
9
+ })
10
+ .catch((e) => {
11
+ console.log("CCP4 problem :(");
12
+ console.log(e);
13
+ });
14
+
15
+ initRDKitModule({print(t){postMessage(["output",t])},printErr(t){postMessage(["output",t]);}})
16
+ .then(function(RDKitMod) {
17
+ RDKit = RDKitMod;
18
+ })
19
+ .catch((e) => {
20
+ console.log("RDKit problem :(");
21
+ console.log(e);
22
+ });
23
+
24
+ function makeRequest (method, url) {
25
+ return new Promise(function (resolve, reject) {
26
+ var xhr = new XMLHttpRequest();
27
+ xhr.open(method, url, true);
28
+ xhr.onload = function () {
29
+ if (this.status >= 200 && this.status < 300) {
30
+ resolve(xhr.response);
31
+ } else {
32
+ reject({
33
+ status: this.status,
34
+ statusText: xhr.statusText
35
+ });
36
+ }
37
+ };
38
+ xhr.onerror = function () {
39
+ reject({
40
+ status: this.status,
41
+ statusText: xhr.statusText
42
+ });
43
+ };
44
+ xhr.send();
45
+ });
46
+ }
47
+
48
+ function onlyUnique(value, index, self) {
49
+ return self.indexOf(value) === index;
50
+ }
51
+
52
+ function getLoop(lines,loopName_in){
53
+ let loopName = loopName_in+".";
54
+ let inWantedLoop = false;
55
+ let loopLines = [];
56
+ let len = lines.length;
57
+ for(let il=0;il<len;il++){
58
+ let l = lines[il].replace(/(^\s+|\s+$)/g,'');
59
+ if(l === "loop_"||(l.substring(0,1)==="_"&&l.substring(0,loopName.length)!==loopName)){
60
+ if(inWantedLoop){
61
+ break;
62
+ }else{
63
+ if(il<lines.length){
64
+ if(lines[il+1].substring(0,loopName.length) === loopName){
65
+ inWantedLoop = true;
66
+ }
67
+ }
68
+ }
69
+ }else{
70
+ if(inWantedLoop){
71
+ loopLines.push(l);
72
+ }
73
+ }
74
+ }
75
+ return loopLines;
76
+ }
77
+
78
+ function splitQuotedCIFString(stringToSplit){
79
+ if(stringToSplit.length===0) return [];
80
+ return stringToSplit.match(/(?:[^\s"]+|"[^"]*")+/g);
81
+ }
82
+
83
+ function addCIFAtomTypes(resname,cif) {
84
+
85
+ let ener_lib_lines = cif.split("\n");
86
+ let libAtomTypes = [];
87
+ let libAtomLines = getLoop(ener_lib_lines,"_chem_comp_atom");
88
+ let atoms = [];
89
+ for(let il=0;il<libAtomLines.length;il++){
90
+ // We are only interested in atom_id and type_energy, so we do not worry about float and int types.
91
+ if(libAtomLines[il].substr(0,1)==="#"||libAtomLines[il].trim()===""){
92
+ continue;
93
+ } else if(libAtomLines[il].substr(0,1)==="_"){
94
+ libAtomTypes.push(libAtomLines[il]);
95
+ } else {
96
+ let split = splitQuotedCIFString(libAtomLines[il]);
97
+ if(split[0]!=="."){
98
+ let atom = {};
99
+ for(let iprop=0;iprop<split.length;iprop++){
100
+ atom[libAtomTypes[iprop]] = split[iprop];
101
+ }
102
+ atoms.push(atom);
103
+ }
104
+ }
105
+ }
106
+ return atoms;
107
+ }
108
+
109
+ function addCIFBondTypes(resname,cif) {
110
+ let ener_lib_lines = cif.split("\n");
111
+ let libAtomTypes = [];
112
+ let libAtomLines = getLoop(ener_lib_lines,"_chem_comp_bond");
113
+ let bonds = [];
114
+ for(let il=0;il<libAtomLines.length;il++){
115
+ // We are only interested in bond_id, atom_id and type, so we do not worry about float and int types.
116
+ if(libAtomLines[il].substr(0,1)==="#"||libAtomLines[il].trim()===""){
117
+ continue;
118
+ } else if(libAtomLines[il].substr(0,1)==="_"){
119
+ libAtomTypes.push(libAtomLines[il]);
120
+ } else {
121
+ let split = libAtomLines[il].match(/(?:[^\s"]+|"[^"]*")+/g);
122
+ if(split[0]!=="."){
123
+ let bond = {};
124
+ for(let iprop=0;iprop<split.length;iprop++){
125
+ bond[libAtomTypes[iprop]] = split[iprop];
126
+ }
127
+ if(typeof(bond["_chem_comp_bond.type"])!=="undefined"&&bond["_chem_comp_bond.type"].length>0&&typeof(bond["_chem_comp_bond.comp_id"])!=="undefined"&&bond["_chem_comp_bond.comp_id"].length>0&&typeof(bond["_chem_comp_bond.atom_id_1"])!=="undefined"&&bond["_chem_comp_bond.atom_id_1"].length>0&&typeof(bond["_chem_comp_bond.atom_id_2"])!=="undefined"&&bond["_chem_comp_bond.atom_id_2"].length>0){
128
+ bonds.push(bond);
129
+ } else if(typeof(bond["_chem_comp_bond.value_order"])!=="undefined"&&bond["_chem_comp_bond.value_order"].length>0&&typeof(bond["_chem_comp_bond.comp_id"])!=="undefined"&&bond["_chem_comp_bond.comp_id"].length>0&&typeof(bond["_chem_comp_bond.atom_id_1"])!=="undefined"&&bond["_chem_comp_bond.atom_id_1"].length>0&&typeof(bond["_chem_comp_bond.atom_id_2"])!=="undefined"&&bond["_chem_comp_bond.atom_id_2"].length>0){
130
+ if(bond["_chem_comp_bond.pdbx_aromatic_flag"]==="Y"){
131
+ bond["_chem_comp_bond.type"] = "aromatic";
132
+ } else if(bond["_chem_comp_bond.value_order"]==="SING"||bond["_chem_comp_bond.value_order"]==="SINGLE"){
133
+ bond["_chem_comp_bond.type"] = "single";
134
+ } else if(bond["_chem_comp_bond.value_order"]==="DOUB"||bond["_chem_comp_bond.value_order"]==="DOUBLE"){
135
+ bond["_chem_comp_bond.type"] = "double";
136
+ } else if(bond["_chem_comp_bond.value_order"]==="TRIP"||bond["_chem_comp_bond.value_order"]==="TRIPLE"){
137
+ bond["_chem_comp_bond.type"] = "triple";
138
+ } else {
139
+ bond["_chem_comp_bond.type"] = "single";
140
+ }
141
+ bonds.push(bond);
142
+ }
143
+ }
144
+ }
145
+ }
146
+
147
+ return bonds;
148
+ }
149
+
150
+ function dictToMolBlock(name,dictLines){
151
+
152
+ let atoms = addCIFAtomTypes(name,dictLines);
153
+ let bonds = addCIFBondTypes(name,dictLines);
154
+
155
+ let nAtoms = atoms.length;
156
+ let nBonds = bonds.length;
157
+
158
+ let nAtomsString = (" " + nAtoms).slice(-3);
159
+ let nBondsString = (" " + nBonds).slice(-3);
160
+
161
+ let molblock = name+`
162
+ CCP4-MonomerLibrary-WebToCif
163
+
164
+ `
165
+
166
+ molblock += nAtomsString+nBondsString+" 0 0 0 0 0 0 0 0999 V2000\n"
167
+ let ncharged = 0;
168
+ let chargeStr = "";
169
+ for(let iat=0;iat<nAtoms;iat++){
170
+ let x = parseFloat(atoms[iat]["_chem_comp_atom.x"]);
171
+ let y = parseFloat(atoms[iat]["_chem_comp_atom.y"]);
172
+ let z = parseFloat(atoms[iat]["_chem_comp_atom.z"]);
173
+ if(atoms[iat]["_chem_comp_atom.charge"]!="."&&atoms[iat]["_chem_comp_atom.charge"]!="0"){
174
+ ncharged++;
175
+ chargeStr += (" "+(iat+1)).slice(-4)+(" "+atoms[iat]["_chem_comp_atom.charge"]).slice(-4);
176
+ }
177
+ let symbol = atoms[iat]["_chem_comp_atom.type_symbol"];
178
+ let xString = (" "+x.toFixed(4)).slice(-10)
179
+ let yString = (" "+y.toFixed(4)).slice(-10)
180
+ let zString = (" "+z.toFixed(4)).slice(-10)
181
+ let symbolString = (" "+symbol).slice(-3);
182
+ molblock += xString+yString+zString+symbolString+" 0 0 0 0 0 0 0 0 0 0 0 0\n";
183
+ }
184
+
185
+ for(let ib=0;ib<nBonds;ib++){
186
+ let atom1 = atoms.find(obj => {
187
+ return obj["_chem_comp_atom.atom_id"] === bonds[ib]["_chem_comp_bond.atom_id_1"]
188
+ })
189
+ let atom2 = atoms.find(obj => {
190
+ return obj["_chem_comp_atom.atom_id"] === bonds[ib]["_chem_comp_bond.atom_id_2"]
191
+ })
192
+ let idx1 = atoms.indexOf(atom1);
193
+ let idx2 = atoms.indexOf(atom2);
194
+ let atom1String = (" " + (idx1+1)).slice(-3);
195
+ let atom2String = (" " + (idx2+1)).slice(-3);
196
+ let bondType = 1;
197
+ //FIXME - I am not sure this is handled by RDKit.
198
+ if(["_chem_comp_bond.aromatic"] in bonds[ib] && (bonds[ib]["_chem_comp_bond.aromatic"]==='y_XXX'||bonds[ib]["_chem_comp_bond.aromatic"]==='Y_XXX')){
199
+ bondType = 4;
200
+ } else if(["_chem_comp_bond.type"] in bonds[ib] && (bonds[ib]["_chem_comp_bond.type"]==='TRIPLE'||bonds[ib]["_chem_comp_bond.type"]==='triple')) {
201
+ bondType = 3;
202
+ } else if(["_chem_comp_bond.type"] in bonds[ib] && (bonds[ib]["_chem_comp_bond.type"]==='DOUBLE'||bonds[ib]["_chem_comp_bond.type"]==='double')) {
203
+ bondType = 2;
204
+ } else if(["_chem_comp_bond.type"] in bonds[ib] && (bonds[ib]["_chem_comp_bond.type"]==='SINGLE'||bonds[ib]["_chem_comp_bond.type"]==='single')) {
205
+ bondType = 1;
206
+ } else {
207
+ console.log("Unknown bond type");
208
+ console.log(bonds[ib]);
209
+ }
210
+ let bondTypeString = (" " + (bondType)).slice(-2);
211
+
212
+ molblock += atom1String+atom2String+bondTypeString+" 0 0 0 0\n";
213
+ }
214
+
215
+ if(ncharged>0){
216
+ molblock += "M CHG"+((" "+ncharged).slice(-3))+chargeStr+"\n";
217
+ }
218
+ molblock += "M END";
219
+
220
+ return molblock;
221
+
222
+ }
223
+
224
+ onmessage = function(e) {
225
+ let contents = e.data[0];
226
+ let name = e.data[1];
227
+
228
+ let promises = [contents];
229
+ let names = [name];
230
+
231
+ console.log(promises);
232
+
233
+ let svgResult = {};
234
+
235
+ if(promises.length>0){
236
+ Promise.all(promises).then((values) => {
237
+ console.log("Do RDKit stuff");
238
+ let mol2 = RDKit.get_mol(values[0]);
239
+ let mol3 = RDKit.get_mol(mol2.add_hs());
240
+ console.log("Done get_mol");
241
+ svgResult[names[0]] = mol3.get_svg();
242
+ console.log("Done get_svg");
243
+ postMessage(["result",svgResult]);
244
+ console.log("Done postMessage");
245
+ }).catch((error) => {
246
+ console.error(error);
247
+ postMessage(["result",svgResult]);
248
+ });
249
+ }
250
+
251
+
252
+ }
@@ -0,0 +1,144 @@
1
+ var CCP4Module;
2
+
3
+ importScripts('web_example.js');
4
+ importScripts('papaparse.min.js');
5
+
6
+ createCCP4Module({print(t){postMessage(["output",t])},printErr(t){postMessage(["output",t]);}})
7
+ .then(function(CCP4Mod) {
8
+ CCP4Module = CCP4Mod;
9
+ })
10
+ .catch((e) => {
11
+ console.log("CCP4 problem :(");
12
+ console.log(e);
13
+ });
14
+
15
+ onmessage = function(e) {
16
+
17
+ var args = new CCP4Module.VectorString();
18
+ //Do not add program name for superpose, only gesamt. I probably should have had the programs behave the same.
19
+ args.push_back("gesamt");
20
+ var sels = new CCP4Module.VectorString();
21
+
22
+ for(let ifile=0;ifile<e.data[0].length;ifile++){
23
+ try {
24
+ CCP4Module.FS_createDataFile(".", e.data[1][ifile], e.data[0][ifile], true, true);
25
+ } catch(e) {
26
+ //This happens when we supply sme file name on subsequent calls to this function?:w
27
+ }
28
+ args.push_back(e.data[1][ifile]);
29
+ sels.push_back("dummy"); // TODO: Selections are not dealt with yet
30
+ }
31
+
32
+ //var result = CCP4Module.superpose(args,sels);
33
+ //Do not do this with superpose!
34
+ args.push_back("-csv");
35
+ args.push_back("out.csv");
36
+ var result = CCP4Module.gesamt(args);
37
+ var csv_out = CCP4Module.FS.readFile("out.csv", { encoding: 'utf8' });
38
+ var json_out = Papa.parse(csv_out);
39
+
40
+ /*
41
+ //Testing, belongs elsewhere
42
+ var bessel = CCP4Module.gsl_sf_bessel_J0(5.0);
43
+ var hg = CCP4Module.gsl_cdf_hypergeometric_P(4, 7, 19, 13);
44
+ console.log(bessel);
45
+ console.log(hg);
46
+ */
47
+
48
+ let csv_data = json_out["data"];
49
+ if(e.data[0].length==2){ // TODO: I haven't thought about parsing multi-align csv yet.
50
+ let inTransformation = false;
51
+ let inAlign = false;
52
+ let alignData = [];
53
+ let transformMatrix = [];
54
+ let iTransform = -1;
55
+ for(let ij=0;ij<csv_data.length;ij++){
56
+ if(inTransformation&&ij<iTransform+4){
57
+ transformMatrix.push(parseFloat(csv_data[ij][0]));
58
+ transformMatrix.push(parseFloat(csv_data[ij][1]));
59
+ transformMatrix.push(parseFloat(csv_data[ij][2]));
60
+ transformMatrix.push(parseFloat(csv_data[ij][3]));
61
+ }
62
+ if(inAlign){
63
+ if(csv_data[ij][0].length>0){
64
+ let y = parseFloat(csv_data[ij][0]);
65
+ let x = parseFloat(csv_data[ij][4].trim().split(" ")[csv_data[ij][4].trim().split(" ").length-1]);
66
+ alignData.push({x:x,y:y});
67
+ }
68
+ if(csv_data[ij].length<5){
69
+ break;
70
+ }
71
+ }
72
+ if(csv_data[ij].length==4 && csv_data[ij][0].trim()==="Rx" && csv_data[ij][1].trim()==="Ry" && csv_data[ij][2].trim()==="Rz"&& csv_data[ij][3].trim()==="T"){
73
+ inTransformation = true;
74
+ iTransform = ij;
75
+ }
76
+ if(csv_data[ij].length>4 && csv_data[ij][0].trim()==="Dist [A]" && csv_data[ij][3].trim()==="Query" && csv_data[ij][4].trim()==="Target"){
77
+ inAlign = true;
78
+ }
79
+ }
80
+ if(transformMatrix.length==12){
81
+ transformMatrix.push(0.0);
82
+ transformMatrix.push(0.0);
83
+ transformMatrix.push(0.0);
84
+ transformMatrix.push(1.0);
85
+ }
86
+ let cvsResult = {};
87
+ cvsResult["alignData"] = alignData;
88
+ cvsResult["transformMatrices"] = [transformMatrix];
89
+ if(e.data.length>2){
90
+ cvsResult["jobid"] = e.data[2];
91
+ }
92
+ postMessage(["csvResult",cvsResult]);
93
+ } else {
94
+ let inTransformation = false;
95
+ let inAlign = false;
96
+ let alignData = [];
97
+ let transformMatrix = [];
98
+ let transformMatrices = [];
99
+ let iTransform = -1;
100
+ for(let ij=0;ij<csv_data.length;ij++){
101
+ if(inTransformation&&ij<iTransform+4){
102
+ transformMatrix.push(parseFloat(csv_data[ij][0]));
103
+ transformMatrix.push(parseFloat(csv_data[ij][1]));
104
+ transformMatrix.push(parseFloat(csv_data[ij][2]));
105
+ transformMatrix.push(parseFloat(csv_data[ij][3]));
106
+ }
107
+ if(transformMatrix.length==12){
108
+ transformMatrix.push(0.0);
109
+ transformMatrix.push(0.0);
110
+ transformMatrix.push(0.0);
111
+ transformMatrix.push(1.0);
112
+ transformMatrices.push(transformMatrix);
113
+ transformMatrix = [];
114
+ inTransformation = false;
115
+ }
116
+ if(csv_data[ij].length==4 && csv_data[ij][0].trim()==="Rx" && csv_data[ij][1].trim()==="Ry" && csv_data[ij][2].trim()==="Rz"&& csv_data[ij][3].trim()==="T"){
117
+ inTransformation = true;
118
+ iTransform = ij;
119
+ }
120
+ if(inAlign){
121
+ if(csv_data[ij][0].length>0){
122
+ let y = parseFloat(csv_data[ij][0]);
123
+ let x = parseFloat(csv_data[ij][1].trim().split(" ")[csv_data[ij][1].trim().split(" ").length-1]);
124
+ alignData.push({x:x,y:y});
125
+ }
126
+ if(csv_data[ij].length<e.data[0].length+1){
127
+ break;
128
+ }
129
+ }
130
+ if(csv_data[ij][0].trim()==="Disp.[A]"&&ij>2&&csv_data[ij-2][0].trim()==="RESIDUE ALIGNMENT"){
131
+ inAlign = true;
132
+ }
133
+ }
134
+ let cvsResult = {};
135
+ cvsResult["transformMatrices"] = transformMatrices;
136
+ cvsResult["alignData"] = alignData;
137
+ if(e.data.length>2){
138
+ cvsResult["jobid"] = e.data[2];
139
+ }
140
+ postMessage(["csvResult",cvsResult]);
141
+ }
142
+
143
+ postMessage(["result",result]);
144
+ }