@datagrok/bio 2.27.6 → 2.27.8

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/CREDITS.md ADDED
@@ -0,0 +1,246 @@
1
+ # Bio — Third-Party Libraries
2
+
3
+ The `@datagrok/bio` package is distributed under the MIT license that covers the
4
+ rest of the `public/` repository (see [`../../LICENSE.md`](../../LICENSE.md)). It
5
+ incorporates the open-source components listed below; this file reproduces the
6
+ attribution and notices required by their respective licenses.
7
+
8
+ All runtime JavaScript dependencies bundled into the published artifact are
9
+ under permissive licenses (MIT, Apache-2.0, BSD-3-Clause). No copyleft
10
+ (GPL/LGPL/MPL) component is bundled into the published Bio plugin.
11
+
12
+ ---
13
+
14
+ ## 1. Bundled in the published artifact (`dist/`)
15
+
16
+ ### immunum (1.1.0)
17
+
18
+ ENPICOM's antibody/TCR numbering library, compiled to WebAssembly. The
19
+ WASM binary is bundled into `dist/`; the wasm-bindgen JS glue is reused from
20
+ [`src/utils/antibody-numbering/immunum-glue.js`](src/utils/antibody-numbering/immunum-glue.js),
21
+ which is a port of the upstream `node_modules/immunum/immunum.js` modified
22
+ only to replace the Node-only `require('fs').readFileSync` top-level loader
23
+ with an explicit `initImmunum(bytes)` entry point so it works in browsers and
24
+ web workers. The modification is noted in the file header per MIT terms.
25
+
26
+ - Upstream: https://github.com/ENPICOM/immunum — https://immunum.enpicom.com
27
+ - License: **MIT**
28
+
29
+ ```
30
+ MIT License
31
+
32
+ Copyright (c) 2026 ENPICOM
33
+
34
+ Permission is hereby granted, free of charge, to any person obtaining a copy
35
+ of this software and associated documentation files (the "Software"), to deal
36
+ in the Software without restriction, including without limitation the rights
37
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
38
+ copies of the Software, and to permit persons to whom the Software is
39
+ furnished to do so, subject to the following conditions:
40
+
41
+ The above copyright notice and this permission notice shall be included in all
42
+ copies or substantial portions of the Software.
43
+
44
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
46
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
47
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
48
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
49
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
50
+ SOFTWARE.
51
+ ```
52
+
53
+ ### @biowasm/aioli (3.x)
54
+
55
+ WebAssembly runtime that drives multiple sequence alignment (kalign). The
56
+ aioli library itself is bundled; the kalign tool it loads is fetched at
57
+ runtime — see Section 3 below.
58
+
59
+ - Upstream: https://github.com/biowasm/aioli
60
+ - License: **MIT**
61
+
62
+ ```
63
+ MIT License
64
+
65
+ Copyright (c) 2018 Robert Aboukhalil
66
+
67
+ Permission is hereby granted, free of charge, to any person obtaining a copy
68
+ of this software and associated documentation files (the "Software"), to deal
69
+ in the Software without restriction, including without limitation the rights
70
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
71
+ copies of the Software, and to permit persons to whom the Software is
72
+ furnished to do so, subject to the following conditions:
73
+
74
+ The above copyright notice and this permission notice shall be included in all
75
+ copies or substantial portions of the Software.
76
+
77
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
78
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
79
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
80
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
81
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
82
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
83
+ SOFTWARE.
84
+ ```
85
+
86
+ ### Ajv (8.x) and ajv-errors (3.x)
87
+
88
+ JSON-schema validator used for monomer-library JSON validation.
89
+
90
+ - Upstream: https://ajv.js.org/ — https://github.com/ajv-validator/ajv-errors
91
+ - License: **MIT**
92
+
93
+ ```
94
+ The MIT License (MIT)
95
+
96
+ Copyright (c) 2015-2021 Evgeny Poberezkin
97
+
98
+ Permission is hereby granted, free of charge, to any person obtaining a copy
99
+ of this software and associated documentation files (the "Software"), to deal
100
+ in the Software without restriction, including without limitation the rights
101
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
102
+ copies of the Software, and to permit persons to whom the Software is
103
+ furnished to do so, subject to the following conditions:
104
+
105
+ The above copyright notice and this permission notice shall be included in all
106
+ copies or substantial portions of the Software.
107
+
108
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
109
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
110
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
111
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
112
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
113
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
114
+ SOFTWARE.
115
+ ```
116
+
117
+ (`ajv-errors` carries an analogous MIT notice — *Copyright (c) 2017 Evgeny
118
+ Poberezkin*.)
119
+
120
+ ### fastest-levenshtein (1.0.x)
121
+
122
+ Levenshtein-distance implementation used in sequence comparison code paths.
123
+
124
+ - Upstream: https://github.com/ka-weihe/fastest-levenshtein
125
+ - License: **MIT**
126
+
127
+ ```
128
+ MIT License
129
+
130
+ Copyright (c) 2020 Kasper Unn Weihe
131
+
132
+ Permission is hereby granted, free of charge, to any person obtaining a copy
133
+ of this software and associated documentation files (the "Software"), to deal
134
+ in the Software without restriction, including without limitation the rights
135
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
136
+ copies of the Software, and to permit persons to whom the Software is
137
+ furnished to do so, subject to the following conditions:
138
+
139
+ The above copyright notice and this permission notice shall be included in all
140
+ copies or substantial portions of the Software.
141
+
142
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
143
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
144
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
145
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
146
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
147
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
148
+ SOFTWARE.
149
+ ```
150
+
151
+ ### umap-js (1.4.x)
152
+
153
+ UMAP dimensionality reduction used by sequence-space and similarity viewers.
154
+ The npm package metadata declares MIT but the LICENSE file shipped in the
155
+ tarball is **Apache-2.0**, so we comply with the more conservative Apache-2.0
156
+ terms (preserve copyright/attribution; mark modifications, of which there are
157
+ none).
158
+
159
+ - Upstream: https://github.com/PAIR-code/umap-js
160
+ - Author: Andy Coenen (Google PAIR)
161
+ - License: **Apache-2.0**
162
+
163
+ > Licensed under the Apache License, Version 2.0 (the "License"); you may not
164
+ > use this file except in compliance with the License. You may obtain a copy of
165
+ > the License at http://www.apache.org/licenses/LICENSE-2.0
166
+ >
167
+ > Unless required by applicable law or agreed to in writing, software
168
+ > distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
169
+ > WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
170
+ > License for the specific language governing permissions and limitations
171
+ > under the License.
172
+
173
+ The full Apache-2.0 license text is available at the URL above and in
174
+ `node_modules/umap-js/LICENSE`.
175
+
176
+ ---
177
+
178
+ ## 2. Linked at runtime via the Datagrok platform (webpack externals)
179
+
180
+ These libraries are not bundled into Bio's `dist/` — they are provided once
181
+ by the platform host and shared across all packages.
182
+
183
+ | Component | Version | License | Upstream |
184
+ |----------------------------------|---------|--------------|---------------------------------------------------|
185
+ | OpenChemLib JS | 7.x | BSD-3-Clause | https://github.com/cheminfo/openchemlib-js |
186
+ | RxJS | 6.x | Apache-2.0 | https://github.com/ReactiveX/rxjs |
187
+ | cash-dom | 8.x | MIT | https://github.com/fabiospampinato/cash |
188
+ | Day.js | 1.x | MIT | https://github.com/iamkun/dayjs |
189
+ | wu.js | 2.x | MIT | https://github.com/fitzgen/wu.js |
190
+
191
+ OpenChemLib JS is also referenced by Bio's `package.json` `sources`. The
192
+ upstream `openchemlib-js` npm package is distributed under BSD-3-Clause:
193
+ *Copyright (c) 2015-2017, cheminfo.*
194
+
195
+ ---
196
+
197
+ ## 3. Fetched at runtime from third-party CDNs (not bundled)
198
+
199
+ ### kalign (via @biowasm/aioli)
200
+
201
+ `@biowasm/aioli` loads the **kalign** multiple-sequence-alignment tool from
202
+ the public biowasm CDN (`https://biowasm.com/cdn/v3/...`) on demand. kalign
203
+ itself is **not** bundled into Bio's `dist/` and is **not** redistributed by
204
+ the Datagrok platform. Users that load it transitively are subject to
205
+ kalign's upstream license (GPLv3).
206
+
207
+ - Upstream: https://github.com/TimoLassmann/kalign
208
+ - License: GPLv3 (used as a runtime-fetched, non-bundled dependency)
209
+
210
+ ---
211
+
212
+ ## 4. Docker container (`dockerfiles/`) — PepSeA service
213
+
214
+ The Bio package ships a single Docker image (`dockerfiles/Dockerfile`) that
215
+ provides a PepSeA-based MSA service for HELM peptide sequences. The image is
216
+ built from `datagrok/python` and pulls third-party software at build time:
217
+
218
+ | Component | Source | License |
219
+ |---------------|-------------------------------------------------|------------------------|
220
+ | PepSeA | https://github.com/Merck/PepSeA (main branch) | MIT (Merck & Co.) |
221
+ | MAFFT | https://mafft.cbrc.jp/ (`mafft_7.520-1` .deb) | MAFFT license (BSD-style, free for any use with attribution) |
222
+ | FastAPI | https://github.com/tiangolo/fastapi | MIT |
223
+ | uvicorn | https://www.uvicorn.org/ | BSD-3-Clause |
224
+ | ujson | https://github.com/ultrajson/ultrajson | BSD-3-Clause |
225
+ | Python stdlib | https://www.python.org/ | PSF License |
226
+
227
+ The `Dockerfile` patches a few lines of PepSeA's `api.py` at build time to
228
+ add a `/distout` endpoint and JSON error-handling middleware; per MIT terms
229
+ those modifications are noted here.
230
+
231
+ ---
232
+
233
+ ## 5. Development-only dependencies
234
+
235
+ Tools used during the build/test cycle (not in the runtime tree, not bundled):
236
+ the `datagrok-tools` CLI transitively pulls in `puppeteer-screen-recorder`,
237
+ which references `@ffmpeg-installer/ffmpeg` (LGPL-2.1) and
238
+ `@ffmpeg-installer/win32-x64` (GPLv3). These binaries are **not**
239
+ redistributed as part of the published Bio plugin and impose no obligation on
240
+ users of the plugin.
241
+
242
+ The peer/devDependencies on other Datagrok plugins (`@datagrok/chem`,
243
+ `@datagrok/dendrogram`, `@datagrok/eda`, `@datagrok/helm`,
244
+ `@datagrok/peptides`) are MIT — covered by the repo-wide `LICENSE.md`. Each
245
+ of those plugins maintains its own `CREDITS.md` (or will) for its own
246
+ third-party content.
package/dist/455.js CHANGED
@@ -1,2 +1,2 @@
1
- var bio;(()=>{"use strict";const t={V2K_RGP_SHIFT:8,V2K_RGP_LINE:"M RGP",V2K_A_LINE:"A ",V3K_COUNTS_SHIFT:14,V3K_IDX_SHIFT:7,V3K_HEADER_FIRST_LINE:"\nDatagrok macromolecule handler\n\n",V3K_HEADER_SECOND_LINE:" 0 0 0 0 0 0 999 V3000\n",V3K_BEGIN_CTAB_BLOCK:"M V30 BEGIN CTAB\n",V3K_END_CTAB_BLOCK:"M V30 END CTAB\n",V3K_BEGIN_COUNTS_LINE:"M V30 COUNTS ",V3K_COUNTS_LINE_ENDING:" 0 0 0\n",V3K_BEGIN_ATOM_BLOCK:"M V30 BEGIN ATOM\n",V3K_END_ATOM_BLOCK:"M V30 END ATOM\n",V3K_BEGIN_BOND_BLOCK:"M V30 BEGIN BOND\n",V3K_END_BOND_BLOCK:"M V30 END BOND\n",V3K_BOND_CONFIG:" CFG=",V3K_BEGIN_DATA_LINE:"M V30 ",V3K_END:"M END",PRECISION_FACTOR:1e4,DEOXYRIBOSE:{polymerType:"RNA",symbol:"d"},RIBOSE:{polymerType:"RNA",symbol:"r"},PHOSPHATE:{polymerType:"RNA",symbol:"p"},OXYGEN:"O",HYDROGEN:"H"};function o(t,o){return t[o.polymerType]?.[o.symbol]}var n,e,s,i;!function(t){t[t.SUGAR=0]="SUGAR",t[t.BASE=1]="BASE",t[t.PHOSPHATE=2]="PHOSPHATE"}(n||(n={}));class a extends Map{constructor(t){super(t)}}class l{constructor(t,o){this.molfile=t,this.monomers=o}static createEmpty(){return new l("",new a(null))}}new RegExp("[rd]\\((\\w)\\)p?","g");class h{constructor(t,o,n){this.name=t,this.alphabet=o,this.cutoff=n}}!function(t){t.FASTA="fasta",t.SEPARATOR="separator",t.HELM="helm",t.CUSTOM="custom",t.BILN="biln"}(e||(e={})),function(t){t.DNA="DNA",t.RNA="RNA",t.PT="PT",t.UN="UN"}(s||(s={})),function(t){t.aligned="aligned",t.alphabet="alphabet",t.alphabetSize=".alphabetSize",t.alphabetIsMultichar=".alphabetIsMultichar",t.separator="separator",t.isHelmCompatible=".isHelmCompatible",t.positionNames=".positionNames",t.positionLabels=".positionLabels",t.regions=".regions",t.positionShift=".positionShift",t.selectedPosition=".selectedPosition",t.polymerTypeColumnName=".polymerTypeColumnName",t.annotations=".annotations",t.numberingScheme=".numberingScheme",t.annotationColumnName=".annotationColumnName"}(i||(i={}));const r=new class{constructor(){this.fasta={peptide:new Set(["G","L","Y","S","E","Q","D","N","F","A","K","R","H","C","V","P","W","I","M","T"]),dna:new Set(["A","C","G","T"]),rna:new Set(["A","C","G","U"])}}};var c;function b(t){let o;switch(t){case c.BASE:case c.SUGAR:case c.LINKER:case c.NUCLEOTIDE:case"nucleotide":o="RNA";break;case c.AA:o="PEPTIDE";break;case c.CHEM:o="CHEM";break;case c.BLOB:o="BLOB";break;default:o="PEPTIDE",console.warn(`Unexpected HelmType '${t}'`)}return o}function f(n,e,i,h,r){if(0===n.length)return l.createEmpty();const c="RNA"===h&&!!r&&r.length===n.length&&(n.length%3==0||n.length%3==2),{atomCount:f,bondCount:S,needsCapping:d}=function(n,e,i,a,l){let h=0,r=0,c=0,f=!0,m=null,E=null;for(let t=0;t<n.length;++t){const s=n[t];if(""!==s.symbol){if("*"==s.symbol)throw new Error("Gap canonical symbol is '', not '*");m=o(e,{symbol:s.symbol,polymerType:b(s.biotype)}),h+=m.atoms.x.length,r+=m.bonds.bondTypes.length,c++,l&&t%3==2&&(E=m)}}if("PEPTIDE"===a)h+=1,r+=c,c>0&&((m?.meta?.rNodes?.length??0)<2||m?.terminalR2Atom?.toLowerCase()===t.HYDROGEN.toLowerCase())&&(f=!1,h-=1,r-=1);else if(l)h+=1,r+=c;else{const a=i===s.DNA?o(e,t.DEOXYRIBOSE):o(e,t.RIBOSE),l=o(e,t.PHOSPHATE);h+=(n.length-1)*l.atoms.x.length,h+=n.length*a.atoms.x.length,h+=1,r+=(n.length-1)*l.bonds.bondTypes.length,r+=n.length*a.bonds.bondTypes.length,r-=1,r+=3*n.length}return{atomCount:h,bondCount:r,needsCapping:f}}(n,e,i,h,c),A=new Array(f),y=new Array(S);let u,T=null,I=null;"PEPTIDE"===h?u=m:(u=N,c||(T=i===s.DNA?o(e,t.DEOXYRIBOSE):o(e,t.RIBOSE),I=o(e,t.PHOSPHATE)));const O={i:0,nodeShift:0,bondShift:0,backbonePositionShift:new Array(2).fill(0),branchPositionShift:new Array(2).fill(0),backboneAttachNode:0,branchAttachNode:0,flipFactor:1},C={sugar:T,phosphate:I,seqLength:c?Math.ceil(n.length/3):n.length,atomCount:f,bondCount:S},g=new a,B=[];let L,D=0;if(c)!function(t,n,e,s,i,a,l,h,r,c){const f=a.seqLength,m=t.length===3*f;for(let a=0;a<f;++a){i.i=a;const f=t[3*a],m=t[3*a+1],N=o(n,{symbol:f.symbol,polymerType:b(f.biotype)}),S=o(n,{symbol:m.symbol,polymerType:b(m.biotype)}),_=0===a?null:o(n,{symbol:t[3*(a-1)+2].symbol,polymerType:b(t[3*(a-1)+2].biotype)}),d=3*a;if(_){const o=i.nodeShift,n=i.bondShift;E(_,e,s,i),_.stereoAtoms?.forEach(t=>h.push(t+c())),r(_.atoms.x.length);const b=3*(a-1)+2,f=[];for(let t=o;t<i.nodeShift;++t)f.push(t);const m=[];for(let t=n;t<i.bondShift;++t)m.push(t);l.set(b,{biotype:t[b].biotype,symbol:t[b].symbol,atoms:f,bonds:m})}const A=i.nodeShift,y=i.bondShift;E(N,e,s,i),N.stereoAtoms?.forEach(t=>h.push(t+c())),r(N.atoms.x.length);const u=[];for(let t=A;t<i.nodeShift;++t)u.push(t);const T=[];for(let t=y;t<i.bondShift;++t)T.push(t);l.set(d,{biotype:f.biotype,symbol:f.symbol,atoms:u,bonds:T});const I=i.nodeShift,O=i.bondShift;p(S,e,s,i),S.stereoAtoms?.forEach(t=>h.push(t+c())),r(S.atoms.x.length);const C=[];for(let t=I;t<i.nodeShift;++t)C.push(t);const g=[];for(let t=O;t<i.bondShift;++t)g.push(t);l.set(d+1,{biotype:m.biotype,symbol:m.symbol,atoms:C,bonds:g})}if(m){const a=3*(f-1)+2,m=t[a],N=o(n,{symbol:m.symbol,polymerType:b(m.biotype)}),p=i.nodeShift,S=i.bondShift;E(N,e,s,i),N.stereoAtoms?.forEach(t=>h.push(t+c())),r(N.atoms.x.length);const _=[];for(let t=p;t<i.nodeShift;++t)_.push(t);const d=[];for(let t=S;t<i.bondShift;++t)d.push(t);l.set(a,{biotype:m.biotype,symbol:m.symbol,atoms:_,bonds:d})}}(n,e,A,y,O,C,g,B,t=>{D+=t},()=>D);else for(O.i=0;O.i<C.seqLength;++O.i){const t=n[O.i];if(""===t.symbol)continue;const s=o(e,{symbol:t.symbol,polymerType:b(t.biotype)});L=s.terminalR2Atom;const i=O.nodeShift,a=O.bondShift;u(s,A,y,O,C),s.stereoAtoms?.forEach(t=>B.push(t+D)),D+=s.atoms.x.length;const l=O.nodeShift-i,h=new Array(l);for(let t=0;t<l;++t)h[t]=i+t;const r=O.bondShift-a,c=new Array(r);for(let t=0;t<r;++t)c[t]=a+t;g.set(O.i,{biotype:t.biotype,symbol:t.symbol,atoms:h,bonds:c})}d&&function(o,n,e,s,i=t.OXYGEN){const a=e.nodeShift+1;o[s.atomCount]=t.V3K_BEGIN_DATA_LINE+a+" "+(i??t.OXYGEN)+" "+_(e.backbonePositionShift[0])+" "+e.flipFactor*_(e.backbonePositionShift[1])+" 0.000000 0\n";const l=e.backboneAttachNode,h=a;n[s.bondCount]=t.V3K_BEGIN_DATA_LINE+e.bondShift+" 1 "+l+" "+h+"\n"}(A,y,O,C,L??t.OXYGEN);const K=t.V3K_BEGIN_COUNTS_LINE+f+" "+S+t.V3K_COUNTS_LINE_ENDING;let V="";return V+=t.V3K_HEADER_FIRST_LINE,V+=t.V3K_HEADER_SECOND_LINE,V+=t.V3K_BEGIN_CTAB_BLOCK,V+=K,V+=t.V3K_BEGIN_ATOM_BLOCK,V+=A.join(""),V+=t.V3K_END_ATOM_BLOCK,V+=t.V3K_BEGIN_BOND_BLOCK,V+=y.join(""),V+=t.V3K_END_BOND_BLOCK,B.length>0&&(V+=function(t){const o=[];let n=`M V30 MDLV30/STEABS ATOMS=(${t.length}`;for(let e=0;e<t.length;e++){const s=`${n} ${t[e]}`;s.length>76?(o.push(`${n} -\n`),n=`M V30 ${t[e]}`):n=s,e===t.length-1&&o.push(`${n})\n`)}return`M V30 BEGIN COLLECTION\n${o.join("")}M V30 END COLLECTION\n`}(B)),V+=t.V3K_END_CTAB_BLOCK,V+=t.V3K_END,{molfile:V,monomers:g}}function m(t,o,n,e){e.flipFactor=(-1)**(e.i%2),E(t,o,n,e)}function E(o,n,e,s){!function(o,n,e){for(let s=0;s<o.atoms.atomTypes.length;++s){const i=e.nodeShift+s+1;n[e.nodeShift+s]=t.V3K_BEGIN_DATA_LINE+i+" "+o.atoms.atomTypes[s]+" "+_(e.backbonePositionShift[0]+o.atoms.x[s])+" "+_(e.backbonePositionShift[1]+e.flipFactor*o.atoms.y[s])+" "+o.atoms.kwargs[s]}}(o,n,s),S(o,e,s),function(o,n,e){if(0!==e.backboneAttachNode){const s=e.bondShift,i=e.backboneAttachNode,a=o.meta.terminalNodes[0]+e.nodeShift;n[e.bondShift-1]=t.V3K_BEGIN_DATA_LINE+s+" 1 "+i+" "+a+"\n"}}(o,e,s),null!==o.meta.branchShift&&o.meta.terminalNodes.length>2&&function(t,o){o.branchAttachNode=o.nodeShift+t.meta.terminalNodes[2];for(let n=0;n<2;++n)o.branchPositionShift[n]=o.backbonePositionShift[n]+t.meta.branchShift[n]}(o,s),function(t,o){o.backboneAttachNode=o.nodeShift+t.meta.terminalNodes[1],o.bondShift+=t.bonds.atomPairs.length+1,o.nodeShift+=t.atoms.atomTypes.length,o.backbonePositionShift[0]+=t.meta.backboneShift?.[0]??0,o.backbonePositionShift[1]+=o.flipFactor*(t.meta.backboneShift?.[1]??0)}(o,s)}function N(t,o,n,e,s){if(0===e.i)E(s.sugar,o,n,e);else for(const t of[s.phosphate,s.sugar])E(t,o,n,e);p(t,o,n,e)}function p(o,n,e,s){!function(o,n,e){for(let s=0;s<o.atoms.atomTypes.length;++s){const i=e.nodeShift+s+1;n[e.nodeShift+s]=t.V3K_BEGIN_DATA_LINE+i+" "+o.atoms.atomTypes[s]+" "+_(e.branchPositionShift[0]+o.atoms.x[s])+" "+_(e.branchPositionShift[1]+e.flipFactor*o.atoms.y[s])+" "+o.atoms.kwargs[s]}}(o,n,s),S(o,e,s),function(o,n,e){const s=e.bondShift,i=e.branchAttachNode,a=o.meta.terminalNodes[0]+e.nodeShift;n[s-1]=t.V3K_BEGIN_DATA_LINE+s+" 1 "+i+" "+a+"\n"}(o,e,s);const i=s.bondShift,a=s.branchAttachNode,l=o.meta.terminalNodes[0]+s.nodeShift;e[i-1]=t.V3K_BEGIN_DATA_LINE+i+" 1 "+a+" "+l+"\n",s.bondShift+=o.bonds.atomPairs.length+1,s.nodeShift+=o.atoms.atomTypes.length}function S(o,n,e){for(let s=0;s<o.bonds.atomPairs.length;++s){const i=e.bondShift+s+1,a=o.bonds.atomPairs[s][0]+e.nodeShift,l=o.bonds.atomPairs[s][1]+e.nodeShift;let h="";if(o.bonds.bondConfiguration.has(s)){let t=o.bonds.bondConfiguration.get(s);e.flipFactor<0&&(t=1===t?3:1),h=" CFG="+t}const r=o.bonds.kwargs.has(s)?" "+o.bonds.kwargs.get(s):"";n[e.bondShift+s]=t.V3K_BEGIN_DATA_LINE+i+" "+o.bonds.bondTypes[s]+" "+a+" "+l+h+r+"\n"}}function _(o){return Math.round(t.PRECISION_FACTOR*o)/t.PRECISION_FACTOR}new h(s.PT,r.fasta.peptide,.5),new h(s.DNA,r.fasta.dna,.55),new h(s.RNA,r.fasta.rna,.55),e.FASTA,e.SEPARATOR,e.HELM,e.BILN,function(t){t.BASE="HELM_BASE",t.SUGAR="HELM_SUGAR",t.LINKER="HELM_LINKER",t.AA="HELM_AA",t.CHEM="HELM_CHEM",t.BLOB="HELM_BLOB",t.NUCLEOTIDE="HELM_NUCLETIDE"}(c||(c={})),onmessage=t=>{const{seqList:o,rolesList:n,monomersDict:e,alphabet:s,polymerType:i,start:a,end:l}=t.data,h=new Array(l-a),r=new Array(0);for(let t=a;t<l;++t)try{const l=o[t],r=n?n[t]:void 0;h[t-a]=f(l,e,s,i,r)}catch(o){const n=`Cannot get molfile of row #${t}: ${o instanceof Error?o.message:o.toString()}.`;r.push(n)}postMessage({molfiles:h,warnings:r})},bio={}})();
1
+ var bio;(()=>{"use strict";const t={V2K_RGP_SHIFT:8,V2K_RGP_LINE:"M RGP",V2K_A_LINE:"A ",V3K_COUNTS_SHIFT:14,V3K_IDX_SHIFT:7,V3K_HEADER_FIRST_LINE:"\nDatagrok macromolecule handler\n\n",V3K_HEADER_SECOND_LINE:" 0 0 0 0 0 0 999 V3000\n",V3K_BEGIN_CTAB_BLOCK:"M V30 BEGIN CTAB\n",V3K_END_CTAB_BLOCK:"M V30 END CTAB\n",V3K_BEGIN_COUNTS_LINE:"M V30 COUNTS ",V3K_COUNTS_LINE_ENDING:" 0 0 0\n",V3K_BEGIN_ATOM_BLOCK:"M V30 BEGIN ATOM\n",V3K_END_ATOM_BLOCK:"M V30 END ATOM\n",V3K_BEGIN_BOND_BLOCK:"M V30 BEGIN BOND\n",V3K_END_BOND_BLOCK:"M V30 END BOND\n",V3K_BOND_CONFIG:" CFG=",V3K_BEGIN_DATA_LINE:"M V30 ",V3K_END:"M END",PRECISION_FACTOR:1e4,DEOXYRIBOSE:{polymerType:"RNA",symbol:"d"},RIBOSE:{polymerType:"RNA",symbol:"r"},PHOSPHATE:{polymerType:"RNA",symbol:"p"},OXYGEN:"O",HYDROGEN:"H"};function o(t,o){return t[o.polymerType]?.[o.symbol]}var n,e,s,i;!function(t){t[t.SUGAR=0]="SUGAR",t[t.BASE=1]="BASE",t[t.PHOSPHATE=2]="PHOSPHATE",t[t.TERMINAL_5P=3]="TERMINAL_5P",t[t.TERMINAL_3P=4]="TERMINAL_3P"}(n||(n={}));class a extends Map{constructor(t){super(t)}}class l{constructor(t,o){this.molfile=t,this.monomers=o}static createEmpty(){return new l("",new a(null))}}new RegExp("[rd]\\((\\w)\\)p?","g");class h{constructor(t,o,n){this.name=t,this.alphabet=o,this.cutoff=n}}!function(t){t.FASTA="fasta",t.SEPARATOR="separator",t.HELM="helm",t.CUSTOM="custom",t.BILN="biln"}(e||(e={})),function(t){t.DNA="DNA",t.RNA="RNA",t.PT="PT",t.UN="UN"}(s||(s={})),function(t){t.aligned="aligned",t.alphabet="alphabet",t.alphabetSize=".alphabetSize",t.alphabetIsMultichar=".alphabetIsMultichar",t.separator="separator",t.isHelmCompatible=".isHelmCompatible",t.positionNames=".positionNames",t.positionLabels=".positionLabels",t.regions=".regions",t.positionShift=".positionShift",t.selectedPosition=".selectedPosition",t.polymerTypeColumnName=".polymerTypeColumnName",t.annotations=".annotations",t.numberingScheme=".numberingScheme",t.annotationColumnName=".annotationColumnName"}(i||(i={}));const r=new class{constructor(){this.fasta={peptide:new Set(["G","L","Y","S","E","Q","D","N","F","A","K","R","H","C","V","P","W","I","M","T"]),dna:new Set(["A","C","G","T"]),rna:new Set(["A","C","G","U"])}}};var c;function b(t){let o;switch(t){case c.BASE:case c.SUGAR:case c.LINKER:case c.NUCLEOTIDE:case"nucleotide":o="RNA";break;case c.AA:o="PEPTIDE";break;case c.CHEM:o="CHEM";break;case c.BLOB:o="BLOB";break;default:o="PEPTIDE",console.warn(`Unexpected HelmType '${t}'`)}return o}function E(e,i,h,r,c){if(0===e.length)return l.createEmpty();const E="RNA"===r&&!!c&&c.length===e.length,{atomCount:A,bondCount:p,needsCapping:d}=function(e,i,a,l,h,r){let c=0,E=0,f=0,m=!0,N=null,_=null;for(let t=0;t<e.length;++t){const n=e[t];if(""!==n.symbol){if("*"==n.symbol)throw new Error("Gap canonical symbol is '', not '*");N=o(i,{symbol:n.symbol,polymerType:b(n.biotype)}),c+=N.atoms.x.length,E+=N.bonds.bondTypes.length,f++,h&&t%3==2&&(_=N)}}if("PEPTIDE"===l)c+=1,E+=f,f>0&&((N?.meta?.rNodes?.length??0)<2||N?.terminalR2Atom?.toLowerCase()===t.HYDROGEN.toLowerCase())&&(m=!1,c-=1,E-=1);else if(h)E+=f,r&&r.length>0&&r[r.length-1]===n.TERMINAL_3P?m=!1:c+=1;else{const n=a===s.DNA?o(i,t.DEOXYRIBOSE):o(i,t.RIBOSE),l=o(i,t.PHOSPHATE);c+=(e.length-1)*l.atoms.x.length,c+=e.length*n.atoms.x.length,c+=1,E+=(e.length-1)*l.bonds.bondTypes.length,E+=e.length*n.bonds.bondTypes.length,E-=1,E+=3*e.length}return{atomCount:c,bondCount:E,needsCapping:m}}(e,i,h,r,E,c),T=new Array(A),y=new Array(p);let u,I=null,O=null;"PEPTIDE"===r?u=f:(u=N,E||(I=h===s.DNA?o(i,t.DEOXYRIBOSE):o(i,t.RIBOSE),O=o(i,t.PHOSPHATE)));const g={i:0,nodeShift:0,bondShift:0,backbonePositionShift:new Array(2).fill(0),branchPositionShift:new Array(2).fill(0),backboneAttachNode:0,branchAttachNode:0,flipFactor:1},L={sugar:I,phosphate:O,seqLength:E?Math.ceil(e.length/3):e.length,atomCount:A,bondCount:p},C=new a,B=[];let D,P=0;if(E)!function(t,e,s,i,a,l,h,r,c,E,f){const N=e.length>0&&e[0]===n.TERMINAL_5P,A=e.length>0&&e[e.length-1]===n.TERMINAL_3P,S=N?1:0,p=(A?e.length-1:e.length)-S,d=Math.ceil(p/3),T=p===3*d,y=(t,n)=>{const e=o(s,{symbol:t.symbol,polymerType:b(t.biotype)}),h=l.nodeShift,N=l.bondShift;m(e,i,a,l),e.stereoAtoms?.forEach(t=>c.push(t+f())),E(e.atoms.x.length);const _=[];for(let t=h;t<l.nodeShift;++t)_.push(t);const A=[];for(let t=N;t<l.bondShift;++t)A.push(t);r.set(n,{biotype:t.biotype,symbol:t.symbol,atoms:_,bonds:A})};N&&(l.i=0,y(t[0],0));for(let n=0;n<d;++n){l.i=n+(N?1:0);const e=S+3*n,h=e+1,A=t[e],p=t[h],d=o(s,{symbol:A.symbol,polymerType:b(A.biotype)}),T=o(s,{symbol:p.symbol,polymerType:b(p.biotype)});if(n>=1){const o=S+3*(n-1)+2;y(t[o],o)}const u=l.nodeShift,I=l.bondShift;m(d,i,a,l),d.stereoAtoms?.forEach(t=>c.push(t+f())),E(d.atoms.x.length);const O=[];for(let t=u;t<l.nodeShift;++t)O.push(t);const g=[];for(let t=I;t<l.bondShift;++t)g.push(t);r.set(e,{biotype:A.biotype,symbol:A.symbol,atoms:O,bonds:g});const L=l.nodeShift,C=l.bondShift;_(T,i,a,l),T.stereoAtoms?.forEach(t=>c.push(t+f())),E(T.atoms.x.length);const B=[];for(let t=L;t<l.nodeShift;++t)B.push(t);const D=[];for(let t=C;t<l.bondShift;++t)D.push(t);r.set(h,{biotype:p.biotype,symbol:p.symbol,atoms:B,bonds:D})}if(T){const o=S+3*(d-1)+2;y(t[o],o)}A&&(l.i=d+(N?1:0),y(t[e.length-1],e.length-1))}(e,c,i,T,y,g,0,C,B,t=>{P+=t},()=>P);else for(g.i=0;g.i<L.seqLength;++g.i){const t=e[g.i];if(""===t.symbol)continue;const n=o(i,{symbol:t.symbol,polymerType:b(t.biotype)});D=n.terminalR2Atom;const s=g.nodeShift,a=g.bondShift;u(n,T,y,g,L),n.stereoAtoms?.forEach(t=>B.push(t+P)),P+=n.atoms.x.length;const l=g.nodeShift-s,h=new Array(l);for(let t=0;t<l;++t)h[t]=s+t;const r=g.bondShift-a,c=new Array(r);for(let t=0;t<r;++t)c[t]=a+t;C.set(g.i,{biotype:t.biotype,symbol:t.symbol,atoms:h,bonds:c})}d&&function(o,n,e,s,i=t.OXYGEN){const a=e.nodeShift+1;o[s.atomCount]=t.V3K_BEGIN_DATA_LINE+a+" "+(i??t.OXYGEN)+" "+S(e.backbonePositionShift[0])+" "+e.flipFactor*S(e.backbonePositionShift[1])+" 0.000000 0\n";const l=e.backboneAttachNode,h=a;n[s.bondCount]=t.V3K_BEGIN_DATA_LINE+e.bondShift+" 1 "+l+" "+h+"\n"}(T,y,g,L,D??t.OXYGEN);const R=t.V3K_BEGIN_COUNTS_LINE+A+" "+p+t.V3K_COUNTS_LINE_ENDING;let K="";return K+=t.V3K_HEADER_FIRST_LINE,K+=t.V3K_HEADER_SECOND_LINE,K+=t.V3K_BEGIN_CTAB_BLOCK,K+=R,K+=t.V3K_BEGIN_ATOM_BLOCK,K+=T.join(""),K+=t.V3K_END_ATOM_BLOCK,K+=t.V3K_BEGIN_BOND_BLOCK,K+=y.join(""),K+=t.V3K_END_BOND_BLOCK,B.length>0&&(K+=function(t){const o=[];let n=`M V30 MDLV30/STEABS ATOMS=(${t.length}`;for(let e=0;e<t.length;e++){const s=`${n} ${t[e]}`;s.length>76?(o.push(`${n} -\n`),n=`M V30 ${t[e]}`):n=s,e===t.length-1&&o.push(`${n})\n`)}return`M V30 BEGIN COLLECTION\n${o.join("")}M V30 END COLLECTION\n`}(B)),K+=t.V3K_END_CTAB_BLOCK,K+=t.V3K_END,{molfile:K,monomers:C}}function f(t,o,n,e){e.flipFactor=(-1)**(e.i%2),m(t,o,n,e)}function m(o,n,e,s){!function(o,n,e){for(let s=0;s<o.atoms.atomTypes.length;++s){const i=e.nodeShift+s+1;n[e.nodeShift+s]=t.V3K_BEGIN_DATA_LINE+i+" "+o.atoms.atomTypes[s]+" "+S(e.backbonePositionShift[0]+o.atoms.x[s])+" "+S(e.backbonePositionShift[1]+e.flipFactor*o.atoms.y[s])+" "+o.atoms.kwargs[s]}}(o,n,s),A(o,e,s),function(o,n,e){if(0!==e.backboneAttachNode){const s=e.bondShift,i=e.backboneAttachNode,a=o.meta.terminalNodes[0]+e.nodeShift;n[e.bondShift-1]=t.V3K_BEGIN_DATA_LINE+s+" 1 "+i+" "+a+"\n"}}(o,e,s),null!==o.meta.branchShift&&o.meta.terminalNodes.length>2&&function(t,o){o.branchAttachNode=o.nodeShift+t.meta.terminalNodes[2];for(let n=0;n<2;++n)o.branchPositionShift[n]=o.backbonePositionShift[n]+t.meta.branchShift[n]}(o,s),function(t,o){o.backboneAttachNode=o.nodeShift+t.meta.terminalNodes[1],o.bondShift+=t.bonds.atomPairs.length+1,o.nodeShift+=t.atoms.atomTypes.length,o.backbonePositionShift[0]+=t.meta.backboneShift?.[0]??0,o.backbonePositionShift[1]+=o.flipFactor*(t.meta.backboneShift?.[1]??0)}(o,s)}function N(t,o,n,e,s){if(0===e.i)m(s.sugar,o,n,e);else for(const t of[s.phosphate,s.sugar])m(t,o,n,e);_(t,o,n,e)}function _(o,n,e,s){!function(o,n,e){for(let s=0;s<o.atoms.atomTypes.length;++s){const i=e.nodeShift+s+1;n[e.nodeShift+s]=t.V3K_BEGIN_DATA_LINE+i+" "+o.atoms.atomTypes[s]+" "+S(e.branchPositionShift[0]+o.atoms.x[s])+" "+S(e.branchPositionShift[1]+e.flipFactor*o.atoms.y[s])+" "+o.atoms.kwargs[s]}}(o,n,s),A(o,e,s),function(o,n,e){const s=e.bondShift,i=e.branchAttachNode,a=o.meta.terminalNodes[0]+e.nodeShift;n[s-1]=t.V3K_BEGIN_DATA_LINE+s+" 1 "+i+" "+a+"\n"}(o,e,s);const i=s.bondShift,a=s.branchAttachNode,l=o.meta.terminalNodes[0]+s.nodeShift;e[i-1]=t.V3K_BEGIN_DATA_LINE+i+" 1 "+a+" "+l+"\n",s.bondShift+=o.bonds.atomPairs.length+1,s.nodeShift+=o.atoms.atomTypes.length}function A(o,n,e){for(let s=0;s<o.bonds.atomPairs.length;++s){const i=e.bondShift+s+1,a=o.bonds.atomPairs[s][0]+e.nodeShift,l=o.bonds.atomPairs[s][1]+e.nodeShift;let h="";if(o.bonds.bondConfiguration.has(s)){let t=o.bonds.bondConfiguration.get(s);e.flipFactor<0&&(t=1===t?3:1),h=" CFG="+t}const r=o.bonds.kwargs.has(s)?" "+o.bonds.kwargs.get(s):"";n[e.bondShift+s]=t.V3K_BEGIN_DATA_LINE+i+" "+o.bonds.bondTypes[s]+" "+a+" "+l+h+r+"\n"}}function S(o){return Math.round(t.PRECISION_FACTOR*o)/t.PRECISION_FACTOR}new h(s.PT,r.fasta.peptide,.5),new h(s.DNA,r.fasta.dna,.55),new h(s.RNA,r.fasta.rna,.55),e.FASTA,e.SEPARATOR,e.HELM,e.BILN,function(t){t.BASE="HELM_BASE",t.SUGAR="HELM_SUGAR",t.LINKER="HELM_LINKER",t.AA="HELM_AA",t.CHEM="HELM_CHEM",t.BLOB="HELM_BLOB",t.NUCLEOTIDE="HELM_NUCLETIDE"}(c||(c={})),onmessage=t=>{const{seqList:o,rolesList:n,monomersDict:e,alphabet:s,polymerType:i,start:a,end:l}=t.data,h=new Array(l-a),r=new Array(0);for(let t=a;t<l;++t)try{const l=o[t],r=n?n[t]:void 0;h[t-a]=E(l,e,s,i,r)}catch(o){const n=`Cannot get molfile of row #${t}: ${o instanceof Error?o.message:o.toString()}.`;r.push(n)}postMessage({molfiles:h,warnings:r})},bio={}})();
2
2
  //# sourceMappingURL=455.js.map
