@datagrok/helm 2.1.31 → 2.1.33
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/CHANGELOG.md +15 -0
- package/dist/package-test.js +1 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/package.json +5 -5
- package/src/cell-renderer.ts +34 -18
- package/src/helm-monomer-placer.ts +51 -26
- package/src/package-test.ts +1 -0
- package/src/tests/get-all-parts-tests.ts +34 -0
- package/src/tests/properties-widget-tests.ts +19 -1
- package/src/utils/index.ts +1 -1
package/dist/package.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var helm;(()=>{"use strict";var t={n:e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return t.d(n,{a:n}),n},d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{_package:()=>yt,editMoleculeCell:()=>Lt,getHelmHelper:()=>Pt,getMolfiles:()=>It,getMonomerLib:()=>Mt,helmCellRenderer:()=>Nt,initHelm:()=>St,openEditor:()=>Ht,propertiesWidget:()=>xt});const n=grok,r=ui,s=DG,i=$;var o,l,a=t.n(i);function h(t){var e;return"string"==typeof t||t instanceof String?t:("object"==typeof t||t instanceof Object)&&"$thrownJsError"in t?h(t.$thrownJsError):t instanceof Error?null!==(e=t.stack)&&void 0!==e?e:t.message:t.toString()}class c{constructor(t,e,n){this.name=t,this.alphabet=e,this.cutoff=n}}class g extends c{constructor(t,e,n){super(t.name,t.alphabet,t.cutoff),this.freq=e,this.similarity=n}}(l=o||(o={})).FASTA="fasta",l.SEPARATOR="separator",l.HELM="helm";const u=/(?:\[([A-Za-z0-9_\-,()]+)\])|([A-Za-z\-])/g,m=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"])}}},f=[new c("PT",m.fasta.peptide,.5),new c("DNA",m.fasta.dna,.55),new c("RNA",m.fasta.rna,.55)],d=wu;var p=t.n(d);function C(t={}){const e=function(){if(!t||!t.scoringMatrix||!t.alphabetIndexes)return(t,e)=>t===e?0:1;if(t.scoringMatrix.length!==Object.keys(t.alphabetIndexes).length)throw new Error("Scoring matrix and alphabet indexes should have the same length");const e=t.alphabetIndexes,n=t.scoringMatrix,r=Math.min(...Object.keys(e).map((t=>t.charCodeAt(0))))+1,s=new Float32Array((n.length+r)*(n.length+r));return Object.entries(e).forEach((([t,r])=>{const i=n[r];Object.entries(e).forEach((([e,r])=>{s[t.charCodeAt(0)*n.length+e.charCodeAt(0)]=i[r]}))})),(t,e)=>s[t.charCodeAt(0)*n.length+e.charCodeAt(0)]}(),n=t?.threshold??0;return(t,r)=>{let s=0;const i=t.length,o=r.length,l=Math.max(i,o)*(1-n);i!==o&&(s=Math.abs(i-o));let a=0;for(let n=0;n<Math.min(i,o);n++)if(t[n]!==r[n]&&(a+=e(t[n],r[n]),a>l))return 1;return a+=s,a/=Math.max(i,o),a}}const A=new Uint32Array(65536),b={gapOpen:1,gapExtend:.6,scoringMatrix:[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1,-4],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1,-4],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2,-4],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1,-4],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1,-4],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1,-4],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2,-4],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0,-4],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0,-4],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]],alphabetIndexes:{A:0,R:1,N:2,D:3,C:4,Q:5,E:6,G:7,H:8,I:9,L:10,K:11,M:12,F:13,P:14,S:15,T:16,W:17,Y:18,V:19,B:20,Z:21,X:22,"*":23}};var _;!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(_||(_={}));const w={[_.HAMMING]:C,[_.LEVENSHTEIN]:function(){return(t,e)=>((t,e)=>{if(t.length<e.length){const n=e;e=t,t=n}return 0===e.length?t.length:t.length<=32?((t,e)=>{const n=t.length,r=e.length,s=1<<n-1;let i=-1,o=0,l=n,a=n;for(;a--;)A[t.charCodeAt(a)]|=1<<a;for(a=0;a<r;a++){let t=A[e.charCodeAt(a)];const n=t|o;t|=(t&i)+i^i,o|=~(t|i),i&=t,o&s&&l++,i&s&&l--,o=o<<1|1,i=i<<1|~(n|o),o&=n}for(a=n;a--;)A[t.charCodeAt(a)]=0;return l})(t,e):((t,e)=>{const n=e.length,r=t.length,s=[],i=[],o=Math.ceil(n/32),l=Math.ceil(r/32);for(let t=0;t<o;t++)i[t]=-1,s[t]=0;let a=0;for(;a<l-1;a++){let o=0,l=-1;const h=32*a,c=Math.min(32,r)+h;for(let e=h;e<c;e++)A[t.charCodeAt(e)]|=1<<e;for(let t=0;t<n;t++){const n=A[e.charCodeAt(t)],r=i[t/32|0]>>>t&1,a=s[t/32|0]>>>t&1,h=n|o,c=((n|a)&l)+l^l|n|a;let g=o|~(c|l),u=l&c;g>>>31^r&&(i[t/32|0]^=1<<t),u>>>31^a&&(s[t/32|0]^=1<<t),g=g<<1|r,u=u<<1|a,l=u|~(h|g),o=g&h}for(let e=h;e<c;e++)A[t.charCodeAt(e)]=0}let h=0,c=-1;const g=32*a,u=Math.min(32,r-g)+g;for(let e=g;e<u;e++)A[t.charCodeAt(e)]|=1<<e;let m=r;for(let t=0;t<n;t++){const n=A[e.charCodeAt(t)],o=i[t/32|0]>>>t&1,l=s[t/32|0]>>>t&1,a=n|h,g=((n|l)&c)+c^c|n|l;let u=h|~(g|c),f=c&g;m+=u>>>r-1&1,m-=f>>>r-1&1,u>>>31^o&&(i[t/32|0]^=1<<t),f>>>31^l&&(s[t/32|0]^=1<<t),u=u<<1|o,f=f<<1|l,c=f|~(a|u),h=u&a}for(let e=g;e<u;e++)A[t.charCodeAt(e)]=0;return m})(t,e)})(t,e)/Math.max(t.length,e.length)},[_.NEEDLEMANN_WUNSCH]:function(t){const e=new Uint16Array(65536),{gapOpen:n,gapExtend:r,scoringMatrix:s,alphabetIndexes:i}={...b,...t};Object.entries(i).forEach((([t,n])=>e[t.charCodeAt(0)]=n));const o=[new Float32Array(1e4),new Float32Array(1e4)];return(t,i)=>{const l=new Array(t.length+1).fill(!1),a=new Array(t.length+1).fill(!1);let h=0,c=1;for(let e=1;e<t.length+1;e++)o[0][e]=-n-(e-1)*r,o[1][e]=0;o[0][0]=0;for(let g=1;g<i.length+1;g++){o[c][0]=-n-(g-1)*r;for(let u=1;u<t.length+1;u++){const m=o[h][u-1]+s[e[t.charCodeAt(u-1)]][e[i.charCodeAt(g-1)]],f=o[h][u]-(l[u]?r:n),d=o[c][u-1]-(a[u-1]?r:n);o[c][u]=Math.max(m,d,f),o[c][u]===m?(l[u]=!1,a[u]=!1):o[c][u]===d?(l[u]=!1,a[u]=!0):(l[u]=!0,a[u]=!1)}h=c,c=(c+1)%2}const g=Math.max(t.length,i.length);return(g-o[h][t.length])/g}},[_.MONOMER_CHEMICAL_DISTANCE]:C},T="p",E=new RegExp(`[rd]\\((\\w)\\)${T}?`,"g");class y{constructor(t,e=!1){if(this._length=0,this._version=0,this._updateLevel=0,this._selectedCount=0,this._selectedCountVersion=-1,this._selectedIndexesVersion=-1,this._versionedName="",this._versionedNameVersion=-1,this.SHRINK_THRESHOLD=256,"number"==typeof t){const n=t,r=y._createBuffer(n);if(e)for(let t=0;t<r.length;t++)r[t]=-1;this._data=r,this._length=n}else{if(!(t instanceof Uint32Array))throw new Error("Invalid constructor");this._data=t,this._length=e}}getRawData(){return this._data}assureGoez(t,e){if(t<0)throw new Error(`${e} should be greater than zero`)}assureInRange(t,e,n,r){if(t<e||t>n)throw new Error(`Argument ${r} (${t}) out of range (${e}, ${n})`)}copy(t,e,n){for(let r=0;r<n;r++)e[r]=t[r]}copyFrom(t){if(this._length!=t._length)throw new Error(`Lengths differ (${this._length} != ${t._length})`);this.copy(t._data,this._data,this.lengthInInts),this._version++}get length(){return this._length}get buffer(){return this._data}set buffer(t){this._data=t,this._version++}get version(){return this._version}set version(t){this._version=t}incrementVersion(t=!0){this._version++}get lengthInInts(){return Math.floor((this._length+31)/32)}get versionedName(){return this._version==this._versionedNameVersion?this._versionedName:""}set versionedName(t){this._versionedName=t,this._versionedNameVersion=this._version}get self(){return this}setLength(t){if(t<0)throw new Error("should be >= 0");if(t==this._length)return;const e=Math.floor((t+31)/32);if(e>this._data.length||e+this.SHRINK_THRESHOLD<this._data.length){const t=new Uint32Array(e);this.copy(this._data,t,e>this._data.length?this._data.length:e),this._data=t}t>this._length&&(this._length%32>0&&(this._data[this.lengthInInts-1]&=(1<<(this._length%32&31))-1),this._data.fill(0,this.lengthInInts,e)),this._length=t,this._version++}static fromAnd(t,e){if(t._length!=e._length)throw new Error(`Lengths differ (${t._length} != ${e._length})`);const n=new y(t._length);n._length=t._length,n._data=y._createBuffer(n._length),n._version=0;const r=t.lengthInInts;for(let s=0;s<r;s++)n._data[s]=t._data[s]&e._data[s];return n}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new y(t.length);e._version=0;for(let n=0;n<e._length;n++)t[n]&&(e._data[Math.floor(n/32)]|=1<<(n%32&31));return e}static fromSeq(t,e){const n=new y(t);for(let r=0;r<t;++r)n.setBit(r,e(r));return n._version=0,n}static fromString(t){return y.fromSeq(t.length,(e=>"1"==t.charAt(e)))}static fromUint32Array(t,e){const n=new y(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new y(8*e);n._data=new Uint32Array(Math.floor((e+3)/4)),n._length=8*e;let r=0,s=0;for(;e-s>=4;)n._data[r++]=255&t[s]|(255&t[s+1])<<8|(255&t[s+2])<<16|(255&t[s+3])<<24,s+=4;return e-s==3&&(n._data[r]=(255&t[s+2])<<16),e-s==2&&(n._data[r]|=(255&t[s+1])<<8),e-s==1&&(n._data[r]|=255&t[s]),n._version=0,n}toString(){return`${this._length} bits, ${this.countBits(!0)} set`}equals(t){if(this==t)return!0;if(null==t)return!1;if(this._length!=t._length)return!1;if(0==this._length)return!0;for(let e=0;e<this._data.length-1;e++)if(this._data[e]!=t._data[e])return!1;for(let e=8*(this._data.length-1);e<this._length;e++)if(this.getBit(e)!=t.getBit(e))return!1;return!0}clone(){const t=new y(0,!1);return t._data=Uint32Array.from(this._data),t._length=this._length,t._version=this._version,t}init(t,e){this.setAll(!1,!1);for(let e=0;e<this._length;e++)t(e)&&(this._data[Math.floor(e/32)]|=1<<(e%32&31));return this.incrementVersion(e),this}invert(t=!0){for(let t=0;t<this._data.length;t++)this._data[t]^=-1;this.incrementVersion(t)}setAll(t,e=!1){const n=t?-1:0,r=this.lengthInInts;for(let t=0;t<r;t++)this._data[t]=n;this.incrementVersion(e)}setIndexes(t,e=!0,n=!0,r=!0){n&&this.setAll(!e,!1);for(const n of t)this.setFast(n,e);this.incrementVersion(r)}everyIndex(t,e=!0){for(const n of t)if(this.getBit(n)!=e)return!1;return!0}anyIndex(t,e=!0){for(const n of t)if(this.getBit(n)==e)return!0;return!1}setWhere(t,e=!0,n=!0,r=!0,s=!0){if(n&&s&&this.setAll(!e,!1),s)for(let n=0;n<this._length;n++)t(n)&&this.setFast(n,e);else for(let n=0;n<this._length;n++)this.setFast(n,t(n)?e:!e);this.incrementVersion(r)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let r=t;r<e;++r)n.push(this.getBit(r));return y.fromValues(n)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let r=t;r<e;++r)n.push(this.getBit(r));return n}setRange(t,e,n,r=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const s=Math.min(t,e),i=Math.max(t,e);if(n)for(let t=s;t<=i;t++)this.setTrue(t);else for(let t=s;t<=i;t++)this.setFalse(t);return this.incrementVersion(r),this}setRandom(t,e,n=!0){if(t<0||t>this._length)throw new Error("n must be >= 0 && <= Count");t>this._length/2&&this.setRandom(this._length-t,!e),this.setAll(!e);for(let n=0;n<t;){const t=Math.floor(Math.random()*this._length);this.getBit(t)!=e&&(this.setFast(t,e),n++)}this.incrementVersion(n)}and(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]&=t._data[e];return this.incrementVersion(e),this}andNot(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");const n=this.lengthInInts;for(let e=0;e<n;e++)this._data[e]&=~t._data[e];return this.incrementVersion(e),this}notAnd(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]=~this._data[e]&t._data[e];return this.incrementVersion(e),this}not(t=!0){for(let t=0,e=this.lengthInInts;t<e;t++)this._data[t]=~this._data[t];return this.incrementVersion(t),this}or(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]|=t._data[e];return this.incrementVersion(e),this}xor(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]^=t._data[e];return this.incrementVersion(e),this}insertAt(t,e,n=!1){if(this.assureInRange(t,0,this._length,"pos"),0==e)return;const r=this._length;this.setLength(this._length+e);for(let n=r-1;n>=t;n--)this.setBit(n+e,this.getBit(n));for(let r=t;r<t+e;r++)this.setBit(r,n)}removeAt(t,e=1){if(e<0)throw new Error("n cannot be negative");if(this.assureInRange(t,0,this._length-e,"pos"),this.contains(!0))for(let n=t;n<this._length-e;n++)this.setBit(n,this.getBit(n+e));this.setLength(this._length-e)}removeByMask(t,e=!0){if(this._length!=t.length)throw new Error("length != mask.length");if(t==this)this.setLength(t.countBits(!e)),this.setAll(!e);else{let n=0;for(let r=-1;-1!=(r=t.findNext(r,!e));)this.setFast(n++,this.getBit(r));this._length=n,this._version++}return this}getBit(t){return 0!=(this._data[Math.floor(t/32)]&1<<(31&t))}setBit(t,e,n=!0){this.setFast(t,e),this._version++}setFast(t,e){e?this._data[Math.floor(t/32)]|=1<<(31&t):this._data[Math.floor(t/32)]&=~(1<<(31&t))}setTrue(t){this._data[Math.floor(t/32)]|=1<<(31&t)}setFalse(t){this._data[Math.floor(t/32)]&=~(1<<(31&t))}trueCount(){return this.countBits(!0)}falseCount(){return this.countBits(!1)}countBits(t){if(0==this._length)return 0;if(this._selectedCountVersion!=this._version){this._selectedCount=0;const t=this.lengthInInts;let e=0;for(;e<t-1;e++)for(let t=this._data[e];0!=t;t>>>=8)this._selectedCount+=y._onBitCount[255&t];let n=this._data[e];const r=31&this._length;for(0!=r&&(n&=~(4294967295<<r));0!=n;n>>>=8)this._selectedCount+=y._onBitCount[255&n];this._selectedCountVersion=this._version}return t?this._selectedCount:this._length-this._selectedCount}countWhere(t){let e=0;if(this.trueCount()==this._length)for(let n=0;n<this._length;n++)e+=t(n)?1:0;else for(let n=-1;-1!=(n=this.findNext(n,!0));)e+=t(n)?1:0;return e}andWithCountBits(t,e){if(0==this._length)return 0;let n=0;const r=this.lengthInInts;let s=0;for(;s<r-1;s++)for(let e=this._data[s]&t._data[s];0!=e;e>>>=8)n+=y._onBitCount[255&e];let i=this._data[s]&t._data[s];const o=31&this._length;for(0!=o&&(i&=~(4294967295<<o));0!=i;i>>>=8)n+=y._onBitCount[255&i];return e?n:this._length-n}clear(){this.setLength(0)}contains(t){return this.findNext(-1,t)>=0}get allTrue(){return this.countBits(!0)==this._length}get allFalse(){return this.countBits(!1)==this._length}get anyTrue(){return this.countBits(!0)>0}get anyFalse(){return this.countBits(!1)>0}findNext(t,e=!0){if(this.assureInRange(t,-1,this._length,"index"),t>=this._length-1)return-1;let n=31&(t=t<0?0:t+1);const r=this.lengthInInts;for(let s=Math.floor(t/32);s<r;s++){let r=e?this._data[s]:~this._data[s];if(0!=n)r&=4294967295<<n&4294967295,n=0;else if(!e&&-4294967296==r)continue;for(let e=0;0!=r;e+=8,r>>>=8){const n=y._firstOnBit[255&r];if(n>=0)return(t=n+32*s+e)>=this._length?-1:t}}return-1}findPrev(t,e=!0){if(0==t)return-1;this.assureInRange(t,-1,this._length,"index");let n=1+(t=t<0?this._length-1:t-1)&31;for(let r=Math.floor(t/32);r>=0;r--){let t=e?this._data[r]:~this._data[r];0!=n&&(t&=~(4294967295<<n),n=0);for(let e=24;0!=t;e-=8,t<<=8){const n=y._lastOnBit[t>>>24];if(n>=0)return n+32*r+e}}return-1}}var S,M,O,N,v,L,H;y._onBitCount=Int8Array.from([0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8]),y._firstOnBit=Int8Array.from([-1,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0]),y._lastOnBit=Int8Array.from([-1,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7]),function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan",t.Onehot="One-Hot"}(S||(S={})),function(t){t.Euclidean="Euclidean"}(M||(M={})),function(t){t.Tanimoto="Tanimoto",t.Dice="Dice",t.Asymmetric="Asymmetric",t.BraunBlanquet="Braun-Blanquet",t.Cosine="Cosine",t.Kulczynski="Kulczynski",t.McConnaughey="Mc-Connaughey",t.RogotGoldberg="Rogot-Goldberg",t.Russel="Russel",t.Sokal="Sokal",t.Hamming="Hamming",t.Euclidean="Euclidean"}(O||(O={})),function(t){t.TanimotoIntArray="TanimotoIntArray"}(N||(N={})),function(t){t.Vector="Vector",t.String="String",t.BitArray="BitArray",t.MacroMolecule="MacroMolecule",t.Number="Number",t.IntArray="IntArray",t.NumberArray="NumberArray"}(v||(v={})),function(t){t.Difference="Difference"}(L||(L={})),function(t){t.CommonItems="Common Items"}(H||(H={})),O.Tanimoto,O.Dice,O.Asymmetric,O.BraunBlanquet,O.Cosine,O.Kulczynski,O.McConnaughey,O.RogotGoldberg,O.Russel,O.Sokal,O.Hamming,O.Euclidean,O.Tanimoto,O.Dice,O.Asymmetric,O.BraunBlanquet,O.Cosine,O.Kulczynski,O.McConnaughey,O.RogotGoldberg,O.Russel,O.Sokal,O.Hamming,O.Euclidean,O.Tanimoto,O.Dice,O.Cosine,O.Tanimoto,O.Asymmetric,O.Cosine,O.Sokal,_.HAMMING,_.LEVENSHTEIN,_.MONOMER_CHEMICAL_DISTANCE,_.NEEDLEMANN_WUNSCH;const x=new class{constructor(){this.uh=`units-handler.${s.SEMTYPE.MACROMOLECULE}`}},R={[o.FASTA]:"-",[o.SEPARATOR]:"",[o.HELM]:"*"};class I{constructor(t){if(this._splitter=null,this.cached=!0,this._splitted=null,this.columnVersion=null,this._stats=null,this._maxLength=null,this._posList=null,this._joiner=void 0,t.type!==s.TYPE.STRING)throw new Error(`Unexpected column type '${t.type}', must be '${s.TYPE.STRING}'.`);this._column=t,this._columnVersion=t.version;const e=this._column.getTag(s.TAGS.UNITS);if(null==e)throw new Error("Units are not specified in column");if(this._units=e,this._notation=this.getNotation(),this._defaultGapOriginal=this.isFasta()?R[o.FASTA]:this.isHelm()?R[o.HELM]:R[o.SEPARATOR],!this.column.tags.has("aligned")||!this.column.tags.has("alphabet")||!this.column.tags.has(".alphabetIsMultichar")&&!this.isHelm()&&"UN"===this.alphabet)if(this.isFasta())I.setUnitsToFastaColumn(this);else if(this.isSeparator()){const e=t.getTag("separator");I.setUnitsToSeparatorColumn(this,e)}else{if(!this.isHelm())throw new Error(`Unexpected units '${this.column.getTag(s.TAGS.UNITS)}'.`);I.setUnitsToHelmColumn(this)}if(!this.column.tags.has(".alphabetIsMultichar"))if(this.isHelm())this.column.setTag(".alphabetIsMultichar","true");else if(["UN"].includes(this.alphabet))throw new Error(`For column '${this.column.name}' of alphabet '${this.alphabet}' tag '.alphabetIsMultichar' is mandatory.`)}static setUnitsToFastaColumn(t){if(t.column.semType!==s.SEMTYPE.MACROMOLECULE||t.column.getTag(s.TAGS.UNITS)!==o.FASTA)throw new Error(`The column of notation '${o.FASTA}' must be '${s.SEMTYPE.MACROMOLECULE}'.`);t.column.setTag(s.TAGS.UNITS,o.FASTA),I.setTags(t)}static setUnitsToSeparatorColumn(t,e){if(t.column.semType!==s.SEMTYPE.MACROMOLECULE||t.column.getTag(s.TAGS.UNITS)!==o.SEPARATOR)throw new Error(`The column of notation '${o.SEPARATOR}' must be '${s.SEMTYPE.MACROMOLECULE}'.`);if(!e)throw new Error(`The column of notation '${o.SEPARATOR}' must have the separator tag.`);t.column.setTag(s.TAGS.UNITS,o.SEPARATOR),t.column.setTag("separator",e),I.setTags(t)}static setUnitsToHelmColumn(t){if(t.column.semType!==s.SEMTYPE.MACROMOLECULE)throw new Error(`The column of notation '${o.HELM}' must be '${s.SEMTYPE.MACROMOLECULE}'`);t.column.setTag(s.TAGS.UNITS,o.HELM),I.setTags(t)}static setTags(t){const e=t.column.getTag(s.TAGS.UNITS),n=t.stats;if(Object.keys(n.freq).some((t=>t.length>1)),[o.FASTA,o.SEPARATOR].includes(e)){if(!t.column.getTag("alphabet")&&0===Object.keys(n.freq).length)throw new Error("Alphabet is empty and not annotated.");let e=t.column.getTag("aligned");null===e&&(e=n.sameLength?"SEQ.MSA":"SEQ",t.column.setTag("aligned",e));let r=t.column.getTag("alphabet");if(null===r&&(r=function(t,e,n="-"){const r=e.map((e=>{const r=function(t,e,n="-"){const r=new Set([...new Set(Object.keys(t)),...e]);r.delete(n);const s=[],i=[];for(const n of r)s.push(n in t?t[n]:0),i.push(e.has(n)?1:0);const o=new B(s),l=new B(i);return function(t,e){if(t.length!=e.length)throw new Error("The dimensionality of the vectors must match");let n=0;for(let r=0;r<t.length;r++)n+=t[r]*e[r];return n}(o,l)/(k(o)*k(l))}(t,e.alphabet,n);return new g(e,t,r)}));let s;const i=Math.max(...r.map((t=>t.similarity>t.cutoff?t.similarity:-1)));s=i>0?r.find((t=>t.similarity===i)).name:"UN";return s}(n.freq,f),t.column.setTag("alphabet",r)),"UN"===r){const e=Object.keys(n.freq).length,r=Object.keys(n.freq).some((t=>t.length>1));t.column.setTag(".alphabetSize",e.toString()),t.column.setTag(".alphabetIsMultichar",r?"true":"false")}}}get column(){return this._column}get length(){return this._column.length}get units(){return this._units}get notation(){return this._notation}get defaultGapOriginal(){return this._defaultGapOriginal}get separator(){const t=this.column.getTag("separator")??void 0;if(this.notation===o.SEPARATOR&&void 0===t)throw new Error(`Separator is mandatory for column '${this.column.name}' of notation '${this.notation}'.`);return t}get aligned(){const t=this.column.getTag("aligned");if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag aligned not set");return t}get alphabet(){const t=this.column.getTag("alphabet");if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag alphabet not set");return t}get helmCompatible(){return this.column.getTag(".isHelmCompatible")}getAlphabetSize(){if(this.notation==o.HELM||"UN"==this.alphabet){const t=this.column.getTag(".alphabetSize");let e;if(t)e=parseInt(t);else{const t=this.stats;e=Object.keys(t.freq).length}return e}switch(this.alphabet){case"PT":return 20;case"DNA":case"RNA":return 4;case"NT":return console.warn("Unexpected alphabet 'NT'."),4;default:throw new Error(`Unexpected alphabet '${this.alphabet}'.`)}}getAlphabetIsMultichar(){return this.notation===o.HELM||"UN"===this.alphabet&&"true"===this.column.getTag(".alphabetIsMultichar")}getSplitted(t){if(this.cached){this.column.version===this.columnVersion&&null!==this._splitted||(this.columnVersion=this.column.version,this._splitted=new Array(this.column.length));let e=this._splitted[t]?this._splitted[t].deref():void 0;if(!e){const n=this.column.get(t);e=this.splitter(n),this._splitted[t]=new WeakRef(e)}return e}{const e=this.column.get(t);return this.splitter(e)}}get stats(){if(null===this._stats){const t={};let e=!0,n=null;const r=this.column.length;for(let s=0;s<r;++s){const r=this.getSplitted(s);null==n?n=r.length:r.length!==n&&(e=!1);for(const e of r.canonicals)e in t||(t[e]=0),t[e]+=1}this._stats={freq:t,sameLength:e}}return this._stats}get maxLength(){return null===this._maxLength&&(this._maxLength=0===this.column.length?0:Math.max(...p().count(0).take(this.column.length).map((t=>this.getSplitted(t).length)))),this._maxLength}get posList(){if(null===this._posList){const t=this.column.getTag(".positionNames");this._posList=t?t.split(", ").map((t=>t.trim())):p().count(1).take(this.maxLength).map((t=>t.toString())).toArray()}return this._posList}isFasta(){return this.notation===o.FASTA}isSeparator(){return this.notation===o.SEPARATOR}isHelm(){return this.notation===o.HELM}isRna(){return"RNA"===this.alphabet}isDna(){return"DNA"===this.alphabet}isPeptide(){return"PT"===this.alphabet}isMsa(){return!!this.aligned&&this.aligned.toUpperCase().includes("MSA")}isHelmCompatible(){return"true"===this.helmCompatible}isGap(t){return!t||t===this._defaultGapOriginal}getNotation(){if(this.units.toLowerCase().startsWith(o.FASTA))return o.FASTA;if(this.units.toLowerCase().startsWith(o.SEPARATOR))return o.SEPARATOR;if(this.units.toLowerCase().startsWith(o.HELM))return o.HELM;throw new Error(`Column '${this.column.name}' has unexpected notation '${this.units}'.`)}getHelmWrappers(){return[this.isDna()||this.isRna()||this.isHelmCompatible()?"RNA1{":"PEPTIDE1{",this.isDna()?"d(":this.isRna()?"r(":"",this.isDna()||this.isRna()?")p":"","}$$$$"]}getNewColumn(t,e,n,r){const i=this.column,l=t.toLowerCase()+"("+i.name+")",a=n??i.dataFrame.columns.getUnusedName(l),h=s.Column.fromList("string",a,r??new Array(this.column.length).fill(""));if(h.semType=s.SEMTYPE.MACROMOLECULE,h.setTag(s.TAGS.UNITS,t),t===o.SEPARATOR){if(!e)throw new Error(`Notation '${o.SEPARATOR}' requires separator value.`);h.setTag("separator",e)}h.setTag(s.TAGS.CELL_RENDERER,"sequence");const c=i.getTag("aligned");c&&h.setTag("aligned",c);let g=i.getTag("alphabet");g||this.notation!==o.HELM||t===o.HELM||(g="UN"),null!=g&&h.setTag("alphabet",g);let u=i.getTag(".alphabetSize");null!=g&&u&&h.setTag(".alphabetSize",u);const m=i.getTag(".alphabetIsMultichar");return null!=g&&void 0!==m&&h.setTag(".alphabetIsMultichar",m),t==o.HELM&&(u=this.getAlphabetSize().toString(),h.setTag(".alphabetSize",u)),h}getNewColumnFromList(t,e){return this.getNewColumn(this.notation,this.separator,t,e)}static getNewColumn(t){const e=I.forColumn(t),n=e.notation;return e.getNewColumn(n)}static unitsStringIsValid(t){return t=t.toLowerCase(),[o.FASTA,o.SEPARATOR,o.HELM].some((e=>t.startsWith(e.toLowerCase())))}static getNewColumnFromParams(t,e,n){if(!I.unitsStringIsValid(n))throw new Error("Invalid format of 'units' parameter");const r=s.Column.fromList("string",e,new Array(t).fill(""));return r.semType=s.SEMTYPE.MACROMOLECULE,r.setTag(s.TAGS.UNITS,n),r}getSplitter(t){if(this.units.toLowerCase().startsWith(o.FASTA))return null===this.column.getTag("alphabet")||this.getAlphabetIsMultichar()?K:J;if(this.units.toLowerCase().startsWith(o.SEPARATOR))return Q(this.separator,t);if(this.units.toLowerCase().startsWith(o.HELM))return tt;throw new Error(`Unexpected units ${this.units} .`)}split(t){return this.splitter(t)}getDistanceFunctionName(){if(!this.isFasta())throw new Error("Only FASTA notation is supported");return this.isMsa()?_.HAMMING:(this.alphabet,_.LEVENSHTEIN)}getDistanceFunction(){return w[this.getDistanceFunctionName()]()}async checkHelmCompatibility(){if(this.column.tags.has(".isHelmCompatible"))return"true"===this.column.getTag(".isHelmCompatible");const t=(await async function(){const t=s.Func.find({package:"Bio",name:"getMonomerLibHelper"});if(0===t.length)throw new Error('Package "Bio" must be installed for MonomerLibHelper.');return(await t[0].prepare().call()).getOutputParamValue()}()).getBioLib().getMonomerSymbolsByType("PEPTIDE".toString()),e=new Set(t),n=(Q(this.separator),new Set),r=this.column.length,i=this.column.getRawData();for(let t=0;t<r;++t){const r=i[t];if(!(r in n)){n.add(r);const s=this.getSplitted(t);for(const t of s.canonicals)if(!e.has(t))return this.column.setTag(".isHelmCompatible","false"),!1}}return this.column.setTag(".isHelmCompatible","true"),!0}get splitter(){return null===this._splitter&&(this._splitter=this.getSplitter()),this._splitter}toFasta(t){return t===o.FASTA}toSeparator(t){return t===o.SEPARATOR}toHelm(t){return t===o.HELM}convertHelmToFastaSeparator(t,e,n,r){r||(r=this.toFasta(e)?R[o.FASTA]:R[o.SEPARATOR]),n||(n=this.toFasta(e)?"":this.separator);const s=t.startsWith("RNA"),i=this.splitter(t),l=[];for(let t=0;t<i.length;++t){let n=i.getOriginal(t);if(s&&(n=n.replace(E,"")),n===R[o.HELM])l.push(r);else if(this.toFasta(e)&&n.length>1){const t="["+n+"]";l.push(t)}else l.push(n)}return l.join(n)}convert(t,e){const n=this.getJoiner({notation:t,separator:e}),r=this.getNewColumn(t,e);return r.init((t=>{const e=this.getSplitted(t);return n(e)})),r}getRegion(t,e,n){const r=this.getNewColumn(this.notation,this.separator);r.name=n;const s=t??0,i=e??this.maxLength-1,o=this.getJoiner(),l=i-s+1;r.init((t=>{const e=this.getSplitted(t),n=new Array(l);for(let t=0;t<l;++t){const r=s+t,i=e.getOriginal(r);n[t]=r<e.length?i:R[this.notation]}return o(new z(n,R[this.notation]))}));const a=t=>{const e=t.split(",").map((t=>t.trim())),n=new Array(l);for(let t=0;t<l;++t){const r=s+t;n[t]=r<e.length?e[r]:"?"}return n.join(", ")},h=this.column.getTag(".positionNames");h&&r.setTag(".positionNames",a(h));const c=this.column.getTag(".positionLabels");return c&&r.setTag(".positionLabels",a(c)),r}get joiner(){return this._joiner||(this._joiner=this.getJoiner()),this._joiner}getJoiner(t){const e=t?t.notation:this.notation,n=t?t.separator:this.separator;let r;const s=this;switch(e){case o.FASTA:r=function(t){return s.joinToFasta(t,s.isHelm())};break;case o.SEPARATOR:if(!n)throw new Error(`Separator is mandatory for notation '${e}'.`);r=function(t){return P(t,n,s.isHelm())};break;case o.HELM:{const t="DNA"===s.alphabet||"RNA"===s.alphabet,e=s.getHelmWrappers();r=function(n){return F(n,e,t)};break}default:throw new Error(`Unexpected notation '${e}'.`)}return r}getConverter(t,e=void 0){if(t===o.SEPARATOR&&!e)throw new Error(`Target separator is not specified for target units '${o.SEPARATOR}'.`);const n=this;if(t===o.FASTA)return function(t){return n.convertToFasta(t)};if(t===o.HELM)return function(t){return n.convertToHelm(t)};if(t===o.SEPARATOR)return function(t){return n.convertToSeparator(t,e)};throw new Error}static forColumn(t){let e=t.temp[x.uh];return e&&e.columnVersion===t.version||(e=t.temp[x.uh]=new I(t)),e}joinToFasta(t,e){const n=new Array(t.length);for(let r=0;r<t.length;++r){const s=t.getOriginal(r);let i=t.getOriginal(r);e&&(i=i.replace(E,"$1")),""===s?i=R[o.FASTA]:s===T?i="":i.length>1&&(i="["+i+"]"),n[r]=i}return n.join("")}convertToFasta(t){const e=this.splitter,n=this.isHelm()?this.splitterAsHelmNucl(t):e(t);return this.joinToFasta(n,this.isHelm())}convertToSeparator(t,e){return P(this.isHelm()?this.splitterAsHelmNucl(t):this.splitter(t),e,this.isHelm())}convertToHelm(t){const e=this.getHelmWrappers(),n=t.startsWith("DNA")||t.startsWith("RNA");return F(this.splitter(t),e,n)}splitterAsHelmNucl(t){const e=this.splitter(t),n=new Array(e.length),r=t.startsWith("DNA"),s=t.startsWith("RNA");for(let t=0;t<e.length;++t){let i=e.getOriginal(t);(r||s)&&(i=i.replace(E,"$1"),i=i===T?null:i),n[t]=i||null}return new z(n.filter((t=>!!t)),R[o.HELM])}}function P(t,e,n){const r=new Array(t.length);for(let e=0;e<t.length;++e){const s=t.getCanonical(e);let i=t.getOriginal(e);n&&(i=i.replace(E,"$1")),""===s?i=R[o.SEPARATOR]:s===T&&(i=""),r[e]=i}return r.join(e)}function F(t,e,n){const[r,s,i,l]=e,a=new Array(t.length);for(let e=0;e<t.length;++e){const r=t.getCanonical(e);let l=t.getOriginal(e);""===r?l=R[o.HELM]:(n&&(l=l.replace(E,"$1")),l=1===l.length?`${s}${l}${i}`:`${s}[${l}]${i}`),a[e]=l}return`${r}${a.join(".")}${l}`}class B extends Float32Array{}function k(t){let e=0;for(let n=0;n<t.length;n++)e+=t[n]*t[n];return Math.sqrt(e)}class G{static makePalette(t,e=!1,n=G){const r={};return t.forEach((t=>{const n=t[0],s=t[1];n.forEach(((t,n)=>{r[t]=this.colourPalette[s][e?0:n]}))})),new n(r)}constructor(t){this._palette=t}get(t){return this._palette[t]}}G.undefinedColor="rgb(100,100,100)",G.colourPalette={orange:["rgb(255,187,120)","rgb(245,167,100)","rgb(235,137,70)","rgb(205, 111, 71)"],all_green:["rgb(44,160,44)","rgb(74,160,74)","rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)","rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],all_blue:["rgb(31,119,180)","rgb(23,190,207)","rgb(122, 102, 189)","rgb(158,218,229)","rgb(141, 124, 217)","rgb(31, 120, 150)"],magenta:["rgb(162,106,192)","rgb(197,165,224)","rgb(208,113,218)"],red:["rgb(214,39,40)","rgb(255,152,150)"],st_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(31,119,180)"],dark_blue:["rgb(31,119,180)","rgb(31, 120, 150)"],light_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(108, 218, 229)","rgb(23,190,227)"],lilac_blue:["rgb(124,102,211)","rgb(149,134,217)","rgb(97, 81, 150)"],dark_green:["rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)"],green:["rgb(44,160,44)","rgb(74,160,74)"],light_green:["rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],st_green:["rgb(44,160,44)","rgb(152,223,138)","rgb(39, 174, 96)","rgb(74,160,74)"],pink:["rgb(247,182,210)"],brown:["rgb(140,86,75)","rgb(102, 62, 54)"],gray:["rgb(127,127,127)","rgb(199,199,199)","rgb(196,156,148)","rgb(222, 222, 180)"],yellow:["rgb(188,189,34)"],white:["rgb(230,230,230)"]};class U extends G{static get Lesk(){return void 0===this.lesk&&(this.lesk=this.makePalette([[["G","A","S","T"],"orange"],[["C","V","I","L","P","F","Y","M","W"],"all_green"],[["N","Q","H"],"magenta"],[["D","E"],"red"],[["K","R"],"all_blue"]],!1,U)),this.lesk}static get GrokGroups(){return void 0===this.grokGroups&&(this.grokGroups=this.makePalette([[["C","U"],"yellow"],[["G","P"],"red"],[["A","V","I","L","M","F","Y","W"],"all_green"],[["R","H","K"],"light_blue"],[["D","E"],"dark_blue"],[["S","T","N","Q"],"orange"]],!1,U)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new U({D:"#E60A0A",E:"#E60A0A",C:"#E6E600",M:"#E6E600",K:"#145AFF",R:"#145AFF",S:"#FA9600",T:"#FA9600",F:"#3232AA",Y:"#3232AA",N:"#00DCDC",Q:"#00DCDC",G:"#EBEBEB",L:"#0F820F",V:"#0F820F",I:"#0F820F",A:"#C8C8C8",W:"#B45AB4",H:"#8282D2",P:"#DC9682",others:"#BEA06E"})),this.rasMol}get(t){const e=t in U.aaSynonyms?U.aaSynonyms[t]:t;return super.get(e)}}U.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class D{static getPalette(t="grok"){switch(t){case"grok":return U.GrokGroups;case"lesk":return U.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,n="",r="";for(const s of t)"("==s?e++:")"==s?e--:e?n+=s:r+=s;return isNaN(parseInt(n))?[r,n]:[r,""]}static getColorAAPivot(t="",e="grok"){const n=this.getPalette(e);let[r,s]=this.getInnerOuter(t);if(r=r.length>6?`${r.slice(0,3)}...`:r,s=s.length>6?`${s.slice(0,3)}...`:s,1==t.length||"("==t[1]){const e=t[0]?.toUpperCase();return e in n?[n.get(e),e,s,1]:[this.undefinedColor,r,s,1]}if("d"==t[0]&&t[1]in n&&(2==t.length||"("==t[2])){const e=t[1]?.toUpperCase();return e in n?[n.get(e),e,s,2]:[this.undefinedColor,r,s,2]}if(t.substring(0,3)in this.AAFullNames&&(3==t.length||"("==t[3])){const e=this.AAFullNames[t.substring(0,3)];return e in n?[n.get(e),e,s,3]:[this.undefinedColor,r,s,3]}if(t[0]?.toLowerCase()==t[0]&&t.substring(1,3)in this.AAFullNames&&(4==t.length||"("==t[4])){const e=this.AAFullNames[t.substring(1,3)];return e in n?[n.get(e),e,s,4]:[this.undefinedColor,r,s,4]}return[this.undefinedColor,r,s,0]}}D.SemType="Aminoacids",D.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",D.undefinedColor="rgb(100,100,100)",D.Names={G:"Glycine",L:"Leucine",Y:"Tyrosine",S:"Serine",E:"Glutamic acid",Q:"Glutamine",D:"Aspartic acid",N:"Asparagine",F:"Phenylalanine",A:"Alanine",K:"Lysine",R:"Arginine",H:"Histidine",C:"Cysteine",V:"Valine",P:"Proline",W:"Tryptophan",I:"Isoleucine",M:"Methionine",T:"Threonine"},D.AASmiles={G:"NCC(=O)O",L:"N[C@H](CC(C)C)C(=O)O",Y:"NC(CC1=CC=C(O)C=C1)C(=O)O",S:"NC(CO)C(=O)O",E:"N[C@@H](CCC(O)=O)C(=O)O",Q:"N[C@@H](CCC(N)=O)C(=O)O",D:"N[C@@H](CC(O)=O)C(=O)O",N:"N[C@@H](CC(N)=O)C(=O)O",F:"NC(CC1=CC=CC=C1)C(=O)O",A:"N[C@H](C)C(=O)O",K:"NC(CCCCN)C(=O)O",R:"N[C@H](CCCNC(=N)C)C(=O)O",H:"NC(CC1=CN=C[N]1)C(=O)O",C:"N[C@@H](CS)C(=O)O",V:"NC(C(C)C)C(=O)O",P:"N(CCC1)C1C(=O)O",W:"N[C@@H](Cc1c2ccccc2n([H])c1)C(=O)O",I:"N[C@H]([C@H](C)CC)C(=O)O",M:"NC(CCSC)C(=O)O",T:"NC(C(O)C)C(=O)O"},D.AASmilesTruncated={G:"*C*",L:"CC(C)C[C@H](*)*",Y:"C1=CC(=CC=C1CC(*)*)O",S:"OCC(*)C*",E:"*[C@@H](CCC(O)=O)*",Q:"*N[C@@H](CCC(N)=O)*",D:"*[C@@H](CC(O)=O)*",N:"*[C@@H](CC(N)=O)*",F:"C1=CC=C(C=C1)CC(*)*",A:"C[C@H](*)*",K:"C(CCN)CC(*)*",R:"*[C@H](CCCNC(=N)C)*",H:"C1=C(NC=N1)CC(*)*",C:"C([C@@H](*)*)S",V:"CC(C)C(*)*",P:"C1CCN(*)C1*",W:"*[C@@H](Cc1c2ccccc2n([H])c1)*",I:"CC[C@H](C)[C@H](*)*",M:"CSCCC(*)*",T:"CC(O)C(*)*"},D.AAFullNames={Ala:"A",Arg:"R",Asn:"N",Asp:"D",Cys:"C",Gln:"Q",Glu:"E",Gly:"G",His:"H",Ile:"I",Leu:"L",Lys:"K",Met:"M",Phe:"F",Pro:"P",Ser:"S",Thr:"T",Trp:"W",Tyr:"Y",Val:"V"};class V{}V.SemType="Nucleotides",V.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",V.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"};class W{static hashCode(t){let e=0;if(0===t.length)return e;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e}}class j{}class q extends j{static buildPalette(){return[].concat(...Object.values(G.colourPalette))}get(t){const e=W.hashCode(t)%q.palette.length;return function(t){if(null==t)return"rgb(100,100,100)";const e=s.Color.fromHtml(t),n=s.Color.g(e),r=s.Color.r(e),i=s.Color.b(e),o=Math.sqrt(Math.pow(0-r,2)+Math.pow(0-n,2)+Math.pow(0-i,2));return o>210?`rgb(${r/o*210},${n/o*210},${i/o*210})`:s.Color.toRgb(e)}(q.palette[e])}}q.palette=q.buildPalette();class z{get length(){return this.mList.length}get canonicals(){return this.mList}get originals(){return this.mList}isGap(t){return this.getOriginal(t)===this.gapOriginalMonomer}getCanonical(t){return this.mList[t]}getOriginal(t){return this.mList[t]}constructor(t,e){this.mList=t,this.gapOriginalMonomer=e}}class Y{get length(){return this.seqS.length}get canonicals(){return this.seqS}get originals(){return this.seqS}isGap(t){return this.getOriginal(t)===R[o.FASTA]}getCanonical(t){return this.isGap(t)?"":this.seqS[t]}getOriginal(t){return this.seqS[t]}constructor(t){this.seqS=t}}const K=t=>{const e=p()(t.toString().matchAll(u)).map((t=>t[2]??t[1])).toArray();return new z(e,R[o.FASTA])},J=t=>t?new Y(t):new z([],R[o.FASTA]);function Q(t,e=void 0){return n=>{if(n){const r=n.replaceAll('"-"',"").replaceAll("'-'","").split(t,e);return new z(r,R[o.SEPARATOR])}return new z([],R[o.SEPARATOR])}}const Z=/(PEPTIDE1|DNA1|RNA1)\{([^}]+)}/g,X=/\[([^\[\]]+)]/g,tt=t=>{Z.lastIndex=0;const e=Z.exec(t.toString()),n=e?e[2]:null,r=n?n.split("."):[];return new z(r.map((t=>{X.lastIndex=0;const e=X.exec(t);return e&&e.length>=2?e[1]:t})),R[o.HELM])},et=/([^\W_]+)/g;const nt=/\{(\*\.)+/g,rt=/\.(\*\.)+/g,st=/(\.\*)+\}/g;function it(t){return t.replaceAll(nt,"{").replaceAll(rt,".").replaceAll(st,"}").replace("{*}","{}")}function ot(t){t=ct(t,"$")[0];const e=[];if(!scil.Utils.isNullOrEmpty(t)){const n=ct(t,"|");for(let r=0;r<n.length;++r){let s=(t=gt(n[r]).str).indexOf("{");s=(t=t.substring(s+1)).indexOf("}");const i=ct(t=t.substring(0,s),".");for(const t of i)if(t&&""!==t)if(t.startsWith("[")&&t.includes("]")){const n=at(t,1,"[","]"),r=t.substring(1,n);e.push(r);const s=t.substring(n+1);i.push(s)}else if(t.includes("[")&&t.endsWith("]")){const n=ht(t,t.length-2,"[","]"),r=t.substring(n+1,t.length-1);e.push(r);const s=t.substring(0,n);i.push(s)}else if(t.includes("(")&&t.includes(")")){const e=t.substring(0,t.indexOf("(")),n=t.substring(t.lastIndexOf(")")+1),r=[e,t.substring(e.length+1,t.length-n.length-1),n];for(const t of r)i.push(t)}else e.push(t)}}return e}function lt(t){const e=Object.keys(org.helm.webeditor.monomerTypeList()),n=[],r=[];for(let t=0;t<e.length;t++)n.push(new scil.helm.Monomers.getMonomerSet(e[t])),Object.keys(n[t]).forEach((e=>{r.push(n[t][e].id)}));return new Set(t.filter((t=>!r.includes(t))))}function at(t,e,n,r){let s=e,i=0;for(;s<t.length;){if(t[s]===n&&i++,t[s]===r){if(0===i)return s;i--}s++}return-1}function ht(t,e,n,r){let s=e,i=0;for(;s>=0;){if(t[s]===r&&i++,t[s]===n){if(0===i)return s;i--}s--}return-1}function ct(t,e){const n=[];let r="",s=0,i=0,o=0,l=0;for(let a=0;a<t.length;++a){let h=t.substring(a,a+1);if(h==e&&0==i&&0==s&&0==o&&0==l)n.push(r),r="";else{if(r+=h,l>0&&"\\"==h&&a+1<t.length){++a;const e=t.substring(a,a+1);r+=e,h+=e}'"'==h?a>0&&"\\"==t.substring(a-1,a)||(l=0==l?1:0):"["==h?++i:"]"==h?--i:"("==h?++s:")"==h?--s:"{"==h?++o:"}"==h&&--o}}return n.push(r),n}function gt(t){const e=ut(t,'"');if(null!=e.tag)return e;const n=ut(t,"'");return{tag:e.tag,repeat:n.tag,str:n.str}}function ut(t,e){let n=null;if(scil.Utils.endswith(t,e)){let r=t.length-1;for(;r>0&&(r=t.lastIndexOf(e,r-1),!(r<=0||"\\"!=t.substring(r-1,r))););r>0&&r<t.length-1&&(n=t.substring(r+1,t.length-1),t=t.substring(0,r))}return null!=n&&(n=function(t){return scil.Utils.isNullOrEmpty(t)?t:t.replace(/[\\]./g,(function(t){switch(t){case"\\r":return"\r";case"\\n":return"\n";case"\\t":return"\t";default:return t.substring(1)}}))}(n.replace(new RegExp("\\"+e,"g"),e))),{tag:n,str:t}}var mt,ft;function dt(t,e,n,r,s,i,o="rgb(100,100,100)",l=0,a=!1,h=1,c="",g=!1,u=ft.classic,m=[],f=0,d=null,p=null,C=null,A={}){s.textAlign="start";let b=i.substring(0),_=g?"":c;u===ft.MSA&&(_="");let w=!0,T=!0,E="difference";if(null!=d&&null!=d.cell.column&&(w=d.cell.column.temp["color-code"]??!0,T=d.cell.column.temp["compare-with-current"]??!0,E=d.cell.column.temp["highlight-difference"]??"difference"),p){const t=p[f];T&&p.length>0&&"difference"===E&&(h=b==t?.3:h),T&&p.length>0&&"equal"===E&&(h=b!=t?.3:h)}null!=C&&(b=function(t,e){if(t.length<=e)return t;const n=t.match(et),r=t.length>e||(n?.length??0)>1,s=n?.[0]??" ";return r?s.substring(0,e-1)+"…":s}(b,C));const y=b+_;A[y]??(A[y]=s.measureText(y));let S=A[y];A[b]??(A[b]=s.measureText(b));let M=A[b].width;A[_]??(A[_]=s.measureText(_));const O=A[_].width,N=r/2-(S.fontBoundingBoxAscent+S.fontBoundingBoxDescent)/2+1;function v(n,r){const i=w?o:"rgb(0,0,0)";s.fillStyle=i,s.globalAlpha=h,u===ft.classic&&(s.fillText(b,t+n,e+N),s.fillStyle="#808080",s.fillText(_,t+r,e+N)),u===ft.MSA&&s.fillText(b,t+n,e+N)}S=S.width,u===ft.MSA&&(M=m[f],S=m[f]);const L=(m[f]??0)-(m[0]??0);if(a||S>n)return v(L,L+M),t+L+M+O;{const e=(n-S)/2;return v(e,e+M),t+L+e+M}}!function(t){t.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(mt||(mt={})),function(t){t.MSA="MSA",t.classic="classic"}(ft||(ft={}));class pt{constructor(t){this.col=t,this.monomerCharWidth=7,this.leftPadding=5,this.monomerTextSizeMap={},this.col.dataFrame.onDataChanged.subscribe(),this.monomerLib=Mt(),this.monomerLib.onChanged.subscribe(this.monomerLibOnChanged.bind(this)),this._allPartsList=new Array(this.col.length).fill(null),this._lengthsList=new Array(this.col.length).fill(null),this._editorList=new Array(this.col.length).fill(null)}skipCell(t){this._allPartsList[t]=[],this._lengthsList[t]=[]}getCellAllPartsLengths(t){const[e,n]=this.getCellMonomerLengthsForSeq(t),r=new Array(n.length+1);r[0]=this.leftPadding;for(let t=1;t<r.length;t++)r[t]=r[t-1]+n[t-1];return[e,n,r]}getCellMonomerLengthsForSeq(t){let e=this._allPartsList[t];null===e&&(e=this._allPartsList[t]=this.getAllParts(t));let n=this._lengthsList[t];if(null===n){n=this._lengthsList[t]=new Array(e.length);for(const[t,r]of p().enumerate(e)){const e=t.length*this.monomerCharWidth;n[r]=e}}return[e,n]}getAllParts(t){const e=this.col.get(t),n=e?ot(e):[];return e?function(t,e){const n=[];for(let r=0;r<t.length;++r){const s=e.indexOf(t[r]),i=e.slice(0,s);n.push(i),n.push(t[r]),e=e.substring(s+t[r].length)}return n.push(e),n}(n,e):[]}getMonomer(t){let e=null;if(t.polymerType)e=this.monomerLib.getMonomer(t.polymerType,t.symbol);else for(const n of this.monomerLib.getPolymerTypes())if(e=this.monomerLib.getMonomer(n,t.symbol),e)break;return e}monomerLibOnChanged(t){this._lengthsList.fill(null),this._allPartsList.fill(null),this._editorList.fill(null)}static getOrCreate(t){return"bio-helmMonomerPlacer"in t.temp||(t.temp["bio-helmMonomerPlacer"]=new pt(t)),t.temp["bio-helmMonomerPlacer"]}setEditor(t,e){this._editorList[t]=e}getEditor(t){return this._editorList[t]}}class Ct extends s.GridCellRenderer{get name(){return"helm"}get cellType(){return"helm"}get defaultWidth(){return 400}get defaultHeight(){return 100}onMouseMove(t,e){try{let s=null;try{s=t.tableColumn}catch{}if(!s)return;const i=t.bounds,o=e.offsetX-i.x,l=e.offsetY-i.y,a=pt.getOrCreate(s),h=a.getEditor(t.tableRowIndex);let c,g=new Set;if(h)c=function(t,e,n,r){let s=null;function i(n){let s,i;for(let o=0;o<r.m.atoms.length;++o)if(!n.includes(o)){const n=r.m.atoms[o].p.x,l=r.m.atoms[o].p.y,a=Math.sqrt((t-n)**2+(e-l)**2);(void 0===i||i>a)&&(s=o,i=a)}return[s,i]}const[o,l]=i([]),[a,h]=i([o]);if(void 0!==o&&void 0!==l){const t=function(t){let e;switch(t.bio.type){case"HELM_BASE":case"HELM_SUGAR":case"HELM_LINKER":e="RNA";break;default:e="PEPTIDE"}return{symbol:t.elem,polymerType:e}}(r.m.atoms[o]);void 0!==a&&void 0!==h?l<.45*h&&(s=t):l<.35*n.bounds.height&&(s=t)}return s}(o,l,t,h);else{const e=ot(t.cell.value?it(t.cell.value):"");g=lt(e);const n=new Set(e);if(c=function(t,e,n,r){let s=null;const[i,o,l]=r.getCellAllPartsLengths(n.tableRowIndex);let a=0,h=Object.values(o).length-1,c=!1,g=0,u=0;if(t>l[0])for(;!c&&g<l.length;)u=Math.floor((h+a)/2),t>=l[u]&&t<=l[u+1]?(a=u,c=!0):t<l[u]?h=u-1:t>l[u+1]&&(a=u+1),a==h&&(c=!0),g++;return a=t>=l[a]?a:a-1,a>=0&&(s=function(t,e,n){let r;for(const s of n.getPolymerTypes())t.startsWith(s)&&(r={symbol:e,polymerType:s});return r||(r={symbol:e}),r}(i[0],i[a],r.monomerLib)),s}(o,0,t,a),c&&!n.has(c.symbol)&&(c=null),c){const t=a.monomerTextSizeMap[c.symbol];if(t){const e=i.height/2-(t.fontBoundingBoxAscent+t.fontBoundingBoxDescent)/2+1,n=e-t.fontBoundingBoxAscent,r=e+t.fontBoundingBoxDescent;(l<n||r<l)&&(c=null)}}}if(c)if(g.has(c.symbol))r.tooltip.show(r.divV([r.divText(`Monomer '${c.symbol}' not found.`),r.divText("Open the Context Panel, then expand Manage Libraries")]),e.x+16,e.y+16);else{const t=a.getMonomer(c);if(t){const s={autoCrop:!0,autoCropMargin:0,suppressChiralText:!0},i=n.chem.svgMol(t.smiles,void 0,void 0,s);r.tooltip.show(r.divV([r.divText(c.symbol),i]),e.x+16,e.y+16)}}else{if(0==g.size)return void r.tooltip.hide();{const t=p()(g.keys()).toArray().sort().filter(((t,e)=>e<3)).join(", ")+(g.size>3?", ...":"");r.tooltip.show(r.divV([r.divText("Monomers missed in monomer libraries:"),r.divText(t)]),e.x+16,e.y+16)}}}catch(t){const e=h(t);console.error("Helm: HelmCellRenderer.onMouseMove() error:\n"+e)}finally{e.preventDefault(),e.stopPropagation()}}render(t,e,n,s,i,o,l){t.save();try{let l=null;try{l=o.tableColumn}catch{}if(!l)return;const a=-1!==o.gridRow?o.grid:void 0,h="red",c="#404040",g="#C0C0C0",u=o.cell.value?it(o.cell.value):"",m=ot(u),f=new Set(m),d=lt(m),p=pt.getOrCreate(l);if(0==d.size){const t=o.element=r.div([],{style:{width:s-2+"px",height:i-2+"px",margin:"1px",backgroundColor:"#FFE0E0"}});t.setAttribute("dataformat","helm"),t.setAttribute("data",u),t.parentElement&&(o.grid?.canvas?.offsetLeft??0)>0&&(t.parentElement.style.left=`${(o.grid?.canvas?.offsetLeft??0)+t.parentElement.offsetLeft}px`);const e=new JSDraw2.Editor(t,{width:s,height:i,skin:"w8",viewonly:!0});return p.setEditor(o.tableRowIndex,e),void p.skipCell(o.tableRowIndex)}if(d.size>0){if(!a){const e=window.devicePixelRatio;i=28,t.canvas.height=i*e,t.canvas.style.height=`${i}px`}s=a?Math.min(a.canvas.width-e,s):t.canvas.width-e,t.beginPath(),t.rect(e,n,s,i),t.clip(),t.transform(1,0,0,1,e,n),t.font="12px monospace",t.textBaseline="top";const[r,l,u]=p.getCellAllPartsLengths(o.tableRowIndex);for(let e=0;e<r.length;++e){const n=r[e],o="."===n||n.endsWith("{")||n.startsWith("}")?g:d.has(n)?h:f.has(n)?c:g;t.fillStyle=o,dt(u[e],0,s,i,t,r[e],o,0,!0,1,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,p.monomerTextSizeMap)}}}finally{t.restore()}}}class At{constructor(){this.w=200,this.h=100,this.host=r.div([],{style:{width:`${this.w}px`,height:`${this.h}px`}}),this.editor=new JSDraw2.Editor(this.host,{width:this.w,height:this.h,viewonly:!0})}resizeEditor(t,e){this.editor.setSize(t,e)}}class bt{createHelmWebEditor(){return new At}createWebEditorApp(t,e){org.helm.webeditor.MolViewer.molscale=.8;const n=new scil.helm.App(t,{showabout:!1,mexfontsize:"90%",mexrnapinontab:!0,topmargin:20,mexmonomerstab:!0,sequenceviewonly:!1,mexfavoritefirst:!0,mexfilter:!0}),r=n.calculateSizes();n.canvas.resize(r.rightwidth-100,r.topheight-210);let s={width:r.rightwidth-100+"px",height:r.bottomheight+"px"};return scil.apply(n.sequence.style,s),scil.apply(n.notation.style,s),s={width:r.rightwidth+"px",height:r.bottomheight+n.toolbarheight+"px"},scil.apply(n.properties.parent.style,s),n.structureview.resize(r.rightwidth,r.bottomheight+n.toolbarheight),n.mex.resize(r.topheight-80),setTimeout((()=>{n.canvas.helm.setSequence(e,"HELM")}),200),n}static async getInstance(){let t=window.$helmHelper;return t||(window.$helmHelper=t=new bt),t}}const _t="smiles",wt="capGroupName",Tt="label";let Et=null;const yt=new s.Package;async function St(){return org.helm.webeditor.kCaseSensitive=!0,Promise.all([new Promise(((t,e)=>{dojo.ready((function(){t(null)}))})).then((()=>{window.dojox.gfx.svg.Text.prototype.getTextWidth=function(){const t=this.rawNode,e=t.parentNode,n=t.cloneNode(!0);n.style.visibility="hidden";let r=0;const s=n.firstChild.nodeValue;if(e.appendChild(n),""!=s){let t=100;for(;!r&&--t>0;)r=n.getBBox?parseInt(n.getBBox().width):68}return e.removeChild(n),r}})),n.functions.call("Bio:getBioLib")]).then((([t,e])=>{Et=e,Ot(),Et.onChanged.subscribe((t=>{try{Ot();const t=Et.getPolymerTypes(),e="Monomer lib updated:<br />"+(0==t.length?"empty":t.map((t=>`${t} ${Et.getMonomerSymbolsByType(t).length}`)).join("<br />"));n.shell.info(e)}catch(t){const e=h(t);console.error("Helm: initHelm monomerLib.onChanged() error:\n"+e)}}))})).catch((t=>{const e=t instanceof Error?t.message:t?t.toString():"Exception 'undefined'";n.shell.error(`Package 'Helm' init initHelm() error: ${e}`);const r=new Error(e);throw r.stack=t.stack,r}))}function Mt(){return Et}function Ot(){org.helm.webeditor.Monomers.clear(),Et.getPolymerTypes().forEach((t=>{Et.getMonomerSymbolsByType(t).forEach((e=>{let n=!1;const r=Et.getMonomer(t,e),s={id:e,m:r.molfile,n:r.name,na:r.naturalAnalog,rs:r.rgroups.length,type:r.polymerType,mt:r.monomerType,at:{}};if(r.rgroups.length>0){s.rs=r.rgroups.length;const t={};r.rgroups.forEach((e=>{t[e[Tt]]=e[wt]})),s.at=t}else null!=r[_t]?(s.rs=Object.keys(Rt(r[_t].toString())).length,s.at=Rt(r[_t].toString())):n=!0;n||org.helm.webeditor.Monomers.addOneMonomer(s)}))}));const t=n.shell.tv?.grid;t&&t.invalidate()}function Nt(){return new Ct}function vt(t,e,s){const i=lt(ot(t&&void 0===s?t.value:e));0===i.size?function(t,e,n){const s=r.div(),i=t.column,o=I.forColumn(i);t.rowIndex,org.helm.webeditor.MolViewer.molscale=.8;const l=new scil.helm.App(s,{showabout:!1,mexfontsize:"90%",mexrnapinontab:!0,topmargin:20,mexmonomerstab:!0,sequenceviewonly:!1,mexfavoritefirst:!0,mexfilter:!0}),a=l.calculateSizes();l.canvas.resize(a.rightwidth-100,a.topheight-210);let h={width:a.rightwidth-100+"px",height:a.bottomheight+"px"};scil.apply(l.sequence.style,h),scil.apply(l.notation.style,h),h={width:a.rightwidth+"px",height:a.bottomheight+l.toolbarheight+"px"},scil.apply(l.properties.parent.style,h),l.structureview.resize(a.rightwidth,a.bottomheight+l.toolbarheight),l.mex.resize(a.topheight-80),setTimeout((()=>{t&&void 0===n?l.canvas.helm.setSequence(t.value,"HELM"):l.canvas.helm.setSequence(e,"HELM")}),200),r.dialog({showHeader:!1,showFooter:!0}).add(s).onOK((()=>{const e=l.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");if(t)if(void 0===n)t.value=e;else{const r=o.convertHelmToFastaSeparator(e,n,o.separator);t.value=r}})).show({modal:!0,fullScreen:!0})}(t,e,s):1===i.size&&i.has(R[o.HELM])?n.shell.warning(`WebEditor doesn't support Helm with gaps '${R[o.HELM]}'.`):n.shell.warning(`Monomers ${Array.from(i).map((t=>`'${t}'`)).join(", ")} are absent! <br/>Please, upload the monomer library! <br/><a href="https://datagrok.ai/help/domains/bio/macromolecules" target="_blank">Learn more</a>`)}function Lt(t){vt(t.cell,void 0,void 0)}function Ht(t){const e=n.shell.tv.grid.dataFrame,r=e.columns.bySemType("Macromolecule"),i=I.forColumn(r);r.getTag(s.TAGS.UNITS)===o.HELM&&vt(e.currentCell,void 0,void 0);const l=i.getConverter(o.HELM)(t);vt(e.currentCell,l,r.getTag(s.TAGS.UNITS))}function xt(t){return function(t){const e=I.forColumn(t.cell.column),n=function(t,e){const n=it(e.isHelm()?t:e.getConverter(o.HELM)(t)),s=r.div([],{style:{width:"0",height:"0"}});document.documentElement.appendChild(s);try{const t=new JSDraw2.Editor(s,{viewonly:!0});t.setHelm(n);const e=t.getFormula(!0),r=Math.round(100*t.getMolWeight())/100,i=Math.round(100*t.getExtinctionCoefficient(!0))/100;return{formula:e.replace(/<sub>/g,"").replace(/<\/sub>/g,""),"molecular weight":r,"extinction coefficient":i}}finally{a()(s).empty(),s.remove()}}(t.value,e);return new s.Widget(r.tableFromMap(n))}(t)}function Rt(t){const e=t.match(/(?<=\[)[^\][]*(?=])/gm),n={};let r,s="";if(e)for(let t=0;t<e.length;t++)if(null!=e[t]&&/\d/.test(e[t])){r=e[t][e[t].length-1],e[t]=e[t].replace(/[0-9]/g,"");for(let n=0;n<e[t].length;n++)":"!=e[t][n]&&(s+=e[t][n]);n["R"+r]=s,s=""}return n}function It(t){const e=s.Column.string("mols",t.length),n=r.div([],{style:{width:"0",height:"0"}});document.documentElement.appendChild(n);try{const r=new JSDraw2.Editor(n,{viewonly:!0});return e.init((e=>(r.setHelm(t.get(e)),r.getMolfile()))),e}finally{a()(n).empty(),n.remove()}}async function Pt(){return bt.getInstance()}helm=e})();
|
|
1
|
+
var helm;(()=>{"use strict";var t={460:(t,e,n)=>{n.d(e,{wW:()=>m});var r,s,i,o,l,a,h,c=n(888);n(200),n(852),n(923),n(688);class u{constructor(t,e=!1){if(this._length=0,this._version=0,this._updateLevel=0,this._selectedCount=0,this._selectedCountVersion=-1,this._selectedIndexesVersion=-1,this._versionedName="",this._versionedNameVersion=-1,this.SHRINK_THRESHOLD=256,"number"==typeof t){const n=t,r=u._createBuffer(n);if(e)for(let t=0;t<r.length;t++)r[t]=-1;this._data=r,this._length=n}else{if(!(t instanceof Uint32Array))throw new Error("Invalid constructor");this._data=t,this._length=e}}getRawData(){return this._data}assureGoez(t,e){if(t<0)throw new Error(`${e} should be greater than zero`)}assureInRange(t,e,n,r){if(t<e||t>n)throw new Error(`Argument ${r} (${t}) out of range (${e}, ${n})`)}copy(t,e,n){for(let r=0;r<n;r++)e[r]=t[r]}copyFrom(t){if(this._length!=t._length)throw new Error(`Lengths differ (${this._length} != ${t._length})`);this.copy(t._data,this._data,this.lengthInInts),this._version++}get length(){return this._length}get buffer(){return this._data}set buffer(t){this._data=t,this._version++}get version(){return this._version}set version(t){this._version=t}incrementVersion(t=!0){this._version++}get lengthInInts(){return Math.floor((this._length+31)/32)}get versionedName(){return this._version==this._versionedNameVersion?this._versionedName:""}set versionedName(t){this._versionedName=t,this._versionedNameVersion=this._version}get self(){return this}setLength(t){if(t<0)throw new Error("should be >= 0");if(t==this._length)return;const e=Math.floor((t+31)/32);if(e>this._data.length||e+this.SHRINK_THRESHOLD<this._data.length){const t=new Uint32Array(e);this.copy(this._data,t,e>this._data.length?this._data.length:e),this._data=t}t>this._length&&(this._length%32>0&&(this._data[this.lengthInInts-1]&=(1<<(this._length%32&31))-1),this._data.fill(0,this.lengthInInts,e)),this._length=t,this._version++}static fromAnd(t,e){if(t._length!=e._length)throw new Error(`Lengths differ (${t._length} != ${e._length})`);const n=new u(t._length);n._length=t._length,n._data=u._createBuffer(n._length),n._version=0;const r=t.lengthInInts;for(let s=0;s<r;s++)n._data[s]=t._data[s]&e._data[s];return n}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new u(t.length);e._version=0;for(let n=0;n<e._length;n++)t[n]&&(e._data[Math.floor(n/32)]|=1<<(n%32&31));return e}static fromSeq(t,e){const n=new u(t);for(let r=0;r<t;++r)n.setBit(r,e(r));return n._version=0,n}static fromString(t){return u.fromSeq(t.length,(e=>"1"==t.charAt(e)))}static fromUint32Array(t,e){const n=new u(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new u(8*e);n._data=new Uint32Array(Math.floor((e+3)/4)),n._length=8*e;let r=0,s=0;for(;e-s>=4;)n._data[r++]=255&t[s]|(255&t[s+1])<<8|(255&t[s+2])<<16|(255&t[s+3])<<24,s+=4;return e-s==3&&(n._data[r]=(255&t[s+2])<<16),e-s==2&&(n._data[r]|=(255&t[s+1])<<8),e-s==1&&(n._data[r]|=255&t[s]),n._version=0,n}toString(){return`${this._length} bits, ${this.countBits(!0)} set`}equals(t){if(this==t)return!0;if(null==t)return!1;if(this._length!=t._length)return!1;if(0==this._length)return!0;for(let e=0;e<this._data.length-1;e++)if(this._data[e]!=t._data[e])return!1;for(let e=8*(this._data.length-1);e<this._length;e++)if(this.getBit(e)!=t.getBit(e))return!1;return!0}clone(){const t=new u(0,!1);return t._data=Uint32Array.from(this._data),t._length=this._length,t._version=this._version,t}init(t,e){this.setAll(!1,!1);for(let e=0;e<this._length;e++)t(e)&&(this._data[Math.floor(e/32)]|=1<<(e%32&31));return this.incrementVersion(e),this}invert(t=!0){for(let t=0;t<this._data.length;t++)this._data[t]^=-1;this.incrementVersion(t)}setAll(t,e=!1){const n=t?-1:0,r=this.lengthInInts;for(let t=0;t<r;t++)this._data[t]=n;this.incrementVersion(e)}setIndexes(t,e=!0,n=!0,r=!0){n&&this.setAll(!e,!1);for(const n of t)this.setFast(n,e);this.incrementVersion(r)}everyIndex(t,e=!0){for(const n of t)if(this.getBit(n)!=e)return!1;return!0}anyIndex(t,e=!0){for(const n of t)if(this.getBit(n)==e)return!0;return!1}setWhere(t,e=!0,n=!0,r=!0,s=!0){if(n&&s&&this.setAll(!e,!1),s)for(let n=0;n<this._length;n++)t(n)&&this.setFast(n,e);else for(let n=0;n<this._length;n++)this.setFast(n,t(n)?e:!e);this.incrementVersion(r)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let r=t;r<e;++r)n.push(this.getBit(r));return u.fromValues(n)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let r=t;r<e;++r)n.push(this.getBit(r));return n}setRange(t,e,n,r=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const s=Math.min(t,e),i=Math.max(t,e);if(n)for(let t=s;t<=i;t++)this.setTrue(t);else for(let t=s;t<=i;t++)this.setFalse(t);return this.incrementVersion(r),this}setRandom(t,e,n=!0){if(t<0||t>this._length)throw new Error("n must be >= 0 && <= Count");t>this._length/2&&this.setRandom(this._length-t,!e),this.setAll(!e);for(let n=0;n<t;){const t=Math.floor(Math.random()*this._length);this.getBit(t)!=e&&(this.setFast(t,e),n++)}this.incrementVersion(n)}and(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]&=t._data[e];return this.incrementVersion(e),this}andNot(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");const n=this.lengthInInts;for(let e=0;e<n;e++)this._data[e]&=~t._data[e];return this.incrementVersion(e),this}notAnd(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]=~this._data[e]&t._data[e];return this.incrementVersion(e),this}not(t=!0){for(let t=0,e=this.lengthInInts;t<e;t++)this._data[t]=~this._data[t];return this.incrementVersion(t),this}or(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]|=t._data[e];return this.incrementVersion(e),this}xor(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]^=t._data[e];return this.incrementVersion(e),this}insertAt(t,e,n=!1){if(this.assureInRange(t,0,this._length,"pos"),0==e)return;const r=this._length;this.setLength(this._length+e);for(let n=r-1;n>=t;n--)this.setBit(n+e,this.getBit(n));for(let r=t;r<t+e;r++)this.setBit(r,n)}removeAt(t,e=1){if(e<0)throw new Error("n cannot be negative");if(this.assureInRange(t,0,this._length-e,"pos"),this.contains(!0))for(let n=t;n<this._length-e;n++)this.setBit(n,this.getBit(n+e));this.setLength(this._length-e)}removeByMask(t,e=!0){if(this._length!=t.length)throw new Error("length != mask.length");if(t==this)this.setLength(t.countBits(!e)),this.setAll(!e);else{let n=0;for(let r=-1;-1!=(r=t.findNext(r,!e));)this.setFast(n++,this.getBit(r));this._length=n,this._version++}return this}getBit(t){return 0!=(this._data[Math.floor(t/32)]&1<<(31&t))}setBit(t,e,n=!0){this.setFast(t,e),this._version++}setFast(t,e){e?this._data[Math.floor(t/32)]|=1<<(31&t):this._data[Math.floor(t/32)]&=~(1<<(31&t))}setTrue(t){this._data[Math.floor(t/32)]|=1<<(31&t)}setFalse(t){this._data[Math.floor(t/32)]&=~(1<<(31&t))}trueCount(){return this.countBits(!0)}falseCount(){return this.countBits(!1)}countBits(t){if(0==this._length)return 0;if(this._selectedCountVersion!=this._version){this._selectedCount=0;const t=this.lengthInInts;let e=0;for(;e<t-1;e++)for(let t=this._data[e];0!=t;t>>>=8)this._selectedCount+=u._onBitCount[255&t];let n=this._data[e];const r=31&this._length;for(0!=r&&(n&=~(4294967295<<r));0!=n;n>>>=8)this._selectedCount+=u._onBitCount[255&n];this._selectedCountVersion=this._version}return t?this._selectedCount:this._length-this._selectedCount}countWhere(t){let e=0;if(this.trueCount()==this._length)for(let n=0;n<this._length;n++)e+=t(n)?1:0;else for(let n=-1;-1!=(n=this.findNext(n,!0));)e+=t(n)?1:0;return e}andWithCountBits(t,e){if(0==this._length)return 0;let n=0;const r=this.lengthInInts;let s=0;for(;s<r-1;s++)for(let e=this._data[s]&t._data[s];0!=e;e>>>=8)n+=u._onBitCount[255&e];let i=this._data[s]&t._data[s];const o=31&this._length;for(0!=o&&(i&=~(4294967295<<o));0!=i;i>>>=8)n+=u._onBitCount[255&i];return e?n:this._length-n}clear(){this.setLength(0)}contains(t){return this.findNext(-1,t)>=0}get allTrue(){return this.countBits(!0)==this._length}get allFalse(){return this.countBits(!1)==this._length}get anyTrue(){return this.countBits(!0)>0}get anyFalse(){return this.countBits(!1)>0}findNext(t,e=!0){if(this.assureInRange(t,-1,this._length,"index"),t>=this._length-1)return-1;let n=31&(t=t<0?0:t+1);const r=this.lengthInInts;for(let s=Math.floor(t/32);s<r;s++){let r=e?this._data[s]:~this._data[s];if(0!=n)r&=4294967295<<n&4294967295,n=0;else if(!e&&-4294967296==r)continue;for(let e=0;0!=r;e+=8,r>>>=8){const n=u._firstOnBit[255&r];if(n>=0)return(t=n+32*s+e)>=this._length?-1:t}}return-1}findPrev(t,e=!0){if(0==t)return-1;this.assureInRange(t,-1,this._length,"index");let n=1+(t=t<0?this._length-1:t-1)&31;for(let r=Math.floor(t/32);r>=0;r--){let t=e?this._data[r]:~this._data[r];0!=n&&(t&=~(4294967295<<n),n=0);for(let e=24;0!=t;e-=8,t<<=8){const n=u._lastOnBit[t>>>24];if(n>=0)return n+32*r+e}}return-1}}u._onBitCount=Int8Array.from([0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8]),u._firstOnBit=Int8Array.from([-1,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0]),u._lastOnBit=Int8Array.from([-1,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7]),function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan",t.Onehot="One-Hot"}(r||(r={})),function(t){t.Euclidean="Euclidean"}(s||(s={})),function(t){t.Tanimoto="Tanimoto",t.Dice="Dice",t.Asymmetric="Asymmetric",t.BraunBlanquet="Braun-Blanquet",t.Cosine="Cosine",t.Kulczynski="Kulczynski",t.McConnaughey="Mc-Connaughey",t.RogotGoldberg="Rogot-Goldberg",t.Russel="Russel",t.Sokal="Sokal",t.Hamming="Hamming",t.Euclidean="Euclidean"}(i||(i={})),function(t){t.TanimotoIntArray="TanimotoIntArray"}(o||(o={})),function(t){t.Vector="Vector",t.String="String",t.BitArray="BitArray",t.MacroMolecule="MacroMolecule",t.Number="Number",t.IntArray="IntArray",t.NumberArray="NumberArray"}(l||(l={})),function(t){t.Difference="Difference"}(a||(a={})),function(t){t.CommonItems="Common Items"}(h||(h={}));var g=n(384);async function m(){const t=c.Func.find({package:"Bio",name:"getMonomerLibHelper"});if(0===t.length)throw new Error('Package "Bio" must be installed for MonomerLibHelper.');return(await t[0].prepare().call()).getOutputParamValue()}i.Tanimoto,i.Dice,i.Asymmetric,i.BraunBlanquet,i.Cosine,i.Kulczynski,i.McConnaughey,i.RogotGoldberg,i.Russel,i.Sokal,i.Hamming,i.Euclidean,i.Tanimoto,i.Dice,i.Asymmetric,i.BraunBlanquet,i.Cosine,i.Kulczynski,i.McConnaughey,i.RogotGoldberg,i.Russel,i.Sokal,i.Hamming,i.Euclidean,i.Tanimoto,i.Dice,i.Cosine,i.Tanimoto,i.Asymmetric,i.Cosine,i.Sokal,g.Y.HAMMING,g.Y.LEVENSHTEIN,g.Y.MONOMER_CHEMICAL_DISTANCE,g.Y.NEEDLEMANN_WUNSCH},852:(t,e,n)=>{n.d(e,{E1:()=>r,cT:()=>s});const r="p",s=new RegExp(`[rd]\\((\\w)\\)${r}?`,"g")},136:(t,e,n)=>{n.d(e,{YF:()=>i,eQ:()=>o,qD:()=>r,y6:()=>a});var r,s=n(923);!function(t){t.FASTA="fasta",t.SEPARATOR="separator",t.HELM="helm"}(r||(r={}));const i=", ",o=/(?:\[([A-Za-z0-9_\-,()]+)\])|([A-Za-z\-])/g,l=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"])}}},a=[new s._u("PT",l.fasta.peptide,.5),new s._u("DNA",l.fasta.dna,.55),new s._u("RNA",l.fasta.rna,.55)]},736:(t,e,n)=>{n.d(e,{YF:()=>r.YF,g9:()=>s.g9,gX:()=>s.gX,oB:()=>s.oB,qD:()=>r.qD,y6:()=>r.y6});var r=n(136),s=n(502)},923:(t,e,n)=>{n.d(e,{AD:()=>i,_u:()=>s,yK:()=>r});const r="";class s{constructor(t,e,n){this.name=t,this.alphabet=e,this.cutoff=n}}class i extends s{constructor(t,e,n){super(t.name,t.alphabet,t.cutoff),this.freq=e,this.similarity=n}}},502:(t,e,n)=>{n.d(e,{Mx:()=>b,o5:()=>N,gX:()=>T,uw:()=>v,oB:()=>w,lh:()=>_,g9:()=>S});var r=n(888),s=n(848),i=n.n(s),o=n(923),l=n(136),a=n(688);class h extends Float32Array{}function c(t){let e=0;for(let n=0;n<t.length;n++)e+=t[n]*t[n];return Math.sqrt(e)}class u{static makePalette(t,e=!1,n=u){const r={};return t.forEach((t=>{const n=t[0],s=t[1];n.forEach(((t,n)=>{r[t]=this.colourPalette[s][e?0:n]}))})),new n(r)}constructor(t){this._palette=t}get(t){return this._palette[t]}}u.undefinedColor="rgb(100,100,100)",u.colourPalette={orange:["rgb(255,187,120)","rgb(245,167,100)","rgb(235,137,70)","rgb(205, 111, 71)"],all_green:["rgb(44,160,44)","rgb(74,160,74)","rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)","rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],all_blue:["rgb(31,119,180)","rgb(23,190,207)","rgb(122, 102, 189)","rgb(158,218,229)","rgb(141, 124, 217)","rgb(31, 120, 150)"],magenta:["rgb(162,106,192)","rgb(197,165,224)","rgb(208,113,218)"],red:["rgb(214,39,40)","rgb(255,152,150)"],st_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(31,119,180)"],dark_blue:["rgb(31,119,180)","rgb(31, 120, 150)"],light_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(108, 218, 229)","rgb(23,190,227)"],lilac_blue:["rgb(124,102,211)","rgb(149,134,217)","rgb(97, 81, 150)"],dark_green:["rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)"],green:["rgb(44,160,44)","rgb(74,160,74)"],light_green:["rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],st_green:["rgb(44,160,44)","rgb(152,223,138)","rgb(39, 174, 96)","rgb(74,160,74)"],pink:["rgb(247,182,210)"],brown:["rgb(140,86,75)","rgb(102, 62, 54)"],gray:["rgb(127,127,127)","rgb(199,199,199)","rgb(196,156,148)","rgb(222, 222, 180)"],yellow:["rgb(188,189,34)"],white:["rgb(230,230,230)"]};class g extends u{static get Lesk(){return void 0===this.lesk&&(this.lesk=this.makePalette([[["G","A","S","T"],"orange"],[["C","V","I","L","P","F","Y","M","W"],"all_green"],[["N","Q","H"],"magenta"],[["D","E"],"red"],[["K","R"],"all_blue"]],!1,g)),this.lesk}static get GrokGroups(){return void 0===this.grokGroups&&(this.grokGroups=this.makePalette([[["C","U"],"yellow"],[["G","P"],"red"],[["A","V","I","L","M","F","Y","W"],"all_green"],[["R","H","K"],"light_blue"],[["D","E"],"dark_blue"],[["S","T","N","Q"],"orange"]],!1,g)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new g({D:"#E60A0A",E:"#E60A0A",C:"#E6E600",M:"#E6E600",K:"#145AFF",R:"#145AFF",S:"#FA9600",T:"#FA9600",F:"#3232AA",Y:"#3232AA",N:"#00DCDC",Q:"#00DCDC",G:"#EBEBEB",L:"#0F820F",V:"#0F820F",I:"#0F820F",A:"#C8C8C8",W:"#B45AB4",H:"#8282D2",P:"#DC9682",others:"#BEA06E"})),this.rasMol}get(t){const e=t in g.aaSynonyms?g.aaSynonyms[t]:t;return super.get(e)}}g.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class m{static getPalette(t="grok"){switch(t){case"grok":return g.GrokGroups;case"lesk":return g.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,n="",r="";for(const s of t)"("==s?e++:")"==s?e--:e?n+=s:r+=s;return isNaN(parseInt(n))?[r,n]:[r,""]}static getColorAAPivot(t="",e="grok"){const n=this.getPalette(e);let[r,s]=this.getInnerOuter(t);if(r=r.length>6?`${r.slice(0,3)}...`:r,s=s.length>6?`${s.slice(0,3)}...`:s,1==t.length||"("==t[1]){const e=t[0]?.toUpperCase();return e in n?[n.get(e),e,s,1]:[this.undefinedColor,r,s,1]}if("d"==t[0]&&t[1]in n&&(2==t.length||"("==t[2])){const e=t[1]?.toUpperCase();return e in n?[n.get(e),e,s,2]:[this.undefinedColor,r,s,2]}if(t.substring(0,3)in this.AAFullNames&&(3==t.length||"("==t[3])){const e=this.AAFullNames[t.substring(0,3)];return e in n?[n.get(e),e,s,3]:[this.undefinedColor,r,s,3]}if(t[0]?.toLowerCase()==t[0]&&t.substring(1,3)in this.AAFullNames&&(4==t.length||"("==t[4])){const e=this.AAFullNames[t.substring(1,3)];return e in n?[n.get(e),e,s,4]:[this.undefinedColor,r,s,4]}return[this.undefinedColor,r,s,0]}}m.SemType="Aminoacids",m.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",m.undefinedColor="rgb(100,100,100)",m.Names={G:"Glycine",L:"Leucine",Y:"Tyrosine",S:"Serine",E:"Glutamic acid",Q:"Glutamine",D:"Aspartic acid",N:"Asparagine",F:"Phenylalanine",A:"Alanine",K:"Lysine",R:"Arginine",H:"Histidine",C:"Cysteine",V:"Valine",P:"Proline",W:"Tryptophan",I:"Isoleucine",M:"Methionine",T:"Threonine"},m.AASmiles={G:"NCC(=O)O",L:"N[C@H](CC(C)C)C(=O)O",Y:"NC(CC1=CC=C(O)C=C1)C(=O)O",S:"NC(CO)C(=O)O",E:"N[C@@H](CCC(O)=O)C(=O)O",Q:"N[C@@H](CCC(N)=O)C(=O)O",D:"N[C@@H](CC(O)=O)C(=O)O",N:"N[C@@H](CC(N)=O)C(=O)O",F:"NC(CC1=CC=CC=C1)C(=O)O",A:"N[C@H](C)C(=O)O",K:"NC(CCCCN)C(=O)O",R:"N[C@H](CCCNC(=N)C)C(=O)O",H:"NC(CC1=CN=C[N]1)C(=O)O",C:"N[C@@H](CS)C(=O)O",V:"NC(C(C)C)C(=O)O",P:"N(CCC1)C1C(=O)O",W:"N[C@@H](Cc1c2ccccc2n([H])c1)C(=O)O",I:"N[C@H]([C@H](C)CC)C(=O)O",M:"NC(CCSC)C(=O)O",T:"NC(C(O)C)C(=O)O"},m.AASmilesTruncated={G:"*C*",L:"CC(C)C[C@H](*)*",Y:"C1=CC(=CC=C1CC(*)*)O",S:"OCC(*)C*",E:"*[C@@H](CCC(O)=O)*",Q:"*N[C@@H](CCC(N)=O)*",D:"*[C@@H](CC(O)=O)*",N:"*[C@@H](CC(N)=O)*",F:"C1=CC=C(C=C1)CC(*)*",A:"C[C@H](*)*",K:"C(CCN)CC(*)*",R:"*[C@H](CCCNC(=N)C)*",H:"C1=C(NC=N1)CC(*)*",C:"C([C@@H](*)*)S",V:"CC(C)C(*)*",P:"C1CCN(*)C1*",W:"*[C@@H](Cc1c2ccccc2n([H])c1)*",I:"CC[C@H](C)[C@H](*)*",M:"CSCCC(*)*",T:"CC(O)C(*)*"},m.AAFullNames={Ala:"A",Arg:"R",Asn:"N",Asp:"D",Cys:"C",Gln:"Q",Glu:"E",Gly:"G",His:"H",Ile:"I",Leu:"L",Lys:"K",Met:"M",Phe:"F",Pro:"P",Ser:"S",Thr:"T",Trp:"W",Tyr:"Y",Val:"V"};class f{}f.SemType="Nucleotides",f.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",f.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"};class d{static hashCode(t){let e=0;if(0===t.length)return e;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e}}class p{}class C extends p{static buildPalette(){return[].concat(...Object.values(u.colourPalette))}get(t){const e=d.hashCode(t)%C.palette.length;return function(t){if(null==t)return"rgb(100,100,100)";const e=r.Color.fromHtml(t),n=r.Color.g(e),s=r.Color.r(e),i=r.Color.b(e),o=Math.sqrt(Math.pow(0-s,2)+Math.pow(0-n,2)+Math.pow(0-i,2));return o>210?`rgb(${s/o*210},${n/o*210},${i/o*210})`:r.Color.toRgb(e)}(C.palette[e])}}C.palette=C.buildPalette();class b{get length(){return this.mList.length}get canonicals(){return this.mList}get originals(){return this.mList}isGap(t){return this.getOriginal(t)===this.gapOriginalMonomer}getCanonical(t){if(this.length<=t)throw new Error("Index out of bounds");return this.mList[t]}getOriginal(t){if(this.length<=t)throw new Error("Index out of bounds");return this.mList[t]}constructor(t,e){this.mList=t,this.gapOriginalMonomer=e}}class A{get length(){return this.seqS.length}get canonicals(){return this.seqS}get originals(){return this.seqS}isGap(t){return this.getOriginal(t)===a.oh[l.qD.FASTA]}getCanonical(t){if(this.length<=t)throw new Error("Index out of bounds");return this.isGap(t)?o.yK:this.seqS[t]}getOriginal(t){if(this.length<=t)throw new Error("Index out of bounds");return this.seqS[t]}constructor(t){this.seqS=t}}const w=t=>{const e=i()(t.toString().matchAll(l.eQ)).map((t=>t[2]??t[1])).toArray();return new b(e,a.oh[l.qD.FASTA])},_=t=>t?new A(t):new b([],a.oh[l.qD.FASTA]);function T(t,e=void 0){return n=>{if(n){const r=n.replaceAll('"-"',"").replaceAll("'-'","").split(t,e);return new b(r,a.oh[l.qD.SEPARATOR])}return new b([],a.oh[l.qD.SEPARATOR])}}const y=/(PEPTIDE1|DNA1|RNA1)\{([^}]+)}/g,E=/\[([^\[\]]+)]/g,S=t=>{y.lastIndex=0;const e=y.exec(t.toString()),n=e?e[2]:null,r=n?n.split("."):[];return new b(r.map((t=>{E.lastIndex=0;const e=E.exec(t);return e&&e.length>=2?e[1]:t})),a.oh[l.qD.HELM])},M=/([^\W_]+)/g;function v(t,e){if(t.length<=e)return t;const n=t.match(M),r=t.length>e||(n?.length??0)>1,s=n?.[0]??" ";return r?s.substring(0,e-1)+"…":s}function N(t,e,n="-"){const r=e.map((e=>{const r=function(t,e,n="-"){const r=new Set([...new Set(Object.keys(t)),...e]);r.delete(n);const s=[],i=[];for(const n of r)s.push(n in t?t[n]:0),i.push(e.has(n)?1:0);const o=new h(s),l=new h(i);return function(t,e){if(t.length!=e.length)throw new Error("The dimensionality of the vectors must match");let n=0;for(let r=0;r<t.length;r++)n+=t[r]*e[r];return n}(o,l)/(c(o)*c(l))}(t,e.alphabet,n);return new o.AD(e,t,r)}));let s;const i=Math.max(...r.map((t=>t.similarity>t.cutoff?t.similarity:-1)));return s=i>0?r.find((t=>t.similarity===i)).name:"UN",s}},688:(t,e,n)=>{n.d(e,{YL:()=>f,oh:()=>m});var r=n(888),s=n(848),i=n.n(s),o=n(736),l=n(923),a=n(502),h=n(384),c=n(460),u=n(852);const g=new class{constructor(){this.seqHandler="seq-handler",this.notationProvider="seq-handler.notation-provider"}},m={[o.qD.FASTA]:"-",[o.qD.SEPARATOR]:"",[o.qD.HELM]:"*"};class f{constructor(t){if(this._splitter=null,this.cached=!0,this._splitted=null,this.columnVersion=null,this._stats=null,this._maxLength=null,this._posList=null,this._joiner=void 0,t.type!==r.TYPE.STRING)throw new Error(`Unexpected column type '${t.type}', must be '${r.TYPE.STRING}'.`);this._column=t;const e=this._column.getTag(r.TAGS.UNITS);if(null==e)throw new Error("Units are not specified in column");if(this._units=e,this._notation=this.getNotation(),this._defaultGapOriginal=this.isFasta()?m[o.qD.FASTA]:this.isHelm()?m[o.qD.HELM]:m[o.qD.SEPARATOR],!this.column.tags.has("aligned")||!this.column.tags.has("alphabet")||!this.column.tags.has(".alphabetIsMultichar")&&!this.isHelm()&&"UN"===this.alphabet)if(this.isFasta())f.setUnitsToFastaColumn(this);else if(this.isSeparator()){const e=t.getTag("separator");f.setUnitsToSeparatorColumn(this,e)}else{if(!this.isHelm())throw new Error(`Unexpected units '${this.column.getTag(r.TAGS.UNITS)}'.`);f.setUnitsToHelmColumn(this)}if(!this.column.tags.has(".alphabetIsMultichar"))if(this.isHelm())this.column.setTag(".alphabetIsMultichar","true");else if(["UN"].includes(this.alphabet))throw new Error(`For column '${this.column.name}' of alphabet '${this.alphabet}' tag '.alphabetIsMultichar' is mandatory.`);this.notationProvider=this.column.temp[g.notationProvider]??null,this.columnVersion=this.column.version}static setUnitsToFastaColumn(t){if(t.column.semType!==r.SEMTYPE.MACROMOLECULE||t.column.getTag(r.TAGS.UNITS)!==o.qD.FASTA)throw new Error(`The column of notation '${o.qD.FASTA}' must be '${r.SEMTYPE.MACROMOLECULE}'.`);t.column.setTag(r.TAGS.UNITS,o.qD.FASTA),f.setTags(t)}static setUnitsToSeparatorColumn(t,e){if(t.column.semType!==r.SEMTYPE.MACROMOLECULE||t.column.getTag(r.TAGS.UNITS)!==o.qD.SEPARATOR)throw new Error(`The column of notation '${o.qD.SEPARATOR}' must be '${r.SEMTYPE.MACROMOLECULE}'.`);if(!e)throw new Error(`The column of notation '${o.qD.SEPARATOR}' must have the separator tag.`);t.column.setTag(r.TAGS.UNITS,o.qD.SEPARATOR),t.column.setTag("separator",e),f.setTags(t)}static setUnitsToHelmColumn(t){if(t.column.semType!==r.SEMTYPE.MACROMOLECULE)throw new Error(`The column of notation '${o.qD.HELM}' must be '${r.SEMTYPE.MACROMOLECULE}'`);t.column.setTag(r.TAGS.UNITS,o.qD.HELM),f.setTags(t)}static setTags(t){const e=t.column.getTag(r.TAGS.UNITS),n=t.stats;if(Object.keys(n.freq).some((t=>t.length>1)),[o.qD.FASTA,o.qD.SEPARATOR].includes(e)){if(!t.column.getTag("alphabet")&&0===Object.keys(n.freq).length)throw new Error("Alphabet is empty and not annotated.");let e=t.column.getTag("aligned");null===e&&(e=n.sameLength?"SEQ.MSA":"SEQ",t.column.setTag("aligned",e));let r=t.column.getTag("alphabet");if(null===r&&(r=(0,a.o5)(n.freq,o.y6),t.column.setTag("alphabet",r)),"UN"===r){const e=Object.keys(n.freq).length,r=Object.keys(n.freq).some((t=>t.length>1));t.column.setTag(".alphabetSize",e.toString()),t.column.setTag(".alphabetIsMultichar",r?"true":"false")}}}get column(){return this._column}get length(){return this._column.length}get units(){return this._units}get notation(){return this._notation}get defaultGapOriginal(){return this._defaultGapOriginal}get separator(){const t=this.column.getTag("separator")??void 0;if(this.notation===o.qD.SEPARATOR&&void 0===t)throw new Error(`Separator is mandatory for column '${this.column.name}' of notation '${this.notation}'.`);return t}get aligned(){const t=this.column.getTag("aligned");if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag aligned not set");return t}get alphabet(){const t=this.column.getTag("alphabet");if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag alphabet not set");return t}get helmCompatible(){return this.column.getTag(".isHelmCompatible")}getAlphabetSize(){if(this.notation==o.qD.HELM||"UN"==this.alphabet){const t=this.column.getTag(".alphabetSize");let e;if(t)e=parseInt(t);else{const t=this.stats;e=Object.keys(t.freq).length}return e}switch(this.alphabet){case"PT":return 20;case"DNA":case"RNA":return 4;case"NT":return console.warn("Unexpected alphabet 'NT'."),4;default:throw new Error(`Unexpected alphabet '${this.alphabet}'.`)}}getAlphabetIsMultichar(){return this.notation===o.qD.HELM||"UN"===this.alphabet&&"true"===this.column.getTag(".alphabetIsMultichar")}getSplitted(t){if(this.cached){this.column.version===this.columnVersion&&null!==this._splitted||(this.columnVersion=this.column.version,this._splitted=new Array(this.column.length));let e=this._splitted[t]?this._splitted[t].deref():void 0;if(!e){const n=this.column.get(t);e=this.splitter(n),this._splitted[t]=new WeakRef(e)}return e}{const e=this.column.get(t);return this.splitter(e)}}get stats(){if(null===this._stats){const t={};let e=!0,n=null;const r=this.column.length;for(let s=0;s<r;++s){const r=this.getSplitted(s);null==n?n=r.length:r.length!==n&&(e=!1);for(const e of r.canonicals)e in t||(t[e]=0),t[e]+=1}this._stats={freq:t,sameLength:e}}return this._stats}get maxLength(){return null===this._maxLength&&(this._maxLength=0===this.column.length?0:Math.max(...i().count(0).take(this.column.length).map((t=>this.getSplitted(t).length)))),this._maxLength}get posList(){if(null===this._posList){const t=this.column.getTag(".positionNames");this._posList=t?t.split(o.YF).map((t=>t.trim())):i().count(1).take(this.maxLength).map((t=>t.toString())).toArray()}return this._posList}isFasta(){return this.notation===o.qD.FASTA}isSeparator(){return this.notation===o.qD.SEPARATOR}isHelm(){return this.notation===o.qD.HELM}isRna(){return"RNA"===this.alphabet}isDna(){return"DNA"===this.alphabet}isPeptide(){return"PT"===this.alphabet}isMsa(){return!!this.aligned&&this.aligned.toUpperCase().includes("MSA")}isHelmCompatible(){return"true"===this.helmCompatible}isGap(t){return!t||t===this._defaultGapOriginal}getNotation(){if(this.units.toLowerCase().startsWith(o.qD.FASTA))return o.qD.FASTA;if(this.units.toLowerCase().startsWith(o.qD.SEPARATOR))return o.qD.SEPARATOR;if(this.units.toLowerCase().startsWith(o.qD.HELM))return o.qD.HELM;throw new Error(`Column '${this.column.name}' has unexpected notation '${this.units}'.`)}getHelmWrappers(){return[this.isDna()||this.isRna()||this.isHelmCompatible()?"RNA1{":"PEPTIDE1{",this.isDna()?"d(":this.isRna()?"r(":"",this.isDna()||this.isRna()?")p":"","}$$$$"]}getNewColumn(t,e,n,s){const i=this.column,l=t.toLowerCase()+"("+i.name+")",a=n??i.dataFrame.columns.getUnusedName(l),h=r.Column.fromList("string",a,s??new Array(this.column.length).fill(""));if(h.semType=r.SEMTYPE.MACROMOLECULE,h.setTag(r.TAGS.UNITS,t),t===o.qD.SEPARATOR){if(!e)throw new Error(`Notation '${o.qD.SEPARATOR}' requires separator value.`);h.setTag("separator",e)}h.setTag(r.TAGS.CELL_RENDERER,"sequence");const c=i.getTag("aligned");c&&h.setTag("aligned",c);let u=i.getTag("alphabet");u||this.notation!==o.qD.HELM||t===o.qD.HELM||(u="UN"),null!=u&&h.setTag("alphabet",u);let g=i.getTag(".alphabetSize");null!=u&&g&&h.setTag(".alphabetSize",g);const m=i.getTag(".alphabetIsMultichar");return null!=u&&void 0!==m&&h.setTag(".alphabetIsMultichar",m),t==o.qD.HELM&&(g=this.getAlphabetSize().toString(),h.setTag(".alphabetSize",g)),h}getNewColumnFromList(t,e){return this.getNewColumn(this.notation,this.separator,t,e)}static getNewColumn(t){const e=f.forColumn(t),n=e.notation;return e.getNewColumn(n)}static unitsStringIsValid(t){return t=t.toLowerCase(),[o.qD.FASTA,o.qD.SEPARATOR,o.qD.HELM].some((e=>t.startsWith(e.toLowerCase())))}static getNewColumnFromParams(t,e,n){if(!f.unitsStringIsValid(n))throw new Error("Invalid format of 'units' parameter");const s=r.Column.fromList("string",e,new Array(t).fill(""));return s.semType=r.SEMTYPE.MACROMOLECULE,s.setTag(r.TAGS.UNITS,n),s}getSplitter(t){let e=null;if(e=this.notationProvider?this.notationProvider.splitter:null,e)return e;if(this.units.toLowerCase().startsWith(o.qD.FASTA))return null===this.column.getTag("alphabet")||this.getAlphabetIsMultichar()?o.oB:a.lh;if(this.units.toLowerCase().startsWith(o.qD.SEPARATOR))return(0,o.gX)(this.separator,t);if(this.units.toLowerCase().startsWith(o.qD.HELM))return o.g9;throw new Error(`Unexpected units ${this.units} .`)}split(t){return this.splitter(t)}getDistanceFunctionName(){if(!this.isFasta())throw new Error("Only FASTA notation is supported");return this.isMsa()?h.Y.HAMMING:(this.alphabet,h.Y.LEVENSHTEIN)}getDistanceFunction(){return h.S[this.getDistanceFunctionName()]()}async checkHelmCompatibility(){if(this.column.tags.has(".isHelmCompatible"))return"true"===this.column.getTag(".isHelmCompatible");const t=(await(0,c.wW)()).getBioLib().getMonomerSymbolsByType("PEPTIDE".toString()),e=new Set(t),n=((0,o.gX)(this.separator),new Set),r=this.column.length,s=this.column.getRawData();for(let t=0;t<r;++t){const r=s[t];if(!(r in n)){n.add(r);const s=this.getSplitted(t);for(const t of s.canonicals)if(!e.has(t))return this.column.setTag(".isHelmCompatible","false"),!1}}return this.column.setTag(".isHelmCompatible","true"),!0}get splitter(){return null===this._splitter&&(this._splitter=this.getSplitter()),this._splitter}toFasta(t){return t===o.qD.FASTA}toSeparator(t){return t===o.qD.SEPARATOR}toHelm(t){return t===o.qD.HELM}convertHelmToFastaSeparator(t,e,n,r){r||(r=this.toFasta(e)?m[o.qD.FASTA]:m[o.qD.SEPARATOR]),n||(n=this.toFasta(e)?"":this.separator);const s=t.startsWith("RNA"),i=this.splitter(t),l=[];for(let t=0;t<i.length;++t){let n=i.getOriginal(t);if(s&&(n=n.replace(u.cT,"")),n===m[o.qD.HELM])l.push(r);else if(this.toFasta(e)&&n.length>1){const t="["+n+"]";l.push(t)}else l.push(n)}return l.join(n)}convert(t,e){const n=this.getJoiner({notation:t,separator:e}),r=this.getNewColumn(t,e);return r.init((t=>{const e=this.getSplitted(t);return n(e)})),r}getRegion(t,e,n){const r=this.getNewColumn(this.notation,this.separator);r.name=n;const s=t??0,i=e??this.maxLength-1,l=this.getJoiner(),h=i-s+1,c=m[this.notation];r.init((t=>{const e=this.getSplitted(t),n=new Array(h);for(let t=0;t<h;++t){const r=s+t;n[t]=r<e.length?e.getOriginal(r):c}return l(new a.Mx(n,c))}));const u=t=>{const e=t.split(",").map((t=>t.trim())),n=new Array(h);for(let t=0;t<h;++t){const r=s+t;n[t]=r<e.length?e[r]:"?"}return n.join(o.YF)},g=this.column.getTag(".positionNames");g&&r.setTag(".positionNames",u(g));const f=this.column.getTag(".positionLabels");return f&&r.setTag(".positionLabels",u(f)),r}get joiner(){return this._joiner||(this._joiner=this.getJoiner()),this._joiner}getJoiner(t){const e=t?t.notation:this.notation,n=t?t.separator:this.separator;let r;const s=this;switch(e){case o.qD.FASTA:r=function(t){return s.joinToFasta(t,s.isHelm())};break;case o.qD.SEPARATOR:if(!n)throw new Error(`Separator is mandatory for notation '${e}'.`);r=function(t){return d(t,n,s.isHelm())};break;case o.qD.HELM:{const t="DNA"===s.alphabet||"RNA"===s.alphabet,e=s.getHelmWrappers();r=function(n){return p(n,e,t)};break}default:throw new Error(`Unexpected notation '${e}'.`)}return r}getConverter(t,e=void 0){if(t===o.qD.SEPARATOR&&!e)throw new Error(`Target separator is not specified for target units '${o.qD.SEPARATOR}'.`);const n=this;if(t===o.qD.FASTA)return function(t){return n.convertToFasta(t)};if(t===o.qD.HELM)return function(t){return n.convertToHelm(t)};if(t===o.qD.SEPARATOR)return function(t){return n.convertToSeparator(t,e)};throw new Error}static forColumn(t){let e=t.temp[g.seqHandler];return e&&e.columnVersion===t.version||(e=t.temp[g.seqHandler]=new f(t)),e}joinToFasta(t,e){const n=new Array(t.length);for(let r=0;r<t.length;++r){const s=t.getOriginal(r);let i=t.getOriginal(r);e&&(i=i.replace(u.cT,"$1")),s===l.yK?i=m[o.qD.FASTA]:s===u.E1?i="":i.length>1&&(i="["+i+"]"),n[r]=i}return n.join("")}convertToFasta(t){const e=this.splitter,n=this.isHelm()?this.splitterAsHelmNucl(t):e(t);return this.joinToFasta(n,this.isHelm())}convertToSeparator(t,e){return d(this.isHelm()?this.splitterAsHelmNucl(t):this.splitter(t),e,this.isHelm())}convertToHelm(t){const e=this.getHelmWrappers(),n=t.startsWith("DNA")||t.startsWith("RNA");return p(this.splitter(t),e,n)}splitterAsHelmNucl(t){const e=this.splitter(t),n=new Array(e.length),r=t.startsWith("DNA"),s=t.startsWith("RNA");for(let t=0;t<e.length;++t){let i=e.getOriginal(t);(r||s)&&(i=i.replace(u.cT,"$1"),i=i===u.E1?null:i),n[t]=i||null}return new a.Mx(n.filter((t=>!!t)),m[o.qD.HELM])}}function d(t,e,n){const r=new Array(t.length);for(let e=0;e<t.length;++e){const s=t.getCanonical(e);let i=t.getOriginal(e);n&&(i=i.replace(u.cT,"$1")),s===l.yK?i=m[o.qD.SEPARATOR]:s===u.E1&&(i=""),r[e]=i}return r.join(e)}function p(t,e,n){const[r,s,i,a]=e,h=new Array(t.length);for(let e=0;e<t.length;++e){const r=t.getCanonical(e);let a=t.getOriginal(e);r===l.yK?a=m[o.qD.HELM]:(n&&(a=a.replace(u.cT,"$1")),a=1===a.length?`${s}${a}${i}`:`${s}[${a}]${i}`),h[e]=a}return`${r}${h.join(".")}${a}`}},384:(t,e,n)=>{function r(t={}){const e=function(){if(!t||!t.scoringMatrix||!t.alphabetIndexes)return(t,e)=>t===e?0:1;if(t.scoringMatrix.length!==Object.keys(t.alphabetIndexes).length)throw new Error("Scoring matrix and alphabet indexes should have the same length");const e=t.alphabetIndexes,n=t.scoringMatrix,r=Math.min(...Object.keys(e).map((t=>t.charCodeAt(0))))+1,s=new Float32Array((n.length+r)*(n.length+r));return Object.entries(e).forEach((([t,r])=>{const i=n[r];Object.entries(e).forEach((([e,r])=>{s[t.charCodeAt(0)*n.length+e.charCodeAt(0)]=i[r]}))})),(t,e)=>1-s[t.charCodeAt(0)*n.length+e.charCodeAt(0)]}(),n=t?.threshold??0;return(t,r)=>{let s=0;const i=t.length,o=r.length,l=Math.max(i,o)*(1-n);i!==o&&(s=Math.abs(i-o));let a=0;for(let n=0;n<Math.min(i,o);n++)if(t[n]!==r[n]&&(a+=e(t[n],r[n]),a>l))return 1;return a+=s,a/=Math.max(i,o),a}}n.d(e,{Y:()=>o,S:()=>l});const s=new Uint32Array(65536),i={gapOpen:1,gapExtend:.6,scoringMatrix:[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1,-4],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1,-4],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2,-4],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1,-4],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1,-4],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1,-4],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2,-4],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0,-4],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0,-4],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]],alphabetIndexes:{A:0,R:1,N:2,D:3,C:4,Q:5,E:6,G:7,H:8,I:9,L:10,K:11,M:12,F:13,P:14,S:15,T:16,W:17,Y:18,V:19,B:20,Z:21,X:22,"*":23}};var o;!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(o||(o={}));const l={[o.HAMMING]:r,[o.LEVENSHTEIN]:function(){return(t,e)=>((t,e)=>{if(t.length<e.length){const n=e;e=t,t=n}return 0===e.length?t.length:t.length<=32?((t,e)=>{const n=t.length,r=e.length,i=1<<n-1;let o=-1,l=0,a=n,h=n;for(;h--;)s[t.charCodeAt(h)]|=1<<h;for(h=0;h<r;h++){let t=s[e.charCodeAt(h)];const n=t|l;t|=(t&o)+o^o,l|=~(t|o),o&=t,l&i&&a++,o&i&&a--,l=l<<1|1,o=o<<1|~(n|l),l&=n}for(h=n;h--;)s[t.charCodeAt(h)]=0;return a})(t,e):((t,e)=>{const n=e.length,r=t.length,i=[],o=[],l=Math.ceil(n/32),a=Math.ceil(r/32);for(let t=0;t<l;t++)o[t]=-1,i[t]=0;let h=0;for(;h<a-1;h++){let l=0,a=-1;const c=32*h,u=Math.min(32,r)+c;for(let e=c;e<u;e++)s[t.charCodeAt(e)]|=1<<e;for(let t=0;t<n;t++){const n=s[e.charCodeAt(t)],r=o[t/32|0]>>>t&1,h=i[t/32|0]>>>t&1,c=n|l,u=((n|h)&a)+a^a|n|h;let g=l|~(u|a),m=a&u;g>>>31^r&&(o[t/32|0]^=1<<t),m>>>31^h&&(i[t/32|0]^=1<<t),g=g<<1|r,m=m<<1|h,a=m|~(c|g),l=g&c}for(let e=c;e<u;e++)s[t.charCodeAt(e)]=0}let c=0,u=-1;const g=32*h,m=Math.min(32,r-g)+g;for(let e=g;e<m;e++)s[t.charCodeAt(e)]|=1<<e;let f=r;for(let t=0;t<n;t++){const n=s[e.charCodeAt(t)],l=o[t/32|0]>>>t&1,a=i[t/32|0]>>>t&1,h=n|c,g=((n|a)&u)+u^u|n|a;let m=c|~(g|u),d=u&g;f+=m>>>r-1&1,f-=d>>>r-1&1,m>>>31^l&&(o[t/32|0]^=1<<t),d>>>31^a&&(i[t/32|0]^=1<<t),m=m<<1|l,d=d<<1|a,u=d|~(h|m),c=m&h}for(let e=g;e<m;e++)s[t.charCodeAt(e)]=0;return f})(t,e)})(t,e)/Math.max(t.length,e.length)},[o.NEEDLEMANN_WUNSCH]:function(t){const e=new Uint16Array(65536),{gapOpen:n,gapExtend:r,scoringMatrix:s,alphabetIndexes:o}={...i,...t};Object.entries(o).forEach((([t,n])=>e[t.charCodeAt(0)]=n));const l=[new Float32Array(1e4),new Float32Array(1e4)];return(t,i)=>{const o=new Array(t.length+1).fill(!1),a=new Array(t.length+1).fill(!1);let h=0,c=1;for(let e=1;e<t.length+1;e++)l[0][e]=-n-(e-1)*r,l[1][e]=0;l[0][0]=0;for(let u=1;u<i.length+1;u++){l[c][0]=-n-(u-1)*r;for(let g=1;g<t.length+1;g++){const m=l[h][g-1]+s[e[t.charCodeAt(g-1)]][e[i.charCodeAt(u-1)]],f=l[h][g]-(o[g]?r:n),d=l[c][g-1]-(a[g-1]?r:n);l[c][g]=Math.max(m,d,f),l[c][g]===m?(o[g]=!1,a[g]=!1):l[c][g]===d?(o[g]=!1,a[g]=!0):(o[g]=!0,a[g]=!1)}h=c,c=(c+1)%2}const u=Math.max(t.length,i.length);return(u-l[h][t.length])/u}},[o.MONOMER_CHEMICAL_DISTANCE]:r}},24:(t,e,n)=>{function r(t){var e;return"string"==typeof t||t instanceof String?t:("object"==typeof t||t instanceof Object)&&"$thrownJsError"in t?r(t.$thrownJsError):t instanceof Error?null!==(e=t.stack)&&void 0!==e?e:t.message:t.toString()}n.d(e,{v:()=>r})},52:(t,e,n)=>{n.d(e,{S:()=>a});var r=n(200),s=n(848),i=n.n(s),o=n(788),l=n(48);class a{constructor(t,e){this.gridCol=t,this.col=e,this.monomerCharWidth=7,this.leftPadding=5,this.monomerTextSizeMap={},this.subs=[],this.grid=this.gridCol?this.gridCol.grid:null,this.reset(),this.grid&&(this.subs.push(this.col.dataFrame.onDataChanged.subscribe((()=>{try{this.reset()}catch(t){console.error(t)}}))),this.subs.push(r.events.onViewRemoved.subscribe((t=>{try{this.grid&&this.grid.view?.id===t.id&&this.destroy()}catch(t){console.error(t)}})))),this.monomerLib=(0,l.getMonomerLib)(),this.subs.push(this.monomerLib.onChanged.subscribe(this.monomerLibOnChanged.bind(this)))}reset(){this._allPartsList=new Array(this.col.length).fill(null),this._lengthsList=new Array(this.col.length).fill(null),this._editorList=new Array(this.col.length).fill(null)}destroy(){for(const t of this.subs)t.unsubscribe()}skipCell(t){this._allPartsList[t]=[],this._lengthsList[t]=[]}getCellAllPartsLengths(t){const[e,n]=this.getCellMonomerLengthsForSeq(t),r=new Array(n.length+1);r[0]=this.leftPadding;for(let t=1;t<r.length;t++)r[t]=r[t-1]+n[t-1];return[e,n,r]}getCellMonomerLengthsForSeq(t){let e=this._allPartsList[t];if(null===e){const n=this.col.get(t);e=this._allPartsList[t]=function(t){const e=t?(0,o.a6)(t):[];return t?(0,o.kR)(e,t):[]}(n)}let n=this._lengthsList[t];if(null===n){n=this._lengthsList[t]=new Array(e.length);for(const[t,r]of i().enumerate(e)){const e=t.length*this.monomerCharWidth;n[r]=e}}return[e,n]}getMonomer(t){let e=null;if(t.polymerType)e=this.monomerLib.getMonomer(t.polymerType,t.symbol);else for(const n of this.monomerLib.getPolymerTypes())if(e=this.monomerLib.getMonomer(n,t.symbol),e)break;return e}monomerLibOnChanged(t){this.reset(),this.grid&&this.grid.invalidate()}setEditor(t,e){this._editorList[t]=e}getEditor(t){return this._editorList[t]}}},48:(t,e,n)=>{n.r(e),n.d(e,{_package:()=>N,editMoleculeCell:()=>I,getHelmHelper:()=>B,getMolfiles:()=>F,getMonomerLib:()=>O,helmCellRenderer:()=>H,initHelm:()=>L,openEditor:()=>D,propertiesWidget:()=>q});var r=n(200),s=n(304),i=n(888),o=n(592),l=n.n(o),a=n(24),h=n(736),c=n(688),u=n(788),g=n(848),m=n.n(g);const f=n(502).uw;var d,p;function C(t,e,n,r,s,i,o="rgb(100,100,100)",l=0,a=!1,h=1,c="",u=!1,g=p.classic,m=[],d=0,C=null,b=null,A=null,w={}){s.textAlign="start";let _=i.substring(0),T=u?"":c;g===p.MSA&&(T="");let y=!0,E=!0,S="difference";if(null!=C&&null!=C.cell.column&&(y=C.cell.column.temp["color-code"]??!0,E=C.cell.column.temp["compare-with-current"]??!0,S=C.cell.column.temp["highlight-difference"]??"difference"),b){const t=b[d];E&&b.length>0&&"difference"===S&&(h=_==t?.3:h),E&&b.length>0&&"equal"===S&&(h=_!=t?.3:h)}null!=A&&(_=f(_,A));const M=_+T;w[M]??(w[M]=s.measureText(M));let v=w[M];w[_]??(w[_]=s.measureText(_));let N=w[_].width;w[T]??(w[T]=s.measureText(T));const L=w[T].width,O=r/2-(v.fontBoundingBoxAscent+v.fontBoundingBoxDescent)/2+1;function x(n,r){const i=y?o:"rgb(0,0,0)";s.fillStyle=i,s.globalAlpha=h,g===p.classic&&(s.fillText(_,t+n,e+O),s.fillStyle="#808080",s.fillText(T,t+r,e+O)),g===p.MSA&&s.fillText(_,t+n,e+O)}v=v.width,g===p.MSA&&(N=m[d],v=m[d]);const H=(m[d]??0)-(m[0]??0);if(a||v>n)return x(H,H+N),t+H+N+L;{const e=(n-v)/2;return x(e,e+N),t+H+e+N}}!function(t){t.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(d||(d={})),function(t){t.MSA="MSA",t.classic="classic"}(p||(p={}));var b=n(52);function A(t){let e=null,n=null;try{n=t.gridColumn}catch{n=null}e=n?n.temp:null;let r=null;if(!e){try{r=t.cell.column}catch{r=null}e=r?r.temp:null}if(null===e)throw new Error("Monomer placer store (GridColumn or Column) not found.");return[n,r,e]}class w extends i.GridCellRenderer{get name(){return"helm"}get cellType(){return"helm"}get defaultWidth(){return 400}get defaultHeight(){return 100}onMouseMove(t,e){try{const[n,r,i]=A(t),o=i["bio-helmMonomerPlacer"];if(!r)return;const l=t.bounds,a=e.offsetX-l.x,h=e.offsetY-l.y,c=o.getEditor(t.tableRowIndex);let g,f=new Set;if(c)g=function(t,e,n,r){let s=null;function i(n){let s,i;for(let o=0;o<r.m.atoms.length;++o)if(!n.includes(o)){const n=r.m.atoms[o].p.x,l=r.m.atoms[o].p.y,a=Math.sqrt((t-n)**2+(e-l)**2);(void 0===i||i>a)&&(s=o,i=a)}return[s,i]}const[o,l]=i([]),[a,h]=i([o]);if(void 0!==o&&void 0!==l){const t=function(t){let e;switch(t.bio.type){case"HELM_BASE":case"HELM_SUGAR":case"HELM_LINKER":e="RNA";break;default:e="PEPTIDE"}return{symbol:t.elem,polymerType:e}}(r.m.atoms[o]);void 0!==a&&void 0!==h?l<.45*h&&(s=t):l<.35*n.bounds.height&&(s=t)}return s}(a,h,t,c);else{const e=t.cell.value?(0,u.aY)(t.cell.value):"",n=(0,u.a6)(e);f=(0,u.__)(n);const r=new Set(n);if(g=function(t,e,n,r){let s=null;const[i,o,l]=r.getCellAllPartsLengths(n.tableRowIndex);let a=0,h=Object.values(o).length-1,c=!1,u=0,g=0;if(t>l[0])for(;!c&&u<l.length;)g=Math.floor((h+a)/2),t>=l[g]&&t<=l[g+1]?(a=g,c=!0):t<l[g]?h=g-1:t>l[g+1]&&(a=g+1),a==h&&(c=!0),u++;return a=t>=l[a]?a:a-1,a>=0&&(s=function(t,e,n){let r;for(const s of n.getPolymerTypes())t.startsWith(s)&&(r={symbol:e,polymerType:s});if(!r)throw new Error(`Monomer not found for symbol = '${e}' and helmPrefix = '${t}'.`);return r}(i[0],i[a],r.monomerLib)),s}(a,0,t,o),g&&!r.has(g.symbol)&&(g=null),g){const t=o.monomerTextSizeMap[g.symbol];if(t){const e=l.height/2-(t.fontBoundingBoxAscent+t.fontBoundingBoxDescent)/2+1,n=e-t.fontBoundingBoxAscent,r=e+t.fontBoundingBoxDescent;(h<n||r<h)&&(g=null)}}}if(g)if(f.has(g.symbol))s.tooltip.show(s.divV([s.divText(`Monomer '${g.symbol}' not found.`),s.divText("Open the Context Panel, then expand Manage Libraries")]),e.x+16,e.y+16);else{const t=[s.div(g.symbol)],n=o.monomerLib.getTooltip(g.polymerType,g.symbol);t.push(n),s.tooltip.show(s.divV(t),e.x+16,e.y+16)}else{if(0==f.size)return void s.tooltip.hide();{const t=m()(f.keys()).toArray().sort().filter(((t,e)=>e<3)).join(", ")+(f.size>3?", ...":"");s.tooltip.show(s.divV([s.divText("Monomers missed in monomer libraries:"),s.divText(t)]),e.x+16,e.y+16)}}}catch(t){const e=(0,a.v)(t);console.error("Helm: HelmCellRenderer.onMouseMove() error:\n"+e)}finally{e.preventDefault(),e.stopPropagation()}}render(t,e,n,r,i,o,l){t.save();try{const[l,a,h]=A(o);if(!a)return;let c=h["bio-helmMonomerPlacer"];c||(c=h["bio-helmMonomerPlacer"]=new b.S(l,a));const g=-1!==o.gridRow?o.grid:void 0,m="red",f="#404040",d="#C0C0C0",p=o.cell.value?(0,u.aY)(o.cell.value):"",w=(0,u.a6)(p),_=new Set(w),T=(0,u.__)(w);if(0==T.size){const t=o.element=s.div([],{style:{width:r-2+"px",height:i-2+"px",margin:"1px",backgroundColor:"#FFE0E0"}});t.setAttribute("dataformat","helm"),t.setAttribute("data",p),t.parentElement&&(o.grid?.canvas?.offsetLeft??0)>0&&(t.parentElement.style.left=`${(o.grid?.canvas?.offsetLeft??0)+t.parentElement.offsetLeft}px`);const e=new JSDraw2.Editor(t,{width:r,height:i,skin:"w8",viewonly:!0});return c.setEditor(o.tableRowIndex,e),void c.skipCell(o.tableRowIndex)}if(T.size>0){if(!g){const e=window.devicePixelRatio;i=28,t.canvas.height=i*e,t.canvas.style.height=`${i}px`}r=g?Math.min(g.canvas.width-e,r):t.canvas.width-e,t.beginPath(),t.rect(e,n,r,i),t.clip(),t.transform(1,0,0,1,e,n),t.font="12px monospace",t.textBaseline="top";const[s,l,a]=c.getCellAllPartsLengths(o.tableRowIndex);for(let e=0;e<s.length;++e){const n=s[e],o="."===n||n.endsWith("{")||n.startsWith("}")?d:T.has(n)?m:_.has(n)?f:d;t.fillStyle=o,C(a[e],0,r,i,t,s[e],o,0,!0,1,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,c.monomerTextSizeMap)}}}finally{t.restore()}}}class _{constructor(){this.w=200,this.h=100,this.host=s.div([],{style:{width:`${this.w}px`,height:`${this.h}px`}}),this.editor=new JSDraw2.Editor(this.host,{width:this.w,height:this.h,viewonly:!0})}resizeEditor(t,e){this.editor.setSize(t,e)}}class T{createHelmWebEditor(){return new _}createWebEditorApp(t,e){org.helm.webeditor.MolViewer.molscale=.8;const n=new scil.helm.App(t,{showabout:!1,mexfontsize:"90%",mexrnapinontab:!0,topmargin:20,mexmonomerstab:!0,sequenceviewonly:!1,mexfavoritefirst:!0,mexfilter:!0}),r=n.calculateSizes();n.canvas.resize(r.rightwidth-100,r.topheight-210);let s={width:r.rightwidth-100+"px",height:r.bottomheight+"px"};return scil.apply(n.sequence.style,s),scil.apply(n.notation.style,s),s={width:r.rightwidth+"px",height:r.bottomheight+n.toolbarheight+"px"},scil.apply(n.properties.parent.style,s),n.structureview.resize(r.rightwidth,r.bottomheight+n.toolbarheight),n.mex.resize(r.topheight-80),setTimeout((()=>{n.canvas.helm.setSequence(e,"HELM")}),200),n}static async getInstance(){let t=window.$helmHelper;return t||(window.$helmHelper=t=new T),t}}var y=n(980);const E="smiles",S="capGroupName",M="label";let v=null;const N=new i.Package;async function L(){return org.helm.webeditor.kCaseSensitive=!0,Promise.all([new Promise(((t,e)=>{dojo.ready((function(){t(null)}))})).then((()=>{window.dojox.gfx.svg.Text.prototype.getTextWidth=function(){const t=this.rawNode,e=t.parentNode,n=t.cloneNode(!0);n.style.visibility="hidden";let r=0;const s=n.firstChild.nodeValue;if(e.appendChild(n),""!=s){let t=100;for(;!r&&--t>0;)r=n.getBBox?parseInt(n.getBBox().width):68}return e.removeChild(n),r}})),r.functions.call("Bio:getBioLib")]).then((([t,e])=>{v=e,x(),v.onChanged.subscribe((t=>{try{x();const t=v.getPolymerTypes(),e="Monomer lib updated:<br />"+(0==t.length?"empty":t.map((t=>`${t} ${v.getMonomerSymbolsByType(t).length}`)).join("<br />"));r.shell.info(e)}catch(t){const e=(0,a.v)(t);console.error("Helm: initHelm monomerLib.onChanged() error:\n"+e)}}))})).catch((t=>{const e=t instanceof Error?t.message:t?t.toString():"Exception 'undefined'";r.shell.error(`Package 'Helm' init initHelm() error: ${e}`);const n=new Error(e);throw n.stack=t.stack,n}))}function O(){return v}function x(){org.helm.webeditor.Monomers.clear(),v.getPolymerTypes().forEach((t=>{v.getMonomerSymbolsByType(t).forEach((e=>{let n=!1;const r=v.getMonomer(t,e),s={id:e,m:r.molfile,n:r.name,na:r.naturalAnalog,rs:r.rgroups.length,type:r.polymerType,mt:r.monomerType,at:{}};if(r.rgroups.length>0){s.rs=r.rgroups.length;const t={};r.rgroups.forEach((e=>{t[e[M]]=e[S]})),s.at=t}else null!=r[E]?(s.rs=Object.keys(P(r[E].toString())).length,s.at=P(r[E].toString())):n=!0;n||org.helm.webeditor.Monomers.addOneMonomer(s)}))}));const t=r.shell.tv?.grid;t&&t.invalidate()}function H(){return new w}function R(t,e,n){const i=t&&void 0===n?t.value:e,o=(0,u.a6)(i),l=(0,u.__)(o);0===l.size?function(t,e,n){const r=s.div(),i=t.column,o=c.YL.forColumn(i);t.rowIndex,org.helm.webeditor.MolViewer.molscale=.8;const l=new scil.helm.App(r,{showabout:!1,mexfontsize:"90%",mexrnapinontab:!0,topmargin:20,mexmonomerstab:!0,sequenceviewonly:!1,mexfavoritefirst:!0,mexfilter:!0}),a=l.calculateSizes();l.canvas.resize(a.rightwidth-100,a.topheight-210);let h={width:a.rightwidth-100+"px",height:a.bottomheight+"px"};scil.apply(l.sequence.style,h),scil.apply(l.notation.style,h),h={width:a.rightwidth+"px",height:a.bottomheight+l.toolbarheight+"px"},scil.apply(l.properties.parent.style,h),l.structureview.resize(a.rightwidth,a.bottomheight+l.toolbarheight),l.mex.resize(a.topheight-80),setTimeout((()=>{t&&void 0===n?l.canvas.helm.setSequence(t.value,"HELM"):l.canvas.helm.setSequence(e,"HELM")}),200),s.dialog({showHeader:!1,showFooter:!0}).add(r).onOK((()=>{const e=l.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");if(t)if(void 0===n)t.value=e;else{const r=o.convertHelmToFastaSeparator(e,n,o.separator);t.value=r}})).show({modal:!0,fullScreen:!0})}(t,e,n):1===l.size&&l.has(c.oh[h.qD.HELM])?r.shell.warning(`WebEditor doesn't support Helm with gaps '${c.oh[h.qD.HELM]}'.`):r.shell.warning(`Monomers ${Array.from(l).map((t=>`'${t}'`)).join(", ")} are absent! <br/>Please, upload the monomer library! <br/><a href="https://datagrok.ai/help/domains/bio/macromolecules" target="_blank">Learn more</a>`)}function I(t){R(t.cell,void 0,void 0)}function D(t){const e=r.shell.tv.grid.dataFrame,n=e.columns.bySemType("Macromolecule"),s=c.YL.forColumn(n);n.getTag(i.TAGS.UNITS)===h.qD.HELM&&R(e.currentCell,void 0,void 0);const o=s.getConverter(h.qD.HELM)(t);R(e.currentCell,o,n.getTag(i.TAGS.UNITS))}function q(t){return(0,y.g)(t)}function P(t){const e=t.match(/(?<=\[)[^\][]*(?=])/gm),n={};let r,s="";if(e)for(let t=0;t<e.length;t++)if(null!=e[t]&&/\d/.test(e[t])){r=e[t][e[t].length-1],e[t]=e[t].replace(/[0-9]/g,"");for(let n=0;n<e[t].length;n++)":"!=e[t][n]&&(s+=e[t][n]);n["R"+r]=s,s=""}return n}function F(t){const e=i.Column.string("mols",t.length),n=s.div([],{style:{width:"0",height:"0"}});document.documentElement.appendChild(n);try{const r=new JSDraw2.Editor(n,{viewonly:!0});return e.init((e=>(r.setHelm(t.get(e)),r.getMolfile()))),e}finally{l()(n).empty(),n.remove()}}async function B(){return T.getInstance()}},788:(t,e,n)=>{n.d(e,{__:()=>h,a6:()=>a,aY:()=>o,kR:()=>l});const r=/\{(\*\.)+/g,s=/\.(\*\.)+/g,i=/(\.\*)+\}/g;function o(t){return t.replaceAll(r,"{").replaceAll(s,".").replaceAll(i,"}").replace("{*}","{}")}function l(t,e){const n=[];for(let r=0;r<(t??[]).length;++r){const s=e.indexOf(t[r]),i=e.slice(0,s);n.push(i),n.push(t[r]),e=e.substring(s+t[r].length)}return n.push(e),n}function a(t){t=g(t,"$")[0];const e=[];if(!scil.Utils.isNullOrEmpty(t)){const n=g(t,"|");for(let r=0;r<n.length;++r){let s=(t=m(n[r]).str).indexOf("{");s=(t=t.substring(s+1)).indexOf("}");const i=g(t=t.substring(0,s),".");for(const t of i)if(t&&""!==t)if(t.startsWith("[")&&t.includes("]")){const n=c(t,1,"[","]"),r=t.substring(1,n);e.push(r);const s=t.substring(n+1);i.push(s)}else if(t.includes("[")&&t.endsWith("]")){const n=u(t,t.length-2,"[","]"),r=t.substring(n+1,t.length-1);e.push(r);const s=t.substring(0,n);i.push(s)}else if(t.includes("(")&&t.includes(")")){const e=t.substring(0,t.indexOf("(")),n=t.substring(t.lastIndexOf(")")+1),r=[e,t.substring(e.length+1,t.length-n.length-1),n];for(const t of r)i.push(t)}else e.push(t)}}return e}function h(t){const e=Object.keys(org.helm.webeditor.monomerTypeList()),n=[],r=[];for(let t=0;t<e.length;t++)n.push(new scil.helm.Monomers.getMonomerSet(e[t])),Object.keys(n[t]).forEach((e=>{r.push(n[t][e].id)}));return new Set(t.filter((t=>!r.includes(t))))}function c(t,e,n,r){let s=e,i=0;for(;s<t.length;){if(t[s]===n&&i++,t[s]===r){if(0===i)return s;i--}s++}return-1}function u(t,e,n,r){let s=e,i=0;for(;s>=0;){if(t[s]===r&&i++,t[s]===n){if(0===i)return s;i--}s--}return-1}function g(t,e){const n=[];let r="",s=0,i=0,o=0,l=0;for(let a=0;a<t.length;++a){let h=t.substring(a,a+1);if(h==e&&0==i&&0==s&&0==o&&0==l)n.push(r),r="";else{if(r+=h,l>0&&"\\"==h&&a+1<t.length){++a;const e=t.substring(a,a+1);r+=e,h+=e}'"'==h?a>0&&"\\"==t.substring(a-1,a)||(l=0==l?1:0):"["==h?++i:"]"==h?--i:"("==h?++s:")"==h?--s:"{"==h?++o:"}"==h&&--o}}return n.push(r),n}function m(t){const e=f(t,'"');if(null!=e.tag)return e;const n=f(t,"'");return{tag:e.tag,repeat:n.tag,str:n.str}}function f(t,e){let n=null;if(scil.Utils.endswith(t,e)){let r=t.length-1;for(;r>0&&(r=t.lastIndexOf(e,r-1),!(r<=0||"\\"!=t.substring(r-1,r))););r>0&&r<t.length-1&&(n=t.substring(r+1,t.length-1),t=t.substring(0,r))}return null!=n&&(n=function(t){return scil.Utils.isNullOrEmpty(t)?t:t.replace(/[\\]./g,(function(t){switch(t){case"\\r":return"\r";case"\\n":return"\n";case"\\t":return"\t";default:return t.substring(1)}}))}(n.replace(new RegExp("\\"+e,"g"),e))),{tag:n,str:t}}},980:(t,e,n)=>{n.d(e,{g:()=>c});var r=n(304),s=n(888),i=n(592),o=n.n(i),l=n(688),a=n(736),h=n(788);function c(t){const e=l.YL.forColumn(t.cell.column),n=function(t,e){const n=e.isHelm()?t:e.getConverter(a.qD.HELM)(t),s=(0,h.aY)(n),i=r.div([],{style:{width:"0",height:"0"}});document.documentElement.appendChild(i);try{const t=new JSDraw2.Editor(i,{viewonly:!0});t.setHelm(s);const e=t.getFormula(!0),n=Math.round(100*t.getMolWeight())/100,r=Math.round(100*t.getExtinctionCoefficient(!0))/100;return{formula:e.replace(/<sub>/g,"").replace(/<\/sub>/g,""),"molecular weight":n,"extinction coefficient":r}}finally{o()(i).empty(),i.remove()}}(t.value,e);return new s.Widget(r.tableFromMap(n))}},592:t=>{t.exports=$},888:t=>{t.exports=DG},200:t=>{t.exports=grok},304:t=>{t.exports=ui},848:t=>{t.exports=wu}},e={};function n(r){var s=e[r];if(void 0!==s)return s.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r=n(48);helm=r})();
|
|
2
2
|
//# sourceMappingURL=package.js.map
|