package/dist/455.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"455.js","mappings":"2BAAO,MAAMA,EAAqB,CAE9BC,cAAe,EACfC,aAAc,SACdC,WAAY,MAEZC,iBAAkB,GAClBC,cAAe,EACfC,sBAAuB,uCACvBC,uBAAwB,4CACxBC,qBAAsB,sBACtBC,mBAAoB,oBACpBC,sBAAuB,iBACvBC,uBAAwB,WACxBC,qBAAsB,sBACtBC,mBAAoB,oBACpBC,qBAAsB,sBACtBC,mBAAoB,oBACpBC,gBAAiB,QACjBC,oBAAqB,UACrBC,QAAS,SACTC,iBAAkB,IAElBC,YAAa,CAAEC,YAAa,MAA8BC,OAAQ,KAClEC,OAAQ,CAAEF,YAAa,MAA8BC,OAAQ,KAC7DE,UAAW,CAAEH,YAAa,MAA8BC,OAAQ,KAChEG,OAAQ,IACRC,SAAU,KC3BP,SAASC,EAAYC,EAAMC,GAC9B,OAAOD,EAAKC,EAAOR,eAAeQ,EAAOP,OAC7C,CAWO,IAAIQ,ECXAC,EAQAC,EAQAC,GDJX,SAAWH,GACPA,EAAeA,EAAsB,MAAI,GAAK,QAC9CA,EAAeA,EAAqB,KAAI,GAAK,OAC7CA,EAAeA,EAA0B,UAAI,GAAK,WACrD,CAJD,CAIGA,IAAmBA,EAAiB,CAAC,IACjC,MAAMI,UAAmBC,IAC5B,WAAAC,CAAYC,GACRC,MAAMD,EACV,EAGG,MAAME,EACT,WAAAH,CAAYI,EAASC,GACjBC,KAAKF,QAAUA,EACfE,KAAKD,SAAWA,CACpB,CACA,kBAAOE,GAAgB,OAAO,IAAI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c,GAAI,UAClBA,EAAgB,KAAI,YACpBA,EAAgB,KAAI,YACpBA,EAAsB,WAAI,gBAC7B,CARD,CAQGA,IAAcA,EAAY,CAAC,IGR9B2J,UAAaC,IACT,MAAM,QAAEC,EAAO,UAAEC,EAAS,aAAEhJ,EAAY,SAAEtB,EAAQ,YAAE1B,EAAW,MAAEiM,EAAK,IAAEC,GAAQJ,EAAMK,KAChFC,EAAa,IAAIzH,MAAMuH,EAAMD,GAC7BI,EAAqB,IAAI1H,MAAM,GACrC,IAAK,IAAI2H,EAAOL,EAAOK,EAAOJ,IAAOI,EACjC,IACI,MAAMC,EAAMR,EAAQO,GACdrJ,EAAQ+I,EAAYA,EAAUM,QAAQE,EAC5CJ,EAAWE,EAAOL,GAASnJ,EAAoByJ,EAAKvJ,EAActB,EAAU1B,EAAaiD,EAC7F,CACA,MAAOwJ,GACH,MACMC,EAAM,8BAA8BJ,MAD3BG,aAAe7I,MAAQ6I,EAAIE,QAAUF,EAAIG,cAExDP,EAAmBrF,KAAK0F,EAC5B,CAEJG,YAAY,CAAEC,SAAUV,EAAYW,SAAUV,K","sources":["webpack://bio/./node_modules/@datagrok-libraries/bio/src/monomer-works/consts.js","webpack://bio/./node_modules/@datagrok-libraries/bio/src/monomer-works/types.js","webpack://bio/./node_modules/@datagrok-libraries/bio/src/utils/macromolecule/consts.js","webpack://bio/./node_modules/@datagrok-libraries/bio/src/utils/const.js","webpack://bio/./node_modules/@datagrok-libraries/bio/src/utils/macromolecule/types.js","webpack://bio/./node_modules/@datagrok-libraries/js-draw-lite/src/types/org.js","webpack://bio/./node_modules/@datagrok-libraries/bio/src/monomer-works/monomer-works.js","webpack://bio/./node_modules/@datagrok-libraries/bio/src/monomer-works/to-atomic-level-utils.js","webpack://bio/./node_modules/@datagrok-libraries/bio/src/monomer-works/seq-to-molfile-worker.js"],"sourcesContent":["export const monomerWorksConsts = {\n // constants for parsing molfile V2000\n V2K_RGP_SHIFT: 8,\n V2K_RGP_LINE: 'M RGP',\n V2K_A_LINE: 'A ',\n // constants for parsing/reconstruction of molfile V3000\n V3K_COUNTS_SHIFT: 14,\n V3K_IDX_SHIFT: 7,\n V3K_HEADER_FIRST_LINE: '\\nDatagrok macromolecule handler\\n\\n',\n V3K_HEADER_SECOND_LINE: ' 0 0 0 0 0 0 999 V3000\\n',\n V3K_BEGIN_CTAB_BLOCK: 'M V30 BEGIN CTAB\\n',\n V3K_END_CTAB_BLOCK: 'M V30 END CTAB\\n',\n V3K_BEGIN_COUNTS_LINE: 'M V30 COUNTS ',\n V3K_COUNTS_LINE_ENDING: ' 0 0 0\\n',\n V3K_BEGIN_ATOM_BLOCK: 'M V30 BEGIN ATOM\\n',\n V3K_END_ATOM_BLOCK: 'M V30 END ATOM\\n',\n V3K_BEGIN_BOND_BLOCK: 'M V30 BEGIN BOND\\n',\n V3K_END_BOND_BLOCK: 'M V30 END BOND\\n',\n V3K_BOND_CONFIG: ' CFG=',\n V3K_BEGIN_DATA_LINE: 'M V30 ',\n V3K_END: 'M END',\n PRECISION_FACTOR: 10000, // HELMCoreLibrary has 4 significant digits after decimal point in atom coordinates\n // symbols for the corresponding monomers in HELM library\n DEOXYRIBOSE: { polymerType: \"RNA\" /* PolymerTypes.RNA */, symbol: 'd' },\n RIBOSE: { polymerType: \"RNA\" /* PolymerTypes.RNA */, symbol: 'r' },\n PHOSPHATE: { polymerType: \"RNA\" /* PolymerTypes.RNA */, symbol: 'p' },\n OXYGEN: 'O',\n HYDROGEN: 'H',\n};\n//# sourceMappingURL=consts.js.map","export function getMolGraph(dict, libKey) {\n return dict[libKey.polymerType]?.[libKey.symbol];\n}\nexport function hasMolGraph(dict, libKey) {\n return !!dict[libKey.polymerType]?.[libKey.symbol];\n}\nexport function setMolGraph(dict, libKey, value) {\n let pt = dict[libKey.polymerType];\n if (!pt)\n pt = dict[libKey.polymerType] = {};\n pt[libKey.symbol] = value;\n}\n/** Role of an entry in a HELM RNA splitted sequence (sugar, base, phosphate). */\nexport var NucleotideRole;\n(function (NucleotideRole) {\n NucleotideRole[NucleotideRole[\"SUGAR\"] = 0] = \"SUGAR\";\n NucleotideRole[NucleotideRole[\"BASE\"] = 1] = \"BASE\";\n NucleotideRole[NucleotideRole[\"PHOSPHATE\"] = 2] = \"PHOSPHATE\";\n})(NucleotideRole || (NucleotideRole = {}));\nexport class MonomerMap extends Map {\n constructor(entries) {\n super(entries);\n }\n}\n/** @property monomers key - helm seq position, */\nexport class MolfileWithMap {\n constructor(molfile, monomers) {\n this.molfile = molfile;\n this.monomers = monomers;\n }\n static createEmpty() { return new MolfileWithMap('', new MonomerMap(null)); }\n}\n//# sourceMappingURL=types.js.map","import { CandidateType } from './types';\n/** enum type to simplify setting \"user-friendly\" notation if necessary */\nexport var NOTATION;\n(function (NOTATION) {\n NOTATION[\"FASTA\"] = \"fasta\";\n NOTATION[\"SEPARATOR\"] = \"separator\";\n NOTATION[\"HELM\"] = \"helm\";\n /* Requires notation handler */ NOTATION[\"CUSTOM\"] = \"custom\";\n /* Requires notation handler */ NOTATION[\"BILN\"] = \"biln\";\n})(NOTATION || (NOTATION = {}));\nexport var ALPHABET;\n(function (ALPHABET) {\n ALPHABET[\"DNA\"] = \"DNA\";\n ALPHABET[\"RNA\"] = \"RNA\";\n ALPHABET[\"PT\"] = \"PT\";\n /** Unknown */\n ALPHABET[\"UN\"] = \"UN\";\n})(ALPHABET || (ALPHABET = {}));\nexport var TAGS;\n(function (TAGS) {\n TAGS[\"aligned\"] = \"aligned\";\n TAGS[\"alphabet\"] = \"alphabet\";\n TAGS[\"alphabetSize\"] = \".alphabetSize\";\n TAGS[\"alphabetIsMultichar\"] = \".alphabetIsMultichar\";\n TAGS[\"separator\"] = \"separator\";\n TAGS[\"isHelmCompatible\"] = \".isHelmCompatible\";\n TAGS[\"positionNames\"] = \".positionNames\";\n TAGS[\"positionLabels\"] = \".positionLabels\";\n TAGS[\"regions\"] = \".regions\";\n TAGS[\"positionShift\"] = \".positionShift\";\n TAGS[\"selectedPosition\"] = \".selectedPosition\";\n TAGS[\"polymerTypeColumnName\"] = \".polymerTypeColumnName\";\n TAGS[\"annotations\"] = \".annotations\";\n TAGS[\"numberingScheme\"] = \".numberingScheme\";\n TAGS[\"annotationColumnName\"] = \".annotationColumnName\";\n})(TAGS || (TAGS = {}));\nexport { TAGS as BioTags };\nexport const positionSeparator = ', ';\nexport const monomerRe = /(?:\\[([A-Za-z0-9_\\-,()]+)\\])|([A-Za-z\\-])/g;\nexport const helmRe = /(PEPTIDE1|DNA1|RNA1)\\{([^}]+)}/g;\nexport const helmPp1Re = /\\[([^\\[\\]]+)]/g;\nexport const Alphabets = new class {\n constructor() {\n this.fasta = {\n peptide: new Set([\n 'G', 'L', 'Y', 'S', 'E', 'Q', 'D', 'N', 'F', 'A',\n 'K', 'R', 'H', 'C', 'V', 'P', 'W', 'I', 'M', 'T',\n ]),\n dna: new Set(['A', 'C', 'G', 'T']),\n rna: new Set(['A', 'C', 'G', 'U']),\n };\n }\n}();\nexport const candidateAlphabets = [\n new CandidateType(ALPHABET.PT, Alphabets.fasta.peptide, 0.50),\n new CandidateType(ALPHABET.DNA, Alphabets.fasta.dna, 0.55),\n new CandidateType(ALPHABET.RNA, Alphabets.fasta.rna, 0.55),\n];\n/** Canonical gap symbol */\nexport const GAP_SYMBOL = '';\nexport const GapOriginals = {\n [NOTATION.FASTA]: '-',\n [NOTATION.SEPARATOR]: '',\n [NOTATION.HELM]: '*',\n [NOTATION.BILN]: '',\n};\nexport const MONOMER_MOTIF_SPLITTER = ' , ';\n/** Tag on Monomer columns storing the nqName of a function that returns an IMonomerCanonicalizer.\n * The `.%` prefix ensures this tag is persisted with projects. */\nexport const MONOMER_CANONICALIZER_FUNC_TAG = '.%monomer-canonicalizer-func';\n/** Column temp key for the cached IMonomerCanonicalizer instance */\nexport const MONOMER_CANONICALIZER_TEMP = 'monomer-canonicalizer';\nexport const NOTATION_PROVIDER_CONSTRUCTOR_ROLE = 'notationProviderConstructor';\n//# sourceMappingURL=consts.js.map","// core fields of HELM library object used in toAtomicLevel function\nexport const HELM_CORE_FIELDS = [\n \"symbol\" /* HELM_FIELDS.SYMBOL */,\n \"molfile\" /* HELM_FIELDS.MOLFILE */,\n \"rgroups\" /* HELM_FIELDS.RGROUPS */,\n \"name\" /* HELM_FIELDS.NAME */,\n // HELM_FIELDS.MONOMER_TYPE, // add if terminal monomers for PEPTIDEs to be\n // supported\n];\nexport const SDF_MONOMER_NAME = 'MonomerName';\n// todo: ideally, keys should be expressed via constants\nexport const jsonSdfMonomerLibDict = {\n 'monomerType': null, // -> Backbone\n 'smiles': null,\n 'name': 'Name',\n 'author': null,\n 'molfile': 'molecule',\n 'naturalAnalog': 'MonomerNaturalAnalogCode',\n 'rgroups': 'MonomerCaps',\n 'createDate': null,\n 'id': null,\n 'polymerType': 'MonomerType',\n 'symbol': 'MonomerName'\n};\nexport const DUMMY_MONOMER = {\n 'monomerType': 'Backbone',\n 'smiles': '',\n 'name': '',\n 'author': 'Datagrok',\n 'molfile': '',\n 'naturalAnalog': '',\n 'rgroups': [],\n 'createDate': null,\n 'id': 0,\n 'polymerType': 'PEPTIDE',\n 'symbol': ''\n};\n// range of hex nubers used in PepSea library to endode monomers\nexport const MONOMER_ENCODE_MIN = 0x100;\nexport const MONOMER_ENCODE_MAX = 0x40A;\nexport const RIBOSE_SYMBOL = 'r';\nexport const DEOXYRIBOSE_SYMBOL = 'd';\nexport const PHOSPHATE_SYMBOL = 'p';\nexport const HELM_WRAPPERS_REGEXP = new RegExp(`[${RIBOSE_SYMBOL}${DEOXYRIBOSE_SYMBOL}]\\\\((\\\\w)\\\\)${PHOSPHATE_SYMBOL}?`, 'g');\n//# sourceMappingURL=const.js.map","import { NOTATION_PROVIDER_CONSTRUCTOR_ROLE } from './consts';\nexport class NotationProviderBase {\n /** Name of the custom notation */\n static get notationName() {\n return 'Custom';\n }\n ;\n /** flag to let bio know if this provider implements method for converting helm to it */\n static get implementsFromHelm() {\n return false;\n }\n ;\n /** Method for converting HELM to this notation */\n static convertFromHelm(helm, options) {\n throw new Error(`Method convertFromHelm not implemented for this notation provider`);\n }\n ;\n static async getProviderConstructors() {\n // this is terrible, I know, but otherwise this gets put in webworkers and fails due to DG resolution)))\n // @ts-ignore\n if (window?.DG) {\n // @ts-ignore\n const constFuncs = window.DG.Func.find({ meta: { role: NOTATION_PROVIDER_CONSTRUCTOR_ROLE } });\n return Promise.all(constFuncs.map((f) => f.apply({})));\n }\n return [];\n }\n}\n/** Alphabet candidate type */\nexport class CandidateType {\n constructor(name, alphabet, cutoff) {\n this.name = name;\n this.alphabet = alphabet;\n this.cutoff = cutoff;\n }\n}\n/** Alphabet candidate similarity type */\nexport class CandidateSimType extends CandidateType {\n constructor(candidate, freq, similarity) {\n super(candidate.name, candidate.alphabet, candidate.cutoff);\n this.freq = freq;\n this.similarity = similarity;\n }\n}\n//# sourceMappingURL=types.js.map","export var HelmTypes;\n(function (HelmTypes) {\n HelmTypes[\"BASE\"] = \"HELM_BASE\";\n HelmTypes[\"SUGAR\"] = \"HELM_SUGAR\";\n HelmTypes[\"LINKER\"] = \"HELM_LINKER\";\n HelmTypes[\"AA\"] = \"HELM_AA\";\n HelmTypes[\"CHEM\"] = \"HELM_CHEM\";\n HelmTypes[\"BLOB\"] = \"HELM_BLOB\";\n HelmTypes[\"NUCLEOTIDE\"] = \"HELM_NUCLETIDE\";\n})(HelmTypes || (HelmTypes = {}));\n//# sourceMappingURL=org.js.map","import { HelmTypes } from '../helm/consts';\nexport class MonomerWorks {\n //private molfileConverter: IMolfileConverter;\n constructor(monomerLib /*, molfileConverter: IMolfileConverter*/) {\n this.monomerLib = monomerLib;\n //this.molfileConverter = molfileConverter;\n }\n //types according to Monomer possible\n getCappedRotatedMonomer(monomerType, monomerName) {\n // TODO: Check type of monomerType arg\n const monomer = this.monomerLib.getMonomer(monomerType, monomerName);\n if (monomer)\n return monomer.molfile; //TODO cap\n return null;\n }\n}\nexport function helmTypeToPolymerType(helmType) {\n let polymerType = undefined;\n switch (helmType) {\n case HelmTypes.BASE:\n case HelmTypes.SUGAR: // r - ribose, d - deoxyribose\n case HelmTypes.LINKER: // p - phosphate\n case HelmTypes.NUCLEOTIDE:\n // @ts-ignore\n case 'nucleotide':\n polymerType = \"RNA\" /* PolymerTypes.RNA */;\n break;\n case HelmTypes.AA:\n polymerType = \"PEPTIDE\" /* PolymerTypes.PEPTIDE */;\n break;\n case HelmTypes.CHEM:\n polymerType = \"CHEM\" /* PolymerTypes.CHEM */;\n break;\n case HelmTypes.BLOB:\n polymerType = \"BLOB\" /* PolymerTypes.BLOB */;\n break;\n default:\n polymerType = \"PEPTIDE\" /* PolymerTypes.PEPTIDE */;\n console.warn(`Unexpected HelmType '${helmType}'`);\n }\n return polymerType;\n}\n//# sourceMappingURL=monomer-works.js.map","/* eslint-disable max-len */\nimport { monomerWorksConsts as C } from './consts';\nimport { getMolGraph, MolfileWithMap, MonomerMap } from './types';\nimport { HELM_CORE_FIELDS, } from '../utils/const';\nimport { ALPHABET, GAP_SYMBOL } from '../utils/macromolecule/consts';\nimport { helmTypeToPolymerType } from './monomer-works';\n/** Get a mapping of peptide symbols to HELM monomer library objects with selected fields.\n * @param {IMonomerLib} monomerLib - Monomer library\n * @param {HELM_POLYMER_TYPE} polymerType - Polymer type\n * @param {ALPHABET} alphabet - Alphabet of the column\n * @return {Map<string, any>} - Mapping of peptide symbols to HELM monomer library objects with selected fields*/\nexport function getFormattedMonomerLib(monomerLib, polymerType, alphabet) {\n const map = new Map();\n for (const monomerSymbol of monomerLib.getMonomerSymbolsByType(polymerType)) {\n const it = monomerLib.getMonomer(polymerType, monomerSymbol);\n if (\n // RNA: all branch monomers (bases) and all backbone monomers (sugars +\n // phosphates, including modified ones). Modifications are looked up by\n // symbol at assembly time, so they MUST be present in the formatted lib.\n polymerType === \"RNA\" /* HELM_POLYMER_TYPE.RNA */ &&\n (it[\"monomerType\" /* HELM_FIELDS.MONOMER_TYPE */] === \"Branch\" /* HELM_MONOMER_TYPE.BRANCH */ ||\n it[\"monomerType\" /* HELM_FIELDS.MONOMER_TYPE */] === \"Backbone\" /* HELM_MONOMER_TYPE.BACKBONE */) ||\n polymerType === \"PEPTIDE\" /* HELM_POLYMER_TYPE.PEPTIDE */ &&\n it[\"monomerType\" /* HELM_FIELDS.MONOMER_TYPE */] !== \"Branch\" /* HELM_MONOMER_TYPE.BRANCH */) {\n const monomerObject = {};\n HELM_CORE_FIELDS.forEach((field) => {\n //@ts-ignore\n monomerObject[field] = it[field];\n });\n map.set(monomerSymbol, monomerObject);\n }\n }\n return map;\n}\n/** Translate a sequence of monomer symbols into Molfile V3000\n * @param {ISeqMonomer[]} monomerSeq - Sequence of monomer symbols (canonical)\n * @param {MonomerMolGraphMap} monomersDict - Mapping of monomer symbols to MolGraph objects\n * @param {ALPHABET} alphabet - Alphabet of the column\n * @param {PolymerType} polymerType - Polymer type\n * @param {Array} roles - Optional per-position NucleotideRole tags. When set, RNA assembly\n * uses per-position sugars/phosphates from monomerSeq directly (HELM triples mode).\n * @return {MolfileWithMap} - Molfile V3000 + per-position monomer index map */\nexport function monomerSeqToMolfile(monomerSeq, monomersDict, alphabet, polymerType, roles) {\n if (monomerSeq.length === 0) {\n // throw new Error('monomerSeq is empty');\n return MolfileWithMap.createEmpty();\n }\n // Triples mode is on only when (a) caller flagged the row with roles, and\n // (b) the row's length is a positive multiple of 3 (sugar/base/phosphate triples).\n // in edge cases, terminal phosphate may be missing, so we also allow length % 3 === 2, but only if roles are present to disambiguate the monomers.\n const triplesMode = polymerType === \"RNA\" /* HELM_POLYMER_TYPE.RNA */ && !!roles &&\n roles.length === monomerSeq.length && (monomerSeq.length % 3 === 0 || monomerSeq.length % 3 === 2);\n // define atom and bond counts, taking into account the bond type\n const { atomCount, bondCount, needsCapping } = getResultingAtomBondCounts(monomerSeq, monomersDict, alphabet, polymerType, triplesMode);\n // create arrays to store lines of the resulting molfile\n const molfileAtomBlock = new Array(atomCount);\n const molfileBondBlock = new Array(bondCount);\n let addMonomerToMolblock;\n let sugar = null;\n let phosphate = null;\n if (polymerType === \"PEPTIDE\" /* HELM_POLYMER_TYPE.PEPTIDE */)\n addMonomerToMolblock = addAminoAcidToMolblock;\n else { // nucleotides\n addMonomerToMolblock = addNucleotideToMolblock;\n // Default sugar/phosphate are only consulted in bases-only mode. In\n // triples mode, every nucleotide carries its own.\n if (!triplesMode) {\n sugar = (alphabet === ALPHABET.DNA) ? getMolGraph(monomersDict, C.DEOXYRIBOSE) : getMolGraph(monomersDict, C.RIBOSE);\n phosphate = getMolGraph(monomersDict, C.PHOSPHATE);\n }\n }\n const v = {\n i: 0,\n nodeShift: 0,\n bondShift: 0,\n backbonePositionShift: new Array(2).fill(0),\n branchPositionShift: new Array(2).fill(0),\n backboneAttachNode: 0,\n branchAttachNode: 0,\n flipFactor: 1,\n };\n const LC = {\n sugar: sugar,\n phosphate: phosphate,\n // In triples mode, the \"logical\" sequence length is the nucleotide count.\n seqLength: triplesMode ? Math.ceil(monomerSeq.length / 3) : monomerSeq.length,\n atomCount: atomCount,\n bondCount: bondCount,\n };\n const monomers = new MonomerMap();\n const steabsCollection = [];\n let nAtoms = 0;\n let lastMonomerCappingAtom = undefined;\n if (triplesMode) {\n runTriplesAssembly(monomerSeq, monomersDict, molfileAtomBlock, molfileBondBlock, v, LC, monomers, steabsCollection, (a) => { nAtoms += a; }, () => nAtoms);\n }\n else {\n for (v.i = 0; v.i < LC.seqLength; ++v.i) {\n const seqMonomer = monomerSeq[v.i];\n if (seqMonomer.symbol === GAP_SYMBOL)\n continue;\n const monomer = getMolGraph(monomersDict, { symbol: seqMonomer.symbol, polymerType: helmTypeToPolymerType(seqMonomer.biotype) });\n lastMonomerCappingAtom = monomer.terminalR2Atom;\n const mAtomFirst = v.nodeShift;\n const mBondFirst = v.bondShift;\n addMonomerToMolblock(monomer, molfileAtomBlock, molfileBondBlock, v, LC);\n //adding stereo atoms to array for further STEABS block generation\n monomer.stereoAtoms?.forEach((i) => steabsCollection.push(i + nAtoms));\n nAtoms += monomer.atoms.x.length;\n const mAtomCount = v.nodeShift - mAtomFirst;\n const mAtomList = new Array(mAtomCount);\n for (let maI = 0; maI < mAtomCount; ++maI)\n mAtomList[maI] = mAtomFirst + maI;\n const mBondCount = v.bondShift - mBondFirst;\n const mBondList = new Array(mBondCount);\n for (let mbI = 0; mbI < mBondCount; ++mbI)\n mBondList[mbI] = mBondFirst + mbI;\n monomers.set(v.i, {\n biotype: seqMonomer.biotype,\n symbol: seqMonomer.symbol,\n atoms: mAtomList, bonds: mBondList\n });\n }\n }\n // if the last monomer needs to be capped, add the terminal OH to the resulting molfile\n if (needsCapping)\n capResultingMolblock(molfileAtomBlock, molfileBondBlock, v, LC, lastMonomerCappingAtom ?? C.OXYGEN);\n const molfileCountsLine = C.V3K_BEGIN_COUNTS_LINE + atomCount + ' ' + bondCount + C.V3K_COUNTS_LINE_ENDING;\n // todo: possible optimization may be achieved by replacing .join('') with +=\n // since counterintuitively joining an array into a new string is reportedly\n // slower than using += as below\n let result = '';\n result += C.V3K_HEADER_FIRST_LINE;\n result += C.V3K_HEADER_SECOND_LINE;\n result += C.V3K_BEGIN_CTAB_BLOCK;\n result += molfileCountsLine;\n result += C.V3K_BEGIN_ATOM_BLOCK;\n result += molfileAtomBlock.join('');\n result += C.V3K_END_ATOM_BLOCK;\n result += C.V3K_BEGIN_BOND_BLOCK;\n result += molfileBondBlock.join('');\n result += C.V3K_END_BOND_BLOCK;\n if (steabsCollection.length > 0)\n result += getCollectionBlock(steabsCollection);\n result += C.V3K_END_CTAB_BLOCK;\n result += C.V3K_END;\n // return molfileParts.join('');\n return { molfile: result, monomers: monomers };\n}\nfunction getCollectionBlock(collection) {\n //one row in STEABS block can be no longer than 80 symbols\n //maxSymbols = 80 symbols minus ' -\\n' (4 symbols)\n const maxSymbols = 76;\n const rowsArray = [];\n let newCollectionRow = `M V30 MDLV30/STEABS ATOMS=(${collection.length}`;\n for (let i = 0; i < collection.length; i++) {\n const updatedRow = `${newCollectionRow} ${collection[i]}`;\n if (updatedRow.length > maxSymbols) {\n rowsArray.push(`${newCollectionRow} -\\n`);\n newCollectionRow = `M V30 ${collection[i]}`;\n }\n else\n newCollectionRow = updatedRow;\n //in case last atom was added - close the block\n if (i === collection.length - 1)\n rowsArray.push(`${newCollectionRow})\\n`);\n }\n return `M V30 BEGIN COLLECTION\\n${rowsArray.join('')}M V30 END COLLECTION\\n`;\n}\n/** Cap the resulting (after sewing up all the monomers) molfile with 'O'\n * @param {string[]} molfileAtomBlock - Array of lines of the resulting molfile atom block\n * @param {string[]} molfileBondBlock - Array of lines of the resulting molfile bond block\n * @param {LoopVariables} v - Loop variables\n * @param {LoopConstants} LC - Loop constants*/\nfunction capResultingMolblock(molfileAtomBlock, molfileBondBlock, v, LC, cappingAtomType = C.OXYGEN) {\n // add terminal oxygen\n const atomIdx = v.nodeShift + 1;\n molfileAtomBlock[LC.atomCount] = C.V3K_BEGIN_DATA_LINE + atomIdx + ' ' +\n (cappingAtomType ?? C.OXYGEN) + ' ' + keepPrecision(v.backbonePositionShift[0]) + ' ' +\n v.flipFactor * keepPrecision(v.backbonePositionShift[1]) + ' ' + '0.000000 0' + '\\n';\n // add terminal bond\n const firstAtom = v.backboneAttachNode;\n const secondAtom = atomIdx;\n molfileBondBlock[LC.bondCount] = C.V3K_BEGIN_DATA_LINE + v.bondShift + ' ' +\n 1 + ' ' + firstAtom + ' ' + secondAtom + '\\n';\n}\nfunction addAminoAcidToMolblock(monomer, molfileAtomBlock, molfileBondBlock, v) {\n v.flipFactor = (-1) ** (v.i % 2); // to flip every even monomer over OX\n addBackboneMonomerToMolblock(monomer, molfileAtomBlock, molfileBondBlock, v);\n}\nfunction addBackboneMonomerToMolblock(monomer, molfileAtomBlock, molfileBondBlock, v) {\n // todo: remove these comments to the docstrings of the corr. functions\n // construnct the lines of V3K molfile atom block\n fillAtomLines(monomer, molfileAtomBlock, v);\n // construct the lines of V3K molfile bond block\n fillBondLines(monomer, molfileBondBlock, v);\n // peptide bond\n fillChainExtendingBond(monomer, molfileBondBlock, v);\n // update branch variables if necessary\n if (monomer.meta.branchShift !== null && monomer.meta.terminalNodes.length > 2)\n updateBranchVariables(monomer, v);\n // update loop variables\n updateChainExtendingVariables(monomer, v);\n}\nfunction addNucleotideToMolblock(nucleobase, molfileAtomBlock, molfileBondBlock, v, LC) {\n // construnct the lines of V3K molfile atom block corresponding to phosphate\n // and sugar\n if (v.i === 0)\n addBackboneMonomerToMolblock(LC.sugar, molfileAtomBlock, molfileBondBlock, v);\n else {\n for (const monomer of [LC.phosphate, LC.sugar])\n addBackboneMonomerToMolblock(monomer, molfileAtomBlock, molfileBondBlock, v);\n }\n addBranchMonomerToMolblock(nucleobase, molfileAtomBlock, molfileBondBlock, v);\n}\nfunction addBranchMonomerToMolblock(monomer, molfileAtomBlock, molfileBondBlock, v) {\n fillBranchAtomLines(monomer, molfileAtomBlock, v);\n fillBondLines(monomer, molfileBondBlock, v);\n fillBackboneToBranchBond(monomer, molfileBondBlock, v);\n // C-N bond\n const bondIdx = v.bondShift;\n const firstAtom = v.branchAttachNode;\n const secondAtom = monomer.meta.terminalNodes[0] + v.nodeShift;\n molfileBondBlock[bondIdx - 1] = C.V3K_BEGIN_DATA_LINE + bondIdx + ' ' +\n 1 + ' ' + firstAtom + ' ' + secondAtom + '\\n';\n // update loop variables\n v.bondShift += monomer.bonds.atomPairs.length + 1;\n v.nodeShift += monomer.atoms.atomTypes.length;\n}\nfunction updateChainExtendingVariables(monomer, v) {\n v.backboneAttachNode = v.nodeShift + monomer.meta.terminalNodes[1];\n v.bondShift += monomer.bonds.atomPairs.length + 1;\n v.nodeShift += monomer.atoms.atomTypes.length;\n v.backbonePositionShift[0] += monomer.meta.backboneShift?.[0] ?? 0; // todo: non-null check\n v.backbonePositionShift[1] += v.flipFactor * (monomer.meta.backboneShift?.[1] ?? 0);\n}\nfunction updateBranchVariables(monomer, v) {\n v.branchAttachNode = v.nodeShift + monomer.meta.terminalNodes[2];\n for (let i = 0; i < 2; ++i)\n v.branchPositionShift[i] = v.backbonePositionShift[i] + monomer.meta.branchShift[i];\n}\nfunction fillAtomLines(monomer, molfileAtomBlock, v) {\n for (let j = 0; j < monomer.atoms.atomTypes.length; ++j) {\n const atomIdx = v.nodeShift + j + 1;\n molfileAtomBlock[v.nodeShift + j] = C.V3K_BEGIN_DATA_LINE + atomIdx + ' ' +\n monomer.atoms.atomTypes[j] + ' ' +\n keepPrecision(v.backbonePositionShift[0] + monomer.atoms.x[j]) + ' ' +\n keepPrecision(v.backbonePositionShift[1] + v.flipFactor * monomer.atoms.y[j]) +\n ' ' + monomer.atoms.kwargs[j];\n }\n}\n// todo: remove as quickfix\nfunction fillBranchAtomLines(monomer, molfileAtomBlock, v) {\n for (let j = 0; j < monomer.atoms.atomTypes.length; ++j) {\n const atomIdx = v.nodeShift + j + 1;\n molfileAtomBlock[v.nodeShift + j] = C.V3K_BEGIN_DATA_LINE + atomIdx + ' ' +\n monomer.atoms.atomTypes[j] + ' ' +\n keepPrecision(v.branchPositionShift[0] + monomer.atoms.x[j]) + ' ' +\n keepPrecision(v.branchPositionShift[1] + v.flipFactor * monomer.atoms.y[j]) +\n ' ' + monomer.atoms.kwargs[j];\n }\n}\nfunction fillBondLines(monomer, molfileBondBlock, v) {\n // construct the lines of V3K molfile bond block\n for (let j = 0; j < monomer.bonds.atomPairs.length; ++j) {\n const bondIdx = v.bondShift + j + 1;\n const firstAtom = monomer.bonds.atomPairs[j][0] + v.nodeShift;\n const secondAtom = monomer.bonds.atomPairs[j][1] + v.nodeShift;\n let bondCfg = '';\n if (monomer.bonds.bondConfiguration.has(j)) {\n // flip orientation when necessary\n let orientation = monomer.bonds.bondConfiguration.get(j);\n if (v.flipFactor < 0)\n orientation = (orientation === 1) ? 3 : 1;\n bondCfg = ' CFG=' + orientation;\n }\n const kwargs = monomer.bonds.kwargs.has(j) ?\n ' ' + monomer.bonds.kwargs.get(j) : '';\n molfileBondBlock[v.bondShift + j] = C.V3K_BEGIN_DATA_LINE + bondIdx + ' ' +\n monomer.bonds.bondTypes[j] + ' ' +\n firstAtom + ' ' + secondAtom + bondCfg + kwargs + '\\n';\n }\n}\nfunction fillChainExtendingBond(monomer, molfileBondBlock, v) {\n if (v.backboneAttachNode !== 0) {\n const bondIdx = v.bondShift;\n const firstAtom = v.backboneAttachNode;\n const secondAtom = monomer.meta.terminalNodes[0] + v.nodeShift;\n molfileBondBlock[v.bondShift - 1] = C.V3K_BEGIN_DATA_LINE + bondIdx + ' ' +\n 1 + ' ' + firstAtom + ' ' + secondAtom + '\\n';\n }\n}\n// todo: remove\nfunction fillBackboneToBranchBond(branchMonomer, molfileBondBlock, v) {\n const bondIdx = v.bondShift;\n const firstAtom = v.branchAttachNode;\n const secondAtom = branchMonomer.meta.terminalNodes[0] + v.nodeShift;\n molfileBondBlock[bondIdx - 1] = C.V3K_BEGIN_DATA_LINE + bondIdx + ' ' +\n 1 + ' ' + firstAtom + ' ' + secondAtom + '\\n';\n}\n/** Compute the atom/bond counts for the resulting molfile, depending on the\n * type of polymer (peptide/nucleotide)\n * @param {ISeqMonomer[]} monomerSeq - the sequence of monomers\n * @param {MonomerMolGraphMap} monomersDict - the dictionary of monomers\n * @param {ALPHABET} alphabet - the alphabet of the monomers\n * @param {PolymerType} polymerType - the type of polymer\n * @param {boolean} triplesMode - true when monomerSeq is a flat list of HELM RNA triples\n * @return {Object} the atom/bond counts plus needsCapping flag */\nfunction getResultingAtomBondCounts(monomerSeq, monomersDict, alphabet, polymerType, triplesMode) {\n let atomCount = 0;\n let bondCount = 0;\n let monomerCount = 0;\n let needsCapping = true;\n let lastMonomerGraph = null;\n let lastPhosphateGraph = null;\n // sum up all the atoms/nodes provided by the sequence\n for (let i = 0; i < monomerSeq.length; ++i) {\n const seqMonomer = monomerSeq[i];\n if (seqMonomer.symbol === GAP_SYMBOL)\n continue; // Skip for gap/empty monomer in MSA\n if (seqMonomer.symbol == '*')\n throw new Error(`Gap canonical symbol is '', not '*`);\n lastMonomerGraph = getMolGraph(monomersDict, { symbol: seqMonomer.symbol, polymerType: helmTypeToPolymerType(seqMonomer.biotype) });\n atomCount += lastMonomerGraph.atoms.x.length;\n bondCount += lastMonomerGraph.bonds.bondTypes.length;\n monomerCount++;\n // In triples mode, every 3rd entry (index 2 mod 3) is a phosphate. Track\n // the LAST one — its atoms/bonds are dropped at the 3'-terminus.\n if (triplesMode && i % 3 === 2)\n lastPhosphateGraph = lastMonomerGraph;\n }\n // add extra values depending on the polymer type\n if (polymerType === \"PEPTIDE\" /* HELM_POLYMER_TYPE.PEPTIDE */) {\n // add the rightmost/terminating cap group 'OH' (i.e. 'O')\n atomCount += 1;\n // add chain-extending bonds (C-NH per each monomer pair and terminal C-OH)\n bondCount += monomerCount;\n // if the last monomer is something like NH2, which only has R1, there is no need to cap it\n // although, this should never happen, but hey... in other bits of code, there is a chunk that adds pseudo-R2 as hydrogen\n // we should also check, if the R2 of the last monomer is not hydrogen, that case should also be omitted\n if (monomerCount > 0) {\n if ((lastMonomerGraph?.meta?.rNodes?.length ?? 0) < 2 || lastMonomerGraph?.terminalR2Atom?.toLowerCase() === C.HYDROGEN.toLowerCase()) {\n needsCapping = false;\n atomCount -= 1; // remove the last atom (the terminal 'O')\n bondCount -= 1; // remove the last bond (the terminal C-OH)\n }\n }\n }\n else if (triplesMode) { // nucleotides — HELM triples (per-position sugar/base/phosphate)\n void lastPhosphateGraph; // kept for symmetry; trailing P is now retained when HELM wrote it\n // Per-monomer-loop already summed sugars + bases + phosphates for every\n // entry in monomerSeq. Reservation: each backbone (sugar/phosphate)\n // reserves +1 bond slot for the chain-extending bond, each branch (base)\n // reserves +1 for its branch bond. Total reservations = monomerCount.\n // length === 3N → trailing P emitted, monomerCount = 3N.\n // length === 3N - 1 → trailing P absent, monomerCount = 3N - 1.\n // Either way, bondCount = sum_bonds + monomerCount.\n atomCount += 1; // OH cap atom (rides on trailing P or on last sugar's R2)\n bondCount += monomerCount;\n }\n else { // nucleotides — bases-only legacy path with default sugar/phosphate\n const sugar = (alphabet === ALPHABET.DNA) ?\n getMolGraph(monomersDict, C.DEOXYRIBOSE) : getMolGraph(monomersDict, C.RIBOSE);\n const phosphate = getMolGraph(monomersDict, C.PHOSPHATE);\n // add phosphate per each pair of nucleobase symbols\n atomCount += (monomerSeq.length - 1) * phosphate.atoms.x.length;\n // add sugar per each nucleobase symbol\n atomCount += monomerSeq.length * sugar.atoms.x.length;\n // add the leftmost cap group 'OH' (i.e. 'O')\n atomCount += 1;\n // add bonds from phosphate monomers\n bondCount += (monomerSeq.length - 1) * phosphate.bonds.bondTypes.length;\n // add bonds from sugar monomers\n bondCount += monomerSeq.length * sugar.bonds.bondTypes.length;\n // exclude the first chain-extending bond O-P (absent, no 'leftmost' phosphate)\n bondCount -= 1;\n // add chain-extending and branch bonds (O-P, C-O and C-N per each nucleotide)\n bondCount += monomerSeq.length * 3;\n }\n return { atomCount, bondCount, needsCapping };\n}\n/** Triples-mode RNA assembly. Iterate by NUCLEOTIDE; each nucleotide normally\n * contributes 3 entries from monomerSeq in order [sugar, base, phosphate].\n * The LAST nucleotide may omit its trailing phosphate (length === 3N - 1) —\n * in that case HELM specified an unphosphorylated 3'-end and we cap on the\n * last sugar's R2 instead of on a final phosphate.\n *\n * @param {ISeqMonomer[]} monomerSeq - flat sugar/base/[phosphate] entries\n * @param {MonomerMolGraphMap} monomersDict - monomer dictionary\n * @param {string[]} molfileAtomBlock - output atom block buffer\n * @param {string[]} molfileBondBlock - output bond block buffer\n * @param {LoopVariables} v - mutable loop variables\n * @param {LoopConstants} LC - loop constants (seqLength = nucleotide count)\n * @param {MonomerMap} monomers - per-position monomer index map (filled in)\n * @param {number[]} steabsCollection - stereo atoms collected for STEABS block\n * @param {Function} addAtoms - callback to bump per-row atom counter for stereo offsets\n * @param {Function} getAtoms - callback to read current atom counter */\nfunction runTriplesAssembly(monomerSeq, monomersDict, molfileAtomBlock, molfileBondBlock, v, LC, monomers, steabsCollection, addAtoms, getAtoms) {\n const N = LC.seqLength;\n // length === 3N → trailing P present. length === 3N-1 → trailing P absent.\n const hasTrailingP = monomerSeq.length === 3 * N;\n for (let n = 0; n < N; ++n) {\n v.i = n;\n const sugarSm = monomerSeq[3 * n];\n const baseSm = monomerSeq[3 * n + 1];\n const sugarG = getMolGraph(monomersDict, { symbol: sugarSm.symbol, polymerType: helmTypeToPolymerType(sugarSm.biotype) });\n const baseG = getMolGraph(monomersDict, { symbol: baseSm.symbol, polymerType: helmTypeToPolymerType(baseSm.biotype) });\n // The previous nucleotide's trailing phosphate is the linker into THIS\n // nucleotide's sugar. It always exists for n >= 1 because only the\n // very LAST nucleotide is permitted to omit its phosphate.\n const prevPhosG = (n === 0) ? null :\n getMolGraph(monomersDict, { symbol: monomerSeq[3 * (n - 1) + 2].symbol,\n polymerType: helmTypeToPolymerType(monomerSeq[3 * (n - 1) + 2].biotype) });\n // emit prevPhosphate (chain linker), then sugar, then base\n const seqStartIdx = 3 * n; // for keying the per-row monomer map by HELM splitter index\n if (prevPhosG) {\n const prevAtomFirst = v.nodeShift;\n const prevBondFirst = v.bondShift;\n addBackboneMonomerToMolblock(prevPhosG, molfileAtomBlock, molfileBondBlock, v);\n prevPhosG.stereoAtoms?.forEach((i) => steabsCollection.push(i + getAtoms()));\n addAtoms(prevPhosG.atoms.x.length);\n // The phosphate \"belongs to\" nucleotide n-1's HELM index (3*(n-1)+2).\n const prevPhosKey = 3 * (n - 1) + 2;\n const aList = [];\n for (let a = prevAtomFirst; a < v.nodeShift; ++a)\n aList.push(a);\n const bList = [];\n for (let b = prevBondFirst; b < v.bondShift; ++b)\n bList.push(b);\n monomers.set(prevPhosKey, {\n biotype: monomerSeq[prevPhosKey].biotype,\n symbol: monomerSeq[prevPhosKey].symbol,\n atoms: aList, bonds: bList,\n });\n }\n const sugarAtomFirst = v.nodeShift;\n const sugarBondFirst = v.bondShift;\n addBackboneMonomerToMolblock(sugarG, molfileAtomBlock, molfileBondBlock, v);\n sugarG.stereoAtoms?.forEach((i) => steabsCollection.push(i + getAtoms()));\n addAtoms(sugarG.atoms.x.length);\n const sAList = [];\n for (let a = sugarAtomFirst; a < v.nodeShift; ++a)\n sAList.push(a);\n const sBList = [];\n for (let b = sugarBondFirst; b < v.bondShift; ++b)\n sBList.push(b);\n monomers.set(seqStartIdx, {\n biotype: sugarSm.biotype, symbol: sugarSm.symbol,\n atoms: sAList, bonds: sBList,\n });\n const baseAtomFirst = v.nodeShift;\n const baseBondFirst = v.bondShift;\n addBranchMonomerToMolblock(baseG, molfileAtomBlock, molfileBondBlock, v);\n baseG.stereoAtoms?.forEach((i) => steabsCollection.push(i + getAtoms()));\n addAtoms(baseG.atoms.x.length);\n const bAList = [];\n for (let a = baseAtomFirst; a < v.nodeShift; ++a)\n bAList.push(a);\n const bBList = [];\n for (let b = baseBondFirst; b < v.bondShift; ++b)\n bBList.push(b);\n monomers.set(seqStartIdx + 1, {\n biotype: baseSm.biotype, symbol: baseSm.symbol,\n atoms: bAList, bonds: bBList,\n });\n }\n // Emit the trailing phosphate (the LAST nucleotide's P) as the final\n // backbone monomer ONLY if HELM explicitly wrote it. The OH cap then\n // rides on its free oxygen (3'-phosphate-OH terminus). If HELM omitted\n // the trailing phosphate, the cap rides on the last sugar's R2 — that\n // requires no extra emission here, since v.backboneAttachNode already\n // points at the last sugar's R2 attach.\n if (hasTrailingP) {\n const lastPhosKey = 3 * (N - 1) + 2;\n const lastPhosSm = monomerSeq[lastPhosKey];\n const lastPhosG = getMolGraph(monomersDict, { symbol: lastPhosSm.symbol, polymerType: helmTypeToPolymerType(lastPhosSm.biotype) });\n const trailAtomFirst = v.nodeShift;\n const trailBondFirst = v.bondShift;\n addBackboneMonomerToMolblock(lastPhosG, molfileAtomBlock, molfileBondBlock, v);\n lastPhosG.stereoAtoms?.forEach((i) => steabsCollection.push(i + getAtoms()));\n addAtoms(lastPhosG.atoms.x.length);\n const tAList = [];\n for (let a = trailAtomFirst; a < v.nodeShift; ++a)\n tAList.push(a);\n const tBList = [];\n for (let b = trailBondFirst; b < v.bondShift; ++b)\n tBList.push(b);\n monomers.set(lastPhosKey, {\n biotype: lastPhosSm.biotype, symbol: lastPhosSm.symbol,\n atoms: tAList, bonds: tBList,\n });\n }\n}\n/** Keep precision upon floating point operations over atom coordinates\n * @param {number}x - the floating point number\n * @return {number} - the floating point number with the same precision\n */\nexport function keepPrecision(x) {\n return Math.round(C.PRECISION_FACTOR * x) / C.PRECISION_FACTOR;\n}\n//# sourceMappingURL=to-atomic-level-utils.js.map","import { monomerSeqToMolfile } from './to-atomic-level-utils';\nonmessage = (event) => {\n const { seqList, rolesList, monomersDict, alphabet, polymerType, start, end } = event.data;\n const resMolList = new Array(end - start);\n const molfileWarningList = new Array(0);\n for (let rowI = start; rowI < end; ++rowI) {\n try {\n const seq = seqList[rowI];\n const roles = rolesList ? rolesList[rowI] : undefined;\n resMolList[rowI - start] = monomerSeqToMolfile(seq, monomersDict, alphabet, polymerType, roles);\n }\n catch (err) {\n const errMsg = err instanceof Error ? err.message : err.toString();\n const msg = `Cannot get molfile of row #${rowI}: ${errMsg}.`;\n molfileWarningList.push(msg);\n }\n }\n postMessage({ molfiles: resMolList, warnings: molfileWarningList });\n};\n//# sourceMappingURL=seq-to-molfile-worker.js.map"],"names":["monomerWorksConsts","V2K_RGP_SHIFT","V2K_RGP_LINE","V2K_A_LINE","V3K_COUNTS_SHIFT","V3K_IDX_SHIFT","V3K_HEADER_FIRST_LINE","V3K_HEADER_SECOND_LINE","V3K_BEGIN_CTAB_BLOCK","V3K_END_CTAB_BLOCK","V3K_BEGIN_COUNTS_LINE","V3K_COUNTS_LINE_ENDING","V3K_BEGIN_ATOM_BLOCK","V3K_END_ATOM_BLOCK","V3K_BEGIN_BOND_BLOCK","V3K_END_BOND_BLOCK","V3K_BOND_CONFIG","V3K_BEGIN_DATA_LINE","V3K_END","PRECISION_FACTOR","DEOXYRIBOSE","polymerType","symbol","RIBOSE","PHOSPHATE","OXYGEN","HYDROGEN","getMolGraph","dict","libKey","NucleotideRole","NOTATION","ALPHABET","TAGS","MonomerMap","Map","constructor","entries","super","MolfileWithMap","molfile","monomers","this","createEmpty","RegExp","CandidateType","name","alphabet","cutoff","Alphabets","fasta","peptide","Set","dna","rna","HelmTypes","helmTypeToPolymerType","helmType","BASE","SUGAR","LINKER","NUCLEOTIDE","AA","CHEM","BLOB","console","warn","monomerSeqToMolfile","monomerSeq","monomersDict","roles","length","triplesMode","atomCount","bondCount","needsCapping","monomerCount","lastMonomerGraph","lastPhosphateGraph","i","seqMonomer","Error","biotype","atoms","x","bonds","bondTypes","meta","rNodes","terminalR2Atom","toLowerCase","sugar","DNA","phosphate","getResultingAtomBondCounts","molfileAtomBlock","Array","molfileBondBlock","addMonomerToMolblock","addAminoAcidToMolblock","addNucleotideToMolblock","v","nodeShift","bondShift","backbonePositionShift","fill","branchPositionShift","backboneAttachNode","branchAttachNode","flipFactor","LC","seqLength","Math","ceil","steabsCollection","lastMonomerCappingAtom","nAtoms","addAtoms","getAtoms","N","hasTrailingP","n","sugarSm","baseSm","sugarG","baseG","prevPhosG","seqStartIdx","prevAtomFirst","prevBondFirst","addBackboneMonomerToMolblock","stereoAtoms","forEach","push","prevPhosKey","aList","a","bList","b","set","sugarAtomFirst","sugarBondFirst","sAList","sBList","baseAtomFirst","baseBondFirst","addBranchMonomerToMolblock","bAList","bBList","lastPhosKey","lastPhosSm","lastPhosG","trailAtomFirst","trailBondFirst","tAList","tBList","runTriplesAssembly","monomer","mAtomFirst","mBondFirst","mAtomCount","mAtomList","maI","mBondCount","mBondList","mbI","cappingAtomType","atomIdx","keepPrecision","firstAtom","secondAtom","capResultingMolblock","molfileCountsLine","result","join","collection","rowsArray","newCollectionRow","updatedRow","getCollectionBlock","j","atomTypes","y","kwargs","fillAtomLines","fillBondLines","bondIdx","terminalNodes","fillChainExtendingBond","branchShift","updateBranchVariables","atomPairs","backboneShift","updateChainExtendingVariables","nucleobase","fillBranchAtomLines","branchMonomer","fillBackboneToBranchBond","bondCfg","bondConfiguration","has","orientation","get","round","PT","RNA","FASTA","SEPARATOR","HELM","BILN","onmessage","event","seqList","rolesList","start","end","data","resMolList","molfileWarningList","rowI","seq","undefined","err","msg","message","toString","postMessage","molfiles","warnings"],"sourceRoot":""}
1
+ {"version":3,"file":"455.js","mappings":"2BAAO,MAAMA,EAAqB,CAE9BC,cAAe,EACfC,aAAc,SACdC,WAAY,MAEZC,iBAAkB,GAClBC,cAAe,EACfC,sBAAuB,uCACvBC,uBAAwB,4CACxBC,qBAAsB,sBACtBC,mBAAoB,oBACpBC,sBAAuB,iBACvBC,uBAAwB,WACxBC,qBAAsB,sBACtBC,mBAAoB,oBACpBC,qBAAsB,sBACtBC,mBAAoB,oBACpBC,gBAAiB,QACjBC,oBAAqB,UACrBC,QAAS,SACTC,iBAAkB,IAElBC,YAAa,CAAEC,YAAa,MAA8BC,OAAQ,KAClEC,OAAQ,CAAEF,YAAa,MAA8BC,OAAQ,KAC7DE,UAAW,CAAEH,YAAa,MAA8BC,OAAQ,KAChEG,OAAQ,IACRC,SAAU,KC3BP,SAASC,EAAYC,EAAMC,GAC9B,OAAOD,EAAKC,EAAOR,eAAeQ,EAAOP,OAC7C,CAiBO,IAAIQ,ECjBAC,EAQAC,EAQAC,GDEX,SAAWH,GACPA,EAAeA,EAAsB,MAAI,GAAK,QAC9CA,EAAeA,EAAqB,KAAI,GAAK,OAC7CA,EAAeA,EAA0B,UAAI,GAAK,YAClDA,EAAeA,EAA4B,YAAI,GAAK,cACpDA,EAAeA,EAA4B,YAAI,GAAK,aACvD,CAND,CAMGA,IAAmBA,EAAiB,CAAC,IACjC,MAAMI,UAAmBC,IAC5B,WAAAC,CAAYC,GACRC,MAAMD,EACV,EAGG,MAAME,EACT,WAAAH,CAAYI,EAASC,GACjBC,KAAKF,QAAUA,EACfE,KAAKD,SAAWA,CACpB,CACA,kBAAOE,GAAgB,OAAO,IAAIJ,EAAe,GAAI,IAAIL,EAAW,MAAQ,EEK5C,IAAIU,OAAO,oBAA0E,KCdlH,MAAMC,EACT,WAAAT,CAAYU,EAAMC,EAAUC,GACxBN,K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,EAAW,MAAEqM,EAAK,IAAEC,GAAQJ,EAAMK,KAChFC,EAAa,IAAI5H,MAAM0H,EAAMD,GAC7BI,EAAqB,IAAI7H,MAAM,GACrC,IAAK,IAAI8H,EAAOL,EAAOK,EAAOJ,IAAOI,EACjC,IACI,MAAMC,EAAMR,EAAQO,GACdzJ,EAAQmJ,EAAYA,EAAUM,QAAQE,EAC5CJ,EAAWE,EAAOL,GAASvJ,EAAoB6J,EAAK3J,EAActB,EAAU1B,EAAaiD,EAC7F,CACA,MAAO4J,GACH,MACMC,EAAM,8BAA8BJ,MAD3BG,aAAejJ,MAAQiJ,EAAIE,QAAUF,EAAIG,cAExDP,EAAmBtF,KAAK2F,EAC5B,CAEJG,YAAY,CAAEC,SAAUV,EAAYW,SAAUV,K","sources":["webpack://bio/./node_modules/@datagrok-libraries/bio/src/monomer-works/consts.js","webpack://bio/./node_modules/@datagrok-libraries/bio/src/monomer-works/types.js","webpack://bio/./node_modules/@datagrok-libraries/bio/src/utils/macromolecule/consts.js","webpack://bio/./node_modules/@datagrok-libraries/bio/src/utils/const.js","webpack://bio/./node_modules/@datagrok-libraries/bio/src/utils/macromolecule/types.js","webpack://bio/./node_modules/@datagrok-libraries/js-draw-lite/src/types/org.js","webpack://bio/./node_modules/@datagrok-libraries/bio/src/monomer-works/monomer-works.js","webpack://bio/./node_modules/@datagrok-libraries/bio/src/monomer-works/to-atomic-level-utils.js","webpack://bio/./node_modules/@datagrok-libraries/bio/src/monomer-works/seq-to-molfile-worker.js"],"sourcesContent":["export const monomerWorksConsts = {\n // constants for parsing molfile V2000\n V2K_RGP_SHIFT: 8,\n V2K_RGP_LINE: 'M RGP',\n V2K_A_LINE: 'A ',\n // constants for parsing/reconstruction of molfile V3000\n V3K_COUNTS_SHIFT: 14,\n V3K_IDX_SHIFT: 7,\n V3K_HEADER_FIRST_LINE: '\\nDatagrok macromolecule handler\\n\\n',\n V3K_HEADER_SECOND_LINE: ' 0 0 0 0 0 0 999 V3000\\n',\n V3K_BEGIN_CTAB_BLOCK: 'M V30 BEGIN CTAB\\n',\n V3K_END_CTAB_BLOCK: 'M V30 END CTAB\\n',\n V3K_BEGIN_COUNTS_LINE: 'M V30 COUNTS ',\n V3K_COUNTS_LINE_ENDING: ' 0 0 0\\n',\n V3K_BEGIN_ATOM_BLOCK: 'M V30 BEGIN ATOM\\n',\n V3K_END_ATOM_BLOCK: 'M V30 END ATOM\\n',\n V3K_BEGIN_BOND_BLOCK: 'M V30 BEGIN BOND\\n',\n V3K_END_BOND_BLOCK: 'M V30 END BOND\\n',\n V3K_BOND_CONFIG: ' CFG=',\n V3K_BEGIN_DATA_LINE: 'M V30 ',\n V3K_END: 'M END',\n PRECISION_FACTOR: 10000, // HELMCoreLibrary has 4 significant digits after decimal point in atom coordinates\n // symbols for the corresponding monomers in HELM library\n DEOXYRIBOSE: { polymerType: \"RNA\" /* PolymerTypes.RNA */, symbol: 'd' },\n RIBOSE: { polymerType: \"RNA\" /* PolymerTypes.RNA */, symbol: 'r' },\n PHOSPHATE: { polymerType: \"RNA\" /* PolymerTypes.RNA */, symbol: 'p' },\n OXYGEN: 'O',\n HYDROGEN: 'H',\n};\n//# sourceMappingURL=consts.js.map","export function getMolGraph(dict, libKey) {\n return dict[libKey.polymerType]?.[libKey.symbol];\n}\nexport function hasMolGraph(dict, libKey) {\n return !!dict[libKey.polymerType]?.[libKey.symbol];\n}\nexport function setMolGraph(dict, libKey, value) {\n let pt = dict[libKey.polymerType];\n if (!pt)\n pt = dict[libKey.polymerType] = {};\n pt[libKey.symbol] = value;\n}\n/** Role of an entry in a HELM RNA splitted sequence.\n * SUGAR/BASE/PHOSPHATE are the standard triple positions.\n * TERMINAL_5P marks a 5'-end terminal modifier (e.g. Chol) — a monomer\n * with R2 only that takes the place of the leading sugar.\n * TERMINAL_3P marks a 3'-end terminal modifier (e.g. GalNAc) — a monomer\n * with R1 only that takes the place of the trailing phosphate. The OH cap\n * MUST be omitted when a TERMINAL_3P is present. */\nexport var NucleotideRole;\n(function (NucleotideRole) {\n NucleotideRole[NucleotideRole[\"SUGAR\"] = 0] = \"SUGAR\";\n NucleotideRole[NucleotideRole[\"BASE\"] = 1] = \"BASE\";\n NucleotideRole[NucleotideRole[\"PHOSPHATE\"] = 2] = \"PHOSPHATE\";\n NucleotideRole[NucleotideRole[\"TERMINAL_5P\"] = 3] = \"TERMINAL_5P\";\n NucleotideRole[NucleotideRole[\"TERMINAL_3P\"] = 4] = \"TERMINAL_3P\";\n})(NucleotideRole || (NucleotideRole = {}));\nexport class MonomerMap extends Map {\n constructor(entries) {\n super(entries);\n }\n}\n/** @property monomers key - helm seq position, */\nexport class MolfileWithMap {\n constructor(molfile, monomers) {\n this.molfile = molfile;\n this.monomers = monomers;\n }\n static createEmpty() { return new MolfileWithMap('', new MonomerMap(null)); }\n}\n//# sourceMappingURL=types.js.map","import { CandidateType } from './types';\n/** enum type to simplify setting \"user-friendly\" notation if necessary */\nexport var NOTATION;\n(function (NOTATION) {\n NOTATION[\"FASTA\"] = \"fasta\";\n NOTATION[\"SEPARATOR\"] = \"separator\";\n NOTATION[\"HELM\"] = \"helm\";\n /* Requires notation handler */ NOTATION[\"CUSTOM\"] = \"custom\";\n /* Requires notation handler */ NOTATION[\"BILN\"] = \"biln\";\n})(NOTATION || (NOTATION = {}));\nexport var ALPHABET;\n(function (ALPHABET) {\n ALPHABET[\"DNA\"] = \"DNA\";\n ALPHABET[\"RNA\"] = \"RNA\";\n ALPHABET[\"PT\"] = \"PT\";\n /** Unknown */\n ALPHABET[\"UN\"] = \"UN\";\n})(ALPHABET || (ALPHABET = {}));\nexport var TAGS;\n(function (TAGS) {\n TAGS[\"aligned\"] = \"aligned\";\n TAGS[\"alphabet\"] = \"alphabet\";\n TAGS[\"alphabetSize\"] = \".alphabetSize\";\n TAGS[\"alphabetIsMultichar\"] = \".alphabetIsMultichar\";\n TAGS[\"separator\"] = \"separator\";\n TAGS[\"isHelmCompatible\"] = \".isHelmCompatible\";\n TAGS[\"positionNames\"] = \".positionNames\";\n TAGS[\"positionLabels\"] = \".positionLabels\";\n TAGS[\"regions\"] = \".regions\";\n TAGS[\"positionShift\"] = \".positionShift\";\n TAGS[\"selectedPosition\"] = \".selectedPosition\";\n TAGS[\"polymerTypeColumnName\"] = \".polymerTypeColumnName\";\n TAGS[\"annotations\"] = \".annotations\";\n TAGS[\"numberingScheme\"] = \".numberingScheme\";\n TAGS[\"annotationColumnName\"] = \".annotationColumnName\";\n})(TAGS || (TAGS = {}));\nexport { TAGS as BioTags };\nexport const positionSeparator = ', ';\nexport const monomerRe = /(?:\\[([A-Za-z0-9_\\-,()]+)\\])|([A-Za-z\\-])/g;\nexport const helmRe = /(PEPTIDE1|DNA1|RNA1)\\{([^}]+)}/g;\nexport const helmPp1Re = /\\[([^\\[\\]]+)]/g;\nexport const Alphabets = new class {\n constructor() {\n this.fasta = {\n peptide: new Set([\n 'G', 'L', 'Y', 'S', 'E', 'Q', 'D', 'N', 'F', 'A',\n 'K', 'R', 'H', 'C', 'V', 'P', 'W', 'I', 'M', 'T',\n ]),\n dna: new Set(['A', 'C', 'G', 'T']),\n rna: new Set(['A', 'C', 'G', 'U']),\n };\n }\n}();\nexport const candidateAlphabets = [\n new CandidateType(ALPHABET.PT, Alphabets.fasta.peptide, 0.50),\n new CandidateType(ALPHABET.DNA, Alphabets.fasta.dna, 0.55),\n new CandidateType(ALPHABET.RNA, Alphabets.fasta.rna, 0.55),\n];\n/** Canonical gap symbol */\nexport const GAP_SYMBOL = '';\nexport const GapOriginals = {\n [NOTATION.FASTA]: '-',\n [NOTATION.SEPARATOR]: '',\n [NOTATION.HELM]: '*',\n [NOTATION.BILN]: '',\n};\nexport const MONOMER_MOTIF_SPLITTER = ' , ';\n/** Tag on Monomer columns storing the nqName of a function that returns an IMonomerCanonicalizer.\n * The `.%` prefix ensures this tag is persisted with projects. */\nexport const MONOMER_CANONICALIZER_FUNC_TAG = '.%monomer-canonicalizer-func';\n/** Column temp key for the cached IMonomerCanonicalizer instance */\nexport const MONOMER_CANONICALIZER_TEMP = 'monomer-canonicalizer';\nexport const NOTATION_PROVIDER_CONSTRUCTOR_ROLE = 'notationProviderConstructor';\n//# sourceMappingURL=consts.js.map","// core fields of HELM library object used in toAtomicLevel function\nexport const HELM_CORE_FIELDS = [\n \"symbol\" /* HELM_FIELDS.SYMBOL */,\n \"molfile\" /* HELM_FIELDS.MOLFILE */,\n \"rgroups\" /* HELM_FIELDS.RGROUPS */,\n \"name\" /* HELM_FIELDS.NAME */,\n // HELM_FIELDS.MONOMER_TYPE, // add if terminal monomers for PEPTIDEs to be\n // supported\n];\nexport const SDF_MONOMER_NAME = 'MonomerName';\n// todo: ideally, keys should be expressed via constants\nexport const jsonSdfMonomerLibDict = {\n 'monomerType': null, // -> Backbone\n 'smiles': null,\n 'name': 'Name',\n 'author': null,\n 'molfile': 'molecule',\n 'naturalAnalog': 'MonomerNaturalAnalogCode',\n 'rgroups': 'MonomerCaps',\n 'createDate': null,\n 'id': null,\n 'polymerType': 'MonomerType',\n 'symbol': 'MonomerName'\n};\nexport const DUMMY_MONOMER = {\n 'monomerType': 'Backbone',\n 'smiles': '',\n 'name': '',\n 'author': 'Datagrok',\n 'molfile': '',\n 'naturalAnalog': '',\n 'rgroups': [],\n 'createDate': null,\n 'id': 0,\n 'polymerType': 'PEPTIDE',\n 'symbol': ''\n};\n// range of hex nubers used in PepSea library to endode monomers\nexport const MONOMER_ENCODE_MIN = 0x100;\nexport const MONOMER_ENCODE_MAX = 0x40A;\nexport const RIBOSE_SYMBOL = 'r';\nexport const DEOXYRIBOSE_SYMBOL = 'd';\nexport const PHOSPHATE_SYMBOL = 'p';\nexport const HELM_WRAPPERS_REGEXP = new RegExp(`[${RIBOSE_SYMBOL}${DEOXYRIBOSE_SYMBOL}]\\\\((\\\\w)\\\\)${PHOSPHATE_SYMBOL}?`, 'g');\n//# sourceMappingURL=const.js.map","import { NOTATION_PROVIDER_CONSTRUCTOR_ROLE } from './consts';\nexport class NotationProviderBase {\n /** Name of the custom notation */\n static get notationName() {\n return 'Custom';\n }\n ;\n /** flag to let bio know if this provider implements method for converting helm to it */\n static get implementsFromHelm() {\n return false;\n }\n ;\n /** Method for converting HELM to this notation */\n static convertFromHelm(helm, options) {\n throw new Error(`Method convertFromHelm not implemented for this notation provider`);\n }\n ;\n static async getProviderConstructors() {\n // this is terrible, I know, but otherwise this gets put in webworkers and fails due to DG resolution)))\n // @ts-ignore\n if (window?.DG) {\n // @ts-ignore\n const constFuncs = window.DG.Func.find({ meta: { role: NOTATION_PROVIDER_CONSTRUCTOR_ROLE } });\n return Promise.all(constFuncs.map((f) => f.apply({})));\n }\n return [];\n }\n}\n/** Alphabet candidate type */\nexport class CandidateType {\n constructor(name, alphabet, cutoff) {\n this.name = name;\n this.alphabet = alphabet;\n this.cutoff = cutoff;\n }\n}\n/** Alphabet candidate similarity type */\nexport class CandidateSimType extends CandidateType {\n constructor(candidate, freq, similarity) {\n super(candidate.name, candidate.alphabet, candidate.cutoff);\n this.freq = freq;\n this.similarity = similarity;\n }\n}\n//# sourceMappingURL=types.js.map","export var HelmTypes;\n(function (HelmTypes) {\n HelmTypes[\"BASE\"] = \"HELM_BASE\";\n HelmTypes[\"SUGAR\"] = \"HELM_SUGAR\";\n HelmTypes[\"LINKER\"] = \"HELM_LINKER\";\n HelmTypes[\"AA\"] = \"HELM_AA\";\n HelmTypes[\"CHEM\"] = \"HELM_CHEM\";\n HelmTypes[\"BLOB\"] = \"HELM_BLOB\";\n HelmTypes[\"NUCLEOTIDE\"] = \"HELM_NUCLETIDE\";\n})(HelmTypes || (HelmTypes = {}));\n//# sourceMappingURL=org.js.map","import { HelmTypes } from '../helm/consts';\nexport class MonomerWorks {\n //private molfileConverter: IMolfileConverter;\n constructor(monomerLib /*, molfileConverter: IMolfileConverter*/) {\n this.monomerLib = monomerLib;\n //this.molfileConverter = molfileConverter;\n }\n //types according to Monomer possible\n getCappedRotatedMonomer(monomerType, monomerName) {\n // TODO: Check type of monomerType arg\n const monomer = this.monomerLib.getMonomer(monomerType, monomerName);\n if (monomer)\n return monomer.molfile; //TODO cap\n return null;\n }\n}\nexport function helmTypeToPolymerType(helmType) {\n let polymerType = undefined;\n switch (helmType) {\n case HelmTypes.BASE:\n case HelmTypes.SUGAR: // r - ribose, d - deoxyribose\n case HelmTypes.LINKER: // p - phosphate\n case HelmTypes.NUCLEOTIDE:\n // @ts-ignore\n case 'nucleotide':\n polymerType = \"RNA\" /* PolymerTypes.RNA */;\n break;\n case HelmTypes.AA:\n polymerType = \"PEPTIDE\" /* PolymerTypes.PEPTIDE */;\n break;\n case HelmTypes.CHEM:\n polymerType = \"CHEM\" /* PolymerTypes.CHEM */;\n break;\n case HelmTypes.BLOB:\n polymerType = \"BLOB\" /* PolymerTypes.BLOB */;\n break;\n default:\n polymerType = \"PEPTIDE\" /* PolymerTypes.PEPTIDE */;\n console.warn(`Unexpected HelmType '${helmType}'`);\n }\n return polymerType;\n}\n//# sourceMappingURL=monomer-works.js.map","/* eslint-disable max-len */\nimport { monomerWorksConsts as C } from './consts';\nimport { getMolGraph, MolfileWithMap, MonomerMap, NucleotideRole } from './types';\nimport { HELM_CORE_FIELDS, } from '../utils/const';\nimport { ALPHABET, GAP_SYMBOL } from '../utils/macromolecule/consts';\nimport { helmTypeToPolymerType } from './monomer-works';\n/** Get a mapping of peptide symbols to HELM monomer library objects with selected fields.\n * @param {IMonomerLib} monomerLib - Monomer library\n * @param {HELM_POLYMER_TYPE} polymerType - Polymer type\n * @param {ALPHABET} alphabet - Alphabet of the column\n * @return {Map<string, any>} - Mapping of peptide symbols to HELM monomer library objects with selected fields*/\nexport function getFormattedMonomerLib(monomerLib, polymerType, alphabet) {\n const map = new Map();\n for (const monomerSymbol of monomerLib.getMonomerSymbolsByType(polymerType)) {\n const it = monomerLib.getMonomer(polymerType, monomerSymbol);\n if (\n // RNA: all branch monomers (bases) and all backbone monomers (sugars +\n // phosphates, including modified ones). Modifications are looked up by\n // symbol at assembly time, so they MUST be present in the formatted lib.\n polymerType === \"RNA\" /* HELM_POLYMER_TYPE.RNA */ || (polymerType === \"PEPTIDE\" /* HELM_POLYMER_TYPE.PEPTIDE */ &&\n it[\"monomerType\" /* HELM_FIELDS.MONOMER_TYPE */] !== \"Branch\" /* HELM_MONOMER_TYPE.BRANCH */)) {\n const monomerObject = {};\n HELM_CORE_FIELDS.forEach((field) => {\n //@ts-ignore\n monomerObject[field] = it[field];\n });\n map.set(monomerSymbol, monomerObject);\n }\n }\n return map;\n}\n/** Translate a sequence of monomer symbols into Molfile V3000\n * @param {ISeqMonomer[]} monomerSeq - Sequence of monomer symbols (canonical)\n * @param {MonomerMolGraphMap} monomersDict - Mapping of monomer symbols to MolGraph objects\n * @param {ALPHABET} alphabet - Alphabet of the column\n * @param {PolymerType} polymerType - Polymer type\n * @param {Array} roles - Optional per-position NucleotideRole tags. When set, RNA assembly\n * uses per-position sugars/phosphates from monomerSeq directly (HELM triples mode).\n * @return {MolfileWithMap} - Molfile V3000 + per-position monomer index map */\nexport function monomerSeqToMolfile(monomerSeq, monomersDict, alphabet, polymerType, roles) {\n if (monomerSeq.length === 0) {\n // throw new Error('monomerSeq is empty');\n return MolfileWithMap.createEmpty();\n }\n // Triples mode is on only when the caller flagged the row with roles\n // (built and validated by `buildRolesForHelmRna` in to-atomic-level.ts).\n // The roles array carries the per-position semantics — including\n // TERMINAL_5P / TERMINAL_3P for non-canonical chain ends — so we don't\n // re-validate the length here.\n const triplesMode = polymerType === \"RNA\" /* HELM_POLYMER_TYPE.RNA */ && !!roles &&\n roles.length === monomerSeq.length;\n // define atom and bond counts, taking into account the bond type\n const { atomCount, bondCount, needsCapping } = getResultingAtomBondCounts(monomerSeq, monomersDict, alphabet, polymerType, triplesMode, roles);\n // create arrays to store lines of the resulting molfile\n const molfileAtomBlock = new Array(atomCount);\n const molfileBondBlock = new Array(bondCount);\n let addMonomerToMolblock;\n let sugar = null;\n let phosphate = null;\n if (polymerType === \"PEPTIDE\" /* HELM_POLYMER_TYPE.PEPTIDE */)\n addMonomerToMolblock = addAminoAcidToMolblock;\n else { // nucleotides\n addMonomerToMolblock = addNucleotideToMolblock;\n // Default sugar/phosphate are only consulted in bases-only mode. In\n // triples mode, every nucleotide carries its own.\n if (!triplesMode) {\n sugar = (alphabet === ALPHABET.DNA) ? getMolGraph(monomersDict, C.DEOXYRIBOSE) : getMolGraph(monomersDict, C.RIBOSE);\n phosphate = getMolGraph(monomersDict, C.PHOSPHATE);\n }\n }\n const v = {\n i: 0,\n nodeShift: 0,\n bondShift: 0,\n backbonePositionShift: new Array(2).fill(0),\n branchPositionShift: new Array(2).fill(0),\n backboneAttachNode: 0,\n branchAttachNode: 0,\n flipFactor: 1,\n };\n const LC = {\n sugar: sugar,\n phosphate: phosphate,\n // In triples mode, the \"logical\" sequence length is the nucleotide count.\n seqLength: triplesMode ? Math.ceil(monomerSeq.length / 3) : monomerSeq.length,\n atomCount: atomCount,\n bondCount: bondCount,\n };\n const monomers = new MonomerMap();\n const steabsCollection = [];\n let nAtoms = 0;\n let lastMonomerCappingAtom = undefined;\n if (triplesMode) {\n runTriplesAssembly(monomerSeq, roles, monomersDict, molfileAtomBlock, molfileBondBlock, v, LC, monomers, steabsCollection, (a) => { nAtoms += a; }, () => nAtoms);\n }\n else {\n for (v.i = 0; v.i < LC.seqLength; ++v.i) {\n const seqMonomer = monomerSeq[v.i];\n if (seqMonomer.symbol === GAP_SYMBOL)\n continue;\n const monomer = getMolGraph(monomersDict, { symbol: seqMonomer.symbol, polymerType: helmTypeToPolymerType(seqMonomer.biotype) });\n lastMonomerCappingAtom = monomer.terminalR2Atom;\n const mAtomFirst = v.nodeShift;\n const mBondFirst = v.bondShift;\n addMonomerToMolblock(monomer, molfileAtomBlock, molfileBondBlock, v, LC);\n //adding stereo atoms to array for further STEABS block generation\n monomer.stereoAtoms?.forEach((i) => steabsCollection.push(i + nAtoms));\n nAtoms += monomer.atoms.x.length;\n const mAtomCount = v.nodeShift - mAtomFirst;\n const mAtomList = new Array(mAtomCount);\n for (let maI = 0; maI < mAtomCount; ++maI)\n mAtomList[maI] = mAtomFirst + maI;\n const mBondCount = v.bondShift - mBondFirst;\n const mBondList = new Array(mBondCount);\n for (let mbI = 0; mbI < mBondCount; ++mbI)\n mBondList[mbI] = mBondFirst + mbI;\n monomers.set(v.i, {\n biotype: seqMonomer.biotype,\n symbol: seqMonomer.symbol,\n atoms: mAtomList, bonds: mBondList\n });\n }\n }\n // if the last monomer needs to be capped, add the terminal OH to the resulting molfile\n if (needsCapping)\n capResultingMolblock(molfileAtomBlock, molfileBondBlock, v, LC, lastMonomerCappingAtom ?? C.OXYGEN);\n const molfileCountsLine = C.V3K_BEGIN_COUNTS_LINE + atomCount + ' ' + bondCount + C.V3K_COUNTS_LINE_ENDING;\n // todo: possible optimization may be achieved by replacing .join('') with +=\n // since counterintuitively joining an array into a new string is reportedly\n // slower than using += as below\n let result = '';\n result += C.V3K_HEADER_FIRST_LINE;\n result += C.V3K_HEADER_SECOND_LINE;\n result += C.V3K_BEGIN_CTAB_BLOCK;\n result += molfileCountsLine;\n result += C.V3K_BEGIN_ATOM_BLOCK;\n result += molfileAtomBlock.join('');\n result += C.V3K_END_ATOM_BLOCK;\n result += C.V3K_BEGIN_BOND_BLOCK;\n result += molfileBondBlock.join('');\n result += C.V3K_END_BOND_BLOCK;\n if (steabsCollection.length > 0)\n result += getCollectionBlock(steabsCollection);\n result += C.V3K_END_CTAB_BLOCK;\n result += C.V3K_END;\n // return molfileParts.join('');\n return { molfile: result, monomers: monomers };\n}\nfunction getCollectionBlock(collection) {\n //one row in STEABS block can be no longer than 80 symbols\n //maxSymbols = 80 symbols minus ' -\\n' (4 symbols)\n const maxSymbols = 76;\n const rowsArray = [];\n let newCollectionRow = `M V30 MDLV30/STEABS ATOMS=(${collection.length}`;\n for (let i = 0; i < collection.length; i++) {\n const updatedRow = `${newCollectionRow} ${collection[i]}`;\n if (updatedRow.length > maxSymbols) {\n rowsArray.push(`${newCollectionRow} -\\n`);\n newCollectionRow = `M V30 ${collection[i]}`;\n }\n else\n newCollectionRow = updatedRow;\n //in case last atom was added - close the block\n if (i === collection.length - 1)\n rowsArray.push(`${newCollectionRow})\\n`);\n }\n return `M V30 BEGIN COLLECTION\\n${rowsArray.join('')}M V30 END COLLECTION\\n`;\n}\n/** Cap the resulting (after sewing up all the monomers) molfile with 'O'\n * @param {string[]} molfileAtomBlock - Array of lines of the resulting molfile atom block\n * @param {string[]} molfileBondBlock - Array of lines of the resulting molfile bond block\n * @param {LoopVariables} v - Loop variables\n * @param {LoopConstants} LC - Loop constants*/\nfunction capResultingMolblock(molfileAtomBlock, molfileBondBlock, v, LC, cappingAtomType = C.OXYGEN) {\n // add terminal oxygen\n const atomIdx = v.nodeShift + 1;\n molfileAtomBlock[LC.atomCount] = C.V3K_BEGIN_DATA_LINE + atomIdx + ' ' +\n (cappingAtomType ?? C.OXYGEN) + ' ' + keepPrecision(v.backbonePositionShift[0]) + ' ' +\n v.flipFactor * keepPrecision(v.backbonePositionShift[1]) + ' ' + '0.000000 0' + '\\n';\n // add terminal bond\n const firstAtom = v.backboneAttachNode;\n const secondAtom = atomIdx;\n molfileBondBlock[LC.bondCount] = C.V3K_BEGIN_DATA_LINE + v.bondShift + ' ' +\n 1 + ' ' + firstAtom + ' ' + secondAtom + '\\n';\n}\nfunction addAminoAcidToMolblock(monomer, molfileAtomBlock, molfileBondBlock, v) {\n v.flipFactor = (-1) ** (v.i % 2); // to flip every even monomer over OX\n addBackboneMonomerToMolblock(monomer, molfileAtomBlock, molfileBondBlock, v);\n}\nfunction addBackboneMonomerToMolblock(monomer, molfileAtomBlock, molfileBondBlock, v) {\n // todo: remove these comments to the docstrings of the corr. functions\n // construnct the lines of V3K molfile atom block\n fillAtomLines(monomer, molfileAtomBlock, v);\n // construct the lines of V3K molfile bond block\n fillBondLines(monomer, molfileBondBlock, v);\n // peptide bond\n fillChainExtendingBond(monomer, molfileBondBlock, v);\n // update branch variables if necessary\n if (monomer.meta.branchShift !== null && monomer.meta.terminalNodes.length > 2)\n updateBranchVariables(monomer, v);\n // update loop variables\n updateChainExtendingVariables(monomer, v);\n}\nfunction addNucleotideToMolblock(nucleobase, molfileAtomBlock, molfileBondBlock, v, LC) {\n // construnct the lines of V3K molfile atom block corresponding to phosphate\n // and sugar\n if (v.i === 0)\n addBackboneMonomerToMolblock(LC.sugar, molfileAtomBlock, molfileBondBlock, v);\n else {\n for (const monomer of [LC.phosphate, LC.sugar])\n addBackboneMonomerToMolblock(monomer, molfileAtomBlock, molfileBondBlock, v);\n }\n addBranchMonomerToMolblock(nucleobase, molfileAtomBlock, molfileBondBlock, v);\n}\nfunction addBranchMonomerToMolblock(monomer, molfileAtomBlock, molfileBondBlock, v) {\n fillBranchAtomLines(monomer, molfileAtomBlock, v);\n fillBondLines(monomer, molfileBondBlock, v);\n fillBackboneToBranchBond(monomer, molfileBondBlock, v);\n // C-N bond\n const bondIdx = v.bondShift;\n const firstAtom = v.branchAttachNode;\n const secondAtom = monomer.meta.terminalNodes[0] + v.nodeShift;\n molfileBondBlock[bondIdx - 1] = C.V3K_BEGIN_DATA_LINE + bondIdx + ' ' +\n 1 + ' ' + firstAtom + ' ' + secondAtom + '\\n';\n // update loop variables\n v.bondShift += monomer.bonds.atomPairs.length + 1;\n v.nodeShift += monomer.atoms.atomTypes.length;\n}\nfunction updateChainExtendingVariables(monomer, v) {\n v.backboneAttachNode = v.nodeShift + monomer.meta.terminalNodes[1];\n v.bondShift += monomer.bonds.atomPairs.length + 1;\n v.nodeShift += monomer.atoms.atomTypes.length;\n v.backbonePositionShift[0] += monomer.meta.backboneShift?.[0] ?? 0; // todo: non-null check\n v.backbonePositionShift[1] += v.flipFactor * (monomer.meta.backboneShift?.[1] ?? 0);\n}\nfunction updateBranchVariables(monomer, v) {\n v.branchAttachNode = v.nodeShift + monomer.meta.terminalNodes[2];\n for (let i = 0; i < 2; ++i)\n v.branchPositionShift[i] = v.backbonePositionShift[i] + monomer.meta.branchShift[i];\n}\nfunction fillAtomLines(monomer, molfileAtomBlock, v) {\n for (let j = 0; j < monomer.atoms.atomTypes.length; ++j) {\n const atomIdx = v.nodeShift + j + 1;\n molfileAtomBlock[v.nodeShift + j] = C.V3K_BEGIN_DATA_LINE + atomIdx + ' ' +\n monomer.atoms.atomTypes[j] + ' ' +\n keepPrecision(v.backbonePositionShift[0] + monomer.atoms.x[j]) + ' ' +\n keepPrecision(v.backbonePositionShift[1] + v.flipFactor * monomer.atoms.y[j]) +\n ' ' + monomer.atoms.kwargs[j];\n }\n}\n// todo: remove as quickfix\nfunction fillBranchAtomLines(monomer, molfileAtomBlock, v) {\n for (let j = 0; j < monomer.atoms.atomTypes.length; ++j) {\n const atomIdx = v.nodeShift + j + 1;\n molfileAtomBlock[v.nodeShift + j] = C.V3K_BEGIN_DATA_LINE + atomIdx + ' ' +\n monomer.atoms.atomTypes[j] + ' ' +\n keepPrecision(v.branchPositionShift[0] + monomer.atoms.x[j]) + ' ' +\n keepPrecision(v.branchPositionShift[1] + v.flipFactor * monomer.atoms.y[j]) +\n ' ' + monomer.atoms.kwargs[j];\n }\n}\nfunction fillBondLines(monomer, molfileBondBlock, v) {\n // construct the lines of V3K molfile bond block\n for (let j = 0; j < monomer.bonds.atomPairs.length; ++j) {\n const bondIdx = v.bondShift + j + 1;\n const firstAtom = monomer.bonds.atomPairs[j][0] + v.nodeShift;\n const secondAtom = monomer.bonds.atomPairs[j][1] + v.nodeShift;\n let bondCfg = '';\n if (monomer.bonds.bondConfiguration.has(j)) {\n // flip orientation when necessary\n let orientation = monomer.bonds.bondConfiguration.get(j);\n if (v.flipFactor < 0)\n orientation = (orientation === 1) ? 3 : 1;\n bondCfg = ' CFG=' + orientation;\n }\n const kwargs = monomer.bonds.kwargs.has(j) ?\n ' ' + monomer.bonds.kwargs.get(j) : '';\n molfileBondBlock[v.bondShift + j] = C.V3K_BEGIN_DATA_LINE + bondIdx + ' ' +\n monomer.bonds.bondTypes[j] + ' ' +\n firstAtom + ' ' + secondAtom + bondCfg + kwargs + '\\n';\n }\n}\nfunction fillChainExtendingBond(monomer, molfileBondBlock, v) {\n if (v.backboneAttachNode !== 0) {\n const bondIdx = v.bondShift;\n const firstAtom = v.backboneAttachNode;\n const secondAtom = monomer.meta.terminalNodes[0] + v.nodeShift;\n molfileBondBlock[v.bondShift - 1] = C.V3K_BEGIN_DATA_LINE + bondIdx + ' ' +\n 1 + ' ' + firstAtom + ' ' + secondAtom + '\\n';\n }\n}\n// todo: remove\nfunction fillBackboneToBranchBond(branchMonomer, molfileBondBlock, v) {\n const bondIdx = v.bondShift;\n const firstAtom = v.branchAttachNode;\n const secondAtom = branchMonomer.meta.terminalNodes[0] + v.nodeShift;\n molfileBondBlock[bondIdx - 1] = C.V3K_BEGIN_DATA_LINE + bondIdx + ' ' +\n 1 + ' ' + firstAtom + ' ' + secondAtom + '\\n';\n}\n/** Compute the atom/bond counts for the resulting molfile, depending on the\n * type of polymer (peptide/nucleotide)\n * @param {ISeqMonomer[]} monomerSeq - the sequence of monomers\n * @param {MonomerMolGraphMap} monomersDict - the dictionary of monomers\n * @param {ALPHABET} alphabet - the alphabet of the monomers\n * @param {PolymerType} polymerType - the type of polymer\n * @param {boolean} triplesMode - true when monomerSeq is a flat list of HELM RNA triples\n * @param {Array} roles - per-position role tags (only meaningful when triplesMode is true)\n * @return {Object} the atom/bond counts plus needsCapping flag */\nfunction getResultingAtomBondCounts(monomerSeq, monomersDict, alphabet, polymerType, triplesMode, roles) {\n let atomCount = 0;\n let bondCount = 0;\n let monomerCount = 0;\n let needsCapping = true;\n let lastMonomerGraph = null;\n let lastPhosphateGraph = null;\n // sum up all the atoms/nodes provided by the sequence\n for (let i = 0; i < monomerSeq.length; ++i) {\n const seqMonomer = monomerSeq[i];\n if (seqMonomer.symbol === GAP_SYMBOL)\n continue; // Skip for gap/empty monomer in MSA\n if (seqMonomer.symbol == '*')\n throw new Error(`Gap canonical symbol is '', not '*`);\n lastMonomerGraph = getMolGraph(monomersDict, { symbol: seqMonomer.symbol, polymerType: helmTypeToPolymerType(seqMonomer.biotype) });\n atomCount += lastMonomerGraph.atoms.x.length;\n bondCount += lastMonomerGraph.bonds.bondTypes.length;\n monomerCount++;\n // In triples mode, every 3rd entry (index 2 mod 3) is a phosphate. Track\n // the LAST one — its atoms/bonds are dropped at the 3'-terminus.\n if (triplesMode && i % 3 === 2)\n lastPhosphateGraph = lastMonomerGraph;\n }\n // add extra values depending on the polymer type\n if (polymerType === \"PEPTIDE\" /* HELM_POLYMER_TYPE.PEPTIDE */) {\n // add the rightmost/terminating cap group 'OH' (i.e. 'O')\n atomCount += 1;\n // add chain-extending bonds (C-NH per each monomer pair and terminal C-OH)\n bondCount += monomerCount;\n // if the last monomer is something like NH2, which only has R1, there is no need to cap it\n // although, this should never happen, but hey... in other bits of code, there is a chunk that adds pseudo-R2 as hydrogen\n // we should also check, if the R2 of the last monomer is not hydrogen, that case should also be omitted\n if (monomerCount > 0) {\n if ((lastMonomerGraph?.meta?.rNodes?.length ?? 0) < 2 || lastMonomerGraph?.terminalR2Atom?.toLowerCase() === C.HYDROGEN.toLowerCase()) {\n needsCapping = false;\n atomCount -= 1; // remove the last atom (the terminal 'O')\n bondCount -= 1; // remove the last bond (the terminal C-OH)\n }\n }\n }\n else if (triplesMode) { // nucleotides — HELM triples (per-position sugar/base/phosphate)\n void lastPhosphateGraph; // kept for symmetry; trailing P is now retained when HELM wrote it\n // Per-monomer-loop already summed sugars + bases + phosphates for every\n // entry in monomerSeq (terminals included). Reservation: each backbone\n // emit (sugar / phosphate / terminal) reserves +1 bond slot for the\n // chain-extending bond, each branch (base) reserves +1 for its branch\n // bond. Total reservations = monomerCount.\n bondCount += monomerCount;\n // OH cap atom rides on the 3'-end. Skip it when HELM specified a\n // 3'-terminal modifier (e.g. GalNAc) that IS the chain end.\n const has3pTerm = !!roles && roles.length > 0 &&\n roles[roles.length - 1] === NucleotideRole.TERMINAL_3P;\n if (has3pTerm)\n needsCapping = false;\n else\n atomCount += 1; // OH cap atom (rides on trailing P or on last sugar's R2)\n }\n else { // nucleotides — bases-only legacy path with default sugar/phosphate\n const sugar = (alphabet === ALPHABET.DNA) ?\n getMolGraph(monomersDict, C.DEOXYRIBOSE) : getMolGraph(monomersDict, C.RIBOSE);\n const phosphate = getMolGraph(monomersDict, C.PHOSPHATE);\n // add phosphate per each pair of nucleobase symbols\n atomCount += (monomerSeq.length - 1) * phosphate.atoms.x.length;\n // add sugar per each nucleobase symbol\n atomCount += monomerSeq.length * sugar.atoms.x.length;\n // add the leftmost cap group 'OH' (i.e. 'O')\n atomCount += 1;\n // add bonds from phosphate monomers\n bondCount += (monomerSeq.length - 1) * phosphate.bonds.bondTypes.length;\n // add bonds from sugar monomers\n bondCount += monomerSeq.length * sugar.bonds.bondTypes.length;\n // exclude the first chain-extending bond O-P (absent, no 'leftmost' phosphate)\n bondCount -= 1;\n // add chain-extending and branch bonds (O-P, C-O and C-N per each nucleotide)\n bondCount += monomerSeq.length * 3;\n }\n return { atomCount, bondCount, needsCapping };\n}\n// Triples-mode RNA assembly. Iterates by NUCLEOTIDE over the row's \"core\"\n// positions (those tagged SUGAR/BASE/PHOSPHATE), and emits at most one\n// TERMINAL_5P at the head and one TERMINAL_3P at the tail.\n//\n// Layout permutations the function handles:\n// roles = [SUGAR, BASE, PHOSPHATE, ...] // standard RNA\n// roles = [..., SUGAR, BASE] // no trailing P\n// roles = [TERMINAL_5P, SUGAR, BASE, PHOSPHATE, ...] // 5' modifier\n// roles = [..., SUGAR, BASE, TERMINAL_3P] // 3' modifier (replaces last P)\n// roles = [TERMINAL_5P, ..., TERMINAL_3P] // both\n//\n// When a TERMINAL_3P is present the OH cap MUST be skipped (the last\n// monomer is the chain end, period); the caller takes responsibility for\n// needsCapping=false in `getResultingAtomBondCounts`.\nfunction runTriplesAssembly(monomerSeq, roles, monomersDict, molfileAtomBlock, molfileBondBlock, v, LC, monomers, steabsCollection, addAtoms, getAtoms) {\n const has5pTerm = roles.length > 0 && roles[0] === NucleotideRole.TERMINAL_5P;\n const has3pTerm = roles.length > 0 && roles[roles.length - 1] === NucleotideRole.TERMINAL_3P;\n const coreStart = has5pTerm ? 1 : 0;\n const coreEnd = has3pTerm ? roles.length - 1 : roles.length;\n const coreLen = coreEnd - coreStart;\n const N = Math.ceil(coreLen / 3); // nucleotide count in the core\n // coreLen === 3N → trailing P present. coreLen === 3N - 1 → no trailing P.\n const hasTrailingP = coreLen === 3 * N;\n // Helper: emit one monomer as a backbone unit and record its atom/bond\n // ranges in the per-row monomer map.\n const emitBackbone = (sm, mapKey) => {\n const mG = getMolGraph(monomersDict, { symbol: sm.symbol, polymerType: helmTypeToPolymerType(sm.biotype) });\n const aFirst = v.nodeShift;\n const bFirst = v.bondShift;\n addBackboneMonomerToMolblock(mG, molfileAtomBlock, molfileBondBlock, v);\n mG.stereoAtoms?.forEach((i) => steabsCollection.push(i + getAtoms()));\n addAtoms(mG.atoms.x.length);\n const aList = [];\n for (let a = aFirst; a < v.nodeShift; ++a)\n aList.push(a);\n const bList = [];\n for (let b = bFirst; b < v.bondShift; ++b)\n bList.push(b);\n monomers.set(mapKey, { biotype: sm.biotype, symbol: sm.symbol, atoms: aList, bonds: bList });\n };\n // 1. 5'-end terminal modifier (e.g. Chol).\n if (has5pTerm) {\n v.i = 0;\n emitBackbone(monomerSeq[0], 0);\n }\n // 2. Core triples loop: each iteration emits [prev-P (if n>=1)] + sugar + base.\n for (let n = 0; n < N; ++n) {\n v.i = n + (has5pTerm ? 1 : 0); // keep v.i monotone across emits\n const sugarSeqIdx = coreStart + 3 * n;\n const baseSeqIdx = sugarSeqIdx + 1;\n const sugarSm = monomerSeq[sugarSeqIdx];\n const baseSm = monomerSeq[baseSeqIdx];\n const sugarG = getMolGraph(monomersDict, { symbol: sugarSm.symbol, polymerType: helmTypeToPolymerType(sugarSm.biotype) });\n const baseG = getMolGraph(monomersDict, { symbol: baseSm.symbol, polymerType: helmTypeToPolymerType(baseSm.biotype) });\n // Inter-nucleotide phosphate sits at coreStart + 3*(n-1) + 2 for n >= 1.\n if (n >= 1) {\n const prevPhosKey = coreStart + 3 * (n - 1) + 2;\n emitBackbone(monomerSeq[prevPhosKey], prevPhosKey);\n }\n // Sugar (backbone)\n const sugarAtomFirst = v.nodeShift;\n const sugarBondFirst = v.bondShift;\n addBackboneMonomerToMolblock(sugarG, molfileAtomBlock, molfileBondBlock, v);\n sugarG.stereoAtoms?.forEach((i) => steabsCollection.push(i + getAtoms()));\n addAtoms(sugarG.atoms.x.length);\n const sAList = [];\n for (let a = sugarAtomFirst; a < v.nodeShift; ++a)\n sAList.push(a);\n const sBList = [];\n for (let b = sugarBondFirst; b < v.bondShift; ++b)\n sBList.push(b);\n monomers.set(sugarSeqIdx, {\n biotype: sugarSm.biotype, symbol: sugarSm.symbol,\n atoms: sAList, bonds: sBList,\n });\n // Base (branch)\n const baseAtomFirst = v.nodeShift;\n const baseBondFirst = v.bondShift;\n addBranchMonomerToMolblock(baseG, molfileAtomBlock, molfileBondBlock, v);\n baseG.stereoAtoms?.forEach((i) => steabsCollection.push(i + getAtoms()));\n addAtoms(baseG.atoms.x.length);\n const bAList = [];\n for (let a = baseAtomFirst; a < v.nodeShift; ++a)\n bAList.push(a);\n const bBList = [];\n for (let b = baseBondFirst; b < v.bondShift; ++b)\n bBList.push(b);\n monomers.set(baseSeqIdx, {\n biotype: baseSm.biotype, symbol: baseSm.symbol,\n atoms: bAList, bonds: bBList,\n });\n }\n // 3. Trailing phosphate (the LAST nucleotide's P) — only if HELM wrote\n // one AND there is no 3'-terminal modifier replacing it.\n if (hasTrailingP) {\n const lastPhosKey = coreStart + 3 * (N - 1) + 2;\n emitBackbone(monomerSeq[lastPhosKey], lastPhosKey);\n }\n // 4. 3'-end terminal modifier (e.g. GalNAc).\n if (has3pTerm) {\n v.i = N + (has5pTerm ? 1 : 0);\n emitBackbone(monomerSeq[roles.length - 1], roles.length - 1);\n }\n}\n/** Keep precision upon floating point operations over atom coordinates\n * @param {number}x - the floating point number\n * @return {number} - the floating point number with the same precision\n */\nexport function keepPrecision(x) {\n return Math.round(C.PRECISION_FACTOR * x) / C.PRECISION_FACTOR;\n}\n//# sourceMappingURL=to-atomic-level-utils.js.map","import { monomerSeqToMolfile } from './to-atomic-level-utils';\nonmessage = (event) => {\n const { seqList, rolesList, monomersDict, alphabet, polymerType, start, end } = event.data;\n const resMolList = new Array(end - start);\n const molfileWarningList = new Array(0);\n for (let rowI = start; rowI < end; ++rowI) {\n try {\n const seq = seqList[rowI];\n const roles = rolesList ? rolesList[rowI] : undefined;\n resMolList[rowI - start] = monomerSeqToMolfile(seq, monomersDict, alphabet, polymerType, roles);\n }\n catch (err) {\n const errMsg = err instanceof Error ? err.message : err.toString();\n const msg = `Cannot get molfile of row #${rowI}: ${errMsg}.`;\n molfileWarningList.push(msg);\n }\n }\n postMessage({ molfiles: resMolList, warnings: molfileWarningList });\n};\n//# sourceMappingURL=seq-to-molfile-worker.js.map"],"names":["monomerWorksConsts","V2K_RGP_SHIFT","V2K_RGP_LINE","V2K_A_LINE","V3K_COUNTS_SHIFT","V3K_IDX_SHIFT","V3K_HEADER_FIRST_LINE","V3K_HEADER_SECOND_LINE","V3K_BEGIN_CTAB_BLOCK","V3K_END_CTAB_BLOCK","V3K_BEGIN_COUNTS_LINE","V3K_COUNTS_LINE_ENDING","V3K_BEGIN_ATOM_BLOCK","V3K_END_ATOM_BLOCK","V3K_BEGIN_BOND_BLOCK","V3K_END_BOND_BLOCK","V3K_BOND_CONFIG","V3K_BEGIN_DATA_LINE","V3K_END","PRECISION_FACTOR","DEOXYRIBOSE","polymerType","symbol","RIBOSE","PHOSPHATE","OXYGEN","HYDROGEN","getMolGraph","dict","libKey","NucleotideRole","NOTATION","ALPHABET","TAGS","MonomerMap","Map","constructor","entries","super","MolfileWithMap","molfile","monomers","this","createEmpty","RegExp","CandidateType","name","alphabet","cutoff","Alphabets","fasta","peptide","Set","dna","rna","HelmTypes","helmTypeToPolymerType","helmType","BASE","SUGAR","LINKER","NUCLEOTIDE","AA","CHEM","BLOB","console","warn","monomerSeqToMolfile","monomerSeq","monomersDict","roles","length","triplesMode","atomCount","bondCount","needsCapping","monomerCount","lastMonomerGraph","lastPhosphateGraph","i","seqMonomer","Error","biotype","atoms","x","bonds","bondTypes","meta","rNodes","terminalR2Atom","toLowerCase","TERMINAL_3P","sugar","DNA","phosphate","getResultingAtomBondCounts","molfileAtomBlock","Array","molfileBondBlock","addMonomerToMolblock","addAminoAcidToMolblock","addNucleotideToMolblock","v","nodeShift","bondShift","backbonePositionShift","fill","branchPositionShift","backboneAttachNode","branchAttachNode","flipFactor","LC","seqLength","Math","ceil","steabsCollection","lastMonomerCappingAtom","nAtoms","addAtoms","getAtoms","has5pTerm","TERMINAL_5P","has3pTerm","coreStart","coreLen","N","hasTrailingP","emitBackbone","sm","mapKey","mG","aFirst","bFirst","addBackboneMonomerToMolblock","stereoAtoms","forEach","push","aList","a","bList","b","set","n","sugarSeqIdx","baseSeqIdx","sugarSm","baseSm","sugarG","baseG","prevPhosKey","sugarAtomFirst","sugarBondFirst","sAList","sBList","baseAtomFirst","baseBondFirst","addBranchMonomerToMolblock","bAList","bBList","lastPhosKey","runTriplesAssembly","monomer","mAtomFirst","mBondFirst","mAtomCount","mAtomList","maI","mBondCount","mBondList","mbI","cappingAtomType","atomIdx","keepPrecision","firstAtom","secondAtom","capResultingMolblock","molfileCountsLine","result","join","collection","rowsArray","newCollectionRow","updatedRow","getCollectionBlock","j","atomTypes","y","kwargs","fillAtomLines","fillBondLines","bondIdx","terminalNodes","fillChainExtendingBond","branchShift","updateBranchVariables","atomPairs","backboneShift","updateChainExtendingVariables","nucleobase","fillBranchAtomLines","branchMonomer","fillBackboneToBranchBond","bondCfg","bondConfiguration","has","orientation","get","round","PT","RNA","FASTA","SEPARATOR","HELM","BILN","onmessage","event","seqList","rolesList","start","end","data","resMolList","molfileWarningList","rowI","seq","undefined","err","msg","message","toString","postMessage","molfiles","warnings"],"sourceRoot":""}