@datagrok/bio 2.11.26 → 2.11.28

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/dist/package.js CHANGED
@@ -1,2 +1,2 @@
1
- var bio;(()=>{var t={2012:(t,e,n)=>{"use strict";n.d(e,{f:()=>s});var i=n(9976);class s extends i.B{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,s)),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,s)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new s({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 s.aaSynonyms?s.aaSynonyms[t]:t;return super.get(e)}}s.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class o{static getPalette(t="grok"){switch(t){case"grok":return s.GrokGroups;case"lesk":return s.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,n="",i="";for(const s of t)"("==s?e++:")"==s?e--:e?n+=s:i+=s;return isNaN(parseInt(n))?[i,n]:[i,""]}static getColorAAPivot(t="",e="grok"){const n=this.getPalette(e);let[i,s]=this.getInnerOuter(t);if(i=i.length>6?`${i.slice(0,3)}...`:i,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,i,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,i,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,i,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,i,s,4]}return[this.undefinedColor,i,s,0]}}o.SemType="Aminoacids",o.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",o.undefinedColor="rgb(100,100,100)",o.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"},o.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"},o.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(*)*"},o.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"}},6584:(t,e,n)=>{"use strict";n.d(e,{BX:()=>o,nW:()=>a,tW:()=>l});var i=n(4469);const s="Libraries",o="System:AppData/Bio/libraries/";let r=Promise.resolve();async function a(){let t;return r=r.then((async()=>{const e=await i.dapi.userDataStorage.getValue(s,"Settings",!0);t=e?JSON.parse(e):{exclude:[],explicit:[]},t.exclude=t.exclude instanceof Array?t.exclude:[],t.explicit=t.explicit instanceof Array?t.explicit:[],console.debug(`Bio: getUserLibSettings()\n${JSON.stringify(t,void 0,2)}`)})),await r,t}async function l(t){r=r.then((async()=>{console.debug(`Bio: setUserLibSettings()\n${JSON.stringify(t,void 0,2)}`),await i.dapi.userDataStorage.postValue(s,"Settings",JSON.stringify(t),!0)})),await r}},7228:(t,e,n)=>{"use strict";n.d(e,{GR:()=>d,JN:()=>c,Qx:()=>h,Xk:()=>l});var i=n(976),s=n(4469),o=n(1047),r=(n(499),n(8457)),a=n(5697);function l(t){const e=[];for(let n=0;n<t.rowCount;n++){const i={};Object.keys(o.K4).forEach((e=>{if("symbol"===e){const s=t.get(o.K4[e],n);i[e]="."===s?t.get(o.At,n):s}else if("rgroups"===e){const s=t.get(o.K4[e],n).split("\n"),r=[];s.forEach((t=>{const e={},n=t.substring(t.lastIndexOf("]")+1),i=t.match(/\[R(\d+)\]/)[1];e.capGroupSmiles="H"===n?`[*:${i}][H]`:`O[*:${i}]`,e.alternateId="H"===n?`R${i}-H`:`R${i}-OH`,e.capGroupName="H"===n?"H":"OH",e.label=`R${i}`,r.push(e)})),i[e]=r}else o.K4[e]&&(i[e]=t.get(o.K4[e],n))})),e.push(i)}return e}async function c(){const t=i.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()}async function h(t,e){t instanceof i.Column&&(t=(0,r.O)(t).columns.toList());const n=(await c()).getBioLib(),o=new Array(t.length),a=t[0].length,l=new Float32Array(a);for(let r=0;r<t.length;++r){const c=e[r],h=n.getMonomer("PEPTIDE",c)?.smiles??"",u=t[r],d=u.getRawData(),m=u.categories,p=m.indexOf("");if(o[r]={categories:m,data:d,emptyIndex:p},void 0===c)continue;const g=i.Column.fromStrings("smiles",m.map((t=>n.getMonomer("PEPTIDE",t)?.smiles??""))),f=(i.DataFrame.fromColumns([g]),(await s.chem.getSimilarities(g,h)).getRawData());for(let t=0;t<a;++t){const e=d[t];l[t]+=""!==c&&e!==p?f[e]:""===c&&e===p?1:0}}for(let n=0;n<l.length;++n){let s=l[n]/e.length;for(let r=0;r<t.length;++r){const t=o[r];if(r>=e.length&&t.data[n]!==t.emptyIndex||t.data[n]===t.emptyIndex&&r<e.length){s=i.FLOAT_NULL;break}}l[n]=s}return i.Column.fromFloat32Array("Similarity",l)}async function u(t){const e=(await c()).getBioLib(),n=[],o={},r=t.map((t=>e.getMonomer("PEPTIDE",t)?.smiles??"")),a=i.Column.fromStrings("smiles",r);for(let e=0;e<r.length;++e){o[t[e]]=e;const i=r[e],l=""===i?new Array(r.length).fill(0):(await s.chem.getSimilarities(a,i)).getRawData();l[e]=1,n[e]=Array.from(l)}return{scoringMatrix:n,alphabetIndexes:o}}async function d(t,e="Morgan"){const n=(await c()).getBioLib(),s=new Array(t.length).fill(0).map((()=>new Array(t.length).fill(0))),o={},r=t.map((t=>n.getMonomer("PEPTIDE",t)?.smiles??"")),l=i.Func.find({package:"Chem",name:"getFingerprints"})[0];if(!l)return console.warn('Function "Chem:getFingerprints" is not found in chem package. falling back to Morgan fingerprints'),await u(t);const h=i.Column.fromStrings("smiles",r),d=(i.DataFrame.fromColumns([h]),(await l.apply({col:h,fingerprintType:e}))?.entries);if(!d)return console.warn(`${e} Fingerprints could not be calculated for monomers from chem package.\n falling back to Morgan fingerprints`),await u(t);for(let e=0;e<d.length;++e)if(s[e][e]=1,o[t[e]]=e,d[e])for(let t=e+1;t<d.length;++t)d[t]&&(s[e][t]=s[t][e]=(0,a.Z3)(d[e],d[t]));return{scoringMatrix:s,alphabetIndexes:o}}},8601:(t,e,n)=>{"use strict";n.d(e,{i0:()=>d});var i=n(4469),s=n(976),o=n(6414),r=n.n(o),a=n(1821),l=n(499);const c={V2K_RGP_SHIFT:8,V2K_RGP_LINE:"M RGP",V2K_A_LINE:"A ",V3K_COUNTS_SHIFT:14,V3K_IDX_SHIFT:7,V3K_HEADER_FIRST_LINE:"\nDatagrok macromolecule handler\n\n",V3K_HEADER_SECOND_LINE:" 0 0 0 0 0 0 999 V3000\n",V3K_BEGIN_CTAB_BLOCK:"M V30 BEGIN CTAB\n",V3K_END_CTAB_BLOCK:"M V30 END CTAB\n",V3K_BEGIN_COUNTS_LINE:"M V30 COUNTS ",V3K_COUNTS_LINE_ENDING:" 0 0 0\n",V3K_BEGIN_ATOM_BLOCK:"M V30 BEGIN ATOM\n",V3K_END_ATOM_BLOCK:"M V30 END ATOM\n",V3K_BEGIN_BOND_BLOCK:"M V30 BEGIN BOND\n",V3K_END_BOND_BLOCK:"M V30 END BOND\n",V3K_BOND_CONFIG:" CFG=",V3K_BEGIN_DATA_LINE:"M V30 ",V3K_END:"M END",PRECISION_FACTOR:1e4,DEOXYRIBOSE:"d",RIBOSE:"r",PHOSPHATE:"p",OXYGEN:"O",HYDROGEN:"H"};var h=n(1047);function u(t){return Math.round(c.PRECISION_FACTOR*t)/c.PRECISION_FACTOR}async function d(t,e,o){if(0===s.Func.find({package:"Chem",name:"getRdKitModule"}).length)return{col:null,warnings:['Transformation to atomic level requires the package "Chem" installed.']};if(e.semType!==s.SEMTYPE.MACROMOLECULE)return{col:null,warnings:[`Only the ${s.SEMTYPE.MACROMOLECULE} columns can be converted to atomic level, the chosen column has semType '${e.semType}'`]};let u=e;const d=l.Cn.getOrCreate(e);d.isHelm()&&(u=d.convert(a.r2.SEPARATOR,"."),u.name=e.name);const p=l.Cn.getOrCreate(u).alphabet;let g;if("PT"===p||"UN"===p)g="PEPTIDE";else{if("RNA"!==p&&"DNA"!==p)return{col:null,warnings:[`Unexpected column's '${u.name}' alphabet '${p}'.`]};g="RNA"}const f=function(t){const e=t.length,n=new Array(e),i=l.Cn.getOrCreate(t).getSplitter();for(let s=0;s<e;++s){const e=t.get(s);n[s]=e?r()(i(e)).filter((t=>""!==t)).toArray():[]}return n}(u),y=await async function(t,e,n,s){const o=function(t,e,n){const i=new Map;for(const s of t.getMonomerSymbolsByType(e)){const o=t.getMonomer(e,s);if("RNA"===e&&("Branch"===o.monomerType||"DNA"===n&&o.symbol===c.DEOXYRIBOSE||"RNA"===n&&o.symbol===c.RIBOSE||o.symbol===c.PHOSPHATE)||"PEPTIDE"===e&&"Branch"!==o.monomerType){const t={};h.rx.forEach((e=>{t[e]=o[e]})),i.set(o.symbol,t)}}return i}(e,n,s),r=new Map,a=await i.functions.call("Chem:getRdKitModule"),l={value:null};if("RNA"===n){const t="RNA"===s?[c.RIBOSE,c.PHOSPHATE]:[c.DEOXYRIBOSE,c.PHOSPHATE];for(const e of t)m(r,e,o,a,n,l)}for(let e=0;e<t.length;++e){const i=t[e];for(const t of i)if(""!==t)try{m(r,t,o,a,n,l)}catch(e){const n=e instanceof Error?e.message:e.toString(),i=e instanceof Error?e.stack:void 0;throw console.error(`bio lib: getMonomersDictFromLib() sym='${t}', error:\n${n}\n${i}`),new Error(`Can't get monomer '${t}' from library: ${n}`)}}return r}(f,o,g,p),b=u.length,{molfileList:C,molfileWarningList:w}=await async function(t,e,i,s,o){const r=Math.max(navigator.hardwareConcurrency-2,1),a=new Array(r).fill(null).map((()=>new Worker(new URL(n.p+n.u(79),n.b)))),l=o/r;let c=[],h=[];const u=new Array(r);for(let n=0;n<r;n++){const c=Math.floor(n*l),h=n===r-1?o:Math.floor((n+1)*l);a[n].postMessage({monomerSequencesArray:t,monomersDict:e,alphabet:i,polymerType:s,start:c,end:h}),u[n]=new Promise((t=>{a[n].onmessage=({data:{molfileList:e,molfileWarningList:n}})=>{t({molfileList:e,molfileWarningList:n})}}))}return(await Promise.all(u)).forEach((t=>{c=c.concat(...t.molfileList),h=h.concat(...t.molfileWarningList)})),setTimeout((()=>{a.forEach((t=>{t.terminate()}))}),0),{molfileList:c,molfileWarningList:h}}(f,y,p,g,b);if(w.length>.05*b)throw new Error("Too many errors getting molfiles.");const v=`molfile(${u.name})`,S=t.columns.getUnusedName(v),A=s.Column.fromStrings(S,C);return A.semType=s.SEMTYPE.MOLECULE,A.setTag(s.TAGS.UNITS,s.UNITS.Molecule.MOLBLOCK),{col:A,warnings:w}}function m(t,e,n,i,s,o){if(!t.has(e)){const r=function(t,e,n,i,s){if(e.has(t)){const o=e.get(t),r=function(t){const e=[];for(const n of t){let t=n.capGroupSmiles;t||(t=n.capGroupSMILES),t=t.replace(/(\[|\]|\*|:|\d)/g,""),e.push(t)}return e}(o.rgroups),a=function(t){const e=new Map;let n=t.indexOf(c.V2K_A_LINE,0),i=n;for(;-1!==n;){i=t.indexOf("\n",n);const s=parseInt(t.substring(n,i).replace(/^A\s+/,""));n=t.indexOf("R",i),i=t.indexOf("\n",n);const o=parseInt(t.substring(n,i).replace(/^R/,""));e.set(s,o),n=t.indexOf(c.V2K_A_LINE,i)}for(n=t.indexOf(c.V2K_RGP_LINE,0),i=t.indexOf("\n",n);-1!==n;){n+=c.V2K_RGP_SHIFT,i=t.indexOf("\n",n);const s=t.substring(n,i).replaceAll(/\s+/g," ").split(" ").map((t=>parseInt(t))).slice(1);for(let t=0;t<s.length;t+=2){if(e.has(s[t])&&e.get(s[t])!==s[t+1])throw new Error(`r-group index ${s[t]} has already been added with a different value`);e.set(s[t],s[t+1])}n=t.indexOf(c.V2K_RGP_LINE,i)}return e}(o.molfile),l=function(t,e){const n=e.get_mol(t),i=n.get_v3Kmolblock();return n.delete(),i}(function(t){let e=t.indexOf(c.V2K_A_LINE,0);-1===e&&(e=t.indexOf(c.V2K_RGP_LINE));const n=t.indexOf(c.V3K_END,e);return t.substring(0,e)+t.substring(n)}(o.molfile),n),h=function(t){let e=(t=t.replaceAll("\r","")).indexOf(c.V3K_BEGIN_COUNTS_LINE)+c.V3K_COUNTS_SHIFT,n=t.indexOf(" ",e+1);const i=parseInt(t.substring(e,n));return e=n+1,n=t.indexOf(" ",e+1),{atomCount:i,bondCount:parseInt(t.substring(e,n))}}(l),d=function(t,e){const n=new Array(e),i=new Float32Array(e),s=new Float32Array(e),o=new Array(e);let r=t.indexOf(c.V3K_BEGIN_ATOM_BLOCK);r=t.indexOf("\n",r);let a=r;for(let l=0;l<e;l++){r=t.indexOf(c.V3K_BEGIN_DATA_LINE,r)+c.V3K_IDX_SHIFT,a=t.indexOf(" ",r),r=a+1,a=t.indexOf(" ",r),n[l]=t.substring(r,a);const e=new Array(2);for(let n=0;n<2;++n)r=a+1,a=t.indexOf(" ",r),e[n]=parseFloat(t.substring(r,a));i[l]=e[0],s[l]=e[1],r=a,a=t.indexOf("\n",r)+1,o[l]=t.slice(r,a),r=a}return{atomTypes:n,x:i,y:s,kwargs:o}}(l,h.atomCount),m=function(t,e){const n=new Uint32Array(e),i=new Array(e),s=new Map,o=new Map;let r=t.indexOf(c.V3K_BEGIN_BOND_BLOCK);r=t.indexOf("\n",r);let a=r;for(let l=0;l<e;++l){const e=new Array(3);r=t.indexOf(c.V3K_BEGIN_DATA_LINE,a)+c.V3K_IDX_SHIFT,a=t.indexOf(" ",r);for(let n=0;n<3;++n)r=a+1,a=Math.min(t.indexOf("\n",r),t.indexOf(" ",r)),e[n]=parseInt(t.slice(r,a));n[l]=e[0],i[l]=e.slice(1);const h=t.indexOf("\n",r);let u=t.slice(a,h),d=u.indexOf(c.V3K_BOND_CONFIG);if(-1!==d){d=u.indexOf("=",d)+1;let t=u.indexOf(" ",d);-1===t&&(t=u.length);const e=parseInt(u.slice(d,t));s.set(l,e);const n=c.V3K_BOND_CONFIG+e.toString();u=u.replace(n,"")}u||o.set(l,u)}return{bondTypes:n,atomPairs:i,bondConfiguration:s,kwargs:o}}(l,h.bondCount),y={atoms:d,bonds:m,meta:p(d,m,r,a)};return"PEPTIDE"===i?function(t){const e=t.meta.terminalNodes[0]-1,n=t.meta.rNodes[0]-1,i=t.atoms.x,s=t.atoms.y;A(t,-i[e],-s[e]);const o=w(i[n],s[n]);v(t.atoms,-o),i[t.meta.rNodes[1]-1]<0&&function(t){S(t,!1)}(t);const r=function(t){const e=function(t){const e=new Map;for(const n of t.bonds.atomPairs)for(let t=0;t<2;t++){const i=n[t],s=n[(t+1)%2];e.has(i)?e.get(i)?.push(s):e.set(i,new Array(1).fill(s))}return e}(t);let n=0;const i=t.atoms.atomTypes.length;let s=0;for(;0===n;){const o=e.get(t.meta.terminalNodes[1])[s];if(t.atoms.atomTypes[o-1]===c.OXYGEN&&o!==t.meta.rNodes[1]&&(n=o),s++,s>i)throw new Error(`Search for double-bonded Oxygen in ${t} has exceeded the limit of ${i}`)}return n}(t);!function(t,e){t.atoms.y[t.meta.rNodes[1]-1]<0&&t.atoms.y[e-1]<0&&(function(t){S(t,!0)}(t),v(t.atoms,-function(t,e){return w(t,e)+Math.PI/2}(t.atoms.x[t.meta.terminalNodes[1]-1],t.atoms.y[t.meta.terminalNodes[1]-1])))}(t,r),function(t,e){const n=t.atoms.x;n[t.meta.rNodes[1]-1]>n[e-1]&&function(t,e,n){const i=e-1,s=n-1,o=t.atoms.x,r=t.atoms.y,a=o[i],l=r[i];o[i]=o[s],r[i]=r[s],o[s]=a,r[s]=l}(t,e,t.meta.rNodes[1])}(t,r)}(y):t===c.RIBOSE||t===c.DEOXYRIBOSE?function(t,e){const n=t.atoms.x,i=t.atoms.y;let s=t.meta.terminalNodes[0]-1;const o=t.meta.rNodes[1]-1;A(t,-n[s],-i[s]);const r=w(n[o],i[o]);v(t.atoms,3*Math.PI/2-r),e.value=function(t){const e=t.atoms.x,n=t.atoms.y,i=t.meta.rNodes[2]-1,s=t.meta.terminalNodes[2]-1,o=e[i]-e[s],r=n[i]-n[s];return Math.atan(r/o)+Math.PI/2}(t),s=t.meta.terminalNodes[0]-1,A(t,-n[s],-i[s])}(y,s):t===c.PHOSPHATE?function(t){const e=t.meta.terminalNodes[0]-1,n=t.meta.rNodes[0]-1,i=t.atoms.x,s=t.atoms.y;A(t,-i[e],-s[e]);const o=w(i[n],s[n]);v(t.atoms,Math.PI/2-o)}(y):function(t,e){const n=t.atoms.x,i=t.atoms.y,s=t.meta.terminalNodes[0]-1,o=t.meta.rNodes[0]-1;A(t,-n[s],-i[s]);const r=w(n[o],i[o]),a=e.value;if(!a)throw new Error("The value of sugarBranchToOYAngle is null");v(t.atoms,Math.PI-r+a);const l=function(t,e){return u(Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2))}({x:n[t.meta.rNodes[0]-1],y:i[t.meta.rNodes[0]-1]},{x:n[t.meta.terminalNodes[0]-1],y:i[t.meta.terminalNodes[0]-1]});if(1!=l)for(let t=0;t<n.length;++t)n[t]=u(n[t]/l),i[t]=u(i[t]/l)}(y,s),function(t,e,n){"PEPTIDE"===t?(f(e,t),b(e,e.meta.rNodes[1])):n===c.RIBOSE||n===c.DEOXYRIBOSE?(b(e,e.meta.rNodes[1]),e.meta.rNodes[1]=e.meta.terminalNodes[1],g(e.bonds,e.meta),f(e,t),b(e,e.meta.rNodes[1]),b(e,e.meta.rNodes[0]),b(e,e.meta.rNodes[2])):n===c.PHOSPHATE&&(e.meta.terminalNodes[0]=e.meta.rNodes[0],A(e,-e.atoms.x[e.meta.terminalNodes[0]-1],-e.atoms.y[e.meta.terminalNodes[0]-1]),f(e,t),b(e,e.meta.rNodes[1]))}(i,y,t),function(t){let e=0;for(;e<t.atoms.atomTypes.length;)t.atoms.atomTypes[e]===c.HYDROGEN&&(b(t,e+1),--e),++e}(y),y}return null}(e,n,i,s,o);if(!r)throw new Error(`Monomer with symbol '${e}' is absent the monomer library`);t.set(e,r)}}function p(t,e,n,i){const s={backboneShift:null,branchShift:null,terminalNodes:[],rNodes:[]};return function(t,e,n){for(const[i,s]of n)t.atomTypes[i-1]=e[s-1]}(t,n,i),function(t,e){e.rNodes=Array.from(t.keys());for(let n=0;n<e.rNodes.length;n++)for(const i of[1,2])if(t.get(e.rNodes[n])===i){const t=e.rNodes[i-1];e.rNodes[i-1]=e.rNodes[n],e.rNodes[n]=t}}(i,s),g(e,s),s}function g(t,e){const n=e.rNodes;e.terminalNodes=new Array(n.length).fill(0);const i=e.terminalNodes,s=t.atomPairs;let o=0,r=0;for(;o<s.length&&r<i.length;){for(let t=0;t<i.length;++t)for(let e=0;e<2;++e)s[o][e]===n[t]&&(i[t]=s[o][(e+1)%2],n.length,++r);++o}}function f(t,e){t.meta.rNodes.length>1&&(t.meta.backboneShift=y(t,t.meta.rNodes[1]-1,t.meta.terminalNodes[0]-1)),"RNA"===e&&t.meta.rNodes.length>2&&(t.meta.branchShift=y(t,t.meta.rNodes[2]-1,t.meta.terminalNodes[0]-1))}function y(t,e,n){return[u(t.atoms.x[e]-t.atoms.x[n]),u(t.atoms.y[e]-t.atoms.y[n])]}function b(t,e){if(void 0!==e){const n=e-1,i=t.atoms,s=t.bonds,o=t.meta;i.atomTypes.splice(n,1),i.x=C(Float32Array,i.x,n,1),i.y=C(Float32Array,i.y,n,1),i.kwargs.splice(n,1);for(let t=0;t<o.terminalNodes.length;++t)o.terminalNodes[t]>e?--o.terminalNodes[t]:o.terminalNodes[t]===e&&(o.terminalNodes[t]=-1);for(let t=0;t<o.rNodes.length;++t)o.rNodes[t]>e?--o.rNodes[t]:o.rNodes[t]===e&&(o.rNodes[t]=-1);let r=0;for(;r<s.atomPairs.length;){const t=s.atomPairs[r][0],n=s.atomPairs[r][1];t===e||n===e?(s.atomPairs.splice(r,1),s.bondTypes=C(Uint32Array,s.bondTypes,r,1),s.bondConfiguration.has(r)&&s.bondConfiguration.delete(r),s.kwargs.has(r)&&s.kwargs.delete(r),--r):(s.atomPairs[r][0]=t>e?t-1:t,s.atomPairs[r][1]=n>e?n-1:n),++r}let a=Array.from(s.bondConfiguration.keys());a.forEach((t=>{if(s.bondConfiguration.has(t)&&t>n){const e=s.bondConfiguration.get(t);s.bondConfiguration.delete(t),s.bondConfiguration.set(t-1,e)}})),a=Array.from(s.kwargs.keys()),a.forEach((t=>{if(s.kwargs.has(t)&&t>n){const e=s.kwargs.get(t);s.kwargs.delete(t),s.kwargs.set(t-1,e)}}))}}function C(t,e,n,i){const s=new t(e.length-i);let o=0,r=0;for(;o<e.length;)o===n&&(o+=i),s[r]=e[o],++r,++o;return s}function w(t,e){let n;if(0===t)n=e>0?0:Math.PI;else if(0===e)n=t>0?-Math.PI/2:Math.PI/2;else{const i=e/t,s=Math.atan(i);n=t<0?Math.PI/2+s:-Math.PI/2+s}return n}function v(t,e){if(0!==e){const n=t.x,i=t.y,s=Math.cos(e),o=Math.sin(e);for(let t=0;t<n.length;++t){const e=n[t];n[t]=u(e*s-i[t]*o),i[t]=u(e*o+i[t]*s)}}}function S(t,e){if(e){const e=t.atoms.y;for(let t=0;t<e.length;t++)e[t]=-e[t]}else{const e=t.atoms.x;for(let t=0;t<e.length;t++)e[t]=-e[t]}const n=t.bonds.bondConfiguration;for(const[t,e]of n){const i=1===e?3:1;n.set(t,i)}}function A(t,e,n){const i=t.atoms.x,s=t.atoms.y;for(let t=0;t<i.length;++t)i[t]=u(i[t]+e),void 0!==n&&(s[t]=u(s[t]+n))}},6137:(t,e,n)=>{"use strict";n.d(e,{J:()=>s});var i=n(9976);class s extends i.B{static get Chromatogram(){return void 0===this.chromatogram&&(this.chromatogram=new s({A:"green",C:"blue",G:"black",T:"red",U:"red",others:"gray"})),this.chromatogram}}class o{}o.SemType="Nucleotides",o.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",o.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"}},9976:(t,e,n)=>{"use strict";n.d(e,{B:()=>i});class i{static makePalette(t,e=!1,n=i){const s={};return t.forEach((t=>{const n=t[0],i=t[1];n.forEach(((t,n)=>{s[t]=this.colourPalette[i][e?0:n]}))})),new n(s)}constructor(t){this._palette=t}get(t){return this._palette[t]}}i.undefinedColor="rgb(100,100,100)",i.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)"]}},7331:(t,e,n)=>{"use strict";n.d(e,{UE:()=>c});var i=n(976),s=n(9976);class o{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 r{}class a extends r{get(t){return"#666666"}}class l extends r{static buildPalette(){return[].concat(...Object.values(s.B.colourPalette))}get(t){const e=o.hashCode(t)%l.palette.length;return function(t){if(null==t)return"rgb(100,100,100)";const e=i.Color.fromHtml(t),n=i.Color.g(e),s=i.Color.r(e),o=i.Color.b(e),r=Math.sqrt(Math.pow(0-s,2)+Math.pow(0-n,2)+Math.pow(0-o,2));return r>210?`rgb(${s/r*210},${n/r*210},${o/r*210})`:i.Color.toRgb(e)}(l.palette[e])}}l.palette=l.buildPalette();class c extends s.B{static get Gray(){return void 0===this.gray&&(this.gray=new a),this.gray}static get Color(){return void 0===this.color&&(this.color=new l),this.color}}},9611:(t,e,n)=>{"use strict";n.d(e,{A:()=>c});var i=n(4469),s=n(976),o=n(6414),r=n.n(o),a=n(8447);const l={DNA:"RNA",RNA:"RNA",PT:"PEPTIDE",UN:"PEPTIDE"};class c{get updated(){return this._updated}constructor(t,e,n){this.grid=t,this.col=e,this.propsProvider=n,this._monomerLengthList=null,this.separatorWidth=5,this._updated=!1,this._monomerLengthMap={},this._monomerStructureMap={},this.subs=[],this._splitter=(0,a.Mj)(this.col),this.props=this.propsProvider(),this._rowsProcessed=s.BitSet.create(this.col.length),this.grid&&(this.subs.push(e.dataFrame.onDataChanged.subscribe((()=>{this.props=this.propsProvider(),this._monomerLengthList=null,this._rowsProcessed=s.BitSet.create(this.col.length)}))),this.subs.push(i.events.onViewRemoved.subscribe((t=>{this.grid?.view?.id===t.id&&this.destroy()}))))}destroy(){for(const t of this.subs)t.unsubscribe()}getCellMonomerLengths(t){const e=this.props.unitsHandler.isMsa()?this.getCellMonomerLengthsForSeqMsa():this.getCellMonomerLengthsForSeq(t),n=new Array(e.length+1);n[0]=5;for(let t=1;t<n.length;t++)n[t]=n[t-1]+e[t-1];return[e,n]}getCellMonomerLengthsForSeq(t){null===this._monomerLengthList&&(this._monomerLengthList=new Array(this.col.length).fill(null),this._updated=!0);let e=this._monomerLengthList[t];if(null===e){const n=this.getSeqMonList(t);e=this._monomerLengthList[t]=new Array(n.length);for(const[t,i]of r().enumerate(n)){const n=this.props.monomerToShort(t,this.props.monomerLengthLimit),s=(this.props.unitsHandler.isSeparator()?this.separatorWidth:this.props.separatorWidth)+n.length*this.props.monomerCharWidth;e[i]=s}this._updated=!0}return e}getCellMonomerLengthsForSeqMsa(){var t;null===this._monomerLengthList&&(this._monomerLengthList=new Array(1).fill(null),this._updated=!0),(t=this._monomerLengthList)[0]??(t[0]=new Array(0));const e=this._monomerLengthList[0],n=Math.max(Math.floor((this.grid?.vertScroll.min??0)-10),0),i=Math.min(Math.ceil((this.grid?.vertScroll.max??0)+10),this.col.length);for(let t=n;t<i;t++){if(this._rowsProcessed.get(t))continue;const n=this.getSeqMonList(t);n.length>e.length&&e.push(...new Array(n.length-e.length).fill(0));for(const[t,i]of r().enumerate(n)){const n=this.props.monomerToShort(t,this.props.monomerLengthLimit),s=this.props.separatorWidth+n.length*this.props.monomerCharWidth;e[i]=Math.max(e[i]??0,s)}this._updated=!0}return e}getPosition(t,e){const[n,i]=this.getCellMonomerLengths(t),s=this.col.get(t),o=r()(this._splitter(s)).toArray();if(0===o.length)return null;let a=100,l=null,c=o.length,h=!1,u=0;if(i[0]<=e&&e<i.slice(-1)[0])for(;!h;)if(u=Math.floor((c+(l??0))/2),e>=i[u]&&e<=i[u+1]?(l=u,h=!0):e<i[u]?c=u-1:e>i[u+1]&&(l=u+1),l==c&&(h=!0),--a<=0)throw new Error(`Get position for pointer x = ${e} searching has not converged on ${JSON.stringify(i)}. `);return l}getSeqMonList(t){const e=this.col.get(t);return e?r()(this._splitter(e)).toArray():[]}getMonomer(t){const e=this.props.unitsHandler.alphabet??"UN",n=l[e];return this.props.monomerLib?.getMonomer(n,t)??null}setMonomerLengthLimit(t){this.props.monomerLengthLimit=t,this._updated=!0}setSeparatorWidth(t){this.props.separatorWidth=t,this._updated=!0}isMsa(){return this.props.unitsHandler.isMsa()}}},1047:(t,e,n)=>{"use strict";n.d(e,{$3:()=>c,At:()=>s,K4:()=>a,Wc:()=>o,Z2:()=>l,nJ:()=>r,pU:()=>h,rx:()=>i});const i=["symbol","molfile","rgroups","name"],s="MonomerName",o={symbol:"Short Name",name:"Medium Name",smiles:"SMILES"},r=[{capGroupSmiles:"[*:1][H]",alternateId:"R1-H",capGroupName:"H",label:"R1"},{capGroupSmiles:"O[*:2]",alternateId:"R2-OH",capGroupName:"OH",label:"R2"},{capGroupSmiles:"[*:3][H]",alternateId:"R3-H",capGroupName:"H",label:"R3"}],a={monomerType:null,smiles:null,name:"MonomerName",author:null,molfile:"molecule",naturalAnalog:"MonomerNaturalAnalogCode",rgroups:"MonomerCaps",createDate:null,id:null,polymerType:"MonomerType",symbol:"MonomerCode"},l={monomerType:"Backbone",smiles:"",name:"",author:"Datagrok",molfile:"",naturalAnalog:"",rgroups:[],createDate:null,id:0,polymerType:"PEPTIDE",symbol:""},c="p",h=new RegExp(`[rd]\\((\\w)\\)${c}?`,"g")},7945:(t,e,n)=>{"use strict";function i(t){return"string"==typeof t||t instanceof String?t:"StateError"===t.constructor.name?t.message:"StateError"===t.constructor.name&&"$thrownJsError"in t?i(t.$thrownJsError):t instanceof Error?t.message:t.toString()}function s(t){return t instanceof Error?t.stack:"StateError"===t.constructor.name&&"$thrownJsError"in t?s(t.$thrownJsError):void 0}function o(t){return[i(t),s(t)]}n.d(e,{yf:()=>o})},5226:(t,e,n)=>{"use strict";n.d(e,{i:()=>r});var i=n(976),s=n(499),o=n(1821);class r{get descriptionsArray(){return this._descriptionsArray}get sequencesArray(){return this._sequencesArray}parseMacromolecule(t,e){return this._fileContent.slice(t,e).split(/\s/).join("")}parseColumns(){const t=/^>(.*)$/gm;let e,n=0;for(;e=t.exec(this._fileContent);){const i=this._fileContent.substring(e.index+1,t.lastIndex);this._descriptionsArray.push(i),0!==n&&this._sequencesArray.push(this.parseMacromolecule(n,e.index)),n=t.lastIndex+1}this._sequencesArray.push(this.parseMacromolecule(n,-1))}importFasta(){const t=i.Column.fromStrings("description",this.descriptionsArray),e=i.Column.fromStrings("sequence",this.sequencesArray);return e.semType=i.SEMTYPE.MACROMOLECULE,e.setTag(i.TAGS.UNITS,o.r2.FASTA),s.Cn.getOrCreate(e),[i.DataFrame.fromColumns([t,e])]}constructor(t){this._descriptionsArray=[],this._sequencesArray=[],this._fileContent=t,this.parseColumns()}}},1821:(t,e,n)=>{"use strict";n.d(e,{BM:()=>r,CI:()=>o,XS:()=>l,r2:()=>i});var i,s=n(6286);!function(t){t.FASTA="fasta",t.SEPARATOR="separator",t.HELM="helm"}(i||(i={}));const o=", ",r=/(?:\[([A-Za-z0-9_\-,()]+)\])|([A-Za-z\-])/g,a=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"])}}},l=[new s.L("PT",a.fasta.peptide,.5),new s.L("DNA",a.fasta.dna,.55),new s.L("RNA",a.fasta.rna,.55)]},8447:(t,e,n)=>{"use strict";n.d(e,{CI:()=>i.CI,GU:()=>s.GU,Mj:()=>s.Mj,XS:()=>i.XS,dQ:()=>s.dQ,kB:()=>s.kB,py:()=>s.py,r2:()=>i.r2,up:()=>s.up});var i=n(1821),s=n(8260)},6286:(t,e,n)=>{"use strict";n.d(e,{L:()=>i,d:()=>s});class i{constructor(t,e,n){this.name=t,this.alphabet=e,this.cutoff=n}}class s extends i{constructor(t,e,n){super(t.name,t.alphabet,t.cutoff),this.freq=e,this.similarity=n}}},8260:(t,e,n)=>{"use strict";n.d(e,{w4:()=>x,py:()=>I,vU:()=>w,Mj:()=>v,Ar:()=>f,GU:()=>A,dQ:()=>T,up:()=>M,kB:()=>p,FJ:()=>g,gP:()=>C});var i=n(976),s=n(6414),o=n.n(s),r=n(6286),a=n(1821),l=n(499);class c extends Float32Array{}var h=n(850),u=n(2012),d=n(6137),m=n(7331);function p(t){return o()(t.toString().matchAll(a.BM)).map((t=>t[2]??t[1])).toArray()}function g(t){return t||[]}function f(t,e=undefined){return n=>n?n.replaceAll('"-"',"").replaceAll("'-'","").split(t,e):[]}const y=/(PEPTIDE1|DNA1|RNA1)\{([^}]+)}/g,b=/\[([^\[\]]+)]/g;function C(t){y.lastIndex=0;const e=y.exec(t.toString()),n=e?e[2]:null;return(n?n.split("."):[]).map((t=>{b.lastIndex=0;const e=b.exec(t);return e&&e.length>=2?e[1]:t}))}function w(t,e,n=undefined){if(t.toLowerCase().startsWith(a.r2.FASTA))return p;if(t.toLowerCase().startsWith(a.r2.SEPARATOR))return f(e,n);if(t.toLowerCase().startsWith(a.r2.HELM))return C;throw new Error(`Unexpected units ${t} .`)}function v(t){return l.Cn.getOrCreate(t).getSplitter()}const S=/([^\W_]+)/g;function A(t,e){if(t.length<=e)return t;const n=t.match(S),i=t.length>e||(n?.length??0)>1,s=n?.[0]??" ";return i?s.substring(0,e-1)+"…":s}function x(t,e,n="-"){const i=e.map((e=>{const i=function(t,e,n="-"){const i=new Set([...new Set(Object.keys(t)),...e]);i.delete(n);const s=[],o=[];for(const n of i)s.push(n in t?t[n]:0),o.push(e.has(n)?1:0);const r=new c(s),a=new c(o);return(0,h.MA)(r,a)/((0,h.$G)(r)*(0,h.$G)(a))}(t,e.alphabet,n);return new r.d(e,t,i)}));let s;const o=Math.max(...i.map((t=>t.similarity>t.cutoff?t.similarity:-1)));return s=o>0?i.find((t=>t.similarity===o)).name:"UN",s}function T(t,e=5){let n;if(t.semType==i.SEMTYPE.MACROMOLECULE)n=l.Cn.getOrCreate(t).alphabet;else{const i=function(t,e,n){return t.categories,function(t,e){const n={};let i=!0,s=null;for(const o of t)if(null==s?s=o.length:o.length!==s&&(i=!1),o.length>=e)for(const t of o)t in n||(n[t]=0),n[t]+=1;return{freq:n,sameLength:i}}(o()(t.getRawData()).map((e=>n(t.categories[e]))),e)}(t,e,p);n=x(i.freq,a.XS)}return I(n)}function I(t){switch(t){case"PT":return u.f.GrokGroups;case"DNA":case"RNA":return d.J.Chromatogram;default:return m.UE.Color}}function M(t){const e=t.columns.bySemTypeAll(i.SEMTYPE.MACROMOLECULE);let n=e.find((t=>{const e=t.getTag(i.TAGS.UNITS);return!!e&&-1!==e.indexOf("MSA")}))??null;return!n&&e.length>0&&(n=e[0]),n}},8457:(t,e,n)=>{"use strict";n.d(e,{O:()=>a});var i=n(976),s=n(6414),o=n.n(s),r=n(8260);function a(t){const e=(0,r.Mj)(t),n=t=>{const e=l.columns.addNewString((t+1).toString());return s.push(e),e},s=[],a=t.length,l=i.DataFrame.create(a);for(let i=0;i<a;++i){const r=t.get(i);if(null==r)continue;const a=e(r);for(const[t,e]of o().enumerate(a))((s[e]??null)||n(e)).set(i,t||"-",!1)}return l}},172:(t,e,n)=>{"use strict";n.d(e,{c:()=>o});var i,s=n(7945);!function(t){t[t.error=0]="error",t[t.warning=1]="warning",t[t.info=2]="info",t[t.debug=3]="debug"}(i||(i={}));class o{constructor(t){this.logger=t,this.promise=Promise.resolve(),this.syncCounter=0}sync(t,e){const n=++this.syncCounter;this.logger.debug(`${t}, SYNC syncId = ${n}, IN `),this.promise=this.promise.then((async()=>{this.logger.debug(`${t}, SYNC syncId = ${n}, START `),await e(),this.logger.debug(`${t}, SYNC syncId = ${n}, END `)})).catch((e=>{const[i,o]=(0,s.yf)(e);this.logger.error(`${t}, SYNC syncId = ${n}, ERROR:\n${i}`,void 0,o)}))}}},499:(t,e,n)=>{"use strict";n.d(e,{Cn:()=>m});var i=n(976),s=n(6414),o=n.n(s),r=n(8447),a=n(8260),l=n(708),c=n(7228),h=n(1047);const u=new class{constructor(){this.uh=`units-handler.${i.SEMTYPE.MACROMOLECULE}`}},d={[r.r2.FASTA]:"-",[r.r2.SEPARATOR]:"",[r.r2.HELM]:"*"};class m{static setUnitsToFastaColumn(t){if(t.column.semType!==i.SEMTYPE.MACROMOLECULE||t.column.getTag(i.TAGS.UNITS)!==r.r2.FASTA)throw new Error(`The column of notation '${r.r2.FASTA}' must be '${i.SEMTYPE.MACROMOLECULE}'.`);t.column.setTag(i.TAGS.UNITS,r.r2.FASTA),m.setTags(t)}static setUnitsToSeparatorColumn(t,e){if(t.column.semType!==i.SEMTYPE.MACROMOLECULE||t.column.getTag(i.TAGS.UNITS)!==r.r2.SEPARATOR)throw new Error(`The column of notation '${r.r2.SEPARATOR}' must be '${i.SEMTYPE.MACROMOLECULE}'.`);if(!e)throw new Error(`The column of notation '${r.r2.SEPARATOR}' must have the separator tag.`);t.column.setTag(i.TAGS.UNITS,r.r2.SEPARATOR),t.column.setTag("separator",e),m.setTags(t)}static setUnitsToHelmColumn(t){if(t.column.semType!==i.SEMTYPE.MACROMOLECULE)throw new Error(`The column of notation '${r.r2.HELM}' must be '${i.SEMTYPE.MACROMOLECULE}'`);t.column.setTag(i.TAGS.UNITS,r.r2.HELM),m.setTags(t)}static setTags(t){const e=t.column.getTag(i.TAGS.UNITS),n=t.stats;if(Object.keys(n.freq).some((t=>t.length>1)),[r.r2.FASTA,r.r2.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 i=t.column.getTag("alphabet");if(null===i&&(i=(0,a.w4)(n.freq,r.XS),t.column.setTag("alphabet",i)),"UN"===i){const e=Object.keys(n.freq).length,i=Object.keys(n.freq).some((t=>t.length>1));t.column.setTag(".alphabetSize",e.toString()),t.column.setTag(".alphabetIsMultichar",i?"true":"false")}}}get column(){return this._column}get units(){return this._units}get notation(){return this._notation}get defaultGapSymbol(){return this._defaultGapSymbol}get separator(){const t=this.column.getTag("separator")??void 0;if(this.notation===r.r2.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==r.r2.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===r.r2.HELM||"UN"===this.alphabet&&"true"===this.column.getTag(".alphabetIsMultichar")}get splitted(){if(null===this._splitted){const t=this.getSplitter(),e=this._column.length;this._splitted=new Array(e);const n=this._column.getRawData(),i=this._column.categories;for(let s=0;s<e;s++){const e=i[n[s]];this._splitted[s]=t(e)}}return this._splitted}get stats(){if(null===this._stats){const t={};let e=!0,n=null;for(const i of this.splitted){null==n?n=i.length:i.length!==n&&(e=!1);for(const e of i)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.splitted.length?0:Math.max(...this.splitted.map((t=>t.length)))),this._maxLength}get posList(){if(null===this._posList){const t=this.column.getTag(".positionNames");this._posList=t?t.split(r.CI).map((t=>t.trim())):o().count(1).take(this.maxLength).map((t=>t.toString())).toArray()}return this._posList}isFasta(){return this.notation===r.r2.FASTA}isSeparator(){return this.notation===r.r2.SEPARATOR}isHelm(){return this.notation===r.r2.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||this.units===r.r2.FASTA&&t===d[r.r2.FASTA]||this.units===r.r2.HELM&&t===d[r.r2.HELM]}getNotation(){if(this.units.toLowerCase().startsWith(r.r2.FASTA))return r.r2.FASTA;if(this.units.toLowerCase().startsWith(r.r2.SEPARATOR))return r.r2.SEPARATOR;if(this.units.toLowerCase().startsWith(r.r2.HELM))return r.r2.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 o=this.column,a=t.toLowerCase()+"("+o.name+")",l=n??o.dataFrame.columns.getUnusedName(a),c=i.Column.fromList("string",l,s??new Array(this.column.length).fill(""));if(c.semType=i.SEMTYPE.MACROMOLECULE,c.setTag(i.TAGS.UNITS,t),t===r.r2.SEPARATOR){if(!e)throw new Error(`Notation '${r.r2.SEPARATOR}' requires separator value.`);c.setTag("separator",e)}c.setTag(i.TAGS.CELL_RENDERER,"Macromolecule");const h=o.getTag("aligned");h&&c.setTag("aligned",h);const u=o.getTag("alphabet");null!=u&&c.setTag("alphabet",u);let d=o.getTag(".alphabetSize");null!=u&&d&&c.setTag(".alphabetSize",d);const m=o.getTag(".alphabetIsMultichar");return null!=u&&void 0!==m&&c.setTag(".alphabetIsMultichar",m),t==r.r2.HELM&&(d=this.getAlphabetSize().toString(),c.setTag(".alphabetSize",d)),c}getNewColumnFromList(t,e){return this.getNewColumn(this.notation,this.separator,t,e)}static getNewColumn(t){const e=m.getOrCreate(t),n=e.notation;return e.getNewColumn(n)}static unitsStringIsValid(t){return t=t.toLowerCase(),[r.r2.FASTA,r.r2.SEPARATOR,r.r2.HELM].some((e=>t.startsWith(e.toLowerCase())))}static getNewColumnFromParams(t,e,n){if(!m.unitsStringIsValid(n))throw new Error("Invalid format of 'units' parameter");const s=i.Column.fromList("string",e,new Array(t).fill(""));return s.semType=i.SEMTYPE.MACROMOLECULE,s.setTag(i.TAGS.UNITS,n),s}getSplitter(t){if(this.units.toLowerCase().startsWith(r.r2.FASTA))return null===this.column.getTag("alphabet")||this.getAlphabetIsMultichar()?a.kB:a.FJ;if(this.units.toLowerCase().startsWith(r.r2.SEPARATOR))return(0,a.Ar)(this.separator,t);if(this.units.toLowerCase().startsWith(r.r2.HELM))return a.gP;throw new Error(`Unexpected units ${this.units} .`)}getDistanceFunctionName(){if(!this.isFasta())throw new Error("Only FASTA notation is supported");return this.isMsa()?l.U.HAMMING:(this.alphabet,l.U.LEVENSHTEIN)}getDistanceFunction(){return l.o[this.getDistanceFunctionName()]()}async checkHelmCompatibility(){if(this.column.tags.has(".isHelmCompatible"))return"true"===this.column.getTag(".isHelmCompatible");const t=(await(0,c.JN)()).getBioLib().getMonomerSymbolsByType("PEPTIDE".toString()),e=new Set(t),n=(0,a.Ar)(this.separator);for(const t of this.column.categories){const i=n(t);for(const t of i)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=(0,a.Mj)(this.column)),this._splitter}toFasta(t){return t===r.r2.FASTA}toSeparator(t){return t===r.r2.SEPARATOR}toHelm(t){return t===r.r2.HELM}convertHelmToFastaSeparator(t,e,n,i){i||(i=this.toFasta(e)?d[r.r2.FASTA]:d[r.r2.SEPARATOR]),n||(n=this.toFasta(e)?"":this.separator);const s=t.startsWith("RNA"),o=this.splitter(t),a=[];for(let t=0;t<o.length;t++){let n=o[t];if(s&&(n=n.replace(h.pU,"")),n===d[r.r2.HELM])a.push(i);else if(this.toFasta(e)&&n.length>1){const t="["+n+"]";a.push(t)}else a.push(n)}return a.join(n)}convert(t,e){const n=this.getConverter(t,e),i=this.getNewColumn(t,e);return i.init((t=>n(this.column.get(t)))),i}getRegion(t,e,n){const i=this.getNewColumn(this.notation,this.separator);i.name=n,Math.max(...this.splitted.map((t=>t.length)));const s=t??0,o=e??this.maxLength-1,a=this.getJoiner(),l=o-s+1;i.init((t=>{const e=this.splitted[t],n=new Array(l);for(let t=0;t<l;++t){const i=s+t;n[t]=i<e.length?e[i]:d[this.notation]}return a(n)}));const c=t=>{const e=t.split(",").map((t=>t.trim())),n=new Array(l);for(let t=0;t<l;++t){const i=s+t;n[t]=i<e.length?e[i]:"?"}return n.join(r.CI)},h=this.column.getTag(".positionNames");h&&i.setTag(".positionNames",c(h));const u=this.column.getTag(".positionLabels");return u&&i.setTag(".positionLabels",c(u)),i}getJoiner(){if(void 0===this._joiner){const t=this;if(this.notation===r.r2.FASTA)this._joiner=function(e){return p(t,e)};else if(this.notation===r.r2.SEPARATOR)this._joiner=function(e){return g(t,e,t.separator)};else{if(this.notation!==r.r2.HELM)throw new Error;{const e="DNA"===t.alphabet||"RNA"===t.alphabet;this._joiner=function(n){return f(t,n,e)}}}}return this._joiner}getConverter(t,e=undefined){if(t===r.r2.SEPARATOR&&!e)throw new Error(`Target separator is not specified for target units '${r.r2.SEPARATOR}'.`);const n=this;if(t===r.r2.FASTA)return function(t){return function(t,e){const n=t.isHelm()?y(t,e):t.getSplitter()(e);return p(t,n)}(n,t)};if(t===r.r2.HELM)return function(t){return function(t,e){const n=e.startsWith("DNA")||e.startsWith("RNA"),i=t.getSplitter()(e);return f(t,i,n)}(n,t)};if(t===r.r2.SEPARATOR)return function(t){return function(t,e,n){const i=t.isHelm()?y(t,e):t.getSplitter()(e);return g(t,i,n)}(n,t,e)};throw new Error}constructor(t){if(this._splitter=null,this._splitted=null,this._stats=null,this._maxLength=null,this._posList=null,this._joiner=void 0,t.type!==i.TYPE.STRING)throw new Error(`Unexpected column type '${t.type}', must be '${i.TYPE.STRING}'.`);this._column=t;const e=this._column.getTag(i.TAGS.UNITS);if(null==e)throw new Error("Units are not specified in column");if(this._units=e,this._notation=this.getNotation(),this._defaultGapSymbol=this.isFasta()?d[r.r2.FASTA]:this.isHelm()?d[r.r2.HELM]:d[r.r2.SEPARATOR],!this.column.tags.has("aligned")||!this.column.tags.has("alphabet")||!this.column.tags.has(".alphabetIsMultichar")&&!this.isHelm()&&"UN"===this.alphabet)if(this.isFasta())m.setUnitsToFastaColumn(this);else if(this.isSeparator()){const e=t.getTag("separator");m.setUnitsToSeparatorColumn(this,e)}else{if(!this.isHelm())throw new Error(`Unexpected units '${this.column.getTag(i.TAGS.UNITS)}'.`);m.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 getOrCreate(t){let e=t.temp[u.uh];return e||(e=t.temp[u.uh]=new m(t)),e}}function p(t,e){const n=new Array(e.length);for(const[i,s]of o().enumerate(e)){let o=i;t.isHelm()&&(o=i.replace(h.pU,"$1")),t.isGap(o)?o=d[r.r2.FASTA]:o.length>1&&(o="["+e[s]+"]"),n[s]=o}return n.join("")}function g(t,e,n){const i=new Array(e.length);for(const[n,s]of o().enumerate(e)){let e=n;t.isGap(e)&&(e=d[r.r2.SEPARATOR]),i[s]=e}return i.map((t=>t??"")).join(n)}function f(t,e,n){const[i,s,a,l]=t.getHelmWrappers();return`${i}${o()(e).map((e=>{let i=e;return i=t.isGap(i)?d[r.r2.HELM]:n?i.replace(h.pU,"$1"):1==e.length?`${s}${e}${a}`:`${s}[${e}]${a}`,i})).toArray().join(".")}${l}`}function y(t,e){const n=t.getSplitter()(e),i=new Array(n.length),s=e.startsWith("DNA"),r=e.startsWith("RNA");for(const[t,e]of o().enumerate(n)){let n=t;(s||r)&&(n=n.replace(h.pU,"$1"),n=n===h.$3?null:n),i[e]=n}return i.filter((t=>null!==t))}},9298:(t,e,n)=>{"use strict";n.d(e,{Ct:()=>l,DX:()=>i,ES:()=>s,dE:()=>a,iD:()=>r,vS:()=>h,vw:()=>o});var i,s,o,r,a,l,c=n(976);!function(t){t.tooltipWebLogo=".tooltipWebLogo"}(i||(i={})),function(t){t.Entropy="Entropy",t.full="100%"}(s||(s={})),function(t){t.TOP="top",t.MIDDLE="middle",t.BOTTOM="bottom"}(o||(o={})),function(t){t.LEFT="left",t.CENTER="center",t.RIGHT="right"}(r||(r={})),function(t){t.AUTO="auto",t.ON="on",t.OFF="off"}(a||(a={})),function(t){t.Filtered="Filtered",t.Selected="Selected"}(l||(l={}));const h=new class{constructor(){this.sequenceColumnName=null,this.valueAggrType=c.AGG.TOTAL_COUNT,this.valueColumnName="Activity",this.startPositionName=null,this.endPositionName=null,this.skipEmptySequences=!0,this.skipEmptyPositions=!1,this.shrinkEmptyTail=!0,this.backgroundColor=4294967295,this.positionHeight=s.Entropy,this.positionWidth=16,this.verticalAlignment=o.MIDDLE,this.horizontalAlignment=r.CENTER,this.fixWidth=!1,this.fitArea=!0,this.minHeight=50,this.maxHeight=100,this.showPositionLabels=!0,this.positionMarginState=a.AUTO,this.positionMargin=0,this.filterSource=l.Filtered}}},922:(t,e,n)=>{"use strict";n.d(e,{_:()=>l});class i{constructor(t){this.init(t)}init(t){this.fileContent=t.replace(/\r/g,""),this._atomCount=void 0,this._atomTypes=void 0,this._bondCount=void 0,this._bondTypes=void 0,this.xyzAtomCoordinates=void 0,this._pairsOfBondedAtoms=void 0}get atomCount(){return void 0===this._atomCount&&this.setAtomAndBondCounts(),this._atomCount}get bondCount(){return void 0===this._bondCount&&this.setAtomAndBondCounts(),this._bondCount}get x(){var t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.x}get y(){var t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.y}get z(){var t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.z}get atomTypes(){var t;return null!==(t=this._atomTypes)&&void 0!==t||(this._atomTypes=this.parseAtomTypes()),this._atomTypes}get pairsOfBondedAtoms(){var t;return null!==(t=this._pairsOfBondedAtoms)&&void 0!==t||(this._pairsOfBondedAtoms=this.parseBondedAtomPairs()),this._pairsOfBondedAtoms}get bondTypes(){var t;return null!==(t=this._bondTypes)&&void 0!==t||(this._bondTypes=this.parseBondTypes()),this._bondTypes}setAtomAndBondCounts(){const{atomCount:t,bondCount:e}=this.parseAtomAndBondCounts();this._atomCount=t,this._bondCount=e}getNextColumnIdx(t){for(;!this.isWhitespace(t);)++t;for(;this.isWhitespace(t);)++t;return t}shiftIdxToSpecifiedColumn(t,e){let n=t;const i=this.isWhitespace(n)?e:e-1;for(let t=0;t<i;t++)n=this.getNextColumnIdx(n);return n}parseAtomTypes(){const t=this.atomCount,e=new Array(t);let n=this.getAtomBlockIdx();for(let i=0;i<t;i++)n=this.shiftIdxToAtomType(n),e[i]=this.parseAtomType(n),n=this.getNextLineIdx(n);return e}parseAtomCoordinates(){const t=new Float32Array(this.atomCount),e=new Float32Array(this.atomCount),n=new Float32Array(this.atomCount);let i=this.getAtomBlockIdx();for(let s=0;s<this.atomCount;s++){i=this.shiftIdxToXColumn(i);for(const o of[t,e,n])o[s]=this.parseFloatValue(i),i=this.getNextColumnIdx(i);i=this.getNextLineIdx(i)}return{x:t,y:e,z:n}}parseBondedAtomPairs(){const t=new Array(this.bondCount);let e=this.getBondBlockIdx();for(let n=0;n<this.bondCount;n++){e=this.shiftIdxToBondedAtomsPair(e);const i=new Uint16Array(2);i[0]=this.parseIntValue(e),e=this.getNextColumnIdx(e),i[1]=this.parseIntValue(e),t[n]=i,e=this.getNextLineIdx(e)}return t}parseBondTypes(){const t=this.bondCount,e=new Uint16Array(t);let n=this.getBondBlockIdx();for(let i=0;i<t;i++)n=this.shiftIdxToBondType(n),e[i]=this.parseIntValue(n),n=this.getNextLineIdx(n);return e}isWhitespace(t){const e=this.fileContent[t];return" "===e||"\t"===e}getNextLineIdx(t){return"\n"!==this.fileContent[t]?this.fileContent.indexOf("\n",t)+1:t+1}parseFloatValue(t){return this.parseNumericValue(parseFloat,t)}parseIntValue(t){return this.parseNumericValue(parseInt,t)}parseNumericValue(t,e){let n=e+1;for(;!this.isWhitespace(n);)++n;return t(this.fileContent.substring(e,n))}}class s extends i{constructor(t){super(t),this.init(t)}init(t){super.init(t)}parseAtomType(t){let e=t,n=e;return this.isQuote(e)?(n=this.getNextIdenticalChar(e),e++):n=this.fileContent.indexOf(" ",n),this.fileContent.substring(e,n)}isQuote(t){const e=this.fileContent[t].charCodeAt(0);return 39===e||34===e}getNextIdenticalChar(t){const e=this.fileContent[t];return e?this.fileContent.indexOf(e,t+1):-1}isQuery(){return this.isQueryOrFragment(((t,e)=>{return 39===t||34===t||76===t&&!((n=this.fileContent.charCodeAt(e+1))>64&&n<91||n>96&&n<123);var n}))}isFragment(){return this.isQueryOrFragment((t=>82===t||42===t))}isQueryOrFragment(t){const e=this.atomCount;let n=this.getAtomBlockIdx();for(let i=0;i<e;i++){if(n=this.shiftIdxToAtomType(n),t(this.fileContent.charCodeAt(n),n))return!0;n=this.getNextLineIdx(n)}return!1}}var o;!function(t){t.HEADER="V2000",t[t.NUM_OF_HEADER_LINES=3]="NUM_OF_HEADER_LINES",t[t.NUM_OF_COUNTS_DIGITS=3]="NUM_OF_COUNTS_DIGITS",t[t.ATOM_TYPE_COL=4]="ATOM_TYPE_COL",t[t.FIRST_BONDED_ATOM_COL=1]="FIRST_BONDED_ATOM_COL",t[t.BOND_TYPE_COL=3]="BOND_TYPE_COL",t[t.RGP_SHIFT=8]="RGP_SHIFT",t.RGP_LINE="M RGP",t.A_LINE="A ",t.END="M END"}(o||(o={}));class r extends s{constructor(t){super(t)}static validate(t){return-1!==t.indexOf(o.HEADER)&&-1!==t.indexOf(o.END)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,o.ATOM_TYPE_COL)}getCountsLineIdx(){let t=0;for(let e=0;e<o.NUM_OF_HEADER_LINES;++e)t=this.getNextLineIdx(t);return t}getAtomBlockIdx(){let t=this.getCountsLineIdx();return t=this.getNextLineIdx(t),t}shiftIdxToXColumn(t){return this.getNextColumnIdx(t)}shiftIdxToBondedAtomsPair(t){return this.shiftIdxToSpecifiedColumn(t,o.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,o.BOND_TYPE_COL)}getBondBlockIdx(){let t=this.getAtomBlockIdx();for(let e=0;e<this.atomCount;e++)t=this.getNextLineIdx(t);return t}parseAtomAndBondCounts(){let t=this.getCountsLineIdx(),e=t+o.NUM_OF_COUNTS_DIGITS;const n=parseInt(this.fileContent.substring(t,e));return t=e,e+=o.NUM_OF_COUNTS_DIGITS,{atomCount:n,bondCount:parseInt(this.fileContent.substring(t,e))}}}class a extends s{constructor(t){super(t),this.init(t)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getCountsLineIdx(){return this.fileContent.indexOf("M V30 COUNTS ")}getAtomBlockIdx(){let t=this.fileContent.indexOf("M V30 BEGIN ATOM");return t=this.getNextLineIdx(t),t}shiftIdxToXColumn(t){let e=this.shiftIdxToAtomType(t);return this.isQuote(e)?(e=this.getNextIdenticalChar(e),e=this.getNextColumnIdx(e),e):this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondedAtomsPair(t){return this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getBondBlockIdx(){return this.getNextLineIdx(this.fileContent.indexOf("M V30 BEGIN BOND"))}static validate(t){return-1!==t.indexOf("V3000")&&-1!==t.indexOf("M END")}parseAtomAndBondCounts(){let t=this.fileContent.indexOf("M V30 COUNTS ")+14,e=this.fileContent.indexOf(" ",t+1);const n=parseInt(this.fileContent.substring(t,e));return t=e+1,e=this.fileContent.indexOf(" ",t+1),{atomCount:n,bondCount:parseInt(this.fileContent.substring(t,e))}}}class l{constructor(){}static getInstance(t){if(r.validate(t))return new r(t);if(a.validate(t))return new a(t);throw new Error("Malformed molfile")}}},7905:(t,e,n)=>{"use strict";t=n.hmd(t);var i,s=(i="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(t={}){var e,n,s=void 0!==t?t:{};s.ready=new Promise((function(t,i){e=t,n=i}));var o,r=Object.assign({},s),a="object"==typeof window,l="function"==typeof importScripts,c=("object"==typeof process&&"object"==typeof process.versions&&process.versions.node,"");(a||l)&&(l?c=self.location.href:"undefined"!=typeof document&&document.currentScript&&(c=document.currentScript.src),i&&(c=i),c=0!==c.indexOf("blob:")?c.substr(0,c.replace(/[?#].*/,"").lastIndexOf("/")+1):"",l&&(o=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)})),s.print||console.log.bind(console);var h,u,d=s.printErr||console.warn.bind(console);Object.assign(s,r),r=null,s.arguments&&s.arguments,s.thisProgram&&s.thisProgram,s.quit&&s.quit,s.wasmBinary&&(h=s.wasmBinary),s.noExitRuntime,"object"!=typeof WebAssembly&&x("no native wasm support detected");var m,p,g,f=!1;function y(){var t=u.buffer;s.HEAP8=m=new Int8Array(t),s.HEAP16=new Int16Array(t),s.HEAP32=new Int32Array(t),s.HEAPU8=p=new Uint8Array(t),s.HEAPU16=new Uint16Array(t),s.HEAPU32=g=new Uint32Array(t),s.HEAPF32=new Float32Array(t),s.HEAPF64=new Float64Array(t)}var b=[],C=[],w=[],v=0,S=null,A=null;function x(t){s.onAbort&&s.onAbort(t),d(t="Aborted("+t+")"),f=!0,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw n(e),e}var T,I,M="data:application/octet-stream;base64,";function L(t){return t.startsWith(M)}function E(t){try{if(t==T&&h)return new Uint8Array(h);if(o)return o(t);throw"both async and sync fetching of the wasm failed"}catch(t){x(t)}}function N(t,e,n){return function(t){return h||!a&&!l||"function"!=typeof fetch?Promise.resolve().then((function(){return E(t)})):fetch(t,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+t+"'";return e.arrayBuffer()})).catch((function(){return E(t)}))}(t).then((function(t){return WebAssembly.instantiate(t,e)})).then((function(t){return t})).then(n,(function(t){d("failed to asynchronously prepare wasm: "+t),x(t)}))}function R(t){for(;t.length>0;)t.shift()(s)}function _(t){this.excPtr=t,this.ptr=t-24,this.set_type=function(t){g[this.ptr+4>>2]=t},this.get_type=function(){return g[this.ptr+4>>2]},this.set_destructor=function(t){g[this.ptr+8>>2]=t},this.get_destructor=function(){return g[this.ptr+8>>2]},this.set_caught=function(t){t=t?1:0,m[this.ptr+12>>0]=t},this.get_caught=function(){return 0!=m[this.ptr+12>>0]},this.set_rethrown=function(t){t=t?1:0,m[this.ptr+13>>0]=t},this.get_rethrown=function(){return 0!=m[this.ptr+13>>0]},this.init=function(t,e){this.set_adjusted_ptr(0),this.set_type(t),this.set_destructor(e)},this.set_adjusted_ptr=function(t){g[this.ptr+16>>2]=t},this.get_adjusted_ptr=function(){return g[this.ptr+16>>2]},this.get_exception_ptr=function(){if(V(this.get_type()))return g[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}function O(t){var e=u.buffer;try{return u.grow(t-e.byteLength+65535>>>16),y(),1}catch(t){}}function P(t){return s["_"+t]}L(T="wasmDbscan.wasm")||(I=T,T=s.locateFile?s.locateFile(I,c):c+I);var G="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function k(t,e,n,i,s){var o={string:t=>{var e=0;return null!=t&&0!==t&&(e=function(t){var e=function(t){for(var e=0,n=0;n<t.length;++n){var i=t.charCodeAt(n);i<=127?e++:i<=2047?e+=2:i>=55296&&i<=57343?(e+=4,++n):e+=3}return e}(t)+1,n=D(e);return function(t,e,n){!function(t,e,n,i){if(!(i>0))return 0;for(var s=n+i-1,o=0;o<t.length;++o){var r=t.charCodeAt(o);if(r>=55296&&r<=57343&&(r=65536+((1023&r)<<10)|1023&t.charCodeAt(++o)),r<=127){if(n>=s)break;e[n++]=r}else if(r<=2047){if(n+1>=s)break;e[n++]=192|r>>6,e[n++]=128|63&r}else if(r<=65535){if(n+2>=s)break;e[n++]=224|r>>12,e[n++]=128|r>>6&63,e[n++]=128|63&r}else{if(n+3>=s)break;e[n++]=240|r>>18,e[n++]=128|r>>12&63,e[n++]=128|r>>6&63,e[n++]=128|63&r}}e[n]=0}(t,p,e,n)}(t,n,e),n}(t)),e},array:t=>{var e,n,i=D(t.length);return e=t,n=i,m.set(e,n),i}},r=P(t),a=[],l=0;if(i)for(var c=0;c<i.length;c++){var h=o[n[c]];h?(0===l&&(l=W()),a[c]=h(i[c])):a[c]=i[c]}var u=r.apply(null,a);return function(t){return 0!==l&&H(l),function(t){return"string"===e?(n=t)?function(t,e,n){for(var i=e+n,s=e;t[s]&&!(s>=i);)++s;if(s-e>16&&t.buffer&&G)return G.decode(t.subarray(e,s));for(var o="";e<s;){var r=t[e++];if(128&r){var a=63&t[e++];if(192!=(224&r)){var l=63&t[e++];if((r=224==(240&r)?(15&r)<<12|a<<6|l:(7&r)<<18|a<<12|l<<6|63&t[e++])<65536)o+=String.fromCharCode(r);else{var c=r-65536;o+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else o+=String.fromCharCode((31&r)<<6|a)}else o+=String.fromCharCode(r)}return o}(p,n,i):"":"boolean"===e?Boolean(t):t;var n,i}(t)}(u)}var F,B={__cxa_throw:function(t,e,n){throw new _(t).init(e,n),t},abort:function(){x("")},emscripten_memcpy_big:function(t,e,n){p.copyWithin(t,e,e+n)},emscripten_resize_heap:function(t){var e,n=p.length,i=2147483648;if((t>>>=0)>i)return!1;for(var s=1;s<=4;s*=2){var o=n*(1+.2/s);if(o=Math.min(o,t+100663296),O(Math.min(i,(e=Math.max(t,o))+(65536-e%65536)%65536)))return!0}return!1}},W=(function(){var t,e,i,o,r={env:B,wasi_snapshot_preview1:B};function a(t,e){var n,i=t.exports;return s.asm=i,u=s.asm.memory,y(),s.asm.__indirect_function_table,n=s.asm.__wasm_call_ctors,C.unshift(n),function(t){if(v--,s.monitorRunDependencies&&s.monitorRunDependencies(v),0==v&&(null!==S&&(clearInterval(S),S=null),A)){var e=A;A=null,e()}}(),i}if(v++,s.monitorRunDependencies&&s.monitorRunDependencies(v),s.instantiateWasm)try{return s.instantiateWasm(r,a)}catch(t){d("Module.instantiateWasm callback failed with error: "+t),n(t)}(t=h,e=T,i=r,o=function(t){a(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||L(e)||"function"!=typeof fetch?N(e,i,o):fetch(e,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,i).then(o,(function(t){return d("wasm streaming compile failed: "+t),d("falling back to ArrayBuffer instantiation"),N(e,i,o)}))}))).catch(n)}(),s._dbscan=function(){return(s._dbscan=s.asm.dbscan).apply(null,arguments)},s._malloc=function(){return(s._malloc=s.asm.malloc).apply(null,arguments)},s._free=function(){return(s._free=s.asm.free).apply(null,arguments)},function(){return(W=s.asm.stackSave).apply(null,arguments)}),H=function(){return(H=s.asm.stackRestore).apply(null,arguments)},D=function(){return(D=s.asm.stackAlloc).apply(null,arguments)},V=function(){return(V=s.asm.__cxa_is_pointer_type).apply(null,arguments)};function U(){function t(){F||(F=!0,s.calledRun=!0,f||(R(C),e(s),s.onRuntimeInitialized&&s.onRuntimeInitialized(),function(){if(s.postRun)for("function"==typeof s.postRun&&(s.postRun=[s.postRun]);s.postRun.length;)t=s.postRun.shift(),w.unshift(t);var t;R(w)}()))}v>0||(function(){if(s.preRun)for("function"==typeof s.preRun&&(s.preRun=[s.preRun]);s.preRun.length;)t=s.preRun.shift(),b.unshift(t);var t;R(b)}(),v>0||(s.setStatus?(s.setStatus("Running..."),setTimeout((function(){setTimeout((function(){s.setStatus("")}),1),t()}),1)):t()))}if(s.ccall=k,s.cwrap=function(t,e,n,i){var s=!n||n.every((t=>"number"===t||"boolean"===t));return"string"!==e&&s&&!i?P(t):function(){return k(t,e,n,arguments)}},A=function t(){F||U(),F||(A=t)},s.preInit)for("function"==typeof s.preInit&&(s.preInit=[s.preInit]);s.preInit.length>0;)s.preInit.pop()();return U(),t.ready});"object"==typeof exports?t.exports=s:"function"==typeof define&&n.amdO?define([],(function(){return s})):"object"==typeof exports&&(exports.exportCppDbscanLib=s)},2669:(t,e,n)=>{"use strict";n.d(e,{m:()=>i});class i{_workers;_workerCount;_terminateOnComplete;constructor(t=!0,e=!0){const i=navigator.hardwareConcurrency;this._workerCount=t?Math.max(i-2,1):1,this._workers=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(n.p+n.u(100),n.b)))),this._terminateOnComplete=e}async calc(t,e,n=!0,i){return new Promise((async(s,o)=>{try{const o=t.length,r=new Array(this._workerCount),a=o*(o-1)/2;this._workerCount=Math.min(this._workerCount,a);const l=a/this._workerCount,c=new Float32Array(a);let h=0,u=1,d=0,m=Number.MIN_VALUE;for(let n=0;n<this._workerCount;n++){const s=Math.floor(n*l),p=n===this._workerCount-1?a:Math.floor((n+1)*l),g=h,f=u;n!==this._workerCount-1&&(h=o-2-Math.floor(Math.sqrt(-8*p+4*o*(o-1)-7)/2-.5),u=p-o*h+Math.floor((h+1)*(h+2)/2)),this._workers[n].postMessage({values:t,fnName:e,startRow:g,startCol:f,chunckSize:p-s,opts:i}),r[n]=new Promise(((t,e)=>{this._workers[n].onmessage=({data:{error:i,distanceMatrixData:o,min:r,max:a}})=>{this._terminateOnComplete&&this._workers[n].terminate(),i?e(i):(c.set(o,s),r<d&&(d=r),a>m&&(m=a),t())}}))}await Promise.all(r),n&&c.forEach(((t,e)=>{c[e]=(t-d)/(m-d)})),s(c)}catch(t){o(t)}}))}terminate(){this._workers.forEach((t=>t.terminate()))}}},6254:(t,e,n)=>{"use strict";function i(t){return(e,n)=>t*e+n-Math.floor((e+2)*(e+1)/2)}n.d(e,{y:()=>i})},5697:(t,e,n)=>{"use strict";n.d(e,{Dz:()=>b,FV:()=>c,KR:()=>l,MI:()=>w,NB:()=>p,Om:()=>v,UX:()=>m,WI:()=>d,Z3:()=>a,Zd:()=>u,_h:()=>h,aW:()=>f,bX:()=>A,eo:()=>S,fX:()=>C,kg:()=>r,s:()=>g,yU:()=>y});var i=n(9657),s=n(1040),o=n(708);s.gk.Tanimoto,s.gk.Dice,s.gk.Asymmetric,s.gk.BraunBlanquet,s.gk.Cosine,s.gk.Kulczynski,s.gk.McConnaughey,s.gk.RogotGoldberg,s.gk.Russel,s.gk.Sokal,s.gk.Hamming,s.gk.Euclidean,s.gk.Tanimoto,s.gk.Dice,s.gk.Asymmetric,s.gk.BraunBlanquet,s.gk.Cosine,s.gk.Kulczynski,s.gk.McConnaughey,s.gk.RogotGoldberg,s.gk.Russel,s.gk.Sokal,s.gk.Hamming,s.gk.Euclidean;const r=[s.gk.Tanimoto,s.gk.Dice,s.gk.Cosine];function a(t,e){const n=t.trueCount()+e.trueCount();if(0==n)return 1;const i=t.andWithCountBits(e,!0);return i/(n-i)}function l(t,e){return S(a(t,e))}function c(t,e){return S(a(new i.Z(t,32*t.length),new i.Z(e,32*e.length)))}function h(t,e){return S(function(t,e){const n=t.trueCount()+e.trueCount();return 0==n?0:2*t.andWithCountBits(e,!0)/n}(t,e))}function u(t,e){return S(function(t,e){const n=t.trueCount()*e.trueCount();return 0==n?0:t.andWithCountBits(e,!0)/Math.sqrt(n)}(t,e))}function d(t,e){return Math.sqrt(t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0))}function m(t,e){return t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0)}function p(t,e){return S(function(t,e){const n=t.trueCount()+e.trueCount(),i=t.andWithCountBits(e,!0);return i/(2*n-3*i)}(t,e))}function g(t,e){return S(function(t,e){const n=t.trueCount()+e.trueCount(),i=t.trueCount()*e.trueCount();return 0==i?0:t.andWithCountBits(e,!0)*n/(2*i)}(t,e))}function f(t,e){return S(function(t,e){const n=t.trueCount()+e.trueCount(),i=t.trueCount()*e.trueCount();return 0==i?0:(t.andWithCountBits(e,!0)*n-i)/i}(t,e))}function y(t,e){return S(function(t,e){const n=Math.min(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e))}function b(t,e){return S(function(t,e){const n=Math.max(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e))}function C(t,e){return S(function(t,e){return 0==t.length?0:t.andWithCountBits(e,!0)/t.length}(t,e))}function w(t,e){return S(function(t,e){const n=t.andWithCountBits(e,!0),i=t.countBits(!0)+e.countBits(!0),s=t.length,o=s-i+n;return n==s||o==s?1:n/i+o/(2*s-i)}(t,e))}function v(t){return 1/(1+t)}function S(t){return 0===t?3402823e32:1/t-1}function A(t,e){return Math.abs(t-e)}s.gk.Tanimoto,s.gk.Asymmetric,s.gk.Cosine,s.gk.Sokal,o.U.HAMMING,o.U.LEVENSHTEIN,o.U.MONOMER_CHEMICAL_DISTANCE,o.U.NEEDLEMANN_WUNSCH},3277:(t,e,n)=>{"use strict";n.d(e,{Ec:()=>c,dB:()=>a,n3:()=>i,q6:()=>r,sS:()=>l,ts:()=>o,vO:()=>s});const i="dim-red-preprocessing-function",s="supportedSemTypes",o="supportedTypes",r="supportedUnits",a="supportedDistanceFunctions",l="bypassLargeDataWarning",c="show-scatterplot-progress"},708:(t,e,n)=>{"use strict";function i(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,i=Math.min(...Object.keys(e).map((t=>t.charCodeAt(0))))+1,s=new Float32Array((n.length+i)*(n.length+i));return Object.entries(e).forEach((([t,i])=>{const o=n[i];Object.entries(e).forEach((([e,i])=>{s[t.charCodeAt(0)*n.length+e.charCodeAt(0)]=o[i]}))})),(t,e)=>s[t.charCodeAt(0)*n.length+e.charCodeAt(0)]}(),n=t?.threshold??0;return(t,i)=>{let s=0;const o=t.length,r=i.length,a=Math.max(o,r)*(1-n);o!==r&&(s=Math.abs(o-r));let l=0;for(let n=0;n<Math.min(o,r);n++)if(t[n]!==i[n]&&(l+=e(t[n],i[n]),l>a))return 1;return l+=s,l/=Math.max(o,r),l}}n.d(e,{U:()=>r,o:()=>a});var s=n(1811);const o={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,-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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 r;!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(r||(r={}));const a={[r.HAMMING]:i,[r.LEVENSHTEIN]:function(){return(t,e)=>(0,s.T)(t,e)/Math.max(t.length,e.length)},[r.NEEDLEMANN_WUNSCH]:function(t){const e=new Uint16Array(65536),{gapOpen:n,gapExtend:i,scoringMatrix:s,alphabetIndexes:r}={...o,...t};Object.entries(r).forEach((([t,n])=>e[t.charCodeAt(0)]=n));const a=[new Float32Array(1e4),new Float32Array(1e4)];return(t,o)=>{const r=new Array(t.length+1).fill(!1),l=new Array(t.length+1).fill(!1);let c=0,h=1;for(let e=1;e<t.length+1;e++)a[0][e]=-n-(e-1)*i,a[1][e]=0;for(let u=1;u<o.length+1;u++){a[h][0]=-n-(u-1)*i;for(let d=1;d<t.length+1;d++){const m=a[c][d-1]+s[e[t.charCodeAt(d-1)]][e[o.charCodeAt(u-1)]],p=a[c][d]-(r[d]?i:n),g=a[h][d-1]-(l[d-1]?i:n);a[h][d]=Math.max(m,g,p),a[h][d]===m?(r[d]=!1,l[d]=!1):a[h][d]===g?(r[d]=!1,l[d]=!0):(r[d]=!0,l[d]=!1)}c=h,h=(h+1)%2}const u=Math.max(t.length,o.length);return(u-a[c][t.length])/u}},[r.MONOMER_CHEMICAL_DISTANCE]:i}},4628:(t,e,n)=>{"use strict";var i;n.d(e,{A:()=>i}),function(t){t.UMAP="UMAP",t.T_SNE="t-SNE"}(i||(i={}))},1040:(t,e,n)=>{"use strict";var i,s,o,r,a,l;n.d(e,{CF:()=>s,Qe:()=>a,W:()=>i,Yc:()=>l,gd:()=>r,gk:()=>o}),function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan",t.Onehot="One-Hot"}(i||(i={})),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"}(o||(o={})),function(t){t.TanimotoIntArray="TanimotoIntArray"}(r||(r={})),function(t){t.Vector="Vector",t.String="String",t.BitArray="BitArray",t.MacroMolecule="MacroMolecule",t.Number="Number",t.IntArray="IntArray"}(a||(a={})),function(t){t.Difference="Difference"}(l||(l={}))},6361:(t,e,n)=>{"use strict";n.d(e,{W:()=>i.W,gk:()=>i.gk});var i=n(1040);n(7861)},7861:(t,e,n)=>{"use strict";n.d(e,{sQ:()=>f});var i=n(1811),s=n(3979),o=n(5697),r=n(850),a=n(708),l=n(1040);const c={[l.CF.Euclidean]:r.dP},h={[l.W.Levenshtein]:i.T,[l.W.JaroWinkler]:s.H$,[l.W.Manhattan]:function(t,e){if(t.length!==e.length)return 1;{let n=0;for(let i=1;i<t.length;i++)n+=t[i]==e[i]?0:1;return n/t.length}},[l.W.Onehot]:function(t,e){return t===e?0:1}},u={[l.gk.Tanimoto]:o.KR,[l.gk.Dice]:o._h,[l.gk.Asymmetric]:o.yU,[l.gk.BraunBlanquet]:o.Dz,[l.gk.Cosine]:o.Zd,[l.gk.Kulczynski]:o.s,[l.gk.McConnaughey]:o.aW,[l.gk.RogotGoldberg]:o.MI,[l.gk.Russel]:o.fX,[l.gk.Sokal]:o.NB,[l.gk.Hamming]:o.UX,[l.gk.Euclidean]:o.WI},d={[l.gd.TanimotoIntArray]:o.FV},m={[l.Yc.Difference]:o.bX},p={[l.Qe.Vector]:{[l.CF.Euclidean]:c[l.CF.Euclidean]},[l.Qe.String]:{[l.W.Levenshtein]:h[l.W.Levenshtein],[l.W.JaroWinkler]:h[l.W.JaroWinkler],[l.W.Manhattan]:h[l.W.Manhattan],[l.W.Onehot]:h[l.W.Onehot]},[l.Qe.BitArray]:{[l.gk.Tanimoto]:u[l.gk.Tanimoto],[l.gk.Dice]:u[l.gk.Dice],[l.gk.Asymmetric]:u[l.gk.Asymmetric],[l.gk.BraunBlanquet]:u[l.gk.BraunBlanquet],[l.gk.Cosine]:u[l.gk.Cosine],[l.gk.Kulczynski]:u[l.gk.Kulczynski],[l.gk.McConnaughey]:u[l.gk.McConnaughey],[l.gk.RogotGoldberg]:u[l.gk.RogotGoldberg],[l.gk.Russel]:u[l.gk.Russel],[l.gk.Sokal]:u[l.gk.Sokal]},[l.Qe.MacroMolecule]:{[a.U.HAMMING]:a.o[a.U.HAMMING],[a.U.LEVENSHTEIN]:a.o[a.U.LEVENSHTEIN],[a.U.NEEDLEMANN_WUNSCH]:a.o[a.U.NEEDLEMANN_WUNSCH],[a.U.MONOMER_CHEMICAL_DISTANCE]:a.o[a.U.MONOMER_CHEMICAL_DISTANCE]},[l.Qe.Number]:{[l.Yc.Difference]:m[l.Yc.Difference]},[l.Qe.IntArray]:{[l.gd.TanimotoIntArray]:d[l.gd.TanimotoIntArray]}},g=Object.keys(p).reduce(((t,e)=>{for(const n of Object.keys(p[e]))t[n]=e;return t}),{});function f(t){return"BitArray"==g[t]}},9657:(t,e,n)=>{"use strict";n.d(e,{Z:()=>i});class i{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,s=i._createBuffer(n);if(e)for(let t=0;t<s.length;t++)s[t]=-1;this._data=s,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,i){if(t<e||t>n)throw new Error(`Argument ${i} (${t}) out of range (${e}, ${n})`)}copy(t,e,n){for(let i=0;i<n;i++)e[i]=t[i]}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 i(t._length);n._length=t._length,n._data=i._createBuffer(n._length),n._version=0;const s=t.lengthInInts;for(let i=0;i<s;i++)n._data[i]=t._data[i]&e._data[i];return n}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new i(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 i(t);for(let i=0;i<t;++i)n.setBit(i,e(i));return n._version=0,n}static fromString(t){return i.fromSeq(t.length,(e=>"1"==t.charAt(e)))}static fromUint32Array(t,e){const n=new i(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new i(8*e);n._data=new Uint32Array(Math.floor((e+3)/4)),n._length=8*e;let s=0,o=0;for(;e-o>=4;)n._data[s++]=255&t[o]|(255&t[o+1])<<8|(255&t[o+2])<<16|(255&t[o+3])<<24,o+=4;return e-o==3&&(n._data[s]=(255&t[o+2])<<16),e-o==2&&(n._data[s]|=(255&t[o+1])<<8),e-o==1&&(n._data[s]|=255&t[o]),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 i(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,i=this.lengthInInts;for(let t=0;t<i;t++)this._data[t]=n;this.incrementVersion(e)}setIndexes(t,e=!0,n=!0,i=!0){n&&this.setAll(!e,!1);for(const n of t)this.setFast(n,e);this.incrementVersion(i)}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,i=!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(i)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let i=t;i<e;++i)n.push(this.getBit(i));return i.fromValues(n)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let i=t;i<e;++i)n.push(this.getBit(i));return n}setRange(t,e,n,i=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const s=Math.min(t,e),o=Math.max(t,e);if(n)for(let t=s;t<=o;t++)this.setTrue(t);else for(let t=s;t<=o;t++)this.setFalse(t);return this.incrementVersion(i),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 i=this._length;this.setLength(this._length+e);for(let n=i-1;n>=t;n--)this.setBit(n+e,this.getBit(n));for(let i=t;i<t+e;i++)this.setBit(i,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 i=-1;-1!=(i=t.findNext(i,!e));)this.setFast(n++,this.getBit(i));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+=i._onBitCount[255&t];let n=this._data[e];const s=31&this._length;for(0!=s&&(n&=~(4294967295<<s));0!=n;n>>>=8)this._selectedCount+=i._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 s=this.lengthInInts;let o=0;for(;o<s-1;o++)for(let e=this._data[o]&t._data[o];0!=e;e>>>=8)n+=i._onBitCount[255&e];let r=this._data[o]&t._data[o];const a=31&this._length;for(0!=a&&(r&=~(4294967295<<a));0!=r;r>>>=8)n+=i._onBitCount[255&r];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 s=this.lengthInInts;for(let o=Math.floor(t/32);o<s;o++){let s=e?this._data[o]:~this._data[o];if(0!=n)s&=4294967295<<n&4294967295,n=0;else if(!e&&-4294967296==s)continue;for(let e=0;0!=s;e+=8,s>>>=8){const n=i._firstOnBit[255&s];if(n>=0)return(t=n+32*o+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 s=Math.floor(t/32);s>=0;s--){let t=e?this._data[s]:~this._data[s];0!=n&&(t&=~(4294967295<<n),n=0);for(let e=24;0!=t;e-=8,t<<=8){const n=i._lastOnBit[t>>>24];if(n>=0)return n+32*s+e}}return-1}}i._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,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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])},279:(t,e,n)=>{"use strict";function i(t,e,n){function i(t,e){let n=null,i=null;for(const s of t){const t=e(s);(null==i||t>i)&&(n=s,i=t)}return n}const s=[(r=t-1,Math.floor(function(t){return Math.random()*t}(r)))],o=new Set;var r;for(let e=0;e<t;++e)s.includes(e)||o.add(e);for(;s.length<e;){const t=i(o.values(),(t=>Math.min.apply(Math,s.map((function(e,i){return n(t,e)})))));null!=t&&(s.push(t),o.delete(t))}return s}n.d(e,{L:()=>i})},8467:(t,e,n)=>{"use strict";n.d(e,{gw:()=>a,zg:()=>r}),n(4469);var i=n(976);n(9133),i.DataFrame.fromCsv('countries,fasta,smiles,molregno,LON,Zip Code,Street Address Line 1,ImageUrl,user_id,error_message,xray,flag,magnitude,CS-id,pdb_id,accel_a,time_offset,chart,fit,Questions,empty_number,empty_string\nBelgium,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C(=O)OCCCc1cccnc1)c2cccc(c2)C(=O)c3ccccc3,1480014,36.276729583740234,995042300,14016 ROUTE 31W,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,1,1,1QBS,1,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.497360340644872, 1.7058694986686864, 5.278052678195135, 0.16000320889028383],""points"":[{""x"":0.10000000149011612,""y"":2.374499797821045},{""x"":0.6000000238418579,""y"":2.6242473125457764},{""x"":1.100000023841858,""y"":2.367267608642578},{""x"":1.600000023841858,""y"":2.6723148822784424},{""x"":2.0999999046325684,""y"":2.6537344455718994},{""x"":2.5999999046325684,""y"":2.3651671409606934},{""x"":3.0999999046325684,""y"":2.5654284954071045},{""x"":3.5999999046325684,""y"":2.4160959720611572},{""x"":4.099999904632568,""y"":2.286726713180542},{""x"":4.599999904632568,""y"":2.5100042819976807},{""x"":5.099999904632568,""y"":1.6676985025405884},{""x"":5.599999904632568,""y"":0.680136501789093},{""x"":6.099999904632568,""y"":0.3391543924808502},{""x"":6.599999904632568,""y"":0.09038983285427094},{""x"":7.099999904632568,""y"":0.19802775979042053}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[7.525235855508179, 1.3186911876809984, 5.335672608564294, 0.7860743343958098],""points"":[{""x"":0.10000000149011612,""y"":7.988070487976074},{""x"":0.6000000238418579,""y"":7.018453121185303},{""x"":1.100000023841858,""y"":8.115279197692871},{""x"":1.600000023841858,""y"":7.486658096313477},{""x"":2.0999999046325684,""y"":7.396438121795654},{""x"":2.5999999046325684,""y"":7.477052211761475},{""x"":3.0999999046325684,""y"":6.913095474243164},{""x"":3.5999999046325684,""y"":8.01385498046875},{""x"":4.099999904632568,""y"":6.985900402069092},{""x"":4.599999904632568,""y"":6.970335960388184},{""x"":5.099999904632568,""y"":5.448817253112793},{""x"":5.599999904632568,""y"":2.5534818172454834},{""x"":6.099999904632568,""y"":1.893947958946228},{""x"":6.599999904632568,""y"":0.6340042352676392},{""x"":7.099999904632568,""y"":0.8403874039649963}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,100,abc\nBurundi,MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW,COc1ccc2cc(ccc2c1)C(C)C(=O)Oc3ccc(C)cc3OC,1480015,36.276729583740234,995073444,80 STATE HIGHWAY 310,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,2,2,1ZP8,2,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.431460753103398, 2.1691498799246745, 5.266445597102774, 0.7825762827017926],""points"":[{""x"":0.10000000149011612,""y"":4.751083850860596},{""x"":0.6000000238418579,""y"":4.203000068664551},{""x"":1.100000023841858,""y"":4.415858745574951},{""x"":1.600000023841858,""y"":4.68414306640625},{""x"":2.0999999046325684,""y"":4.198400974273682},{""x"":2.5999999046325684,""y"":4.179222106933594},{""x"":3.0999999046325684,""y"":4.638473987579346},{""x"":3.5999999046325684,""y"":4.708553314208984},{""x"":4.099999904632568,""y"":4.291589260101318},{""x"":4.599999904632568,""y"":4.038082599639893},{""x"":5.099999904632568,""y"":3.4349939823150635},{""x"":5.599999904632568,""y"":1.2194708585739136},{""x"":6.099999904632568,""y"":1.1920831203460693},{""x"":6.599999904632568,""y"":0.5352635979652405},{""x"":7.099999904632568,""y"":0.3346920311450958}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.339458017970126, -1.0734184310171178, 4.746332950550934, 0.2482416857595658],""points"":[{""x"":0.10000000149011612,""y"":0.2139337658882141},{""x"":0.6000000238418579,""y"":0.4269562065601349},{""x"":1.100000023841858,""y"":0.2441573292016983},{""x"":1.600000023841858,""y"":0.146635964512825},{""x"":2.0999999046325684,""y"":0.08818462491035461},{""x"":2.5999999046325684,""y"":0.2560656666755676},{""x"":3.0999999046325684,""y"":0.42434045672416687},{""x"":3.5999999046325684,""y"":0.37111231684684753},{""x"":4.099999904632568,""y"":0.5581737160682678},{""x"":4.599999904632568,""y"":1.183590054512024},{""x"":5.099999904632568,""y"":1.5629843473434448},{""x"":5.599999904632568,""y"":2.3211288452148438},{""x"":6.099999904632568,""y"":2.229961633682251},{""x"":6.599999904632568,""y"":2.2560226917266846},{""x"":7.099999904632568,""y"":2.2142398357391357}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCameroon,MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL,COc1ccc2cc(ccc2c1)C(C)C(=O)OCCCc3cccnc3,1480016,36.26095962524414,995153596,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,3,3,2BDJ,3,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.6760652578642325, 0.9046956320756703, 5.651408971856738, 0.07738846012184185],""points"":[{""x"":0.10000000149011612,""y"":4.32425594329834},{""x"":0.6000000238418579,""y"":4.668442249298096},{""x"":1.100000023841858,""y"":4.379785060882568},{""x"":1.600000023841858,""y"":5.0345139503479},{""x"":2.0999999046325684,""y"":4.878653526306152},{""x"":2.5999999046325684,""y"":4.3451313972473145},{""x"":3.0999999046325684,""y"":4.336992263793945},{""x"":3.5999999046325684,""y"":5.037430286407471},{""x"":4.099999904632568,""y"":5.0092692375183105},{""x"":4.599999904632568,""y"":4.151902675628662},{""x"":5.099999904632568,""y"":3.4066951274871826},{""x"":5.599999904632568,""y"":2.3732759952545166},{""x"":6.099999904632568,""y"":1.673728108406067},{""x"":6.599999904632568,""y"":0.48574790358543396},{""x"":7.099999904632568,""y"":0.2783052325248718}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.938395863010111, -1.4658480661392117, 5.462702751996584, 0.3473139023615039],""points"":[{""x"":0.10000000149011612,""y"":0.4941710829734802},{""x"":0.6000000238418579,""y"":0.15323974192142487},{""x"":1.100000023841858,""y"":0.46373432874679565},{""x"":1.600000023841858,""y"":0.3370431363582611},{""x"":2.0999999046325684,""y"":0.5179030299186707},{""x"":2.5999999046325684,""y"":0.27899765968322754},{""x"":3.0999999046325684,""y"":0.22075064480304718},{""x"":3.5999999046325684,""y"":0.5789918899536133},{""x"":4.099999904632568,""y"":0.21169911324977875},{""x"":4.599999904632568,""y"":0.27857646346092224},{""x"":5.099999904632568,""y"":1.0906332731246948},{""x"":5.599999904632568,""y"":1.8520300388336182},{""x"":6.099999904632568,""y"":2.7177059650421143},{""x"":6.599999904632568,""y"":2.8680918216705322},{""x"":7.099999904632568,""y"":3.2413077354431152}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCanada,MMELVLKTIIGPIVVGVVLRIVDKWLNKDK,CC(C(=O)NCCS)c1cccc(c1)C(=O)c2ccccc2,1480017,36.26095962524414,99515,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,4,4,1IAN,4,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[0.8597390975430008, 1.0957625732481946, 5.260537067987958, 0.07974187998177736],""points"":[{""x"":0.10000000149011612,""y"":0.8190152645111084},{""x"":0.6000000238418579,""y"":0.8421689867973328},{""x"":1.100000023841858,""y"":0.8740922212600708},{""x"":1.600000023841858,""y"":0.8924275040626526},{""x"":2.0999999046325684,""y"":0.8249067664146423},{""x"":2.5999999046325684,""y"":0.9327669143676758},{""x"":3.0999999046325684,""y"":0.8522974252700806},{""x"":3.5999999046325684,""y"":0.8174492716789246},{""x"":4.099999904632568,""y"":0.8394647240638733},{""x"":4.599999904632568,""y"":0.7139387726783752},{""x"":5.099999904632568,""y"":0.5561167597770691},{""x"":5.599999904632568,""y"":0.3276226818561554},{""x"":6.099999904632568,""y"":0.12479474395513535},{""x"":6.599999904632568,""y"":0.13006797432899475},{""x"":7.099999904632568,""y"":0.059702079743146896}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.760930219582546, 1.6591793293833013, 4.667155929720851, 0.7858109544121652],""points"":[{""x"":0.10000000149011612,""y"":6.156993389129639},{""x"":0.6000000238418579,""y"":5.236701965332031},{""x"":1.100000023841858,""y"":6.010560512542725},{""x"":1.600000023841858,""y"":5.495512962341309},{""x"":2.0999999046325684,""y"":6.087770462036133},{""x"":2.5999999046325684,""y"":5.79986572265625},{""x"":3.0999999046325684,""y"":5.597546577453613},{""x"":3.5999999046325684,""y"":5.520902156829834},{""x"":4.099999904632568,""y"":5.360654354095459},{""x"":4.599999904632568,""y"":3.5539746284484863},{""x"":5.099999904632568,""y"":1.577236294746399},{""x"":5.599999904632568,""y"":1.0001264810562134},{""x"":6.099999904632568,""y"":0.9305797815322876},{""x"":6.599999904632568,""y"":0.6033638715744019},{""x"":7.099999904632568,""y"":0.4203685522079468}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nColombia,MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN,FC(F)(F)c1ccc(OC2CCNCC2)cc1,1480029,36.3309440612793,995152050,1 COURT HOUSE SQUARE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,5,5,4UJ1,5,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[6.4995088314153655, 2.4270351004539914, 5.178659535348579, 0.625653346241577],""points"":[{""x"":0.10000000149011612,""y"":6.496231555938721},{""x"":0.6000000238418579,""y"":6.42543363571167},{""x"":1.100000023841858,""y"":7.040063858032227},{""x"":1.600000023841858,""y"":6.1115403175354},{""x"":2.0999999046325684,""y"":6.680728435516357},{""x"":2.5999999046325684,""y"":6.406774520874023},{""x"":3.0999999046325684,""y"":6.611269474029541},{""x"":3.5999999046325684,""y"":5.889094352722168},{""x"":4.099999904632568,""y"":6.75344705581665},{""x"":4.599999904632568,""y"":6.361435890197754},{""x"":5.099999904632568,""y"":4.1666975021362305},{""x"":5.599999904632568,""y"":1.172118902206421},{""x"":6.099999904632568,""y"":0.801048994064331},{""x"":6.599999904632568,""y"":0.4640021026134491},{""x"":7.099999904632568,""y"":0.0010357667924836278}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[1.4734381347446401, 1.1649805188074196, 4.82958608866421, 0.09500545496710007],""points"":[{""x"":0.10000000149011612,""y"":1.5279096364974976},{""x"":0.6000000238418579,""y"":1.3559974431991577},{""x"":1.100000023841858,""y"":1.5246378183364868},{""x"":1.600000023841858,""y"":1.5567657947540283},{""x"":2.0999999046325684,""y"":1.4114240407943726},{""x"":2.5999999046325684,""y"":1.4045010805130005},{""x"":3.0999999046325684,""y"":1.4769829511642456},{""x"":3.5999999046325684,""y"":1.4875500202178955},{""x"":4.099999904632568,""y"":1.2991987466812134},{""x"":4.599999904632568,""y"":0.922961413860321},{""x"":5.099999904632568,""y"":0.6520044803619385},{""x"":5.599999904632568,""y"":0.15350978076457977},{""x"":6.099999904632568,""y"":0.1078903079032898},{""x"":6.599999904632568,""y"":0.17276449501514435},{""x"":7.099999904632568,""y"":0.14066608250141144}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCosta Rica,MKSTKEEIQTIKTLLKDSRTAKYHKRLQIVL,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCCc3ccccc3,1480018,36.3309440612793,995084218,4041 SOUTHWESTERN BLVD,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,6,6,2BPW,6,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.4833641843311227, -1.8945978742090062, 4.671127708092568, 0.24159861311815153],""points"":[{""x"":0.10000000149011612,""y"":0.0969524160027504},{""x"":0.6000000238418579,""y"":0.028483040630817413},{""x"":1.100000023841858,""y"":0.22087176144123077},{""x"":1.600000023841858,""y"":0.0068915546871721745},{""x"":2.0999999046325684,""y"":0.4305879771709442},{""x"":2.5999999046325684,""y"":0.44774115085601807},{""x"":3.0999999046325684,""y"":0.45346319675445557},{""x"":3.5999999046325684,""y"":0.2370593100786209},{""x"":4.099999904632568,""y"":0.4657953977584839},{""x"":4.599999904632568,""y"":1.155200719833374},{""x"":5.099999904632568,""y"":2.2294070720672607},{""x"":5.599999904632568,""y"":2.4311530590057373},{""x"":6.099999904632568,""y"":2.33846116065979},{""x"":6.599999904632568,""y"":2.608201026916504},{""x"":7.099999904632568,""y"":2.8136143684387207}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.224573521642033, 1.4454033924198528, 5.6014197746076535, 0.2823216054197577],""points"":[{""x"":0.10000000149011612,""y"":4.95027494430542},{""x"":0.6000000238418579,""y"":5.1754679679870605},{""x"":1.100000023841858,""y"":5.276752948760986},{""x"":1.600000023841858,""y"":5.589294910430908},{""x"":2.0999999046325684,""y"":5.616994857788086},{""x"":2.5999999046325684,""y"":5.120813846588135},{""x"":3.0999999046325684,""y"":5.340766906738281},{""x"":3.5999999046325684,""y"":4.876471042633057},{""x"":4.099999904632568,""y"":4.94999361038208},{""x"":4.599999904632568,""y"":5.162564754486084},{""x"":5.099999904632568,""y"":4.399557590484619},{""x"":5.599999904632568,""y"":2.7977969646453857},{""x"":6.099999904632568,""y"":1.0229872465133667},{""x"":6.599999904632568,""y"":0.48275601863861084},{""x"":7.099999904632568,""y"":0.10408931970596313}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCuba,MHAILRYFIRRLFYHIFYKIYSLISKKHQSLPSDVRQF,COc1ccc2c(c1)c(CC(=O)N3CCCC3C(=O)Oc4ccc(C)cc4OC)c(C)n2C(=O)c5ccc(Cl)cc5,1480019,36.33115768432617,995081928,1227 US HIGHWAY 11,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,7,7,1QBS,7,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.320838679713925, -1.2421619987316728, 4.831325425225256, 0.3236011098403072],""points"":[{""x"":0.10000000149011612,""y"":0.3727470338344574},{""x"":0.6000000238418579,""y"":0.12365014106035233},{""x"":1.100000023841858,""y"":0.48422467708587646},{""x"":1.600000023841858,""y"":0.2264465093612671},{""x"":2.0999999046325684,""y"":0.16821794211864471},{""x"":2.5999999046325684,""y"":0.3879014551639557},{""x"":3.0999999046325684,""y"":0.5470244884490967},{""x"":3.5999999046325684,""y"":0.3419053554534912},{""x"":4.099999904632568,""y"":0.7655120491981506},{""x"":4.599999904632568,""y"":1.2346516847610474},{""x"":5.099999904632568,""y"":2.453336715698242},{""x"":5.599999904632568,""y"":2.9565491676330566},{""x"":6.099999904632568,""y"":3.335299491882324},{""x"":6.599999904632568,""y"":3.240290880203247},{""x"":7.099999904632568,""y"":3.1107218265533447}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.6401853521511094, 1.26211588875013, 5.399028074402744, 0.5089580830068091],""points"":[{""x"":0.10000000149011612,""y"":3.8585598468780518},{""x"":0.6000000238418579,""y"":3.6077206134796143},{""x"":1.100000023841858,""y"":3.855252265930176},{""x"":1.600000023841858,""y"":3.619039297103882},{""x"":2.0999999046325684,""y"":3.839388370513916},{""x"":2.5999999046325684,""y"":3.335283041000366},{""x"":3.0999999046325684,""y"":3.571141481399536},{""x"":3.5999999046325684,""y"":3.4155046939849854},{""x"":4.099999904632568,""y"":3.7316646575927734},{""x"":4.599999904632568,""y"":3.0680155754089355},{""x"":5.099999904632568,""y"":2.891066551208496},{""x"":5.599999904632568,""y"":1.6022753715515137},{""x"":6.099999904632568,""y"":0.7652576565742493},{""x"":6.599999904632568,""y"":0.6875326037406921},{""x"":7.099999904632568,""y"":0.5828871726989746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nItaly,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO[N+](=O)[O-],1480020,36.33115768432617,99502,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,8,8,1ZP8,8,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.293592105923809, 1.3781586549141835, 5.1025898038676605, 0.03493851245291291],""points"":[{""x"":0.10000000149011612,""y"":2.1287283897399902},{""x"":0.6000000238418579,""y"":2.267972230911255},{""x"":1.100000023841858,""y"":2.398442506790161},{""x"":1.600000023841858,""y"":2.5130622386932373},{""x"":2.0999999046325684,""y"":2.3255116939544678},{""x"":2.5999999046325684,""y"":2.127340793609619},{""x"":3.0999999046325684,""y"":2.47259783744812},{""x"":3.5999999046325684,""y"":2.131181478500366},{""x"":4.099999904632568,""y"":2.090421438217163},{""x"":4.599999904632568,""y"":2.02299165725708},{""x"":5.099999904632568,""y"":1.1105059385299683},{""x"":5.599999904632568,""y"":0.4494485855102539},{""x"":6.099999904632568,""y"":0.1375635862350464},{""x"":6.599999904632568,""y"":0.036351121962070465},{""x"":7.099999904632568,""y"":0.1619771122932434}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.953125499439879, 1.2528620255306528, 5.187637440149802, 0.3110348753260886],""points"":[{""x"":0.10000000149011612,""y"":5.6585283279418945},{""x"":0.6000000238418579,""y"":5.911152362823486},{""x"":1.100000023841858,""y"":5.924920082092285},{""x"":1.600000023841858,""y"":5.8469438552856445},{""x"":2.0999999046325684,""y"":5.929472923278809},{""x"":2.5999999046325684,""y"":6.190037727355957},{""x"":3.0999999046325684,""y"":6.236179828643799},{""x"":3.5999999046325684,""y"":6.141019344329834},{""x"":4.099999904632568,""y"":5.295210838317871},{""x"":4.599999904632568,""y"":5.265801906585693},{""x"":5.099999904632568,""y"":3.3722851276397705},{""x"":5.599999904632568,""y"":1.8299226760864258},{""x"":6.099999904632568,""y"":0.32690900564193726},{""x"":6.599999904632568,""y"":0.6274543404579163},{""x"":7.099999904632568,""y"":0.8441857099533081}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nRwanda,MPNSEPASLLELFNSIATQGELVRSLKAGNASK,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO,1480021,36.33137130737305,995037247,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,9,2BDJ,9,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.8209972202654474, 1.3779216716448506, 5.299882228439686, 0.06040645519069608],""points"":[{""x"":0.10000000149011612,""y"":3.7821109294891357},{""x"":0.6000000238418579,""y"":3.542433023452759},{""x"":1.100000023841858,""y"":3.7008674144744873},{""x"":1.600000023841858,""y"":3.717301607131958},{""x"":2.0999999046325684,""y"":4.024452209472656},{""x"":2.5999999046325684,""y"":4.013899326324463},{""x"":3.0999999046325684,""y"":3.945094347000122},{""x"":3.5999999046325684,""y"":3.866621971130371},{""x"":4.099999904632568,""y"":3.7461626529693604},{""x"":4.599999904632568,""y"":3.3454740047454834},{""x"":5.099999904632568,""y"":2.61944317817688},{""x"":5.599999904632568,""y"":0.999405026435852},{""x"":6.099999904632568,""y"":0.46259793639183044},{""x"":6.599999904632568,""y"":0.054134611040353775},{""x"":7.099999904632568,""y"":0.05711187422275543}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.6318079657726035, 1.8495493770000595, 5.391793312471116, 0.17060707587348442],""points"":[{""x"":0.10000000149011612,""y"":5.458079814910889},{""x"":0.6000000238418579,""y"":5.554427146911621},{""x"":1.100000023841858,""y"":5.799983024597168},{""x"":1.600000023841858,""y"":5.364140033721924},{""x"":2.0999999046325684,""y"":5.864485740661621},{""x"":2.5999999046325684,""y"":5.4509806632995605},{""x"":3.0999999046325684,""y"":5.702574729919434},{""x"":3.5999999046325684,""y"":5.7314534187316895},{""x"":4.099999904632568,""y"":5.5123443603515625},{""x"":4.599999904632568,""y"":5.724395751953125},{""x"":5.099999904632568,""y"":4.354506969451904},{""x"":5.599999904632568,""y"":1.7307666540145874},{""x"":6.099999904632568,""y"":0.6305936574935913},{""x"":6.599999904632568,""y"":0.035183437168598175},{""x"":7.099999904632568,""y"":0.7575169205665588}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nSwitzerland,IRVVGRYLIEVWKAAGMDMDKVLFLWSSDEI,CN1CCC(CC1)Oc2ccc(cc2)C(F)(F)F,1480028,36.33137130737305,99504,92-11 179TH PLACE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,10,1IAN,10,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[1.1190255865097471, 2.3163895161544437, 5.4968866182279195, 0.2035204047289052],""points"":[{""x"":0.10000000149011612,""y"":1.1057683229446411},{""x"":0.6000000238418579,""y"":1.1019697189331055},{""x"":1.100000023841858,""y"":1.0818607807159424},{""x"":1.600000023841858,""y"":1.062997817993164},{""x"":2.0999999046325684,""y"":1.046447515487671},{""x"":2.5999999046325684,""y"":1.1217249631881714},{""x"":3.0999999046325684,""y"":1.2166996002197266},{""x"":3.5999999046325684,""y"":1.215477705001831},{""x"":4.099999904632568,""y"":1.0581893920898438},{""x"":4.599999904632568,""y"":1.1747995615005493},{""x"":5.099999904632568,""y"":1.0181127786636353},{""x"":5.599999904632568,""y"":0.5344523191452026},{""x"":6.099999904632568,""y"":0.2569526433944702},{""x"":6.599999904632568,""y"":0.1912207305431366},{""x"":7.099999904632568,""y"":0.15060538053512573}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.1038581025805785, 2.0032224204185245, 5.087602825989163, 0.13277988512492753],""points"":[{""x"":0.10000000149011612,""y"":3.0498509407043457},{""x"":0.6000000238418579,""y"":2.805217742919922},{""x"":1.100000023841858,""y"":3.3415253162384033},{""x"":1.600000023841858,""y"":3.0549843311309814},{""x"":2.0999999046325684,""y"":3.250074863433838},{""x"":2.5999999046325684,""y"":3.0432586669921875},{""x"":3.0999999046325684,""y"":3.265852451324463},{""x"":3.5999999046325684,""y"":2.9475724697113037},{""x"":4.099999904632568,""y"":3.1929898262023926},{""x"":4.599999904632568,""y"":2.7460060119628906},{""x"":5.099999904632568,""y"":1.6175861358642578},{""x"":5.599999904632568,""y"":0.3006608486175537},{""x"":6.099999904632568,""y"":0.3444803059101105},{""x"":6.599999904632568,""y"":0.015537971630692482},{""x"":7.099999904632568,""y"":0.5527358055114746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\n,,,,,,,,,,,,,,,,,,,,,').columns.add(i.Column.fromList(i.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var s,o=function(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function r(t,e,n,i=0){return o(this,void 0,void 0,(function*(){return new Promise(((s,o)=>{const r=t.subscribe((t=>{try{e(t),s("OK")}catch(t){o(t)}r.unsubscribe(),clearTimeout(a)})),a=setTimeout((()=>{r.unsubscribe(),o("timeout")}),i);n()}))}))}function a(t){return o(this,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,t)))}))}!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(s||(s={})),i.DataFrame.fromColumns([i.Column.fromStrings("col",["val1","val2","val3"])])},850:(t,e,n)=>{"use strict";function i(t=!1,e="Assertion error."){if(!t)throw new Error(e)}function s(t){let e=0;for(let n=0;n<t.length;n++)e+=t[n]*t[n];return Math.sqrt(e)}function o(t,e){if(t.length!=e.length)throw new Error("The dimensionality of the vectors must match");let n=0;for(let i=0;i<t.length;i++)n+=t[i]*e[i];return n}function r(t,e){let n=0;const i=t.length;if(i!==e.length)throw new Error("The dimensionality of the vectors must match");for(let s=0;s<i;++s)n+=Math.pow(t[s]-e[s],2);return Math.sqrt(n)}function a(t){const e=t.length;let n=0,i=0;for(let s=0;s<e;++s)n+=t[s],i+=Math.pow(t[s],2);const s=n/e,o=1/Math.sqrt(i/e-Math.pow(s,2));for(let n=0;n<e;++n)t[n]=(t[n]-s)*o;return t}n.d(e,{$G:()=>s,Fv:()=>a,MA:()=>o,dP:()=>r,hu:()=>i})},5362:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(7537),s=n.n(i),o=n(3645),r=n.n(o)()(s());r.push([t.id,".macromolecule-cell-comp-analysis-host{\n max-height: 250px;\n overflow-y: scroll;\n}\n\n.macromolecule-cell-comp-analysis-bar{\n height: inherit;\n display: block;\n margin-top: 1.5px;\n margin-bottom: 1.5px;\n margin-right: 3px;\n}\n\n.macromolecule-cell-comp-analysis-value{\n display: flex;\n}","",{version:3,sources:["webpack://./css/composition-analysis.css"],names:[],mappings:"AAAA;IACI,iBAAiB;IACjB,kBAAkB;AACtB;;AAEA;IACI,eAAe;IACf,cAAc;IACd,iBAAiB;IACjB,oBAAoB;IACpB,iBAAiB;AACrB;;AAEA;IACI,aAAa;AACjB",sourcesContent:[".macromolecule-cell-comp-analysis-host{\n max-height: 250px;\n overflow-y: scroll;\n}\n\n.macromolecule-cell-comp-analysis-bar{\n height: inherit;\n display: block;\n margin-top: 1.5px;\n margin-bottom: 1.5px;\n margin-right: 3px;\n}\n\n.macromolecule-cell-comp-analysis-value{\n display: flex;\n}"],sourceRoot:""}]);const a=r},9564:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(7537),s=n.n(i),o=n(3645),r=n.n(o)()(s());r.push([t.id,".kalign-version {\n margin-bottom: 0;\n text-align: end;\n font-size: 12px;\n opacity: 0.8;\n}\nbutton.msa-params-button.ui-btn {\n justify-content: end;\n}","",{version:3,sources:["webpack://./css/msa.css"],names:[],mappings:"AAAA;IACI,gBAAgB;IAChB,eAAe;IACf,eAAe;IACf,YAAY;AAChB;AACA;IACI,oBAAoB;AACxB",sourcesContent:[".kalign-version {\n margin-bottom: 0;\n text-align: end;\n font-size: 12px;\n opacity: 0.8;\n}\nbutton.msa-params-button.ui-btn {\n justify-content: end;\n}"],sourceRoot:""}]);const a=r},9414:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(7537),s=n.n(i),o=n(3645),r=n.n(o)()(s());r.push([t.id,".scatter_plot_link {\n position: absolute!important;\n right: 10px;\n}\n\n.cliffs_grid {\n top: 10px;\n}\n\n.show_only_cliffs {\n top: 30px;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings {\n font-size: 18px;\n position: absolute;\n height: 28px;\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/ml/css/styles.css"],names:[],mappings:"AAAA;IACI,4BAA4B;IAC5B,WAAW;AACf;;AAEA;IACI,SAAS;AACb;;AAEA;IACI,SAAS;AACb;;AAEA;IACI,eAAe;IACf,kBAAkB;IAClB,YAAY;AAChB",sourcesContent:[".scatter_plot_link {\n position: absolute!important;\n right: 10px;\n}\n\n.cliffs_grid {\n top: 10px;\n}\n\n.show_only_cliffs {\n top: 30px;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings {\n font-size: 18px;\n position: absolute;\n height: 28px;\n}\n"],sourceRoot:""}]);const a=r},3645:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",i=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),i&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),i&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,i,s,o){"string"==typeof t&&(t=[[null,t,void 0]]);var r={};if(i)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(r[l]=!0)}for(var c=0;c<t.length;c++){var h=[].concat(t[c]);i&&r[h[0]]||(void 0!==o&&(void 0===h[5]||(h[1]="@layer".concat(h[5].length>0?" ".concat(h[5]):""," {").concat(h[1],"}")),h[5]=o),n&&(h[2]?(h[1]="@media ".concat(h[2]," {").concat(h[1],"}"),h[2]=n):h[2]=n),s&&(h[4]?(h[1]="@supports (".concat(h[4],") {").concat(h[1],"}"),h[4]=s):h[4]="".concat(s)),e.push(h))}},e}},7537:t=>{"use strict";t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var i=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),s="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),o="/*# ".concat(s," */");return[e].concat([o]).join("\n")}return[e].join("\n")}},9133:function(t,e,n){var i;!function(e,s){var o={};!function(t){"use strict";t.__esModule=!0,t.digestLength=32,t.blockSize=64;var e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t,n,i,s,o){for(var r,a,l,c,h,u,d,m,p,g,f,y,b;o>=64;){for(r=n[0],a=n[1],l=n[2],c=n[3],h=n[4],u=n[5],d=n[6],m=n[7],g=0;g<16;g++)f=s+4*g,t[g]=(255&i[f])<<24|(255&i[f+1])<<16|(255&i[f+2])<<8|255&i[f+3];for(g=16;g<64;g++)y=((p=t[g-2])>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,b=((p=t[g-15])>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,t[g]=(y+t[g-7]|0)+(b+t[g-16]|0);for(g=0;g<64;g++)y=(((h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7))+(h&u^~h&d)|0)+(m+(e[g]+t[g]|0)|0)|0,b=((r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10))+(r&a^r&l^a&l)|0,m=d,d=u,u=h,h=c+y|0,c=l,l=a,a=r,r=y+b|0;n[0]+=r,n[1]+=a,n[2]+=l,n[3]+=c,n[4]+=h,n[5]+=u,n[6]+=d,n[7]+=m,s+=64,o-=64}return s}var i=function(){function e(){this.digestLength=t.digestLength,this.blockSize=t.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return e.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},e.prototype.clean=function(){for(var t=0;t<this.buffer.length;t++)this.buffer[t]=0;for(t=0;t<this.temp.length;t++)this.temp[t]=0;this.reset()},e.prototype.update=function(t,e){if(void 0===e&&(e=t.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var i=0;if(this.bytesHashed+=e,this.bufferLength>0){for(;this.bufferLength<64&&e>0;)this.buffer[this.bufferLength++]=t[i++],e--;64===this.bufferLength&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(e>=64&&(i=n(this.temp,this.state,t,i,e),e%=64);e>0;)this.buffer[this.bufferLength++]=t[i++],e--;return this},e.prototype.finish=function(t){if(!this.finished){var e=this.bytesHashed,i=this.bufferLength,s=e/536870912|0,o=e<<3,r=e%64<56?64:128;this.buffer[i]=128;for(var a=i+1;a<r-8;a++)this.buffer[a]=0;this.buffer[r-8]=s>>>24&255,this.buffer[r-7]=s>>>16&255,this.buffer[r-6]=s>>>8&255,this.buffer[r-5]=s>>>0&255,this.buffer[r-4]=o>>>24&255,this.buffer[r-3]=o>>>16&255,this.buffer[r-2]=o>>>8&255,this.buffer[r-1]=o>>>0&255,n(this.temp,this.state,this.buffer,0,r),this.finished=!0}for(a=0;a<8;a++)t[4*a+0]=this.state[a]>>>24&255,t[4*a+1]=this.state[a]>>>16&255,t[4*a+2]=this.state[a]>>>8&255,t[4*a+3]=this.state[a]>>>0&255;return this},e.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},e.prototype._saveState=function(t){for(var e=0;e<this.state.length;e++)t[e]=this.state[e]},e.prototype._restoreState=function(t,e){for(var n=0;n<this.state.length;n++)this.state[n]=t[n];this.bytesHashed=e,this.finished=!1,this.bufferLength=0},e}();t.Hash=i;var s=function(){function t(t){this.inner=new i,this.outer=new i,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new i).update(t).finish(e).clean();else for(var n=0;n<t.length;n++)e[n]=t[n];for(n=0;n<e.length;n++)e[n]^=54;for(this.inner.update(e),n=0;n<e.length;n++)e[n]^=106;for(this.outer.update(e),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),n=0;n<e.length;n++)e[n]=0}return t.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},t.prototype.clean=function(){for(var t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean()},t.prototype.update=function(t){return this.inner.update(t),this},t.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},t.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},t}();function o(t){var e=(new i).update(t),n=e.digest();return e.clean(),n}function r(t,e){var n=new s(t).update(e),i=n.digest();return n.clean(),i}function a(t,e,n,i){var s=i[0];if(0===s)throw new Error("hkdf: cannot expand more");e.reset(),s>1&&e.update(t),n&&e.update(n),e.update(i),e.finish(t),i[0]++}t.HMAC=s,t.hash=o,t.default=o,t.hmac=r;var l=new Uint8Array(t.digestLength);t.hkdf=function(t,e,n,i){void 0===e&&(e=l),void 0===i&&(i=32);for(var o=new Uint8Array([1]),c=r(e,t),h=new s(c),u=new Uint8Array(h.digestLength),d=u.length,m=new Uint8Array(i),p=0;p<i;p++)d===u.length&&(a(u,h,n,o),d=0),m[p]=u[d++];return h.clean(),u.fill(0),o.fill(0),m},t.pbkdf2=function(t,e,n,i){for(var o=new s(t),r=o.digestLength,a=new Uint8Array(4),l=new Uint8Array(r),c=new Uint8Array(r),h=new Uint8Array(i),u=0;u*r<i;u++){var d=u+1;a[0]=d>>>24&255,a[1]=d>>>16&255,a[2]=d>>>8&255,a[3]=d>>>0&255,o.reset(),o.update(e),o.update(a),o.finish(c);for(var m=0;m<r;m++)l[m]=c[m];for(m=2;m<=n;m++){o.reset(),o.update(c).finish(c);for(var p=0;p<r;p++)l[p]^=c[p]}for(m=0;m<r&&u*r+m<i;m++)h[u*r+m]=l[m]}for(u=0;u<r;u++)l[u]=c[u]=0;for(u=0;u<4;u++)a[u]=0;return o.clean(),h}}(o);var r=o.default;for(var a in o)r[a]=o[a];"object"==typeof t.exports?t.exports=r:void 0===(i=function(){return r}.call(o,n,o,t))||(t.exports=i)}()},1811:(t,e,n)=>{"use strict";n.d(e,{T:()=>s});const i=new Uint32Array(65536),s=(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,s=e.length,o=1<<n-1;let r=-1,a=0,l=n,c=n;for(;c--;)i[t.charCodeAt(c)]|=1<<c;for(c=0;c<s;c++){let t=i[e.charCodeAt(c)];const n=t|a;t|=(t&r)+r^r,a|=~(t|r),r&=t,a&o&&l++,r&o&&l--,a=a<<1|1,r=r<<1|~(n|a),a&=n}for(c=n;c--;)i[t.charCodeAt(c)]=0;return l})(t,e):((t,e)=>{const n=e.length,s=t.length,o=[],r=[],a=Math.ceil(n/32),l=Math.ceil(s/32);for(let t=0;t<a;t++)r[t]=-1,o[t]=0;let c=0;for(;c<l-1;c++){let a=0,l=-1;const h=32*c,u=Math.min(32,s)+h;for(let e=h;e<u;e++)i[t.charCodeAt(e)]|=1<<e;for(let t=0;t<n;t++){const n=i[e.charCodeAt(t)],s=r[t/32|0]>>>t&1,c=o[t/32|0]>>>t&1,h=n|a,u=((n|c)&l)+l^l|n|c;let d=a|~(u|l),m=l&u;d>>>31^s&&(r[t/32|0]^=1<<t),m>>>31^c&&(o[t/32|0]^=1<<t),d=d<<1|s,m=m<<1|c,l=m|~(h|d),a=d&h}for(let e=h;e<u;e++)i[t.charCodeAt(e)]=0}let h=0,u=-1;const d=32*c,m=Math.min(32,s-d)+d;for(let e=d;e<m;e++)i[t.charCodeAt(e)]|=1<<e;let p=s;for(let t=0;t<n;t++){const n=i[e.charCodeAt(t)],a=r[t/32|0]>>>t&1,l=o[t/32|0]>>>t&1,c=n|h,d=((n|l)&u)+u^u|n|l;let m=h|~(d|u),g=u&d;p+=m>>>s-1&1,p-=g>>>s-1&1,m>>>31^a&&(r[t/32|0]^=1<<t),g>>>31^l&&(o[t/32|0]^=1<<t),m=m<<1|a,g=g<<1|l,u=g|~(c|m),h=m&c}for(let e=d;e<m;e++)i[t.charCodeAt(e)]=0;return p})(t,e)}},3979:(t,e)=>{"use strict";e.H$=void 0,e.H$=function(t,e,n){var i=function(t,e,n){if(0===t.length||0===e.length)return 0;if(n&&!n.caseSensitive&&(t=t.toUpperCase(),e=e.toUpperCase()),t===e)return 1;for(var i=0,s=t.length,o=e.length,r=Math.floor(Math.max(s,o)/2)-1,a=new Array(s),l=new Array(o),c=0;c<s;c++)for(var h=Math.max(0,c-r);h<=Math.min(o,c+r+1);h++)if(!a[c]&&!l[h]&&t[c]===e[h]){++i,a[c]=l[h]=!0;break}if(0===i)return 0;var u=0,d=0;for(c=0;c<s;c++)if(a[c]){for(;!l[d];)d++;t.charAt(c)!==e.charAt(d++)&&u++}return(i/s+i/o+(i-(u/=2))/i)/3}(t,e,n),s=0;if(i>.7){for(var o=Math.min(t.length,e.length),r=0;t[r]===e[r]&&r<4&&r<o;)++s,r++;i+=.1*s*(1-i)}return i}},3379:t=>{"use strict";var e=[];function n(t){for(var n=-1,i=0;i<e.length;i++)if(e[i].identifier===t){n=i;break}return n}function i(t,i){for(var o={},r=[],a=0;a<t.length;a++){var l=t[a],c=i.base?l[0]+i.base:l[0],h=o[c]||0,u="".concat(c," ").concat(h);o[c]=h+1;var d=n(u),m={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)e[d].references++,e[d].updater(m);else{var p=s(m,i);i.byIndex=a,e.splice(a,0,{identifier:u,updater:p,references:1})}r.push(u)}return r}function s(t,e){var n=e.domAPI(e);return n.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,s){var o=i(t=t||[],s=s||{});return function(t){t=t||[];for(var r=0;r<o.length;r++){var a=n(o[r]);e[a].references--}for(var l=i(t,s),c=0;c<o.length;c++){var h=n(o[c]);0===e[h].references&&(e[h].updater(),e.splice(h,1))}o=l}}},569:t=>{"use strict";var e={};t.exports=function(t,n){var i=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(n)}},9216:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},3565:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},7795:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var i="";n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {"));var s=void 0!==n.layer;s&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,s&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}");var o=n.sourceMap;o&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},4589:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},7241:(t,e,n)=>{"use strict";n.d(e,{D:()=>h});var i=n(4469),s=n(976),o=n(6414),r=n.n(o),a=n(4955),l=n(499);const c=31;async function h(t,e=!1,n){const o=l.Cn.getOrCreate(t);let h;n??(n=new Map);const d=o.isHelm()?(0,a.getHelmMonomers)(t):Object.keys(o.stats.freq).filter((t=>""!==t));for(let t=0;t<d.length;t++)n.has(d[t])||n.set(d[t],`${n.size+1}`);if(o.isHelm())h=await i.functions.call("HELM:getMolFiles",{col:t}),h=function(t,e,n=!1){const i=new Array(t.length);for(let s=0;s<t.length;s++){let o=0,r=0,a="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";const l=t.get(s);o=l.indexOf("\n",o)+1,o=l.indexOf("\n",o)+1,o=l.indexOf("\n",o)+1;const h=parseInt(l.substring(o,o+3)),u=parseInt(l.substring(o+3,o+6));a+=`M V30 COUNTS ${h} ${u} 0 0 0\n`,a+="M V30 BEGIN ATOM\n";for(let t=0;t<h;t++){o=l.indexOf("\n",o)+1+c,r=l.indexOf(" ",o);const i=l.substring(o,r);a+=n?`M V30 ${t+1} R${e.get(i)} 0.000 0.000 0 0\n`:`M V30 ${t+1} At 0.000 0.000 0 0 MASS=${e.get(i)}\n`}a+="M V30 END ATOM\n",a+="M V30 BEGIN BOND\n";for(let t=0;t<u;t++){o=l.indexOf("\n",o)+1;const e=parseInt(l.substring(o,o+3).trim()),n=parseInt(l.substring(o+3,o+6).trim());a+=`M V30 ${t+1} ${parseInt(l.substring(o+6,o+9).trim())} ${e} ${n}\n`}a+="M V30 END BOND\n",a+="M V30 END CTAB\n",a+="M END",i[s]=a}return i}(h,n,e);else{h=new Array(t.length);for(let i=0;i<t.length;i++){const t=u(r()(o.splitted[i]).filter((t=>""!==t)).toArray(),n,e);h[i]=t}}return s.Column.fromStrings("monomericMols",h)}function u(t,e,n=!1){let i="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";i+=`M V30 COUNTS ${t.length} ${t.length?t.length-1:0} 0 0 0\n`,i+="M V30 BEGIN ATOM\n";for(let s=0;s<t.length;s++)i+=n?`M V30 ${s+1} R${e.get(t[s])} 0.000 0.000 0 0\n`:`M V30 ${s+1} At 0.000 0.000 0 0 MASS=${e.get(t[s])}\n`;i+="M V30 END ATOM\n",i+="M V30 BEGIN BOND\n";for(let e=0;e<t.length-1;e++)i+=`M V30 ${e+1} 1 ${e+1} ${e+2}\n`;return i+="M V30 END BOND\n",i+="M V30 END CTAB\n",i+="M END",i}},4955:(t,e,n)=>{"use strict";n.r(e),n.d(e,{GetRegionEditor:()=>Tn,SeqActivityCliffsEditor:()=>Ln,SeqPaletteCustom:()=>Cn,SequenceSpaceEditor:()=>Mn,SplitToMonomersEditor:()=>In,SubsequenceSearchTopMenu:()=>ri,_package:()=>fn,activityCliffs:()=>Wn,addCopyMenu:()=>gi,alignSequences:()=>Yn,bioSubstructureFilter:()=>hi,compositionAnalysis:()=>$n,compositionAnalysisWidget:()=>Rn,convertDialog:()=>qn,demoBioActivityCliffs:()=>bi,demoBioAtomicLevel:()=>Ci,demoBioHelmMsaSequenceSpace:()=>wi,demoBioSequenceSpace:()=>yi,demoBioSimilarityDiversity:()=>fi,detectMacromoleculeProbe:()=>Ai,diversitySearchTopMenu:()=>si,diversitySearchViewer:()=>ii,fastaSequenceCellRenderer:()=>En,getBioLib:()=>Sn,getHelmMonomers:()=>ti,getMonomerLibHelper:()=>yn,getRegion:()=>Fn,getRegionApp:()=>mi,getRegionHelmApp:()=>pi,getRegionPanel:()=>An,getRegionTopMenu:()=>Bn,helmPreprocessingFunction:()=>Dn,hydrophobPalette:()=>bn,importBam:()=>Xn,importFasta:()=>Kn,initBio:()=>wn,libraryPanel:()=>xn,macroMolColumnPropertyPanel:()=>Nn,macromoleculeDifferenceCellRenderer:()=>On,macromoleculePreprocessingFunction:()=>Hn,monomerCellRenderer:()=>jn,multipleSequenceAlignmentDialog:()=>Zn,polyTool:()=>zn,polyToolColumnChoice:()=>vi,saveAsFasta:()=>ci,sdfToJsonLib:()=>Si,searchSubsequenceEditor:()=>oi,separatorSequenceCellRenderer:()=>_n,sequenceAlignment:()=>Pn,sequenceIdentityScoring:()=>ai,sequenceSimilarityScoring:()=>li,sequenceSpaceTopMenu:()=>Vn,sequenceTooltip:()=>vn,similaritySearchTopMenu:()=>ni,similaritySearchViewer:()=>ei,splitToMonomersTopMenu:()=>Qn,testDetectMacromolecule:()=>Jn,toAtomicLevel:()=>Un,vdRegionsViewer:()=>kn,webLogoAggApp:()=>di,webLogoLargeApp:()=>ui,webLogoViewer:()=>Gn});var i,s,o=n(4469),r=n(3870),a=n(976),l=n(3277),c=n(4628);(s=i||(i={})).EUCLIDEAN="EUCLIDEAN",s.MANHATTAN="MANHATTAN";class h{learningRate={uiName:"Learinig rate",value:1,tooltip:"The initial learning rate for the embedding optimization"};nComponents={uiName:"Components",value:2,tooltip:"The number of components (dimensions) to project the data to"};nEpochs={uiName:"Epochs",value:0,tooltip:"The number of epochs to optimize embeddings via SGD. Computed automatically if set to 0"};nNeighbors={uiName:"Neighbors",value:15,tooltip:"The number of nearest neighbors to construct the fuzzy manifold"};spread={uiName:"Spread",value:1,tooltip:"The effective scale of embedded points, used with min distance to control \n the clumped/dispersed nature of the embedding"};minDist={uiName:"Min distance",value:.1,tooltip:"The effective minimum distance between embedded points, \n used with spread to control the clumped/dispersed nature of the embedding"};constructor(){}}class u{epsilon={uiName:"Epsilon",value:10,tooltip:"Epsilon is learning rate"};perplexity={uiName:"Perplexity",value:30,tooltip:"Roughly how many neighbors each point influences"};dim={uiName:"Dimensionality",value:2,tooltip:"Dimensionality of the embedding"};constructor(){}}a.SEMTYPE.MOLECULE,a.SEMTYPE.MACROMOLECULE;class d{epsilon={uiName:"Epsilon",value:.01,tooltip:"Minimum distance between cluster points",min:0,max:2,step:.005};minPts={uiName:"Minimum points",value:4,tooltip:"Minimum number of points in cluster",min:1,max:1e3,step:1};constructor(){}}class m{editorSettings={};tableInput;colInput;preprocessingFunctionInput;plotEmbeddingsInput=r.boolInput("Plot embeddings",!0);clusterEmbeddingsInput=r.boolInput("Cluster embeddings",!0);preprocessingFunctionInputRoot=null;colInputRoot;methodInput;methodSettingsIcon;dbScanSettingsIcon;preprocessingFuncSettingsIcon;columnFunctionsMap={};supportedFunctions={};availableMetrics=[];similarityMetricInputRoot;methodSettingsDiv=r.inputs([]);dbScanSettingsDiv=r.inputs([]);preprocessingFuncSettingsDiv=r.inputs([]);preprocessingFunctionSettings={};methodsParams={[c.A.UMAP]:new h,[c.A.T_SNE]:new u};dbScanParams=new d;similarityMetricInput;get algorithmOptions(){const t=this.methodsParams[this.methodInput.value],e={};return Object.keys(t).forEach((n=>{null!=t[n].value&&(e[n]=t[n].value)})),e}get dbScanOptions(){return{dbScanEpsilon:this.dbScanParams.epsilon.value??.01,dbScanMinPts:this.dbScanParams.minPts.value??4}}constructor(t={}){this.editorSettings=t,a.Func.find({tags:[l.n3]}).forEach((t=>{const e=t.options.get(l.vO)??"",n=t.friendlyName??t.name,i=t.options.get(l.ts)??"",s=t.options.get(l.q6)??"",o=t.options.get(l.dB)??"";this.editorSettings.semtype&&!e.includes(this.editorSettings.semtype)||this.editorSettings.type&&!i.includes(this.editorSettings.type)||this.editorSettings.units&&!s.includes(this.editorSettings.units)||(this.supportedFunctions[n]={func:t,semTypes:e?e.split(","):[],types:i?i.split(","):[],units:s?s.split(","):[],distanceFunctions:o?o.split(","):[]})})),this.tableInput=r.tableInput("Table",o.shell.tv.dataFrame,o.shell.tables,(()=>{this.onTableInputChanged()})),this.onTableInputChanged(),this.regenerateColInput(),this.onColumnInputChanged();let e=!1,n=!1;this.methodInput=r.choiceInput("Method",c.A.UMAP,[c.A.UMAP,c.A.T_SNE],(()=>{e&&this.createAlgorithmSettingsDiv(this.methodSettingsDiv,this.methodsParams[this.methodInput.value])})),this.methodSettingsIcon=r.icons.settings((()=>{e=!e,e?this.createAlgorithmSettingsDiv(this.methodSettingsDiv,this.methodsParams[this.methodInput.value]):r.empty(this.methodSettingsDiv)}),"Modify methods parameters"),this.dbScanSettingsIcon=r.icons.settings((()=>{n=!n,n?this.createAlgorithmSettingsDiv(this.dbScanSettingsDiv,this.dbScanParams):r.empty(this.dbScanSettingsDiv)}),"Modify clustering parameters"),this.clusterEmbeddingsInput.classList.add("ml-dim-reduction-settings-input"),this.clusterEmbeddingsInput.root.prepend(this.dbScanSettingsIcon),this.methodInput.root.classList.add("ml-dim-reduction-settings-input"),this.methodInput.root.prepend(this.methodSettingsIcon),this.methodSettingsDiv=r.inputs([]);const i=this.columnFunctionsMap[this.colInput.value.name];this.preprocessingFunctionInput=r.choiceInput("Encoding function",i[0],i,(()=>{this.onPreprocessingFunctionChanged()}));let s=!1;this.preprocessingFunctionInputRoot||(this.preprocessingFunctionInputRoot=this.preprocessingFunctionInput.root,s=!0),s||(r.empty(this.preprocessingFunctionInputRoot),Array.from(this.preprocessingFunctionInput.root.children).forEach((t=>this.preprocessingFunctionInputRoot.append(t)))),this.preprocessingFunctionInputRoot.classList.add("ml-dim-reduction-settings-input");let h=!1;this.preprocessingFuncSettingsIcon=r.icons.settings((async()=>{h?r.empty(this.preprocessingFuncSettingsDiv):await this.createPreprocessingFuncParamsDiv(this.preprocessingFuncSettingsDiv,this.supportedFunctions[this.preprocessingFunctionInput.value].func),h=!h}),"Modify encoding function parameters"),this.preprocessingFunctionInputRoot.prepend(this.preprocessingFuncSettingsIcon),this.similarityMetricInput=r.choiceInput("Similarity","",[],null),this.similarityMetricInput.nullable=!1,this.similarityMetricInputRoot||(this.similarityMetricInputRoot=this.similarityMetricInput.root),this.onPreprocessingFunctionChanged()}getColInput(){const t=this.tableInput.value?.columns.toList().find((t=>!!this.columnFunctionsMap[t.name]))??null,e=r.columnInput("Column",this.tableInput.value,t,(()=>this.onColumnInputChanged()),{filter:t=>!!this.columnFunctionsMap[t.name]});return this.colInputRoot||(this.colInputRoot=e.root),e}regenerateColInput(){let t=!1;this.colInputRoot&&(t=!0,r.empty(this.colInputRoot)),this.colInput=this.getColInput(),t&&Array.from(this.colInput.root.children).forEach((t=>this.colInputRoot.append(t))),this.onColumnInputChanged()}onTableInputChanged(){const t=this.tableInput.value;t&&(this.columnFunctionsMap={},t.columns.toList().forEach((t=>{Object.keys(this.supportedFunctions).forEach((e=>{const n=this.supportedFunctions[e].semTypes,i=this.supportedFunctions[e].types,s=this.supportedFunctions[e].units,o=!n.length||t.semType&&n.includes(t.semType),r=!i.length||i.includes(t.type),l=!s.length||t.getTag(a.TAGS.UNITS)&&s.includes(t.getTag(a.TAGS.UNITS));o&&r&&l&&(this.columnFunctionsMap[t.name]||(this.columnFunctionsMap[t.name]=[]),this.columnFunctionsMap[t.name].push(e))}))})),this.regenerateColInput())}onColumnInputChanged(){const t=this.colInput.value;if(!t)return;const e=this.columnFunctionsMap[t.name];this.preprocessingFunctionInput=r.choiceInput("Preprocessing function",e[0],e,(()=>{this.onPreprocessingFunctionChanged()}));let n=!1;this.preprocessingFunctionInputRoot||(this.preprocessingFunctionInputRoot=this.preprocessingFunctionInput.root,n=!0),n||(r.empty(this.preprocessingFunctionInputRoot),Array.from(this.preprocessingFunctionInput.root.children).forEach((t=>this.preprocessingFunctionInputRoot.append(t)))),this.onPreprocessingFunctionChanged()}onPreprocessingFunctionChanged(){r.empty(this.preprocessingFuncSettingsDiv),this.preprocessingFunctionSettings={};const t=this.preprocessingFunctionInput.value,e=this.supportedFunctions[t].distanceFunctions;this.availableMetrics=[...e],this.similarityMetricInput=r.choiceInput("Similarity",this.availableMetrics[0],this.availableMetrics,null),this.similarityMetricInput.nullable=!1,this.similarityMetricInputRoot||(this.similarityMetricInputRoot=this.similarityMetricInput.root),r.empty(this.similarityMetricInputRoot),Array.from(this.similarityMetricInput.root.children).forEach((t=>this.similarityMetricInputRoot.append(t))),this.preprocessingFuncSettingsIcon&&(this.supportedFunctions[t].func.inputs.length<3?this.preprocessingFuncSettingsIcon.style.display="none":this.preprocessingFuncSettingsIcon.style.display="flex")}createAlgorithmSettingsDiv(t,e){return r.empty(t),Object.keys(e).forEach((n=>{const i=e[n],s=r.floatInput(i.uiName,i.value,(()=>{i.value=s.value}));r.tooltip.bind(s.root,i.tooltip),t.append(s.root)})),t}async createPreprocessingFuncParamsDiv(t,e){if(r.empty(t),e.inputs.length<3)return r.div();const n=e.prepare(),i=await n.buildEditor(r.div());for(let s=2;s<e.inputs.length;s++){const o=e.inputs[s];(this.preprocessingFunctionSettings[o.name]||n.inputParams[e.inputs[s].name].value||o.defaultValue)&&(this.preprocessingFunctionSettings[o.name]=this.preprocessingFunctionSettings[o.name]??n.inputParams[o.name].value??o.defaultValue);const r=i.find((t=>t.property.name===o.name));r&&(null!==this.preprocessingFunctionSettings[o.name]&&void 0!==this.preprocessingFunctionSettings[o.name]&&(r.value=this.preprocessingFunctionSettings[o.name]),r.onChanged((()=>{this.preprocessingFunctionSettings[o.name]=r.value})),t.append(r.root))}return t}getEditor(){return r.div([this.tableInput,this.colInputRoot,this.preprocessingFunctionInputRoot,this.preprocessingFuncSettingsDiv,this.methodInput,this.methodSettingsDiv,this.similarityMetricInputRoot,this.plotEmbeddingsInput,this.clusterEmbeddingsInput,this.dbScanSettingsDiv],{style:{minWidth:"320px"},classes:"ui-form"})}getParams(){return{table:this.tableInput.value,col:this.colInput.value,methodName:this.methodInput.value,preprocessingFunction:this.supportedFunctions[this.preprocessingFunctionInput.value].func,similarityMetric:this.similarityMetricInput.value,plotEmbeddings:this.plotEmbeddingsInput.value,clusterEmbeddings:this.clusterEmbeddingsInput.value,options:{...this.algorithmOptions,...this.dbScanOptions,preprocessingFuncArgs:this.preprocessingFunctionSettings??{}}}}}var p=n(442),g=n(5697),f=n(701),y=n(3379),b=n.n(y),C=n(7795),w=n.n(C),v=n(569),S=n.n(v),A=n(3565),x=n.n(A),T=n(9216),I=n.n(T),M=n(4589),L=n.n(M),E=n(9414),N={};N.styleTagTransform=L(),N.setAttributes=x(),N.insert=S().bind(null,"head"),N.domAPI=w(),N.insertStyleElement=I(),b()(E.Z,N),E.Z&&E.Z.locals&&E.Z.locals;var R=n(7861);const _=t=>null==t;function O(t,e,n,i){if(n>t[t.length-1])return;const s=t.findIndex((t=>n<t));t.pop(),t.splice(s,0,n),e.pop(),e.splice(s,0,i)}var P=n(6254),G=n(2669),k=n(6361);class F{_workerCount;constructor(){this._workerCount=Math.max(navigator.hardwareConcurrency-2,1)}async calc(t,e,i,s={}){const o=t.length*(t.length-1)/2,r=Math.floor(o/this._workerCount),a=t.length>2e4?await this.getMinimalThreshold(t,e,s):0;i<a&&(console.log(`using threshold ${a}`),i=a),s.threshold=i;const l=new Array(this._workerCount),c=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(n.p+n.u(471),n.b))));for(let n=0;n<this._workerCount;n++)l[n]=new Promise(((a,l)=>{const h=n*r,u=n===this._workerCount-1?o:(n+1)*r;u<=h&&a({i:new Int32Array(0),j:new Int32Array(0),distance:new Float32Array(0),idx:n}),c[n].postMessage({values:t,startIdx:h,endIdx:u,threshold:i,fnName:e,opts:s}),c[n].onmessage=({data:{error:t,i:e,j:i,distance:s}})=>{t?(c[n].terminate(),l(t)):(c[n].terminate(),a({i:e,j:i,distance:s,idx:n}))}}));const h=await Promise.all(l),u=h.reduce(((t,e)=>t+e.i.length),0),d=new Int32Array(u),m=new Int32Array(u),p=new Float32Array(u);let g=0;for(const t of h)d.set(t.i,g),m.set(t.j,g),p.set(t.distance,g),g+=t.i.length;return{i:d,j:m,distance:p}}async getKNN(t,e,n=15,i={}){return await this.multiColumnKNN([t],[e],n,[i],[1])}async multiColumnKNN(t,e,s=15,o,r,a=i.EUCLIDEAN){if(t.length!==e.length||t.length!==o.length||t.length!==r.length)throw new Error("values, distance functions, options and weights arrays should have the same length");if(t.some((e=>e.length!==t[0].length)))throw new Error("all values arrays should have the same length");const l=t[0].length*(t[0].length-1)/2,c=Math.floor(l/this._workerCount),h=new Array(this._workerCount),u=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(n.p+n.u(664),n.b))));for(let n=0;n<this._workerCount;n++)h[n]=new Promise(((i,h)=>{const d=n*c,m=n===this._workerCount-1?l:(n+1)*c;m<=d&&i({knnDistances:new Array(0),knnIndexes:new Array(0)}),u[n].postMessage({values:t,startIdx:d,endIdx:m,fnNames:e,opts:o,nNeighbours:s,weights:r,aggregationMethod:a}),u[n].onmessage=({data:{error:t,knnDistances:e,knnIndexes:s}})=>{t?(u[n].terminate(),h(t)):(u[n].terminate(),i({knnDistances:e,knnIndexes:s}))}}));const d=await Promise.all(h),m={knnDistances:new Array(t[0].length).fill(null).map((()=>new Array(s).fill(99999))),knnIndexes:new Array(t[0].length).fill(null).map((()=>new Array(s).fill(-1)))};for(const e of d)for(let n=0;n<t[0].length;++n)for(let t=0;t<e.knnDistances[n]?.length;++t)O(m.knnDistances[n],m.knnIndexes[n],e.knnDistances[n][t],e.knnIndexes[n][t]);return m}async getSampleDistances(t,e,i={}){const s=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(n.p+n.u(118),n.b)))),o=t.slice();for(let t=o.length-1;t>0;t--){const e=Math.floor(Math.random()*(t+1));[o[t],o[e]]=[o[e],o[t]]}try{const n=t.length*(t.length-1)/2,r=Math.floor(n/this._workerCount),a=1e6,l=Math.max(Math.min(n/1e3,a),Math.min(n,a)),c=Math.floor(l/this._workerCount),h=new Array(this._workerCount);for(let t=0;t<this._workerCount;t++)h[t]=new Promise(((a,l)=>{const h=t*r,u=t===this._workerCount-1?n:(t+1)*r;s[t].postMessage({values:o,startIdx:h,endIdx:u,sampleLength:c,fnName:e,opts:i}),s[t].onmessage=({data:{error:e,distance:n}})=>{s[t].terminate(),e?l(e):a({distance:n})}}));const u=await Promise.all(h),d=u.reduce(((t,e)=>t+e.distance.length),0),m=new Float32Array(d);let p=0;for(const t of u)m.set(t.distance,p),p+=t.distance.length;return m.sort(),m}catch(t){return s?.forEach((t=>t?.terminate())),console.error(t),new Float32Array(1).fill(.5)}}async getMinimalThreshold(t,e,n={}){try{const i=t.length*(t.length-1)/2,s=await this.getSampleDistances(t,e,n);return 1-s[Math.floor(7e7/i*s.length)]}catch(t){return console.error(t),.5}}static calcSync(t,e,n,i){const s=[],o=[],r=[];let a=0,l=0,c=0;const h=t.length*(t.length-1)/2;for(;a<h;){const h=_(t[l])||_(t[c])?1:n(t[l],t[c]);(Object.values(k.gk).some((t=>t===e))?(0,g.Om)(h):1-h)>=i&&(s.push(l),o.push(c),r.push(h)),a++,c++,c===t.length&&(l++,c=l+1)}return{i:new Int32Array(s),j:new Int32Array(o),distance:new Float32Array(r)}}}var B,W=n(9657);!function(t){t.none="none",t.bold="bold",t.dashed="dashed"}(B||(B={}));class H{get currentLineId(){return this._currentLineIdx}set currentLineId(t){t!==this._currentLineIdx&&(this._currentLineIdx=t,this.sp.render(this.ctx))}set linesToRender(t){this.updateLines(t),this.sp.render(this.ctx)}set linesVisibility(t){this.visibility=t,this.sp.render(this.ctx)}constructor(t,e,n,i,s=B.none){var o;this._currentLineIdx=-1,this.lineClicked=new f.Subject,this.lineHover=new f.Subject,this.mouseOverLineId=-1,this.arrowWidth=15,this.sp=t,this.xAxisCol=this.sp.dataFrame.columns.byName(e),this.yAxisCol=this.sp.dataFrame.columns.byName(n),this.canvas=this.sp.getInfo().canvas,this.ctx=this.canvas.getContext("2d"),this.currentLineStyle=s,this.updateLines(i),this.visibility=null!==(o=i.visibility)&&void 0!==o?o:new W.Z(this.lines.from.length),i.visibility||this.visibility.setAll(!0,!1),i.arrowSize&&(this.arrowWidth=i.arrowSize),this.canvas.onmousedown=t=>{-1!==this.mouseOverLineId&&this.lineClicked.next({x:t.clientX,y:t.clientY,id:this.mouseOverLineId,event:t})},this.canvas.onmousemove=t=>{this.mouseOverLineId=this.checkCoordsOnLine(t.offsetX,t.offsetY),-1!==this.mouseOverLineId&&this.lineHover.next({x:t.clientX,y:t.clientY,id:this.mouseOverLineId,event:t})},t.onEvent("d4-before-draw-scene").subscribe((t=>{this.renderLines()}))}updateLines(t){this.lines=t,this.multipleLinesCounts=new Uint8Array(this.lines.from.length),this.createMultiLinesIndices()}renderLines(){var t,e,n,i,s,o,r,a,l,c,h,u,d;const m=this.sp.getOptions().look,p=this.lines.colors||this.lines.width||this.lines.opacities||this.lines.drawArrowsArr;p||(this.ctx.lineWidth=null!==(t=this.lines.width)&&void 0!==t?t:1,this.ctx.strokeStyle=`rgba(${null!==(e=this.lines.color)&&void 0!==e?e:"0,128,0"},${null!==(n=this.lines.opacity)&&void 0!==n?n:1})`);const g=m.sizeColumnName?this.sp.dataFrame.col(m.sizeColumnName):null,f=this.sp.dataFrame.filter;for(let t=0;t<this.lines.from.length;t++)if(f.get(this.lines.from[t])&&f.get(this.lines.to[t])&&this.visibility.getBit(t)){let e=0;const{sizeFrom:n,sizeTo:f}=this.getMarkersSizes(m,g,t),y=this.sp.worldToScreen(this.xAxisCol.get(this.lines.from[t]),this.yAxisCol.get(this.lines.from[t]));let b=null==y?void 0:y.x,C=null==y?void 0:y.y;const w=this.sp.worldToScreen(this.xAxisCol.get(this.lines.to[t]),this.yAxisCol.get(this.lines.to[t]));let v=null==w?void 0:w.x,S=null==w?void 0:w.y;if(this.ctx.beginPath(),b&&C&&v&&S){if(p){const e=(null===(i=this.lines.colors)||void 0===i?void 0:i[t])?null===(s=this.lines.colors)||void 0===s?void 0:s[t]:"0,128,0",n=(null===(o=this.lines.opacities)||void 0===o?void 0:o[t])?null===(r=this.lines.opacities)||void 0===r?void 0:r[t]:1;this.ctx.strokeStyle=`rgba(${e},${n})`,this.ctx.lineWidth=(null===(a=this.lines.widths)||void 0===a?void 0:a[t])?null===(l=this.lines.widths)||void 0===l?void 0:l[t]:1}t===this._currentLineIdx&&this.toggleCurrentLineStyle(!0);const m=this.multipleLinesCounts[t];let g=null;if(m){e=this.getLineLength(b,C,v,S);const i=this.getPointOnDistance(b,C,v,S,f,e),s=this.getPointOnDistance(v,S,b,C,n,e);b=i.x,C=i.y,v=s.x,S=s.y,g=this.lines.from[t]>this.lines.to[t]?this.findControlPoint(m,b,C,v,S,t):this.findControlPoint(m,v,S,b,C,t),this.ctx.moveTo(b,C),this.ctx.quadraticCurveTo(g.x,g.y,v,S)}else this.ctx.moveTo(b,C),this.ctx.lineTo(v,S);if((null!==(c=this.lines.drawArrows)&&void 0!==c?c:null===(h=this.lines.drawArrowsArr)||void 0===h?void 0:h.getBit(t))&&(e||(e=this.getLineLength(b,C,v,S)),e>this.arrowWidth)){const t=m?null:this.getPointOnDistance(b,C,v,S,f,e),n=m?g.x:b,i=m?g.y:C;this.canvasArrow(this.ctx,null!==(u=null==t?void 0:t.x)&&void 0!==u?u:b,null!==(d=null==t?void 0:t.y)&&void 0!==d?d:C,n,i)}this.ctx.stroke(),this.ctx.closePath(),t===this._currentLineIdx&&this.toggleCurrentLineStyle(!1)}}this.fillLeftBottomRect()}toggleCurrentLineStyle(t){switch(this.currentLineStyle){case B.bold:t?this.ctx.lineWidth+=2:this.ctx.lineWidth-=2;break;case B.dashed:t?this.ctx.setLineDash([5,5]):this.ctx.setLineDash([]);break;default:return}}getMarkersSizes(t,e,n){let i=3,s=3;return e?(i=(t.markerMinSize+(t.markerMaxSize-t.markerMinSize)*e.scale(this.lines.from[n]))/2,s=(t.markerMinSize+(t.markerMaxSize-t.markerMinSize)*e.scale(this.lines.to[n]))/2):t.markerDefaultSize&&(i=t.markerDefaultSize/2,s=t.markerDefaultSize/2),{sizeFrom:i,sizeTo:s}}fillLeftBottomRect(){const t=new Path2D;t.rect(this.sp.yAxisBox.minX,this.sp.yAxisBox.maxY,this.sp.yAxisBox.width,this.sp.xAxisBox.height),this.ctx.fillStyle="white",this.ctx.beginPath(),this.ctx.fill(t),this.ctx.closePath()}createMultiLinesIndices(){const t=new W.Z(this.lines.from.length);t.setAll(!0);for(let e=-1;-1!==(e=t.findNext(e));){let n=e,i=this.lines.from[n],s=this.lines.to[n],o=1;for(let n=e;-1!==(n=t.findNext(n));){const e=this.lines.from[n],r=this.lines.to[n];(e===i&&r===s||r===i&&e===s)&&(this.multipleLinesCounts[n]=++o,t.setBit(n,!1,!1))}o>1&&(this.multipleLinesCounts[n]=1),t.setBit(e,!1,!1)}}checkCoordsOnLine(t,e){let n=-1,i=null,s=null;const o=this.sp.getOptions().look,r=o.sizeColumnName?this.sp.dataFrame.col(o.sizeColumnName):null,a=this.sp.dataFrame.filter;for(let l=0;l<this.lines.from.length;l++)if(a.get(this.lines.from[l])&&a.get(this.lines.to[l])&&this.visibility.getBit(l)){const{sizeFrom:a,sizeTo:c}=this.getMarkersSizes(o,r,l),h=this.sp.worldToScreen(this.xAxisCol.get(this.lines.from[l]),this.yAxisCol.get(this.lines.from[l])),u=this.sp.worldToScreen(this.xAxisCol.get(this.lines.to[l]),this.yAxisCol.get(this.lines.to[l]));if(this.multipleLinesCounts[l]){const n=this.getLineLength(h.x,h.y,u.x,u.y),i=this.getPointOnDistance(h.x,h.y,u.x,u.y,c,n),o=this.getPointOnDistance(u.x,u.y,null==h?void 0:h.x,null==h?void 0:h.y,a,n),r=this.lines.from[l]>this.lines.to[l]?this.findControlPoint(this.multipleLinesCounts[l],i.x,i.y,o.x,o.y,l):this.findControlPoint(this.multipleLinesCounts[l],o.x,o.y,i.x,i.y,l);s=this.calculateDistToCurveLine(l,t,e,i,o,r)}else s=this.calculateDistToStraightLine(t,e,h,u);(!i&&null!==s&&s<5||i&&null!==s&&s<i)&&(i=s,n=l)}return n}calculateDistToStraightLine(t,e,n,i){let s=Math.min(n.x,i.x),o=Math.max(n.x,i.x),r=Math.min(n.y,i.y),a=Math.max(n.y,i.y);return t>=s-2&&t<=o+2&&e>=r-2&&e<=a+2?this.distToStraightLineSegment(t,e,n,i):null}distToStraightLineSegment(t,e,n,i){const s=(t,e,n,i)=>Math.pow(t-n,2)+Math.pow(e-i,2),o=s(n.x,n.y,i.x,i.y);if(0==o)return s(t,e,n.x,n.y);let r=((t-n.x)*(i.x-n.x)+(e-n.y)*(i.y-n.y))/o;return r=Math.max(0,Math.min(1,r)),s(t,e,n.x+r*(i.x-n.x),n.y+r*(i.y-n.y))}calculateDistToCurveLine(t,e,n,i,s,o){let r=Math.min(i.x,s.x,o.x),a=Math.max(i.x,s.x,o.x),l=Math.min(i.y,s.y,o.y),c=Math.max(i.y,s.y,o.y);if(e>=r-2&&e<=a+2&&n>=l-2&&n<=c+2){const t=a-r,h=c-l;return this.calculateDistToCurveInRect(e,n,i,o,s,t,h)}return null}calculateDistToCurveInRect(t,e,n,i,s,o,r){const a=Math.floor((o+r)/3),l=1/a,c=new Uint32Array(a),h=new Uint32Array(a);let u=new Uint32Array(a),d=null;const m=new W.Z(a);for(let o=0;o<c.length;o++){const r=o*l,a=Math.pow(1-r,2)*n.x+2*r*(1-r)*i.x+Math.pow(r,2)*s.x,m=Math.pow(1-r,2)*n.y+2*r*(1-r)*i.y+Math.pow(r,2)*s.y,p=Math.abs(t-a),g=Math.abs(e-m),f=p+g;(!d||d>f)&&(d=f),u[o]=Math.max(p,g),c[o]=a,h[o]=m}for(let t=0;t<c.length;t++)u[t]<d&&m.setBit(t,!0,!1);let p=null;for(let n=-1;-1!==(n=m.findNext(n));){const i=Math.hypot(c[n]-t,h[n]-e);(!p||p>i)&&(p=i)}return p}getLineLength(t,e,n,i){return Math.sqrt(Math.pow(n-t,2)+Math.pow(i-e,2))}getPointOnDistance(t,e,n,i,s,o){const r=n-s*((n-t)/o),l=i-s*((i-e)/o);return new a.Point(r,l)}findControlPoint(t,e,n,i,s,o){const r=e+(i-e)/2,l=n+(s-n)/2;let c=r-e,h=l-n;const u=Math.sqrt(c*c+h*h);c/=u,h/=u;const d=50*Math.ceil(t/2);return t%2==0?new a.Point(r+d/2*h,l-d/2*c):new a.Point(r-d/2*h,l+d/2*c)}canvasArrow(t,e,n,i,s){const o=Math.atan2(i-e,s-n)+Math.PI;t.moveTo(e-this.arrowWidth*Math.sin(o-Math.PI/10),n-this.arrowWidth*Math.cos(o-Math.PI/10)),t.lineTo(e,n),t.lineTo(e-this.arrowWidth*Math.sin(o+Math.PI/10),n-this.arrowWidth*Math.cos(o+Math.PI/10))}}const D="dimensionality-reducer-terminate-event";var V=n(850);async function U(t,e,i,s,r,a,l){let c=await async function(t,e,i,s,r,a,l){if(!a.distanceFnArgs)throw new Error("options.distanceFnArgs must be defined");if(t.length!==e.length||t.length!==a.distanceFnArgs.length||t.length!==s.length)throw new Error("data, metrics and options and weights must have the same length");return new Promise((function(c,h){const u=new Worker(new URL(n.p+n.u(886),n.b));u.postMessage({columnsData:t,distanceMetrics:e,method:i,options:a,weights:s,aggregationMethod:r});const d=o.events.onCustomEvent(D).subscribe((()=>{try{u?.terminate()}finally{d.unsubscribe()}}));u.onmessage=({data:{error:t,embedding:e,epochNum:n,epochsLength:i}})=>{n&&i?l&&l(n,i,e):(d.unsubscribe(),t?h(t):c(e),setTimeout((()=>u.terminate()),0))}}))}(t,i,e,s,r,a,l);return c=c.map((t=>(0,V.Fv)(t))),c}let Z=0;const Y="cliffsDf",$=new f.Subject,K="act_diff",X="sali",q="sim",z="line_index",j=["1_seq","2_seq"],J="filterCliffs";var Q,tt=n(499),et=n(5226),nt=n(7228),it=n(8457),st=n(8260);async function ot(t,e,n,i){const s=(0,it.O)(e),o=(0,st.vU)(e.getTag(a.TAGS.UNITS),e.getTag("separator"))(n),r=i===Q.IDENTITY?function(t,e){const n=e.columns.length,i=new Array(n),s=new Array(n),o=new Array(n);for(let r=0;r<n;++r){const n=e.columns.byIndex(r);i[r]=n.getRawData(),s[r]=n.categories.indexOf(""),o[r]=n.categories.indexOf(t[r]??"")}const r=a.Column.float("Identity",e.rowCount),l=r.getRawData();for(let n=0;n<e.rowCount;++n){l[n]=0;for(let e=0;e<t.length;++e)i[e][n]===o[e]&&++l[n];l[n]/=t.length}return r}(o,s):i===Q.SIMILARITY?await async function(t,e){const n=e.columns.toList();return await(0,nt.Qx)(n,t)}(o,s):null;if(null===r)throw new Error(`In bio library: Unkown sequence scoring method: ${i}`);return r.name=t.columns.getUnusedName(r.name),t.columns.add(r),r}!function(t){t.IDENTITY="identity",t.SIMILARITY="similarity"}(Q||(Q={}));var rt=n(7945),at=n(4293),lt=n(6414),ct=n.n(lt);const ht="rgb(100,100,100)",ut="#808080",dt="rgb(0,0,0)",mt=st.GU;var pt,gt;function ft(t,e,n,i,s,o,r=ht,a=0,l=!1,c=1,h="",u=!1,d=gt.classic,m=[],p=0,g=null,f=[],y=null,b={}){s.textAlign="start";let C=o.substring(0),w=u?"":h;d===gt.MSA&&(w="");let v=!0,S=!0,A="difference";null!=g&&null!=g.cell.column&&(v=g.cell.column.temp["color-code"]??!0,S=g.cell.column.temp["compare-with-current"]??!0,A=g.cell.column.temp["highlight-difference"]??"difference");const x=f[p];S&&f.length>0&&"difference"===A&&(c=C==x?.3:c),S&&f.length>0&&"equal"===A&&(c=C!=x?.3:c),null!=y&&(C=mt(C,y));const T=C+w;b[T]??(b[T]=s.measureText(T));let I=b[T];b[C]??(b[C]=s.measureText(C));let M=b[C].width;b[w]??(b[w]=s.measureText(w));const L=b[w].width,E=i/2-(I.fontBoundingBoxAscent+I.fontBoundingBoxDescent)/2+1;function N(n,i){const o=v?r:dt;s.fillStyle=o,s.globalAlpha=c,d===gt.classic&&(s.fillText(C,t+n,e+E),s.fillStyle=ut,s.fillText(w,t+i,e+E)),d===gt.MSA&&s.fillText(C,t+n,e+E)}I=I.width,d===gt.MSA&&(M=m[p],I=m[p]);const R=(m[p]??0)-(m[0]??0);if(l||I>n)return N(R,R+M),t+R+M+L;{const e=(n-I)/2;return N(e,e+M),t+R+e+M}}!function(t){t.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(pt||(pt={})),function(t){t.MSA="MSA",t.classic="classic"}(gt||(gt={}));var yt,bt=n(9611),Ct=n(8447),wt=n(7331);!function(t){t.long="long",t.short="short"}(yt||(yt={}));const vt={true:"1",false:"0"};var St=n(3553);const At="rgb(100,100,100)",xt=Ct.GU;function Tt(t,e,n,i,s){return t?Math.max(Math.min(t.canvas.width/s-n,i)):Math.max(e.canvas.width/s-n,0)}function It(t){const e=!ct().enumerate(t).some((([e,n])=>e.length>1&&0!=n&&n!=t.length-1)),n=[],i=e?"":" ";for(const[e,s]of ct().enumerate(t)){let o=e;s<t.length&&(o+=`${e?"":"-"}${i}`),n.push(o)}return[n,e]}class Mt extends a.GridCellRenderer{constructor(){super(...arguments),this.padding=5}get name(){return"sequence"}get cellType(){return"sequence"}get defaultHeight(){return 30}get defaultWidth(){return 230}onClick(t,e){t.cell.column.temp["current-word"]=t.cell.value,t.grid.invalidate()}onMouseMove(t,e){const n=t.cell.column.temp["bio-seqCol"];if(!n)return;const i=t.bounds,s=e.offsetX-t.gridColumn.left+(t.gridColumn.left-i.x),a=n.getPosition(t.tableRowIndex,s),l=n.getSeqMonList(t.tableRowIndex);if(null!==a&&a<l.length){const t=l[a],i=[r.div(t)];if(n._monomerStructureMap[t])i.push(n._monomerStructureMap[t]);else{const e=n.getMonomer(t);if(e){const s={autoCrop:!0,autoCropMargin:0,suppressChiralText:!0},r=o.chem.svgMol(e.smiles,void 0,void 0,s);i.push(r),n._monomerStructureMap[t]=r}}r.tooltip.show(r.divV(i),e.x+16,e.y+16)}else r.tooltip.hide()}render(t,e,n,i,s,o,r){let l,c=0,h=50;try{l=o.grid}catch(t){l=void 0;const[e,n]=(0,rt.yf)(t);fn.logger.error(e,void 0,n)}const u=o.cell.column;if(!l||!u)return;const d=u.temp,m=d["monomer-width"];if("short"===(null!=m?m:"short")){const t=parseInt(u.getTag(pt.maxMonomerLength));h=(isNaN(t)?fn.properties?.MaxMonomerLength:t)??4}let p=u.temp["bio-seqCol"];p||(p=new bt.A(l,u,(()=>{const t=tt.Cn.getOrCreate(u);return{unitsHandler:t,monomerCharWidth:7,separatorWidth:t.isMsa()?8:c,monomerToShort:xt,monomerLengthLimit:h,monomerLib:Sn()}}))),u.tags[".mm.cellRenderer.settingsChanged"]===vt.true&&(c=d[".mm.cellRenderer.gapLength"]??c,p.setMonomerLengthLimit(h),p.setSeparatorWidth(p.isMsa()?8:c),u.setTag(".mm.cellRenderer.settingsChanged",vt.false));const[g,f]=p.getCellMonomerLengths(o.tableRowIndex);g.length,p.updated&&(d["bio-seqCol"]=p),t.save();try{const r=window.devicePixelRatio,l=-1!==o.gridRow?o.grid:null,c=o.cell.value,m=u.getTag("alphabet"),g=50;i=Tt(l,t,e,i,r),t.beginPath(),t.rect(e+this.padding,n+this.padding,i-this.padding-1,s-2*this.padding),t.clip(),t.font="12px monospace",t.textBaseline="top";const y=u.getTag(a.TAGS.UNITS),b=u.getTag("aligned"),C=(0,Ct.py)(m),w=u.getTag("separator")??"",v=i/5,S=tt.Cn.getOrCreate(u).getSplitter(v),A=d["reference-sequence"],x=d["current-word"],T=S(null!=A&&""!=A?A:x??""),I=S(c);let M=At,L=gt.classic;b&&b.includes("MSA")&&y==Ct.r2.SEPARATOR&&(L=gt.MSA);for(const[r,a]of ct().enumerate(I)){M=C.get(r),t.fillStyle=At;const l=a===I.length-1;if(ft(e+this.padding,n,i,s,t,r,M,0,!0,1,w,l,L,f,a,o,T,h,p._monomerLengthMap),g>i)break}}catch(t){const e=t instanceof Error?t.message:t?t.toString():"Error 'undefined'";fn.logger.error(`Bio: MacromoleculeSequenceCellRenderer.render() error: ${e}`)}finally{t.restore()}}}class Lt extends a.GridCellRenderer{get name(){return"MacromoleculeDifferenceCR"}get cellType(){return St.Of.MACROMOLECULE_DIFFERENCE}get defaultHeight(){return 30}get defaultWidth(){return 230}render(t,e,n,i,s,o,r){const l=window.devicePixelRatio,c=o.grid,h=o.cell,u=o.tableColumn,d=h.value??"",m=u.tags.separator,p=u.tags[a.TAGS.UNITS];i=Tt(c,t,e,i,l);const[g,f]=d.split("#"),y=(0,st.vU)(p,m);Et(t,e,n,i,s,y(g),y(f),p)}}function Et(t,e,n,i,s,o,r,a,l,c){if(o.length!==r.length){const t=function(t,e){let n=0,i=0;const s=t.length>e.length?t:e,o=t.length>e.length?e:t;for(let t=0;t<o.length;t++)s[t]===o[t]&&n++;const r=s.length-o.length;for(let t=s.length-1;t>r;t--)s[t]===o[t-r]&&i++;const a=new Array(Math.abs(t.length-e.length)).fill("");function l(t){return n>i?t.concat(a):a.concat(t)}return t.length>e.length?e=l(e):t=l(t),{subParts1:t,subParts2:e}}(ct()(o).toArray(),ct()(r).toArray());o=t.subParts1,r=t.subParts2}const h=t.measureText(It(o).join("")),u=t.measureText(It(r).join("")),d=Math.max(h.width,u.width);l&&(i=d+4*o.length,t.canvas.width=d+4*o.length);let m=Math.max(e,e+(i-(d+4*o.length))/2)+5;const p=Math.max(n,n+(s-28)/2);t.save(),t.beginPath(),t.rect(e,n,l?d+4*o.length:i,s),t.clip(),t.font="12px monospace",t.textBaseline="top";let g=wt.UE.Color;"HELM"!=a&&(g=(0,Ct.py)(a.substring(a.length-2)));for(let e=0;e<o.length;e++){const n=o[e],a=r[e],l=g.get(n);if(n!=a){const o=g.get(a),r=ft(m,p-7,i,s,t,n,l,0,!0),h=ft(m,p+7,i,s,t,a,o,0,!0);m=Math.max(h,r),c&&(c[e]=Nt(n,a,l,o,p,7,s))}else m=ft(m,p,i,s,t,n,l,0,!0,.5);m+=4}t.restore()}function Nt(t,e,n,i,s,o,r){const a=document.createElement("canvas"),l=a.getContext("2d");l.font="12px monospace";const c=l.measureText(It([t]).join("")).width,h=l.measureText(It([e]).join("")).width,u=Math.max(c,h);return a.height=r,a.width=u+4,l.font="12px monospace",l.textBaseline="top",ft(0,s-o,u,r,l,t,n,0,!0),ft(0,s+o,u,r,l,e,i,0,!0),a}var Rt,_t=n(8467),Ot=n(9298);!function(t){t.Unknown="unknown",t.FR="framework",t.CDR="cdr"}(Rt||(Rt={}));const Pt=new class{constructor(){this.regionTypes=[Rt.CDR],this.chains=["Heavy","Light"],this.skipEmptyPositions=!1,this.fitWidth=!1,this.positionWidth=16,this.positionHeight=Ot.ES.Entropy,this.filterSource=Ot.vS.filterSource}};var Gt=n(172),kt=n(8415);const Ft=Rt;var Bt,Wt;!function(t){t.STYLE="Style",t.BEHAVIOR="Behavior",t.LAYOUT="Layout",t.DATA="Data"}(Bt||(Bt={})),function(t){t.skipEmptyPositions="skipEmptyPositions",t.regionTypes="regionTypes",t.chains="chains",t.fitWidth="fitWidth",t.positionWidth="positionWidth",t.positionHeight="positionHeight",t.filterSource="filterSource"}(Wt||(Wt={}));const Ht=Pt;class Dt extends a.JsViewer{constructor(){super(),this.viewed=!1,this.regionsFg=null,this.regionsRoot=null,this.isOpened=!1,this.panelNode=null,this.regions=[],this.viewerId=++Dt.viewerCounter,this.setDataInProgress=!1,this.host=null,this.mainLayout=null,this.logos=[],this.viewSubs=[],this.calcSizeRequested=!1,this._onRendered=new f.Subject,this.skipEmptyPositions=this.bool(Wt.skipEmptyPositions,Ht.skipEmptyPositions,{category:Bt.DATA}),this.regionTypes=this.stringList(Wt.regionTypes,Ht.regionTypes,{category:Bt.DATA,choices:Object.values(Ft).filter((t=>t!=Ft.Unknown))}),this.chains=this.stringList(Wt.chains,Ht.chains,{category:Bt.DATA,choices:["Heavy","Light"]}),this.fitWidth=this.bool(Wt.fitWidth,Ht.fitWidth,{category:Bt.LAYOUT}),this.positionWidth=this.float(Wt.positionWidth,Ht.positionWidth,{category:Bt.LAYOUT,editor:"slider",min:0,max:64,description:"Internal WebLogo viewers property width of position."}),this.positionHeight=this.string(Wt.positionHeight,Ht.positionHeight,{category:Bt.LAYOUT,choices:Object.keys(Ot.ES)}),this.filterSource=this.string(Wt.filterSource,Ht.filterSource,{category:Bt.BEHAVIOR,choices:Object.values(Ot.Ct)}),this.viewSyncer=new Gt.c(fn.logger)}viewerToLog(){return`VdRegionsViewer<${this.viewerId}>`}async init(){this.subs.push((0,f.fromEvent)(this.root,"mousemove").subscribe(this.rootOnMouseMove.bind(this)))}detach(){const t=`${this.viewerToLog()}.detach()`,e=super.detach.bind(this);this.viewSyncer.sync(`${t}`,(async()=>{this.setDataInProgress||(this.viewed&&(await this.destroyView("detach"),this.viewed=!1),e())}))}onTableAttached(){super.onTableAttached(),this.setData(this.regions)}onPropertyChanged(t){if(super.onPropertyChanged(t),t){switch(t.name){case Wt.regionTypes:case Wt.chains:this.setData(this.regions)}switch(t.name){case Wt.skipEmptyPositions:for(let t=0;t<this.logos.length;++t)for(const e of this.chains)this.logos[t][e].setOptions({[kt.bo.skipEmptyPositions]:this.skipEmptyPositions});this.calcSize();break;case Wt.fitWidth:case Wt.positionWidth:this.calcSize();break;case Wt.positionHeight:for(let t=0;t<this.logos.length;++t)for(const e of this.chains)this.logos[t][e].setOptions({[kt.bo.positionHeight]:this.positionHeight});this.calcSize();break;case Wt.filterSource:this.filterSourceInput.value=this.filterSource;break;default:this.setData(this.regions)}}else console.warn("Bio: VdRegionsViewer.onPropertyChanged() property is null")}setData(t){const e=`${this.viewerToLog()}.setData()`;fn.logger.debug(`${e}, in, regions.length = ${t.length}`),this.viewSyncer.sync(`${e}`,(async()=>{if(!this.setDataInProgress){this.setDataInProgress=!0;try{this.viewed&&(await this.destroyView("setData"),this.viewed=!1),this.regions=t,this.viewed||(await this.buildView("setData"),this.viewed=!0)}finally{this.setDataInProgress=!1}}}))}async destroyView(t){fn.logger.debug(`Bio: VdRegionsViewer.destroyView( mainLayout = ${this.mainLayout?"value":"none"} ), purpose = '${t}', this.regions.length = ${this.regions.length}`),this.filterSourceInput&&r.empty(this.filterSourceInput.root),null!=this.mainLayout&&(this.mainLayout.remove(),this.host.remove(),this.host=null,this.mainLayout=null);for(const t of this.viewSubs)t.unsubscribe()}async buildView(t){fn.logger.debug(`Bio: VdRegionsViewer.buildView() begin, purpose = '${t}', this.regions.length = ${this.regions.length}`);const e=this.regions.filter((t=>this.regionTypes.includes(t.type))),n=Array.from(new Set(e.map((t=>t.order)))).sort(),i=[];for(let t=0;t<n.length;t++)for(const s of this.chains){const o=e.find((e=>e.order==n[t]&&e.chain==s));i.push((async()=>{const e=await this.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:o.sequenceColumnName,startPositionName:o.positionStartName,endPositionName:o.positionEndName,fixWidth:!0,skipEmptyPositions:this.skipEmptyPositions,positionWidth:this.positionWidth,positionHeight:this.positionHeight,filterSource:this.filterSource});return e.onSizeChanged.subscribe((()=>{this.calcSize()})),[t,s,e]})())}const s=await Promise.all(i);this.logos=new Array(n.length);for(let t=0;t<n.length;++t)this.logos[t]={};for(const[t,e,n]of s)this.logos[t][e]=n,this.viewSubs.push(n.onFreqsCalculated.subscribe((()=>{this.calcSize()})));this.mainLayout=r.table(this.chains,(t=>[...n.length>0?[r.div(t,{style:{transform:"rotate(-90deg)",font:"12px Roboto, Roboto Local, sans-serif",textAlign:"center",width:"16px",marginTop:"24px",marginLeft:"6px"}})]:[],...[...Array(n.length).keys()].map((e=>{const n=this.logos[e][t];return n.root.style.height="100%",r.div([n.root],{style:{marginTop:"4px",marginBottom:"4px"}})}))]),["",...[...Array(n.length).keys()].map((t=>e.find((e=>e.order==n[t]&&e.chain==this.chains[0])).name||"Name"))]),this.mainLayout.className="mlb-vd-regions-viewer-table2",this.filterSourceInput=r.choiceInput("Data source",this.filterSource,Object.values(Ot.Ct),this.filterSourceInputOnValueChanged.bind(this)),this.filterSourceInput.root.style.position="absolute",this.filterSourceInput.root.style.right="9px",this.filterSourceInput.root.style.top="-4px",Math.ceil(255*Math.random()).toString(16),this.host=r.div([this.mainLayout,this.filterSourceInput.root],{}),this.root.appendChild(this.host),this.root.style.overflowX="auto",this.calcSize(),this.viewSubs.push(r.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),fn.logger.debug("Bio: VdRegionsViewer.buildView() end")}calcSize(){fn.logger.debug("Bio: VdRegionsViewer.calcSize(), start");const t=()=>{if(!this.host)return;const t=(this.root.clientHeight-54)/this.chains.length;let e=0;for(let n=0;n<this.logos.length;n++){for(const e of this.chains)this.logos[n][e].root.style.height=`${t}px`;e+=Math.max(...this.chains.map((t=>this.logos[n][t].Length)))}if(this.fitWidth){if(this.logos.length>0&&e>0){const t=22,n=13,i=9,s=(this.root.clientWidth-t-(this.logos.length-1)*i-n)/e;for(let t=0;t<this.logos.length;t++)for(const e of this.chains){const n=this.logos[t][e];n.setOptions({[kt.bo.positionWidth]:s-n.positionMarginValue}),n.root.style.width=s*n.Length+"px"}}this.host.style.setProperty("overflow","hidden","important")}else{for(let t=0;t<this.logos.length;t++)for(const e of this.chains)this.logos[t][e].setOptions({[kt.bo.positionWidth]:this.positionWidth});this.host.style.removeProperty("overflow")}0===this.positionWidth?this.host.style.setProperty("overflow-x","hidden","important"):this.host.style.removeProperty("overflow-x")};this.calcSizeRequested||(this.calcSizeRequested=!0,window.setTimeout((()=>{t(),this.calcSizeRequested=!1}),0))}rootOnSizeChanged(t){this.calcSize()}rootOnMouseMove(t){}filterSourceInputOnValueChanged(){const t=`${this.viewerToLog()}.filterSourceInputOnValueChanged()`,e=this.filterSourceInput.value;this.viewSyncer.sync(`${t}`,(async()=>{if(this.filterSource!==e){this.props.getProperty(Wt.filterSource).set(this,e);for(let t=0;t<this.logos.length;t++)for(let e=0;e<this.chains.length;e++){const n=this.chains[e];this.logos[t][n].setOptions({[kt.bo.filterSource]:this.filterSource})}}}))}get onRendered(){return this._onRendered}invalidate(){const t=`${this.viewerToLog()}.invalidate()`;this.viewSyncer.sync(`${t}`,(async()=>{this._onRendered.next()}))}async awaitRendered(t=5e3){await(0,_t.zg)(this.onRendered,(()=>{}),(()=>{this.invalidate()}),t)}}Dt.viewerCounter=-1;var Vt=n(9017),Ut=n(708);async function Zt(t,e,n="Morgan"){const i=tt.Cn.getOrCreate(t),s=t.toList(),o=i.getSplitter(),r=s.length;let a=36;const l=new Map;for(let e=0;e<r;e++){const n=s[e];if(null===s[e]||t.isNone(e)){s[e]=null;continue}s[e]="";const i=o(n);for(let t=0;t<i.length;t++){const n=i[t];l.has(n)||(l.set(n,String.fromCharCode(a)),a++),s[e]+=l.get(n)}}let c={};if(e===Ut.U.MONOMER_CHEMICAL_DISTANCE){const t=Array.from(l.keys()),e=await(0,nt.GR)(t,n);e.scoringMatrix.forEach(((t,n)=>{t.forEach(((t,i)=>{e.scoringMatrix[n][i]=1-t}))}));const i={};Object.entries(e.alphabetIndexes).forEach((([t,e])=>{i[l.get(t)]=e})),c={scoringMatrix:e.scoringMatrix,alphabetIndexes:i}}else if(e===Ut.U.NEEDLEMANN_WUNSCH){const t=Array.from(l.keys()),e=await(0,nt.GR)(t,n),i={};Object.entries(e.alphabetIndexes).forEach((([t,e])=>{i[l.get(t)]=e})),c={scoringMatrix:e.scoringMatrix,alphabetIndexes:i}}return{seqList:s,options:c}}var Yt=n(7983);function $t(t){const e=r.divH([],{style:{gap:"10px"}}),n=r.divV([r.divText(t.seqCol.name),r.divText(t.activityCol.name)]);return n.style.fontWeight="bold",n.style.display="flex",n.style.justifyContent="space-between",e.append(n),t.points.forEach((n=>{const i=r.divText(t.activityCol.get(n).toFixed(2));i.style.display="flex",i.style.justifyContent="left",i.style.paddingLeft="30px",e.append(r.divV([r.divText(t.seqCol.get(n)),i]))})),e}function Kt(t){const e=r.div();e.append(r.divText(t.seqCol.name,{style:{fontWeight:"bold"}}));const n=new Array(2),i=new Array(2);t.points.forEach(((e,s)=>{n[s]=t.seqCol.get(e),i[s]=t.activityCol.get(e)}));const s={},o=tt.Cn.getOrCreate(t.seqCol),a=o.getSplitter(),l=qt(a(n[0]),a(n[1]),o.units,s);return e.append(r.div(l,{style:{width:"300px",overflow:"scroll"}})),e.append(zt(s)),e.append(Xt("Activity delta",Math.abs(i[0]-i[1]))),e.append(Xt("Cliff",t.sali)),e}function Xt(t,e){return r.divH([r.divText(`${t}: `,{style:{fontWeight:"bold",paddingRight:"5px"}}),r.divText(e.toFixed(2))],{style:{paddingTop:"10px"}})}function qt(t,e,n,i){const s=document.createElement("canvas"),o=s.getContext("2d");return s.height=30,Et(o,0,0,0,30,t,e,n,!0,i),s}function zt(t){const e=r.div();if(Object.keys(t).length>0){const n=r.divV([]);n.append(r.divH([r.divText("Pos",{style:{fontWeight:"bold",width:"30px",borderBottom:"1px solid"}}),r.divText("Difference",{style:{fontWeight:"bold",borderBottom:"1px solid"}})]));for(const e of Object.keys(t))t[e].style.borderBottom="1px solid lightgray",n.append(r.divH([r.divText((parseInt(e)+1).toString(),{style:{width:"30px",borderBottom:"1px solid lightgray"}}),t[e]]));e.append(n)}return e}function jt(t,e){const n=a.Column.string("seq_diff",t.rowCount).init((n=>`${t.get(e[0],n)}#${t.get(e[1],n)}`));n.semType="MacromoleculeDifference",n.setTag(a.TAGS.UNITS,t.col(e[0]).getTag(a.TAGS.UNITS)),n.setTag("separator",t.col(e[0]).getTag("separator")),t.columns.add(n);const i=t.plot.grid();return i.col(e[0]).visible=!1,i.col(e[1]).visible=!1,i}class Jt extends a.JsViewer{constructor(t){super(),this.name="",this.metricsProperties=["distanceMetric","fingerprint"],this.fingerprintChoices=["Morgan","Pattern"],this.initialized=!1,this.tags=[a.TAGS.UNITS,"aligned","separator","alphabet"],this.preComputeDistanceMatrix=!1,this.renderPromise=Promise.resolve(),this.fingerprint=this.string("fingerprint",this.fingerprintChoices[0],{choices:this.fingerprintChoices}),this.limit=this.int("limit",10),this.distanceMetric=this.string("distanceMetric",g.kg[0],{choices:g.kg}),this.moleculeColumnName=this.string("moleculeColumnName"),this.name=t}init(){this.initialized=!0}detach(){this.subs.forEach((t=>t.unsubscribe()))}async onTableAttached(){if(this.init(),this.dataFrame){this.preComputeDistanceMatrix=this.dataFrame.rowCount<=22e3,this.subs.push(a.debounce(this.dataFrame.onRowsRemoved,50).subscribe((t=>this.render(!0))));const t="diversity"!==this.name;this.subs.push(a.debounce(this.dataFrame.onCurrentRowChanged,50).subscribe((e=>this.render(t)))),this.subs.push(a.debounce(this.dataFrame.selection.onChanged,50).subscribe((t=>this.render(!1)))),this.subs.push(a.debounce(r.onSizeChanged(this.root),50).subscribe((t=>this.render(!1)))),this.moleculeColumn=this.dataFrame.columns.bySemType(a.SEMTYPE.MACROMOLECULE),this.moleculeColumnName=this.moleculeColumn?.name,this.getProperty("limit").fromOptions({min:1,max:this.dataFrame.rowCount})}this.render()}onPropertyChanged(t){if(super.onPropertyChanged(t),this.initialized){if("moleculeColumnName"===t.name){const e=this.dataFrame.col(t.get(this));e.semType===a.SEMTYPE.MACROMOLECULE&&(this.moleculeColumn=e)}this.render()}}render(t=!0){this.renderPromise=this.renderPromise.then((async()=>{this.computeRequested=this.computeRequested||t,await this.renderInt(t)}))}async renderInt(t){}beforeRender(){return!(!this.initialized||this.dataFrame&&this.moleculeColumnName&&this.dataFrame.col(this.moleculeColumnName).semType!==a.SEMTYPE.MACROMOLECULE&&(o.shell.error(`${this.moleculeColumnName} is not Macromolecule type`),1))}}var Qt=n(7241);const te={gapPenalty:1,matchScore:1,gapSymbol:"-",localAlignment:!1};class ee extends Jt{constructor(){super("similarity"),this.sketchedMolecule="",this.curIdx=0,this.molCol=null,this.idxs=null,this.scores=null,this.gridSelect=!1,this.targetMoleculeIdx=0,this.computeCompleted=new f.Subject,this.distanceMatrixComputed=!1,this.kPrevNeighbors=0,this.cutoff=this.float("cutoff",.01,{min:0,max:1}),this.hotSearch=this.bool("hotSearch",!0),this.similarColumnLabel=this.string("similarColumnLabel",null)}init(){this.hotSearch=!0,this.initialized=!0}async renderInt(t){if(this.beforeRender()&&this.moleculeColumn&&(this.curIdx=-1==this.dataFrame.currentRowIdx?0:this.dataFrame.currentRowIdx,t&&!this.gridSelect)){this.targetMoleculeIdx=-1==this.dataFrame.currentRowIdx?0:this.dataFrame.currentRowIdx;const t=tt.Cn.getOrCreate(this.moleculeColumn);await(t.isHelm()?this.computeByChem():this.computeByMM());const e=null!=this.similarColumnLabel?this.similarColumnLabel:`similar (${this.moleculeColumnName})`;this.molCol=a.Column.string(e,this.idxs.length).init((t=>this.moleculeColumn?.get(this.idxs?.get(t)))),this.molCol.semType=a.SEMTYPE.MACROMOLECULE,this.tags.forEach((t=>this.molCol.setTag(t,this.moleculeColumn.getTag(t))));const n=a.DataFrame.fromColumns([this.idxs,this.molCol,this.scores]);n.onCurrentRowChanged.subscribe((t=>{this.dataFrame.currentRowIdx=n.col("indexes").get(n.currentRowIdx),setTimeout((()=>{this.createPropertyPanel(n)}),1e3),this.gridSelect=!0}));const i=n.plot.grid();i.col("indexes").visible=!1;const s=this.idxs?.getRawData().findIndex((t=>t==this.targetMoleculeIdx));i.cell("score",s).cell.value=null,o.shell.v.grid.root.addEventListener("click",(t=>{this.gridSelect=!1})),(0,at.Y)(this.root,i.root),this.computeCompleted.next(!0)}}async computeByChem(){const t=await(0,Qt.D)(this.moleculeColumn),e=(a.DataFrame.fromColumns([t]),await o.functions.call("Chem:callChemSimilaritySearch",{df:this.dataFrame,col:t,molecule:t.get(this.targetMoleculeIdx),metricName:this.distanceMetric,limit:this.limit,minScore:this.cutoff,fingerprint:this.fingerprint}));this.idxs=e.getCol("indexes"),this.scores=e.getCol("score")}async computeByMM(){const t=this.moleculeColumn.length,e=Math.min(this.limit,t-1);if(!this.knn||this.kPrevNeighbors!==e){const n=(await Zt(this.moleculeColumn,Ut.U.LEVENSHTEIN)).seqList;this.kPrevNeighbors=e,this.knn=await(new F).getKNN(n,Ut.U.LEVENSHTEIN,Math.min(this.limit,t-1))}const n=new Array(e).fill(0).map(((t,e)=>({idx:this.knn.knnIndexes[this.targetMoleculeIdx][e],score:1-this.knn.knnDistances[this.targetMoleculeIdx][e]})));n.sort(((t,e)=>e.score-t.score)),n.unshift({idx:this.targetMoleculeIdx,score:a.FLOAT_NULL}),this.idxs=a.Column.int("indexes",e+1).init((t=>n[t].idx)),this.scores=a.Column.float("score",e+1).init((t=>n[t].score))}createPropertyPanel(t){const e=r.div(),n={},i=this.molCol?.name,s=t.col(i),a=tt.Cn.getOrCreate(s),l=a.getSplitter(),c=l(this.moleculeColumn.get(this.targetMoleculeIdx)),h=l(t.get(i,t.currentRowIdx)),u=function(t,e,n={}){const i={...te,...n},s=t.length,o=e.length,r=Array(s+1).fill(0).map((()=>Array(o+1).fill(0)));let a=-9999,l=[1,1];for(let n=1;n<s+1;n++)for(let s=1;s<o+1;s++)r[n][s]=Math.max(0,r[n-1][s-1]+(t[n-1]===e[s-1]?i.matchScore:-i.matchScore),r[n-1][s]-i.gapPenalty,r[n][s-1]-i.gapPenalty),r[n][s]>=a&&(a=r[n][s],l=[n,s]);let c=i.localAlignment?l[0]:s,h=i.localAlignment?l[1]:o,u=new Array(0),d=new Array(0);for(;c>0&&h>0;){const n=Math.max(r[c-1][h-1],r[c-1][h],r[c][h-1]);r[c][h]==r[c-1][h-1]+i.matchScore&&n==r[c-1][h-1]?(u.push(t[c-1]),d.push(e[h-1]),c-=1,h-=1):r[c][h]==r[c-1][h]-i.gapPenalty?(d.push(i.gapSymbol.valueOf()),u.push(t[c-1]),c-=1):r[c][h]==r[c][h-1]-i.gapPenalty?(u.push(i.gapSymbol.valueOf()),d.push(e[h-1]),h-=1):(u.push(t[c-1]),d.push(e[h-1]),c-=1,h-=1)}u=[...Array.from(t).splice(0,c),...u.reverse(),...i.localAlignment?Array.from(t).splice(l[0],s):[]],d=[...Array.from(e).splice(0,h),...d.reverse(),...i.localAlignment?Array.from(e).splice(l[1],o):[]];const m=c,p=h;return m>p?d=[...new Array(m-p).fill(i.gapSymbol.valueOf()),...d]:u=[...new Array(p-m).fill(i.gapSymbol.valueOf()),...u],d.length>u.length?u.push(...new Array(d.length-u.length).fill(i.gapSymbol.valueOf())):d.push(...new Array(u.length-d.length).fill(i.gapSymbol.valueOf())),{seq1:u.join(""),seq2:d.join(""),seq1Splitted:u,seq2Splitted:d}}(Array.from(c),Array.from(h)),d=qt(u.seq1Splitted,u.seq2Splitted,a.units,n);e.append(r.div(d,{style:{width:"300px",overflow:"scroll"}})),c.length!==h.length&&e.append(r.divV([r.divText("Different sequence length:",{style:{fontWeight:"bold"}}),r.divText(`target: ${c.length} monomers`),r.divText(`selected: ${h.length} monomers`)],{style:{paddingBottom:"10px"}})),e.append(zt(n));const m=r.accordion(),p=r.element("i");p.className="grok-icon svg-icon svg-view-layout",m.addTitle(r.span([p,r.label("Similarity search")])),m.addPane("Differences",(()=>e),!0),o.shell.o=m.root}}var ne=n(279);class ie extends Jt{constructor(){super("diversity"),this.renderMolIds=null,this.columnNames=[],this.computeCompleted=new f.Subject,this.diverseColumnLabel=this.string("diverseColumnLabel",null)}async renderInt(t){if(this.beforeRender()&&this.dataFrame&&t&&this.moleculeColumn){const t=tt.Cn.getOrCreate(this.moleculeColumn);await(t.isFasta()?this.computeByMM():this.computeByChem());const e=null!=this.diverseColumnLabel?this.diverseColumnLabel:`diverse (${this.moleculeColumnName})`,n=a.Column.string(e,this.renderMolIds.length).init((t=>this.moleculeColumn?.get(this.renderMolIds[t])));n.semType=a.SEMTYPE.MACROMOLECULE,this.tags.forEach((t=>n.setTag(t,this.moleculeColumn.getTag(t))));const i=a.DataFrame.fromColumns([n]);i.onCurrentRowChanged.subscribe((t=>{this.dataFrame.currentRowIdx=this.renderMolIds[i.currentRowIdx]})),(0,at.Y)(this.root,i.plot.grid().root),this.computeCompleted.next(!0)}}async computeByChem(){const t=await(0,Qt.D)(this.moleculeColumn);a.DataFrame.fromColumns([t]),this.renderMolIds=await o.functions.call("Chem:callChemDiversitySearch",{col:t,metricName:this.distanceMetric,limit:this.limit,fingerprint:this.fingerprint})}async computeByMM(){const t=(await Zt(this.moleculeColumn,Ut.U.LEVENSHTEIN)).seqList,e=new G.m(!0,!1),n=await e.calc(t,Ut.U.LEVENSHTEIN);e.terminate();const i=this.moleculeColumn.length,s=(0,P.y)(i);this.renderMolIds=(0,ne.L)(i,Math.min(i,this.limit),((t,e)=>this.moleculeColumn.isNone(t)||this.moleculeColumn.isNone(e)?0:n[s(t,e)]))}}var se,oe=n(4004),re=n(9943),ae=n(6099),le=n(2918),ce=function(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class he{constructor(t,e,n=!1,i){var s;this.name="",this.description="",this._isAutomatic=!1,this._autoStartFirstStep=!1,this._currentStep=0,this._isStopped=!1,this._isCancelled=!1,this._isStepProcessed=!1,this._root=r.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._steps=[],this._mainHeader=r.panel([],"tutorials-main-header"),this._header=r.h2(""),this._headerDiv=r.divH([],"tutorials-root-header"),this._stopStartBtn=r.button(r.iconFA("pause"),(()=>this._changeStopState()),"Play / pause"),this._restartBtn=r.button(r.iconFA("redo"),(()=>this._restartScript()),"Restart"),this._nextStepBtn=r.button(r.iconFA("play"),(()=>{this._isStepProcessed||this._nextStep()}),"Next step"),this._activity=r.panel([],"tutorials-root-description"),this._progressDiv=r.divV([],"tutorials-root-progress"),this._progress=r.element("progress"),this._progressSteps=r.divText(""),this._closeBtn=r.button(r.iconFA("chevron-left"),(()=>this._closeDock()),"Back to demo"),this.name=t,this.description=e,this._isAutomatic=n,this._autoStartFirstStep=null!==(s=null==i?void 0:i.autoStartFirstStep)&&void 0!==s&&s,this._progress.max=0,this._progress.value=1,he.currentObject=this}get steps(){return this._steps}get stepNumber(){return this._steps.length}_addHeader(){this._createHeaderDiv(),this._createProgressDiv(),this._mainHeader.append(this._headerDiv,this._progressDiv)}_createHeaderDiv(){this._header.innerText=this.name,this._headerDiv.append(this._closeBtn),this._headerDiv.append(this._header),this._nextStepBtn.firstChild.className="grok-icon fas fa-play",this._headerDiv.append(this._isAutomatic?this._stopStartBtn:this._nextStepBtn)}_createProgressDiv(){this._progress.max=this.stepNumber,this._progressDiv.append(this._progress),this._progressSteps=r.divText(`Step: ${this._progress.value} of ${this.stepNumber}`),this._progressDiv.append(this._progressSteps)}_addDescription(){var t;this._activity.append(r.div(this.description,"tutorials-root-description"));for(let e=0;e<this.stepNumber;e++){let n=r.iconFA("clock");this._isAutomatic||0===e&&(n=r.iconFA("play",(()=>this._nextStep()),"Next step"),n.className="grok-icon fas fa-play");const i=r.div(this._steps[e].name,"grok-tutorial-entry-instruction"),s=r.div(null===(t=this._steps[e].options)||void 0===t?void 0:t.description,"grok-tutorial-step-description hidden"),o=r.divH([n,i],"grok-tutorial-entry");this._activity.append(o,s)}}_initRoot(){var t,e,n;o.shell.windows.showContextPanel=!0,o.shell.windows.showHelp=!1;const i=Array.from(o.shell.dockManager.rootNode.children)[0];this._node=o.shell.dockManager.dock(this._root,a.DOCK_TYPE.FILL,i,""),(null===(e=null===(t=i.parent.container.containerElement.firstElementChild)||void 0===t?void 0:t.lastElementChild)||void 0===e?void 0:e.classList.contains("tab-handle-list-container"))&&(null===(n=i.parent.container.containerElement.firstElementChild)||void 0===n||n.lastElementChild.remove()),this._node.container.containerElement.classList.add("tutorials-demo-script-container"),this._addHeader(),this._root.append(this._mainHeader),this._addDescription(),this._root.append(this._activity)}_nextStep(){var t,e;return ce(this,void 0,void 0,(function*(){this._isStepProcessed=!0,this._isAutomatic||(this._nextStepBtn.classList.add("disabled"),this._nextStepBtn.firstChild.classList.add("fa-disabled"));const n=this._activity.getElementsByClassName("grok-tutorial-entry")[this._currentStep],i=this._activity.getElementsByClassName("grok-icon")[this._currentStep],s=this._activity.getElementsByClassName("grok-tutorial-step-description")[this._currentStep];i.className="grok-icon far fa-spinner-third fa-spin",s.classList.remove("hidden"),s.classList.add("visible");const o=n,a=(null===(t=this._steps[this._currentStep].options)||void 0===t?void 0:t.delay)?null===(e=this._steps[this._currentStep].options)||void 0===e?void 0:e.delay:2e3;yield this._steps[this._currentStep].func(),this._scrollTo(this._root,o.offsetTop-this._mainHeader.offsetHeight),this._isAutomatic&&(yield this._countdown(n,i,a),yield(0,_t.gw)(a));const l=r.iconFA("check");if(i.replaceWith(l),l.className="grok-icon far fa-check",this._progress.value++,this._progressSteps.innerText=`Step: ${this._progress.value} of ${this.stepNumber}`,this._currentStep++,this._isStepProcessed=!1,this._currentStep!==this.stepNumber){if(!this._isAutomatic){const t=this._activity.getElementsByClassName("grok-icon")[this._currentStep],e=r.iconFA("play",(()=>this._nextStep()),"Next step");e.className="grok-icon fas fa-play",t.replaceWith(e),this._nextStepBtn.classList.remove("disabled"),this._nextStepBtn.firstChild.classList.remove("fa-disabled")}}else this._isAutomatic?this._stopStartBtn.replaceWith(this._restartBtn):this._nextStepBtn.replaceWith(this._restartBtn)}))}_startScript(){return ce(this,void 0,void 0,(function*(){for(let t=this._currentStep;t<this.stepNumber&&!this._isStopped&&!this._isCancelled;t++)yield this._nextStep()}))}_scrollTo(t,e){t.focus(),t.scrollTop=e}_countdown(t,e,n){return ce(this,void 0,void 0,(function*(){const i=r.div([],"demo-script-countdown");e.classList.add("hidden");let s=n/1e3;const o=this._createSVGIndicator(s);i.append(o),t.prepend(i);const a=setInterval((()=>{s--,0===s&&(clearInterval(a),i.remove(),e.classList.remove("hidden"),e.classList.add("visible"))}),1e3)}))}_createSVGIndicator(t){const e=document.createElementNS("http://www.w3.org/2000/svg","svg"),n=document.createElementNS("http://www.w3.org/2000/svg","circle");return n.setAttributeNS(null,"cx","7"),n.setAttributeNS(null,"cy","7"),n.setAttributeNS(null,"r","6"),n.setAttributeNS(null,"style",`animation: countdown ${t}s linear infinite forwards`),e.append(n),e}_changeStopState(){const t=this._stopStartBtn.getElementsByClassName("grok-icon");t[0].className="grok-icon fas fa-play",this._isStopped=!this._isStopped,this._isStopped||(t[0].className="grok-icon fal fa-pause",this._isStepProcessed||this._startScript())}_restartScript(){o.shell.dockManager.close(this._node),o.shell.closeAll(),this._clearRoot(),this._setInitParams(),this.start()}_clearRoot(){this._root=r.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._mainHeader=r.panel([],"tutorials-main-header"),this._header=r.h2(""),this._headerDiv=r.divH([],"tutorials-root-header"),this._activity=r.panel([],"tutorials-root-description"),this._progressDiv=r.divV([],"tutorials-root-progress"),this._progress=r.element("progress"),this._progressSteps=r.divText(""),this._progress.max=0,this._progress.value=1}_setInitParams(){this._currentStep=0,this._isStopped=!1,this._isCancelled=!1,this._stopStartBtn.getElementsByClassName("grok-icon")[0].className="grok-icon fal fa-pause",this._nextStepBtn.classList.remove("disabled")}_closeDock(){o.shell.dockManager.close(this._node),this.cancelScript()}cancelScript(){this._isCancelled=!0,he.currentObject=null}step(t,e,n){return this._steps[this.steps.length]={name:t,func:e,options:n},this}start(){return ce(this,void 0,void 0,(function*(){this._initRoot(),o.shell.newView(this.name),this._isAutomatic?this._startScript():this._autoStartFirstStep&&(yield this._nextStep())}))}}function ue(t){const e=t instanceof Error?t.message:t.toString(),n=t instanceof Error?t.stack:void 0;o.shell.error(e),fn.logger.error(t.message,void 0,n)}he.currentObject=null,function(t){t.X="Embed_X",t.Y="Embed_Y"}(se||(se={}));const de="data/sample_FASTA_PT_activity.csv";async function me(){const t="Dendrogram",e=a.Func.find({package:t,name:"getTreeHelper"});if(0===e.length)throw new Error(`Package "${t}" must be installed for TreeHelper.`);return(await e[0].prepare().call()).getOutputParamValue()}async function pe(){return await o.functions.call("Dendrogram:getDendrogramService",{})}var ge=function(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function fe(t,e,i){return ge(this,void 0,void 0,(function*(){return new Promise((function(s,o){const r=new Worker(new URL(n.p+n.u(356),n.b));r.postMessage({distMatArray:t,n:e,methodCode:i}),r.onmessage=({data:{error:t,clusterMatrix:e}})=>{r.terminate(),t?o(t):s(e)}}))}))}var ye=function(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};n(7905);const be="data/sample_FASTA_PT_activity.csv",Ce="sequence";var we=n(3336),ve=n.n(we);const Se="data/sample_FASTA_PT_activity.csv";var Ae=n(8341);const xe="samples/HELM.csv";var Te=n(2568),Ie=n(525);class Me{constructor(t,e,n={}){this.urlParams=t,this.funcName=e,this.options=n}async init(t){this.df=t,await this.buildView()}async buildView(){const t=ct()(this.urlParams.entries()).map((([t,e])=>`${t}=${encodeURIComponent(e)}`)).toArray().join("&");this.view=o.shell.addTableView(this.df),this.view.path=this.view.basePath=`func/${fn.name}.${this.funcName}?${t}`;const e={...this.options,sequenceColumnName:"sequence"};for(const[t,n]of this.urlParams.entries())switch(t){case kt.bo.fixWidth:case kt.bo.fitArea:e[t]=["1","on","true"].includes(n.toLowerCase());break;default:e[t]=n}const n=await this.view.dataFrame.plot.fromType("WebLogo",e);this.view.dockManager.dock(n,a.DOCK_TYPE.DOWN,null,"WebLogo",.35)}}class Le{get funcParams(){return{table:this.tableInput.value,sequence:this.seqColInput.value}}get paramsUI(){return this.funcParamsDiv}constructor(){this.tableInput=r.tableInput("Table",o.shell.tv.dataFrame,void 0,(()=>{this.onTableInputChanged()}));const t=this.tableInput.value.columns.bySemType(a.SEMTYPE.MACROMOLECULE),e={filter:t=>t.semType===a.SEMTYPE.MACROMOLECULE};this.seqColInput=r.columnInput("Sequence",this.tableInput.value,t,null,e),this.funcParamsDiv=r.inputs([this.tableInput,this.seqColInput],{style:{minWidth:"320px"}})}onTableInputChanged(){this.seqColInput=r.columnInput("Sequence",this.tableInput.value,this.tableInput.value.columns.bySemType(a.SEMTYPE.MACROMOLECULE))}}var Ee=n(9416);class Ne{constructor(t){this.monomerLib=t}getCappedRotatedMonomer(t,e){const n=this.monomerLib.getMonomer(t,e);return n?n.molfile:null}}const Re=new class{constructor(){this.tooltipHandlerTemp="tooltip-handler.Monomer"}},_e={autoCrop:!0,autoCropMargin:0,suppressChiralText:!0};class Oe{constructor(t){this.gridCol=t,this.gridCol.grid.onCellTooltip(this.onCellTooltip.bind(this))}onCellTooltip(t,e,n){if(t.grid.dart!=this.gridCol.grid.dart||t.gridColumn.dart!=this.gridCol.dart||!t.tableColumn||!t.isTableCell)return!1;const i=t.tableColumn.getTag("alphabet"),s=t.cell.value,a="DNA"===i||"RNA"===i?"RNA":"PEPTIDE",l=new Ne(yn().getBioLib()).getCappedRotatedMonomer(a,s),c=r.div(s),h=l?o.chem.svgMol(l,void 0,void 0,_e):null,u=t.grid.canvas.getBoundingClientRect(),d=t.bounds.right+u.left-4,m=t.bounds.bottom+u.top-4;return r.tooltip.show(r.divV([c,...h?[h]:[]]),d,m),!0}static getOrCreate(t){let e=t.temp[Re.tooltipHandlerTemp];return e||(e=t.temp[Re.tooltipHandlerTemp]=new Oe(t)),e}}class Pe extends a.GridCellRenderer{get name(){return St.Of.MONOMER}get cellType(){return St.Of.MONOMER}get defaultHeight(){return 15}get defaultWidth(){return 40}render(t,e,n,i,s,o,r){if(o.gridRow<0)return;Oe.getOrCreate(o.gridColumn),t.font="12px monospace",t.textBaseline="middle",t.textAlign="center";const a=(0,Ct.py)(o.cell.column.getTag("alphabet")),l=o.cell.value;if(!l)return;const c=a.get(l);t.fillStyle=c,t.fillText((0,Ct.GU)(l,6),e+i/2,n+s/2,i)}}class Ge extends Map{get onPropertyChanged(){return this._onPropertyChanged}get MaxMonomerLength(){return super.get("MaxMonomerLength")}set MaxMonomerLength(t){super.set("MaxMonomerLength",t),this._onPropertyChanged.next("MaxMonomerLength")}get TooltipWebLogo(){return super.get("TooltipWebLogo")}set TooltipWebLogo(t){super.set("TooltipWebLogo",t),this._onPropertyChanged.next("TooltipWebLogo")}get DefaultSeparator(){return super.get("DefaultSeparator")}set DefaultSeparator(t){if(1!==t.length)throw new Error("The separator must be of length one.");super.set("DefaultSeparator",t),this._onPropertyChanged.next("DefaultSeparator")}constructor(t){super(Object.entries(t)),this._onPropertyChanged=new f.Subject}}class ke extends a.Package{constructor(){super(...arguments),this._initialized=!1}get properties(){return this._properties}set properties(t){this._properties=t}get initialized(){return this._initialized}completeInit(){this._initialized=!0}handleErrorUI(t){const[e,n]=(0,rt.yf)(t);o.shell.error(e),this.logger.error(e,void 0,n)}}var Fe=n(8770);class Be extends a.Widget{constructor(t){super(r.divV([])),this.viewed=!1,this.seqCol=t}async init(){const t=tt.Cn.getOrCreate(this.seqCol),e=fn.properties.TooltipWebLogo,n=this.seqCol.getTag(Ot.DX.tooltipWebLogo);!1===e||["false","off","disable","disabled"].includes(n)||(this.wlViewer=await this.seqCol.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:this.seqCol.name,backgroundColor:0,positionHeight:"Entropy",positionWidth:t.getAlphabetIsMultichar()?24:16,fixWidth:!0,fitArea:!1}),this.wlViewer.root.style.height="50px",this.root.appendChild(this.wlViewer.root),this.root.style.width="100%")}detach(){this.wlViewer.detach(),super.detach()}}var We=n(9953);function He(t){t.setTag("quality",a.SEMTYPE.MACROMOLECULE),t.setTag("aligned","SEQ"),t.setTag("alphabet","PT")}var De=n(922);async function Ve(t,e){const n=new Ue(e,t),i=await n.convertToRdKitBeautifiedMolfileColumn();return i.semType=a.SEMTYPE.MOLECULE,i}class Ue{constructor(t,e){this.helmColumn=t,this.df=e,this.helmColumn=t}async convertToSmiles(){const t=await this.getSmilesList(),e=this.df.columns.getUnusedName(`smiles(${this.helmColumn.name})`);return a.Column.fromStrings(e,t.map((t=>null===t?"":t)))}async getSmilesList(){return(await this.convertToMolfileV2KColumn()).toList().map((t=>a.chem.convert(t,a.chem.Notation.MolBlock,a.chem.Notation.Smiles)))}async convertToRdKitBeautifiedMolfileColumn(){const t=await this.getSmilesList(),e=await o.functions.call("Chem:getRdKitModule"),n=t.map((t=>{if(""===t)return null;const n=e.get_mol(t);return n?(n.normalize_depiction(1),n.straighten_depiction(!0),n):null})),i=this.df.columns.getUnusedName(`molfile(${this.helmColumn.name})`);return a.Column.fromStrings(i,n.map((t=>null===t?"":t.get_molblock())))}async convertToMolfileV2KColumn(){const t=(await this.getPolymerGraphColumn()).toList().map(((t,e)=>{const n=this.helmColumn.get(e);if(!n)return"";let i="";try{i=this.getPolymerMolfile(n,t)}catch(t){const[e,n]=(0,rt.yf)(t);fn.logger.error(e,void 0,n)}finally{return i}})),e=this.df.columns.getUnusedName(`molfileV2K(${this.helmColumn.name})`);return a.Column.fromList("string",e,t)}async getPolymerGraphColumn(){return await o.functions.call("HELM:getMolfiles",{col:this.helmColumn})}getPolymerMolfile(t,e){const n=new Ze(e),i=new Qe(t);return n.monomerSymbols.forEach(((t,e)=>{const s=n.getMonomerShifts(e);i.addMonomer(t,e,s)})),i.compileToMolfile()}}class Ze{constructor(t){this.molfileHandler=De._.getInstance(t)}get monomerSymbols(){return this.molfileHandler.atomTypes}getMonomerShifts(t){return{x:this.molfileHandler.x[t],y:this.molfileHandler.y[t]}}}class Ye{constructor(t,e){this.capGroupElements=[];const n=le.NT.instance.getBioLib().getMonomer(e,t);if(!n)throw new Error(`Monomer ${t} is not found in the library`);this.molfileWrapper=new qe(n.molfile,t),this.capGroupElements=n.rgroups.map((t=>(t.capGroupSmiles||t.capGroupSMILES).replace(/(\[|\]|\*|:|\d)/g,"")))}shiftCoordinates(t){this.molfileWrapper.shiftCoordinates(t)}getAtomLines(){return this.molfileWrapper.getAtomLines()}getBondLines(){return this.molfileWrapper.getBondLines()}removeBondedRGroups(t){this.molfileWrapper.removeRGroups(t)}capTrailingRGroups(){this.molfileWrapper.capRGroups(this.capGroupElements)}replaceRGroupWithAttachmentAtom(t,e){this.molfileWrapper.replaceRGroupWithAttachmentAtom(t,e)}getAttachmentAtomByRGroupId(t){return this.molfileWrapper.getAttachmentAtomByRGroupId(t)}deleteBondLineWithSpecifiedRGroup(t){this.molfileWrapper.deleteBondLineWithSpecifiedRGroup(t)}shiftBonds(t){this.molfileWrapper.shiftBonds(t)}}class $e{constructor(t,e,n){this.atoms=e,this.bonds=n,this.rGroupBondPositionMap=new Map,this.rGroupIdToAtomicIndexMap=this.getRGroupIdToAtomicIdxMap(t)}getAtomicIdx(t){const e=this.rGroupIdToAtomicIndexMap.get(t);return void 0===e?null:e}removeRGroupsFromAtomBlock(t){t.forEach((t=>{if(void 0===this.rGroupIdToAtomicIndexMap.get(t))throw new Error(`Cannot find atomic index for R group ${t}`)}));const e=Array.from(this.rGroupIdToAtomicIndexMap.entries()).filter((([e,n])=>t.includes(e))).map((([t,e])=>e));this.atoms.deleteAtoms(e)}removeRGroups(t){this.removeRGroupsFromAtomBlock(t),t.forEach((t=>{const e=this.replaceRGroupInBondsByDummy(t);this.rGroupBondPositionMap.set(t,e)}))}replaceRGroupInBondsByDummy(t){const e=this.rGroupIdToAtomicIndexMap.get(t);if(this.rGroupBondPositionMap.has(t))throw new Error(`R group ${t} is already handled`);const n=this.bonds.getPositionsInBonds(e+1);if(0===n.length)throw new Error(`Cannot find position for R group ${t}`);if(n.length>1)throw new Error(`More than one position for R group ${t}`);const i=n[0];return this.bonds.replacePositionsInBondsByDummy([i]),this.bonds.removeAtomIdFromBonds(e+1),this.removeRGroupFromAtomicIdxMap(t,e),i}removeRGroupFromAtomicIdxMap(t,e){this.rGroupIdToAtomicIndexMap.delete(t);for(const[t,n]of this.rGroupIdToAtomicIndexMap)n>e&&this.rGroupIdToAtomicIndexMap.set(t,n-1)}getRGroupIdToAtomicIdxMap(t){const e=new Map;t.filter((t=>t.startsWith("M RGP"))).forEach((t=>{const n=function(t){const e=t.split(/\s+/).filter((t=>t)).slice(3).map((t=>parseInt(t))),n=new Array(e.length/2);for(let t=0;t<e.length;t+=2)n[t/2]=[e[t+1],e[t]-1];return n}(t);for(const[t,i]of n){if(e.has(t))throw new Error(`R group ${t} is already in the map`);e.set(t,i)}}));const n=t.map(((t,e)=>{if(t.startsWith("A "))return e})).filter((t=>void 0!==t)),i=n.map((e=>t[e])),s=n.map((e=>t[e+1]));i.forEach(((t,n)=>{const i=parseInt(t.split(/\s+/)[1])-1,o=parseInt(s[n].substring(1));if(e.has(o))throw new Error(`R group ${o} is already in the map`);e.set(o,i)}));const o=this.atoms.getRGroupAtomicIndices().filter((t=>!Array.from(e.values()).includes(t)));if(0!==o.length)throw new Error(`Unaccounted R group indices: ${o}`);return e}deleteBondLineWithSpecifiedRGroup(t){const e=this.rGroupBondPositionMap.get(t);if(!e)throw new Error(`Cannot find position for R group ${t}`);const{bondLineIdx:n}=e;this.bonds.deleteBondLines([n]),this.rGroupBondPositionMap.delete(t),this.rGroupIdToAtomicIndexMap.delete(t),this.rGroupBondPositionMap.forEach((t=>{t.bondLineIdx>n&&(t.bondLineIdx-=1)}))}replaceRGroupWithAttachmentAtom(t,e){const n=this.rGroupBondPositionMap.get(t);if(!n)throw new Error(`Cannot find position for R group ${t}`);const{bondLineIdx:i,nodeIdx:s}=n;this.bonds.bondedAtoms[i][s]=e}getAttachmentAtomIdByRGroupId(t){const e=this.rGroupBondPositionMap.get(t);if(!e)throw new Error(`Cannot find position for R group ${t}`);const{bondLineIdx:n,nodeIdx:i}=e;return this.bonds.bondedAtoms[n][(i+1)%2]}capRGroups(t){this.rGroupIdToAtomicIndexMap.forEach(((e,n)=>{const i=t[n-1];"H"===i?(this.removeRGroups([n]),this.deleteBondLineWithSpecifiedRGroup(n)):this.atoms.replaceElementSymbol(e,i)}))}}class Ke{constructor(t){this.bondedPairs=[],this.rawBondLines=[],this.rawBondLines=t,this.bondedPairs=this.rawBondLines.map((t=>[parseInt(t.substring(0,3)),parseInt(t.substring(3,6))]))}getBondLines(){return this.bondedPairs.map(((t,e)=>{if(t.some((t=>-1===t)))throw new Error(`Bonded pair ${t} contains -1`);return`${t[0].toString().padStart(3," ")}${t[1].toString().padStart(3," ")}${this.rawBondLines[e].substring(6)}`}))}get bondedAtoms(){return this.bondedPairs}deleteBondLines(t){this.rawBondLines=this.rawBondLines.filter(((e,n)=>!t.includes(n))),this.bondedPairs=this.bondedPairs.filter(((e,n)=>!t.includes(n)))}getPositionsInBonds(t){const e=[];return this.bondedPairs.forEach(((n,i)=>{n.forEach(((n,s)=>{n===t&&e.push({bondLineIdx:i,nodeIdx:s})}))})),e}replacePositionsInBondsByDummy(t,e){void 0===e&&(e=-1),t.forEach((t=>{const{bondLineIdx:n,nodeIdx:i}=t;this.bondedPairs[n][i]=e}))}removeAtomIdFromBonds(t){this.bondedPairs=this.bondedPairs.map((e=>e.map((e=>e>t?e-1:e))))}shift(t){this.bondedPairs=this.bondedPairs.map((e=>e.map((e=>e+t))))}}class Xe{constructor(t){this.coordinates=[],this.rawAtomLines=[],this.rawAtomLines=t,this.coordinates=this.rawAtomLines.map((t=>({x:parseFloat(t.substring(0,10)),y:parseFloat(t.substring(10,20))})))}get atomCoordinates(){return this.coordinates}get atomLines(){return this.rawAtomLines.map(((t,e)=>{const n=this.coordinates[e];return`${n.x.toFixed(4).padStart(10," ")}${n.y.toFixed(4).padStart(10," ")}${t.substring(20)}`}))}replaceElementSymbol(t,e){this.rawAtomLines[t]=this.rawAtomLines[t].replace("R#",e)}deleteAtoms(t){this.coordinates=this.coordinates.filter(((e,n)=>!t.includes(n))),this.rawAtomLines=this.rawAtomLines.filter(((e,n)=>!t.includes(n)))}shift(t){this.coordinates=this.coordinates.map((e=>{const n=e.x+t.x,i=e.y+t.y;if(isNaN(n)||isNaN(i))throw new Error(`Cannot shift coordinates by ${t.x}, ${t.y}`);return{x:n,y:i}}))}rotate(t){this.coordinates=this.coordinates.map((e=>{const n=e.x,i=e.y,s=n*Math.cos(t)-i*Math.sin(t),o=n*Math.sin(t)+i*Math.cos(t);if(isNaN(s)||isNaN(o))throw new Error(`Cannot rotate coordinates by ${t}`);return{x:s,y:o}}))}getRGroupAtomicIndices(){return this.rawAtomLines.map(((t,e)=>{if(t.includes("R#"))return e})).filter((t=>void 0!==t))}}class qe{constructor(t,e){this.monomerSymbol=e;const n=t.split("\n"),i=parseInt(n[3].substring(0,3)),s=parseInt(n[3].substring(3,6)),o=n.slice(4,4+i);this.atoms=new Xe(o);const r=n.slice(4+i,4+i+s);this.bonds=new Ke(r),this.rGroups=new $e(n,this.atoms,this.bonds),this.shiftMonomerToDefaultPosition()}deleteBondLineWithSpecifiedRGroup(t){this.rGroups.deleteBondLineWithSpecifiedRGroup(t)}shiftCoordinates(t){this.atoms.shift(t)}rotateCoordinates(t){this.atoms.rotate(t)}getBondLines(){return this.bonds.getBondLines()}getAtomLines(){return this.atoms.atomLines}removeRGroups(t){this.rGroups.removeRGroups(t)}replaceRGroupWithAttachmentAtom(t,e){this.rGroups.replaceRGroupWithAttachmentAtom(t,e)}getAttachmentAtomByRGroupId(t){return this.rGroups.getAttachmentAtomIdByRGroupId(t)}shiftR1GroupToOrigin(){const t=this.rGroups.getAtomicIdx(1);if(null===t)throw new Error(`Cannot find R1 group for monomer ${this.monomerSymbol}`);const{x:e,y:n}=this.atoms.atomCoordinates[t];this.atoms.shift({x:-e,y:-n})}alignR2AlongX(){const t=this.rGroups.getAtomicIdx(2);if(null===t)throw new Error(`Cannot find R2 group for monomer ${this.monomerSymbol}`);const e=this.atoms.atomCoordinates[t],n=e.y/e.x,i=Math.atan(n);if(isNaN(i))throw new Error(`Cannot calculate angle for R2 group for monomer ${this.monomerSymbol}`);this.rotateCoordinates(-i)}shiftMonomerToDefaultPosition(){this.shiftR1GroupToOrigin(),null!==this.rGroups.getAtomicIdx(2)&&this.alignR2AlongX()}shiftBonds(t){this.bonds.shift(t)}capRGroups(t){this.rGroups.capRGroups(t)}}class ze{constructor(t){this.simplePolymer=t,this.polymerType=this.getPolymerType(),this.idx=this.getIdx();const{monomers:e,monomerTypes:n}=this.getMonomerSymbolsAndTypes();this.monomers=e,this.monomerTypes=n}get id(){return this.polymerType+this.idx.toString()}getPolymerType(){const t=new RegExp("(PEPTIDE|RNA)[0-9]+{"),e=this.simplePolymer.match(t);if(!e)throw new Error(`Unsupported polymer type in ${this.simplePolymer}`);return e[1]}getIdx(){const t=new RegExp(`${this.polymerType}([0-9]+){`),e=this.simplePolymer.match(t);if(!e)throw new Error(`Cannot parse simple polymer id from ${this.simplePolymer}`);return parseInt(e[1])}getMonomerSymbolsAndTypes(){const t=new RegExp(`${this.polymerType}${this.idx}{|}`,"g"),e=this.simplePolymer.replace(t,"").split("."),n=[],i=[];return e.forEach((t=>{const e=t.split(/\(|\)/).map((t=>t.replace(/[\[\]]/g,"")));n.push(...e);const s=e.map(((t,e)=>e%2==0?0:1));i.push(...s)})),{monomers:n,monomerTypes:i}}getBondData(){const t=[],e=this.monomerTypes.map(((t,e)=>{if(0===t)return e})).filter((t=>void 0!==t)),n=this.monomerTypes.map(((t,e)=>{if(1===t)return e})).filter((t=>void 0!==t));for(let n=0;n<e.length-1;n++){const i=e[n],s=e[n+1];t.push([{monomerIdx:i,rGroupId:2},{monomerIdx:s,rGroupId:1}])}for(let e=0;e<n.length;e++){const i=n[e],s=i-1;t.push([{monomerIdx:s,rGroupId:3},{monomerIdx:i,rGroupId:1}])}return t}}class je{constructor(t){const e=t.split("|");e.forEach((t=>this.validateConnectionItem(t))),this.connectionItems=e}validateConnectionItem(t){const e="(PEPTIDE|RNA)",n=new RegExp(`${e}[0-9]+,${e}[0-9]+,[0-9]+:R[0-9]+-[0-9]+:R[0-9]+`,"g");if(!t.match(n))throw new Error(`Cannot parse connection item from ${t}`)}getConnectionData(){const t=[];return this.connectionItems.forEach((e=>{const n=[],i=e.split(",");i[2].split("-").forEach(((t,e)=>{const s=i[e],o=t.split(":"),r={monomerIdx:parseInt(o[0])-1,rGroupId:parseInt(o[1].slice(1))};n.push({polymerId:s,bond:r})})),t.push(n)})),t}}class Je{constructor(t){this.helm=t;const e=this.helm.split("$"),n=e[0].split("|");this.simplePolymers=n.map((t=>new ze(t))),""!==e[1]&&(this.connectionList=new je(e[1])),this.bondData=this.getBondData()}toString(){return this.helm}getPolymerTypeByMonomerIdx(t){return this.getSimplePolymerByMonomerIdx(t).polymerType}getSimplePolymerByMonomerIdx(t){const e=this.getMonomerIdxShifts(),n=Object.values(e).sort(((t,e)=>t-e)).find((e=>t>=e));if(void 0===n)throw new Error(`Cannot find simple polymer for monomer ${t}`);const i=Object.keys(e).find((t=>e[t]===n));return this.simplePolymers.find((t=>t.id===i))}shiftBondMonomerIds(t,e){e.forEach((e=>{e.forEach((e=>{e.monomerIdx+=t}))}))}getMonomerIdxShifts(){const t={};let e=0;return this.simplePolymers.forEach((n=>{t[n.id]=e,e+=n.monomers.length})),t}getBondData(){const t=this.getMonomerIdxShifts(),e=[];return this.simplePolymers.forEach((n=>{const i=n.getBondData(),s=t[n.id];this.shiftBondMonomerIds(s,i),e.push(...i)})),this.connectionList&&this.connectionList.getConnectionData().forEach((n=>{const i=[];n.forEach((e=>{const n=t[e.polymerId],s=e.bond;s.monomerIdx+=n,i.push(s)})),e.push(i)})),e}}class Qe{constructor(t){this.monomerWrappers=[],this.helm=new Je(t),this.bondedRGroupsMap=new Map,this.helm.bondData.forEach((t=>{t.forEach((t=>{const e=t.monomerIdx,n=t.rGroupId;this.bondedRGroupsMap.get(e)||this.bondedRGroupsMap.set(e,[]),this.bondedRGroupsMap.get(e).push(n)}))}))}addMonomer(t,e,n){const i=this.helm.getPolymerTypeByMonomerIdx(e),s=new Ye(t,i);s.shiftCoordinates(n),this.monomerWrappers.push(s)}removeRGroups(){this.monomerWrappers.forEach(((t,e)=>{this.bondedRGroupsMap.has(e)&&t.removeBondedRGroups(this.bondedRGroupsMap.get(e)),t.capTrailingRGroups()}))}getAtomNumberShifts(){const t=[];let e=0;return this.monomerWrappers.forEach((n=>{t.push(e),e+=n.getAtomLines().length})),t}restoreBondsBetweenMonomers(){this.helm.bondData.forEach((t=>{const e=t.map((t=>t.monomerIdx)),n=t.map((t=>t.rGroupId)),i=e.map((t=>this.monomerWrappers[t])),s=i[1].getAttachmentAtomByRGroupId(n[1]);i[0].replaceRGroupWithAttachmentAtom(n[0],s),i[1].deleteBondLineWithSpecifiedRGroup(n[1])}))}compileToMolfile(){const t=[],e=[];this.removeRGroups();const n=this.getAtomNumberShifts();this.monomerWrappers.forEach(((t,e)=>{t.shiftBonds(n[e])})),this.restoreBondsBetweenMonomers(),this.monomerWrappers.forEach((n=>{t.push(...n.getAtomLines()),e.push(...n.getBondLines())}));const i=t.length;if(i>999)throw new Error(`Atom count in polymer ${this.helm.toString()} is ${i} and exceeds 999`);const s=e.length;return["\nDatagrok\n",`${i.toString().padStart(3," ")}${s.toString().padStart(3," ")} 0 0 1 0 0 V2000`,t.join("\n"),e.join("\n"),"M END\n"].join("\n")}}class tn{constructor(t,e){this.helmColumn=t,this.leftTerminal=e.leftTerminal,this.rightTerminal=e.rightTerminal}transform(){return this.helmColumn.toList().map((t=>this.hasTerminals(t)?this.getTransformedHelm(t):t))}}class en extends tn{constructor(t,e){super(t,e)}hasTerminals(t){return this.getLinkedPositions(t).every((t=>t>0))}getLinkedPositions(t){return[1,t.replace("PEPTIDE1{","").replace("}$$$$","").split(".").findIndex(((t,e)=>t===this.rightTerminal&&e>0))+1]}getTransformedHelm(t){const e=this.getLinkedPositions(t);return an(t,{monomerPosition:e[0],attachmentPoint:1},{monomerPosition:e[1],attachmentPoint:3})}}class nn extends tn{constructor(t,e){super(t,e)}hasTerminals(t){return this.leftTerminal===We.M||this.rightTerminal===We.M||t.includes("PEPTIDE1{"+this.leftTerminal)&&t.includes(this.rightTerminal+"}$$$$")}getLinkedPositions(t){return[1,rn(t)]}getTransformedHelm(t){const e=this.getLinkedPositions(t);return an(t,{monomerPosition:e[0],attachmentPoint:1},{monomerPosition:e[1],attachmentPoint:2})}}class sn extends tn{constructor(t,e){super(t,e)}hasTerminals(t){return this.leftTerminal===We.M||this.rightTerminal===We.M||this.getLinkedPositions(t).every((t=>t>0))}getLinkedPositions(t){const e=t.replace("PEPTIDE1{","").replace("}$$$$","").split("."),n=e.findIndex((t=>t===this.leftTerminal)),i=e.findIndex(((t,e)=>t===this.rightTerminal&&e>n));return[n+1,i+1]}getTransformedHelm(t){const e=this.getLinkedPositions(t);return an(t,{monomerPosition:e[0],attachmentPoint:3},{monomerPosition:e[1],attachmentPoint:3})}}class on{constructor(){}static getInstance(t,e){const n=e.cyclizationType;return"R3-R3"===n?new sn(t,e):"N-Cys"===n?new en(t,e):new nn(t,e)}}function rn(t){return t.replace("PEPTIDE1{","").replace("}$$$$","").split(".").length}function an(t,e,n){return t.replace("}$$$$",`}$PEPTIDE1,PEPTIDE1,${e.monomerPosition}:R${e.attachmentPoint}-${n.monomerPosition}:R${n.attachmentPoint}${"$".repeat(6)}`)}async function ln(t,e,n){const i=t.dataFrame,s=tt.Cn.getOrCreate(t).convert(Ct.r2.HELM),r=on.getInstance(s,e).transform(),l=i.columns.getUnusedName(`${e.transformationType}(`+t.name+")"),c=a.Column.fromList("string",l,r);He(c),c.setTag("units",Ct.r2.HELM);const h=await Ve(i,c);h.name=i.columns.getUnusedName(`${e.transformationType}_molfile(`+t.name+")"),n&&(c.setTag("cell.renderer","helm"),i.columns.add(c)),i.columns.add(h,!0),await o.data.detectSemanticTypes(i)}function cn(t,e,n,i){const s=tt.Cn.getOrCreate(t);let o=null,r=null;for(let t=0;t<s.posList.length;++t)s.posList[t]==e&&(o=t),s.posList[t]==n&&(r=t);if(null===o&&null!==e)throw new Error(`Start position ${e} not found.`);if(null===r&&null!==n)throw new Error(`End position ${n} not found.`);if(s.posList.length<r)throw new Error(`End position ${r} exceeds positions length`);const a=i||`${t.name}: (${e??""}-${n??""})`;return s.getRegion(o,r,a)}const hn={df:a.DataFrame.fromCsv("seq,value\nATCCGTCGT,0.5\nTGTTCGTCA,0.4\nATGGTCGTA,0.7\nATCCGTGCA,0.1"),colName:"seq",positionNames:["1","1A","1C","2","4","4A","4B","5","6"].join(Ct.CI),regions:[{name:"first region",start:"1",end:"2"},{name:"second region",start:"1C",end:"4"},{name:"overlapping second",start:"1C",end:"4A"},{name:"whole sequence",start:"1",end:"6"},{name:"bad start",start:"0",end:"6"},{name:"bad end",start:"1",end:"4C"},{name:"bad start & end",start:"0",end:"4C"}]};class un{constructor(t,e){this.urlParams=t,this.funcName=e}async init(t){this.data=t??hn;const e=this.data.df.getCol(this.data.colName);this.data.positionNames&&e.setTag(".positionNames",this.data.positionNames),this.data.regions&&e.setTag(".regions",JSON.stringify(this.data.regions)),await this.buildView()}async buildView(){await o.data.detectSemanticTypes(this.data.df),this.view=o.shell.addTableView(this.data.df),this.view.path=this.view.basePath=`func/${fn.name}.${this.funcName}`;const t=await this.view.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:this.data.colName});this.view.dockManager.dock(t,a.DOCK_TYPE.DOWN,null,"WebLogo",.35)}}class dn{constructor(t){this.call=t,this.inputs=new class{},this.fixRegion=!1,this.defaultName=!0,this.defaultNameUpdating=!1;const e=t=>this.call.inputParams[t].property.description;this.inputs.table=r.tableInput("Table",this.call.inputParams.table.value??o.shell.tv.dataFrame,void 0,(()=>{}));const n=this.call.inputParams.sequence.value??this.inputs.table.value.columns.bySemType(a.SEMTYPE.MACROMOLECULE),i={filter:t=>t.semType===a.SEMTYPE.MACROMOLECULE};this.inputs.sequence=r.columnInput("Sequence",o.shell.tv.dataFrame,n,this.sequenceInputChanged.bind(this),i),this.inputs.start=r.choiceInput("Start",void 0,[],this.startInputChanged.bind(this)),this.inputs.end=r.choiceInput("End",void 0,[],this.endInputChanged.bind(this)),this.inputs.region=r.choiceInput("Region",null,[],this.regionInputChanged.bind(this)),this.inputs.name=r.stringInput("Column name",this.getDefaultName(),this.nameInputChanged.bind(this),{clearIcon:!0}),this.inputs.name.onInput(this.nameInputInput.bind(this));for(const t in this.call.inputParams)r.tooltip.bind(this.inputs[t].captionLabel,e(t));this.sequenceInputChanged()}sequenceInputChanged(){const t=this.inputs.sequence.value;t&&tt.Cn.getOrCreate(t),this.updateRegionItems(),this.updateStartEndInputItems(),this.updateRegion(!0),this.updateNameInput()}regionInputChanged(){this.fixRegion=!0;try{const t=this.inputs.region.stringValue,e=t?JSON.parse(t):null;if(null!==e)this.inputs.start.value=e?.start,this.inputs.end.value=e?.end;else{const t=tt.Cn.getOrCreate(this.inputs.sequence.value);this.inputs.start.value=t.posList[0],this.inputs.end.value=t.posList[t.posList.length-1]}}finally{this.fixRegion=!1}}startInputChanged(){this.updateRegion(!1),this.updateNameInput()}endInputChanged(){this.updateRegion(!1),this.updateNameInput()}nameInputChanged(){this.defaultNameUpdating||(this.defaultName=!1)}nameInputInput(){this.inputs.name.value||(this.defaultName=!0,this.inputs.name.input.focus())}updateStartEndInputItems(){const t=this.inputs.sequence.value,e=t?tt.Cn.getOrCreate(t):null,n=this.inputs.start.input,i=this.inputs.end.input;for(let t=n.options.length-1;t>=0;--t)n.options.remove(t);for(let t=i.options.length-1;t>=0;--t)i.options.remove(t);for(const t of e?.posList??[]){const e=document.createElement("option"),s=document.createElement("option");e.text=s.text=t,e.value=s.value=t,n.options.add(e),i.options.add(s)}n.value=e?.posList[0]??"",i.value=e?.posList[e?.posList.length-1]??""}updateRegionItems(){const t=this.inputs.sequence.value,e=t?t.getTag(".regions"):null,n=e?JSON.parse(e):null,i=this.inputs.region.input;for(let t=i.options.length-1;t>=0;--t)i.options.remove(t);const s=document.createElement("option");if(s.text="",s.value=JSON.stringify(null),i.options.add(s),null!=n){this.inputs.region.root.style.removeProperty("display");for(const t of n){const e=document.createElement("option");e.text=`${t.name}: ${t.start}-${t.end}`,e.value=JSON.stringify(t),i.options.add(e)}}else this.inputs.region.root.style.display="none"}updateRegion(t){const e=this.inputs.start.stringValue??"",n=this.inputs.end.stringValue??"";if(!this.fixRegion){const t=this.inputs.region.input;t.selectedIndex=-1;for(let i=t.options.length-1;i>=0;--i){const s=t.options[i],o=JSON.parse(s.value);o&&e===o.start&&n===o.end&&(t.selectedIndex=i)}}}updateNameInput(){this.defaultNameUpdating=!0;try{this.defaultName&&(this.inputs.name.value=this.getDefaultName())}finally{this.defaultNameUpdating=!1}}getDefaultName(){const t=this.inputs.region.stringValue,e=t?JSON.parse(t):null,n=this.inputs.sequence.value,i=this.inputs.start.stringValue??"",s=this.inputs.end.stringValue??"";return null!=e?`${n.name}(${e.name}): ${e.start}-${e.end}`:`${n?.name}: (${i}-${s})`}getParams(){return{table:this.inputs.table.value,sequence:this.inputs.sequence.value,start:this.getStart(),end:this.getEnd(),name:this.getName()}}getStart(){return this.inputs.start.stringValue}getEnd(){return this.inputs.end.stringValue}getName(){const t=this.inputs.name.stringValue;return""==t?null:t}dialog(){const t=r.inputs(Object.values(this.inputs),{style:{minWidth:"320px"}});r.dialog({title:"Get Region"}).add(t).onOK((()=>{(async()=>{const t=this.getParams();await this.call.func.prepare(t).call(!0)})().catch((t=>{fn.handleErrorUI(t)}))})).show()}widget(){const t=r.inputs(Object.entries(this.inputs).filter((([t,e])=>!["table","sequence"].includes(t))).map((([t,e])=>e))),e=r.button("Get Region",(()=>{(async()=>{const t=this.getParams();await this.call.func.prepare(t).call(!0)})().catch((t=>{fn.handleErrorUI(t)}))}));return a.Widget.fromRoot(r.divV([t,r.div(e)]))}}var mn=n(8601);class pn extends m{activitiesInput;activitiesInputRoot;similarityInput;constructor(t={}){super(t);const e=this.tableInput.value.columns.numerical;this.activitiesInput=r.columnInput("Activities",this.tableInput.value,a.Utils.firstOrNull(e),null,{filter:t=>Array.from(e).includes(t)}),this.activitiesInputRoot=this.activitiesInput.root,this.similarityInput=r.intInput("Similarity cutoff",80)}onTableInputChanged(){if(super.onTableInputChanged(),this.activitiesInputRoot){r.empty(this.activitiesInputRoot);const t=this.tableInput.value.columns.numerical;this.activitiesInput=r.columnInput("Activities",this.tableInput.value,a.Utils.firstOrNull(t),null,{filter:e=>Array.from(t).includes(e)}),Array.from(this.activitiesInput.root.children).forEach((t=>this.activitiesInputRoot.append(t)))}}getEditor(){return r.div([this.tableInput,this.colInputRoot,this.preprocessingFunctionInputRoot,this.preprocessingFuncSettingsDiv,this.activitiesInputRoot,this.similarityMetricInputRoot,this.methodInput,this.methodSettingsDiv,this.similarityMetricInputRoot,this.similarityInput],{style:{minWidth:"320px"},classes:"ui-form"})}getParams(){return{...super.getParams(),activities:this.activitiesInput.value,similarityThreshold:this.similarityInput.value}}}function gn(t){const e=["Embed_X","Embed_Y"],n=t.columns.names().filter((t=>t.includes(e[0]))).length+1;return e.map((t=>`${t}_${n}`))}const fn=new ke;function yn(){return le.NT.instance}let bn=null;class Cn{constructor(t){this._palette=t}get(t){return this._palette[t]}}async function wn(){fn.logger.debug("Bio: initBio(), started");const t=await o.functions.call("Chem:getRdKitModule");await Promise.all([(async()=>{await le.NT.instance.loadLibraries()})(),(async()=>{const t=await fn.getProperties(),e=new Ge(t);fn.properties=e})()]).finally((()=>{fn.completeInit()}));const e=le.NT.instance.getBioLib(),n=[],i=[],s=e.getMonomerMolsByPolymerType("PEPTIDE");Object.keys(s).forEach((e=>{n.push(e);const o=s[e].replaceAll("#R","O "),r=t.get_mol(o),a=JSON.parse(r.get_descriptors()).CrippenClogP;i.push(a),r?.delete()}));const r=i.reduce(((t,e)=>t+e),0)/i.length||0,a={};for(let t=0;t<n.length;t++)a[n[t]]=i[t]<r?"#4682B4":"#DC143C";bn=new Cn(a),fn.logger.debug("Bio: initBio(), completed")}function vn(t){const e=new Be(t);return e.init().then((()=>{})).catch((t=>{const e=t instanceof Error?t.message:t.toString();o.shell.error(e)})),e}function Sn(){return le.NT.instance.getBioLib()}function An(t){const e="getRegionTopMenu",n=a.Func.find({package:fn.name,name:e});if(1!==n.length)throw new Error(`Package '${fn.name}' func '${e}' not found`);const i=n[0].prepare({table:t.dataFrame,sequence:t});return new dn(i).widget()}async function xn(t){return(0,le.cf)()}function Tn(t){try{new dn(t).dialog()}catch(t){const e=t instanceof Error?t.message:t.toString(),n=t instanceof Error?t.stack:void 0;o.shell.error(`Get region editor error: ${e}`),fn.logger.error(e,void 0,n)}}function In(t){const e=new Le;r.dialog({title:"Split to Monomers"}).add(e.paramsUI).onOK((async()=>t.func.prepare(e.funcParams).call(!0))).show()}function Mn(t){const e=new m({semtype:a.SEMTYPE.MACROMOLECULE});r.dialog({title:"Sequence Space"}).add(e.getEditor()).onOK((async()=>{const n=e.getParams();return t.func.prepare({molecules:n.col,table:n.table,methodName:n.methodName,similarityMetric:n.similarityMetric,plotEmbeddings:n.plotEmbeddings,options:n.options,preprocessingFunction:n.preprocessingFunction,clusterEmbeddings:n.clusterEmbeddings}).call()})).show()}function Ln(t){const e=new pn({semtype:a.SEMTYPE.MACROMOLECULE});r.dialog({title:"Activity Cliffs"}).add(e.getEditor()).onOK((async()=>{const n=e.getParams();return t.func.prepare({table:n.table,molecules:n.col,activities:n.activities,similarity:n.similarityThreshold,methodName:n.methodName,similarityMetric:n.similarityMetric,preprocessingFunction:n.preprocessingFunction,options:n.options}).call()})).show()}function En(){return new Mt}function Nn(t){return function(t){const e=Array.from(t.dataFrame.columns).filter((t=>t.semType===a.SEMTYPE.MOLECULE)).map((t=>t.name));new Set(e).delete(t.name);const n=r.choiceInput("Monomer width",null!=t?.temp["monomer-width"]?t.temp["monomer-width"]:yt.short,[yt.short,yt.long],(e=>{t.temp["monomer-width"]=e,t.setTag(".mm.cellRenderer.settingsChanged",vt.true),t.dataFrame.fireValuesChanged()}));n.setTooltip("In short mode, only the 'Max monomer length' characters are displayed, followed by .. if there are more");const i=parseInt(t.getTag(pt.maxMonomerLength)),s=r.intInput("Max monomer length",isNaN(i)?fn.properties.MaxMonomerLength:i,(e=>{t.setTag(pt.maxMonomerLength,e.toString()),t.setTag(".mm.cellRenderer.settingsChanged",vt.true),t.dataFrame.fireValuesChanged()}));s.setTooltip(`The max length of monomer name displayed without shortening in '${yt.short}' monomer width mode.`);const o=r.intInput("Monomer margin",t.temp[".mm.cellRenderer.gapLength"]??0,(e=>{t.temp[".mm.cellRenderer.gapLength"]=e,t.setTag(".mm.cellRenderer.settingsChanged",vt.true),t.dataFrame.fireValuesChanged()}));o.setTooltip("The size of margin between monomers (in pixels)");const l=r.boolInput("Color code",null==t?.temp["color-code"]||t.temp["color-code"],(e=>{t.temp["color-code"]=e,t.dataFrame.fireValuesChanged()}));l.setTooltip("Color code");const c=r.stringInput("Reference sequence",null!=t?.temp["reference-sequence"]?t?.temp["reference-sequence"]:"",(e=>{t.temp["reference-sequence"]=e,t.dataFrame.fireValuesChanged()}));c.setTooltip("Reference sequence is not empty, then the sequence will be render \nas a difference from the reference sequence");const h=r.boolInput("Compare with current",null==t?.temp["compare-with-current"]||t.temp["compare-with-current"],(e=>{t.temp["compare-with-current"]=e,t.dataFrame.fireValuesChanged()}));h.setTooltip('When on, all sequences get rendered in the "diff" mode');const u=r.inputs([n,s,o,c,l,h]);return new a.Widget(u)}(t)}function Rn(t){return(0,Fe.t)(t)}function _n(){return new Mt}function On(){return new Lt}function Pn(t,e,n,i,s){const o=new Vt.k(i,s,n,e);return"Local alignment"==t?o.smithWaterman():o.needlemanWunch()}function Gn(){return new kt.OZ}function kn(){return new Dt}function Fn(t,e,n,i){return cn(t,e??null,n??null,i??null)}async function Bn(t,e,n,i,s){const r=cn(e,n??null,i??null,s??null);e.dataFrame.columns.add(r),await o.data.detectSemanticTypes(e.dataFrame)}async function Wn(t,e,n,i,s,h,u,d){if(!(0,Te.n)(e,"Activity Cliffs"))return;const m=gn(t),f={units:e.getTag(a.TAGS.UNITS),aligned:e.getTag("aligned"),separator:e.getTag("separator"),alphabet:e.getTag("alphabet")},y=h,b=e,C=async()=>await async function(t,e,n,i,s,l,c,h,u,d,m,f,y,b,C,w){Z++;const v=l/100;let S,A=!1;const x=f.inputs,T=await f.apply({[x[0].name]:e,[x[1].name]:c,...u.preprocessingFuncArgs??{}}),I=await U([T.entries],h,[c],[1],"MANHATTAN",{...u,distanceFnArgs:[T.options??{}]});if(I.length!==n.length)throw new Error("Number of axes names should be equal to number of embedding dimensions");for(let e=0;e<I.length;++e)t.columns.addNewFloat(n[e]).init((t=>I[e][t]));const M=(0,R.sQ)(c)?1-(0,g.eo)(v):v,L=await(new F).calc(T.entries,c,M,T.options),E=await async function(t,e){const n=t.distance.map(((n,i)=>{const s=Math.abs(e.get(t.i[i])-e.get(t.j[i]));return 0!=n?s/n:1/0})),i=t.distance.map((t=>1-t)),s=t.i,o=t.j,r=new Set;return t.distance.forEach(((e,n)=>{r.add(t.i[n]),r.add(t.j[n])})),{simVals:i,saliVals:n,n1:s,n2:o,cliffsMolIds:r}}(L,s),N=function(t,e,n,i,s,o){const r=new Array(t).fill(0);for(let t=0;t!=n.length;++t)e[t]!=1/0&&(o.get(n[t])>o.get(i[t])?r[n[t]]+=e[t]:r[i[t]]+=e[t]);return a.Column.fromList("double",`sali_${s[0].substring(s[0].lastIndexOf("_"))}`,r)}(e.length,E.saliVals,E.n1,E.n2,n,s);t.columns.add(N);const _=function(t,e){const n=a.BitSet.create(t.rowCount);for(let i=0;i<t.rowCount;i++)n.set(i,e.has(i));return n}(t,E.cliffsMolIds),O=function(t){const e=t.filter((t=>t!==1/0)),n=e.reduce(((t,e)=>Math.min(t,e)),Number.MAX_VALUE),i=e.reduce(((t,e)=>Math.max(t,e)),n);return{max:i,min:n}}(E.saliVals),P=.8/(O.max-O.min),G=o.shell.getTableView(t.name),k=G.addViewer(a.VIEWER.SCATTER_PLOT,{xColumnName:n[0],yColumnName:n[1],size:N.name,color:s.name,showXSelector:!1,showYSelector:!1,showSizeSelector:!1,showColorSelector:!1,markerMinSize:5,markerMaxSize:25,title:i}),W=function(t,e,n,i,s,o,r,l){const c={from:new Uint32Array(e.n1.length),to:new Uint32Array(e.n1.length),opacities:new Float32Array(e.n1.length),colors:new Array(e.n1.length),widths:new Float32Array(e.n1.length)};for(let n=0;n<e.n1.length;n++)c.from[n]=e.n1[n],c.to[n]=e.n2[n],c.opacities[n]=e.saliVals[n]===1/0?1:.2+(e.saliVals[n]-r.min)*l,c.colors[n]=t.selection.get(c.from[n])&&t.selection.get(c.to[n])?"255,255,0":"0,128,0",c.widths[n]=1;const h=a.DataFrame.create(c.from.length);return j.forEach(((t,e)=>{h.columns.addNewString(t).init((t=>n.get(0===e?c.from[t]:c.to[t]))),function(t,e){Object.keys(e).forEach((n=>{t.tags[n]=e[n]}))}(h.col(t),o),h.col(t).semType=s})),h.columns.addNewFloat(K).init((t=>Math.abs(i.get(c.from[t])-i.get(c.to[t])))),h.columns.addNewInt(z).init((t=>t)),h.columns.addNewFloat(X).init((t=>e.saliVals[t])),h.columns.addNewFloat(q).init((t=>e.simVals[t])),h.name=`${Y}${Z}`,{lines:c,linesDf:h}}(t,E,e,s,d,m,O,P),D=new H(k,n[0],n[1],W.lines,B.none),V=C?C(W.linesDf,j).sort([X],[!1]):W.linesDf.plot.grid().sort([X],[!1]);t.temp[".cliffsDfGrid"]=V;const Q=r.button(`${W.linesDf.rowCount} cliffs`,(()=>{G.dockManager.dock(V,"down",null,"Activity cliffs",w??.2)}));Q.classList.add("scatter_plot_link","cliffs_grid"),k.root.append(Q);const tt=r.switchInput("Show only cliffs",!1,(()=>{tt.value?(k.dataFrame.setTag(J,n[0]),t.filter.and(_),$.next(n[0])):(k.dataFrame.setTag(J,""),t.filter.setAll(!0),$.next(""))}));tt.root.classList.add("scatter_plot_link","show_only_cliffs"),k.root.append(tt.root),$.subscribe((t=>{tt.enabled=""===t||t===n[0]}));let et=!1;k.onEvent("d4-before-draw-scene").subscribe((e=>{et?et=!1:tt.value&&(setTimeout((()=>{t.filter.and(_)}),100),et=!0)}));const nt=o.events.onViewerClosed.subscribe((t=>{t.args.viewer===k&&(G.dockManager.close(V.root),nt.unsubscribe(),G.subs=G.subs.filter((t=>t!==nt)))}));return G.subs.push(nt),W.linesDf.onCurrentCellChanged.subscribe((()=>{for(let t=0;t<W.linesDf.rowCount;t++)W.lines.widths[t]=t===W.linesDf.currentRowIdx?3:1;D.linesToRender=W.lines;const i=W.linesDf.currentCol&&W.linesDf.currentCol.name===j[1]?W.lines.to:W.lines.from,a=-1!==W.linesDf.currentRowIdx?W.linesDf.currentRowIdx:null;if(k.dataFrame.currentRowIdx=a?i[a]:-1,null!==a){const i=W.linesDf.currentRowIdx;D.currentLineId=i;const{zoomLeft:l,zoomRight:c,zoomTop:h,zoomBottom:u}=function(t,e,n,i,s,o){const r=Math.abs(n-s),a=Math.abs(i-o),l=t/r,c=e/a,h=Math.min(l,c),u=t/h*5,d=e/h*5,m=(n<s?n:s)+r/2-u/2,p=(i>o?i:o)-a/2+d/2;return{zoomLeft:m,zoomRight:m+u,zoomTop:p,zoomBottom:p-d}}(k.viewport.width,k.viewport.height,k.dataFrame.get(n[0],W.lines.from[i]),k.dataFrame.get(n[1],W.lines.from[i]),k.dataFrame.get(n[0],W.lines.to[i]),k.dataFrame.get(n[1],W.lines.to[i]));k.zoom(l,h,c,u),tt.value?t.filter.and(_):!0===tt.enabled&&t.filter.setAll(!0),setTimeout((()=>{!function(t,e,n,i,s,a,l,c,h){const u=e.getPane("Cliff Details");r.empty(u.root);const d=h({points:[n,i],lineId:s,df:t,seqCol:a,activityCol:l,sali:c});u.root.append(d),setTimeout((()=>{o.shell.o=e.root}),500)}(t,S,W.lines.from[a],W.lines.to[a],a,e,s,W.linesDf.get(X,a),b);const n=k.dataFrame.getSortedOrder(G.grid.sortByColumns,G.grid.sortTypes);G.grid.scrollToCell(e.name,n.indexOf(k.dataFrame.currentRowIdx))}),1e3)}})),W.linesDf.onSelectionChanged.subscribe((e=>{setTimeout((()=>(()=>{const e=a.BitSet.create(t.rowCount);for(let t=0;t<W.linesDf.rowCount;t++){const n=W.linesDf.selection.get(t);n&&(e.set(W.lines.from[t],!0),e.set(W.lines.to[t],!0)),W.lines.colors[t]=n?"255,255,0":"0,128,0"}t.selection.copyFrom(e),D.linesToRender=W.lines})()),100)})),t.onSelectionChanged.subscribe((e=>{!1===t.selection.anyTrue&&"number"==typeof e&&(A?A=!1:(t=>{t.selection.setAll(!1);for(let t=0;t<W.lines.colors.length;t++)W.lines.colors[t]="0,128,0";D.linesToRender=W.lines})(V.dataFrame))})),D.lineClicked.subscribe((e=>{if(A=!0,D.currentLineId=e.id,-1!==e.id){const n=W.linesDf.selection.clone();setTimeout((()=>{e.event.ctrlKey?(n.set(e.id,!n.get(e.id)),W.linesDf.selection.copyFrom(n)):(W.linesDf.currentRowIdx!==e.id&&(W.linesDf.currentRowIdx=e.id,t.currentRowIdx=W.lines.from[e.id]),W.linesDf.selection.copyFrom(n));const i=W.linesDf.getSortedOrder(V.sortByColumns,V.sortTypes);V.scrollToCell(j[0],i.indexOf(e.id))}),500)}})),D.lineHover.pipe((0,p.debounceTime)(500)).subscribe((n=>{-1!==n.id&&-1===t.mouseOverRowIdx&&r.tooltip.show(y({lineId:n.id,points:[W.lines.from[n.id],W.lines.to[n.id]],df:t,seqCol:e,activityCol:s}),n.x,n.y)})),k.addProperty("similarityLimit","double",v),S=function(){const t=r.accordion(),e=r.element("i");return e.className="grok-icon svg-icon svg-view-layout",t.addTitle(r.span([e,r.label("Activity cliffs")])),t.addPane("Cliff Details",(()=>r.divText("Cliff has not been selected")),!0),o.shell.o=t.root,t}(),k}(t,b,m,"Activity cliffs",n,i,y,s,{...d??{}},a.SEMTYPE.MACROMOLECULE,f,u,$t,Kt,jt),w=s===c.A.UMAP?2e5:2e4,v=s===c.A.UMAP?5e3:2e3;if(t.rowCount>w)return void o.shell.warning(`Too many rows, maximum for sequence activity cliffs is ${w}`);const S=a.TaskBarProgressIndicator.create("Running sequence activity cliffs ...");return new Promise(((e,n)=>{t.rowCount>v&&!d?.[l.sS]?r.dialog().add(r.divText("Activity cliffs analysis might take several minutes.\n Do you want to continue?")).onOK((async()=>{C().then((t=>e(t))).catch((t=>n(t)))})).onCancel((()=>{e(void 0)})).show():C().then((t=>e(t))).catch((t=>n(t)))})).catch((t=>{const[e,n]=(0,rt.yf)(t);throw fn.logger.error(e,void 0,n),t})).finally((()=>{S.close()}))}async function Hn(t,e,n=1,i=.6,s="Morgan"){if(t.semType!==a.SEMTYPE.MACROMOLECULE)return{entries:t.toList(),options:{}};const{seqList:o,options:r}=await Zt(t,e,s);return{entries:o,options:{...r,gapOpen:n,gapExtend:i}}}async function Dn(t,e){t.version!==t.temp["last-invalidated-version"]&&await(0,Yt.HV)(t,!1);const n=t.temp["monomeric-mols"],i=await o.functions.call("Chem:getMorganFingerprints",{molColumn:n}),s=new Array(i.length).fill(null);for(let t=0;t<i.length;t++){if(i.isNone(t)||!i.get(t))continue;const e=i.get(t);s[t]=W.Z.fromUint32Array(e.length,new Uint32Array(e.getBuffer().buffer))}return{entries:s,options:{}}}async function Vn(t,e,i,s,c,h,u,d){if((0,Te.n)(e,"Sequence Space"))return h||(h=a.Func.find({name:"macromoleculePreprocessingFunction",package:"Bio"})[0]),u??(u={}),await async function(t,e,i,s,c,h,u,d=!0,m=!1,p={preprocessingFuncArgs:[]},g={}){const f={showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1};if(e.length!==s.length||e.length!==h.length||e.length!==c.length||e.length!==p.preprocessingFuncArgs.length)throw new Error("columns, metrics and preprocessing functions, weights and function argumentsmust have the same length");const y=async()=>{const y=a.TaskBarProgressIndicator.create(`Initializing ${g.scatterPlotName??"dimensionality reduction"} ...`);let b;try{const C=gn(t);function w(e,n,i){let s=null,c=null;t.columns.names().includes(C[0])?(s=t.columns.byName(C[0]),c=t.columns.byName(C[1])):(s=t.columns.add(a.Column.float(C[0],t.rowCount)),c=t.columns.add(a.Column.float(C[1],t.rowCount)),d&&!b&&(b=o.shell.tableView(t.name).scatterPlot({...f,x:C[0],y:C[1],title:g.scatterPlotName??"Embedding space"}))),g[l.Ec]&&(b?.root&&r.setUpdateIndicator(b.root,!1),s.init((t=>i[0]?i[0][t]:void 0)),c.init((t=>i[1]?i[1][t]:void 0)));const h=e/n*100;y.update(h,`Running ${g.scatterPlotName??"dimensionality reduction"}... ${h.toFixed(0)}%`)}async function v(){t.columns.add(a.Column.float(C[0],t.rowCount)),t.columns.add(a.Column.float(C[1],t.rowCount));let n=null;d&&(b=o.shell.tableView(t.name).scatterPlot({...f,x:C[0],y:C[1],title:g.scatterPlotName??"Embedding space"}),r.setUpdateIndicator(b.root,!0));const m=o.events.onViewerClosed.subscribe((t=>{const e=t.args.viewer;e?.getOptions()?.look?.title&&b?.getOptions()?.look?.title&&e?.getOptions()?.look?.title===b?.getOptions()?.look?.title&&(o.events.fireCustomEvent(D,{}),m.unsubscribe(),n?.(),y.close())})),v=new Promise((async(t,o)=>{try{n=t;const o=[];for(let t=0;t<h.length;++t){const n=h[t];if(p.distanceFnArgs||(p.distanceFnArgs=[]),n){const i=n.inputs[0].name,r=n.inputs[1].name,{entries:a,options:l}=await n.apply({[i]:e[t],[r]:s[t],...p.preprocessingFuncArgs[t]??{}});o.push({entries:a,options:l}),p.distanceFnArgs.push(l)}else{const n=e[t].toList(),i={};o.push({entries:n,options:i}),p.distanceFnArgs.push(i)}}t(await U(o.map((t=>t.entries)),i,s,c,u,p,g[l.sS]?void 0:w))}catch(t){o(t)}})),S=await v;return y.close(),m.unsubscribe(),S}const S=await v();if(m&&S){const A=a.TaskBarProgressIndicator.create("Clustering embeddings ...");try{const x=await function(t,e,i,s){return ye(this,void 0,void 0,(function*(){return new Promise((function(o,r){const a=new Worker(new URL(n.p+n.u(796),n.b));a.postMessage({embedX:t,embedY:e,minPts:s,epsilon:i}),a.onmessage=({data:{error:t,clusters:e}})=>{a.terminate(),t?r(t):o(e)}}))}))}(S[0],S[1],p.dbScanEpsilon??.01,p.dbScanMinPts??4),T=t.columns.getUnusedName("Cluster");t.columns.addNewString(T).init((t=>x[t].toString())),b&&(b.props.colorColumnName=T)}catch(I){o.shell.error("Clustering embeddings failed"),console.error(I)}finally{A.close()}}if(S&&d&&b){r.setUpdateIndicator(b.root,!1);const M=t.columns.byName(C[0]),L=t.columns.byName(C[1]);return M.init((t=>S[0][t])),L.init((t=>S[1][t])),b}}catch(E){o.shell.error("Dimensionality reduction failed"),console.error(E),y.close(),b&&r.setUpdateIndicator(b.root,!1)}};return new Promise((async(e,n)=>{try{if(g.fastRowCount&&t.rowCount>g.fastRowCount&&!g[l.sS])r.dialog().add(r.divText("Analysis might take several minutes. Do you want to continue?")).onOK((async()=>{try{const t=await y();e(t)}catch(t){n(t)}})).onCancel((()=>e(void 0))).show();else{const t=await y();e(t)}}catch(t){n(t)}}))}(t,[e],i,[s],[1],[h],"MANHATTAN",c,d??!1,{...u,preprocessingFuncArgs:[u.preprocessingFuncArgs??{}]},{fastRowCount:1e4,scatterPlotName:"Sequence space",bypassLargeDataWarning:u?.[l.sS]})}async function Un(t,e,n){const i=a.TaskBarProgressIndicator.create("Converting to atomic level ...");try{await async function(t,e,n){if(0===a.Func.find({package:"Chem",name:"getRdKitModule"}).length)return void o.shell.warning('Transformation to atomic level requires package "Chem" installed.');if(n){const n=tt.Cn.getOrCreate(e);return n.isHelm()||(e=n.convert(Ct.r2.HELM)),void async function(t,e){const n=await Ve(t,e);t.columns.add(n,!0),await o.data.detectSemanticTypes(t)}(t,e)}if(!(0,Te.n)(e,"To Atomic Level"))return;const i=yn().getBioLib(),s=await(0,mn.i0)(t,e,i);null!==s.col&&(t.columns.add(s.col,!0),await o.data.detectSemanticTypes(t)),s.warnings&&s.warnings.length>0&&o.shell.warning(r.list(s.warnings))}(t,e,n)}finally{i.close()}}function Zn(){(0,Ie.K)()}async function Yn(t=null,e=null){return(0,Ie.K)({col:t,clustersCol:e})}async function $n(){const t=o.shell.tv,e=t.dataFrame.columns.toList().filter((t=>t.semType==a.SEMTYPE.MACROMOLECULE&&(tt.Cn.getOrCreate(t),!0))),n=async e=>{if(!(0,Te.n)(e,"Composition"))return;const n=t.addViewer("WebLogo",{sequenceColumnName:e.name});o.shell.tv.dockManager.dock(n,a.DOCK_TYPE.DOWN,null,"Composition analysis",.25)};let i=null;if(0!=e.length){if(e.length>1){const t=e.map((t=>t.name)),i=e.find((t=>tt.Cn.getOrCreate(t).isMsa())),s=r.choiceInput("Column",i?i.name:t[0],t);r.dialog({title:"Composition Analysis",helpUrl:"https://datagrok.ai/help/datagrok/solutions/domains/bio/#sequence-composition"}).add(r.div([s])).onOK((async()=>{const t=e.find((t=>t.name==s.value))??null;t&&await n(t)})).show()}else i=e[0];i&&await n(i)}else o.shell.error("Current table does not contain sequences")}function Kn(t){return new et.i(t).importFasta()}function Xn(t){return console.log(t),[]}function qn(){const t=(0,at.B)()[0];(0,oe.O)(t)}function zn(){let t;try{t=function(){function t(t){return t===h[0]?[We.M].concat(d.getMonomerSymbolsByType("PEPTIDE")):t===h[1]?[We.M].concat(d.getMonomerSymbolsByRGroup(3,"PEPTIDE")):["C"]}function e(){"N-Cys"===u.value?(m=t("N-O"),p=t("N-Cys")):(m=t(u.value),p=[...m]),g=r.choiceInput("R1:",m[0],m,(()=>{i.next()})),y=r.choiceInput("R2:",p[0],p,(()=>{i.next()})),i.next(),r.empty(b),[g,y].forEach((t=>{b.appendChild(t.root)}))}const n=new f.Subject,i=new f.Subject;n.subscribe((()=>{s.cyclizationType=u.value,e()})),i.subscribe((()=>{s.rightTerminal=y.value,s.leftTerminal=g.value}));const s={},l=["Cyclization"],c=r.choiceInput("Modification",l[0],l,(()=>s.transformationType=c.value)),h=["N-O","R3-R3","N-Cys"],u=r.choiceInput("Type",h[2],h,(()=>{n.next()})),d=le.NT.instance.getBioLib();let m=[],p=[],g=r.choiceInput("R1:",m[0],m,(()=>{s.leftTerminal=g.value})),y=r.choiceInput("R2:",p[0],p,(()=>{s.rightTerminal=y.value}));const b=r.divV([g.root,y.root]);e(),s.cyclizationType=u.value,s.leftTerminal=g.value,s.rightTerminal=y.value,s.transformationType=c.value;const C=o.shell.t.columns.bySemTypeAll(a.SEMTYPE.MACROMOLECULE);if(!C)throw new Error("No dataframe with maceomolecule columns open");const w=r.columnInput("Column",o.shell.t,C[0],null,{filter:t=>t.semType===a.SEMTYPE.MACROMOLECULE}),v=r.boolInput("Get HELM",!0);r.tooltip.bind(v.root,"Add HELM column");const S=r.div([w,c,u,b,v]);return r.dialog("Poly Tool").add(S).onOK((async()=>{const t=w.value;t?ln(t,s,v.value):o.shell.warning("No marcomolecule column chosen!")}))}(),t.show()}catch(t){o.shell.warning("To run PolyTool, open a dataframe with macromolecules")}}function jn(){return new Pe}async function Jn(t){const e=a.TaskBarProgressIndicator.create("Test detectMacromolecule..."),n=(await o.dapi.files.list(t,!0,"")).filter((t=>t.fileName.endsWith(".csv")));let i=0;const s=[];for(const r of n)try{const e=await o.dapi.files.readAsText(t+r.fullPath),n=a.DataFrame.fromCsv(e);for(const t of n.columns)await o.functions.call("Bio:detectMacromolecule",{col:t})===a.SEMTYPE.MACROMOLECULE&&s.push({file:r.path,result:"detected",column:t.name,message:`units: ${t.getTag(a.TAGS.UNITS)}`})}catch(t){s.push({file:r.path,result:"error",column:null,message:t instanceof Error?t.message:t.toString()})}finally{i+=1,e.update(100*i/n.length,`Test ${r.fileName}`)}o.shell.info("Test Demo:Files for detectMacromolecule finished."),e.close();const r=a.DataFrame.fromObjects(s);return r.name=`datasets_detectMacromolecule_${t}`,r}async function Qn(t,e){await(0,Ee.n)(t,e)}function ti(t){const e=tt.Cn.getOrCreate(t).stats;return Object.keys(e.freq)}function ei(){return new ee}function ni(){const t=o.shell.v,e=t.addViewer("Sequence Similarity Search");t.dockManager.dock(e,"down")}function ii(){return new ie}function si(){const t=o.shell.v,e=t.addViewer("Sequence Diversity Search");t.dockManager.dock(e,"down")}function oi(t){const e=(0,at.B)();1===e.length?t.func.prepare({macromolecules:e[0]}).call(!0):new Yt.uH(e)}function ri(t){o.shell.tv.getFiltersGroup({createDefaultFilters:!1}).updateOrAdd({type:"Bio:bioSubstructureFilter",column:t.name,columnName:t.name}),o.shell.tv.grid.scrollToCell(t,0)}async function ai(t,e,n){return ot(t,e,n,Q.IDENTITY)}async function li(t,e,n){return ot(t,e,n,Q.SIMILARITY)}function ci(){(0,re.C2)()}function hi(){return new ae.ST}async function ui(){const t=a.TaskBarProgressIndicator.create("WebLogo");try{const t=new URLSearchParams(window.location.search),e=new Me(t,"webLogoLargeApp"),n=await fn.files.readCsv("data/sample_PT_100000x5.csv");await o.data.detectSemanticTypes(n),await e.init(n)}finally{t.close()}}async function di(){const t=a.TaskBarProgressIndicator.create("WebLogo ...");try{const t=new URLSearchParams(window.location.search),e=new Me(t,"webLogoAggApp"),n=await fn.files.readCsv("data/sample_FASTA_PT_activity.csv");await o.data.detectSemanticTypes(n),await e.init(n)}finally{t.close()}}async function mi(){const t=a.TaskBarProgressIndicator.create("getRegion ...");try{const t=new URLSearchParams(window.location.search),e=new un(t,"getRegionApp");await e.init()}finally{t.close()}}async function pi(){const t=a.TaskBarProgressIndicator.create("getRegion ...");try{const t=new URLSearchParams(window.location.search),e=await fn.files.readCsv("data/sample_HELM_empty_vals.csv"),n=new un(t,"getRegionHelmApp");await n.init({df:e,colName:"HELM"})}finally{t.close()}}function gi(t,e){!function(t,e){const n=tt.Cn.getOrCreate(t.column),i=Object.values(Ct.r2).filter((t=>t!==n.units));e.group("Copy").items(i,(e=>{const n=tt.Cn.getOrCreate(t.column),i=e===Ct.r2.SEPARATOR?fn.properties.DefaultSeparator:void 0,s=n.getConverter(e,i)(t.value);navigator.clipboard?(navigator.clipboard.writeText(s),o.shell.info(`Value of notation '${e}' copied to clipboard`)):o.shell.warning("The clipboard functionality requires a secure origin — either HTTPS or localhost")}))}(t,e)}async function fi(){await async function(){let t,e;try{const n=new he("Similarity, Diversity","Sequence similarity tracking and evaluation dataset diversity");await n.step("Load DNA sequences",(async()=>{o.shell.windows.showContextPanel=!1,o.shell.windows.showProperties=!1,e=await fn.files.readCsv(de),t=o.shell.addTableView(e),t.grid.columns.byName("cluster").visible=!1,t.grid.columns.byName("sequence_id").visible=!1,t.grid.columns.byName("sequence").width=300,t.grid.columns.byName("activity").visible=!1,t.grid.columns.byName("is_cliff").visible=!1}),{description:"Load dataset with macromolecules of 'fasta' notation, 'DNA' alphabet.",delay:2e3}).step("Find the most similar sequences to the current one",(async()=>{const n=await e.plot.fromType("Sequence Similarity Search",{moleculeColumnName:"sequence",similarColumnLabel:"Similar to current"});t.dockManager.dock(n,a.DOCK_TYPE.RIGHT,null,"Similarity search",.35)}),{description:"Add 'Sequence Similarity Search' viewer.",delay:2e3}).step("Explore most diverse sequences in a dataset",(async()=>{const n=await e.plot.fromType("Sequence Diversity Search",{moleculeColumnName:"sequence",diverseColumnLabel:"Top diverse sequences of all data"});t.dockManager.dock(n,a.DOCK_TYPE.DOWN,null,"Diversity search",.27)}),{description:"Add 'Sequence Deversity Search' viewer.",delay:2e3}).step("Choose another sequence for similarity search",(async()=>{e.currentRowIdx=3}),{description:"Handling current row changed of data frame showing update of similar sequences.",delay:2e3}).step("One more sequence for similarity search",(async()=>{e.currentRowIdx=7}),{description:"Just one more sequence to search similar ones.",delay:2e3}).start()}catch(t){ue(t)}}()}async function yi(){await async function(){let t,e,n,i,s;try{const r=new he("Sequence Space","Exploring sequence space of Macromolecules, comparison with hierarchical clustering results");await r.step("Load DNA sequences",(async()=>{[i,t,e]=await Promise.all([fn.files.readCsv(be),me(),pe()]),n=o.shell.addTableView(i),n.grid.props.rowHeight=22,n.grid.columns.byName("cluster").visible=!1,n.grid.columns.byName("sequence").width=200,n.grid.columns.byName("is_cliff").visible=!1,o.shell.windows.showContextPanel=!1,o.shell.windows.showProperties=!1}),{description:"Load dataset with macromolecules of 'fasta' notation, 'DNA' alphabet.",delay:2e3}).step("Build sequence space",(async()=>{s=await async function(t,e,n,i){let s;{const t=Object.values(se);for(let n=0;n<t.length;n++){const i=t[n];if(!e.col(i)){const s=n==t.length-1;e.columns.add(a.Column.float(i,e.rowCount),s)}}if(e.rowCount>=1){const i=e.getCol(n).toList(),s=Date.now();fn.logger.debug("Bio: demoBio01aUI(), calc reduceDimensionality start...");const o=await U([i],"UMAP",[k.W.Levenshtein],[1],"MANHATTAN",{distanceFnArgs:[{}]}),r=Date.now();fn.logger.debug(`Bio: demoBio01aUI(), calc reduceDimensionality ET: ${(r-s)/1e3} s`);for(let n=0;n<t.length;n++){const i=t[n],s=e.getCol(i),r=o[n];s.init((t=>r[t]))}const a=Date.now();fn.logger.debug(`MLB: MlbVrSpaceBrowser.buildView(), postprocess reduceDimensionality ET: ${(a-r)/1e3} s`)}s=await e.plot.fromType(a.VIEWER.SCATTER_PLOT,{xColumnName:se.X,yColumnName:se.Y,lassoTool:!0})}return t.dockManager.dock(s,a.DOCK_TYPE.RIGHT,null,"Sequence Space",.35),s}(n,i,Ce),s.setOptions({color:"activity"})}),{description:"Reduce sequence space dimensionality to display on 2D representation.",delay:2e3}).step("Cluster sequences",(async()=>{const s=await t.calcDistanceMatrix(i,[Ce]),o=await fe(s.data,i.rowCount,1),r=t.parseClusterMatrix(o);e.injectTreeForGrid(n.grid,r,void 0,150,void 0)}),{description:"Perform hierarchical clustering to reveal relationships between sequences.",delay:2e3}).step("Select a sequence",(async()=>{i.selection.set(65,!0)}),{description:"Handling selection of data frame row reflecting on linked viewers.",delay:2e3}).step("Select a bunch of sequences",(async()=>{[67,72,77,82,83,84,85,91,93].forEach((t=>i.selection.set(t,!0))),i.currentRowIdx=27}),{description:"Selecting a group of rows from a data frame to show their similarity and proximity to each other on a viewer..",delay:2e3}).start()}catch(t){ue(t)}}()}async function bi(){await async function(){let t,e,n,i,s;const r=c.A.UMAP;try{const l=new he("Activity Cliffs","Activity Cliffs analysis on Macromolecules data");await l.step("Load DNA sequences",(async()=>{o.shell.windows.showContextPanel=!1,o.shell.windows.showProperties=!1,[n,t,e]=await Promise.all([fn.files.readCsv(Se),me(),pe()]),i=o.shell.addTableView(n),i.grid.props.rowHeight=22,i.grid.columns.byName("cluster").visible=!1,i.grid.columns.byName("sequence").width=300,i.grid.columns.byName("is_cliff").visible=!1}),{description:"Load dataset with macromolecules of 'fasta' notation, 'DNA' alphabet.",delay:2e3}).step("Find activity cliffs",(async()=>{const t=a.Func.find({name:"macromoleculePreprocessingFunction",package:"Bio"})[0];s=await Wn(n,n.getCol("Sequence"),n.getCol("Activity"),80,r,Ut.U.LEVENSHTEIN,t,{}),i.dockManager.dock(s,a.DOCK_TYPE.RIGHT,null,"Activity Cliffs",.35),ve()(s.root).find("button.scatter_plot_link,cliffs_grid").get()[0].click()}),{description:"Reveal similar sequences with a cliff of activity.",delay:2e3}).step("Cluster sequences",(async()=>{const s=a.TaskBarProgressIndicator.create("Running sequence clustering..."),o=await t.calcDistanceMatrix(n,["sequence"]),r=await fe(o.data,n.rowCount,1),l=t.parseClusterMatrix(r);s.close(),e.injectTreeForGrid(i.grid,l,void 0,150,void 0),i.grid.columns.byName("Activity").scrollIntoView()}),{description:"Perform hierarchical clustering to reveal relationships between sequences.",delay:2e3}).step("Browse the cliff",(async()=>{const t=s.dataFrame.temp[".cliffsDfGrid"];t.dataFrame.rowCount>0&&(t.dataFrame.currentRowIdx=0)}),{description:"Zoom in to explore selected activity cliff details.",delay:2e3}).start()}catch(t){ue(t)}}()}async function Ci(){await async function(){const t="HELM";let e,n,i;try{await new he("Atomic Level","Atomic level structure of Macromolecules").step("Loading Macromolecules notation 'Helm'",(async()=>{o.shell.windows.showContextPanel=!1,o.shell.windows.showProperties=!1,e=await fn.files.readCsv("samples/HELM.csv"),n=o.shell.addTableView(e);for(let e=0;e<n.grid.columns.length;e++){const i=n.grid.columns.byIndex(e);[t,"Activity"].includes(i.name)||(i.visible=!1)}}),{description:"Load dataset with macromolecules of 'fasta' notation, 'PT' alphabet (protein, aminoacids).",delay:2e3}).step("To atomic level",(async()=>{const n=e.getCol(t);await Un(e,n,!1)}),{description:"Get atomic level structures of Macromolecules.",delay:2e3}).step("Sketcher",(async()=>{const n=`molfile(${t})`;e.currentCell=e.cell(1,n);const s=e.currentCell.value,o=new a.chem.Sketcher(a.chem.SKETCHER_MODE.INPLACE);o.setMolFile(s),i=r.dialog().add(o).show(),await(0,_t.gw)(3e3),i.close()}),{description:"Display atomic level structure within a sketcher.",delay:2e3}).start()}catch(t){ue(t)}}()}async function wi(){await async function(){let t,e,n,i,s,r;const l="msa(HELM)",h=c.A.UMAP,u=(await Ae.lp.getDockerContainer()).id,d=Ae.lp.getDockerContainer();let m,p;try{const c=new he("Helm, MSA, Sequence Space","MSA and composition analysis on Helm data");await c.step("Load peptides with non-natural aminoacids in 'HELM' notation",(async()=>{[m,e]=await Promise.all([(async()=>(await d).status)(),fn.files.readCsv(xe)]),t=o.shell.addTableView(e),o.shell.windows.showContextPanel=!1,o.shell.windows.showProperties=!1,"started"===m||"checking"===m?(fn.logger.debug(`demoBio05UI(), PepSeA ('${Ae.lp.dcName}') docker container status = '${m}'.`),p=Promise.resolve()):(fn.logger.warning(`demoBio05UI(), PepSeA ('${Ae.lp.dcName}') docker container is trying to start...`),await o.dapi.docker.dockerContainers.run(u),p=async function(t,e,n=3e4,i){const s=window.performance.now(),r=new f.Subject,a=async()=>{const n=await o.dapi.docker.dockerContainers.find(t);return n.status===e&&r.next(n),n};let l;try{await(0,_t.zg)(r,(t=>{const n=window.performance.now();i.debug(`awaitStatus(), docker container ('${t.name}') GET status = '${e}' in ${n-s} ms.`)}),(async()=>{const t=await a();i.debug(`awaitStatus(), docker container ('${t.name}') HAS status = '${t.status}'.`),l=window.setInterval(a,200)}),n)}finally{window.clearInterval(l)}}(u,"started",3e4,fn.logger))}),{description:"Load dataset with macromolecules of 'Helm' notation.",delay:2e3}).step("Align peptides with non-natural aminoacids with PepSeA",(async()=>{const t=a.TaskBarProgressIndicator.create("MSA by PepSeA ...");try{await p,n=e.getCol("HELM");const t=Ae.Jy[0],s=1.53,r=0;if(i=await(0,Ae.f3)(n,l,t,s,r,void 0),!i)throw new Error("Empty MSA result.");e.columns.add(i),await o.data.detectSemanticTypes(e)}finally{t.close()}}),{description:"Multiple sequence alignment (MSA) performed with PepSeA tool operating on non-natural aminoacids as well.",delay:2e3}).step("Build sequence space",(async()=>{const n=a.Func.find({package:"Bio",name:"macromoleculePreprocessingFunction"})[0];r=await Vn(e,i,h,Ut.U.LEVENSHTEIN,!0,n),t.dockManager.dock(r,a.DOCK_TYPE.RIGHT,null,"Sequence Space",.35)}),{description:"Reduce sequence space dimensionality to display on 2D representation.",delay:2e3}).step("Analyse sequence composition",(async()=>{s=await e.plot.fromType("WebLogo",{sequenceColumnName:l,positionWidth:40,maxHeight:50}),t.dockManager.dock(s,a.DOCK_TYPE.DOWN,null,"Composition analysis",.2)}),{description:"Composition analysis allows to reveal functional features of sequences like motifs, or variable loops.",delay:2e3}).start()}catch(t){ue(t)}}()}async function vi(t,e){var n;He(n=e),n.setTag("units",Ct.r2.SEPARATOR),n.setTag("separator","-"),await o.data.detectSemanticTypes(t)}async function Si(t){const e=(0,nt.Xk)(t),n=JSON.stringify(e);a.Utils.download(`${t.name}.json`,n)}async function Ai(t,e,n){const i=await t.readAsString();await async function(t,e,n){const i=a.TaskBarProgressIndicator.create("detectMacromolecule probe ...");try{let s=0;const r=await o.functions.call("Bio:detectMacromoleculeEnableStore");let l=0;for(let c=0;c<n;++c){const h=a.DataFrame.fromCsv(t),u=e?h.getCol(e):h.columns.byIndex(0);await o.functions.call("Bio:detectMacromolecule",{col:u})!==a.SEMTYPE.MACROMOLECULE&&(++l,console.warn(`Reject reason: ${r.last.rejectReason}`));const d=c/n;d-s>=.1&&(s=d,i.update(100*d,`detectMacromolecule probe ${l}/${c}/${n} ...`),await(0,_t.gw)(0))}l>0?o.shell.warning(`detectMacromolecule failed ${l} / ${n}`):o.shell.info(`detectMacromolecule success ${n}`)}finally{i.close()}}(i,e,n)}},9017:(t,e,n)=>{"use strict";n.d(e,{k:()=>o});class i{constructor(){this.value=0,this.parentI=0,this.parentJ=0}}class s{constructor(t,e,n){this.seq1=t,this.seq2=e,this.score=n}}class o{fillNeedleman(){for(let t=0;t<=this.len1;t++)this.dpGrid[t][0].value=-t*this.gap,this.dpGrid[t][0].parentI=t-1,this.dpGrid[t][0].parentJ=0;for(let t=1;t<=this.len2;t++)this.dpGrid[0][t].value=-t*this.gap,this.dpGrid[0][t].parentI=0,this.dpGrid[0][t].parentJ=t-1}fillOne(t,e){this.dpGrid[t][e].value=Math.max(this.dpGrid[t-1][e-1].value+this.scores[t-1][e-1],Math.max(this.dpGrid[t-1][e].value-this.gap,this.dpGrid[t][e-1].value-this.gap)),this.dpGrid[t][e].value==this.dpGrid[t-1][e-1].value+this.scores[t-1][e-1]?(this.dpGrid[t][e].parentI=t-1,this.dpGrid[t][e].parentJ=e-1):this.dpGrid[t][e].value==this.dpGrid[t-1][e].value-this.gap?(this.dpGrid[t][e].parentI=t-1,this.dpGrid[t][e].parentJ=e):(this.dpGrid[t][e].parentI=t,this.dpGrid[t][e].parentJ=e-1)}gridFromName(t){switch(t){case"BLOSUM45":this.alignGrid=this.BLOSUM45,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM50":this.alignGrid=this.BLOSUM50,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM62":this.alignGrid=this.BLOSUM62,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM80":this.alignGrid=this.BLOSUM80,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM90":this.alignGrid=this.BLOSUM90,this.connections=this.CONBLO,this.step=1;break;case"PAM30":this.alignGrid=this.PAM30,this.connections=this.CONBLO,this.step=1;break;case"PAM70":this.alignGrid=this.PAM70,this.connections=this.CONBLO,this.step=1;break;case"PAM250":this.alignGrid=this.PAM250,this.connections=this.CONBLO,this.step=1;break;case"NUCLEOTIDES":this.alignGrid=this.NUCLEOTIDES,this.connections=this.CONNUCL,this.step=1;break;case"TRANS":this.alignGrid=this.TRANS,this.connections=this.CONNUCL,this.step=1;break;case"SCHNEIDER":this.alignGrid=this.SCHNEIDER,this.connections=this.CONSCHN,this.step=3}this.fillScores()}constructResult(t,e){let n="",i="",o="";const r=this.dpGrid[t][e].value;for(let t=0;t<this.step;t++)o+="|";for(;t>0||e>0;){this.dpGrid[t][e].parentI==t?(n=o+n,i=this.seq2.substr((e-1)*this.step,this.step)+i):this.dpGrid[t][e].parentJ==e?(i=o+i,n=this.seq1.substr((t-1)*this.step,this.step)+n):(n=t-1>=0?this.seq1.substr((t-1)*this.step,this.step)+n:o+n,i=e-1>=0?this.seq2.substr((e-1)*this.step,this.step)+i:o+i);const s=t;t=this.dpGrid[t][e].parentI,e=this.dpGrid[s][e].parentJ}return new s(n,i,r)}fillScores(){this.scores=[];for(let t=0;t<this.len1;t++){this.scores.push([]);for(let e=0;e<this.len2;e++)this.scores[t].push(this.alignGrid[this.connections[this.seq1.substr(t*this.step,this.step)]][this.connections[this.seq2.substr(e*this.step,this.step)]])}}typeRec(){if(/[ATGC]*/.test(this.seq1)&&/[ATGC]*/.test(this.seq2))return"NUCLEOTIDES";if(/[ARNDCQEGHILKMFPSTWYVBZX*]*/.test(this.seq1)&&/[ARNDCQEGHILKMFPSTWYVBZX*]*/.test(this.seq2))return"BLOSUM62";throw Error("Can't recognize sequence type")}needlemanWunch(){this.dpGrid=[];for(let t=0;t<this.len1+1;t++){const t=[];for(let e=0;e<this.len2+1;e++)t.push(new i);this.dpGrid.push(t)}this.fillNeedleman();for(let t=1;t<=this.len1;t++)for(let e=1;e<=this.len2;e++)this.fillOne(t,e);return this.constructResult(this.len1,this.len2)}smithWaterman(){this.dpGrid=[];for(let t=0;t<this.len1+1;t++){const t=[];for(let e=0;e<this.len2+1;e++)t.push(new i);this.dpGrid.push(t)}let t=0,e=0,n=0;for(let i=1;i<=this.len1;i++)for(let s=1;s<=this.len2;s++)this.fillOne(i,s),this.dpGrid[i][s].value<=0?(this.dpGrid[i][s].value=0,this.dpGrid[i][s].parentI=0,this.dpGrid[i][s].parentJ=0):0==this.dpGrid[this.dpGrid[i][s].parentI][this.dpGrid[i][s].parentJ].value&&(this.dpGrid[i][s].parentI=0,this.dpGrid[i][s].parentJ=0),this.dpGrid[i][s].value>t&&(t=this.dpGrid[i][s].value,e=i,n=s);return this.constructResult(e,n)}setSequences(t,e){this.seq1=t,this.seq2=e,this.len1=this.seq1.length/this.step,this.len2=this.seq2.length/this.step,this.fillScores()}setGap(t){this.gap=t}setMethod(t=""){"AUTO"==t&&(t=this.typeRec()),this.gridFromName(t)}constructor(t,e,n,i=""){this.seq1="",this.seq2="",this.gap=1,this.len1=0,this.len2=0,this.step=1,this.alignGrid=[],this.scores=[],this.dpGrid=[],this.connections={},this.BLOSUM45=[[5,-2,-1,-2,-1,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-2,-2,0,-1,-1,0,-5],[-2,7,0,-1,-3,1,0,-2,0,-3,-2,3,-1,-2,-2,-1,-1,-2,-1,-2,-1,0,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1,-14.8,-12.1,-18.9,-12.4,-17.4],[-8.5,.8,-9.1,-.7,-10.1,-7.5,-9.1,-8.2,-11.4,-3.1,-11.8,-4.4,-15.5,-14.3,-14.8,-15.4,-6.6,-4.7,-7.1,-5.8,-12.5,-10.3,-11,-12.2,-13.4,-10.6,-12.5,-11.8,-17.4,-15.1,-17.7,-15.7,2.9,12.5,3.1,10.3,-7.7,-5.2,-6.2,-7.3,-5.4,-1.7,-5.4,-3.7,-11.6,-9.1,-13,-10.8,-50,-10.3,-50,-11.2,-9.8,-8.3,-9.1,-9.7,-50,-12.7,-20.6,-13.1,-16,-16.6,-17,-18.4],[-5,-6.4,-3.4,-5.6,-7.5,-9.3,-7.1,-8.8,-8.8,-7.4,-6.9,-6.9,-11.4,-15.2,-9.7,-13.7,-1.8,-7.8,-.8,-7.2,-9.4,-10.6,-8.7,-11.2,-10,-10.1,-7.8,-10.5,-13.2,-14.6,-13,-14.5,9.2,3.1,10.8,3,-4.5,-6.7,-2.7,-6.7,-5,-6.8,-2.5,-6.7,-7.5,-10.4,-7.4,-10.2,-50,-15.5,-50,-14.2,-8.9,-10.2,-8.5,-10,-50,-15.6,-15.3,-15.5,-13,-18.8,-12.6,-18.3],[-8.1,-1.1,-8.9,1.4,-8.6,-9.2,-9.4,-6.8,-11,-4.9,-11.5,-2.6,-13.7,-16.8,-14.5,-12.6,-6,-6.7,-7.2,-4.2,-11.6,-11.9,-11.2,-10.9,-13.1,-12.2,-12.5,-10.3,-16.8,-17.2,-17.8,-14.6,3.5,10.3,3,12.4,-6.9,-7.5,-6.8,-4.9,-5.4,-4.2,-5.4,-1.3,-10.8,-11.5,-12.4,-8.2,-50,-12.5,-50,-8.9,-9.2,-10,-9.4,-7.9,-50,-14.3,-19.9,-11.4,-16.2,-19.2,-15.8,-15.9],[-6.3,-7.4,-8,-6,2.8,-.7,.9,.3,-7.5,-4.4,-8.4,-3.6,-3,-7.7,-3.7,-6.2,-5.3,-10,-7.2,-8.9,-.7,-3.2,-1.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.2],[-11.4,-10,-12.7,-8.2,-3.1,-3.1,-2.8,-.9,-11.7,-7.3,-12.1,-5.8,3.6,3.6,-1.1,5.8,-9.4,-11.9,-10.7,-10,-8.5,-8.8,-8.2,-6.5,-13.9,-13,-12.9,-10.9,-3.1,-2.3,-3.2,-.2,-9.5,-10.8,-10.2,-8.2,-1.1,-1.3,-.8,1.2,-8.6,-7.8,-7.8,-5,9,9.5,8.9,12,-50,-13,-50,-10.3,-6.2,-7,-7.1,-5.4,-50,-9.3,-14,-8.2,-2.4,-6.3,-2.4,-3.9],[-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,33.3,-50,30.6,-50,-50,-50,-50,-50,29.2,-50,-50,-50,-50,-50,-50,-50],[-14.8,-6.2,-14.9,-7.6,-14.6,-11.6,-13,-12.2,-14,-9,-14.1,-10.1,-13.6,-11.2,-12.4,-12.5,-8.1,2.2,-8.7,.4,-15.3,-11.3,-13.2,-13.3,-11.9,-7.2,-11.8,-7.9,-10.7,-7.4,-10.8,-8.9,-15.5,-10.3,-15.5,-12.5,-14.5,-12.1,-11.9,-12.8,-18.3,-12.7,-16.4,-14.7,-14.2,-10.4,-13.7,-13,-50,15.1,-50,13.3,-9.9,-5.8,-8.9,-7.6,-50,-1.5,-7.8,-3,-8.1,3.6,-9.4,2],[-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,30.6,-50,35.2,-50,-50,-50,-50,-50,28.5,-50,-50,-50,-50,-50,-50,-50],[-13.8,-7.5,-14.4,-5.1,-12.6,-11.6,-11.5,-10.1,-13.2,-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,-7.5,-5.5,-7.1,-50,-8.9,-50,-8.4,11,10.1,13.2,10.2,-50,-4.2,-6.1,-3.6,-3.5,-8.4,-1.2,-6.8],[-9.1,-5.4,-10.4,-4.2,1,.5,.6,2.4,-9.6,-1.5,-10.5,-.5,-8.9,-10.5,-7.2,-8.3,-6.3,-6.9,-7.7,-5.1,-.5,.1,-.6,2.3,-11.1,-10.2,-10.5,-7,-8.3,-9.4,-9.4,-6.6,-9.6,-9.7,-10,-7.9,.7,.6,.8,2.3,-7.1,-6.5,-7.2,-5,-6.5,-7.4,-7.5,-5.4,-50,-7.6,-50,-4.8,9.8,10,10.2,12.1,-50,-3.1,-11.4,-.7,-4.6,-6.6,-4.9,-3.9],[-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,29.2,-50,28.5,-50,-50,-50,-50,-50,33.3,-50,-50,-50,-50,-50,-50,-50],[-13,-7,-13.1,-8.3,-9.2,-6.5,-8.9,-7.6,-9.8,-.7,-9.2,-2.1,-12.4,-10.3,-12.4,-11.6,-9.5,-4.6,-10.4,-5.7,-13.6,-10.1,-11.4,-10.9,-6.5,-1.5,-6.2,-3.6,-12.8,-8,-12.3,-9.7,-16.5,-12.7,-15.6,-14.3,-8.7,-6,-7.1,-7.5,-9.5,-4.1,-8.4,-6.1,-11,-8.6,-11.3,-9.3,-50,-1.5,-50,-3,-4.8,-1.5,-4.2,-3.1,-50,16.4,-5.1,14.2,-10.1,-4.3,-10,-5.4],[-13.5,-16.3,-11.8,-15.5,-13.6,-15.3,-12.1,-16.1,-7.7,-13.3,-4.2,-12.6,-14.1,-16.2,-10.3,-15.4,-9.6,-11.6,-7.7,-9.8,-14.3,-17.5,-11.1,-17.2,-5.3,-7.1,-2.2,-7.1,-9.6,-11.9,-8.7,-11.4,-17.1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.8,-.9,14.2,-1.8,11.6],[-11.8,-13.1,-11.5,-12,-6.2,-8.3,-5.4,-7.4,-11.8,-12.3,-11.1,-11.4,.5,-2.5,2.4,-1.6,-6.8,-9.9,-6.4,-8.9,-6.1,-8.6,-5,-7.8,-10.4,-11.6,-8.5,-9.9,8.2,6.4,8.7,6.9,-12.4,-17,-12.6,-15.8,-6.5,-8.5,-5,-7.8,-13.2,-13.6,-10.3,-13.7,-.7,-3.2,-.3,-2.4,-50,-9.4,-50,-8.7,-2.1,-5.6,-1.2,-4.9,-50,-10,-4.5,-8.9,9.7,-1.8,11.3,-.9],[-17.2,-13.3,-17.8,-11.6,-11,-11.1,-10.4,-9,-16,-12.7,-16.1,-11.1,-5.2,-5.4,-6,-3.3,-11.8,-7.3,-13.3,-5.9,-12.7,-11.9,-11.9,-9.3,-15.2,-15,-14.9,-11,-2.8,-1.8,-2.9,.4,-17.4,-18.4,-18.3,-15.9,-10.7,-11.2,-10.6,-9,-15.4,-14.8,-15.8,-13.3,-6.8,-5.9,-7.2,-3.9,-50,2,-50,3.9,-7,-6.8,-6.8,-3.9,-50,-5.4,-7.3,-3.4,-.3,11.6,-.9,14.1]],this.TRANS=[[5,0,0,4],[0,5,4,0],[0,4,5,0],[4,0,0,5]],this.CONBLO={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},this.CONNUCL={A:0,T:1,C:2,G:3},this.CONSCHN={AAA:0,AAC:1,AAG:2,AAT:3,ACA:4,ACC:5,ACG:6,ACT:7,AGA:8,AGC:9,AGG:10,AGT:11,ATA:12,ATC:13,ATG:14,ATT:15,CAA:16,CAC:17,CAG:18,CAT:19,CCA:20,CCC:21,CCG:22,CCT:23,CGA:24,CGC:25,CGG:26,CGT:27,CTA:28,CTC:29,CTG:30,CTT:31,GAA:32,GAC:33,GAG:34,GAT:35,GCA:36,GCC:37,GCG:38,GCT:39,GGA:40,GGC:41,GGG:42,GGT:43,GTA:44,GTC:45,GTG:46,GTT:47,TAA:48,TAC:49,TAG:50,TAT:51,TCA:52,TCC:53,TCG:54,TCT:55,TGA:56,TGC:57,TGG:58,TGT:59,TTA:60,TTC:61,TTG:62,TTT:63},this.setMethod(i),this.setSequences(t,e),this.setGap(n)}}},7983:(t,e,n)=>{"use strict";n.d(e,{HV:()=>p,QF:()=>m,pf:()=>d,uH:()=>u});var i=n(4469),s=n(3870),o=n(976),r=n(7241),a=n(4293),l=n(8467),c=n(8447);const h="substr_helm";class u{constructor(t){this.col=t[0],this.createUI()}editHelmLinkAction(){(0,a.Y)(this.inputsDiv,this.grid.root),s.tools.waitForElementInDom(this.grid.root).then((()=>{setTimeout((()=>{this.grid.cell(h,0).element.children[0].dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"}))}),100)}))}updateInputs(){const t=this.units===c.r2.HELM?s.divV([this.columnsInput,this.editHelmLink]):this.units===c.r2.SEPARATOR?s.inputs([this.columnsInput,this.substructureInput,this.separatorInput]):s.inputs([this.columnsInput,this.substructureInput]);(0,a.Y)(this.inputsDiv,t)}updateNotationDiv(){this.units=this.col.getTag(o.TAGS.UNITS),this.separator=this.col.getTag("separator");const t=this.dialog.root.getElementsByClassName("notation-text")[0];t&&(t.textContent=`Notation: ${this.units}`)}createUI(){const t=i.shell.tv.dataFrame,e={filter:t=>t.semType===o.SEMTYPE.MACROMOLECULE};this.columnsInput=s.columnInput("Column",t,this.col,(t=>{this.col=t,this.updateNotationDiv(),this.updateInputs()}),e),this.substructureInput=s.stringInput("Substructure",""),this.editHelmLink=s.link("Edit helm",(()=>this.editHelmLinkAction()),void 0,{style:{position:"relative",left:"95px"}});const n=o.DataFrame.create(1);n.columns.addNewString(h).init((t=>"")),n.col(h).semType=this.col.semType,n.col(h).setTag(o.TAGS.UNITS,c.r2.HELM),this.grid=n.plot.grid(),this.separatorInput=s.stringInput("Separator",this.separator),this.inputsDiv=s.div(),this.units=this.col.getTag(o.TAGS.UNITS),this.separator=this.col.getTag("separator"),this.updateInputs(),this.dialog=s.dialog("Substructure Search").add(s.divV([s.divText(`Notation: ${this.units}`,"notation-text"),this.inputsDiv])).onOK((async()=>{let t,e=this.units===c.r2.HELM?n.get(h,0):this.substructureInput.value;this.units===c.r2.SEPARATOR&&this.separatorInput.value!==this.separator&&""!==this.separatorInput.value&&(e=e.replaceAll(this.separatorInput.value,this.separator)),t=this.units===c.r2.HELM?await m(e,this.col):d(e,this.col),this.col.dataFrame.filter.and(t)})).show()}}function d(t,e,n){const i=n?function(t,e){const n=`${e}`.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),i=t.charAt(0)===e,s=t.charAt(t.length-1)===e,o=t.replace(new RegExp(`^${n}|${n}$`,"g"),"");return i?s?`${n}${o}${n}`:`${n}${o}${n}|${n}${o}$`:s?`^${o}${n}|${n}${o}${n}`:`^${o}${n}|${n}${o}${n}|${n}${o}$`}(t,n):t,s=o.BitSet.create(e.length);for(let n=0;n<e.length;n++){const o=e.get(n);(o.match(i)||o===t)&&s.set(n,!0,!1)}return s}async function m(t,e){e.version!==e.temp["last-invalidated-version"]&&await p(e,!0);const n=o.Column.string("helm",1).init((e=>t));n.semType=o.SEMTYPE.MACROMOLECULE,n.setTag(o.TAGS.UNITS,c.r2.HELM);const s=await(0,r.D)(n,!0,e.temp["monomers-dict"]);return(await i.functions.call("Chem:searchSubstructure",{molStringsColumn:e.temp["monomeric-mols"],molString:s.get(0),molBlockFailover:""})).get(0)}async function p(t,e){const n=o.TaskBarProgressIndicator.create(`Invalidating molfiles for ${t.name}`);try{await(0,l.gw)(10);const n=new Map,i=await(0,r.D)(t,e,n);t.temp["monomeric-mols"]=i,t.temp["monomers-dict"]=n,t.temp["last-invalidated-version"]=t.version}finally{n.close()}}},2568:(t,e,n)=>{"use strict";n.d(e,{n:()=>r});var i=n(4469),s=n(976),o=n(499);function r(t,e,n=[],r=[],a=!0){const[l,c]=function(t,e,n=[],r=[]){let a=!0,l="";const c=o.Cn.getOrCreate(t);if(t.semType!==s.SEMTYPE.MACROMOLECULE)i.shell.warning(e+" analysis is allowed for Macromolecules semantic type"),a=!1;else{const t=c.notation;if(n.length>0&&!n.some((e=>t.toUpperCase()==e.toUpperCase())))l=`${e} + ' analysis is allowed for Macromolecules with notation ${0==n.length?"any notation":`notation${n.length>1?"s":""} ${n.map((t=>`"${t}"`)).join(", ")} `}.`,a=!1;else if(!c.isHelm()){const t=c.alphabet;r.length>0&&!r.some((e=>t.toUpperCase()==e.toUpperCase()))&&(l=`${e} + ' analysis is allowed for Macromolecules with alphabet ${0==r.length?"any alphabet":`alphabet${r.length>1?"s":""} ${r.map((t=>`"${t}"`)).join(", ")}.`}.`,a=!1)}}return[a,l]}(t,e,n,r);return a&&!l&&i.shell.warning(c),l}},3553:(t,e,n)=>{"use strict";n.d(e,{Of:()=>o,WY:()=>c,jB:()=>h,rs:()=>a});var i,s,o,r,a,l=n(8341);!function(t){t.SPLIT_COL="~split",t.ACTIVITY="~activity",t.ACTIVITY_SCALED="activity_scaled",t.ALIGNED_SEQUENCE="~aligned_sequence",t.AMINO_ACID_RESIDUE="AAR",t.POSITION="Pos",t.P_VALUE="pValue",t.MEAN_DIFFERENCE="Mean difference"}(i||(i={})),function(t){t.AAR="AAR",t.POSITION="Pos",t.SELECTION="selection"}(s||(s={})),function(t){t.MONOMER="Monomer",t.MACROMOLECULE_DIFFERENCE="MacromoleculeDifference",t.ACTIVITY="activity",t.ACTIVITY_SCALED="activityScaled"}(o||(o={})),function(t){t.CELL_CHANGING="isCellChanging"}(r||(r={})),function(t){t.SEPARATOR="."}(a||(a={}));const c="3.3.1",h={pepsea:{gapOpen:1.53,gapExtend:0,method:l.Jy[0]},kalign:{gapOpen:-1,gapExtend:-1,terminalGap:-1}}},4004:(t,e,n)=>{"use strict";n.d(e,{O:()=>d});var i=n(976),s=n(3870),o=n(4469),r=n(3336),a=n.n(r),l=n(8447),c=n(499);let h=null,u=[];function d(t){let e=t??o.shell.t.columns.bySemType("Macromolecule");if(!e)throw new Error("No column with Macromolecule semantic type found");let n=c.Cn.getOrCreate(e),r=n.notation;const d=s.divText("Current notation: "+r,{style:{"text-align":"center","font-weight":"bold","font-size":"14px",padding:"5px"}}),m=[l.r2.FASTA,l.r2.SEPARATOR,l.r2.HELM],p=s.columnInput("Column",o.shell.t,e,(t=>{t.semType===i.SEMTYPE.MACROMOLECULE?(e=t,n=c.Cn.getOrCreate(e),r=n.notation,r===l.r2.HELM&&(y.value="/"),d.textContent="Current notation: "+r,f=m.filter((t=>t!==r)),C=s.choiceInput("Convert to",f[0],f,b),b(),h?.clear(),h?.add(s.div([d,p.root,C.root,y.root]))):p.value=e})),g=["-",".","/"];let f=m.filter((t=>t!==r));const y=s.choiceInput("Separator",g[0],g),b=()=>{C.value!==l.r2.SEPARATOR?a()(y.root).hide():a()(y.root).show()};let C=s.choiceInput("Convert to",f[0],f,b);b(),C.onChanged((()=>{b()})),null==h&&(h=s.dialog("Convert Sequence Notation").add(s.div([d,p.root,C.root,y.root])).onOK((async()=>{const t=C.value,n=y.value??void 0;await async function(t,e,n){const i=c.Cn.getOrCreate(t).convert(e,n);t.dataFrame.columns.add(i);const s=await o.functions.call("Bio:detectMacromolecule",{col:i});return s&&(i.semType=s),await o.data.detectSemanticTypes(t.dataFrame),i}(e,t,n)})).show({x:350,y:100}),u.push(h.onClose.subscribe((t=>{u.forEach((t=>{t.unsubscribe()})),u=[],h=null}))))}},2918:(t,e,n)=>{"use strict";n.d(e,{NT:()=>w,cf:()=>b});var i=n(4469),s=n(3870),o=n(976),r=n(701),a=n(6584),l=n(922),c=n(1047);class h{constructor(t){this.rawLib=t}isValid(){return this.rawLib.every((t=>"object"==typeof t&&Object.values(c.Wc).every((e=>e in t&&"string"==typeof t[e]))))}getJsonMonomerLib(){const t=[];return this.rawLib.forEach((e=>{const n=this.prepareMonomer(e);t.push(n)})),t}prepareMonomer(t){const e={...c.Z2};Object.entries(c.Wc).forEach((([n,i])=>{const s=t[i];e[n]=s}));let n="smiles";const i=t[c.Wc[n]],s=new u(i),o=s.getCappedSmiles();return e[n]=o,n="rgroups",e[n]=d.getRGroups(s.getNumberOfRGroups()),n="molfile",e[n]=new m(s.getSmilesWithRGroups()).getMolfile(),e}}class u{constructor(t){let e=0;this.smilesWithRGroups=t.replace(/\[R(\d+)\]/g,((t,n)=>(++e,`[${n}*]`))),this.numberOfRGroups=e}getSmilesWithRGroups(){return this.smilesWithRGroups}getCappedSmiles(){return this.capRGroups()}getNumberOfRGroups(){return this.numberOfRGroups}capRGroups(){let t=this.smilesWithRGroups.replace("[1*]","[H:1]");return t=t.replace("[2*]","[OH:2]"),t.replace("[3*]","[H:3]")}}class d{constructor(){}static getRGroups(t){return c.nJ.slice(0,t)}}class m{constructor(t){this.smilesWithRGroups=t}getMolfile(){let t=o.chem.convert(this.smilesWithRGroups,o.chem.Notation.Smiles,o.chem.Notation.MolBlock);return t=this.restoreRGPLine(t),t=this.fixRGroupSymbols(t),t}restoreRGPLine(t){return t.replace("M ISO","M RGP")}fixRGroupSymbols(t){return t.replace(/\bR\b/g,"R#")}}var p=n(7228),g=n(4955);async function f(){return await Promise.all((await i.dapi.files.list(a.BX,!0,"")).map((async t=>t.fullPath.substring(a.BX.length))))}async function y(){const t=s.dialog({title:"Manage files"}).add(s.fileBrowser({path:"System:AppData/Bio/libraries"}).root).addButton("OK",(()=>t.close())).show()}async function b(){const t=s.button("Manage",y),e=s.inputs([]),n=await f(),r=await(0,a.nW)();for(const t of n){const n=s.boolInput(t,!r.exclude.includes(t),(()=>{1==n.value?r.exclude=r.exclude.filter((e=>e!=t)):r.exclude.includes(t)||r.exclude.push(t),(0,a.tW)(r).then((async()=>{await w.instance.loadLibraries(!0),i.shell.info("Monomer library user settings saved.")}))}));e.append(n.root)}return new o.Widget(s.divV([e,s.div(t)]))}class C{constructor(t,e){this._monomers={},this._onChanged=new r.Subject,this._monomers=t,this.error=e}getMonomer(t,e){return t in this._monomers&&e in this._monomers[t]?this._monomers[t][e]:null}getPolymerTypes(){return Object.keys(this._monomers)}getMonomerMolsByPolymerType(t){const e={};return Object.keys(this._monomers[t]??{}).forEach((n=>{e[n]=this._monomers[t][n].molfile})),e}getMonomerSymbolsByType(t){return Object.keys(this._monomers[t])}getMonomerSymbolsByRGroup(t,e,n){let i=this.getMonomerSymbolsByType(e).map((t=>this.getMonomer(e,t)));return i=i.filter((t=>null!==t)),0===i.length?[]:(i=i.filter((e=>{if(!e?.rgroups)return!1;let n=e?.rgroups.length>=t;return l._.getInstance(e.molfile).atomTypes.map(((t,e)=>"R#"===t?e:-1)).filter((t=>-1!==t)),n&&(n=!0),n})),i.map((t=>t?.symbol)))}get onChanged(){return this._onChanged}_updateInt(t){const e=t.getPolymerTypes(),n=this.getPolymerTypes();e.forEach((e=>{n.includes(e)||(this._monomers[e]={}),t.getMonomerSymbolsByType(e).forEach((n=>{this._monomers[e][n]=t.getMonomer(e,n)}))}))}update(t){this._updateInt(t),this._onChanged.next()}updateLibs(t,e=!1){e&&(this._monomers={});for(const e of t)e.error||this._updateInt(e);this._onChanged.next()}clear(){this._monomers={},this._onChanged.next()}}class w{constructor(){this._monomerLib=new C({}),this.loadLibrariesPromise=Promise.resolve()}getBioLib(){return this._monomerLib}async loadLibraries(t=!1){return this.loadLibrariesPromise=this.loadLibrariesPromise.then((async()=>{try{const[e,n]=await Promise.all([f(),(0,a.nW)()]),i=e.filter((t=>!n.exclude.includes(t))).filter((t=>!(n.explicit.length>0)||n.explicit.includes(t))),s=await Promise.all(i.map((t=>this.readLibrary(a.BX,t).catch((e=>{const n=`Loading monomers from '${t}' error: ${e instanceof Error?e.message:e.toString()}`;return new C({},n)})))));this._monomerLib.updateLibs(s,t)}catch(t){const e=`Loading monomer libraries error: ${t instanceof Error?t.message:t.toString()}`;i.shell.warning(e);const n=t instanceof Error?t.stack:void 0;g._package.logger.error(e,void 0,n)}}))}async readLibrary(t,e){let n,s,r=[];const a=new o.FileSource(t);if(e.endsWith(".sdf"))1===o.Func.find({package:"Chem",name:"importSdf"}).length?(n=await a.readAsBytes(e),s=await i.functions.call("Chem:importSdf",{bytes:n}),r=(0,p.Xk)(s[0])):i.shell.warning("Chem package is not installed");else if(e.endsWith(".json")){const t=await a.readAsText(e);r=JSON.parse(t)}else{if(!e.endsWith(".csv"))throw new Error("Monomer library of unknown file format, supported formats: SDF, JSON, CSV");{const t=(l=await a.readCsv(e),Array.from({length:l.rowCount},((t,e)=>l.columns.names().reduce(((t,n)=>(t[n]=l.get(n,e),t)),{})))),n=new h(t);if(!n.isValid())throw new Error("Invalid format of CSV monomer lib");r=n.getJsonMonomerLib()}}var l;const c={},u=[];return r.forEach((t=>{u.includes(t.polymerType)||(c[t.polymerType]={},u.push(t.polymerType)),c[t.polymerType][t.symbol]=t})),new C(c)}async selectSpecifiedLibraries(t){const e=await this.getInvalidFileNames(t);if(e.length>0)throw new Error(`Cannot select libraries ${e}: no such library in the list`);const n=await(0,a.nW)();n.exclude=(await f()).filter((e=>!t.includes(e))),await(0,a.tW)(n)}async getInvalidFileNames(t){const e=await f();return t.filter((t=>!e.includes(t)))}static get instance(){return window.$monomerLibHelper||(window.$monomerLibHelper=new w),window.$monomerLibHelper}}},525:(t,e,n)=>{"use strict";n.d(e,{K:()=>L});var i=n(4469),s=n(976),o=n(3870),r=n(8447),a=n(499),l=n(6098),c=n(8341),h=n(2568),u=n(3553),d=n(4955),m=n(3379),p=n.n(m),g=n(7795),f=n.n(g),y=n(569),b=n.n(y),C=n(3565),w=n.n(C),v=n(9216),S=n.n(v),A=n(4589),x=n.n(A),T=n(9564),I={};I.styleTagTransform=x(),I.setAttributes=w(),I.insert=b().bind(null,"head"),I.domAPI=f(),I.insertStyleElement=S(),p()(T.Z,I),T.Z&&T.Z.locals&&T.Z.locals;class M extends Error{constructor(t,e){super(t,e)}}async function L(t={}){return new Promise((async(e,n)=>{var r,a,l;t.clustersCol??(t.clustersCol=null),t.pepsea??(t.pepsea={}),(r=t.pepsea).method??(r.method=u.jB.pepsea.method),(a=t.pepsea).gapOpen??(a.gapOpen=u.jB.pepsea.gapOpen),(l=t.pepsea).gapExtend??(l.gapExtend=u.jB.pepsea.gapExtend);const h=t.col?.dataFrame??i.shell.t,d=t.col??h.columns.bySemType(s.SEMTYPE.MACROMOLECULE);if(null==d){const t="MSAError: dataset doesn't conain any Macromolecule column";i.shell.warning(t),n(new M(t))}const m=o.choiceInput("Method",t.pepsea.method,c.Jy);m.setTooltip("Alignment method");const p=o.floatInput("Terminal gap",t?.kalign?.terminalGap??null);p.setTooltip("Penalty for opening a gap at the beginning or end of the sequence");const g=o.p(`Kalign version: ${u.WY}`,"kalign-version"),f=o.floatInput("Gap open",t.pepsea.gapOpen);f.setTooltip("Gap opening penalty at group-to-group alignment");const y=o.floatInput("Gap extend",t.pepsea.gapExtend);y.setTooltip("Gap extension penalty to skip the alignment");const b=o.inputs([f,y,p]),C=o.button("Alignment parameters",(()=>{b.hidden=!b.hidden}),"Adjust alignment parameters such as penalties for opening and extending gaps");C.classList.add("msa-params-button"),b.hidden=!0,C.prepend(o.icons.settings((()=>null)));const w=[m.root.style],v=[p.root.style,g.style];let S;const A=o.columnInput("Sequence",h,d,(async()=>{S=await N(A.value,h,w,v,m,x,f,y,p)}),{filter:t=>t.semType===s.SEMTYPE.MACROMOLECULE});A.setTooltip("Sequences column to use for alignment");const x=o.columnInput("Clusters",h,t.clustersCol);if(x.nullable=!0,A.fireChanged(),t.col)return S=await N(t.col,h,w,v,m,x,f,y,p),void await E(A,h,S,e,n);o.dialog("MSA").add(A).add(x).add(m).add(b).add(C).add(g).onOK((async()=>{await E(A,h,S,e,n)})).show()}))}async function E(t,e,n,o,r){let a=null;const l=s.TaskBarProgressIndicator.create("Analyze for MSA ...");try{if(t.fireChanged(),t.value.semType!==s.SEMTYPE.MACROMOLECULE)throw new Error("Chosen column has to be of Macromolecule semantic type");if(void 0===n)throw new Error("Invalid column format");if(a=await n(),null==a)return r("PepSeA container has not started");e.columns.add(a),await i.data.detectSemanticTypes(e),o(a)}catch(t){const e=t instanceof Error?t.message:t.toString();i.shell.error(e),r(t)}finally{l.close()}}async function N(t,e,n,o,m,p,g,f,y){try{if(t.semType!==s.SEMTYPE.MACROMOLECULE)return;const i=e.columns.getUnusedName(`msa(${t.name})`);if((0,h.n)(t,t.name,[r.r2.FASTA,r.r2.SEPARATOR],["DNA","RNA","PT"],!1)){R(n,o,"kalign"),g.value=null,f.value=null,y.value=null;const e=a.Cn.getOrCreate(t),s=e.isFasta()?t:e.convert(r.r2.FASTA);return async()=>await(0,l.U)(s,!1,i,p.value)}if((0,h.n)(t,t.name,[r.r2.HELM],[],!1))return R(n,o,"pepsea"),g.value??(g.value=u.jB.pepsea.gapOpen),f.value??(f.value=u.jB.pepsea.gapExtend),async()=>await(0,c.f3)(t,i,m.value,g.value,f.value,p.value);if((0,h.n)(t,t.name,[r.r2.SEPARATOR],["UN"],!1)){const e=a.Cn.getOrCreate(t).convert(r.r2.HELM);return R(n,o,"pepsea"),g.value??(g.value=u.jB.pepsea.gapOpen),f.value??(f.value=u.jB.pepsea.gapExtend),async()=>await(0,c.f3)(e,i,m.value,g.value,f.value,p.value)}return g.value=null,f.value=null,y.value=null,void R(n,o,"kalign")}catch(t){const e=t instanceof Error?t.message:t.toString();i.shell.error(e),d._package.logger.error(e)}}function R(t,e,n){if("kalign"===n){for(const e of t)e.display="none";for(const t of e)t.removeProperty("display")}else{for(const t of e)t.display="none";for(const e of t)e.removeProperty("display")}}},6098:(t,e,n)=>{"use strict";n.d(e,{U:()=>P});var i=n(976),s=n(5226);const o=Symbol("Comlink.proxy"),r=Symbol("Comlink.endpoint"),a=Symbol("Comlink.releaseProxy"),l=Symbol("Comlink.thrown"),c=t=>"object"==typeof t&&null!==t||"function"==typeof t,h=new Map([["proxy",{canHandle:t=>c(t)&&t[o],serialize(t){const{port1:e,port2:n}=new MessageChannel;return u(t,e),[n,[n]]},deserialize:t=>(t.start(),m(t))}],["throw",{canHandle:t=>c(t)&&l in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){throw t.isError?Object.assign(new Error(t.value.message),t.value):t.value}}]]);function u(t,e=self){e.addEventListener("message",(function n(i){if(!i||!i.data)return;const{id:s,type:r,path:a}=Object.assign({path:[]},i.data),c=(i.data.argumentList||[]).map(w);let h;try{const e=a.slice(0,-1).reduce(((t,e)=>t[e]),t),n=a.reduce(((t,e)=>t[e]),t);switch(r){case"GET":h=n;break;case"SET":e[a.slice(-1)[0]]=w(i.data.value),h=!0;break;case"APPLY":h=n.apply(e,c);break;case"CONSTRUCT":h=function(t){return Object.assign(t,{[o]:!0})}(new n(...c));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;u(t,n),h=function(t,e){return b.set(t,e),t}(e,[e])}break;case"RELEASE":h=void 0;break;default:return}}catch(t){h={value:t,[l]:0}}Promise.resolve(h).catch((t=>({value:t,[l]:0}))).then((t=>{const[i,o]=C(t);e.postMessage(Object.assign(Object.assign({},i),{id:s}),o),"RELEASE"===r&&(e.removeEventListener("message",n),d(e))}))})),e.start&&e.start()}function d(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function m(t,e){return g(t,[],e)}function p(t){if(t)throw new Error("Proxy has been released and is not useable")}function g(t,e=[],n=function(){}){let i=!1;const s=new Proxy(n,{get(n,o){if(p(i),o===a)return()=>v(t,{type:"RELEASE",path:e.map((t=>t.toString()))}).then((()=>{d(t),i=!0}));if("then"===o){if(0===e.length)return{then:()=>s};const n=v(t,{type:"GET",path:e.map((t=>t.toString()))}).then(w);return n.then.bind(n)}return g(t,[...e,o])},set(n,s,o){p(i);const[r,a]=C(o);return v(t,{type:"SET",path:[...e,s].map((t=>t.toString())),value:r},a).then(w)},apply(n,s,o){p(i);const a=e[e.length-1];if(a===r)return v(t,{type:"ENDPOINT"}).then(w);if("bind"===a)return g(t,e.slice(0,-1));const[l,c]=y(o);return v(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:l},c).then(w)},construct(n,s){p(i);const[o,r]=y(s);return v(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:o},r).then(w)}});return s}function f(t){return Array.prototype.concat.apply([],t)}function y(t){const e=t.map(C);return[e.map((t=>t[0])),f(e.map((t=>t[1])))]}const b=new WeakMap;function C(t){for(const[e,n]of h)if(n.canHandle(t)){const[i,s]=n.serialize(t);return[{type:"HANDLER",name:e,value:i},s]}return[{type:"RAW",value:t},b.get(t)||[]]}function w(t){switch(t.type){case"HANDLER":return h.get(t.name).deserialize(t.value);case"RAW":return t.value}}function v(t,e,n){return new Promise((i=>{const s=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.addEventListener("message",(function e(n){!n.data||!n.data.id||n.data.id!==s||(t.removeEventListener("message",e),i(n.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:s},e),n)}))}const S="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0ICQ9U3ltYm9sKCJDb21saW5rLnByb3h5IiksQT1TeW1ib2woIkNvbWxpbmsuZW5kcG9pbnQiKSxSPVN5bWJvbCgiQ29tbGluay5yZWxlYXNlUHJveHkiKSx5PVN5bWJvbCgiQ29tbGluay50aHJvd24iKSxfPWU9PnR5cGVvZiBlPT0ib2JqZWN0IiYmZSE9PW51bGx8fHR5cGVvZiBlPT0iZnVuY3Rpb24iLEw9e2NhbkhhbmRsZTplPT5fKGUpJiZlWyRdLHNlcmlhbGl6ZShlKXtjb25zdHtwb3J0MTpyLHBvcnQyOml9PW5ldyBNZXNzYWdlQ2hhbm5lbDtyZXR1cm4gdyhlLHIpLFtpLFtpXV19LGRlc2VyaWFsaXplKGUpe3JldHVybiBlLnN0YXJ0KCksQyhlKX19LE89e2NhbkhhbmRsZTplPT5fKGUpJiZ5IGluIGUsc2VyaWFsaXplKHt2YWx1ZTplfSl7bGV0IHI7c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m1vZHVsZS5GUyxzPWAvJHtyLnRvb2x9YCxvPWAke3QuY29uZmlnLmRpclNoYXJlZH0ke3N9YDshaS5hbmFseXplUGF0aChzKS5leGlzdHN8fGUuYW5hbHl6ZVBhdGgobykuZXhpc3RzfHwodC5fbG9nKGBNb3VudGluZyAke3N9IG9udG8gJHt0LmJhc2UudG9vbH0gZmlsZXN5c3RlbSBhdCAke299YCksZS5ta2RpcihvKSxlLm1vdW50KHQuYmFzZS5tb2R1bGUuUFJPWFlGUyx7cm9vdDpzLGZzOml9LG8pKX19LF9maWxlb3AoZSxyKXt0Ll9sb2coYFJ1bm5pbmcgJHtlfSAke3J9YCk7Y29uc3QgaT10LmZzLmFuYWx5emVQYXRoKHIpO2lmKCFpLmV4aXN0cylyZXR1cm4gdC5fbG9nKGBGaWxlICR7cn0gbm90IGZvdW5kLmApLCExO3N3aXRjaChlKXtjYXNlImNhdCI6cmV0dXJuIHQuZnMucmVhZEZpbGUocix7ZW5jb2Rpbmc6InV0ZjgifSk7Y2FzZSJscyI6cmV0dXJuIHQuZnMuaXNGaWxlKGkub2JqZWN0Lm1vZGUpP3QuZnMuc3RhdChyKTp0LmZzLnJlYWRkaXIocik7Y2FzZSJkb3dubG9hZCI6Y29uc3Qgcz1uZXcgQmxvYihbdGhpcy5jYXQocildKTtyZXR1cm4gVVJMLmNyZWF0ZU9iamVjdFVSTChzKX1yZXR1cm4hMX0sX2xvZyhlKXtpZighdC5jb25maWcuZGVidWcpcmV0dXJuO2xldCByPVsuLi5hcmd1bWVudHNdO3Iuc2hpZnQoKSxjb25zb2xlLmxvZyhgJWNbV2ViV29ya2VyXSVjICR7ZX1gLCJmb250LXdlaWdodDpib2xkIiwiIiwuLi5yKX19O3codCl9KSgpOwo=",A=typeof window<"u"&&window.Blob&&new Blob([atob(S)],{type:"text/javascript;charset=utf-8"});function x(){const t=A&&(window.URL||window.webkitURL).createObjectURL(A);try{return t?new Worker(t):new Worker("data:application/javascript;base64,"+S)}finally{t&&(window.URL||window.webkitURL).revokeObjectURL(t)}}const T={urlCDN:"https://biowasm.com/cdn/v3",urlCDNStg:"https://stg.biowasm.com/cdn/v3",dirShared:"/shared",dirMounted:"/mnt",dirData:"/data",printInterleaved:!0,callback:null,debug:!1,env:"prd"};class I{constructor(t,e={}){if(null==t)throw"Expecting array of tools as input to Aioli constructor.";return Array.isArray(t)||(t=[t]),e=Object.assign({},T,e),t=t.map(this._parseTool),"stg"===e.env&&(e.urlCDN=e.urlCDNStg),this.tools=t,this.config=e,null!=this.config.callback&&(this.callback=this.config.callback),delete this.config.callback,this.init()}async init(){const t=new x;this.callback&&(t.onmessage=t=>{"biowasm"===t.data.type&&this.callback(t.data.value)});const e=m(t);return e.tools=this.tools,e.config=this.config,await e.init(),e}_parseTool(t){if("string"!=typeof t)return t;const e=t.split("/");if(2!=e.length&&3!=e.length)throw"Expecting '<tool>/<version>' or '<tool>/<program>/<version>'";return{tool:e[0],program:3==e.length?e[1]:e[0],version:e[e.length-1]}}}var M=n(850);class L{static getAvailableScales(){return Object.entries(this.scales).map((([t,e])=>t))}static getScale(t){return(0,M.hu)(!(void 0===this.scales[t]),`Scale '${t}' was not found.`),this.scales[t]}}L.scales={WimleyWhite:{"-":0,A:.17,C:-.24,D:-.07,E:-.01,F:-1.13,G:.01,H:.17,I:-.31,K:.99,L:-.56,M:-.23,N:.42,P:.45,Q:.58,R:.81,S:.13,T:.14,V:.07,W:-1.85,Y:-.94},categorial:{"-":0,A:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,K:9,L:10,M:11,N:12,P:13,Q:14,R:15,S:16,T:17,V:18,W:19,Y:20}};class E{constructor(t="categorial"){this.aa2num=L.getScale(t),this.num2aa={},Object.entries(this.aa2num).forEach((([t,e])=>this.num2aa[e]=t))}static _truncateSequence(t){let e=0,n=t.length;const i=["NH2","COOH"];if(t.startsWith(i[0])){const n=i[0].length;(0,M.hu)("-"==t[n],`Wrong sequence format: ${i[0]} without following '-' in '${t}'.`),e=n}if(t.endsWith(i[1])){const e=i[1].length+1;(0,M.hu)("-"==t[n-e],`Wrong sequence format: ${i[1]} without '-' precending in '${t}'.`),n-=e}return t.substring(e,n)}static _dropDefises(t){return t.replace(/(-)([^-]+)/g,"$2")}static clean(t){return E._dropDefises(E._truncateSequence(t))}encode(t){const e=t.length,n=new Array(e).fill(0);for(let i=0;i<e;++i){const e=t[i];(0,M.hu)(e in this.aa2num,`Unknown char '${e}' found in sequence '${t}'`),n[i]=this.encodeLettter(e)}return n}encodeLettter(t){return this.aa2num[t]}decode(t){let e="";for(let n=0;n<t.length;++n){const i=t[n];(0,M.hu)(i in this.num2aa,`Unknown code '${i}' found in vector '${t}'`),e+=this.num2aa[i]}return e}}var N=n(3553);const R="input.fa",_="result.fasta";function O(t){return t.reduce(((t,e,n)=>t+`>sample${n+1}\n${e}\n`),"")}async function P(t,e=!1,n="",o=null,r,a,l){let c=t.toList();e&&(c=c.map((t=>E.clean(t).replace(/\-/g,""))));const h=t.length;o??(o=i.Column.string("Clusters",h).init("0")),o.type!=i.COLUMN_TYPE.STRING&&(o=o.convertTo(i.TYPE.STRING)),o.compact();const u=o.categories,d=o.getRawData(),m=new Array(u.length),p=new Array(u.length);for(let t=0;t<h;++t){const e=d[t];(m[e]??(m[e]=[])).push(c[t]),(p[e]??(p[e]=[])).push(t)}const g=await new I(["base/1.0.0",{tool:"kalign",version:N.WY,reinit:!0}]),f=i.Column.string(n,h);for(let t=0;t<u.length;++t){const e=O(m[t]);await g.fs.writeFile(R,e);const n=`${void 0!==r?` --gpo ${r}`:""}${void 0!==a?` --gpe ${a}`:""}${void 0!==l?` --tgpe ${l}`:""}`,i=await g.exec(`kalign ${R} -f fasta -o ${_}${n}`);console.warn(i);const o=await g.cat(_);if(!o)throw new Error("kalign output no result");const c=new s.i(o).sequencesArray,h=p[t];for(let t=0;t<c.length;++t)f.set(h[t],c[t])}const y=t.getTag(i.TAGS.UNITS),b=t.getTag("alphabet");return f.setTag(i.TAGS.UNITS,y),f.setTag("aligned","SEQ.MSA"),f.setTag("alphabet",b),f.semType=i.SEMTYPE.MACROMOLECULE,f}},8341:(t,e,n)=>{"use strict";n.d(e,{Jy:()=>l,f3:()=>h,lp:()=>a});var i=n(4469),s=n(976),o=n(8447),r=n(3553);const a=new class{constructor(){this.dcName="bio"}async getDockerContainer(){return await i.dapi.docker.dockerContainers.filter(this.dcName).first()}},l=["mafft --auto","mafft","linsi","ginsi","einsi","fftns","fftnsi","nwns","nwnsi"],c=["AlignedSeq","AlignedSubpeptide","HELM","ID","PolymerID"];async function h(t,e,n="ginsi",l=1.53,h=0,d=null){const m=await a.getDockerContainer();if("started"!==m.status&&"checking"!==m.status)return i.log.warning("PepSeA container has not started yet"),null;const p=t.length;d??(d=s.Column.int("Clusters",p).init(0)),d.type!=s.COLUMN_TYPE.STRING&&(d=d.convertTo(s.TYPE.STRING));const g=d.categories,f=new Array(g.length);for(let e=0;e<p;++e){const n=d.get(e);if(""===n)continue;const i=g.indexOf(n),s=t.get(e);s&&(f[i]??(f[i]=[])).push({ID:e.toString(),HELM:s})}const y=new Array(p);for(const t of f){const e=(await u(m.id,t,n,l,h)).Alignment;for(const t of e)y[parseInt(t.ID)]=Object.entries(t).filter((t=>!c.includes(t[0]))).map((t=>"-"!==t[1]?t[1]:"")).join(r.rs.SEPARATOR)}const b=s.Column.fromStrings(e,y);return b.setTag(s.TAGS.UNITS,o.r2.SEPARATOR),b.setTag("separator",r.rs.SEPARATOR),b.setTag("aligned","SEQ.MSA"),b.setTag("alphabet","UN"),b.setTag(".alphabetIsMultichar","true"),b.semType=s.SEMTYPE.MACROMOLECULE,b}async function u(t,e,n,s,o){const r={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)},a=`/align?method=${n}&gap_open=${s}&gap_extend=${o}`,l=await i.dapi.docker.dockerContainers.request(t,a,r);return JSON.parse(l??"{}")}},9953:(t,e,n)=>{"use strict";n.d(e,{M:()=>i});const i="<All>"},9943:(t,e,n)=>{"use strict";n.d(e,{C2:()=>u});var i=n(976),s=n(3870),o=n(4469),r=n(6414),a=n.n(r),l=n(8447),c=n(499);const h=60;function u(){const t=o.shell.tv.grid,e=a().count(0).take(t.columns.length).map((e=>t.columns.byIndex(e))).filter((t=>!!t.column&&t.column.semType!==i.SEMTYPE.MACROMOLECULE)).toArray(),n=e.find((t=>-1!==t.name.toLowerCase().indexOf("id"))),r=n?[n.name]:[],u=s.multiChoiceInput("Seq id columns",r,e.map((t=>t.name))),m=a().count(0).take(t.columns.length).map((e=>t.columns.byIndex(e))).filter((t=>{const e=t.column;return!(!e||e.semType!==i.SEMTYPE.MACROMOLECULE)&&c.Cn.getOrCreate(e).isFasta()})).toArray(),p=m.length>0?m[0].name:[],g=s.choiceInput("Seq column",p,m.map((t=>t.name))),f=s.intInput("FASTA line width",h);s.dialog({title:"Save as FASTA"}).add(s.inputs([u,g,f])).onOK((()=>{const e=u.value?u.value.map((e=>t.columns.byName(e).column)):[],n=g.value?t.columns.byName(g.value).column:null,i=f.value??h;n||o.shell.warning("Seq column is mandatory to save as FASTA.");const s=function(t,e,n=h,i="\n"){const s=l.kB,o=[];for(let r=0;r<e.length;r++){const a=t.map((t=>t.get(r).toString())).join("|"),l=d(e.get(r),s,n);o.push(`>${a}${i}`);for(const t of l)o.push(`${t}${i}`)}return"".concat(...o)}(e,n,i),r=document.createElement("a");r.setAttribute("href",`data:text/plain;charset=utf-8,${encodeURIComponent(s)}`),r.setAttribute("download",`${t.dataFrame.name}.fasta`),r.click()})).show()}function d(t,e,n=h){const i=e(t);let s=0;const o=i.length,r=[];for(;s<o;){const t=a()(i).slice(s,s+n).toArray(),e=t.map((t=>t.length>1?`[${t}]`:t)).join("");r.push(e),s+=t.length}return r}},9416:(t,e,n)=>{"use strict";n.d(e,{n:()=>c});var i=n(4469),s=n(976),o=n(8467),r=n(2568),a=n(8457),l=n(3553);async function c(t,e){if(await(0,o.gw)(10),!(0,r.n)(e,"Sequence space"))return t;const n=(0,a.O)(e);n.name="splitToMonomers";const c=e.dataFrame;for(const t of n.columns)t.semType=l.Of.MONOMER,t.setTag("alphabet",e.getTag("alphabet"));const h=/(\d+)(?: \((\d+)\))?/,u=t=>{h.lastIndex=0;const e=t.match(h);return e?`${e[1]} (${parseInt(e[2]??0)+1})`:t};for(let t=0;t<n.columns.length;t++){const i=n.columns.byIndex(t);i.semType=l.Of.MONOMER,i.setTag("alphabet",e.getTag("alphabet"));const s=100;let o=0;for(;c.columns.byName(i.name)&&o<s;)i.name=u(i.name),o++;c.columns.add(i)}await i.data.detectSemanticTypes(c);for(let t=0;t<n.columns.length;t++){const e=n.columns.byIndex(t);e.setTag(s.TAGS.CELL_RENDERER,"Monomer"),e.setTag(".use-as-filter","false")}return c}},4293:(t,e,n)=>{"use strict";n.d(e,{B:()=>o,Y:()=>r});var i=n(4469),s=n(976);function o(){const t=i.shell.t.columns.bySemTypeAll(s.SEMTYPE.MACROMOLECULE);if(null!==t)return t;i.shell.error("Current table does not contain macromolecules")}function r(t,e){t.innerHTML="",t.append(e)}},8415:(t,e,n)=>{"use strict";n.d(e,{bo:()=>C,OZ:()=>M});var i=n(4469),s=n(3870),o=n(976),r=n(3336),a=n.n(r),l=n(6414),c=n.n(l),h=n(701),u=n(499),d=n(8447),m=n(9298);function p(t){var e;return"string"==typeof t||t instanceof String?t:("object"==typeof t||t instanceof Object)&&"$thrownJsError"in t?p(t.$thrownJsError):t instanceof Error?null!==(e=t.stack)&&void 0!==e?e:t.message:t.toString()}var g=n(7945),f=n(8467),y=n(172);var b,C,w=n(8770),v=n(4955);HTMLCanvasElement.prototype.getCursorPosition=function(t,e){const n=this.getBoundingClientRect();return new o.Point((t.clientX-n.left)*e,(t.clientY-n.top)*e)},o.Rect.prototype.contains=function(t,e){return this.left<=t&&t<=this.right&&this.top<=e&&e<=this.bottom};class S{constructor(t=0,e){this.valueList=null,this.valueIdx=0,this.value=this.rowCount=t,this.bounds=e}push(t){this.valueList||(this.valueList=new Array(this.rowCount),this.valueIdx=0),this.valueList[this.valueIdx]=t,++this.valueIdx}aggregate(t){this.value=t(this.valueList)??0,this.valueList=null}}class A{get label(){return this._label?this._label:this.name}constructor(t,e,n,i){this.sumRowCount=0,this.pos=t,this.name=e,this._freqs=n??{},i?.sumRowCount&&(this.sumRowCount=i.sumRowCount),i?.sumValueForHeight&&(this.sumPlotValue=i.sumValueForHeight),i?.label&&(this._label=i.label)}getMonomers(){return Object.keys(this._freqs)}hasMonomer(t){return t in this._freqs}getFreq(t){let e=this._freqs[t];return e||(e=this._freqs[t]=new S),e}aggregate(t){const e=function(t){return e=>{const n=function(t){let e;const n="agg";return e=t instanceof Float32Array?o.Column.fromFloat32Array(n,t):t instanceof Int32Array?o.Column.fromInt32Array(n,t):o.Column.fromList(o.COLUMN_TYPE.FLOAT,n,t),e}(e);return n.aggregate(t)}}(t);for(const[t,n]of Object.entries(this._freqs))n.aggregate(e)}getMinValue(){return Math.min(...Object.values(this._freqs).map((t=>t.value)))}calcPlotValue(t){for(const e of Object.values(this._freqs))e.plotValue=e.value-t}calcHeights(t){this.sumPlotValue=0;for(const t of Object.values(this._freqs))this.sumPlotValue+=t.plotValue;if(this.sumPlotValueForHeight=0,t===m.ES.Entropy){const t=Object.keys(this._freqs).length,e=.01*this.sumPlotValue,n=e/t;for(const t of Object.values(this._freqs)){const i=(t.plotValue+n)/(this.sumPlotValue+e);this.sumPlotValueForHeight+=-i*Math.log2(i)}}else if(t===m.ES.full)for(const[t,e]of Object.entries(this._freqs)){const t=e.plotValue/this.sumPlotValue;this.sumPlotValueForHeight+=t}}calcScreen(t,e,n,i,s,r,a,l,c,h){const u=s===m.ES.Entropy?i*(r-this.sumPlotValueForHeight)/r:i;let d=h*c+(i-u-1);const p=Object.entries(this._freqs).sort(((e,n)=>t(e[0])||t(n[0])?t(e[0])&&t(n[0])?0:t(e[0])?-1:1:n[1].value-e[1].value));for(const[t,i]of p){const t=u*i.plotValue/this.sumPlotValue;i.bounds=new o.Rect((e-n)*c*a,d,l*c,t),d+=t}}render(t,e,n,i,s,o){for(const[r,a]of Object.entries(this._freqs))if(!e(r)){const e=(0,d.GU)(r,5),l=a.bounds,c=l.left;t.resetTransform(),t.strokeStyle="lightgray",t.lineWidth=1,t.rect(c,l.top,l.width,l.height),t.fillStyle=o.get(r)??o.get("other"),t.textAlign="left",t.font=n;const h=t.measureText(e);t.setTransform(l.width/h.width,0,0,l.height/s,c,l.top),t.fillText(e,0,-i)}}getMonomerAt(t,e){const n=Object.entries(this._freqs).find((([n,i])=>i.bounds.contains(t,e)));return n?n[0]:void 0}buildCompositionTable(t){return(0,w._)(t,Object.assign({},...Object.entries(this._freqs).map((([t,e])=>({[t]:e.rowCount})))))}}!function(t){t.STYLE="Style",t.BEHAVIOR="Behavior",t.LAYOUT="Layout",t.DATA="Data"}(b||(b={})),function(t){t.sequenceColumnName="sequenceColumnName",t.valueAggrType="valueAggrType",t.valueColumnName="valueColumnName",t.startPositionName="startPositionName",t.endPositionName="endPositionName",t.skipEmptySequences="skipEmptySequences",t.skipEmptyPositions="skipEmptyPositions",t.shrinkEmptyTail="shrinkEmptyTail",t.backgroundColor="backgroundColor",t.positionHeight="positionHeight",t.positionWidth="positionWidth",t.verticalAlignment="verticalAlignment",t.horizontalAlignment="horizontalAlignment",t.fixWidth="fixWidth",t.fitArea="fitArea",t.minHeight="minHeight",t.maxHeight="maxHeight",t.showPositionLabels="showPositionLabels",t.positionMarginState="positionMarginState",t.positionMargin="positionMargin",t.filterSource="filterSource"}(C||(C={}));const x=m.vS;var T;!function(t){t[t.None=0]="None",t[t.Render=1]="Render",t[t.Layout=1]="Layout",t[t.Freqs=2]="Freqs"}(T||(T={}));const I=new class{constructor(){this.render=20}};class M extends o.JsViewer{get positionWidthWithMargin(){return this._positionWidthWithMargin}get Length(){return this.skipEmptyPositions?this.positions.length:this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0}get positionMarginValue(){return this.positionMarginState===m.dE.AUTO&&!0===this.unitsHandler.getAlphabetIsMultichar()||this.positionMarginState===m.dE.ON?this.positionMargin:0}constructor(){super(),this.viewed=!1,this.initialized=!1,this.palette=null,this.seqCol=null,this.positions=[],this.visibleSlider=!1,this.allowResize=!0,this.turnOfResizeForOneSetValue=!1,this.backgroundColor=4294967295,this.positionMargin=0,this.positionNames=[],this.positionLabels=void 0,this.startPosition=-1,this.endPosition=-1,this.error=null,this.viewerId=++M.viewerCounter,this.setDataInProgress=!1,this.viewSubs=[],this._onSizeChanged=new h.Subject,this._onFreqsCalculated=new h.Subject,this._onLayoutCalculated=new h.Subject,this.requestedRenderLevel=T.Freqs,this.renderRequest=new h.Subject,this._onRendered=new h.Subject,this.textBaseline="top",this.unitsHandler=null,this.sequenceColumnName=this.string(C.sequenceColumnName,x.sequenceColumnName,{category:b.DATA});const t=[o.AGG.KEY,o.AGG.PIVOT,o.AGG.MISSING_VALUE_COUNT,o.AGG.SKEW,o.AGG.KURT,o.AGG.SELECTED_ROWS_COUNT],e=Object.values(o.AGG).filter((e=>!t.includes(e)));this.valueAggrType=this.string(C.valueAggrType,x.valueAggrType,{category:b.DATA,choices:e}),this.valueColumnName=this.string(C.valueColumnName,x.valueColumnName,{category:b.DATA}),this.startPositionName=this.string(C.startPositionName,x.startPositionName,{category:b.DATA}),this.endPositionName=this.string(C.endPositionName,x.endPositionName,{category:b.DATA}),this.skipEmptySequences=this.bool(C.skipEmptySequences,x.skipEmptySequences,{category:b.DATA}),this.skipEmptyPositions=this.bool(C.skipEmptyPositions,x.skipEmptyPositions,{category:b.DATA}),this.shrinkEmptyTail=this.bool(C.shrinkEmptyTail,x.shrinkEmptyTail,{category:b.DATA}),this.backgroundColor=this.int(C.backgroundColor,x.backgroundColor,{category:b.STYLE}),this.positionHeight=this.string(C.positionHeight,x.positionHeight,{category:b.STYLE,choices:Object.values(m.ES)}),this._positionWidth=this.positionWidth=this.float(C.positionWidth,x.positionWidth,{category:b.STYLE}),this.verticalAlignment=this.string(C.verticalAlignment,x.verticalAlignment,{category:b.LAYOUT,choices:Object.values(m.vw)}),this.horizontalAlignment=this.string(C.horizontalAlignment,x.horizontalAlignment,{category:b.LAYOUT,choices:Object.values(m.iD)}),this.fixWidth=this.bool(C.fixWidth,x.fixWidth,{category:b.LAYOUT,userEditable:!1}),this.fitArea=this.bool(C.fitArea,x.fitArea,{category:b.LAYOUT}),this.minHeight=this.float(C.minHeight,x.minHeight,{category:b.LAYOUT}),this.maxHeight=this.float(C.maxHeight,x.maxHeight,{category:b.LAYOUT}),this.showPositionLabels=this.bool(C.showPositionLabels,x.showPositionLabels,{category:b.LAYOUT}),this.positionMarginState=this.string(C.positionMarginState,x.positionMarginState,{category:b.LAYOUT,choices:Object.values(m.dE)});let n=0;"auto"===this.positionMarginState&&(n=4),this.positionMargin=this.int(C.positionMargin,n,{category:b.LAYOUT,min:0,max:16}),this.filterSource=this.string(C.filterSource,x.filterSource,{category:b.BEHAVIOR,choices:Object.values(m.Ct)}),this.slider=s.rangeSlider(0,100,0,20,!1,{style:"barbell"}),this.canvas=s.canvas(),this.canvas.classList.value="bio-wl-canvas",this.canvas.style.width="100%",this.viewSyncer=new y.c(v._package.logger)}viewerToLog(){return`MolstarViewer<${this.viewerId}>`}setData(){const t=`${this.viewerToLog()}.setData()`;v._package.logger.debug(`${t}, in`),this.viewSyncer.sync(`${t}`,(async()=>{if(!this.setDataInProgress){this.setDataInProgress=!0;try{this.viewed&&(this.renderRequestSub.unsubscribe(),await this.destroyView(),this.viewed=!1),this.updateSeqCol(),this.updateEditors(),this.viewed||(await this.buildView(),this.viewed=!0)}finally{this.setDataInProgress=!1}}})),v._package.logger.debug(`${t}, out`)}async destroyView(){for(const t of this.viewSubs)t.unsubscribe();this.viewSubs=[];const t=this.dataFrame?"data":"null";v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.destroyView( dataFrame = ${t} ) start`),this.host.remove(),this.msgHost=void 0,this.host=void 0,v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.destroyView() end`)}async buildView(){const t=this.dataFrame?"data":"null";v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.buildView( dataFrame = ${t} ) start`),window.devicePixelRatio,this.viewSubs.push(o.debounce(this.renderRequest,I.render).subscribe(this.renderRequestOnDebounce.bind(this))),this.helpUrl="/help/visualize/viewers/web-logo.md",this.msgHost=s.div("No message",{classes:"bio-wl-msg"}),this.msgHost.style.display="none",this.canvas=s.canvas(),this.canvas.style.width="100%",this.slider.root.style.position="absolute",this.slider.root.style.zIndex="999",this.slider.root.style.display="none",this.slider.root.style.height="0.7em",this.visibleSlider=!1,this.host=s.div([this.msgHost,this.canvas],{classes:"bio-wl-host",style:{display:"flex",flexDirection:"row",flexWrap:"wrap"}}),this.root.append(this.host),this.root.append(this.slider.root),this.error&&(this.msgHost.innerText=this.error.message,s.tooltip.bind(this.msgHost,this.error.stack),this.msgHost.style.setProperty("display",null)),this.dataFrame&&(this.viewSubs.push(this.dataFrame.filter.onChanged.subscribe(this.dataFrameFilterOnChanged.bind(this))),this.viewSubs.push(this.dataFrame.selection.onChanged.subscribe(this.dataFrameSelectionOnChanged.bind(this)))),this.viewSubs.push(s.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),this.viewSubs.push(this.slider.onValuesChanged.subscribe(this.sliderOnValuesChanged.bind(this))),this.viewSubs.push((0,h.fromEvent)(this.canvas,"mousemove").subscribe(this.canvasOnMouseMove.bind(this))),this.viewSubs.push((0,h.fromEvent)(this.canvas,"mousedown").subscribe(this.canvasOnMouseDown.bind(this))),this.viewSubs.push((0,h.fromEvent)(this.canvas,"wheel").subscribe(this.canvasOnWheel.bind(this))),this.render(T.Freqs,"buildView"),v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.buildView() end`)}rootOnSizeChanged(){v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.rootOnSizeChanged(), start `),this.render(T.Layout,"rootOnSizeChanged")}updateEditors(){this.props.getProperty(C.valueColumnName).choices=c()(this.dataFrame.columns.numerical).map((t=>t.name)).toArray()}updateSeqCol(){if(this.dataFrame&&(this.seqCol=this.sequenceColumnName?this.dataFrame.col(this.sequenceColumnName):null,null==this.seqCol&&(this.seqCol=(0,d.up)(this.dataFrame),this.sequenceColumnName=this.seqCol?this.seqCol.name:null),this.seqCol)){try{this.unitsHandler=u.Cn.getOrCreate(this.seqCol),this.palette=(0,d.dQ)(this.seqCol),this.render(T.Freqs,"updateSeqCol()"),this.error=null}catch(t){throw this.seqCol=null,this.error=t instanceof Error?t:new Error(t.toString()),t}this.seqCol||(this.unitsHandler=null,this.positionNames=[],this.positionLabels=[],this.startPosition=-1,this.endPosition=-1,this.palette=null)}}getFilter(){let t;switch(this.filterSource){case m.Ct.Filtered:t=this.dataFrame.filter;break;case m.Ct.Selected:t=0===this.dataFrame.selection.trueCount?this.dataFrame.filter:this.dataFrame.selection}return t}setSliderVisibility(t){t?(this.slider.root.style.display="inherit",this.visibleSlider=!0):(this.slider.root.style.display="none",this.visibleSlider=!1)}calcLayout(t){this.host&&this.canvas&&this.slider&&(this.host.classList.remove("bio-wl-fixWidth","bio-wl-fitArea"),this.canvas.classList.remove("bio-wl-fixWidth","bio-wl-fitArea"),this._positionWidth=this.positionWidth,this._positionMargin=this.positionMargin,this._positionWidthWithMargin=this._positionWidth+this.positionMarginValue,this.fixWidth?this.calcLayoutFixWidth(t):this.fitArea?this.calcLayoutFitArea(t):this.calcLayoutNoFitArea(t),this.slider.root.style.width=`${this.host.clientWidth}px`)}calcLayoutFixWidth(t){if(!this.host||!this.canvas||!this.slider)return;this.host.classList.add("bio-wl-fixWidth"),this.canvas.classList.add("bio-wl-fitArea");const e=this._positionWidthWithMargin*this.Length,n=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight);this.host.style.justifyContent=m.iD.LEFT,this.host.style.removeProperty("margin-left"),this.host.style.removeProperty("margin-top"),this.host.style.width=this.canvas.style.width=`${e}px`,this.host.style.height=this.canvas.style.height=`${n}px`,this.host.style.left=this.canvas.style.left="0",this.host.style.top=this.canvas.style.top="0",this.host.style.setProperty("overflow","hidden","important"),this.slider.root.style.display="none",this.slider.setValues(0,Math.max(0,this.Length-1),0,Math.max(0,this.Length-1)),this.canvas.width=e*t,this.canvas.height=n*t}calcLayoutNoFitArea(t){if(!this.host||!this.canvas||!this.slider)return;const e=this._positionWidthWithMargin*this.Length,n=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight),i=Math.min(this.root.clientWidth,e);this.canvas.style.width=`${i}px`,this.canvas.style.height=`${n}px`,this.host.style.width=`${i}px`,this.host.style.height=`${this.root.clientHeight}px`,this.host.style.justifyContent=this.horizontalAlignment,this.host.style.alignContent=this.verticalAlignment===m.vw.TOP?"start":this.verticalAlignment===m.vw.MIDDLE?"center":this.verticalAlignment===m.vw.BOTTOM?"end":"inherit",this.root.clientHeight<this.minHeight&&(this.host.style.alignContent="start",this.host.style.width=`${i+6}px`),this.host.style.width=`${this.host}px`;const s=e>i;if(this.setSliderVisibility(s),s){this.slider.root.style.removeProperty("display"),this.host.style.justifyContent="left",this.host.style.height=this.root.clientHeight-this.slider.root.offsetHeight+"px",this.slider.root.style.top=`${this.host.offsetHeight}px`;let t=Math.min(Math.max(0,this.slider.min),this.Length-.001),e=Math.min(Math.max(0,this.slider.max),this.Length-.001);const n=this.root.clientWidth/this._positionWidthWithMargin;e=Math.min(Math.max(t,0)+n,this.Length-.001),t=Math.max(0,Math.min(e,this.Length-.001)-n),this.slider.setValues(0,Math.max(this.Length-.001),t,e)}else this.slider.setValues(0,Math.max(0,this.Length-.001),0,Math.max(0,this.Length-.001));this.canvas.width=i*t,this.canvas.height=n*t}calcLayoutFitArea(t){if(!this.host||!this.canvas||!this.slider)return;const e=this._positionWidth*this.Length,n=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight),i=e>0?(this.root.clientWidth-this.positionMarginValue*this.Length)/e:0,s=this.root.clientHeight/n,o=Math.max(1,Math.min(i,s));this._positionWidth=this.positionWidth*o,this._positionWidthWithMargin=this._positionWidth+this.positionMarginValue;const r=(this._positionWidth+this.positionMarginValue)*this.Length,a=o*n,l=Math.min(this.root.clientWidth,r);this.canvas.style.width=`${l}px`,this.canvas.style.height=`${a}px`,this.host.style.width=`${l}px`,this.host.style.height=`${this.root.clientHeight}px`,this.host.style.justifyContent=this.horizontalAlignment,this.host.style.alignContent=this.verticalAlignment===m.vw.TOP?"start":this.verticalAlignment===m.vw.MIDDLE?"center":this.verticalAlignment===m.vw.BOTTOM?"end":"inherit",this.root.clientHeight<this.minHeight&&(this.host.style.alignContent="start",this.host.style.width=`${l+6}px`),this.host.style.width=`${this.host}px`;const c=r>l;if(this.setSliderVisibility(c),c){this.slider.root.style.removeProperty("display"),this.host.style.justifyContent="left",this.host.style.height=this.root.clientHeight-this.slider.root.offsetHeight+"px",this.slider.root.style.top=`${this.host.offsetHeight}px`;let t=Math.min(Math.max(0,this.slider.min),this.Length-.001),e=Math.min(Math.max(0,this.slider.max),this.Length-.001);const n=this.root.clientWidth/this._positionWidthWithMargin;e=Math.min(Math.max(t,0)+n,this.Length-.001),t=Math.max(0,Math.min(e,this.Length-.001)-n),this.slider.setValues(0,Math.max(0,this.Length-.001),t,e)}else this.slider.setValues(0,Math.max(0,this.Length-.001),0,Math.max(0,this.Length-.001));this.canvas.width=l*t,this.canvas.height=a*t}onPropertyChanged(t){switch(super.onPropertyChanged(t),t.name){case C.sequenceColumnName:this.updateSeqCol();break;case C.sequenceColumnName:case C.startPositionName:case C.endPositionName:case C.filterSource:case C.shrinkEmptyTail:case C.skipEmptyPositions:case C.positionHeight:case C.valueColumnName:case C.valueAggrType:this.render(T.Freqs,`onPropertyChanged( ${t.name} )`);break;case C.minHeight:case C.maxHeight:case C.positionWidth:case C.showPositionLabels:case C.fixWidth:case C.fitArea:case C.horizontalAlignment:case C.verticalAlignment:case C.positionMargin:case C.positionMarginState:this.render(T.Layout,`onPropertyChanged(${t.name})`);break;case C.backgroundColor:this.render(T.Render,`onPropertyChanged(${t.name})`)}}onTableAttached(){v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.onTableAttached(), `),super.onTableAttached(),this.setData()}detach(){const t=`${this.viewerToLog()}.detach()`;v._package.logger.debug(`${t}, in`);const e=super.detach.bind(this);this.viewSyncer.sync(`${t}`,(async()=>{this.setDataInProgress||(this.viewed&&(await this.destroyView(),this.viewed=!1),e())})),v._package.logger.debug(`${t}, out`)}get onSizeChanged(){return this._onSizeChanged}get onFreqsCalculated(){return this._onFreqsCalculated}get onLayoutCalculated(){return this._onLayoutCalculated}getMonomer(t,e){const n=t.x,i=Math.floor(t.x/(this._positionWidthWithMargin*e)+Math.floor(this.slider.min)),s=this.positions[i];if(!s)return[null,null,null];const o=s.getMonomerAt(n,t.y);return void 0===o?[s,null,null]:[s,o,s.getFreq(o)]}_nullSequence(t="X"){return this.skipEmptySequences?"":new Array(this.Length).fill(t).join("")}_removeEmptyPositions(){this.skipEmptyPositions&&(this.positions=c()(this.positions).filter((t=>{const e=this.unitsHandler.defaultGapSymbol;return!t.hasMonomer(e)||t.getFreq(e).rowCount!==t.sumRowCount})).toArray())}render(t,e){v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render( recalcLevelVal=${t}, reason='${e}' )`),this.requestedRenderLevel=Math.max(this.requestedRenderLevel,t),this.renderRequest.next(this.requestedRenderLevel)}async renderInt(t){if(v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.renderInt( renderLevel=${t} ), start `),this.msgHost&&(this.seqCol&&!this.palette?(this.msgHost.innerText=`Unknown palette (column semType: '${this.seqCol.semType}').`,this.msgHost.style.display=""):this.msgHost.style.display="none"),!this.seqCol||!this.dataFrame||!this.palette||null==this.host||null==this.slider)return;const e=window.devicePixelRatio,n=this.showPositionLabels?12:0;if(t>=T.Freqs&&(()=>{if(v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateFreqsInt(), start `),!this.host||!this.seqCol||!this.dataFrame)return;const t=this.getFilter(),e=0===t.trueCount?this.unitsHandler.maxLength:c().enumerate(this.unitsHandler.splitted).map((([e,n])=>t.get(n)&&e?e.length:0)).reduce(((t,e)=>Math.max(t,e)),0),n=this.seqCol.getTag(".positionNames"),i=this.seqCol.getTag(".positionLabels");this.positionNames=n?n.split(d.CI).map((t=>t.trim())):[...Array(e).keys()].map((t=>`${t+1}`)),this.positionLabels=i?i.split(d.CI).map((t=>t.trim())):void 0,this.startPosition=this.startPositionName&&this.positionNames&&this.positionNames.includes(this.startPositionName)?this.positionNames.indexOf(this.startPositionName):0,this.endPosition=this.endPositionName&&this.positionNames&&this.positionNames.includes(this.endPositionName)?this.positionNames.indexOf(this.endPositionName):e-1;const s=this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0;this.unitsHandler=u.Cn.getOrCreate(this.seqCol);const r=this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0;this.positions=new Array(r);for(let t=0;t<s;t++){const e=this.positionNames[this.startPosition+t],n=this.positionLabels?this.positionLabels[this.startPosition+t]:void 0;this.positions[t]=new A(this.startPosition+t,e,{},{label:n})}const a=this.dataFrame.rowCount,l=this.unitsHandler.splitted;for(let e=0;e<s;++e){for(let n=0;n<a;++n)if(t.get(n)){const t=l[n][this.startPosition+e]||this.unitsHandler.defaultGapSymbol,i=this.positions[e],s=i.getFreq(t);++i.sumRowCount,s.value=++s.rowCount}if(this.valueAggrType===o.AGG.TOTAL_COUNT)continue;let n=null;try{n=this.dataFrame.getCol(this.valueColumnName),n.matches("numerical")||(n=null)}catch{n=null}if(n){for(let i=0;i<a;++i)if(t.get(i)){const t=l[i][this.startPosition+e]||this.unitsHandler.defaultGapSymbol,s=n.get(i);this.positions[e].getFreq(t).push(s)}this.positions[e].aggregate(this.valueAggrType)}}const h=this.valueAggrType===o.AGG.TOTAL_COUNT?0:Math.min(0,Math.min(...this.positions.map((t=>t.getMinValue()))));for(let t=0;t<s;++t)this.positions[t].calcPlotValue(h),this.positions[t].calcHeights(this.positionHeight);this._removeEmptyPositions(),this._onFreqsCalculated.next()})(),this.calcLayout(e),-1===this.startPosition)return;const s=Math.max(Math.floor(this.slider.min),0),r=Math.min(this.positions.length-1,Math.floor(this.slider.max));t>=T.Layout&&((t,e,n,s)=>{v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateLayoutInt(), start `);const r=this.canvas.height-s*n;let a;if(this.valueAggrType===o.AGG.TOTAL_COUNT){const t=this.getAlphabetSize();this.positionHeight==m.ES.Entropy&&null==t&&i.shell.error("WebLogo: alphabet is undefined."),a=Math.log2(t)}else a=Math.max(...c().count(t).takeWhile((t=>t<=e)).map((t=>this.positions[t].sumPlotValueForHeight)));for(let i=t;i<=e;++i)i in this.positions?this.positions[i].calcScreen((t=>this.unitsHandler.isGap(t)),i,this.slider.min,r,this.positionHeight,a,this._positionWidthWithMargin,this._positionWidth,n,s):v._package.logger.warning(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateLayoutInt() this.positions.length = ${this.positions.length}, jPos = ${i}`);v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateLayoutInt(), end `),this._onLayoutCalculated.next()})(s,r,window.devicePixelRatio,n);const a=this.canvas.getContext("2d");if(a){a.save();try{this.Length,a.resetTransform(),a.fillStyle=function(t){const e=o.Color.a(t);return`#${(16777215&t).toString(16).padStart(6,"0")}`+e.toString(16).padStart(2,"0")}(this.backgroundColor),a.fillRect(0,0,this.canvas.width,this.canvas.height),a.textBaseline=this.textBaseline;const t=10*e;a.resetTransform(),a.fillStyle="black",a.textAlign="center",a.font=`${t.toFixed(1)}px Roboto, Roboto Local, sans-serif`,n>0&&this.positions.length>0&&function(t,e,n,i,s,o,r,a){t.save();try{t.textAlign="center";let l=null,c=null;for(let e=Math.floor(r);e<=Math.floor(a);e++){const n=o[e],i=t.measureText(n.name),s=i.actualBoundingBoxDescent-i.actualBoundingBoxAscent;l=null===l?i.width:Math.max(l,i.width),c=null===c?s:Math.max(c,s)}const h=l<i*e-2?1:(i*e-2)/l;for(let l=Math.floor(r);l<=Math.floor(a);l++){const a=o[l],u=(l-r)*n*e+i*e/2,d=(s*e-c)/2;t.setTransform(h,0,0,1,u,d),t.measureText(a.label),t.fillText(a.label,0,0)}}finally{t.restore()}}(a,e,this._positionWidthWithMargin,this._positionWidth,n,this.positions,this.slider.min,this.slider.max);const i="16px Roboto, Roboto Local, sans-serif",l=.25,c=12.2;for(let t=s;t<=r;t++)this.positions[t].render(a,(t=>this.unitsHandler.isGap(t)),i,l,c,this.palette)}finally{a.restore()}v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.renderInt( recalcLevel=${t} ), end`)}}renderRequestOnDebounce(t){const e=`${this.viewerToLog()}.renderRequestOnDebounce()`;"HTML"!==a()(this.root).offsetParent().get()[0]?.tagName?(this.requestedRenderLevel=T.None,this.renderInt(t).catch((t=>{const[e,n]=(0,g.yf)(t);v._package.logger.error(e,void 0,n)}))):v._package.logger.warning(`${e}, $(this.root).offsetParent() is the 'HTML' tag.`)}getAlphabetSize(){return this.unitsHandler?.getAlphabetSize()??0}sliderOnValuesChanged(t){try{const t={minRange:this.slider.minRange,min:this.slider.min,max:this.slider.max,maxRange:this.slider.maxRange};v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.sliderOnValuesChanged( ${JSON.stringify(t)} ), start`),this.render(T.Layout,"sliderOnValuesChanged")}catch(t){const e=p(t);v._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.sliderOnValuesChanged() error:\n`+e)}}dataFrameFilterOnChanged(t){v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameFilterChanged()`);try{this.filterSource===m.Ct.Filtered&&this.render(T.Freqs,"dataFrameFilterOnChanged")}catch(t){const e=p(t);v._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameFilterOnChanged() error:\n`+e)}}dataFrameSelectionOnChanged(t){v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameSelectionOnChanged()`);try{this.filterSource===m.Ct.Selected&&this.render(T.Freqs,"dataFrameSelectionOnChanged")}catch(t){const e=p(t);v._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameSelectionOnChanged() error:\n`+e)}}canvasOnMouseMove(t){const e=window.devicePixelRatio;try{const n=t,i=this.canvas.getCursorPosition(n,e),[r,a]=this.getMonomer(i,e),l=this.showPositionLabels?12*e:0;if(null!==r&&null===a&&0<=i.y&&i.y<=l){const t=[s.divText(`Position ${r.label}`)];this.valueAggrType===o.AGG.TOTAL_COUNT&&t.push(r.buildCompositionTable(this.palette));const e=s.divV(t);s.tooltip.show(e,n.x+16,n.y+16)}else if(null!==r&&a&&this.dataFrame&&this.seqCol&&this.unitsHandler){const t=r.getFreq(a),e=[s.div(`${a}`),s.div(`${t.rowCount} rows`)];this.valueAggrType!==o.AGG.TOTAL_COUNT&&e.push(s.div(`${this.valueAggrType}: ${t.value.toFixed(3)}`));const i=s.divV(e);s.tooltip.show(i,n.x+16,n.y+16)}else s.tooltip.hide()}catch(t){const e=p(t);v._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.canvasOnMouseMove() error:\n`+e)}}canvasOnMouseDown(t){try{const e=t,n=window.devicePixelRatio,[i,s]=this.getMonomer(this.canvas.getCursorPosition(e,n),n);if(null!==i&&null!==s&&this.dataFrame&&this.seqCol&&this.unitsHandler){const t=o.BitSet.create(this.dataFrame.selection.length,(t=>function(t,e,n,i,s,o){const r=e.splitted[i],a=o.pos<r.length?r[o.pos]:null;return a===s||""===a&&s===e.defaultGapSymbol}(this.dataFrame,this.unitsHandler,this.getFilter(),t,s,i)));this.dataFrame.selection.init((e=>t.get(e)))}}catch(t){const e=p(t);v._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.canvasOnMouseDown() error:\n`+e)}}canvasOnWheel(t){const e=window.devicePixelRatio;try{if(!this.visibleSlider)return;const n=this.canvas.width/(this._positionWidthWithMargin*e),i=t.deltaY/100*Math.max(Math.floor(n/5),1);this.slider.scrollBy(this.slider.min+i)}catch(t){const e=p(t);v._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.canvasOnWheel() error:\n`+e)}}get onRendered(){return this._onRendered}invalidate(){const t=`${this.viewerToLog()}.invalidate()`;this.viewSyncer.sync(`${t}`,(async()=>{this.invalidate(),this._onRendered.next()}))}async awaitRendered(t=5e3){await(0,f.zg)(this.onRendered,(()=>{}),(()=>{this.invalidate()}),t)}}M.residuesSet="nucleotides",M.viewerCounter=-1},6099:(t,e,n)=>{"use strict";n.d(e,{ST:()=>f});var i=n(3870),s=n(976),o=n(4469),r=n(6414),a=n.n(r),l=n(701),c=n(442),h=n(8447),u=n(7945),d=n(8467),m=n(7983),p=n(4293),g=n(4955);class f extends s.Filter{get calculating(){return"initial"==this.loader.style.display}set calculating(t){this.loader.style.display=t?"initial":"none"}get filterSummary(){return this.bioFilter.substructure}get isFiltering(){return super.isFiltering&&""!==this.bioFilter.substructure}get isReadyToApplyFilter(){return!this.calculating&&null!=this.bitset}get _debounceTime(){if(null==this.column)return 1e3;const t=this.column.length;return t<500?0:t>1e4?1e3:Math.floor((t-500)/9500*1e3)}constructor(){super(),this.bioFilter=null,this.bitset=null,this.loader=i.loader(),this.notation=void 0,this.root=i.divV([]),this.calculating=!1}attach(t){super.attach(t),this.column=t.columns.bySemType(s.SEMTYPE.MACROMOLECULE),this.columnName??(this.columnName=this.column?.name),this.notation??(this.notation=this.column?.getTag(s.TAGS.UNITS)),this.bioFilter=this.notation===h.r2.FASTA?new b:this.notation===h.r2.SEPARATOR?new C(this.column.getTag("separator")):new w,this.root.appendChild(this.bioFilter.filterPanel),this.root.appendChild(this.loader),this.onBioFilterChangedSubs?.unsubscribe();let e=this.bioFilter.onChanged;e=e.pipe((0,c.debounceTime)(this._debounceTime)),this.onBioFilterChangedSubs=e.subscribe((async t=>await this._onInputChanged())),this.subs.push(o.events.onResetFilterRequest.subscribe((t=>{this.bioFilter?.resetFilter()})))}detach(){this.bioFilter&&this.bioFilter.detach(),super.detach()}applyFilter(){this.bitset&&!this.isDetached&&this.dataFrame?.filter.and(this.bitset)}saveState(){const t=super.saveState();return t.bioSubstructure=this.bioFilter?.substructure,t}applyState(t){super.applyState(t),t.bioSubstructure&&(this.bioFilter.substructure=t.bioSubstructure);const e=this;t.bioSubstructure&&setTimeout((function(){e._onInputChanged()}),1e3)}async _onInputChanged(){if(g._package.logger.debug("Bio: BioSubstructureFilter._onInputChanged(), start"),this.isFiltering){if(a()(this.dataFrame.rows.filters).has(`${this.columnName}: ${this.filterSummary}`))return;this.calculating=!0;try{this.bitset=await(this.bioFilter?.substructureSearch(this.column)),this.calculating=!1,this.dataFrame?.rows.requestFilter()}finally{this.calculating=!1}}else this.bitset=null,this.dataFrame?.rows.requestFilter()}}class y{constructor(){this.onChanged=new l.Subject}get filterPanel(){return new HTMLElement}async substructureSearch(t){return null}}class b extends y{constructor(){super(),this.substructureInput=i.stringInput("","",(()=>{this.onChanged.next()}),{placeholder:"Substructure"})}get filterPanel(){return this.substructureInput.root}get substructure(){return this.substructureInput.value}set substructure(t){this.substructureInput.value=t}async substructureSearch(t){return(0,m.pf)(this.substructure,t)}resetFilter(){this.substructureInput.value=""}detach(){}}class C extends b{constructor(t){super(),this.colSeparator="",this.separatorInput=i.stringInput("","",(()=>{this.onChanged.next()}),{placeholder:"Separator"}),this.colSeparator=t,this.separatorInput.value=t}get filterPanel(){return i.divV([this.substructureInput.root,this.separatorInput.root])}get substructure(){return this.separatorInput.value&&this.separatorInput.value!==this.colSeparator?this.substructureInput.value.replaceAll(this.separatorInput.value,this.colSeparator):this.substructureInput.value}set substructure(t){this.substructureInput.value=t}async substructureSearch(t){return(0,m.pf)(this.substructure,t,this.colSeparator)}detach(){}}class w extends y{constructor(){super(),this._filterPanel=i.div("",{style:{cursor:"pointer"}}),this.helmSubstructure="",this.viewSubs=[],this.init()}async init(){let t,e;this.helmEditor=await o.functions.call("Helm:helmWebEditor"),await i.tools.waitForElementInDom(this._filterPanel),this.updateFilterPanel(),this.viewSubs.push((0,l.fromEvent)(this._filterPanel,"click").subscribe((()=>{({editorDiv:t,webEditor:e}=this.helmEditor.createWebEditor(this.helmSubstructure));const n=i.dialog({showHeader:!1,showFooter:!0}).add(t).onOK((()=>{const t=e.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.helmSubstructure=t,this.updateFilterPanel(this.substructure),setTimeout((()=>{this.onChanged.next()}),10)})).show({modal:!0,fullScreen:!0}).onClose.subscribe((()=>{n.unsubscribe(),t=void 0,e=void 0}))}))),this.viewSubs.push(i.onSizeChanged(this._filterPanel).subscribe((t=>{try{if(e){const t=e.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.updateFilterPanel(t)}}catch(t){const[e,n]=(0,u.yf)(t);g._package.logger.error(e,void 0,n)}})))}get filterPanel(){return this._filterPanel}get substructure(){return this.helmSubstructure}set substructure(t){this.helmEditor.editor.setHelm(t)}updateFilterPanel(t){const e=this._filterPanel.parentElement.clientWidth<100?100:this._filterPanel.parentElement.clientWidth,n=e/2;if(t)(0,p.Y)(this._filterPanel,this.helmEditor.host),this.helmEditor.editor.setHelm(t),this.helmEditor.resizeEditor(e,n);else{const t=i.divText("Click to edit","helm-substructure-filter");(0,p.Y)(this._filterPanel,t)}}async substructureSearch(t){i.setUpdateIndicator(this._filterPanel,!0),await(0,d.gw)(10);const e=await(0,m.QF)(this.substructure,t);return i.setUpdateIndicator(this._filterPanel,!1),e}resetFilter(){console.debug("Bio: HelmFilter.resetFilter()"),this.helmSubstructure="",this.updateFilterPanel(this.substructure)}detach(){for(const t of this.viewSubs)t.unsubscribe()}}},8770:(t,e,n)=>{"use strict";n.d(e,{_:()=>T,t:()=>x});var i=n(3870),s=n(976),o=n(6414),r=n.n(o),a=n(8447),l=n(7331),c=n(3379),h=n.n(c),u=n(7795),d=n.n(u),m=n(569),p=n.n(m),g=n(3565),f=n.n(g),y=n(9216),b=n.n(y),C=n(4589),w=n.n(C),v=n(5362),S={};S.styleTagTransform=w(),S.setAttributes=f(),S.insert=p().bind(null,"head"),S.domAPI=d(),S.insertStyleElement=b(),h()(v.Z,S),v.Z&&v.Z.locals&&v.Z.locals;var A=n(499);function x(t){const e=i.div();e.classList.add("macromolecule-cell-comp-analysis-host");const n=t.cell.column.tags.alphabet;let o=l.UE.Color;switch(n){case"DNA":case"RNA":o=(0,a.py)("DNA");break;case"PT":o=(0,a.py)("PT")}const c={},h=A.Cn.getOrCreate(t.cell.column).getSplitter()(t.value);r()(h).filter((t=>!!t&&""!==t)).forEach((t=>{const e=c[t]||0;c[t]=e+1}));const u=T(o,c);return Array.from(u.rows).forEach((t=>{const e=t.getElementsByClassName("macromolecule-cell-comp-analysis-bar")[0].style.backgroundColor;t.cells[0].style.color=e})),e.appendChild(u),new s.Widget(e)}function T(t,e){let n=0,s=null;for(const t of Object.values(e))n+=t,s=null===s?t:Math.max(s,t);const o=s/n,r=Object.assign({},...Array.from(Object.entries(e)).sort(((t,e)=>e[1]-t[1])).map((([e,s])=>{const r=s/n,a=t.get(e),l=i.div("",{classes:"macromolecule-cell-comp-analysis-bar"});l.style.width=50*r/o+"px",l.style.backgroundColor=a;const c=i.div(`${(100*r).toFixed(2)}%`);return{[e]:i.div([l,c],{classes:"macromolecule-cell-comp-analysis-value"})}}))),a=i.tableFromMap(r);return Array.from(a.rows).forEach((t=>{const e=t.getElementsByClassName("macromolecule-cell-comp-analysis-bar")[0].style.backgroundColor;t.cells[0].style.color=e})),a}},3336:t=>{"use strict";t.exports=$},976:t=>{"use strict";t.exports=DG},4469:t=>{"use strict";t.exports=grok},701:t=>{"use strict";t.exports=rxjs},442:t=>{"use strict";t.exports=rxjs.operators},3870:t=>{"use strict";t.exports=ui},6414:t=>{"use strict";t.exports=wu}},e={};function n(i){var s=e[i];if(void 0!==s)return s.exports;var o=e[i]={id:i,loaded:!1,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}n.m=t,n.amdO={},n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.u=t=>t+".js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.hmd=t=>((t=Object.create(t)).children||(t.children=[]),Object.defineProperty(t,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+t.id)}}),t),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 t;n.g.importScripts&&(t=n.g.location+"");var e=n.g.document;if(!t&&e&&(e.currentScript&&(t=e.currentScript.src),!t)){var i=e.getElementsByTagName("script");if(i.length)for(var s=i.length-1;s>-1&&!t;)t=i[s--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t})(),n.b=document.baseURI||self.location.href,n.nc=void 0;var i=n(4955);bio=i})();
1
+ var bio;(()=>{var t={2012:(t,e,n)=>{"use strict";n.d(e,{f:()=>s});var i=n(9976);class s extends i.B{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,s)),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,s)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new s({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 s.aaSynonyms?s.aaSynonyms[t]:t;return super.get(e)}}s.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class o{static getPalette(t="grok"){switch(t){case"grok":return s.GrokGroups;case"lesk":return s.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,n="",i="";for(const s of t)"("==s?e++:")"==s?e--:e?n+=s:i+=s;return isNaN(parseInt(n))?[i,n]:[i,""]}static getColorAAPivot(t="",e="grok"){const n=this.getPalette(e);let[i,s]=this.getInnerOuter(t);if(i=i.length>6?`${i.slice(0,3)}...`:i,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,i,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,i,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,i,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,i,s,4]}return[this.undefinedColor,i,s,0]}}o.SemType="Aminoacids",o.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",o.undefinedColor="rgb(100,100,100)",o.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"},o.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"},o.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(*)*"},o.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"}},6584:(t,e,n)=>{"use strict";n.d(e,{BX:()=>o,nW:()=>a,tW:()=>l});var i=n(4469);const s="Libraries",o="System:AppData/Bio/libraries/";let r=Promise.resolve();async function a(){let t;return r=r.then((async()=>{const e=await i.dapi.userDataStorage.getValue(s,"Settings",!0);t=e?JSON.parse(e):{exclude:[],explicit:[]},t.exclude=t.exclude instanceof Array?t.exclude:[],t.explicit=t.explicit instanceof Array?t.explicit:[],console.debug(`Bio: getUserLibSettings()\n${JSON.stringify(t,void 0,2)}`)})),await r,t}async function l(t){r=r.then((async()=>{console.debug(`Bio: setUserLibSettings()\n${JSON.stringify(t,void 0,2)}`),await i.dapi.userDataStorage.postValue(s,"Settings",JSON.stringify(t),!0)})),await r}},7228:(t,e,n)=>{"use strict";n.d(e,{GR:()=>d,JN:()=>c,Qx:()=>h,Xk:()=>l});var i=n(976),s=n(4469),o=n(1047),r=(n(499),n(8457)),a=n(5697);function l(t){const e=[];for(let n=0;n<t.rowCount;n++){const i={};Object.keys(o.K4).forEach((e=>{if("symbol"===e){const s=t.get(o.K4[e],n);i[e]="."===s?t.get(o.At,n):s}else if("rgroups"===e){const s=t.get(o.K4[e],n).split("\n"),r=[];s.forEach((t=>{const e={},n=t.substring(t.lastIndexOf("]")+1),i=t.match(/\[R(\d+)\]/)[1];e.capGroupSmiles="H"===n?`[*:${i}][H]`:`O[*:${i}]`,e.alternateId="H"===n?`R${i}-H`:`R${i}-OH`,e.capGroupName="H"===n?"H":"OH",e.label=`R${i}`,r.push(e)})),i[e]=r}else o.K4[e]&&(i[e]=t.get(o.K4[e],n))})),e.push(i)}return e}async function c(){const t=i.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()}async function h(t,e){t instanceof i.Column&&(t=(0,r.O)(t).columns.toList());const n=(await c()).getBioLib(),o=new Array(t.length),a=t[0].length,l=new Float32Array(a);for(let r=0;r<t.length;++r){const c=e[r],h=n.getMonomer("PEPTIDE",c)?.smiles??"",u=t[r],d=u.getRawData(),m=u.categories,p=m.indexOf("");if(o[r]={categories:m,data:d,emptyIndex:p},void 0===c)continue;const g=i.Column.fromStrings("smiles",m.map((t=>n.getMonomer("PEPTIDE",t)?.smiles??""))),f=(i.DataFrame.fromColumns([g]),(await s.chem.getSimilarities(g,h)).getRawData());for(let t=0;t<a;++t){const e=d[t];l[t]+=""!==c&&e!==p?f[e]:""===c&&e===p?1:0}}for(let n=0;n<l.length;++n){let s=l[n]/e.length;for(let r=0;r<t.length;++r){const t=o[r];if(r>=e.length&&t.data[n]!==t.emptyIndex||t.data[n]===t.emptyIndex&&r<e.length){s=i.FLOAT_NULL;break}}l[n]=s}return i.Column.fromFloat32Array("Similarity",l)}async function u(t){const e=(await c()).getBioLib(),n=[],o={},r=t.map((t=>e.getMonomer("PEPTIDE",t)?.smiles??"")),a=i.Column.fromStrings("smiles",r);for(let e=0;e<r.length;++e){o[t[e]]=e;const i=r[e],l=""===i?new Array(r.length).fill(0):(await s.chem.getSimilarities(a,i)).getRawData();l[e]=1,n[e]=Array.from(l)}return{scoringMatrix:n,alphabetIndexes:o}}async function d(t,e="Morgan"){const n=(await c()).getBioLib(),s=new Array(t.length).fill(0).map((()=>new Array(t.length).fill(0))),o={},r=t.map((t=>n.getMonomer("PEPTIDE",t)?.smiles??"")),l=i.Func.find({package:"Chem",name:"getFingerprints"})[0];if(!l)return console.warn('Function "Chem:getFingerprints" is not found in chem package. falling back to Morgan fingerprints'),await u(t);const h=i.Column.fromStrings("smiles",r),d=(i.DataFrame.fromColumns([h]),(await l.apply({col:h,fingerprintType:e}))?.entries);if(!d)return console.warn(`${e} Fingerprints could not be calculated for monomers from chem package.\n falling back to Morgan fingerprints`),await u(t);for(let e=0;e<d.length;++e)if(s[e][e]=1,o[t[e]]=e,d[e])for(let t=e+1;t<d.length;++t)d[t]&&(s[e][t]=s[t][e]=(0,a.Z3)(d[e],d[t]));return{scoringMatrix:s,alphabetIndexes:o}}},8601:(t,e,n)=>{"use strict";n.d(e,{i0:()=>d});var i=n(4469),s=n(976),o=n(6414),r=n.n(o),a=n(1821),l=n(499);const c={V2K_RGP_SHIFT:8,V2K_RGP_LINE:"M RGP",V2K_A_LINE:"A ",V3K_COUNTS_SHIFT:14,V3K_IDX_SHIFT:7,V3K_HEADER_FIRST_LINE:"\nDatagrok macromolecule handler\n\n",V3K_HEADER_SECOND_LINE:" 0 0 0 0 0 0 999 V3000\n",V3K_BEGIN_CTAB_BLOCK:"M V30 BEGIN CTAB\n",V3K_END_CTAB_BLOCK:"M V30 END CTAB\n",V3K_BEGIN_COUNTS_LINE:"M V30 COUNTS ",V3K_COUNTS_LINE_ENDING:" 0 0 0\n",V3K_BEGIN_ATOM_BLOCK:"M V30 BEGIN ATOM\n",V3K_END_ATOM_BLOCK:"M V30 END ATOM\n",V3K_BEGIN_BOND_BLOCK:"M V30 BEGIN BOND\n",V3K_END_BOND_BLOCK:"M V30 END BOND\n",V3K_BOND_CONFIG:" CFG=",V3K_BEGIN_DATA_LINE:"M V30 ",V3K_END:"M END",PRECISION_FACTOR:1e4,DEOXYRIBOSE:"d",RIBOSE:"r",PHOSPHATE:"p",OXYGEN:"O",HYDROGEN:"H"};var h=n(1047);function u(t){return Math.round(c.PRECISION_FACTOR*t)/c.PRECISION_FACTOR}async function d(t,e,o){if(0===s.Func.find({package:"Chem",name:"getRdKitModule"}).length)return{col:null,warnings:['Transformation to atomic level requires the package "Chem" installed.']};if(e.semType!==s.SEMTYPE.MACROMOLECULE)return{col:null,warnings:[`Only the ${s.SEMTYPE.MACROMOLECULE} columns can be converted to atomic level, the chosen column has semType '${e.semType}'`]};let u=e;const d=l.Cn.getOrCreate(e);d.isHelm()&&(u=d.convert(a.r2.SEPARATOR,"."),u.name=e.name);const p=l.Cn.getOrCreate(u).alphabet;let g;if("PT"===p||"UN"===p)g="PEPTIDE";else{if("RNA"!==p&&"DNA"!==p)return{col:null,warnings:[`Unexpected column's '${u.name}' alphabet '${p}'.`]};g="RNA"}const f=function(t){const e=t.length,n=new Array(e),i=l.Cn.getOrCreate(t).getSplitter();for(let s=0;s<e;++s){const e=t.get(s);n[s]=e?r()(i(e)).filter((t=>""!==t)).toArray():[]}return n}(u),y=await async function(t,e,n,s){const o=function(t,e,n){const i=new Map;for(const s of t.getMonomerSymbolsByType(e)){const o=t.getMonomer(e,s);if("RNA"===e&&("Branch"===o.monomerType||"DNA"===n&&o.symbol===c.DEOXYRIBOSE||"RNA"===n&&o.symbol===c.RIBOSE||o.symbol===c.PHOSPHATE)||"PEPTIDE"===e&&"Branch"!==o.monomerType){const t={};h.rx.forEach((e=>{t[e]=o[e]})),i.set(o.symbol,t)}}return i}(e,n,s),r=new Map,a=await i.functions.call("Chem:getRdKitModule"),l={value:null};if("RNA"===n){const t="RNA"===s?[c.RIBOSE,c.PHOSPHATE]:[c.DEOXYRIBOSE,c.PHOSPHATE];for(const e of t)m(r,e,o,a,n,l)}for(let e=0;e<t.length;++e){const i=t[e];for(const t of i)if(""!==t)try{m(r,t,o,a,n,l)}catch(e){const n=e instanceof Error?e.message:e.toString(),i=e instanceof Error?e.stack:void 0;throw console.error(`bio lib: getMonomersDictFromLib() sym='${t}', error:\n${n}\n${i}`),new Error(`Can't get monomer '${t}' from library: ${n}`)}}return r}(f,o,g,p),b=u.length,{molfileList:C,molfileWarningList:w}=await async function(t,e,i,s,o){const r=Math.max(navigator.hardwareConcurrency-2,1),a=new Array(r).fill(null).map((()=>new Worker(new URL(n.p+n.u(79),n.b)))),l=o/r;let c=[],h=[];const u=new Array(r);for(let n=0;n<r;n++){const c=Math.floor(n*l),h=n===r-1?o:Math.floor((n+1)*l);a[n].postMessage({monomerSequencesArray:t,monomersDict:e,alphabet:i,polymerType:s,start:c,end:h}),u[n]=new Promise((t=>{a[n].onmessage=({data:{molfileList:e,molfileWarningList:n}})=>{t({molfileList:e,molfileWarningList:n})}}))}return(await Promise.all(u)).forEach((t=>{c=c.concat(...t.molfileList),h=h.concat(...t.molfileWarningList)})),setTimeout((()=>{a.forEach((t=>{t.terminate()}))}),0),{molfileList:c,molfileWarningList:h}}(f,y,p,g,b);if(w.length>.05*b)throw new Error("Too many errors getting molfiles.");const v=`molfile(${u.name})`,S=t.columns.getUnusedName(v),A=s.Column.fromStrings(S,C);return A.semType=s.SEMTYPE.MOLECULE,A.setTag(s.TAGS.UNITS,s.UNITS.Molecule.MOLBLOCK),{col:A,warnings:w}}function m(t,e,n,i,s,o){if(!t.has(e)){const r=function(t,e,n,i,s){if(e.has(t)){const o=e.get(t),r=function(t){const e=[];for(const n of t){let t=n.capGroupSmiles;t||(t=n.capGroupSMILES),t=t.replace(/(\[|\]|\*|:|\d)/g,""),e.push(t)}return e}(o.rgroups),a=function(t){const e=new Map;let n=t.indexOf(c.V2K_A_LINE,0),i=n;for(;-1!==n;){i=t.indexOf("\n",n);const s=parseInt(t.substring(n,i).replace(/^A\s+/,""));n=t.indexOf("R",i),i=t.indexOf("\n",n);const o=parseInt(t.substring(n,i).replace(/^R/,""));e.set(s,o),n=t.indexOf(c.V2K_A_LINE,i)}for(n=t.indexOf(c.V2K_RGP_LINE,0),i=t.indexOf("\n",n);-1!==n;){n+=c.V2K_RGP_SHIFT,i=t.indexOf("\n",n);const s=t.substring(n,i).replaceAll(/\s+/g," ").split(" ").map((t=>parseInt(t))).slice(1);for(let t=0;t<s.length;t+=2){if(e.has(s[t])&&e.get(s[t])!==s[t+1])throw new Error(`r-group index ${s[t]} has already been added with a different value`);e.set(s[t],s[t+1])}n=t.indexOf(c.V2K_RGP_LINE,i)}return e}(o.molfile),l=function(t,e){const n=e.get_mol(t),i=n.get_v3Kmolblock();return n.delete(),i}(function(t){let e=t.indexOf(c.V2K_A_LINE,0);-1===e&&(e=t.indexOf(c.V2K_RGP_LINE));const n=t.indexOf(c.V3K_END,e);return t.substring(0,e)+t.substring(n)}(o.molfile),n),h=function(t){let e=(t=t.replaceAll("\r","")).indexOf(c.V3K_BEGIN_COUNTS_LINE)+c.V3K_COUNTS_SHIFT,n=t.indexOf(" ",e+1);const i=parseInt(t.substring(e,n));return e=n+1,n=t.indexOf(" ",e+1),{atomCount:i,bondCount:parseInt(t.substring(e,n))}}(l),d=function(t,e){const n=new Array(e),i=new Float32Array(e),s=new Float32Array(e),o=new Array(e);let r=t.indexOf(c.V3K_BEGIN_ATOM_BLOCK);r=t.indexOf("\n",r);let a=r;for(let l=0;l<e;l++){r=t.indexOf(c.V3K_BEGIN_DATA_LINE,r)+c.V3K_IDX_SHIFT,a=t.indexOf(" ",r),r=a+1,a=t.indexOf(" ",r),n[l]=t.substring(r,a);const e=new Array(2);for(let n=0;n<2;++n)r=a+1,a=t.indexOf(" ",r),e[n]=parseFloat(t.substring(r,a));i[l]=e[0],s[l]=e[1],r=a,a=t.indexOf("\n",r)+1,o[l]=t.slice(r,a),r=a}return{atomTypes:n,x:i,y:s,kwargs:o}}(l,h.atomCount),m=function(t,e){const n=new Uint32Array(e),i=new Array(e),s=new Map,o=new Map;let r=t.indexOf(c.V3K_BEGIN_BOND_BLOCK);r=t.indexOf("\n",r);let a=r;for(let l=0;l<e;++l){const e=new Array(3);r=t.indexOf(c.V3K_BEGIN_DATA_LINE,a)+c.V3K_IDX_SHIFT,a=t.indexOf(" ",r);for(let n=0;n<3;++n)r=a+1,a=Math.min(t.indexOf("\n",r),t.indexOf(" ",r)),e[n]=parseInt(t.slice(r,a));n[l]=e[0],i[l]=e.slice(1);const h=t.indexOf("\n",r);let u=t.slice(a,h),d=u.indexOf(c.V3K_BOND_CONFIG);if(-1!==d){d=u.indexOf("=",d)+1;let t=u.indexOf(" ",d);-1===t&&(t=u.length);const e=parseInt(u.slice(d,t));s.set(l,e);const n=c.V3K_BOND_CONFIG+e.toString();u=u.replace(n,"")}u||o.set(l,u)}return{bondTypes:n,atomPairs:i,bondConfiguration:s,kwargs:o}}(l,h.bondCount),y={atoms:d,bonds:m,meta:p(d,m,r,a)};return"PEPTIDE"===i?function(t){const e=t.meta.terminalNodes[0]-1,n=t.meta.rNodes[0]-1,i=t.atoms.x,s=t.atoms.y;A(t,-i[e],-s[e]);const o=w(i[n],s[n]);v(t.atoms,-o),i[t.meta.rNodes[1]-1]<0&&function(t){S(t,!1)}(t);const r=function(t){const e=function(t){const e=new Map;for(const n of t.bonds.atomPairs)for(let t=0;t<2;t++){const i=n[t],s=n[(t+1)%2];e.has(i)?e.get(i)?.push(s):e.set(i,new Array(1).fill(s))}return e}(t);let n=0;const i=t.atoms.atomTypes.length;let s=0;for(;0===n;){const o=e.get(t.meta.terminalNodes[1])[s];if(t.atoms.atomTypes[o-1]===c.OXYGEN&&o!==t.meta.rNodes[1]&&(n=o),s++,s>i)throw new Error(`Search for double-bonded Oxygen in ${t} has exceeded the limit of ${i}`)}return n}(t);!function(t,e){t.atoms.y[t.meta.rNodes[1]-1]<0&&t.atoms.y[e-1]<0&&(function(t){S(t,!0)}(t),v(t.atoms,-function(t,e){return w(t,e)+Math.PI/2}(t.atoms.x[t.meta.terminalNodes[1]-1],t.atoms.y[t.meta.terminalNodes[1]-1])))}(t,r),function(t,e){const n=t.atoms.x;n[t.meta.rNodes[1]-1]>n[e-1]&&function(t,e,n){const i=e-1,s=n-1,o=t.atoms.x,r=t.atoms.y,a=o[i],l=r[i];o[i]=o[s],r[i]=r[s],o[s]=a,r[s]=l}(t,e,t.meta.rNodes[1])}(t,r)}(y):t===c.RIBOSE||t===c.DEOXYRIBOSE?function(t,e){const n=t.atoms.x,i=t.atoms.y;let s=t.meta.terminalNodes[0]-1;const o=t.meta.rNodes[1]-1;A(t,-n[s],-i[s]);const r=w(n[o],i[o]);v(t.atoms,3*Math.PI/2-r),e.value=function(t){const e=t.atoms.x,n=t.atoms.y,i=t.meta.rNodes[2]-1,s=t.meta.terminalNodes[2]-1,o=e[i]-e[s],r=n[i]-n[s];return Math.atan(r/o)+Math.PI/2}(t),s=t.meta.terminalNodes[0]-1,A(t,-n[s],-i[s])}(y,s):t===c.PHOSPHATE?function(t){const e=t.meta.terminalNodes[0]-1,n=t.meta.rNodes[0]-1,i=t.atoms.x,s=t.atoms.y;A(t,-i[e],-s[e]);const o=w(i[n],s[n]);v(t.atoms,Math.PI/2-o)}(y):function(t,e){const n=t.atoms.x,i=t.atoms.y,s=t.meta.terminalNodes[0]-1,o=t.meta.rNodes[0]-1;A(t,-n[s],-i[s]);const r=w(n[o],i[o]),a=e.value;if(!a)throw new Error("The value of sugarBranchToOYAngle is null");v(t.atoms,Math.PI-r+a);const l=function(t,e){return u(Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2))}({x:n[t.meta.rNodes[0]-1],y:i[t.meta.rNodes[0]-1]},{x:n[t.meta.terminalNodes[0]-1],y:i[t.meta.terminalNodes[0]-1]});if(1!=l)for(let t=0;t<n.length;++t)n[t]=u(n[t]/l),i[t]=u(i[t]/l)}(y,s),function(t,e,n){"PEPTIDE"===t?(f(e,t),b(e,e.meta.rNodes[1])):n===c.RIBOSE||n===c.DEOXYRIBOSE?(b(e,e.meta.rNodes[1]),e.meta.rNodes[1]=e.meta.terminalNodes[1],g(e.bonds,e.meta),f(e,t),b(e,e.meta.rNodes[1]),b(e,e.meta.rNodes[0]),b(e,e.meta.rNodes[2])):n===c.PHOSPHATE&&(e.meta.terminalNodes[0]=e.meta.rNodes[0],A(e,-e.atoms.x[e.meta.terminalNodes[0]-1],-e.atoms.y[e.meta.terminalNodes[0]-1]),f(e,t),b(e,e.meta.rNodes[1]))}(i,y,t),function(t){let e=0;for(;e<t.atoms.atomTypes.length;)t.atoms.atomTypes[e]===c.HYDROGEN&&(b(t,e+1),--e),++e}(y),y}return null}(e,n,i,s,o);if(!r)throw new Error(`Monomer with symbol '${e}' is absent the monomer library`);t.set(e,r)}}function p(t,e,n,i){const s={backboneShift:null,branchShift:null,terminalNodes:[],rNodes:[]};return function(t,e,n){for(const[i,s]of n)t.atomTypes[i-1]=e[s-1]}(t,n,i),function(t,e){e.rNodes=Array.from(t.keys());for(let n=0;n<e.rNodes.length;n++)for(const i of[1,2])if(t.get(e.rNodes[n])===i){const t=e.rNodes[i-1];e.rNodes[i-1]=e.rNodes[n],e.rNodes[n]=t}}(i,s),g(e,s),s}function g(t,e){const n=e.rNodes;e.terminalNodes=new Array(n.length).fill(0);const i=e.terminalNodes,s=t.atomPairs;let o=0,r=0;for(;o<s.length&&r<i.length;){for(let t=0;t<i.length;++t)for(let e=0;e<2;++e)s[o][e]===n[t]&&(i[t]=s[o][(e+1)%2],n.length,++r);++o}}function f(t,e){t.meta.rNodes.length>1&&(t.meta.backboneShift=y(t,t.meta.rNodes[1]-1,t.meta.terminalNodes[0]-1)),"RNA"===e&&t.meta.rNodes.length>2&&(t.meta.branchShift=y(t,t.meta.rNodes[2]-1,t.meta.terminalNodes[0]-1))}function y(t,e,n){return[u(t.atoms.x[e]-t.atoms.x[n]),u(t.atoms.y[e]-t.atoms.y[n])]}function b(t,e){if(void 0!==e){const n=e-1,i=t.atoms,s=t.bonds,o=t.meta;i.atomTypes.splice(n,1),i.x=C(Float32Array,i.x,n,1),i.y=C(Float32Array,i.y,n,1),i.kwargs.splice(n,1);for(let t=0;t<o.terminalNodes.length;++t)o.terminalNodes[t]>e?--o.terminalNodes[t]:o.terminalNodes[t]===e&&(o.terminalNodes[t]=-1);for(let t=0;t<o.rNodes.length;++t)o.rNodes[t]>e?--o.rNodes[t]:o.rNodes[t]===e&&(o.rNodes[t]=-1);let r=0;for(;r<s.atomPairs.length;){const t=s.atomPairs[r][0],n=s.atomPairs[r][1];t===e||n===e?(s.atomPairs.splice(r,1),s.bondTypes=C(Uint32Array,s.bondTypes,r,1),s.bondConfiguration.has(r)&&s.bondConfiguration.delete(r),s.kwargs.has(r)&&s.kwargs.delete(r),--r):(s.atomPairs[r][0]=t>e?t-1:t,s.atomPairs[r][1]=n>e?n-1:n),++r}let a=Array.from(s.bondConfiguration.keys());a.forEach((t=>{if(s.bondConfiguration.has(t)&&t>n){const e=s.bondConfiguration.get(t);s.bondConfiguration.delete(t),s.bondConfiguration.set(t-1,e)}})),a=Array.from(s.kwargs.keys()),a.forEach((t=>{if(s.kwargs.has(t)&&t>n){const e=s.kwargs.get(t);s.kwargs.delete(t),s.kwargs.set(t-1,e)}}))}}function C(t,e,n,i){const s=new t(e.length-i);let o=0,r=0;for(;o<e.length;)o===n&&(o+=i),s[r]=e[o],++r,++o;return s}function w(t,e){let n;if(0===t)n=e>0?0:Math.PI;else if(0===e)n=t>0?-Math.PI/2:Math.PI/2;else{const i=e/t,s=Math.atan(i);n=t<0?Math.PI/2+s:-Math.PI/2+s}return n}function v(t,e){if(0!==e){const n=t.x,i=t.y,s=Math.cos(e),o=Math.sin(e);for(let t=0;t<n.length;++t){const e=n[t];n[t]=u(e*s-i[t]*o),i[t]=u(e*o+i[t]*s)}}}function S(t,e){if(e){const e=t.atoms.y;for(let t=0;t<e.length;t++)e[t]=-e[t]}else{const e=t.atoms.x;for(let t=0;t<e.length;t++)e[t]=-e[t]}const n=t.bonds.bondConfiguration;for(const[t,e]of n){const i=1===e?3:1;n.set(t,i)}}function A(t,e,n){const i=t.atoms.x,s=t.atoms.y;for(let t=0;t<i.length;++t)i[t]=u(i[t]+e),void 0!==n&&(s[t]=u(s[t]+n))}},6137:(t,e,n)=>{"use strict";n.d(e,{J:()=>s});var i=n(9976);class s extends i.B{static get Chromatogram(){return void 0===this.chromatogram&&(this.chromatogram=new s({A:"green",C:"blue",G:"black",T:"red",U:"red",others:"gray"})),this.chromatogram}}class o{}o.SemType="Nucleotides",o.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",o.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"}},9976:(t,e,n)=>{"use strict";n.d(e,{B:()=>i});class i{static makePalette(t,e=!1,n=i){const s={};return t.forEach((t=>{const n=t[0],i=t[1];n.forEach(((t,n)=>{s[t]=this.colourPalette[i][e?0:n]}))})),new n(s)}constructor(t){this._palette=t}get(t){return this._palette[t]}}i.undefinedColor="rgb(100,100,100)",i.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)"]}},7331:(t,e,n)=>{"use strict";n.d(e,{UE:()=>c});var i=n(976),s=n(9976);class o{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 r{}class a extends r{get(t){return"#666666"}}class l extends r{static buildPalette(){return[].concat(...Object.values(s.B.colourPalette))}get(t){const e=o.hashCode(t)%l.palette.length;return function(t){if(null==t)return"rgb(100,100,100)";const e=i.Color.fromHtml(t),n=i.Color.g(e),s=i.Color.r(e),o=i.Color.b(e),r=Math.sqrt(Math.pow(0-s,2)+Math.pow(0-n,2)+Math.pow(0-o,2));return r>210?`rgb(${s/r*210},${n/r*210},${o/r*210})`:i.Color.toRgb(e)}(l.palette[e])}}l.palette=l.buildPalette();class c extends s.B{static get Gray(){return void 0===this.gray&&(this.gray=new a),this.gray}static get Color(){return void 0===this.color&&(this.color=new l),this.color}}},9611:(t,e,n)=>{"use strict";n.d(e,{A:()=>c});var i=n(4469),s=n(976),o=n(6414),r=n.n(o),a=n(8447);const l={DNA:"RNA",RNA:"RNA",PT:"PEPTIDE",UN:"PEPTIDE"};class c{get updated(){return this._updated}constructor(t,e,n){this.grid=t,this.col=e,this.propsProvider=n,this._monomerLengthList=null,this.separatorWidth=5,this._updated=!1,this._monomerLengthMap={},this._monomerStructureMap={},this.subs=[],this._splitter=(0,a.Mj)(this.col),this.props=this.propsProvider(),this._rowsProcessed=s.BitSet.create(this.col.length),this.grid&&(this.subs.push(e.dataFrame.onDataChanged.subscribe((()=>{try{this.props=this.propsProvider(),this._monomerLengthList=null,this._rowsProcessed=s.BitSet.create(this.col.length)}catch(t){console.error(t)}}))),this.subs.push(i.events.onViewRemoved.subscribe((t=>{try{this.grid?.view?.id===t.id&&this.destroy()}catch(t){console.error(t)}}))))}destroy(){for(const t of this.subs)t.unsubscribe()}getCellMonomerLengths(t){const e=this.props.unitsHandler.isMsa()?this.getCellMonomerLengthsForSeqMsa():this.getCellMonomerLengthsForSeq(t),n=new Array(e.length+1);n[0]=5;for(let t=1;t<n.length;t++)n[t]=n[t-1]+e[t-1];return[e,n]}getCellMonomerLengthsForSeq(t){null===this._monomerLengthList&&(this._monomerLengthList=new Array(this.col.length).fill(null),this._updated=!0);let e=this._monomerLengthList[t];if(null===e){const n=this.getSeqMonList(t);e=this._monomerLengthList[t]=new Array(n.length);for(const[t,i]of r().enumerate(n)){const n=this.props.monomerToShort(t,this.props.monomerLengthLimit),s=(this.props.unitsHandler.isSeparator()?this.separatorWidth:this.props.separatorWidth)+n.length*this.props.monomerCharWidth;e[i]=s}this._updated=!0}return e}getCellMonomerLengthsForSeqMsa(){var t;null===this._monomerLengthList&&(this._monomerLengthList=new Array(1).fill(null),this._updated=!0),(t=this._monomerLengthList)[0]??(t[0]=new Array(0));const e=this._monomerLengthList[0],{startIdx:n,endIdx:i}=(()=>{try{return this.grid&&this.grid.dart?{startIdx:Math.max(Math.floor((this.grid?.vertScroll.min??0)-10),0),endIdx:Math.min(Math.ceil((this.grid?.vertScroll.max??0)+10),this.col.length)}:{startIdx:0,endIdx:Math.min(this.col.length,10)}}catch(t){return{startIdx:0,endIdx:Math.min(this.col.length,10)}}})();for(let t=n;t<i;t++){if(this._rowsProcessed.get(t))continue;const n=this.getSeqMonList(t);n.length>e.length&&e.push(...new Array(n.length-e.length).fill(0));for(const[t,i]of r().enumerate(n)){const n=this.props.monomerToShort(t,this.props.monomerLengthLimit),s=this.props.separatorWidth+n.length*this.props.monomerCharWidth;e[i]=Math.max(e[i]??0,s)}this._updated=!0}return e}getPosition(t,e){const[n,i]=this.getCellMonomerLengths(t),s=this.col.get(t),o=r()(this._splitter(s)).toArray();if(0===o.length)return null;let a=100,l=null,c=o.length,h=!1,u=0;if(i[0]<=e&&e<i.slice(-1)[0])for(;!h;)if(u=Math.floor((c+(l??0))/2),e>=i[u]&&e<=i[u+1]?(l=u,h=!0):e<i[u]?c=u-1:e>i[u+1]&&(l=u+1),l==c&&(h=!0),--a<=0)throw new Error(`Get position for pointer x = ${e} searching has not converged on ${JSON.stringify(i)}. `);return l}getSeqMonList(t){const e=this.col.get(t);return e?r()(this._splitter(e)).toArray():[]}getMonomer(t){const e=this.props.unitsHandler.alphabet??"UN",n=l[e];return this.props.monomerLib?.getMonomer(n,t)??null}setMonomerLengthLimit(t){this.props.monomerLengthLimit=t,this._updated=!0}setSeparatorWidth(t){this.props.separatorWidth=t,this._updated=!0}isMsa(){return this.props.unitsHandler.isMsa()}}},1047:(t,e,n)=>{"use strict";n.d(e,{$3:()=>c,At:()=>s,K4:()=>a,Wc:()=>o,Z2:()=>l,nJ:()=>r,pU:()=>h,rx:()=>i});const i=["symbol","molfile","rgroups","name"],s="MonomerName",o={symbol:"Short Name",name:"Medium Name",smiles:"SMILES"},r=[{capGroupSmiles:"[*:1][H]",alternateId:"R1-H",capGroupName:"H",label:"R1"},{capGroupSmiles:"O[*:2]",alternateId:"R2-OH",capGroupName:"OH",label:"R2"},{capGroupSmiles:"[*:3][H]",alternateId:"R3-H",capGroupName:"H",label:"R3"}],a={monomerType:null,smiles:null,name:"MonomerName",author:null,molfile:"molecule",naturalAnalog:"MonomerNaturalAnalogCode",rgroups:"MonomerCaps",createDate:null,id:null,polymerType:"MonomerType",symbol:"MonomerCode"},l={monomerType:"Backbone",smiles:"",name:"",author:"Datagrok",molfile:"",naturalAnalog:"",rgroups:[],createDate:null,id:0,polymerType:"PEPTIDE",symbol:""},c="p",h=new RegExp(`[rd]\\((\\w)\\)${c}?`,"g")},7945:(t,e,n)=>{"use strict";function i(t){return"string"==typeof t||t instanceof String?t:"StateError"===t.constructor.name?t.message:"StateError"===t.constructor.name&&"$thrownJsError"in t?i(t.$thrownJsError):t instanceof Error?t.message:t.toString()}function s(t){return t instanceof Error?t.stack:"StateError"===t.constructor.name&&"$thrownJsError"in t?s(t.$thrownJsError):void 0}function o(t){return[i(t),s(t)]}n.d(e,{yf:()=>o})},5226:(t,e,n)=>{"use strict";n.d(e,{i:()=>r});var i=n(976),s=n(499),o=n(1821);class r{get descriptionsArray(){return this._descriptionsArray}get sequencesArray(){return this._sequencesArray}parseMacromolecule(t,e){return this._fileContent.slice(t,e).split(/\s/).join("")}parseColumns(){const t=/^>(.*)$/gm;let e,n=0;for(;e=t.exec(this._fileContent);){const i=this._fileContent.substring(e.index+1,t.lastIndex);this._descriptionsArray.push(i),0!==n&&this._sequencesArray.push(this.parseMacromolecule(n,e.index)),n=t.lastIndex+1}this._sequencesArray.push(this.parseMacromolecule(n,-1))}importFasta(){const t=i.Column.fromStrings("description",this.descriptionsArray),e=i.Column.fromStrings("sequence",this.sequencesArray);return e.semType=i.SEMTYPE.MACROMOLECULE,e.setTag(i.TAGS.UNITS,o.r2.FASTA),s.Cn.getOrCreate(e),[i.DataFrame.fromColumns([t,e])]}constructor(t){this._descriptionsArray=[],this._sequencesArray=[],this._fileContent=t,this.parseColumns()}}},1821:(t,e,n)=>{"use strict";n.d(e,{BM:()=>r,CI:()=>o,XS:()=>l,r2:()=>i});var i,s=n(6286);!function(t){t.FASTA="fasta",t.SEPARATOR="separator",t.HELM="helm"}(i||(i={}));const o=", ",r=/(?:\[([A-Za-z0-9_\-,()]+)\])|([A-Za-z\-])/g,a=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"])}}},l=[new s.L("PT",a.fasta.peptide,.5),new s.L("DNA",a.fasta.dna,.55),new s.L("RNA",a.fasta.rna,.55)]},8447:(t,e,n)=>{"use strict";n.d(e,{CI:()=>i.CI,GU:()=>s.GU,Mj:()=>s.Mj,XS:()=>i.XS,dQ:()=>s.dQ,kB:()=>s.kB,py:()=>s.py,r2:()=>i.r2,up:()=>s.up});var i=n(1821),s=n(8260)},6286:(t,e,n)=>{"use strict";n.d(e,{L:()=>i,d:()=>s});class i{constructor(t,e,n){this.name=t,this.alphabet=e,this.cutoff=n}}class s extends i{constructor(t,e,n){super(t.name,t.alphabet,t.cutoff),this.freq=e,this.similarity=n}}},8260:(t,e,n)=>{"use strict";n.d(e,{w4:()=>x,py:()=>I,vU:()=>w,Mj:()=>v,Ar:()=>f,GU:()=>A,dQ:()=>T,up:()=>M,kB:()=>p,FJ:()=>g,gP:()=>C});var i=n(976),s=n(6414),o=n.n(s),r=n(6286),a=n(1821),l=n(499);class c extends Float32Array{}var h=n(850),u=n(2012),d=n(6137),m=n(7331);function p(t){return o()(t.toString().matchAll(a.BM)).map((t=>t[2]??t[1])).toArray()}function g(t){return t||[]}function f(t,e=undefined){return n=>n?n.replaceAll('"-"',"").replaceAll("'-'","").split(t,e):[]}const y=/(PEPTIDE1|DNA1|RNA1)\{([^}]+)}/g,b=/\[([^\[\]]+)]/g;function C(t){y.lastIndex=0;const e=y.exec(t.toString()),n=e?e[2]:null;return(n?n.split("."):[]).map((t=>{b.lastIndex=0;const e=b.exec(t);return e&&e.length>=2?e[1]:t}))}function w(t,e,n=undefined){if(t.toLowerCase().startsWith(a.r2.FASTA))return p;if(t.toLowerCase().startsWith(a.r2.SEPARATOR))return f(e,n);if(t.toLowerCase().startsWith(a.r2.HELM))return C;throw new Error(`Unexpected units ${t} .`)}function v(t){return l.Cn.getOrCreate(t).getSplitter()}const S=/([^\W_]+)/g;function A(t,e){if(t.length<=e)return t;const n=t.match(S),i=t.length>e||(n?.length??0)>1,s=n?.[0]??" ";return i?s.substring(0,e-1)+"…":s}function x(t,e,n="-"){const i=e.map((e=>{const i=function(t,e,n="-"){const i=new Set([...new Set(Object.keys(t)),...e]);i.delete(n);const s=[],o=[];for(const n of i)s.push(n in t?t[n]:0),o.push(e.has(n)?1:0);const r=new c(s),a=new c(o);return(0,h.MA)(r,a)/((0,h.$G)(r)*(0,h.$G)(a))}(t,e.alphabet,n);return new r.d(e,t,i)}));let s;const o=Math.max(...i.map((t=>t.similarity>t.cutoff?t.similarity:-1)));return s=o>0?i.find((t=>t.similarity===o)).name:"UN",s}function T(t,e=5){let n;if(t.semType==i.SEMTYPE.MACROMOLECULE)n=l.Cn.getOrCreate(t).alphabet;else{const i=function(t,e,n){return t.categories,function(t,e){const n={};let i=!0,s=null;for(const o of t)if(null==s?s=o.length:o.length!==s&&(i=!1),o.length>=e)for(const t of o)t in n||(n[t]=0),n[t]+=1;return{freq:n,sameLength:i}}(o()(t.getRawData()).map((e=>n(t.categories[e]))),e)}(t,e,p);n=x(i.freq,a.XS)}return I(n)}function I(t){switch(t){case"PT":return u.f.GrokGroups;case"DNA":case"RNA":return d.J.Chromatogram;default:return m.UE.Color}}function M(t){const e=t.columns.bySemTypeAll(i.SEMTYPE.MACROMOLECULE);let n=e.find((t=>{const e=t.getTag(i.TAGS.UNITS);return!!e&&-1!==e.indexOf("MSA")}))??null;return!n&&e.length>0&&(n=e[0]),n}},8457:(t,e,n)=>{"use strict";n.d(e,{O:()=>a});var i=n(976),s=n(6414),o=n.n(s),r=n(8260);function a(t){const e=(0,r.Mj)(t),n=t=>{const e=l.columns.addNewString((t+1).toString());return s.push(e),e},s=[],a=t.length,l=i.DataFrame.create(a);for(let i=0;i<a;++i){const r=t.get(i);if(null==r)continue;const a=e(r);for(const[t,e]of o().enumerate(a))((s[e]??null)||n(e)).set(i,t||"-",!1)}return l}},172:(t,e,n)=>{"use strict";n.d(e,{c:()=>o});var i,s=n(7945);!function(t){t[t.error=0]="error",t[t.warning=1]="warning",t[t.info=2]="info",t[t.debug=3]="debug"}(i||(i={}));class o{constructor(t){this.logger=t,this.promise=Promise.resolve(),this.errors=[],this.syncCounter=0}sync(t,e){const n=++this.syncCounter;this.logger.debug(`${t}, SYNC syncId = ${n}, IN `),this.promise=this.promise.then((async()=>{this.logger.debug(`${t}, SYNC syncId = ${n}, START `),await e(),this.logger.debug(`${t}, SYNC syncId = ${n}, END `)})).catch((e=>{const[i,o]=(0,s.yf)(e);this.logger.error(`${t}, SYNC syncId = ${n}, ERROR:\n${i}`,void 0,o),this.errors.push(e)}))}resetErrors(){const t=this.errors;return this.errors=[],t}}},499:(t,e,n)=>{"use strict";n.d(e,{Cn:()=>m});var i=n(976),s=n(6414),o=n.n(s),r=n(8447),a=n(8260),l=n(708),c=n(7228),h=n(1047);const u=new class{constructor(){this.uh=`units-handler.${i.SEMTYPE.MACROMOLECULE}`}},d={[r.r2.FASTA]:"-",[r.r2.SEPARATOR]:"",[r.r2.HELM]:"*"};class m{static setUnitsToFastaColumn(t){if(t.column.semType!==i.SEMTYPE.MACROMOLECULE||t.column.getTag(i.TAGS.UNITS)!==r.r2.FASTA)throw new Error(`The column of notation '${r.r2.FASTA}' must be '${i.SEMTYPE.MACROMOLECULE}'.`);t.column.setTag(i.TAGS.UNITS,r.r2.FASTA),m.setTags(t)}static setUnitsToSeparatorColumn(t,e){if(t.column.semType!==i.SEMTYPE.MACROMOLECULE||t.column.getTag(i.TAGS.UNITS)!==r.r2.SEPARATOR)throw new Error(`The column of notation '${r.r2.SEPARATOR}' must be '${i.SEMTYPE.MACROMOLECULE}'.`);if(!e)throw new Error(`The column of notation '${r.r2.SEPARATOR}' must have the separator tag.`);t.column.setTag(i.TAGS.UNITS,r.r2.SEPARATOR),t.column.setTag("separator",e),m.setTags(t)}static setUnitsToHelmColumn(t){if(t.column.semType!==i.SEMTYPE.MACROMOLECULE)throw new Error(`The column of notation '${r.r2.HELM}' must be '${i.SEMTYPE.MACROMOLECULE}'`);t.column.setTag(i.TAGS.UNITS,r.r2.HELM),m.setTags(t)}static setTags(t){const e=t.column.getTag(i.TAGS.UNITS),n=t.stats;if(Object.keys(n.freq).some((t=>t.length>1)),[r.r2.FASTA,r.r2.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 i=t.column.getTag("alphabet");if(null===i&&(i=(0,a.w4)(n.freq,r.XS),t.column.setTag("alphabet",i)),"UN"===i){const e=Object.keys(n.freq).length,i=Object.keys(n.freq).some((t=>t.length>1));t.column.setTag(".alphabetSize",e.toString()),t.column.setTag(".alphabetIsMultichar",i?"true":"false")}}}get column(){return this._column}get units(){return this._units}get notation(){return this._notation}get defaultGapSymbol(){return this._defaultGapSymbol}get separator(){const t=this.column.getTag("separator")??void 0;if(this.notation===r.r2.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==r.r2.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===r.r2.HELM||"UN"===this.alphabet&&"true"===this.column.getTag(".alphabetIsMultichar")}get splitted(){if(null===this._splitted){const t=this.getSplitter(),e=this._column.length;this._splitted=new Array(e);const n=this._column.getRawData(),i=this._column.categories;for(let s=0;s<e;s++){const e=i[n[s]];this._splitted[s]=t(e)}}return this._splitted}get stats(){if(null===this._stats){const t={};let e=!0,n=null;for(const i of this.splitted){null==n?n=i.length:i.length!==n&&(e=!1);for(const e of i)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.splitted.length?0:Math.max(...this.splitted.map((t=>t.length)))),this._maxLength}get posList(){if(null===this._posList){const t=this.column.getTag(".positionNames");this._posList=t?t.split(r.CI).map((t=>t.trim())):o().count(1).take(this.maxLength).map((t=>t.toString())).toArray()}return this._posList}isFasta(){return this.notation===r.r2.FASTA}isSeparator(){return this.notation===r.r2.SEPARATOR}isHelm(){return this.notation===r.r2.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||this.units===r.r2.FASTA&&t===d[r.r2.FASTA]||this.units===r.r2.HELM&&t===d[r.r2.HELM]}getNotation(){if(this.units.toLowerCase().startsWith(r.r2.FASTA))return r.r2.FASTA;if(this.units.toLowerCase().startsWith(r.r2.SEPARATOR))return r.r2.SEPARATOR;if(this.units.toLowerCase().startsWith(r.r2.HELM))return r.r2.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 o=this.column,a=t.toLowerCase()+"("+o.name+")",l=n??o.dataFrame.columns.getUnusedName(a),c=i.Column.fromList("string",l,s??new Array(this.column.length).fill(""));if(c.semType=i.SEMTYPE.MACROMOLECULE,c.setTag(i.TAGS.UNITS,t),t===r.r2.SEPARATOR){if(!e)throw new Error(`Notation '${r.r2.SEPARATOR}' requires separator value.`);c.setTag("separator",e)}c.setTag(i.TAGS.CELL_RENDERER,"Macromolecule");const h=o.getTag("aligned");h&&c.setTag("aligned",h);const u=o.getTag("alphabet");null!=u&&c.setTag("alphabet",u);let d=o.getTag(".alphabetSize");null!=u&&d&&c.setTag(".alphabetSize",d);const m=o.getTag(".alphabetIsMultichar");return null!=u&&void 0!==m&&c.setTag(".alphabetIsMultichar",m),t==r.r2.HELM&&(d=this.getAlphabetSize().toString(),c.setTag(".alphabetSize",d)),c}getNewColumnFromList(t,e){return this.getNewColumn(this.notation,this.separator,t,e)}static getNewColumn(t){const e=m.getOrCreate(t),n=e.notation;return e.getNewColumn(n)}static unitsStringIsValid(t){return t=t.toLowerCase(),[r.r2.FASTA,r.r2.SEPARATOR,r.r2.HELM].some((e=>t.startsWith(e.toLowerCase())))}static getNewColumnFromParams(t,e,n){if(!m.unitsStringIsValid(n))throw new Error("Invalid format of 'units' parameter");const s=i.Column.fromList("string",e,new Array(t).fill(""));return s.semType=i.SEMTYPE.MACROMOLECULE,s.setTag(i.TAGS.UNITS,n),s}getSplitter(t){if(this.units.toLowerCase().startsWith(r.r2.FASTA))return null===this.column.getTag("alphabet")||this.getAlphabetIsMultichar()?a.kB:a.FJ;if(this.units.toLowerCase().startsWith(r.r2.SEPARATOR))return(0,a.Ar)(this.separator,t);if(this.units.toLowerCase().startsWith(r.r2.HELM))return a.gP;throw new Error(`Unexpected units ${this.units} .`)}getDistanceFunctionName(){if(!this.isFasta())throw new Error("Only FASTA notation is supported");return this.isMsa()?l.U.HAMMING:(this.alphabet,l.U.LEVENSHTEIN)}getDistanceFunction(){return l.o[this.getDistanceFunctionName()]()}async checkHelmCompatibility(){if(this.column.tags.has(".isHelmCompatible"))return"true"===this.column.getTag(".isHelmCompatible");const t=(await(0,c.JN)()).getBioLib().getMonomerSymbolsByType("PEPTIDE".toString()),e=new Set(t),n=(0,a.Ar)(this.separator);for(const t of this.column.categories){const i=n(t);for(const t of i)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=(0,a.Mj)(this.column)),this._splitter}toFasta(t){return t===r.r2.FASTA}toSeparator(t){return t===r.r2.SEPARATOR}toHelm(t){return t===r.r2.HELM}convertHelmToFastaSeparator(t,e,n,i){i||(i=this.toFasta(e)?d[r.r2.FASTA]:d[r.r2.SEPARATOR]),n||(n=this.toFasta(e)?"":this.separator);const s=t.startsWith("RNA"),o=this.splitter(t),a=[];for(let t=0;t<o.length;t++){let n=o[t];if(s&&(n=n.replace(h.pU,"")),n===d[r.r2.HELM])a.push(i);else if(this.toFasta(e)&&n.length>1){const t="["+n+"]";a.push(t)}else a.push(n)}return a.join(n)}convert(t,e){const n=this.getConverter(t,e),i=this.getNewColumn(t,e);return i.init((t=>n(this.column.get(t)))),i}getRegion(t,e,n){const i=this.getNewColumn(this.notation,this.separator);i.name=n,Math.max(...this.splitted.map((t=>t.length)));const s=t??0,o=e??this.maxLength-1,a=this.getJoiner(),l=o-s+1;i.init((t=>{const e=this.splitted[t],n=new Array(l);for(let t=0;t<l;++t){const i=s+t;n[t]=i<e.length?e[i]:d[this.notation]}return a(n)}));const c=t=>{const e=t.split(",").map((t=>t.trim())),n=new Array(l);for(let t=0;t<l;++t){const i=s+t;n[t]=i<e.length?e[i]:"?"}return n.join(r.CI)},h=this.column.getTag(".positionNames");h&&i.setTag(".positionNames",c(h));const u=this.column.getTag(".positionLabels");return u&&i.setTag(".positionLabels",c(u)),i}getJoiner(){if(void 0===this._joiner){const t=this;if(this.notation===r.r2.FASTA)this._joiner=function(e){return p(t,e)};else if(this.notation===r.r2.SEPARATOR)this._joiner=function(e){return g(t,e,t.separator)};else{if(this.notation!==r.r2.HELM)throw new Error;{const e="DNA"===t.alphabet||"RNA"===t.alphabet;this._joiner=function(n){return f(t,n,e)}}}}return this._joiner}getConverter(t,e=undefined){if(t===r.r2.SEPARATOR&&!e)throw new Error(`Target separator is not specified for target units '${r.r2.SEPARATOR}'.`);const n=this;if(t===r.r2.FASTA)return function(t){return function(t,e){const n=t.isHelm()?y(t,e):t.getSplitter()(e);return p(t,n)}(n,t)};if(t===r.r2.HELM)return function(t){return function(t,e){const n=e.startsWith("DNA")||e.startsWith("RNA"),i=t.getSplitter()(e);return f(t,i,n)}(n,t)};if(t===r.r2.SEPARATOR)return function(t){return function(t,e,n){const i=t.isHelm()?y(t,e):t.getSplitter()(e);return g(t,i,n)}(n,t,e)};throw new Error}constructor(t){if(this._splitter=null,this._splitted=null,this._stats=null,this._maxLength=null,this._posList=null,this._joiner=void 0,t.type!==i.TYPE.STRING)throw new Error(`Unexpected column type '${t.type}', must be '${i.TYPE.STRING}'.`);this._column=t;const e=this._column.getTag(i.TAGS.UNITS);if(null==e)throw new Error("Units are not specified in column");if(this._units=e,this._notation=this.getNotation(),this._defaultGapSymbol=this.isFasta()?d[r.r2.FASTA]:this.isHelm()?d[r.r2.HELM]:d[r.r2.SEPARATOR],!this.column.tags.has("aligned")||!this.column.tags.has("alphabet")||!this.column.tags.has(".alphabetIsMultichar")&&!this.isHelm()&&"UN"===this.alphabet)if(this.isFasta())m.setUnitsToFastaColumn(this);else if(this.isSeparator()){const e=t.getTag("separator");m.setUnitsToSeparatorColumn(this,e)}else{if(!this.isHelm())throw new Error(`Unexpected units '${this.column.getTag(i.TAGS.UNITS)}'.`);m.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 getOrCreate(t){let e=t.temp[u.uh];return e||(e=t.temp[u.uh]=new m(t)),e}}function p(t,e){const n=new Array(e.length);for(const[i,s]of o().enumerate(e)){let o=i;t.isHelm()&&(o=i.replace(h.pU,"$1")),t.isGap(o)?o=d[r.r2.FASTA]:o.length>1&&(o="["+e[s]+"]"),n[s]=o}return n.join("")}function g(t,e,n){const i=new Array(e.length);for(const[n,s]of o().enumerate(e)){let e=n;t.isGap(e)&&(e=d[r.r2.SEPARATOR]),i[s]=e}return i.map((t=>t??"")).join(n)}function f(t,e,n){const[i,s,a,l]=t.getHelmWrappers();return`${i}${o()(e).map((e=>{let i=e;return i=t.isGap(i)?d[r.r2.HELM]:n?i.replace(h.pU,"$1"):1==e.length?`${s}${e}${a}`:`${s}[${e}]${a}`,i})).toArray().join(".")}${l}`}function y(t,e){const n=t.getSplitter()(e),i=new Array(n.length),s=e.startsWith("DNA"),r=e.startsWith("RNA");for(const[t,e]of o().enumerate(n)){let n=t;(s||r)&&(n=n.replace(h.pU,"$1"),n=n===h.$3?null:n),i[e]=n}return i.filter((t=>null!==t))}},9298:(t,e,n)=>{"use strict";n.d(e,{Ct:()=>l,DX:()=>i,ES:()=>s,dE:()=>a,iD:()=>r,vS:()=>h,vw:()=>o});var i,s,o,r,a,l,c=n(976);!function(t){t.tooltipWebLogo=".tooltipWebLogo"}(i||(i={})),function(t){t.Entropy="Entropy",t.full="100%"}(s||(s={})),function(t){t.TOP="top",t.MIDDLE="middle",t.BOTTOM="bottom"}(o||(o={})),function(t){t.LEFT="left",t.CENTER="center",t.RIGHT="right"}(r||(r={})),function(t){t.AUTO="auto",t.ON="on",t.OFF="off"}(a||(a={})),function(t){t.Filtered="Filtered",t.Selected="Selected"}(l||(l={}));const h=new class{constructor(){this.sequenceColumnName=null,this.valueAggrType=c.AGG.TOTAL_COUNT,this.valueColumnName="Activity",this.startPositionName=null,this.endPositionName=null,this.skipEmptySequences=!0,this.skipEmptyPositions=!1,this.shrinkEmptyTail=!0,this.backgroundColor=4294967295,this.positionHeight=s.Entropy,this.positionWidth=16,this.verticalAlignment=o.MIDDLE,this.horizontalAlignment=r.CENTER,this.fixWidth=!1,this.fitArea=!0,this.minHeight=50,this.maxHeight=100,this.showPositionLabels=!0,this.positionMarginState=a.AUTO,this.positionMargin=0,this.filterSource=l.Filtered}}},922:(t,e,n)=>{"use strict";n.d(e,{_:()=>l});class i{constructor(t){this.init(t)}init(t){this.fileContent=t.replace(/\r/g,""),this._atomCount=void 0,this._atomTypes=void 0,this._bondCount=void 0,this._bondTypes=void 0,this.xyzAtomCoordinates=void 0,this._pairsOfBondedAtoms=void 0}get atomCount(){return void 0===this._atomCount&&this.setAtomAndBondCounts(),this._atomCount}get bondCount(){return void 0===this._bondCount&&this.setAtomAndBondCounts(),this._bondCount}get x(){var t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.x}get y(){var t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.y}get z(){var t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.z}get atomTypes(){var t;return null!==(t=this._atomTypes)&&void 0!==t||(this._atomTypes=this.parseAtomTypes()),this._atomTypes}get pairsOfBondedAtoms(){var t;return null!==(t=this._pairsOfBondedAtoms)&&void 0!==t||(this._pairsOfBondedAtoms=this.parseBondedAtomPairs()),this._pairsOfBondedAtoms}get bondTypes(){var t;return null!==(t=this._bondTypes)&&void 0!==t||(this._bondTypes=this.parseBondTypes()),this._bondTypes}setAtomAndBondCounts(){const{atomCount:t,bondCount:e}=this.parseAtomAndBondCounts();this._atomCount=t,this._bondCount=e}getNextColumnIdx(t){for(;!this.isWhitespace(t);)++t;for(;this.isWhitespace(t);)++t;return t}shiftIdxToSpecifiedColumn(t,e){let n=t;const i=this.isWhitespace(n)?e:e-1;for(let t=0;t<i;t++)n=this.getNextColumnIdx(n);return n}parseAtomTypes(){const t=this.atomCount,e=new Array(t);let n=this.getAtomBlockIdx();for(let i=0;i<t;i++)n=this.shiftIdxToAtomType(n),e[i]=this.parseAtomType(n),n=this.getNextLineIdx(n);return e}parseAtomCoordinates(){const t=new Float32Array(this.atomCount),e=new Float32Array(this.atomCount),n=new Float32Array(this.atomCount);let i=this.getAtomBlockIdx();for(let s=0;s<this.atomCount;s++){i=this.shiftIdxToXColumn(i);for(const o of[t,e,n])o[s]=this.parseFloatValue(i),i=this.getNextColumnIdx(i);i=this.getNextLineIdx(i)}return{x:t,y:e,z:n}}parseBondedAtomPairs(){const t=new Array(this.bondCount);let e=this.getBondBlockIdx();for(let n=0;n<this.bondCount;n++){e=this.shiftIdxToBondedAtomsPair(e);const i=new Uint16Array(2);i[0]=this.parseIntValue(e),e=this.getNextColumnIdx(e),i[1]=this.parseIntValue(e),t[n]=i,e=this.getNextLineIdx(e)}return t}parseBondTypes(){const t=this.bondCount,e=new Uint16Array(t);let n=this.getBondBlockIdx();for(let i=0;i<t;i++)n=this.shiftIdxToBondType(n),e[i]=this.parseIntValue(n),n=this.getNextLineIdx(n);return e}isWhitespace(t){const e=this.fileContent[t];return" "===e||"\t"===e}getNextLineIdx(t){return"\n"!==this.fileContent[t]?this.fileContent.indexOf("\n",t)+1:t+1}parseFloatValue(t){return this.parseNumericValue(parseFloat,t)}parseIntValue(t){return this.parseNumericValue(parseInt,t)}parseNumericValue(t,e){let n=e+1;for(;!this.isWhitespace(n);)++n;return t(this.fileContent.substring(e,n))}}class s extends i{constructor(t){super(t),this.init(t)}init(t){super.init(t)}parseAtomType(t){let e=t,n=e;return this.isQuote(e)?(n=this.getNextIdenticalChar(e),e++):n=this.fileContent.indexOf(" ",n),this.fileContent.substring(e,n)}isQuote(t){const e=this.fileContent[t].charCodeAt(0);return 39===e||34===e}getNextIdenticalChar(t){const e=this.fileContent[t];return e?this.fileContent.indexOf(e,t+1):-1}isQuery(){return this.isQueryOrFragment(((t,e)=>{return 39===t||34===t||76===t&&!((n=this.fileContent.charCodeAt(e+1))>64&&n<91||n>96&&n<123);var n}))}isFragment(){return this.isQueryOrFragment((t=>82===t||42===t))}isQueryOrFragment(t){const e=this.atomCount;let n=this.getAtomBlockIdx();for(let i=0;i<e;i++){if(n=this.shiftIdxToAtomType(n),t(this.fileContent.charCodeAt(n),n))return!0;n=this.getNextLineIdx(n)}return!1}}var o;!function(t){t.HEADER="V2000",t[t.NUM_OF_HEADER_LINES=3]="NUM_OF_HEADER_LINES",t[t.NUM_OF_COUNTS_DIGITS=3]="NUM_OF_COUNTS_DIGITS",t[t.ATOM_TYPE_COL=4]="ATOM_TYPE_COL",t[t.FIRST_BONDED_ATOM_COL=1]="FIRST_BONDED_ATOM_COL",t[t.BOND_TYPE_COL=3]="BOND_TYPE_COL",t[t.RGP_SHIFT=8]="RGP_SHIFT",t.RGP_LINE="M RGP",t.A_LINE="A ",t.END="M END"}(o||(o={}));class r extends s{constructor(t){super(t)}static validate(t){return-1!==t.indexOf(o.HEADER)&&-1!==t.indexOf(o.END)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,o.ATOM_TYPE_COL)}getCountsLineIdx(){let t=0;for(let e=0;e<o.NUM_OF_HEADER_LINES;++e)t=this.getNextLineIdx(t);return t}getAtomBlockIdx(){let t=this.getCountsLineIdx();return t=this.getNextLineIdx(t),t}shiftIdxToXColumn(t){return this.getNextColumnIdx(t)}shiftIdxToBondedAtomsPair(t){return this.shiftIdxToSpecifiedColumn(t,o.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,o.BOND_TYPE_COL)}getBondBlockIdx(){let t=this.getAtomBlockIdx();for(let e=0;e<this.atomCount;e++)t=this.getNextLineIdx(t);return t}parseAtomAndBondCounts(){let t=this.getCountsLineIdx(),e=t+o.NUM_OF_COUNTS_DIGITS;const n=parseInt(this.fileContent.substring(t,e));return t=e,e+=o.NUM_OF_COUNTS_DIGITS,{atomCount:n,bondCount:parseInt(this.fileContent.substring(t,e))}}}class a extends s{constructor(t){super(t),this.init(t)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getCountsLineIdx(){return this.fileContent.indexOf("M V30 COUNTS ")}getAtomBlockIdx(){let t=this.fileContent.indexOf("M V30 BEGIN ATOM");return t=this.getNextLineIdx(t),t}shiftIdxToXColumn(t){let e=this.shiftIdxToAtomType(t);return this.isQuote(e)?(e=this.getNextIdenticalChar(e),e=this.getNextColumnIdx(e),e):this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondedAtomsPair(t){return this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getBondBlockIdx(){return this.getNextLineIdx(this.fileContent.indexOf("M V30 BEGIN BOND"))}static validate(t){return-1!==t.indexOf("V3000")&&-1!==t.indexOf("M END")}parseAtomAndBondCounts(){let t=this.fileContent.indexOf("M V30 COUNTS ")+14,e=this.fileContent.indexOf(" ",t+1);const n=parseInt(this.fileContent.substring(t,e));return t=e+1,e=this.fileContent.indexOf(" ",t+1),{atomCount:n,bondCount:parseInt(this.fileContent.substring(t,e))}}}class l{constructor(){}static getInstance(t){if(r.validate(t))return new r(t);if(a.validate(t))return new a(t);throw new Error("Malformed molfile")}}},7905:(t,e,n)=>{"use strict";t=n.hmd(t);var i,s=(i="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(t={}){var e,n,s=void 0!==t?t:{};s.ready=new Promise((function(t,i){e=t,n=i}));var o,r=Object.assign({},s),a="object"==typeof window,l="function"==typeof importScripts,c=("object"==typeof process&&"object"==typeof process.versions&&process.versions.node,"");(a||l)&&(l?c=self.location.href:"undefined"!=typeof document&&document.currentScript&&(c=document.currentScript.src),i&&(c=i),c=0!==c.indexOf("blob:")?c.substr(0,c.replace(/[?#].*/,"").lastIndexOf("/")+1):"",l&&(o=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)})),s.print||console.log.bind(console);var h,u,d=s.printErr||console.warn.bind(console);Object.assign(s,r),r=null,s.arguments&&s.arguments,s.thisProgram&&s.thisProgram,s.quit&&s.quit,s.wasmBinary&&(h=s.wasmBinary),s.noExitRuntime,"object"!=typeof WebAssembly&&x("no native wasm support detected");var m,p,g,f=!1;function y(){var t=u.buffer;s.HEAP8=m=new Int8Array(t),s.HEAP16=new Int16Array(t),s.HEAP32=new Int32Array(t),s.HEAPU8=p=new Uint8Array(t),s.HEAPU16=new Uint16Array(t),s.HEAPU32=g=new Uint32Array(t),s.HEAPF32=new Float32Array(t),s.HEAPF64=new Float64Array(t)}var b=[],C=[],w=[],v=0,S=null,A=null;function x(t){s.onAbort&&s.onAbort(t),d(t="Aborted("+t+")"),f=!0,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw n(e),e}var T,I,M="data:application/octet-stream;base64,";function L(t){return t.startsWith(M)}function E(t){try{if(t==T&&h)return new Uint8Array(h);if(o)return o(t);throw"both async and sync fetching of the wasm failed"}catch(t){x(t)}}function N(t,e,n){return function(t){return h||!a&&!l||"function"!=typeof fetch?Promise.resolve().then((function(){return E(t)})):fetch(t,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+t+"'";return e.arrayBuffer()})).catch((function(){return E(t)}))}(t).then((function(t){return WebAssembly.instantiate(t,e)})).then((function(t){return t})).then(n,(function(t){d("failed to asynchronously prepare wasm: "+t),x(t)}))}function R(t){for(;t.length>0;)t.shift()(s)}function _(t){this.excPtr=t,this.ptr=t-24,this.set_type=function(t){g[this.ptr+4>>2]=t},this.get_type=function(){return g[this.ptr+4>>2]},this.set_destructor=function(t){g[this.ptr+8>>2]=t},this.get_destructor=function(){return g[this.ptr+8>>2]},this.set_caught=function(t){t=t?1:0,m[this.ptr+12>>0]=t},this.get_caught=function(){return 0!=m[this.ptr+12>>0]},this.set_rethrown=function(t){t=t?1:0,m[this.ptr+13>>0]=t},this.get_rethrown=function(){return 0!=m[this.ptr+13>>0]},this.init=function(t,e){this.set_adjusted_ptr(0),this.set_type(t),this.set_destructor(e)},this.set_adjusted_ptr=function(t){g[this.ptr+16>>2]=t},this.get_adjusted_ptr=function(){return g[this.ptr+16>>2]},this.get_exception_ptr=function(){if(V(this.get_type()))return g[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}function O(t){var e=u.buffer;try{return u.grow(t-e.byteLength+65535>>>16),y(),1}catch(t){}}function P(t){return s["_"+t]}L(T="wasmDbscan.wasm")||(I=T,T=s.locateFile?s.locateFile(I,c):c+I);var G="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function k(t,e,n,i,s){var o={string:t=>{var e=0;return null!=t&&0!==t&&(e=function(t){var e=function(t){for(var e=0,n=0;n<t.length;++n){var i=t.charCodeAt(n);i<=127?e++:i<=2047?e+=2:i>=55296&&i<=57343?(e+=4,++n):e+=3}return e}(t)+1,n=D(e);return function(t,e,n){!function(t,e,n,i){if(!(i>0))return 0;for(var s=n+i-1,o=0;o<t.length;++o){var r=t.charCodeAt(o);if(r>=55296&&r<=57343&&(r=65536+((1023&r)<<10)|1023&t.charCodeAt(++o)),r<=127){if(n>=s)break;e[n++]=r}else if(r<=2047){if(n+1>=s)break;e[n++]=192|r>>6,e[n++]=128|63&r}else if(r<=65535){if(n+2>=s)break;e[n++]=224|r>>12,e[n++]=128|r>>6&63,e[n++]=128|63&r}else{if(n+3>=s)break;e[n++]=240|r>>18,e[n++]=128|r>>12&63,e[n++]=128|r>>6&63,e[n++]=128|63&r}}e[n]=0}(t,p,e,n)}(t,n,e),n}(t)),e},array:t=>{var e,n,i=D(t.length);return e=t,n=i,m.set(e,n),i}},r=P(t),a=[],l=0;if(i)for(var c=0;c<i.length;c++){var h=o[n[c]];h?(0===l&&(l=W()),a[c]=h(i[c])):a[c]=i[c]}var u=r.apply(null,a);return function(t){return 0!==l&&H(l),function(t){return"string"===e?(n=t)?function(t,e,n){for(var i=e+n,s=e;t[s]&&!(s>=i);)++s;if(s-e>16&&t.buffer&&G)return G.decode(t.subarray(e,s));for(var o="";e<s;){var r=t[e++];if(128&r){var a=63&t[e++];if(192!=(224&r)){var l=63&t[e++];if((r=224==(240&r)?(15&r)<<12|a<<6|l:(7&r)<<18|a<<12|l<<6|63&t[e++])<65536)o+=String.fromCharCode(r);else{var c=r-65536;o+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else o+=String.fromCharCode((31&r)<<6|a)}else o+=String.fromCharCode(r)}return o}(p,n,i):"":"boolean"===e?Boolean(t):t;var n,i}(t)}(u)}var F,B={__cxa_throw:function(t,e,n){throw new _(t).init(e,n),t},abort:function(){x("")},emscripten_memcpy_big:function(t,e,n){p.copyWithin(t,e,e+n)},emscripten_resize_heap:function(t){var e,n=p.length,i=2147483648;if((t>>>=0)>i)return!1;for(var s=1;s<=4;s*=2){var o=n*(1+.2/s);if(o=Math.min(o,t+100663296),O(Math.min(i,(e=Math.max(t,o))+(65536-e%65536)%65536)))return!0}return!1}},W=(function(){var t,e,i,o,r={env:B,wasi_snapshot_preview1:B};function a(t,e){var n,i=t.exports;return s.asm=i,u=s.asm.memory,y(),s.asm.__indirect_function_table,n=s.asm.__wasm_call_ctors,C.unshift(n),function(t){if(v--,s.monitorRunDependencies&&s.monitorRunDependencies(v),0==v&&(null!==S&&(clearInterval(S),S=null),A)){var e=A;A=null,e()}}(),i}if(v++,s.monitorRunDependencies&&s.monitorRunDependencies(v),s.instantiateWasm)try{return s.instantiateWasm(r,a)}catch(t){d("Module.instantiateWasm callback failed with error: "+t),n(t)}(t=h,e=T,i=r,o=function(t){a(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||L(e)||"function"!=typeof fetch?N(e,i,o):fetch(e,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,i).then(o,(function(t){return d("wasm streaming compile failed: "+t),d("falling back to ArrayBuffer instantiation"),N(e,i,o)}))}))).catch(n)}(),s._dbscan=function(){return(s._dbscan=s.asm.dbscan).apply(null,arguments)},s._malloc=function(){return(s._malloc=s.asm.malloc).apply(null,arguments)},s._free=function(){return(s._free=s.asm.free).apply(null,arguments)},function(){return(W=s.asm.stackSave).apply(null,arguments)}),H=function(){return(H=s.asm.stackRestore).apply(null,arguments)},D=function(){return(D=s.asm.stackAlloc).apply(null,arguments)},V=function(){return(V=s.asm.__cxa_is_pointer_type).apply(null,arguments)};function U(){function t(){F||(F=!0,s.calledRun=!0,f||(R(C),e(s),s.onRuntimeInitialized&&s.onRuntimeInitialized(),function(){if(s.postRun)for("function"==typeof s.postRun&&(s.postRun=[s.postRun]);s.postRun.length;)t=s.postRun.shift(),w.unshift(t);var t;R(w)}()))}v>0||(function(){if(s.preRun)for("function"==typeof s.preRun&&(s.preRun=[s.preRun]);s.preRun.length;)t=s.preRun.shift(),b.unshift(t);var t;R(b)}(),v>0||(s.setStatus?(s.setStatus("Running..."),setTimeout((function(){setTimeout((function(){s.setStatus("")}),1),t()}),1)):t()))}if(s.ccall=k,s.cwrap=function(t,e,n,i){var s=!n||n.every((t=>"number"===t||"boolean"===t));return"string"!==e&&s&&!i?P(t):function(){return k(t,e,n,arguments)}},A=function t(){F||U(),F||(A=t)},s.preInit)for("function"==typeof s.preInit&&(s.preInit=[s.preInit]);s.preInit.length>0;)s.preInit.pop()();return U(),t.ready});"object"==typeof exports?t.exports=s:"function"==typeof define&&n.amdO?define([],(function(){return s})):"object"==typeof exports&&(exports.exportCppDbscanLib=s)},2669:(t,e,n)=>{"use strict";n.d(e,{m:()=>i});class i{_workers;_workerCount;_terminateOnComplete;constructor(t=!0,e=!0){const i=navigator.hardwareConcurrency;this._workerCount=t?Math.max(i-2,1):1,this._workers=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(n.p+n.u(100),n.b)))),this._terminateOnComplete=e}async calc(t,e,n=!0,i){return new Promise((async(s,o)=>{try{const o=t.length,r=new Array(this._workerCount),a=o*(o-1)/2;this._workerCount=Math.min(this._workerCount,a);const l=a/this._workerCount,c=new Float32Array(a);let h=0,u=1,d=0,m=Number.MIN_VALUE;for(let n=0;n<this._workerCount;n++){const s=Math.floor(n*l),p=n===this._workerCount-1?a:Math.floor((n+1)*l),g=h,f=u;n!==this._workerCount-1&&(h=o-2-Math.floor(Math.sqrt(-8*p+4*o*(o-1)-7)/2-.5),u=p-o*h+Math.floor((h+1)*(h+2)/2)),this._workers[n].postMessage({values:t,fnName:e,startRow:g,startCol:f,chunckSize:p-s,opts:i}),r[n]=new Promise(((t,e)=>{this._workers[n].onmessage=({data:{error:i,distanceMatrixData:o,min:r,max:a}})=>{this._terminateOnComplete&&this._workers[n].terminate(),i?e(i):(c.set(o,s),r<d&&(d=r),a>m&&(m=a),t())}}))}await Promise.all(r),n&&c.forEach(((t,e)=>{c[e]=(t-d)/(m-d)})),s(c)}catch(t){o(t)}}))}terminate(){this._workers.forEach((t=>t.terminate()))}}},6254:(t,e,n)=>{"use strict";function i(t){return(e,n)=>t*e+n-Math.floor((e+2)*(e+1)/2)}n.d(e,{y:()=>i})},5697:(t,e,n)=>{"use strict";n.d(e,{Dz:()=>b,FV:()=>c,KR:()=>l,MI:()=>w,NB:()=>p,Om:()=>v,UX:()=>m,WI:()=>d,Z3:()=>a,Zd:()=>u,_h:()=>h,aW:()=>f,bX:()=>A,eo:()=>S,fX:()=>C,kg:()=>r,s:()=>g,yU:()=>y});var i=n(9657),s=n(1040),o=n(708);s.gk.Tanimoto,s.gk.Dice,s.gk.Asymmetric,s.gk.BraunBlanquet,s.gk.Cosine,s.gk.Kulczynski,s.gk.McConnaughey,s.gk.RogotGoldberg,s.gk.Russel,s.gk.Sokal,s.gk.Hamming,s.gk.Euclidean,s.gk.Tanimoto,s.gk.Dice,s.gk.Asymmetric,s.gk.BraunBlanquet,s.gk.Cosine,s.gk.Kulczynski,s.gk.McConnaughey,s.gk.RogotGoldberg,s.gk.Russel,s.gk.Sokal,s.gk.Hamming,s.gk.Euclidean;const r=[s.gk.Tanimoto,s.gk.Dice,s.gk.Cosine];function a(t,e){const n=t.trueCount()+e.trueCount();if(0==n)return 1;const i=t.andWithCountBits(e,!0);return i/(n-i)}function l(t,e){return S(a(t,e))}function c(t,e){return S(a(new i.Z(t,32*t.length),new i.Z(e,32*e.length)))}function h(t,e){return S(function(t,e){const n=t.trueCount()+e.trueCount();return 0==n?0:2*t.andWithCountBits(e,!0)/n}(t,e))}function u(t,e){return S(function(t,e){const n=t.trueCount()*e.trueCount();return 0==n?0:t.andWithCountBits(e,!0)/Math.sqrt(n)}(t,e))}function d(t,e){return Math.sqrt(t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0))}function m(t,e){return t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0)}function p(t,e){return S(function(t,e){const n=t.trueCount()+e.trueCount(),i=t.andWithCountBits(e,!0);return i/(2*n-3*i)}(t,e))}function g(t,e){return S(function(t,e){const n=t.trueCount()+e.trueCount(),i=t.trueCount()*e.trueCount();return 0==i?0:t.andWithCountBits(e,!0)*n/(2*i)}(t,e))}function f(t,e){return S(function(t,e){const n=t.trueCount()+e.trueCount(),i=t.trueCount()*e.trueCount();return 0==i?0:(t.andWithCountBits(e,!0)*n-i)/i}(t,e))}function y(t,e){return S(function(t,e){const n=Math.min(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e))}function b(t,e){return S(function(t,e){const n=Math.max(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e))}function C(t,e){return S(function(t,e){return 0==t.length?0:t.andWithCountBits(e,!0)/t.length}(t,e))}function w(t,e){return S(function(t,e){const n=t.andWithCountBits(e,!0),i=t.countBits(!0)+e.countBits(!0),s=t.length,o=s-i+n;return n==s||o==s?1:n/i+o/(2*s-i)}(t,e))}function v(t){return 1/(1+t)}function S(t){return 0===t?3402823e32:1/t-1}function A(t,e){return Math.abs(t-e)}s.gk.Tanimoto,s.gk.Asymmetric,s.gk.Cosine,s.gk.Sokal,o.U.HAMMING,o.U.LEVENSHTEIN,o.U.MONOMER_CHEMICAL_DISTANCE,o.U.NEEDLEMANN_WUNSCH},3277:(t,e,n)=>{"use strict";n.d(e,{Ec:()=>c,dB:()=>a,n3:()=>i,q6:()=>r,sS:()=>l,ts:()=>o,vO:()=>s});const i="dim-red-preprocessing-function",s="supportedSemTypes",o="supportedTypes",r="supportedUnits",a="supportedDistanceFunctions",l="bypassLargeDataWarning",c="show-scatterplot-progress"},708:(t,e,n)=>{"use strict";function i(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,i=Math.min(...Object.keys(e).map((t=>t.charCodeAt(0))))+1,s=new Float32Array((n.length+i)*(n.length+i));return Object.entries(e).forEach((([t,i])=>{const o=n[i];Object.entries(e).forEach((([e,i])=>{s[t.charCodeAt(0)*n.length+e.charCodeAt(0)]=o[i]}))})),(t,e)=>s[t.charCodeAt(0)*n.length+e.charCodeAt(0)]}(),n=t?.threshold??0;return(t,i)=>{let s=0;const o=t.length,r=i.length,a=Math.max(o,r)*(1-n);o!==r&&(s=Math.abs(o-r));let l=0;for(let n=0;n<Math.min(o,r);n++)if(t[n]!==i[n]&&(l+=e(t[n],i[n]),l>a))return 1;return l+=s,l/=Math.max(o,r),l}}n.d(e,{U:()=>r,o:()=>a});var s=n(1811);const o={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],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ance"}(r||(r={}));const a={[r.HAMMING]:i,[r.LEVENSHTEIN]:function(){return(t,e)=>(0,s.T)(t,e)/Math.max(t.length,e.length)},[r.NEEDLEMANN_WUNSCH]:function(t){const e=new Uint16Array(65536),{gapOpen:n,gapExtend:i,scoringMatrix:s,alphabetIndexes:r}={...o,...t};Object.entries(r).forEach((([t,n])=>e[t.charCodeAt(0)]=n));const a=[new Float32Array(1e4),new Float32Array(1e4)];return(t,o)=>{const r=new Array(t.length+1).fill(!1),l=new Array(t.length+1).fill(!1);let c=0,h=1;for(let e=1;e<t.length+1;e++)a[0][e]=-n-(e-1)*i,a[1][e]=0;for(let u=1;u<o.length+1;u++){a[h][0]=-n-(u-1)*i;for(let d=1;d<t.length+1;d++){const m=a[c][d-1]+s[e[t.charCodeAt(d-1)]][e[o.charCodeAt(u-1)]],p=a[c][d]-(r[d]?i:n),g=a[h][d-1]-(l[d-1]?i:n);a[h][d]=Math.max(m,g,p),a[h][d]===m?(r[d]=!1,l[d]=!1):a[h][d]===g?(r[d]=!1,l[d]=!0):(r[d]=!0,l[d]=!1)}c=h,h=(h+1)%2}const u=Math.max(t.length,o.length);return(u-a[c][t.length])/u}},[r.MONOMER_CHEMICAL_DISTANCE]:i}},4628:(t,e,n)=>{"use strict";var i;n.d(e,{A:()=>i}),function(t){t.UMAP="UMAP",t.T_SNE="t-SNE"}(i||(i={}))},1040:(t,e,n)=>{"use strict";var i,s,o,r,a,l;n.d(e,{CF:()=>s,Qe:()=>a,W:()=>i,Yc:()=>l,gd:()=>r,gk:()=>o}),function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan",t.Onehot="One-Hot"}(i||(i={})),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"}(o||(o={})),function(t){t.TanimotoIntArray="TanimotoIntArray"}(r||(r={})),function(t){t.Vector="Vector",t.String="String",t.BitArray="BitArray",t.MacroMolecule="MacroMolecule",t.Number="Number",t.IntArray="IntArray"}(a||(a={})),function(t){t.Difference="Difference"}(l||(l={}))},6361:(t,e,n)=>{"use strict";n.d(e,{W:()=>i.W,gk:()=>i.gk});var i=n(1040);n(7861)},7861:(t,e,n)=>{"use strict";n.d(e,{sQ:()=>f});var i=n(1811),s=n(3979),o=n(5697),r=n(850),a=n(708),l=n(1040);const c={[l.CF.Euclidean]:r.dP},h={[l.W.Levenshtein]:i.T,[l.W.JaroWinkler]:s.H$,[l.W.Manhattan]:function(t,e){if(t.length!==e.length)return 1;{let n=0;for(let i=1;i<t.length;i++)n+=t[i]==e[i]?0:1;return n/t.length}},[l.W.Onehot]:function(t,e){return t===e?0:1}},u={[l.gk.Tanimoto]:o.KR,[l.gk.Dice]:o._h,[l.gk.Asymmetric]:o.yU,[l.gk.BraunBlanquet]:o.Dz,[l.gk.Cosine]:o.Zd,[l.gk.Kulczynski]:o.s,[l.gk.McConnaughey]:o.aW,[l.gk.RogotGoldberg]:o.MI,[l.gk.Russel]:o.fX,[l.gk.Sokal]:o.NB,[l.gk.Hamming]:o.UX,[l.gk.Euclidean]:o.WI},d={[l.gd.TanimotoIntArray]:o.FV},m={[l.Yc.Difference]:o.bX},p={[l.Qe.Vector]:{[l.CF.Euclidean]:c[l.CF.Euclidean]},[l.Qe.String]:{[l.W.Levenshtein]:h[l.W.Levenshtein],[l.W.JaroWinkler]:h[l.W.JaroWinkler],[l.W.Manhattan]:h[l.W.Manhattan],[l.W.Onehot]:h[l.W.Onehot]},[l.Qe.BitArray]:{[l.gk.Tanimoto]:u[l.gk.Tanimoto],[l.gk.Dice]:u[l.gk.Dice],[l.gk.Asymmetric]:u[l.gk.Asymmetric],[l.gk.BraunBlanquet]:u[l.gk.BraunBlanquet],[l.gk.Cosine]:u[l.gk.Cosine],[l.gk.Kulczynski]:u[l.gk.Kulczynski],[l.gk.McConnaughey]:u[l.gk.McConnaughey],[l.gk.RogotGoldberg]:u[l.gk.RogotGoldberg],[l.gk.Russel]:u[l.gk.Russel],[l.gk.Sokal]:u[l.gk.Sokal]},[l.Qe.MacroMolecule]:{[a.U.HAMMING]:a.o[a.U.HAMMING],[a.U.LEVENSHTEIN]:a.o[a.U.LEVENSHTEIN],[a.U.NEEDLEMANN_WUNSCH]:a.o[a.U.NEEDLEMANN_WUNSCH],[a.U.MONOMER_CHEMICAL_DISTANCE]:a.o[a.U.MONOMER_CHEMICAL_DISTANCE]},[l.Qe.Number]:{[l.Yc.Difference]:m[l.Yc.Difference]},[l.Qe.IntArray]:{[l.gd.TanimotoIntArray]:d[l.gd.TanimotoIntArray]}},g=Object.keys(p).reduce(((t,e)=>{for(const n of Object.keys(p[e]))t[n]=e;return t}),{});function f(t){return"BitArray"==g[t]}},9657:(t,e,n)=>{"use strict";n.d(e,{Z:()=>i});class i{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,s=i._createBuffer(n);if(e)for(let t=0;t<s.length;t++)s[t]=-1;this._data=s,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,i){if(t<e||t>n)throw new Error(`Argument ${i} (${t}) out of range (${e}, ${n})`)}copy(t,e,n){for(let i=0;i<n;i++)e[i]=t[i]}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 i(t._length);n._length=t._length,n._data=i._createBuffer(n._length),n._version=0;const s=t.lengthInInts;for(let i=0;i<s;i++)n._data[i]=t._data[i]&e._data[i];return n}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new i(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 i(t);for(let i=0;i<t;++i)n.setBit(i,e(i));return n._version=0,n}static fromString(t){return i.fromSeq(t.length,(e=>"1"==t.charAt(e)))}static fromUint32Array(t,e){const n=new i(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new i(8*e);n._data=new Uint32Array(Math.floor((e+3)/4)),n._length=8*e;let s=0,o=0;for(;e-o>=4;)n._data[s++]=255&t[o]|(255&t[o+1])<<8|(255&t[o+2])<<16|(255&t[o+3])<<24,o+=4;return e-o==3&&(n._data[s]=(255&t[o+2])<<16),e-o==2&&(n._data[s]|=(255&t[o+1])<<8),e-o==1&&(n._data[s]|=255&t[o]),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 i(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,i=this.lengthInInts;for(let t=0;t<i;t++)this._data[t]=n;this.incrementVersion(e)}setIndexes(t,e=!0,n=!0,i=!0){n&&this.setAll(!e,!1);for(const n of t)this.setFast(n,e);this.incrementVersion(i)}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,i=!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(i)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let i=t;i<e;++i)n.push(this.getBit(i));return i.fromValues(n)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let i=t;i<e;++i)n.push(this.getBit(i));return n}setRange(t,e,n,i=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const s=Math.min(t,e),o=Math.max(t,e);if(n)for(let t=s;t<=o;t++)this.setTrue(t);else for(let t=s;t<=o;t++)this.setFalse(t);return this.incrementVersion(i),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 i=this._length;this.setLength(this._length+e);for(let n=i-1;n>=t;n--)this.setBit(n+e,this.getBit(n));for(let i=t;i<t+e;i++)this.setBit(i,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 i=-1;-1!=(i=t.findNext(i,!e));)this.setFast(n++,this.getBit(i));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+=i._onBitCount[255&t];let n=this._data[e];const s=31&this._length;for(0!=s&&(n&=~(4294967295<<s));0!=n;n>>>=8)this._selectedCount+=i._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 s=this.lengthInInts;let o=0;for(;o<s-1;o++)for(let e=this._data[o]&t._data[o];0!=e;e>>>=8)n+=i._onBitCount[255&e];let r=this._data[o]&t._data[o];const a=31&this._length;for(0!=a&&(r&=~(4294967295<<a));0!=r;r>>>=8)n+=i._onBitCount[255&r];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 s=this.lengthInInts;for(let o=Math.floor(t/32);o<s;o++){let s=e?this._data[o]:~this._data[o];if(0!=n)s&=4294967295<<n&4294967295,n=0;else if(!e&&-4294967296==s)continue;for(let e=0;0!=s;e+=8,s>>>=8){const n=i._firstOnBit[255&s];if(n>=0)return(t=n+32*o+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 s=Math.floor(t/32);s>=0;s--){let t=e?this._data[s]:~this._data[s];0!=n&&(t&=~(4294967295<<n),n=0);for(let e=24;0!=t;e-=8,t<<=8){const n=i._lastOnBit[t>>>24];if(n>=0)return n+32*s+e}}return-1}}i._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]),i._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]),i._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])},279:(t,e,n)=>{"use strict";function i(t,e,n){function i(t,e){let n=null,i=null;for(const s of t){const t=e(s);(null==i||t>i)&&(n=s,i=t)}return n}const s=[(r=t-1,Math.floor(function(t){return Math.random()*t}(r)))],o=new Set;var r;for(let e=0;e<t;++e)s.includes(e)||o.add(e);for(;s.length<e;){const t=i(o.values(),(t=>Math.min.apply(Math,s.map((function(e,i){return n(t,e)})))));null!=t&&(s.push(t),o.delete(t))}return s}n.d(e,{L:()=>i})},8467:(t,e,n)=>{"use strict";n.d(e,{gw:()=>a,zg:()=>r}),n(4469);var i=n(976);n(9133),i.DataFrame.fromCsv('countries,fasta,smiles,molregno,LON,Zip Code,Street Address Line 1,ImageUrl,user_id,error_message,xray,flag,magnitude,CS-id,pdb_id,accel_a,time_offset,chart,fit,Questions,empty_number,empty_string\nBelgium,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C(=O)OCCCc1cccnc1)c2cccc(c2)C(=O)c3ccccc3,1480014,36.276729583740234,995042300,14016 ROUTE 31W,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,1,1,1QBS,1,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.497360340644872, 1.7058694986686864, 5.278052678195135, 0.16000320889028383],""points"":[{""x"":0.10000000149011612,""y"":2.374499797821045},{""x"":0.6000000238418579,""y"":2.6242473125457764},{""x"":1.100000023841858,""y"":2.367267608642578},{""x"":1.600000023841858,""y"":2.6723148822784424},{""x"":2.0999999046325684,""y"":2.6537344455718994},{""x"":2.5999999046325684,""y"":2.3651671409606934},{""x"":3.0999999046325684,""y"":2.5654284954071045},{""x"":3.5999999046325684,""y"":2.4160959720611572},{""x"":4.099999904632568,""y"":2.286726713180542},{""x"":4.599999904632568,""y"":2.5100042819976807},{""x"":5.099999904632568,""y"":1.6676985025405884},{""x"":5.599999904632568,""y"":0.680136501789093},{""x"":6.099999904632568,""y"":0.3391543924808502},{""x"":6.599999904632568,""y"":0.09038983285427094},{""x"":7.099999904632568,""y"":0.19802775979042053}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[7.525235855508179, 1.3186911876809984, 5.335672608564294, 0.7860743343958098],""points"":[{""x"":0.10000000149011612,""y"":7.988070487976074},{""x"":0.6000000238418579,""y"":7.018453121185303},{""x"":1.100000023841858,""y"":8.115279197692871},{""x"":1.600000023841858,""y"":7.486658096313477},{""x"":2.0999999046325684,""y"":7.396438121795654},{""x"":2.5999999046325684,""y"":7.477052211761475},{""x"":3.0999999046325684,""y"":6.913095474243164},{""x"":3.5999999046325684,""y"":8.01385498046875},{""x"":4.099999904632568,""y"":6.985900402069092},{""x"":4.599999904632568,""y"":6.970335960388184},{""x"":5.099999904632568,""y"":5.448817253112793},{""x"":5.599999904632568,""y"":2.5534818172454834},{""x"":6.099999904632568,""y"":1.893947958946228},{""x"":6.599999904632568,""y"":0.6340042352676392},{""x"":7.099999904632568,""y"":0.8403874039649963}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,100,abc\nBurundi,MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW,COc1ccc2cc(ccc2c1)C(C)C(=O)Oc3ccc(C)cc3OC,1480015,36.276729583740234,995073444,80 STATE HIGHWAY 310,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,2,2,1ZP8,2,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.431460753103398, 2.1691498799246745, 5.266445597102774, 0.7825762827017926],""points"":[{""x"":0.10000000149011612,""y"":4.751083850860596},{""x"":0.6000000238418579,""y"":4.203000068664551},{""x"":1.100000023841858,""y"":4.415858745574951},{""x"":1.600000023841858,""y"":4.68414306640625},{""x"":2.0999999046325684,""y"":4.198400974273682},{""x"":2.5999999046325684,""y"":4.179222106933594},{""x"":3.0999999046325684,""y"":4.638473987579346},{""x"":3.5999999046325684,""y"":4.708553314208984},{""x"":4.099999904632568,""y"":4.291589260101318},{""x"":4.599999904632568,""y"":4.038082599639893},{""x"":5.099999904632568,""y"":3.4349939823150635},{""x"":5.599999904632568,""y"":1.2194708585739136},{""x"":6.099999904632568,""y"":1.1920831203460693},{""x"":6.599999904632568,""y"":0.5352635979652405},{""x"":7.099999904632568,""y"":0.3346920311450958}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.339458017970126, -1.0734184310171178, 4.746332950550934, 0.2482416857595658],""points"":[{""x"":0.10000000149011612,""y"":0.2139337658882141},{""x"":0.6000000238418579,""y"":0.4269562065601349},{""x"":1.100000023841858,""y"":0.2441573292016983},{""x"":1.600000023841858,""y"":0.146635964512825},{""x"":2.0999999046325684,""y"":0.08818462491035461},{""x"":2.5999999046325684,""y"":0.2560656666755676},{""x"":3.0999999046325684,""y"":0.42434045672416687},{""x"":3.5999999046325684,""y"":0.37111231684684753},{""x"":4.099999904632568,""y"":0.5581737160682678},{""x"":4.599999904632568,""y"":1.183590054512024},{""x"":5.099999904632568,""y"":1.5629843473434448},{""x"":5.599999904632568,""y"":2.3211288452148438},{""x"":6.099999904632568,""y"":2.229961633682251},{""x"":6.599999904632568,""y"":2.2560226917266846},{""x"":7.099999904632568,""y"":2.2142398357391357}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCameroon,MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL,COc1ccc2cc(ccc2c1)C(C)C(=O)OCCCc3cccnc3,1480016,36.26095962524414,995153596,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,3,3,2BDJ,3,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.6760652578642325, 0.9046956320756703, 5.651408971856738, 0.07738846012184185],""points"":[{""x"":0.10000000149011612,""y"":4.32425594329834},{""x"":0.6000000238418579,""y"":4.668442249298096},{""x"":1.100000023841858,""y"":4.379785060882568},{""x"":1.600000023841858,""y"":5.0345139503479},{""x"":2.0999999046325684,""y"":4.878653526306152},{""x"":2.5999999046325684,""y"":4.3451313972473145},{""x"":3.0999999046325684,""y"":4.336992263793945},{""x"":3.5999999046325684,""y"":5.037430286407471},{""x"":4.099999904632568,""y"":5.0092692375183105},{""x"":4.599999904632568,""y"":4.151902675628662},{""x"":5.099999904632568,""y"":3.4066951274871826},{""x"":5.599999904632568,""y"":2.3732759952545166},{""x"":6.099999904632568,""y"":1.673728108406067},{""x"":6.599999904632568,""y"":0.48574790358543396},{""x"":7.099999904632568,""y"":0.2783052325248718}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.938395863010111, -1.4658480661392117, 5.462702751996584, 0.3473139023615039],""points"":[{""x"":0.10000000149011612,""y"":0.4941710829734802},{""x"":0.6000000238418579,""y"":0.15323974192142487},{""x"":1.100000023841858,""y"":0.46373432874679565},{""x"":1.600000023841858,""y"":0.3370431363582611},{""x"":2.0999999046325684,""y"":0.5179030299186707},{""x"":2.5999999046325684,""y"":0.27899765968322754},{""x"":3.0999999046325684,""y"":0.22075064480304718},{""x"":3.5999999046325684,""y"":0.5789918899536133},{""x"":4.099999904632568,""y"":0.21169911324977875},{""x"":4.599999904632568,""y"":0.27857646346092224},{""x"":5.099999904632568,""y"":1.0906332731246948},{""x"":5.599999904632568,""y"":1.8520300388336182},{""x"":6.099999904632568,""y"":2.7177059650421143},{""x"":6.599999904632568,""y"":2.8680918216705322},{""x"":7.099999904632568,""y"":3.2413077354431152}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCanada,MMELVLKTIIGPIVVGVVLRIVDKWLNKDK,CC(C(=O)NCCS)c1cccc(c1)C(=O)c2ccccc2,1480017,36.26095962524414,99515,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,4,4,1IAN,4,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[0.8597390975430008, 1.0957625732481946, 5.260537067987958, 0.07974187998177736],""points"":[{""x"":0.10000000149011612,""y"":0.8190152645111084},{""x"":0.6000000238418579,""y"":0.8421689867973328},{""x"":1.100000023841858,""y"":0.8740922212600708},{""x"":1.600000023841858,""y"":0.8924275040626526},{""x"":2.0999999046325684,""y"":0.8249067664146423},{""x"":2.5999999046325684,""y"":0.9327669143676758},{""x"":3.0999999046325684,""y"":0.8522974252700806},{""x"":3.5999999046325684,""y"":0.8174492716789246},{""x"":4.099999904632568,""y"":0.8394647240638733},{""x"":4.599999904632568,""y"":0.7139387726783752},{""x"":5.099999904632568,""y"":0.5561167597770691},{""x"":5.599999904632568,""y"":0.3276226818561554},{""x"":6.099999904632568,""y"":0.12479474395513535},{""x"":6.599999904632568,""y"":0.13006797432899475},{""x"":7.099999904632568,""y"":0.059702079743146896}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.760930219582546, 1.6591793293833013, 4.667155929720851, 0.7858109544121652],""points"":[{""x"":0.10000000149011612,""y"":6.156993389129639},{""x"":0.6000000238418579,""y"":5.236701965332031},{""x"":1.100000023841858,""y"":6.010560512542725},{""x"":1.600000023841858,""y"":5.495512962341309},{""x"":2.0999999046325684,""y"":6.087770462036133},{""x"":2.5999999046325684,""y"":5.79986572265625},{""x"":3.0999999046325684,""y"":5.597546577453613},{""x"":3.5999999046325684,""y"":5.520902156829834},{""x"":4.099999904632568,""y"":5.360654354095459},{""x"":4.599999904632568,""y"":3.5539746284484863},{""x"":5.099999904632568,""y"":1.577236294746399},{""x"":5.599999904632568,""y"":1.0001264810562134},{""x"":6.099999904632568,""y"":0.9305797815322876},{""x"":6.599999904632568,""y"":0.6033638715744019},{""x"":7.099999904632568,""y"":0.4203685522079468}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nColombia,MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN,FC(F)(F)c1ccc(OC2CCNCC2)cc1,1480029,36.3309440612793,995152050,1 COURT HOUSE SQUARE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,5,5,4UJ1,5,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[6.4995088314153655, 2.4270351004539914, 5.178659535348579, 0.625653346241577],""points"":[{""x"":0.10000000149011612,""y"":6.496231555938721},{""x"":0.6000000238418579,""y"":6.42543363571167},{""x"":1.100000023841858,""y"":7.040063858032227},{""x"":1.600000023841858,""y"":6.1115403175354},{""x"":2.0999999046325684,""y"":6.680728435516357},{""x"":2.5999999046325684,""y"":6.406774520874023},{""x"":3.0999999046325684,""y"":6.611269474029541},{""x"":3.5999999046325684,""y"":5.889094352722168},{""x"":4.099999904632568,""y"":6.75344705581665},{""x"":4.599999904632568,""y"":6.361435890197754},{""x"":5.099999904632568,""y"":4.1666975021362305},{""x"":5.599999904632568,""y"":1.172118902206421},{""x"":6.099999904632568,""y"":0.801048994064331},{""x"":6.599999904632568,""y"":0.4640021026134491},{""x"":7.099999904632568,""y"":0.0010357667924836278}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[1.4734381347446401, 1.1649805188074196, 4.82958608866421, 0.09500545496710007],""points"":[{""x"":0.10000000149011612,""y"":1.5279096364974976},{""x"":0.6000000238418579,""y"":1.3559974431991577},{""x"":1.100000023841858,""y"":1.5246378183364868},{""x"":1.600000023841858,""y"":1.5567657947540283},{""x"":2.0999999046325684,""y"":1.4114240407943726},{""x"":2.5999999046325684,""y"":1.4045010805130005},{""x"":3.0999999046325684,""y"":1.4769829511642456},{""x"":3.5999999046325684,""y"":1.4875500202178955},{""x"":4.099999904632568,""y"":1.2991987466812134},{""x"":4.599999904632568,""y"":0.922961413860321},{""x"":5.099999904632568,""y"":0.6520044803619385},{""x"":5.599999904632568,""y"":0.15350978076457977},{""x"":6.099999904632568,""y"":0.1078903079032898},{""x"":6.599999904632568,""y"":0.17276449501514435},{""x"":7.099999904632568,""y"":0.14066608250141144}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCosta Rica,MKSTKEEIQTIKTLLKDSRTAKYHKRLQIVL,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCCc3ccccc3,1480018,36.3309440612793,995084218,4041 SOUTHWESTERN BLVD,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,6,6,2BPW,6,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.4833641843311227, -1.8945978742090062, 4.671127708092568, 0.24159861311815153],""points"":[{""x"":0.10000000149011612,""y"":0.0969524160027504},{""x"":0.6000000238418579,""y"":0.028483040630817413},{""x"":1.100000023841858,""y"":0.22087176144123077},{""x"":1.600000023841858,""y"":0.0068915546871721745},{""x"":2.0999999046325684,""y"":0.4305879771709442},{""x"":2.5999999046325684,""y"":0.44774115085601807},{""x"":3.0999999046325684,""y"":0.45346319675445557},{""x"":3.5999999046325684,""y"":0.2370593100786209},{""x"":4.099999904632568,""y"":0.4657953977584839},{""x"":4.599999904632568,""y"":1.155200719833374},{""x"":5.099999904632568,""y"":2.2294070720672607},{""x"":5.599999904632568,""y"":2.4311530590057373},{""x"":6.099999904632568,""y"":2.33846116065979},{""x"":6.599999904632568,""y"":2.608201026916504},{""x"":7.099999904632568,""y"":2.8136143684387207}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.224573521642033, 1.4454033924198528, 5.6014197746076535, 0.2823216054197577],""points"":[{""x"":0.10000000149011612,""y"":4.95027494430542},{""x"":0.6000000238418579,""y"":5.1754679679870605},{""x"":1.100000023841858,""y"":5.276752948760986},{""x"":1.600000023841858,""y"":5.589294910430908},{""x"":2.0999999046325684,""y"":5.616994857788086},{""x"":2.5999999046325684,""y"":5.120813846588135},{""x"":3.0999999046325684,""y"":5.340766906738281},{""x"":3.5999999046325684,""y"":4.876471042633057},{""x"":4.099999904632568,""y"":4.94999361038208},{""x"":4.599999904632568,""y"":5.162564754486084},{""x"":5.099999904632568,""y"":4.399557590484619},{""x"":5.599999904632568,""y"":2.7977969646453857},{""x"":6.099999904632568,""y"":1.0229872465133667},{""x"":6.599999904632568,""y"":0.48275601863861084},{""x"":7.099999904632568,""y"":0.10408931970596313}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCuba,MHAILRYFIRRLFYHIFYKIYSLISKKHQSLPSDVRQF,COc1ccc2c(c1)c(CC(=O)N3CCCC3C(=O)Oc4ccc(C)cc4OC)c(C)n2C(=O)c5ccc(Cl)cc5,1480019,36.33115768432617,995081928,1227 US HIGHWAY 11,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,7,7,1QBS,7,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.320838679713925, -1.2421619987316728, 4.831325425225256, 0.3236011098403072],""points"":[{""x"":0.10000000149011612,""y"":0.3727470338344574},{""x"":0.6000000238418579,""y"":0.12365014106035233},{""x"":1.100000023841858,""y"":0.48422467708587646},{""x"":1.600000023841858,""y"":0.2264465093612671},{""x"":2.0999999046325684,""y"":0.16821794211864471},{""x"":2.5999999046325684,""y"":0.3879014551639557},{""x"":3.0999999046325684,""y"":0.5470244884490967},{""x"":3.5999999046325684,""y"":0.3419053554534912},{""x"":4.099999904632568,""y"":0.7655120491981506},{""x"":4.599999904632568,""y"":1.2346516847610474},{""x"":5.099999904632568,""y"":2.453336715698242},{""x"":5.599999904632568,""y"":2.9565491676330566},{""x"":6.099999904632568,""y"":3.335299491882324},{""x"":6.599999904632568,""y"":3.240290880203247},{""x"":7.099999904632568,""y"":3.1107218265533447}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.6401853521511094, 1.26211588875013, 5.399028074402744, 0.5089580830068091],""points"":[{""x"":0.10000000149011612,""y"":3.8585598468780518},{""x"":0.6000000238418579,""y"":3.6077206134796143},{""x"":1.100000023841858,""y"":3.855252265930176},{""x"":1.600000023841858,""y"":3.619039297103882},{""x"":2.0999999046325684,""y"":3.839388370513916},{""x"":2.5999999046325684,""y"":3.335283041000366},{""x"":3.0999999046325684,""y"":3.571141481399536},{""x"":3.5999999046325684,""y"":3.4155046939849854},{""x"":4.099999904632568,""y"":3.7316646575927734},{""x"":4.599999904632568,""y"":3.0680155754089355},{""x"":5.099999904632568,""y"":2.891066551208496},{""x"":5.599999904632568,""y"":1.6022753715515137},{""x"":6.099999904632568,""y"":0.7652576565742493},{""x"":6.599999904632568,""y"":0.6875326037406921},{""x"":7.099999904632568,""y"":0.5828871726989746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nItaly,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO[N+](=O)[O-],1480020,36.33115768432617,99502,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,8,8,1ZP8,8,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.293592105923809, 1.3781586549141835, 5.1025898038676605, 0.03493851245291291],""points"":[{""x"":0.10000000149011612,""y"":2.1287283897399902},{""x"":0.6000000238418579,""y"":2.267972230911255},{""x"":1.100000023841858,""y"":2.398442506790161},{""x"":1.600000023841858,""y"":2.5130622386932373},{""x"":2.0999999046325684,""y"":2.3255116939544678},{""x"":2.5999999046325684,""y"":2.127340793609619},{""x"":3.0999999046325684,""y"":2.47259783744812},{""x"":3.5999999046325684,""y"":2.131181478500366},{""x"":4.099999904632568,""y"":2.090421438217163},{""x"":4.599999904632568,""y"":2.02299165725708},{""x"":5.099999904632568,""y"":1.1105059385299683},{""x"":5.599999904632568,""y"":0.4494485855102539},{""x"":6.099999904632568,""y"":0.1375635862350464},{""x"":6.599999904632568,""y"":0.036351121962070465},{""x"":7.099999904632568,""y"":0.1619771122932434}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.953125499439879, 1.2528620255306528, 5.187637440149802, 0.3110348753260886],""points"":[{""x"":0.10000000149011612,""y"":5.6585283279418945},{""x"":0.6000000238418579,""y"":5.911152362823486},{""x"":1.100000023841858,""y"":5.924920082092285},{""x"":1.600000023841858,""y"":5.8469438552856445},{""x"":2.0999999046325684,""y"":5.929472923278809},{""x"":2.5999999046325684,""y"":6.190037727355957},{""x"":3.0999999046325684,""y"":6.236179828643799},{""x"":3.5999999046325684,""y"":6.141019344329834},{""x"":4.099999904632568,""y"":5.295210838317871},{""x"":4.599999904632568,""y"":5.265801906585693},{""x"":5.099999904632568,""y"":3.3722851276397705},{""x"":5.599999904632568,""y"":1.8299226760864258},{""x"":6.099999904632568,""y"":0.32690900564193726},{""x"":6.599999904632568,""y"":0.6274543404579163},{""x"":7.099999904632568,""y"":0.8441857099533081}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nRwanda,MPNSEPASLLELFNSIATQGELVRSLKAGNASK,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO,1480021,36.33137130737305,995037247,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,9,2BDJ,9,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.8209972202654474, 1.3779216716448506, 5.299882228439686, 0.06040645519069608],""points"":[{""x"":0.10000000149011612,""y"":3.7821109294891357},{""x"":0.6000000238418579,""y"":3.542433023452759},{""x"":1.100000023841858,""y"":3.7008674144744873},{""x"":1.600000023841858,""y"":3.717301607131958},{""x"":2.0999999046325684,""y"":4.024452209472656},{""x"":2.5999999046325684,""y"":4.013899326324463},{""x"":3.0999999046325684,""y"":3.945094347000122},{""x"":3.5999999046325684,""y"":3.866621971130371},{""x"":4.099999904632568,""y"":3.7461626529693604},{""x"":4.599999904632568,""y"":3.3454740047454834},{""x"":5.099999904632568,""y"":2.61944317817688},{""x"":5.599999904632568,""y"":0.999405026435852},{""x"":6.099999904632568,""y"":0.46259793639183044},{""x"":6.599999904632568,""y"":0.054134611040353775},{""x"":7.099999904632568,""y"":0.05711187422275543}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.6318079657726035, 1.8495493770000595, 5.391793312471116, 0.17060707587348442],""points"":[{""x"":0.10000000149011612,""y"":5.458079814910889},{""x"":0.6000000238418579,""y"":5.554427146911621},{""x"":1.100000023841858,""y"":5.799983024597168},{""x"":1.600000023841858,""y"":5.364140033721924},{""x"":2.0999999046325684,""y"":5.864485740661621},{""x"":2.5999999046325684,""y"":5.4509806632995605},{""x"":3.0999999046325684,""y"":5.702574729919434},{""x"":3.5999999046325684,""y"":5.7314534187316895},{""x"":4.099999904632568,""y"":5.5123443603515625},{""x"":4.599999904632568,""y"":5.724395751953125},{""x"":5.099999904632568,""y"":4.354506969451904},{""x"":5.599999904632568,""y"":1.7307666540145874},{""x"":6.099999904632568,""y"":0.6305936574935913},{""x"":6.599999904632568,""y"":0.035183437168598175},{""x"":7.099999904632568,""y"":0.7575169205665588}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nSwitzerland,IRVVGRYLIEVWKAAGMDMDKVLFLWSSDEI,CN1CCC(CC1)Oc2ccc(cc2)C(F)(F)F,1480028,36.33137130737305,99504,92-11 179TH PLACE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,10,1IAN,10,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[1.1190255865097471, 2.3163895161544437, 5.4968866182279195, 0.2035204047289052],""points"":[{""x"":0.10000000149011612,""y"":1.1057683229446411},{""x"":0.6000000238418579,""y"":1.1019697189331055},{""x"":1.100000023841858,""y"":1.0818607807159424},{""x"":1.600000023841858,""y"":1.062997817993164},{""x"":2.0999999046325684,""y"":1.046447515487671},{""x"":2.5999999046325684,""y"":1.1217249631881714},{""x"":3.0999999046325684,""y"":1.2166996002197266},{""x"":3.5999999046325684,""y"":1.215477705001831},{""x"":4.099999904632568,""y"":1.0581893920898438},{""x"":4.599999904632568,""y"":1.1747995615005493},{""x"":5.099999904632568,""y"":1.0181127786636353},{""x"":5.599999904632568,""y"":0.5344523191452026},{""x"":6.099999904632568,""y"":0.2569526433944702},{""x"":6.599999904632568,""y"":0.1912207305431366},{""x"":7.099999904632568,""y"":0.15060538053512573}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.1038581025805785, 2.0032224204185245, 5.087602825989163, 0.13277988512492753],""points"":[{""x"":0.10000000149011612,""y"":3.0498509407043457},{""x"":0.6000000238418579,""y"":2.805217742919922},{""x"":1.100000023841858,""y"":3.3415253162384033},{""x"":1.600000023841858,""y"":3.0549843311309814},{""x"":2.0999999046325684,""y"":3.250074863433838},{""x"":2.5999999046325684,""y"":3.0432586669921875},{""x"":3.0999999046325684,""y"":3.265852451324463},{""x"":3.5999999046325684,""y"":2.9475724697113037},{""x"":4.099999904632568,""y"":3.1929898262023926},{""x"":4.599999904632568,""y"":2.7460060119628906},{""x"":5.099999904632568,""y"":1.6175861358642578},{""x"":5.599999904632568,""y"":0.3006608486175537},{""x"":6.099999904632568,""y"":0.3444803059101105},{""x"":6.599999904632568,""y"":0.015537971630692482},{""x"":7.099999904632568,""y"":0.5527358055114746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\n,,,,,,,,,,,,,,,,,,,,,').columns.add(i.Column.fromList(i.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var s,o=function(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function r(t,e,n,i=0){return o(this,void 0,void 0,(function*(){return new Promise(((s,o)=>{const r=t.subscribe((t=>{try{e(t),s("OK")}catch(t){o(t)}r.unsubscribe(),clearTimeout(a)})),a=setTimeout((()=>{r.unsubscribe(),o("timeout")}),i);n()}))}))}function a(t){return o(this,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,t)))}))}!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(s||(s={})),i.DataFrame.fromColumns([i.Column.fromStrings("col",["val1","val2","val3"])])},850:(t,e,n)=>{"use strict";function i(t=!1,e="Assertion error."){if(!t)throw new Error(e)}function s(t){let e=0;for(let n=0;n<t.length;n++)e+=t[n]*t[n];return Math.sqrt(e)}function o(t,e){if(t.length!=e.length)throw new Error("The dimensionality of the vectors must match");let n=0;for(let i=0;i<t.length;i++)n+=t[i]*e[i];return n}function r(t,e){let n=0;const i=t.length;if(i!==e.length)throw new Error("The dimensionality of the vectors must match");for(let s=0;s<i;++s)n+=Math.pow(t[s]-e[s],2);return Math.sqrt(n)}function a(t){const e=t.length;let n=0,i=0;for(let s=0;s<e;++s)n+=t[s],i+=Math.pow(t[s],2);const s=n/e,o=1/Math.sqrt(i/e-Math.pow(s,2));for(let n=0;n<e;++n)t[n]=(t[n]-s)*o;return t}n.d(e,{$G:()=>s,Fv:()=>a,MA:()=>o,dP:()=>r,hu:()=>i})},5362:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(7537),s=n.n(i),o=n(3645),r=n.n(o)()(s());r.push([t.id,".macromolecule-cell-comp-analysis-host{\n max-height: 250px;\n overflow-y: scroll;\n}\n\n.macromolecule-cell-comp-analysis-bar{\n height: inherit;\n display: block;\n margin-top: 1.5px;\n margin-bottom: 1.5px;\n margin-right: 3px;\n}\n\n.macromolecule-cell-comp-analysis-value{\n display: flex;\n}","",{version:3,sources:["webpack://./css/composition-analysis.css"],names:[],mappings:"AAAA;IACI,iBAAiB;IACjB,kBAAkB;AACtB;;AAEA;IACI,eAAe;IACf,cAAc;IACd,iBAAiB;IACjB,oBAAoB;IACpB,iBAAiB;AACrB;;AAEA;IACI,aAAa;AACjB",sourcesContent:[".macromolecule-cell-comp-analysis-host{\n max-height: 250px;\n overflow-y: scroll;\n}\n\n.macromolecule-cell-comp-analysis-bar{\n height: inherit;\n display: block;\n margin-top: 1.5px;\n margin-bottom: 1.5px;\n margin-right: 3px;\n}\n\n.macromolecule-cell-comp-analysis-value{\n display: flex;\n}"],sourceRoot:""}]);const a=r},9564:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(7537),s=n.n(i),o=n(3645),r=n.n(o)()(s());r.push([t.id,".kalign-version {\n margin-bottom: 0;\n text-align: end;\n font-size: 12px;\n opacity: 0.8;\n}\nbutton.msa-params-button.ui-btn {\n justify-content: end;\n}","",{version:3,sources:["webpack://./css/msa.css"],names:[],mappings:"AAAA;IACI,gBAAgB;IAChB,eAAe;IACf,eAAe;IACf,YAAY;AAChB;AACA;IACI,oBAAoB;AACxB",sourcesContent:[".kalign-version {\n margin-bottom: 0;\n text-align: end;\n font-size: 12px;\n opacity: 0.8;\n}\nbutton.msa-params-button.ui-btn {\n justify-content: end;\n}"],sourceRoot:""}]);const a=r},9414:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(7537),s=n.n(i),o=n(3645),r=n.n(o)()(s());r.push([t.id,".scatter_plot_link {\n position: absolute!important;\n right: 10px;\n}\n\n.cliffs_grid {\n top: 10px;\n}\n\n.show_only_cliffs {\n top: 30px;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings {\n font-size: 18px;\n position: absolute;\n height: 28px;\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/ml/css/styles.css"],names:[],mappings:"AAAA;IACI,4BAA4B;IAC5B,WAAW;AACf;;AAEA;IACI,SAAS;AACb;;AAEA;IACI,SAAS;AACb;;AAEA;IACI,eAAe;IACf,kBAAkB;IAClB,YAAY;AAChB",sourcesContent:[".scatter_plot_link {\n position: absolute!important;\n right: 10px;\n}\n\n.cliffs_grid {\n top: 10px;\n}\n\n.show_only_cliffs {\n top: 30px;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings {\n font-size: 18px;\n position: absolute;\n height: 28px;\n}\n"],sourceRoot:""}]);const a=r},3645:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",i=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),i&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),i&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,i,s,o){"string"==typeof t&&(t=[[null,t,void 0]]);var r={};if(i)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(r[l]=!0)}for(var c=0;c<t.length;c++){var h=[].concat(t[c]);i&&r[h[0]]||(void 0!==o&&(void 0===h[5]||(h[1]="@layer".concat(h[5].length>0?" ".concat(h[5]):""," {").concat(h[1],"}")),h[5]=o),n&&(h[2]?(h[1]="@media ".concat(h[2]," {").concat(h[1],"}"),h[2]=n):h[2]=n),s&&(h[4]?(h[1]="@supports (".concat(h[4],") {").concat(h[1],"}"),h[4]=s):h[4]="".concat(s)),e.push(h))}},e}},7537:t=>{"use strict";t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var i=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),s="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),o="/*# ".concat(s," */");return[e].concat([o]).join("\n")}return[e].join("\n")}},9133:function(t,e,n){var i;!function(e,s){var o={};!function(t){"use strict";t.__esModule=!0,t.digestLength=32,t.blockSize=64;var e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t,n,i,s,o){for(var r,a,l,c,h,u,d,m,p,g,f,y,b;o>=64;){for(r=n[0],a=n[1],l=n[2],c=n[3],h=n[4],u=n[5],d=n[6],m=n[7],g=0;g<16;g++)f=s+4*g,t[g]=(255&i[f])<<24|(255&i[f+1])<<16|(255&i[f+2])<<8|255&i[f+3];for(g=16;g<64;g++)y=((p=t[g-2])>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,b=((p=t[g-15])>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,t[g]=(y+t[g-7]|0)+(b+t[g-16]|0);for(g=0;g<64;g++)y=(((h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7))+(h&u^~h&d)|0)+(m+(e[g]+t[g]|0)|0)|0,b=((r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10))+(r&a^r&l^a&l)|0,m=d,d=u,u=h,h=c+y|0,c=l,l=a,a=r,r=y+b|0;n[0]+=r,n[1]+=a,n[2]+=l,n[3]+=c,n[4]+=h,n[5]+=u,n[6]+=d,n[7]+=m,s+=64,o-=64}return s}var i=function(){function e(){this.digestLength=t.digestLength,this.blockSize=t.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return e.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},e.prototype.clean=function(){for(var t=0;t<this.buffer.length;t++)this.buffer[t]=0;for(t=0;t<this.temp.length;t++)this.temp[t]=0;this.reset()},e.prototype.update=function(t,e){if(void 0===e&&(e=t.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var i=0;if(this.bytesHashed+=e,this.bufferLength>0){for(;this.bufferLength<64&&e>0;)this.buffer[this.bufferLength++]=t[i++],e--;64===this.bufferLength&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(e>=64&&(i=n(this.temp,this.state,t,i,e),e%=64);e>0;)this.buffer[this.bufferLength++]=t[i++],e--;return this},e.prototype.finish=function(t){if(!this.finished){var e=this.bytesHashed,i=this.bufferLength,s=e/536870912|0,o=e<<3,r=e%64<56?64:128;this.buffer[i]=128;for(var a=i+1;a<r-8;a++)this.buffer[a]=0;this.buffer[r-8]=s>>>24&255,this.buffer[r-7]=s>>>16&255,this.buffer[r-6]=s>>>8&255,this.buffer[r-5]=s>>>0&255,this.buffer[r-4]=o>>>24&255,this.buffer[r-3]=o>>>16&255,this.buffer[r-2]=o>>>8&255,this.buffer[r-1]=o>>>0&255,n(this.temp,this.state,this.buffer,0,r),this.finished=!0}for(a=0;a<8;a++)t[4*a+0]=this.state[a]>>>24&255,t[4*a+1]=this.state[a]>>>16&255,t[4*a+2]=this.state[a]>>>8&255,t[4*a+3]=this.state[a]>>>0&255;return this},e.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},e.prototype._saveState=function(t){for(var e=0;e<this.state.length;e++)t[e]=this.state[e]},e.prototype._restoreState=function(t,e){for(var n=0;n<this.state.length;n++)this.state[n]=t[n];this.bytesHashed=e,this.finished=!1,this.bufferLength=0},e}();t.Hash=i;var s=function(){function t(t){this.inner=new i,this.outer=new i,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new i).update(t).finish(e).clean();else for(var n=0;n<t.length;n++)e[n]=t[n];for(n=0;n<e.length;n++)e[n]^=54;for(this.inner.update(e),n=0;n<e.length;n++)e[n]^=106;for(this.outer.update(e),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),n=0;n<e.length;n++)e[n]=0}return t.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},t.prototype.clean=function(){for(var t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean()},t.prototype.update=function(t){return this.inner.update(t),this},t.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},t.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},t}();function o(t){var e=(new i).update(t),n=e.digest();return e.clean(),n}function r(t,e){var n=new s(t).update(e),i=n.digest();return n.clean(),i}function a(t,e,n,i){var s=i[0];if(0===s)throw new Error("hkdf: cannot expand more");e.reset(),s>1&&e.update(t),n&&e.update(n),e.update(i),e.finish(t),i[0]++}t.HMAC=s,t.hash=o,t.default=o,t.hmac=r;var l=new Uint8Array(t.digestLength);t.hkdf=function(t,e,n,i){void 0===e&&(e=l),void 0===i&&(i=32);for(var o=new Uint8Array([1]),c=r(e,t),h=new s(c),u=new Uint8Array(h.digestLength),d=u.length,m=new Uint8Array(i),p=0;p<i;p++)d===u.length&&(a(u,h,n,o),d=0),m[p]=u[d++];return h.clean(),u.fill(0),o.fill(0),m},t.pbkdf2=function(t,e,n,i){for(var o=new s(t),r=o.digestLength,a=new Uint8Array(4),l=new Uint8Array(r),c=new Uint8Array(r),h=new Uint8Array(i),u=0;u*r<i;u++){var d=u+1;a[0]=d>>>24&255,a[1]=d>>>16&255,a[2]=d>>>8&255,a[3]=d>>>0&255,o.reset(),o.update(e),o.update(a),o.finish(c);for(var m=0;m<r;m++)l[m]=c[m];for(m=2;m<=n;m++){o.reset(),o.update(c).finish(c);for(var p=0;p<r;p++)l[p]^=c[p]}for(m=0;m<r&&u*r+m<i;m++)h[u*r+m]=l[m]}for(u=0;u<r;u++)l[u]=c[u]=0;for(u=0;u<4;u++)a[u]=0;return o.clean(),h}}(o);var r=o.default;for(var a in o)r[a]=o[a];"object"==typeof t.exports?t.exports=r:void 0===(i=function(){return r}.call(o,n,o,t))||(t.exports=i)}()},1811:(t,e,n)=>{"use strict";n.d(e,{T:()=>s});const i=new Uint32Array(65536),s=(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,s=e.length,o=1<<n-1;let r=-1,a=0,l=n,c=n;for(;c--;)i[t.charCodeAt(c)]|=1<<c;for(c=0;c<s;c++){let t=i[e.charCodeAt(c)];const n=t|a;t|=(t&r)+r^r,a|=~(t|r),r&=t,a&o&&l++,r&o&&l--,a=a<<1|1,r=r<<1|~(n|a),a&=n}for(c=n;c--;)i[t.charCodeAt(c)]=0;return l})(t,e):((t,e)=>{const n=e.length,s=t.length,o=[],r=[],a=Math.ceil(n/32),l=Math.ceil(s/32);for(let t=0;t<a;t++)r[t]=-1,o[t]=0;let c=0;for(;c<l-1;c++){let a=0,l=-1;const h=32*c,u=Math.min(32,s)+h;for(let e=h;e<u;e++)i[t.charCodeAt(e)]|=1<<e;for(let t=0;t<n;t++){const n=i[e.charCodeAt(t)],s=r[t/32|0]>>>t&1,c=o[t/32|0]>>>t&1,h=n|a,u=((n|c)&l)+l^l|n|c;let d=a|~(u|l),m=l&u;d>>>31^s&&(r[t/32|0]^=1<<t),m>>>31^c&&(o[t/32|0]^=1<<t),d=d<<1|s,m=m<<1|c,l=m|~(h|d),a=d&h}for(let e=h;e<u;e++)i[t.charCodeAt(e)]=0}let h=0,u=-1;const d=32*c,m=Math.min(32,s-d)+d;for(let e=d;e<m;e++)i[t.charCodeAt(e)]|=1<<e;let p=s;for(let t=0;t<n;t++){const n=i[e.charCodeAt(t)],a=r[t/32|0]>>>t&1,l=o[t/32|0]>>>t&1,c=n|h,d=((n|l)&u)+u^u|n|l;let m=h|~(d|u),g=u&d;p+=m>>>s-1&1,p-=g>>>s-1&1,m>>>31^a&&(r[t/32|0]^=1<<t),g>>>31^l&&(o[t/32|0]^=1<<t),m=m<<1|a,g=g<<1|l,u=g|~(c|m),h=m&c}for(let e=d;e<m;e++)i[t.charCodeAt(e)]=0;return p})(t,e)}},3979:(t,e)=>{"use strict";e.H$=void 0,e.H$=function(t,e,n){var i=function(t,e,n){if(0===t.length||0===e.length)return 0;if(n&&!n.caseSensitive&&(t=t.toUpperCase(),e=e.toUpperCase()),t===e)return 1;for(var i=0,s=t.length,o=e.length,r=Math.floor(Math.max(s,o)/2)-1,a=new Array(s),l=new Array(o),c=0;c<s;c++)for(var h=Math.max(0,c-r);h<=Math.min(o,c+r+1);h++)if(!a[c]&&!l[h]&&t[c]===e[h]){++i,a[c]=l[h]=!0;break}if(0===i)return 0;var u=0,d=0;for(c=0;c<s;c++)if(a[c]){for(;!l[d];)d++;t.charAt(c)!==e.charAt(d++)&&u++}return(i/s+i/o+(i-(u/=2))/i)/3}(t,e,n),s=0;if(i>.7){for(var o=Math.min(t.length,e.length),r=0;t[r]===e[r]&&r<4&&r<o;)++s,r++;i+=.1*s*(1-i)}return i}},3379:t=>{"use strict";var e=[];function n(t){for(var n=-1,i=0;i<e.length;i++)if(e[i].identifier===t){n=i;break}return n}function i(t,i){for(var o={},r=[],a=0;a<t.length;a++){var l=t[a],c=i.base?l[0]+i.base:l[0],h=o[c]||0,u="".concat(c," ").concat(h);o[c]=h+1;var d=n(u),m={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)e[d].references++,e[d].updater(m);else{var p=s(m,i);i.byIndex=a,e.splice(a,0,{identifier:u,updater:p,references:1})}r.push(u)}return r}function s(t,e){var n=e.domAPI(e);return n.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,s){var o=i(t=t||[],s=s||{});return function(t){t=t||[];for(var r=0;r<o.length;r++){var a=n(o[r]);e[a].references--}for(var l=i(t,s),c=0;c<o.length;c++){var h=n(o[c]);0===e[h].references&&(e[h].updater(),e.splice(h,1))}o=l}}},569:t=>{"use strict";var e={};t.exports=function(t,n){var i=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(n)}},9216:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},3565:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},7795:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var i="";n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {"));var s=void 0!==n.layer;s&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,s&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}");var o=n.sourceMap;o&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},4589:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},7241:(t,e,n)=>{"use strict";n.d(e,{D:()=>h});var i=n(4469),s=n(976),o=n(6414),r=n.n(o),a=n(4955),l=n(499);const c=31;async function h(t,e=!1,n){const o=l.Cn.getOrCreate(t);let h;n??(n=new Map);const d=o.isHelm()?(0,a.getHelmMonomers)(t):Object.keys(o.stats.freq).filter((t=>""!==t));for(let t=0;t<d.length;t++)n.has(d[t])||n.set(d[t],`${n.size+1}`);if(o.isHelm())h=await i.functions.call("HELM:getMolFiles",{col:t}),h=function(t,e,n=!1){const i=new Array(t.length);for(let s=0;s<t.length;s++){let o=0,r=0,a="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";const l=t.get(s);o=l.indexOf("\n",o)+1,o=l.indexOf("\n",o)+1,o=l.indexOf("\n",o)+1;const h=parseInt(l.substring(o,o+3)),u=parseInt(l.substring(o+3,o+6));a+=`M V30 COUNTS ${h} ${u} 0 0 0\n`,a+="M V30 BEGIN ATOM\n";for(let t=0;t<h;t++){o=l.indexOf("\n",o)+1+c,r=l.indexOf(" ",o);const i=l.substring(o,r);a+=n?`M V30 ${t+1} R${e.get(i)} 0.000 0.000 0 0\n`:`M V30 ${t+1} At 0.000 0.000 0 0 MASS=${e.get(i)}\n`}a+="M V30 END ATOM\n",a+="M V30 BEGIN BOND\n";for(let t=0;t<u;t++){o=l.indexOf("\n",o)+1;const e=parseInt(l.substring(o,o+3).trim()),n=parseInt(l.substring(o+3,o+6).trim());a+=`M V30 ${t+1} ${parseInt(l.substring(o+6,o+9).trim())} ${e} ${n}\n`}a+="M V30 END BOND\n",a+="M V30 END CTAB\n",a+="M END",i[s]=a}return i}(h,n,e);else{h=new Array(t.length);for(let i=0;i<t.length;i++){const t=u(r()(o.splitted[i]).filter((t=>""!==t)).toArray(),n,e);h[i]=t}}return s.Column.fromStrings("monomericMols",h)}function u(t,e,n=!1){let i="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";i+=`M V30 COUNTS ${t.length} ${t.length?t.length-1:0} 0 0 0\n`,i+="M V30 BEGIN ATOM\n";for(let s=0;s<t.length;s++)i+=n?`M V30 ${s+1} R${e.get(t[s])} 0.000 0.000 0 0\n`:`M V30 ${s+1} At 0.000 0.000 0 0 MASS=${e.get(t[s])}\n`;i+="M V30 END ATOM\n",i+="M V30 BEGIN BOND\n";for(let e=0;e<t.length-1;e++)i+=`M V30 ${e+1} 1 ${e+1} ${e+2}\n`;return i+="M V30 END BOND\n",i+="M V30 END CTAB\n",i+="M END",i}},4955:(t,e,n)=>{"use strict";n.r(e),n.d(e,{GetRegionEditor:()=>Tn,SeqActivityCliffsEditor:()=>Ln,SeqPaletteCustom:()=>Cn,SequenceSpaceEditor:()=>Mn,SplitToMonomersEditor:()=>In,SubsequenceSearchTopMenu:()=>ri,_package:()=>fn,activityCliffs:()=>Wn,addCopyMenu:()=>gi,alignSequences:()=>Yn,bioSubstructureFilter:()=>hi,compositionAnalysis:()=>$n,compositionAnalysisWidget:()=>Rn,convertDialog:()=>qn,demoBioActivityCliffs:()=>bi,demoBioAtomicLevel:()=>Ci,demoBioHelmMsaSequenceSpace:()=>wi,demoBioSequenceSpace:()=>yi,demoBioSimilarityDiversity:()=>fi,detectMacromoleculeProbe:()=>Ai,diversitySearchTopMenu:()=>si,diversitySearchViewer:()=>ii,fastaSequenceCellRenderer:()=>En,getBioLib:()=>Sn,getHelmMonomers:()=>ti,getMonomerLibHelper:()=>yn,getRegion:()=>Fn,getRegionApp:()=>mi,getRegionHelmApp:()=>pi,getRegionPanel:()=>An,getRegionTopMenu:()=>Bn,helmPreprocessingFunction:()=>Dn,hydrophobPalette:()=>bn,importBam:()=>Xn,importFasta:()=>Kn,initBio:()=>wn,libraryPanel:()=>xn,macroMolColumnPropertyPanel:()=>Nn,macromoleculeDifferenceCellRenderer:()=>On,macromoleculePreprocessingFunction:()=>Hn,monomerCellRenderer:()=>jn,multipleSequenceAlignmentDialog:()=>Zn,polyTool:()=>zn,polyToolColumnChoice:()=>vi,saveAsFasta:()=>ci,sdfToJsonLib:()=>Si,searchSubsequenceEditor:()=>oi,separatorSequenceCellRenderer:()=>_n,sequenceAlignment:()=>Pn,sequenceIdentityScoring:()=>ai,sequenceSimilarityScoring:()=>li,sequenceSpaceTopMenu:()=>Vn,sequenceTooltip:()=>vn,similaritySearchTopMenu:()=>ni,similaritySearchViewer:()=>ei,splitToMonomersTopMenu:()=>Qn,testDetectMacromolecule:()=>Jn,toAtomicLevel:()=>Un,vdRegionsViewer:()=>kn,webLogoAggApp:()=>di,webLogoLargeApp:()=>ui,webLogoViewer:()=>Gn});var i,s,o=n(4469),r=n(3870),a=n(976),l=n(3277),c=n(4628);(s=i||(i={})).EUCLIDEAN="EUCLIDEAN",s.MANHATTAN="MANHATTAN";class h{learningRate={uiName:"Learinig rate",value:1,tooltip:"The initial learning rate for the embedding optimization"};nComponents={uiName:"Components",value:2,tooltip:"The number of components (dimensions) to project the data to"};nEpochs={uiName:"Epochs",value:0,tooltip:"The number of epochs to optimize embeddings via SGD. Computed automatically if set to 0"};nNeighbors={uiName:"Neighbors",value:15,tooltip:"The number of nearest neighbors to construct the fuzzy manifold"};spread={uiName:"Spread",value:1,tooltip:"The effective scale of embedded points, used with min distance to control \n the clumped/dispersed nature of the embedding"};minDist={uiName:"Min distance",value:.1,tooltip:"The effective minimum distance between embedded points, \n used with spread to control the clumped/dispersed nature of the embedding"};randomSeed={uiName:"Random seed",value:null,tooltip:"Random seed",type:"string"};constructor(){}}class u{epsilon={uiName:"Epsilon",value:10,tooltip:"Epsilon is learning rate"};perplexity={uiName:"Perplexity",value:30,tooltip:"Roughly how many neighbors each point influences"};dim={uiName:"Dimensionality",value:2,tooltip:"Dimensionality of the embedding"};constructor(){}}a.SEMTYPE.MOLECULE,a.SEMTYPE.MACROMOLECULE;class d{epsilon={uiName:"Epsilon",value:.01,tooltip:"Minimum distance between cluster points",min:0,max:2,step:.005};minPts={uiName:"Minimum points",value:4,tooltip:"Minimum number of points in cluster",min:1,max:1e3,step:1};constructor(){}}class m{editorSettings={};tableInput;colInput;preprocessingFunctionInput;plotEmbeddingsInput=r.boolInput("Plot embeddings",!0);clusterEmbeddingsInput=r.boolInput("Cluster embeddings",!0);preprocessingFunctionInputRoot=null;colInputRoot;methodInput;methodSettingsIcon;dbScanSettingsIcon;preprocessingFuncSettingsIcon;columnFunctionsMap={};supportedFunctions={};availableMetrics=[];similarityMetricInputRoot;methodSettingsDiv=r.inputs([]);dbScanSettingsDiv=r.inputs([]);preprocessingFuncSettingsDiv=r.inputs([]);preprocessingFunctionSettings={};methodsParams={[c.A.UMAP]:new h,[c.A.T_SNE]:new u};dbScanParams=new d;similarityMetricInput;get algorithmOptions(){const t=this.methodsParams[this.methodInput.value],e={};return Object.keys(t).forEach((n=>{null!=t[n].value&&(e[n]=t[n].value)})),e}get dbScanOptions(){return{dbScanEpsilon:this.dbScanParams.epsilon.value??.01,dbScanMinPts:this.dbScanParams.minPts.value??4}}constructor(t={}){this.editorSettings=t,a.Func.find({tags:[l.n3]}).forEach((t=>{const e=t.options.get(l.vO)??"",n=t.friendlyName??t.name,i=t.options.get(l.ts)??"",s=t.options.get(l.q6)??"",o=t.options.get(l.dB)??"";this.editorSettings.semtype&&!e.includes(this.editorSettings.semtype)||this.editorSettings.type&&!i.includes(this.editorSettings.type)||this.editorSettings.units&&!s.includes(this.editorSettings.units)||(this.supportedFunctions[n]={func:t,semTypes:e?e.split(","):[],types:i?i.split(","):[],units:s?s.split(","):[],distanceFunctions:o?o.split(","):[]})})),this.tableInput=r.tableInput("Table",o.shell.tv.dataFrame,o.shell.tables,(()=>{this.onTableInputChanged()})),this.onTableInputChanged(),this.regenerateColInput(),this.onColumnInputChanged();let e=!1,n=!1;this.methodInput=r.choiceInput("Method",c.A.UMAP,[c.A.UMAP,c.A.T_SNE],(()=>{e&&this.createAlgorithmSettingsDiv(this.methodSettingsDiv,this.methodsParams[this.methodInput.value])})),this.methodSettingsIcon=r.icons.settings((()=>{e=!e,e?this.createAlgorithmSettingsDiv(this.methodSettingsDiv,this.methodsParams[this.methodInput.value]):r.empty(this.methodSettingsDiv)}),"Modify methods parameters"),this.dbScanSettingsIcon=r.icons.settings((()=>{n=!n,n?this.createAlgorithmSettingsDiv(this.dbScanSettingsDiv,this.dbScanParams):r.empty(this.dbScanSettingsDiv)}),"Modify clustering parameters"),this.clusterEmbeddingsInput.classList.add("ml-dim-reduction-settings-input"),this.clusterEmbeddingsInput.root.prepend(this.dbScanSettingsIcon),this.methodInput.root.classList.add("ml-dim-reduction-settings-input"),this.methodInput.root.prepend(this.methodSettingsIcon),this.methodSettingsDiv=r.inputs([]);const i=this.columnFunctionsMap[this.colInput.value.name];this.preprocessingFunctionInput=r.choiceInput("Encoding function",i[0],i,(()=>{this.onPreprocessingFunctionChanged()}));let s=!1;this.preprocessingFunctionInputRoot||(this.preprocessingFunctionInputRoot=this.preprocessingFunctionInput.root,s=!0),s||(r.empty(this.preprocessingFunctionInputRoot),Array.from(this.preprocessingFunctionInput.root.children).forEach((t=>this.preprocessingFunctionInputRoot.append(t)))),this.preprocessingFunctionInputRoot.classList.add("ml-dim-reduction-settings-input");let h=!1;this.preprocessingFuncSettingsIcon=r.icons.settings((async()=>{h?r.empty(this.preprocessingFuncSettingsDiv):await this.createPreprocessingFuncParamsDiv(this.preprocessingFuncSettingsDiv,this.supportedFunctions[this.preprocessingFunctionInput.value].func),h=!h}),"Modify encoding function parameters"),this.preprocessingFunctionInputRoot.prepend(this.preprocessingFuncSettingsIcon),this.similarityMetricInput=r.choiceInput("Similarity","",[],null),this.similarityMetricInput.nullable=!1,this.similarityMetricInputRoot||(this.similarityMetricInputRoot=this.similarityMetricInput.root),this.onPreprocessingFunctionChanged()}getColInput(){const t=this.tableInput.value?.columns.toList().find((t=>!!this.columnFunctionsMap[t.name]))??null,e=r.columnInput("Column",this.tableInput.value,t,(()=>this.onColumnInputChanged()),{filter:t=>!!this.columnFunctionsMap[t.name]});return this.colInputRoot||(this.colInputRoot=e.root),e}regenerateColInput(){let t=!1;this.colInputRoot&&(t=!0,r.empty(this.colInputRoot)),this.colInput=this.getColInput(),t&&Array.from(this.colInput.root.children).forEach((t=>this.colInputRoot.append(t))),this.onColumnInputChanged()}onTableInputChanged(){const t=this.tableInput.value;t&&(this.columnFunctionsMap={},t.columns.toList().forEach((t=>{Object.keys(this.supportedFunctions).forEach((e=>{const n=this.supportedFunctions[e].semTypes,i=this.supportedFunctions[e].types,s=this.supportedFunctions[e].units,o=!n.length||t.semType&&n.includes(t.semType),r=!i.length||i.includes(t.type),l=!s.length||t.getTag(a.TAGS.UNITS)&&s.includes(t.getTag(a.TAGS.UNITS));o&&r&&l&&(this.columnFunctionsMap[t.name]||(this.columnFunctionsMap[t.name]=[]),this.columnFunctionsMap[t.name].push(e))}))})),this.regenerateColInput())}onColumnInputChanged(){const t=this.colInput.value;if(!t)return;const e=this.columnFunctionsMap[t.name];this.preprocessingFunctionInput=r.choiceInput("Preprocessing function",e[0],e,(()=>{this.onPreprocessingFunctionChanged()}));let n=!1;this.preprocessingFunctionInputRoot||(this.preprocessingFunctionInputRoot=this.preprocessingFunctionInput.root,n=!0),n||(r.empty(this.preprocessingFunctionInputRoot),Array.from(this.preprocessingFunctionInput.root.children).forEach((t=>this.preprocessingFunctionInputRoot.append(t)))),this.onPreprocessingFunctionChanged()}onPreprocessingFunctionChanged(){r.empty(this.preprocessingFuncSettingsDiv),this.preprocessingFunctionSettings={};const t=this.preprocessingFunctionInput.value,e=this.supportedFunctions[t].distanceFunctions;this.availableMetrics=[...e],this.similarityMetricInput=r.choiceInput("Similarity",this.availableMetrics[0],this.availableMetrics,null),this.similarityMetricInput.nullable=!1,this.similarityMetricInputRoot||(this.similarityMetricInputRoot=this.similarityMetricInput.root),r.empty(this.similarityMetricInputRoot),Array.from(this.similarityMetricInput.root.children).forEach((t=>this.similarityMetricInputRoot.append(t))),this.preprocessingFuncSettingsIcon&&(this.supportedFunctions[t].func.inputs.length<3?this.preprocessingFuncSettingsIcon.style.display="none":this.preprocessingFuncSettingsIcon.style.display="flex")}createAlgorithmSettingsDiv(t,e){return r.empty(t),Object.keys(e).forEach((n=>{const i=e[n],s="string"===i.type?r.stringInput(i.uiName,i.value??"",(()=>{i.value=s.value})):r.floatInput(i.uiName,i.value,(()=>{i.value=s.value}));r.tooltip.bind(s.root,i.tooltip),t.append(s.root)})),t}async createPreprocessingFuncParamsDiv(t,e){if(r.empty(t),e.inputs.length<3)return r.div();const n=e.prepare(),i=await n.buildEditor(r.div());for(let s=2;s<e.inputs.length;s++){const o=e.inputs[s];(this.preprocessingFunctionSettings[o.name]||n.inputParams[e.inputs[s].name].value||o.defaultValue)&&(this.preprocessingFunctionSettings[o.name]=this.preprocessingFunctionSettings[o.name]??n.inputParams[o.name].value??o.defaultValue);const r=i.find((t=>t.property.name===o.name));r&&(null!==this.preprocessingFunctionSettings[o.name]&&void 0!==this.preprocessingFunctionSettings[o.name]&&(r.value=this.preprocessingFunctionSettings[o.name]),r.onChanged((()=>{this.preprocessingFunctionSettings[o.name]=r.value})),t.append(r.root))}return t}getEditor(){return r.div([this.tableInput,this.colInputRoot,this.preprocessingFunctionInputRoot,this.preprocessingFuncSettingsDiv,this.methodInput,this.methodSettingsDiv,this.similarityMetricInputRoot,this.plotEmbeddingsInput,this.clusterEmbeddingsInput,this.dbScanSettingsDiv],{style:{minWidth:"320px"},classes:"ui-form"})}getParams(){return{table:this.tableInput.value,col:this.colInput.value,methodName:this.methodInput.value,preprocessingFunction:this.supportedFunctions[this.preprocessingFunctionInput.value].func,similarityMetric:this.similarityMetricInput.value,plotEmbeddings:this.plotEmbeddingsInput.value,clusterEmbeddings:this.clusterEmbeddingsInput.value,options:{...this.algorithmOptions,...this.dbScanOptions,preprocessingFuncArgs:this.preprocessingFunctionSettings??{}}}}}var p=n(442),g=n(5697),f=n(701),y=n(3379),b=n.n(y),C=n(7795),w=n.n(C),v=n(569),S=n.n(v),A=n(3565),x=n.n(A),T=n(9216),I=n.n(T),M=n(4589),L=n.n(M),E=n(9414),N={};N.styleTagTransform=L(),N.setAttributes=x(),N.insert=S().bind(null,"head"),N.domAPI=w(),N.insertStyleElement=I(),b()(E.Z,N),E.Z&&E.Z.locals&&E.Z.locals;var R=n(7861);const _=t=>null==t;function O(t,e,n,i){if(n>t[t.length-1])return;const s=t.findIndex((t=>n<t));t.pop(),t.splice(s,0,n),e.pop(),e.splice(s,0,i)}var P=n(6254),G=n(2669),k=n(6361);class F{_workerCount;constructor(){this._workerCount=Math.max(navigator.hardwareConcurrency-2,1)}async calc(t,e,i,s={}){const o=t.length*(t.length-1)/2,r=Math.floor(o/this._workerCount),a=t.length>2e4?await this.getMinimalThreshold(t,e,s):0;i<a&&(console.log(`using threshold ${a}`),i=a),s.threshold=i;const l=new Array(this._workerCount),c=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(n.p+n.u(471),n.b))));for(let n=0;n<this._workerCount;n++)l[n]=new Promise(((a,l)=>{const h=n*r,u=n===this._workerCount-1?o:(n+1)*r;u<=h&&a({i:new Int32Array(0),j:new Int32Array(0),distance:new Float32Array(0),idx:n}),c[n].postMessage({values:t,startIdx:h,endIdx:u,threshold:i,fnName:e,opts:s}),c[n].onmessage=({data:{error:t,i:e,j:i,distance:s}})=>{t?(c[n].terminate(),l(t)):(c[n].terminate(),a({i:e,j:i,distance:s,idx:n}))}}));const h=await Promise.all(l),u=h.reduce(((t,e)=>t+e.i.length),0),d=new Int32Array(u),m=new Int32Array(u),p=new Float32Array(u);let g=0;for(const t of h)d.set(t.i,g),m.set(t.j,g),p.set(t.distance,g),g+=t.i.length;return{i:d,j:m,distance:p}}async getKNN(t,e,n=15,i={}){return await this.multiColumnKNN([t],[e],n,[i],[1])}async multiColumnKNN(t,e,s=15,o,r,a=i.EUCLIDEAN){if(t.length!==e.length||t.length!==o.length||t.length!==r.length)throw new Error("values, distance functions, options and weights arrays should have the same length");if(t.some((e=>e.length!==t[0].length)))throw new Error("all values arrays should have the same length");const l=t[0].length*(t[0].length-1)/2,c=Math.floor(l/this._workerCount),h=new Array(this._workerCount),u=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(n.p+n.u(664),n.b))));for(let n=0;n<this._workerCount;n++)h[n]=new Promise(((i,h)=>{const d=n*c,m=n===this._workerCount-1?l:(n+1)*c;m<=d&&i({knnDistances:new Array(0),knnIndexes:new Array(0)}),u[n].postMessage({values:t,startIdx:d,endIdx:m,fnNames:e,opts:o,nNeighbours:s,weights:r,aggregationMethod:a}),u[n].onmessage=({data:{error:t,knnDistances:e,knnIndexes:s}})=>{t?(u[n].terminate(),h(t)):(u[n].terminate(),i({knnDistances:e,knnIndexes:s}))}}));const d=await Promise.all(h),m={knnDistances:new Array(t[0].length).fill(null).map((()=>new Array(s).fill(99999))),knnIndexes:new Array(t[0].length).fill(null).map((()=>new Array(s).fill(-1)))};for(const e of d)for(let n=0;n<t[0].length;++n)for(let t=0;t<e.knnDistances[n]?.length;++t)O(m.knnDistances[n],m.knnIndexes[n],e.knnDistances[n][t],e.knnIndexes[n][t]);return m}async getSampleDistances(t,e,i={}){const s=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(n.p+n.u(118),n.b)))),o=t.slice();for(let t=o.length-1;t>0;t--){const e=Math.floor(Math.random()*(t+1));[o[t],o[e]]=[o[e],o[t]]}try{const n=t.length*(t.length-1)/2,r=Math.floor(n/this._workerCount),a=1e6,l=Math.max(Math.min(n/1e3,a),Math.min(n,a)),c=Math.floor(l/this._workerCount),h=new Array(this._workerCount);for(let t=0;t<this._workerCount;t++)h[t]=new Promise(((a,l)=>{const h=t*r,u=t===this._workerCount-1?n:(t+1)*r;s[t].postMessage({values:o,startIdx:h,endIdx:u,sampleLength:c,fnName:e,opts:i}),s[t].onmessage=({data:{error:e,distance:n}})=>{s[t].terminate(),e?l(e):a({distance:n})}}));const u=await Promise.all(h),d=u.reduce(((t,e)=>t+e.distance.length),0),m=new Float32Array(d);let p=0;for(const t of u)m.set(t.distance,p),p+=t.distance.length;return m.sort(),m}catch(t){return s?.forEach((t=>t?.terminate())),console.error(t),new Float32Array(1).fill(.5)}}async getMinimalThreshold(t,e,n={}){try{const i=t.length*(t.length-1)/2,s=await this.getSampleDistances(t,e,n);return 1-s[Math.floor(7e7/i*s.length)]}catch(t){return console.error(t),.5}}static calcSync(t,e,n,i){const s=[],o=[],r=[];let a=0,l=0,c=0;const h=t.length*(t.length-1)/2;for(;a<h;){const h=_(t[l])||_(t[c])?1:n(t[l],t[c]);(Object.values(k.gk).some((t=>t===e))?(0,g.Om)(h):1-h)>=i&&(s.push(l),o.push(c),r.push(h)),a++,c++,c===t.length&&(l++,c=l+1)}return{i:new Int32Array(s),j:new Int32Array(o),distance:new Float32Array(r)}}}var B,W=n(9657);!function(t){t.none="none",t.bold="bold",t.dashed="dashed"}(B||(B={}));class H{get currentLineId(){return this._currentLineIdx}set currentLineId(t){t!==this._currentLineIdx&&(this._currentLineIdx=t,this.sp.render(this.ctx))}set linesToRender(t){this.updateLines(t),this.sp.render(this.ctx)}set linesVisibility(t){this.visibility=t,this.sp.render(this.ctx)}constructor(t,e,n,i,s=B.none){var o;this._currentLineIdx=-1,this.lineClicked=new f.Subject,this.lineHover=new f.Subject,this.mouseOverLineId=-1,this.arrowWidth=15,this.sp=t,this.xAxisCol=this.sp.dataFrame.columns.byName(e),this.yAxisCol=this.sp.dataFrame.columns.byName(n),this.canvas=this.sp.getInfo().canvas,this.ctx=this.canvas.getContext("2d"),this.currentLineStyle=s,this.updateLines(i),this.visibility=null!==(o=i.visibility)&&void 0!==o?o:new W.Z(this.lines.from.length),i.visibility||this.visibility.setAll(!0,!1),i.arrowSize&&(this.arrowWidth=i.arrowSize),this.canvas.onmousedown=t=>{-1!==this.mouseOverLineId&&this.lineClicked.next({x:t.clientX,y:t.clientY,id:this.mouseOverLineId,event:t})},this.canvas.onmousemove=t=>{this.mouseOverLineId=this.checkCoordsOnLine(t.offsetX,t.offsetY),-1!==this.mouseOverLineId&&this.lineHover.next({x:t.clientX,y:t.clientY,id:this.mouseOverLineId,event:t})},t.onEvent("d4-before-draw-scene").subscribe((t=>{this.renderLines()}))}updateLines(t){this.lines=t,this.multipleLinesCounts=new Uint8Array(this.lines.from.length),this.createMultiLinesIndices()}renderLines(){var t,e,n,i,s,o,r,a,l,c,h,u,d;const m=this.sp.getOptions().look,p=this.lines.colors||this.lines.width||this.lines.opacities||this.lines.drawArrowsArr;p||(this.ctx.lineWidth=null!==(t=this.lines.width)&&void 0!==t?t:1,this.ctx.strokeStyle=`rgba(${null!==(e=this.lines.color)&&void 0!==e?e:"0,128,0"},${null!==(n=this.lines.opacity)&&void 0!==n?n:1})`);const g=m.sizeColumnName?this.sp.dataFrame.col(m.sizeColumnName):null,f=this.sp.dataFrame.filter;for(let t=0;t<this.lines.from.length;t++)if(f.get(this.lines.from[t])&&f.get(this.lines.to[t])&&this.visibility.getBit(t)){let e=0;const{sizeFrom:n,sizeTo:f}=this.getMarkersSizes(m,g,t),y=this.sp.worldToScreen(this.xAxisCol.get(this.lines.from[t]),this.yAxisCol.get(this.lines.from[t]));let b=null==y?void 0:y.x,C=null==y?void 0:y.y;const w=this.sp.worldToScreen(this.xAxisCol.get(this.lines.to[t]),this.yAxisCol.get(this.lines.to[t]));let v=null==w?void 0:w.x,S=null==w?void 0:w.y;if(this.ctx.beginPath(),b&&C&&v&&S){if(p){const e=(null===(i=this.lines.colors)||void 0===i?void 0:i[t])?null===(s=this.lines.colors)||void 0===s?void 0:s[t]:"0,128,0",n=(null===(o=this.lines.opacities)||void 0===o?void 0:o[t])?null===(r=this.lines.opacities)||void 0===r?void 0:r[t]:1;this.ctx.strokeStyle=`rgba(${e},${n})`,this.ctx.lineWidth=(null===(a=this.lines.widths)||void 0===a?void 0:a[t])?null===(l=this.lines.widths)||void 0===l?void 0:l[t]:1}t===this._currentLineIdx&&this.toggleCurrentLineStyle(!0);const m=this.multipleLinesCounts[t];let g=null;if(m){e=this.getLineLength(b,C,v,S);const i=this.getPointOnDistance(b,C,v,S,f,e),s=this.getPointOnDistance(v,S,b,C,n,e);b=i.x,C=i.y,v=s.x,S=s.y,g=this.lines.from[t]>this.lines.to[t]?this.findControlPoint(m,b,C,v,S,t):this.findControlPoint(m,v,S,b,C,t),this.ctx.moveTo(b,C),this.ctx.quadraticCurveTo(g.x,g.y,v,S)}else this.ctx.moveTo(b,C),this.ctx.lineTo(v,S);if((null!==(c=this.lines.drawArrows)&&void 0!==c?c:null===(h=this.lines.drawArrowsArr)||void 0===h?void 0:h.getBit(t))&&(e||(e=this.getLineLength(b,C,v,S)),e>this.arrowWidth)){const t=m?null:this.getPointOnDistance(b,C,v,S,f,e),n=m?g.x:b,i=m?g.y:C;this.canvasArrow(this.ctx,null!==(u=null==t?void 0:t.x)&&void 0!==u?u:b,null!==(d=null==t?void 0:t.y)&&void 0!==d?d:C,n,i)}this.ctx.stroke(),this.ctx.closePath(),t===this._currentLineIdx&&this.toggleCurrentLineStyle(!1)}}this.fillLeftBottomRect()}toggleCurrentLineStyle(t){switch(this.currentLineStyle){case B.bold:t?this.ctx.lineWidth+=2:this.ctx.lineWidth-=2;break;case B.dashed:t?this.ctx.setLineDash([5,5]):this.ctx.setLineDash([]);break;default:return}}getMarkersSizes(t,e,n){let i=3,s=3;return e?(i=(t.markerMinSize+(t.markerMaxSize-t.markerMinSize)*e.scale(this.lines.from[n]))/2,s=(t.markerMinSize+(t.markerMaxSize-t.markerMinSize)*e.scale(this.lines.to[n]))/2):t.markerDefaultSize&&(i=t.markerDefaultSize/2,s=t.markerDefaultSize/2),{sizeFrom:i,sizeTo:s}}fillLeftBottomRect(){const t=new Path2D;t.rect(this.sp.yAxisBox.minX,this.sp.yAxisBox.maxY,this.sp.yAxisBox.width,this.sp.xAxisBox.height),this.ctx.fillStyle="white",this.ctx.beginPath(),this.ctx.fill(t),this.ctx.closePath()}createMultiLinesIndices(){const t=new W.Z(this.lines.from.length);t.setAll(!0);for(let e=-1;-1!==(e=t.findNext(e));){let n=e,i=this.lines.from[n],s=this.lines.to[n],o=1;for(let n=e;-1!==(n=t.findNext(n));){const e=this.lines.from[n],r=this.lines.to[n];(e===i&&r===s||r===i&&e===s)&&(this.multipleLinesCounts[n]=++o,t.setBit(n,!1,!1))}o>1&&(this.multipleLinesCounts[n]=1),t.setBit(e,!1,!1)}}checkCoordsOnLine(t,e){let n=-1,i=null,s=null;const o=this.sp.getOptions().look,r=o.sizeColumnName?this.sp.dataFrame.col(o.sizeColumnName):null,a=this.sp.dataFrame.filter;for(let l=0;l<this.lines.from.length;l++)if(a.get(this.lines.from[l])&&a.get(this.lines.to[l])&&this.visibility.getBit(l)){const{sizeFrom:a,sizeTo:c}=this.getMarkersSizes(o,r,l),h=this.sp.worldToScreen(this.xAxisCol.get(this.lines.from[l]),this.yAxisCol.get(this.lines.from[l])),u=this.sp.worldToScreen(this.xAxisCol.get(this.lines.to[l]),this.yAxisCol.get(this.lines.to[l]));if(this.multipleLinesCounts[l]){const n=this.getLineLength(h.x,h.y,u.x,u.y),i=this.getPointOnDistance(h.x,h.y,u.x,u.y,c,n),o=this.getPointOnDistance(u.x,u.y,null==h?void 0:h.x,null==h?void 0:h.y,a,n),r=this.lines.from[l]>this.lines.to[l]?this.findControlPoint(this.multipleLinesCounts[l],i.x,i.y,o.x,o.y,l):this.findControlPoint(this.multipleLinesCounts[l],o.x,o.y,i.x,i.y,l);s=this.calculateDistToCurveLine(l,t,e,i,o,r)}else s=this.calculateDistToStraightLine(t,e,h,u);(!i&&null!==s&&s<5||i&&null!==s&&s<i)&&(i=s,n=l)}return n}calculateDistToStraightLine(t,e,n,i){let s=Math.min(n.x,i.x),o=Math.max(n.x,i.x),r=Math.min(n.y,i.y),a=Math.max(n.y,i.y);return t>=s-2&&t<=o+2&&e>=r-2&&e<=a+2?this.distToStraightLineSegment(t,e,n,i):null}distToStraightLineSegment(t,e,n,i){const s=(t,e,n,i)=>Math.pow(t-n,2)+Math.pow(e-i,2),o=s(n.x,n.y,i.x,i.y);if(0==o)return s(t,e,n.x,n.y);let r=((t-n.x)*(i.x-n.x)+(e-n.y)*(i.y-n.y))/o;return r=Math.max(0,Math.min(1,r)),s(t,e,n.x+r*(i.x-n.x),n.y+r*(i.y-n.y))}calculateDistToCurveLine(t,e,n,i,s,o){let r=Math.min(i.x,s.x,o.x),a=Math.max(i.x,s.x,o.x),l=Math.min(i.y,s.y,o.y),c=Math.max(i.y,s.y,o.y);if(e>=r-2&&e<=a+2&&n>=l-2&&n<=c+2){const t=a-r,h=c-l;return this.calculateDistToCurveInRect(e,n,i,o,s,t,h)}return null}calculateDistToCurveInRect(t,e,n,i,s,o,r){const a=Math.floor((o+r)/3),l=1/a,c=new Uint32Array(a),h=new Uint32Array(a);let u=new Uint32Array(a),d=null;const m=new W.Z(a);for(let o=0;o<c.length;o++){const r=o*l,a=Math.pow(1-r,2)*n.x+2*r*(1-r)*i.x+Math.pow(r,2)*s.x,m=Math.pow(1-r,2)*n.y+2*r*(1-r)*i.y+Math.pow(r,2)*s.y,p=Math.abs(t-a),g=Math.abs(e-m),f=p+g;(!d||d>f)&&(d=f),u[o]=Math.max(p,g),c[o]=a,h[o]=m}for(let t=0;t<c.length;t++)u[t]<d&&m.setBit(t,!0,!1);let p=null;for(let n=-1;-1!==(n=m.findNext(n));){const i=Math.hypot(c[n]-t,h[n]-e);(!p||p>i)&&(p=i)}return p}getLineLength(t,e,n,i){return Math.sqrt(Math.pow(n-t,2)+Math.pow(i-e,2))}getPointOnDistance(t,e,n,i,s,o){const r=n-s*((n-t)/o),l=i-s*((i-e)/o);return new a.Point(r,l)}findControlPoint(t,e,n,i,s,o){const r=e+(i-e)/2,l=n+(s-n)/2;let c=r-e,h=l-n;const u=Math.sqrt(c*c+h*h);c/=u,h/=u;const d=50*Math.ceil(t/2);return t%2==0?new a.Point(r+d/2*h,l-d/2*c):new a.Point(r-d/2*h,l+d/2*c)}canvasArrow(t,e,n,i,s){const o=Math.atan2(i-e,s-n)+Math.PI;t.moveTo(e-this.arrowWidth*Math.sin(o-Math.PI/10),n-this.arrowWidth*Math.cos(o-Math.PI/10)),t.lineTo(e,n),t.lineTo(e-this.arrowWidth*Math.sin(o+Math.PI/10),n-this.arrowWidth*Math.cos(o+Math.PI/10))}}const D="dimensionality-reducer-terminate-event";var V=n(850);async function U(t,e,i,s,r,a,l){let c=await async function(t,e,i,s,r,a,l){if(!a.distanceFnArgs)throw new Error("options.distanceFnArgs must be defined");if(t.length!==e.length||t.length!==a.distanceFnArgs.length||t.length!==s.length)throw new Error("data, metrics and options and weights must have the same length");return new Promise((function(c,h){const u=new Worker(new URL(n.p+n.u(42),n.b));u.postMessage({columnsData:t,distanceMetrics:e,method:i,options:a,weights:s,aggregationMethod:r});const d=o.events.onCustomEvent(D).subscribe((()=>{try{u?.terminate()}finally{d.unsubscribe()}}));u.onmessage=({data:{error:t,embedding:e,epochNum:n,epochsLength:i}})=>{n&&i?l&&l(n,i,e):(d.unsubscribe(),t?h(t):c(e),setTimeout((()=>u.terminate()),0))}}))}(t,i,e,s,r,a,l);return c=c.map((t=>(0,V.Fv)(t))),c}let Z=0;const Y="cliffsDf",$=new f.Subject,K="act_diff",X="sali",q="sim",z="line_index",j=["1_seq","2_seq"],J="filterCliffs";var Q,tt=n(499),et=n(5226),nt=n(7228),it=n(8457),st=n(8260);async function ot(t,e,n,i){const s=(0,it.O)(e),o=(0,st.vU)(e.getTag(a.TAGS.UNITS),e.getTag("separator"))(n),r=i===Q.IDENTITY?function(t,e){const n=e.columns.length,i=new Array(n),s=new Array(n),o=new Array(n);for(let r=0;r<n;++r){const n=e.columns.byIndex(r);i[r]=n.getRawData(),s[r]=n.categories.indexOf(""),o[r]=n.categories.indexOf(t[r]??"")}const r=a.Column.float("Identity",e.rowCount),l=r.getRawData();for(let n=0;n<e.rowCount;++n){l[n]=0;for(let e=0;e<t.length;++e)i[e][n]===o[e]&&++l[n];l[n]/=t.length}return r}(o,s):i===Q.SIMILARITY?await async function(t,e){const n=e.columns.toList();return await(0,nt.Qx)(n,t)}(o,s):null;if(null===r)throw new Error(`In bio library: Unkown sequence scoring method: ${i}`);return r.name=t.columns.getUnusedName(r.name),t.columns.add(r),r}!function(t){t.IDENTITY="identity",t.SIMILARITY="similarity"}(Q||(Q={}));var rt=n(7945),at=n(4293),lt=n(6414),ct=n.n(lt);const ht="rgb(100,100,100)",ut="#808080",dt="rgb(0,0,0)",mt=st.GU;var pt,gt;function ft(t,e,n,i,s,o,r=ht,a=0,l=!1,c=1,h="",u=!1,d=gt.classic,m=[],p=0,g=null,f=[],y=null,b={}){s.textAlign="start";let C=o.substring(0),w=u?"":h;d===gt.MSA&&(w="");let v=!0,S=!0,A="difference";null!=g&&null!=g.cell.column&&(v=g.cell.column.temp["color-code"]??!0,S=g.cell.column.temp["compare-with-current"]??!0,A=g.cell.column.temp["highlight-difference"]??"difference");const x=f[p];S&&f.length>0&&"difference"===A&&(c=C==x?.3:c),S&&f.length>0&&"equal"===A&&(c=C!=x?.3:c),null!=y&&(C=mt(C,y));const T=C+w;b[T]??(b[T]=s.measureText(T));let I=b[T];b[C]??(b[C]=s.measureText(C));let M=b[C].width;b[w]??(b[w]=s.measureText(w));const L=b[w].width,E=i/2-(I.fontBoundingBoxAscent+I.fontBoundingBoxDescent)/2+1;function N(n,i){const o=v?r:dt;s.fillStyle=o,s.globalAlpha=c,d===gt.classic&&(s.fillText(C,t+n,e+E),s.fillStyle=ut,s.fillText(w,t+i,e+E)),d===gt.MSA&&s.fillText(C,t+n,e+E)}I=I.width,d===gt.MSA&&(M=m[p],I=m[p]);const R=(m[p]??0)-(m[0]??0);if(l||I>n)return N(R,R+M),t+R+M+L;{const e=(n-I)/2;return N(e,e+M),t+R+e+M}}!function(t){t.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(pt||(pt={})),function(t){t.MSA="MSA",t.classic="classic"}(gt||(gt={}));var yt,bt=n(9611),Ct=n(8447),wt=n(7331);!function(t){t.long="long",t.short="short"}(yt||(yt={}));const vt={true:"1",false:"0"};var St=n(3553);const At="rgb(100,100,100)",xt=Ct.GU;function Tt(t,e,n,i,s){return t?Math.max(Math.min(t.canvas.width/s-n,i)):Math.max(e.canvas.width/s-n,0)}function It(t){const e=!ct().enumerate(t).some((([e,n])=>e.length>1&&0!=n&&n!=t.length-1)),n=[],i=e?"":" ";for(const[e,s]of ct().enumerate(t)){let o=e;s<t.length&&(o+=`${e?"":"-"}${i}`),n.push(o)}return[n,e]}class Mt extends a.GridCellRenderer{constructor(){super(...arguments),this.padding=5}get name(){return"sequence"}get cellType(){return"sequence"}get defaultHeight(){return 30}get defaultWidth(){return 230}onClick(t,e){t.cell.column.temp["current-word"]=t.cell.value,t.grid.invalidate()}onMouseMove(t,e){const n=t.cell.column.temp["bio-seqCol"];if(!n)return;const i=t.bounds,s=e.offsetX-t.gridColumn.left+(t.gridColumn.left-i.x),a=n.getPosition(t.tableRowIndex,s),l=n.getSeqMonList(t.tableRowIndex);if(null!==a&&a<l.length){const t=l[a],i=[r.div(t)];if(n._monomerStructureMap[t])i.push(n._monomerStructureMap[t]);else{const e=n.getMonomer(t);if(e){const s={autoCrop:!0,autoCropMargin:0,suppressChiralText:!0},r=o.chem.svgMol(e.smiles,void 0,void 0,s);i.push(r),n._monomerStructureMap[t]=r}}r.tooltip.show(r.divV(i),e.x+16,e.y+16)}else r.tooltip.hide()}render(t,e,n,i,s,o,r){let l,c=0,h=50;try{l=o.grid}catch(t){l=void 0;const[e,n]=(0,rt.yf)(t);fn.logger.error(e,void 0,n)}const u=o.cell.column;if(!l||!u)return;const d=u.temp,m=d["monomer-width"];if("short"===(null!=m?m:"short")){const t=parseInt(u.getTag(pt.maxMonomerLength));h=(isNaN(t)?fn.properties?.MaxMonomerLength:t)??4}let p=u.temp["bio-seqCol"];p||(p=new bt.A(l,u,(()=>{const t=tt.Cn.getOrCreate(u);return{unitsHandler:t,monomerCharWidth:7,separatorWidth:t.isMsa()?8:c,monomerToShort:xt,monomerLengthLimit:h,monomerLib:Sn()}}))),u.tags[".mm.cellRenderer.settingsChanged"]===vt.true&&(c=d[".mm.cellRenderer.gapLength"]??c,p.setMonomerLengthLimit(h),p.setSeparatorWidth(p.isMsa()?8:c),u.setTag(".mm.cellRenderer.settingsChanged",vt.false));const[g,f]=p.getCellMonomerLengths(o.tableRowIndex);g.length,p.updated&&(d["bio-seqCol"]=p),t.save();try{const r=window.devicePixelRatio,l=-1!==o.gridRow?o.grid:null,c=o.cell.value,m=u.getTag("alphabet"),g=50;i=Tt(l,t,e,i,r),t.beginPath(),t.rect(e+this.padding,n+this.padding,i-this.padding-1,s-2*this.padding),t.clip(),t.font="12px monospace",t.textBaseline="top";const y=u.getTag(a.TAGS.UNITS),b=u.getTag("aligned"),C=(0,Ct.py)(m),w=u.getTag("separator")??"",v=i/5,S=tt.Cn.getOrCreate(u).getSplitter(v),A=d["reference-sequence"],x=d["current-word"],T=S(null!=A&&""!=A?A:x??""),I=S(c);let M=At,L=gt.classic;b&&b.includes("MSA")&&y==Ct.r2.SEPARATOR&&(L=gt.MSA);for(const[r,a]of ct().enumerate(I)){M=C.get(r),t.fillStyle=At;const l=a===I.length-1;if(ft(e+this.padding,n,i,s,t,r,M,0,!0,1,w,l,L,f,a,o,T,h,p._monomerLengthMap),g>i)break}}catch(t){const e=t instanceof Error?t.message:t?t.toString():"Error 'undefined'";fn.logger.error(`Bio: MacromoleculeSequenceCellRenderer.render() error: ${e}`)}finally{t.restore()}}}class Lt extends a.GridCellRenderer{get name(){return"MacromoleculeDifferenceCR"}get cellType(){return St.Of.MACROMOLECULE_DIFFERENCE}get defaultHeight(){return 30}get defaultWidth(){return 230}render(t,e,n,i,s,o,r){const l=window.devicePixelRatio,c=o.grid,h=o.cell,u=o.tableColumn,d=h.value??"",m=u.tags.separator,p=u.tags[a.TAGS.UNITS];i=Tt(c,t,e,i,l);const[g,f]=d.split("#"),y=(0,st.vU)(p,m);Et(t,e,n,i,s,y(g),y(f),p)}}function Et(t,e,n,i,s,o,r,a,l,c){if(o.length!==r.length){const t=function(t,e){let n=0,i=0;const s=t.length>e.length?t:e,o=t.length>e.length?e:t;for(let t=0;t<o.length;t++)s[t]===o[t]&&n++;const r=s.length-o.length;for(let t=s.length-1;t>r;t--)s[t]===o[t-r]&&i++;const a=new Array(Math.abs(t.length-e.length)).fill("");function l(t){return n>i?t.concat(a):a.concat(t)}return t.length>e.length?e=l(e):t=l(t),{subParts1:t,subParts2:e}}(ct()(o).toArray(),ct()(r).toArray());o=t.subParts1,r=t.subParts2}const h=t.measureText(It(o).join("")),u=t.measureText(It(r).join("")),d=Math.max(h.width,u.width);l&&(i=d+4*o.length,t.canvas.width=d+4*o.length);let m=Math.max(e,e+(i-(d+4*o.length))/2)+5;const p=Math.max(n,n+(s-28)/2);t.save(),t.beginPath(),t.rect(e,n,l?d+4*o.length:i,s),t.clip(),t.font="12px monospace",t.textBaseline="top";let g=wt.UE.Color;"HELM"!=a&&(g=(0,Ct.py)(a.substring(a.length-2)));for(let e=0;e<o.length;e++){const n=o[e],a=r[e],l=g.get(n);if(n!=a){const o=g.get(a),r=ft(m,p-7,i,s,t,n,l,0,!0),h=ft(m,p+7,i,s,t,a,o,0,!0);m=Math.max(h,r),c&&(c[e]=Nt(n,a,l,o,p,7,s))}else m=ft(m,p,i,s,t,n,l,0,!0,.5);m+=4}t.restore()}function Nt(t,e,n,i,s,o,r){const a=document.createElement("canvas"),l=a.getContext("2d");l.font="12px monospace";const c=l.measureText(It([t]).join("")).width,h=l.measureText(It([e]).join("")).width,u=Math.max(c,h);return a.height=r,a.width=u+4,l.font="12px monospace",l.textBaseline="top",ft(0,s-o,u,r,l,t,n,0,!0),ft(0,s+o,u,r,l,e,i,0,!0),a}var Rt,_t=n(8467),Ot=n(9298);!function(t){t.Unknown="unknown",t.FR="framework",t.CDR="cdr"}(Rt||(Rt={}));const Pt=new class{constructor(){this.regionTypes=[Rt.CDR],this.chains=["Heavy","Light"],this.skipEmptyPositions=!1,this.fitWidth=!1,this.positionWidth=16,this.positionHeight=Ot.ES.Entropy,this.filterSource=Ot.vS.filterSource}};var Gt=n(172),kt=n(8415);const Ft=Rt;var Bt,Wt;!function(t){t.STYLE="Style",t.BEHAVIOR="Behavior",t.LAYOUT="Layout",t.DATA="Data"}(Bt||(Bt={})),function(t){t.skipEmptyPositions="skipEmptyPositions",t.regionTypes="regionTypes",t.chains="chains",t.fitWidth="fitWidth",t.positionWidth="positionWidth",t.positionHeight="positionHeight",t.filterSource="filterSource"}(Wt||(Wt={}));const Ht=Pt;class Dt extends a.JsViewer{constructor(){super(),this.viewed=!1,this.regionsFg=null,this.regionsRoot=null,this.isOpened=!1,this.panelNode=null,this.regions=[],this.viewerId=++Dt.viewerCounter,this.setDataInProgress=!1,this.host=null,this.mainLayout=null,this.logos=[],this.viewSubs=[],this.calcSizeRequested=!1,this._onRendered=new f.Subject,this.skipEmptyPositions=this.bool(Wt.skipEmptyPositions,Ht.skipEmptyPositions,{category:Bt.DATA}),this.regionTypes=this.stringList(Wt.regionTypes,Ht.regionTypes,{category:Bt.DATA,choices:Object.values(Ft).filter((t=>t!=Ft.Unknown))}),this.chains=this.stringList(Wt.chains,Ht.chains,{category:Bt.DATA,choices:["Heavy","Light"]}),this.fitWidth=this.bool(Wt.fitWidth,Ht.fitWidth,{category:Bt.LAYOUT}),this.positionWidth=this.float(Wt.positionWidth,Ht.positionWidth,{category:Bt.LAYOUT,editor:"slider",min:0,max:64,description:"Internal WebLogo viewers property width of position."}),this.positionHeight=this.string(Wt.positionHeight,Ht.positionHeight,{category:Bt.LAYOUT,choices:Object.keys(Ot.ES)}),this.filterSource=this.string(Wt.filterSource,Ht.filterSource,{category:Bt.BEHAVIOR,choices:Object.values(Ot.Ct)}),this.viewSyncer=new Gt.c(fn.logger)}viewerToLog(){return`VdRegionsViewer<${this.viewerId}>`}async init(){this.subs.push((0,f.fromEvent)(this.root,"mousemove").subscribe(this.rootOnMouseMove.bind(this)))}detach(){const t=`${this.viewerToLog()}.detach()`,e=super.detach.bind(this);this.viewSyncer.sync(`${t}`,(async()=>{this.setDataInProgress||(this.viewed&&(await this.destroyView("detach"),this.viewed=!1),e())}))}onTableAttached(){super.onTableAttached(),this.setData(this.regions)}onPropertyChanged(t){if(super.onPropertyChanged(t),t){switch(t.name){case Wt.regionTypes:case Wt.chains:this.setData(this.regions)}switch(t.name){case Wt.skipEmptyPositions:for(let t=0;t<this.logos.length;++t)for(const e of this.chains)this.logos[t][e].setOptions({[kt.bo.skipEmptyPositions]:this.skipEmptyPositions});this.calcSize();break;case Wt.fitWidth:case Wt.positionWidth:this.calcSize();break;case Wt.positionHeight:for(let t=0;t<this.logos.length;++t)for(const e of this.chains)this.logos[t][e].setOptions({[kt.bo.positionHeight]:this.positionHeight});this.calcSize();break;case Wt.filterSource:this.filterSourceInput.value=this.filterSource;break;default:this.setData(this.regions)}}else console.warn("Bio: VdRegionsViewer.onPropertyChanged() property is null")}setData(t){const e=`${this.viewerToLog()}.setData()`;fn.logger.debug(`${e}, in, regions.length = ${t.length}`),this.viewSyncer.sync(`${e}`,(async()=>{if(!this.setDataInProgress){this.setDataInProgress=!0;try{this.viewed&&(await this.destroyView("setData"),this.viewed=!1),this.regions=t,this.viewed||(await this.buildView("setData"),this.viewed=!0)}finally{this.setDataInProgress=!1}}}))}async destroyView(t){fn.logger.debug(`Bio: VdRegionsViewer.destroyView( mainLayout = ${this.mainLayout?"value":"none"} ), purpose = '${t}', this.regions.length = ${this.regions.length}`),this.filterSourceInput&&r.empty(this.filterSourceInput.root),null!=this.mainLayout&&(this.mainLayout.remove(),this.host.remove(),this.host=null,this.mainLayout=null);for(const t of this.viewSubs)t.unsubscribe()}async buildView(t){fn.logger.debug(`Bio: VdRegionsViewer.buildView() begin, purpose = '${t}', this.regions.length = ${this.regions.length}`);const e=this.regions.filter((t=>this.regionTypes.includes(t.type))),n=Array.from(new Set(e.map((t=>t.order)))).sort(),i=[];for(let t=0;t<n.length;t++)for(const s of this.chains){const o=e.find((e=>e.order==n[t]&&e.chain==s));i.push((async()=>{const e=await this.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:o.sequenceColumnName,startPositionName:o.positionStartName,endPositionName:o.positionEndName,fixWidth:!0,skipEmptyPositions:this.skipEmptyPositions,positionWidth:this.positionWidth,positionHeight:this.positionHeight,filterSource:this.filterSource});return e.onSizeChanged.subscribe((()=>{this.calcSize()})),[t,s,e]})())}const s=await Promise.all(i);this.logos=new Array(n.length);for(let t=0;t<n.length;++t)this.logos[t]={};for(const[t,e,n]of s)this.logos[t][e]=n,this.viewSubs.push(n.onFreqsCalculated.subscribe((()=>{this.calcSize()})));this.mainLayout=r.table(this.chains,(t=>[...n.length>0?[r.div(t,{style:{transform:"rotate(-90deg)",font:"12px Roboto, Roboto Local, sans-serif",textAlign:"center",width:"16px",marginTop:"24px",marginLeft:"6px"}})]:[],...[...Array(n.length).keys()].map((e=>{const n=this.logos[e][t];return n.root.style.height="100%",r.div([n.root],{style:{marginTop:"4px",marginBottom:"4px"}})}))]),["",...[...Array(n.length).keys()].map((t=>e.find((e=>e.order==n[t]&&e.chain==this.chains[0])).name||"Name"))]),this.mainLayout.className="mlb-vd-regions-viewer-table2",this.filterSourceInput=r.choiceInput("Data source",this.filterSource,Object.values(Ot.Ct),this.filterSourceInputOnValueChanged.bind(this)),this.filterSourceInput.root.style.position="absolute",this.filterSourceInput.root.style.right="9px",this.filterSourceInput.root.style.top="-4px",Math.ceil(255*Math.random()).toString(16),this.host=r.div([this.mainLayout,this.filterSourceInput.root],{}),this.root.appendChild(this.host),this.root.style.overflowX="auto",this.calcSize(),this.viewSubs.push(r.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),fn.logger.debug("Bio: VdRegionsViewer.buildView() end")}calcSize(){fn.logger.debug("Bio: VdRegionsViewer.calcSize(), start");const t=()=>{if(!this.host)return;const t=(this.root.clientHeight-54)/this.chains.length;let e=0;for(let n=0;n<this.logos.length;n++){for(const e of this.chains)this.logos[n][e].root.style.height=`${t}px`;e+=Math.max(...this.chains.map((t=>this.logos[n][t].Length)))}if(this.fitWidth){if(this.logos.length>0&&e>0){const t=22,n=13,i=9,s=(this.root.clientWidth-t-(this.logos.length-1)*i-n)/e;for(let t=0;t<this.logos.length;t++)for(const e of this.chains){const n=this.logos[t][e];n.setOptions({[kt.bo.positionWidth]:s-n.positionMarginValue}),n.root.style.width=s*n.Length+"px"}}this.host.style.setProperty("overflow","hidden","important")}else{for(let t=0;t<this.logos.length;t++)for(const e of this.chains)this.logos[t][e].setOptions({[kt.bo.positionWidth]:this.positionWidth});this.host.style.removeProperty("overflow")}0===this.positionWidth?this.host.style.setProperty("overflow-x","hidden","important"):this.host.style.removeProperty("overflow-x")};this.calcSizeRequested||(this.calcSizeRequested=!0,window.setTimeout((()=>{t(),this.calcSizeRequested=!1}),0))}rootOnSizeChanged(t){this.calcSize()}rootOnMouseMove(t){}filterSourceInputOnValueChanged(){const t=`${this.viewerToLog()}.filterSourceInputOnValueChanged()`,e=this.filterSourceInput.value;this.viewSyncer.sync(`${t}`,(async()=>{if(this.filterSource!==e){this.props.getProperty(Wt.filterSource).set(this,e);for(let t=0;t<this.logos.length;t++)for(let e=0;e<this.chains.length;e++){const n=this.chains[e];this.logos[t][n].setOptions({[kt.bo.filterSource]:this.filterSource})}}}))}get onRendered(){return this._onRendered}invalidate(){const t=`${this.viewerToLog()}.invalidate()`;this.viewSyncer.sync(`${t}`,(async()=>{this._onRendered.next()}))}async awaitRendered(t=5e3){await(0,_t.zg)(this.onRendered,(()=>{}),(()=>{this.invalidate()}),t)}}Dt.viewerCounter=-1;var Vt=n(9017),Ut=n(708);async function Zt(t,e,n="Morgan"){const i=tt.Cn.getOrCreate(t),s=t.toList(),o=i.getSplitter(),r=s.length;let a=36;const l=new Map;for(let e=0;e<r;e++){const n=s[e];if(null===s[e]||t.isNone(e)){s[e]=null;continue}s[e]="";const i=o(n);for(let t=0;t<i.length;t++){const n=i[t];l.has(n)||(l.set(n,String.fromCharCode(a)),a++),s[e]+=l.get(n)}}let c={};if(e===Ut.U.MONOMER_CHEMICAL_DISTANCE){const t=Array.from(l.keys()),e=await(0,nt.GR)(t,n);e.scoringMatrix.forEach(((t,n)=>{t.forEach(((t,i)=>{e.scoringMatrix[n][i]=1-t}))}));const i={};Object.entries(e.alphabetIndexes).forEach((([t,e])=>{i[l.get(t)]=e})),c={scoringMatrix:e.scoringMatrix,alphabetIndexes:i}}else if(e===Ut.U.NEEDLEMANN_WUNSCH){const t=Array.from(l.keys()),e=await(0,nt.GR)(t,n),i={};Object.entries(e.alphabetIndexes).forEach((([t,e])=>{i[l.get(t)]=e})),c={scoringMatrix:e.scoringMatrix,alphabetIndexes:i}}return{seqList:s,options:c}}var Yt=n(7983);function $t(t){const e=r.divH([],{style:{gap:"10px"}}),n=r.divV([r.divText(t.seqCol.name),r.divText(t.activityCol.name)]);return n.style.fontWeight="bold",n.style.display="flex",n.style.justifyContent="space-between",e.append(n),t.points.forEach((n=>{const i=r.divText(t.activityCol.get(n).toFixed(2));i.style.display="flex",i.style.justifyContent="left",i.style.paddingLeft="30px",e.append(r.divV([r.divText(t.seqCol.get(n)),i]))})),e}function Kt(t){const e=r.div();e.append(r.divText(t.seqCol.name,{style:{fontWeight:"bold"}}));const n=new Array(2),i=new Array(2);t.points.forEach(((e,s)=>{n[s]=t.seqCol.get(e),i[s]=t.activityCol.get(e)}));const s={},o=tt.Cn.getOrCreate(t.seqCol),a=o.getSplitter(),l=qt(a(n[0]),a(n[1]),o.units,s);return e.append(r.div(l,{style:{width:"300px",overflow:"scroll"}})),e.append(zt(s)),e.append(Xt("Activity delta",Math.abs(i[0]-i[1]))),e.append(Xt("Cliff",t.sali)),e}function Xt(t,e){return r.divH([r.divText(`${t}: `,{style:{fontWeight:"bold",paddingRight:"5px"}}),r.divText(e.toFixed(2))],{style:{paddingTop:"10px"}})}function qt(t,e,n,i){const s=document.createElement("canvas"),o=s.getContext("2d");return s.height=30,Et(o,0,0,0,30,t,e,n,!0,i),s}function zt(t){const e=r.div();if(Object.keys(t).length>0){const n=r.divV([]);n.append(r.divH([r.divText("Pos",{style:{fontWeight:"bold",width:"30px",borderBottom:"1px solid"}}),r.divText("Difference",{style:{fontWeight:"bold",borderBottom:"1px solid"}})]));for(const e of Object.keys(t))t[e].style.borderBottom="1px solid lightgray",n.append(r.divH([r.divText((parseInt(e)+1).toString(),{style:{width:"30px",borderBottom:"1px solid lightgray"}}),t[e]]));e.append(n)}return e}function jt(t,e){const n=a.Column.string("seq_diff",t.rowCount).init((n=>`${t.get(e[0],n)}#${t.get(e[1],n)}`));n.semType="MacromoleculeDifference",n.setTag(a.TAGS.UNITS,t.col(e[0]).getTag(a.TAGS.UNITS)),n.setTag("separator",t.col(e[0]).getTag("separator")),t.columns.add(n);const i=t.plot.grid();return i.col(e[0]).visible=!1,i.col(e[1]).visible=!1,i}class Jt extends a.JsViewer{constructor(t){super(),this.name="",this.metricsProperties=["distanceMetric","fingerprint"],this.fingerprintChoices=["Morgan","Pattern"],this.initialized=!1,this.tags=[a.TAGS.UNITS,"aligned","separator","alphabet"],this.preComputeDistanceMatrix=!1,this.renderPromise=Promise.resolve(),this.fingerprint=this.string("fingerprint",this.fingerprintChoices[0],{choices:this.fingerprintChoices}),this.limit=this.int("limit",10),this.distanceMetric=this.string("distanceMetric",g.kg[0],{choices:g.kg}),this.moleculeColumnName=this.string("moleculeColumnName"),this.name=t}init(){this.initialized=!0}detach(){this.subs.forEach((t=>t.unsubscribe()))}async onTableAttached(){if(this.init(),this.dataFrame){this.preComputeDistanceMatrix=this.dataFrame.rowCount<=22e3,this.subs.push(a.debounce(this.dataFrame.onRowsRemoved,50).subscribe((t=>this.render(!0))));const t="diversity"!==this.name;this.subs.push(a.debounce(this.dataFrame.onCurrentRowChanged,50).subscribe((e=>this.render(t)))),this.subs.push(a.debounce(this.dataFrame.selection.onChanged,50).subscribe((t=>this.render(!1)))),this.subs.push(a.debounce(r.onSizeChanged(this.root),50).subscribe((t=>this.render(!1)))),this.moleculeColumn=this.dataFrame.columns.bySemType(a.SEMTYPE.MACROMOLECULE),this.moleculeColumnName=this.moleculeColumn?.name,this.getProperty("limit").fromOptions({min:1,max:this.dataFrame.rowCount})}this.render()}onPropertyChanged(t){if(super.onPropertyChanged(t),this.initialized){if("moleculeColumnName"===t.name){const e=this.dataFrame.col(t.get(this));e.semType===a.SEMTYPE.MACROMOLECULE&&(this.moleculeColumn=e)}this.render()}}render(t=!0){this.renderPromise=this.renderPromise.then((async()=>{this.computeRequested=this.computeRequested||t,await this.renderInt(t)}))}async renderInt(t){}beforeRender(){return!(!this.initialized||this.dataFrame&&this.moleculeColumnName&&this.dataFrame.col(this.moleculeColumnName).semType!==a.SEMTYPE.MACROMOLECULE&&(o.shell.error(`${this.moleculeColumnName} is not Macromolecule type`),1))}}var Qt=n(7241);const te={gapPenalty:1,matchScore:1,gapSymbol:"-",localAlignment:!1};class ee extends Jt{constructor(){super("similarity"),this.sketchedMolecule="",this.curIdx=0,this.molCol=null,this.idxs=null,this.scores=null,this.gridSelect=!1,this.targetMoleculeIdx=0,this.computeCompleted=new f.Subject,this.distanceMatrixComputed=!1,this.kPrevNeighbors=0,this.cutoff=this.float("cutoff",.01,{min:0,max:1}),this.hotSearch=this.bool("hotSearch",!0),this.similarColumnLabel=this.string("similarColumnLabel",null)}init(){this.hotSearch=!0,this.initialized=!0}async renderInt(t){if(this.beforeRender()&&this.moleculeColumn&&(this.curIdx=-1==this.dataFrame.currentRowIdx?0:this.dataFrame.currentRowIdx,t&&!this.gridSelect)){this.targetMoleculeIdx=-1==this.dataFrame.currentRowIdx?0:this.dataFrame.currentRowIdx;const t=tt.Cn.getOrCreate(this.moleculeColumn);await(t.isHelm()?this.computeByChem():this.computeByMM());const e=null!=this.similarColumnLabel?this.similarColumnLabel:`similar (${this.moleculeColumnName})`;this.molCol=a.Column.string(e,this.idxs.length).init((t=>this.moleculeColumn?.get(this.idxs?.get(t)))),this.molCol.semType=a.SEMTYPE.MACROMOLECULE,this.tags.forEach((t=>this.molCol.setTag(t,this.moleculeColumn.getTag(t))));const n=a.DataFrame.fromColumns([this.idxs,this.molCol,this.scores]);n.onCurrentRowChanged.subscribe((t=>{this.dataFrame.currentRowIdx=n.col("indexes").get(n.currentRowIdx),setTimeout((()=>{this.createPropertyPanel(n)}),1e3),this.gridSelect=!0}));const i=n.plot.grid();i.col("indexes").visible=!1;const s=this.idxs?.getRawData().findIndex((t=>t==this.targetMoleculeIdx));i.cell("score",s).cell.value=null,o.shell.v.grid.root.addEventListener("click",(t=>{this.gridSelect=!1})),(0,at.Y)(this.root,i.root),this.computeCompleted.next(!0)}}async computeByChem(){const t=await(0,Qt.D)(this.moleculeColumn),e=(a.DataFrame.fromColumns([t]),await o.functions.call("Chem:callChemSimilaritySearch",{df:this.dataFrame,col:t,molecule:t.get(this.targetMoleculeIdx),metricName:this.distanceMetric,limit:this.limit,minScore:this.cutoff,fingerprint:this.fingerprint}));this.idxs=e.getCol("indexes"),this.scores=e.getCol("score")}async computeByMM(){const t=this.moleculeColumn.length,e=Math.min(this.limit,t-1);if(!this.knn||this.kPrevNeighbors!==e){const n=(await Zt(this.moleculeColumn,Ut.U.LEVENSHTEIN)).seqList;this.kPrevNeighbors=e,this.knn=await(new F).getKNN(n,Ut.U.LEVENSHTEIN,Math.min(this.limit,t-1))}const n=new Array(e).fill(0).map(((t,e)=>({idx:this.knn.knnIndexes[this.targetMoleculeIdx][e],score:1-this.knn.knnDistances[this.targetMoleculeIdx][e]})));n.sort(((t,e)=>e.score-t.score)),n.unshift({idx:this.targetMoleculeIdx,score:a.FLOAT_NULL}),this.idxs=a.Column.int("indexes",e+1).init((t=>n[t].idx)),this.scores=a.Column.float("score",e+1).init((t=>n[t].score))}createPropertyPanel(t){const e=r.div(),n={},i=this.molCol?.name,s=t.col(i),a=tt.Cn.getOrCreate(s),l=a.getSplitter(),c=l(this.moleculeColumn.get(this.targetMoleculeIdx)),h=l(t.get(i,t.currentRowIdx)),u=function(t,e,n={}){const i={...te,...n},s=t.length,o=e.length,r=Array(s+1).fill(0).map((()=>Array(o+1).fill(0)));let a=-9999,l=[1,1];for(let n=1;n<s+1;n++)for(let s=1;s<o+1;s++)r[n][s]=Math.max(0,r[n-1][s-1]+(t[n-1]===e[s-1]?i.matchScore:-i.matchScore),r[n-1][s]-i.gapPenalty,r[n][s-1]-i.gapPenalty),r[n][s]>=a&&(a=r[n][s],l=[n,s]);let c=i.localAlignment?l[0]:s,h=i.localAlignment?l[1]:o,u=new Array(0),d=new Array(0);for(;c>0&&h>0;){const n=Math.max(r[c-1][h-1],r[c-1][h],r[c][h-1]);r[c][h]==r[c-1][h-1]+i.matchScore&&n==r[c-1][h-1]?(u.push(t[c-1]),d.push(e[h-1]),c-=1,h-=1):r[c][h]==r[c-1][h]-i.gapPenalty?(d.push(i.gapSymbol.valueOf()),u.push(t[c-1]),c-=1):r[c][h]==r[c][h-1]-i.gapPenalty?(u.push(i.gapSymbol.valueOf()),d.push(e[h-1]),h-=1):(u.push(t[c-1]),d.push(e[h-1]),c-=1,h-=1)}u=[...Array.from(t).splice(0,c),...u.reverse(),...i.localAlignment?Array.from(t).splice(l[0],s):[]],d=[...Array.from(e).splice(0,h),...d.reverse(),...i.localAlignment?Array.from(e).splice(l[1],o):[]];const m=c,p=h;return m>p?d=[...new Array(m-p).fill(i.gapSymbol.valueOf()),...d]:u=[...new Array(p-m).fill(i.gapSymbol.valueOf()),...u],d.length>u.length?u.push(...new Array(d.length-u.length).fill(i.gapSymbol.valueOf())):d.push(...new Array(u.length-d.length).fill(i.gapSymbol.valueOf())),{seq1:u.join(""),seq2:d.join(""),seq1Splitted:u,seq2Splitted:d}}(Array.from(c),Array.from(h)),d=qt(u.seq1Splitted,u.seq2Splitted,a.units,n);e.append(r.div(d,{style:{width:"300px",overflow:"scroll"}})),c.length!==h.length&&e.append(r.divV([r.divText("Different sequence length:",{style:{fontWeight:"bold"}}),r.divText(`target: ${c.length} monomers`),r.divText(`selected: ${h.length} monomers`)],{style:{paddingBottom:"10px"}})),e.append(zt(n));const m=r.accordion(),p=r.element("i");p.className="grok-icon svg-icon svg-view-layout",m.addTitle(r.span([p,r.label("Similarity search")])),m.addPane("Differences",(()=>e),!0),o.shell.o=m.root}}var ne=n(279);class ie extends Jt{constructor(){super("diversity"),this.renderMolIds=null,this.columnNames=[],this.computeCompleted=new f.Subject,this.diverseColumnLabel=this.string("diverseColumnLabel",null)}async renderInt(t){if(this.beforeRender()&&this.dataFrame&&t&&this.moleculeColumn){const t=tt.Cn.getOrCreate(this.moleculeColumn);await(t.isFasta()?this.computeByMM():this.computeByChem());const e=null!=this.diverseColumnLabel?this.diverseColumnLabel:`diverse (${this.moleculeColumnName})`,n=a.Column.string(e,this.renderMolIds.length).init((t=>this.moleculeColumn?.get(this.renderMolIds[t])));n.semType=a.SEMTYPE.MACROMOLECULE,this.tags.forEach((t=>n.setTag(t,this.moleculeColumn.getTag(t))));const i=a.DataFrame.fromColumns([n]);i.onCurrentRowChanged.subscribe((t=>{this.dataFrame.currentRowIdx=this.renderMolIds[i.currentRowIdx]})),(0,at.Y)(this.root,i.plot.grid().root),this.computeCompleted.next(!0)}}async computeByChem(){const t=await(0,Qt.D)(this.moleculeColumn);a.DataFrame.fromColumns([t]),this.renderMolIds=await o.functions.call("Chem:callChemDiversitySearch",{col:t,metricName:this.distanceMetric,limit:this.limit,fingerprint:this.fingerprint})}async computeByMM(){const t=(await Zt(this.moleculeColumn,Ut.U.LEVENSHTEIN)).seqList,e=new G.m(!0,!1),n=await e.calc(t,Ut.U.LEVENSHTEIN);e.terminate();const i=this.moleculeColumn.length,s=(0,P.y)(i);this.renderMolIds=(0,ne.L)(i,Math.min(i,this.limit),((t,e)=>this.moleculeColumn.isNone(t)||this.moleculeColumn.isNone(e)?0:n[s(t,e)]))}}var se,oe=n(4004),re=n(9943),ae=n(6099),le=n(2918),ce=function(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class he{constructor(t,e,n=!1,i){var s;this.name="",this.description="",this._isAutomatic=!1,this._autoStartFirstStep=!1,this._currentStep=0,this._isStopped=!1,this._isCancelled=!1,this._isStepProcessed=!1,this._root=r.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._steps=[],this._mainHeader=r.panel([],"tutorials-main-header"),this._header=r.h2(""),this._headerDiv=r.divH([],"tutorials-root-header"),this._stopStartBtn=r.button(r.iconFA("pause"),(()=>this._changeStopState()),"Play / pause"),this._restartBtn=r.button(r.iconFA("redo"),(()=>this._restartScript()),"Restart"),this._nextStepBtn=r.button(r.iconFA("play"),(()=>{this._isStepProcessed||this._nextStep()}),"Next step"),this._activity=r.panel([],"tutorials-root-description"),this._progressDiv=r.divV([],"tutorials-root-progress"),this._progress=r.element("progress"),this._progressSteps=r.divText(""),this._closeBtn=r.button(r.iconFA("chevron-left"),(()=>this._closeDock()),"Back to demo"),this.name=t,this.description=e,this._isAutomatic=n,this._autoStartFirstStep=null!==(s=null==i?void 0:i.autoStartFirstStep)&&void 0!==s&&s,this._progress.max=0,this._progress.value=1,he.currentObject=this}get steps(){return this._steps}get stepNumber(){return this._steps.length}_addHeader(){this._createHeaderDiv(),this._createProgressDiv(),this._mainHeader.append(this._headerDiv,this._progressDiv)}_createHeaderDiv(){this._header.innerText=this.name,this._headerDiv.append(this._closeBtn),this._headerDiv.append(this._header),this._nextStepBtn.firstChild.className="grok-icon fas fa-play",this._headerDiv.append(this._isAutomatic?this._stopStartBtn:this._nextStepBtn)}_createProgressDiv(){this._progress.max=this.stepNumber,this._progressDiv.append(this._progress),this._progressSteps=r.divText(`Step: ${this._progress.value} of ${this.stepNumber}`),this._progressDiv.append(this._progressSteps)}_addDescription(){var t;this._activity.append(r.div(this.description,"tutorials-root-description"));for(let e=0;e<this.stepNumber;e++){let n=r.iconFA("clock");this._isAutomatic||0===e&&(n=r.iconFA("play",(()=>this._nextStep()),"Next step"),n.className="grok-icon fas fa-play");const i=r.div(this._steps[e].name,"grok-tutorial-entry-instruction"),s=r.div(null===(t=this._steps[e].options)||void 0===t?void 0:t.description,"grok-tutorial-step-description hidden"),o=r.divH([n,i],"grok-tutorial-entry");this._activity.append(o,s)}}_initRoot(){var t,e,n;o.shell.windows.showContextPanel=!0,o.shell.windows.showHelp=!1;const i=Array.from(o.shell.dockManager.rootNode.children)[0];this._node=o.shell.dockManager.dock(this._root,a.DOCK_TYPE.FILL,i,""),(null===(e=null===(t=i.parent.container.containerElement.firstElementChild)||void 0===t?void 0:t.lastElementChild)||void 0===e?void 0:e.classList.contains("tab-handle-list-container"))&&(null===(n=i.parent.container.containerElement.firstElementChild)||void 0===n||n.lastElementChild.remove()),this._node.container.containerElement.classList.add("tutorials-demo-script-container"),this._addHeader(),this._root.append(this._mainHeader),this._addDescription(),this._root.append(this._activity)}_nextStep(){var t,e;return ce(this,void 0,void 0,(function*(){this._isStepProcessed=!0,this._isAutomatic||(this._nextStepBtn.classList.add("disabled"),this._nextStepBtn.firstChild.classList.add("fa-disabled"));const n=this._activity.getElementsByClassName("grok-tutorial-entry")[this._currentStep],i=this._activity.getElementsByClassName("grok-icon")[this._currentStep],s=this._activity.getElementsByClassName("grok-tutorial-step-description")[this._currentStep];i.className="grok-icon far fa-spinner-third fa-spin",s.classList.remove("hidden"),s.classList.add("visible");const o=n,a=(null===(t=this._steps[this._currentStep].options)||void 0===t?void 0:t.delay)?null===(e=this._steps[this._currentStep].options)||void 0===e?void 0:e.delay:2e3;yield this._steps[this._currentStep].func(),this._scrollTo(this._root,o.offsetTop-this._mainHeader.offsetHeight),this._isAutomatic&&(yield this._countdown(n,i,a),yield(0,_t.gw)(a));const l=r.iconFA("check");if(i.replaceWith(l),l.className="grok-icon far fa-check",this._progress.value++,this._progressSteps.innerText=`Step: ${this._progress.value} of ${this.stepNumber}`,this._currentStep++,this._isStepProcessed=!1,this._currentStep!==this.stepNumber){if(!this._isAutomatic){const t=this._activity.getElementsByClassName("grok-icon")[this._currentStep],e=r.iconFA("play",(()=>this._nextStep()),"Next step");e.className="grok-icon fas fa-play",t.replaceWith(e),this._nextStepBtn.classList.remove("disabled"),this._nextStepBtn.firstChild.classList.remove("fa-disabled")}}else this._isAutomatic?this._stopStartBtn.replaceWith(this._restartBtn):this._nextStepBtn.replaceWith(this._restartBtn)}))}_startScript(){return ce(this,void 0,void 0,(function*(){for(let t=this._currentStep;t<this.stepNumber&&!this._isStopped&&!this._isCancelled;t++)yield this._nextStep()}))}_scrollTo(t,e){t.focus(),t.scrollTop=e}_countdown(t,e,n){return ce(this,void 0,void 0,(function*(){const i=r.div([],"demo-script-countdown");e.classList.add("hidden");let s=n/1e3;const o=this._createSVGIndicator(s);i.append(o),t.prepend(i);const a=setInterval((()=>{s--,0===s&&(clearInterval(a),i.remove(),e.classList.remove("hidden"),e.classList.add("visible"))}),1e3)}))}_createSVGIndicator(t){const e=document.createElementNS("http://www.w3.org/2000/svg","svg"),n=document.createElementNS("http://www.w3.org/2000/svg","circle");return n.setAttributeNS(null,"cx","7"),n.setAttributeNS(null,"cy","7"),n.setAttributeNS(null,"r","6"),n.setAttributeNS(null,"style",`animation: countdown ${t}s linear infinite forwards`),e.append(n),e}_changeStopState(){const t=this._stopStartBtn.getElementsByClassName("grok-icon");t[0].className="grok-icon fas fa-play",this._isStopped=!this._isStopped,this._isStopped||(t[0].className="grok-icon fal fa-pause",this._isStepProcessed||this._startScript())}_restartScript(){o.shell.dockManager.close(this._node),o.shell.closeAll(),this._clearRoot(),this._setInitParams(),this.start()}_clearRoot(){this._root=r.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._mainHeader=r.panel([],"tutorials-main-header"),this._header=r.h2(""),this._headerDiv=r.divH([],"tutorials-root-header"),this._activity=r.panel([],"tutorials-root-description"),this._progressDiv=r.divV([],"tutorials-root-progress"),this._progress=r.element("progress"),this._progressSteps=r.divText(""),this._progress.max=0,this._progress.value=1}_setInitParams(){this._currentStep=0,this._isStopped=!1,this._isCancelled=!1,this._stopStartBtn.getElementsByClassName("grok-icon")[0].className="grok-icon fal fa-pause",this._nextStepBtn.classList.remove("disabled")}_closeDock(){o.shell.dockManager.close(this._node),this.cancelScript()}cancelScript(){this._isCancelled=!0,he.currentObject=null}step(t,e,n){return this._steps[this.steps.length]={name:t,func:e,options:n},this}start(){return ce(this,void 0,void 0,(function*(){this._initRoot(),o.shell.newView(this.name),this._isAutomatic?this._startScript():this._autoStartFirstStep&&(yield this._nextStep())}))}}function ue(t){const e=t instanceof Error?t.message:t.toString(),n=t instanceof Error?t.stack:void 0;o.shell.error(e),fn.logger.error(t.message,void 0,n)}he.currentObject=null,function(t){t.X="Embed_X",t.Y="Embed_Y"}(se||(se={}));const de="data/sample_FASTA_PT_activity.csv";async function me(){const t="Dendrogram",e=a.Func.find({package:t,name:"getTreeHelper"});if(0===e.length)throw new Error(`Package "${t}" must be installed for TreeHelper.`);return(await e[0].prepare().call()).getOutputParamValue()}async function pe(){return await o.functions.call("Dendrogram:getDendrogramService",{})}var ge=function(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function fe(t,e,i){return ge(this,void 0,void 0,(function*(){return new Promise((function(s,o){const r=new Worker(new URL(n.p+n.u(356),n.b));r.postMessage({distMatArray:t,n:e,methodCode:i}),r.onmessage=({data:{error:t,clusterMatrix:e}})=>{r.terminate(),t?o(t):s(e)}}))}))}var ye=function(t,e,n,i){return new(n||(n=Promise))((function(s,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};n(7905);const be="data/sample_FASTA_PT_activity.csv",Ce="sequence";var we=n(3336),ve=n.n(we);const Se="data/sample_FASTA_PT_activity.csv";var Ae=n(8341);const xe="samples/HELM.csv";var Te=n(2568),Ie=n(525);class Me{constructor(t,e,n={}){this.urlParams=t,this.funcName=e,this.options=n}async init(t){this.df=t,await this.buildView()}async buildView(){const t=ct()(this.urlParams.entries()).map((([t,e])=>`${t}=${encodeURIComponent(e)}`)).toArray().join("&");this.view=o.shell.addTableView(this.df),this.view.path=this.view.basePath=`func/${fn.name}.${this.funcName}?${t}`;const e={...this.options,sequenceColumnName:"sequence"};for(const[t,n]of this.urlParams.entries())switch(t){case kt.bo.fixWidth:case kt.bo.fitArea:e[t]=["1","on","true"].includes(n.toLowerCase());break;default:e[t]=n}const n=await this.view.dataFrame.plot.fromType("WebLogo",e);this.view.dockManager.dock(n,a.DOCK_TYPE.DOWN,null,"WebLogo",.35)}}class Le{get funcParams(){return{table:this.tableInput.value,sequence:this.seqColInput.value}}get paramsUI(){return this.funcParamsDiv}constructor(){this.tableInput=r.tableInput("Table",o.shell.tv.dataFrame,void 0,(()=>{this.onTableInputChanged()}));const t=this.tableInput.value.columns.bySemType(a.SEMTYPE.MACROMOLECULE),e={filter:t=>t.semType===a.SEMTYPE.MACROMOLECULE};this.seqColInput=r.columnInput("Sequence",this.tableInput.value,t,null,e),this.funcParamsDiv=r.inputs([this.tableInput,this.seqColInput],{style:{minWidth:"320px"}})}onTableInputChanged(){this.seqColInput=r.columnInput("Sequence",this.tableInput.value,this.tableInput.value.columns.bySemType(a.SEMTYPE.MACROMOLECULE))}}var Ee=n(9416);class Ne{constructor(t){this.monomerLib=t}getCappedRotatedMonomer(t,e){const n=this.monomerLib.getMonomer(t,e);return n?n.molfile:null}}const Re=new class{constructor(){this.tooltipHandlerTemp="tooltip-handler.Monomer"}},_e={autoCrop:!0,autoCropMargin:0,suppressChiralText:!0};class Oe{constructor(t){this.gridCol=t,this.gridCol.grid.onCellTooltip(this.onCellTooltip.bind(this))}onCellTooltip(t,e,n){if(t.grid.dart!=this.gridCol.grid.dart||t.gridColumn.dart!=this.gridCol.dart||!t.tableColumn||!t.isTableCell)return!1;const i=t.tableColumn.getTag("alphabet"),s=t.cell.value,a="DNA"===i||"RNA"===i?"RNA":"PEPTIDE",l=new Ne(yn().getBioLib()).getCappedRotatedMonomer(a,s),c=r.div(s),h=l?o.chem.svgMol(l,void 0,void 0,_e):null,u=t.grid.canvas.getBoundingClientRect(),d=t.bounds.right+u.left-4,m=t.bounds.bottom+u.top-4;return r.tooltip.show(r.divV([c,...h?[h]:[]]),d,m),!0}static getOrCreate(t){let e=t.temp[Re.tooltipHandlerTemp];return e||(e=t.temp[Re.tooltipHandlerTemp]=new Oe(t)),e}}class Pe extends a.GridCellRenderer{get name(){return St.Of.MONOMER}get cellType(){return St.Of.MONOMER}get defaultHeight(){return 15}get defaultWidth(){return 40}render(t,e,n,i,s,o,r){if(o.gridRow<0)return;Oe.getOrCreate(o.gridColumn),t.font="12px monospace",t.textBaseline="middle",t.textAlign="center";const a=(0,Ct.py)(o.cell.column.getTag("alphabet")),l=o.cell.value;if(!l)return;const c=a.get(l);t.fillStyle=c,t.fillText((0,Ct.GU)(l,6),e+i/2,n+s/2,i)}}class Ge extends Map{get onPropertyChanged(){return this._onPropertyChanged}get MaxMonomerLength(){return super.get("MaxMonomerLength")}set MaxMonomerLength(t){super.set("MaxMonomerLength",t),this._onPropertyChanged.next("MaxMonomerLength")}get TooltipWebLogo(){return super.get("TooltipWebLogo")}set TooltipWebLogo(t){super.set("TooltipWebLogo",t),this._onPropertyChanged.next("TooltipWebLogo")}get DefaultSeparator(){return super.get("DefaultSeparator")}set DefaultSeparator(t){if(1!==t.length)throw new Error("The separator must be of length one.");super.set("DefaultSeparator",t),this._onPropertyChanged.next("DefaultSeparator")}constructor(t){super(Object.entries(t)),this._onPropertyChanged=new f.Subject}}class ke extends a.Package{constructor(){super(...arguments),this._initialized=!1}get properties(){return this._properties}set properties(t){this._properties=t}get initialized(){return this._initialized}completeInit(){this._initialized=!0}handleErrorUI(t){const[e,n]=(0,rt.yf)(t);o.shell.error(e),this.logger.error(e,void 0,n)}}var Fe=n(8770);class Be extends a.Widget{constructor(t){super(r.divV([])),this.viewed=!1,this.seqCol=t}async init(){const t=tt.Cn.getOrCreate(this.seqCol),e=fn.properties.TooltipWebLogo,n=this.seqCol.getTag(Ot.DX.tooltipWebLogo);!1===e||["false","off","disable","disabled"].includes(n)||(this.wlViewer=await this.seqCol.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:this.seqCol.name,backgroundColor:0,positionHeight:"Entropy",positionWidth:t.getAlphabetIsMultichar()?24:16,fixWidth:!0,fitArea:!1}),this.wlViewer.root.style.height="50px",this.root.appendChild(this.wlViewer.root),this.root.style.width="100%")}detach(){this.wlViewer.detach(),super.detach()}}var We=n(9953);function He(t){t.setTag("quality",a.SEMTYPE.MACROMOLECULE),t.setTag("aligned","SEQ"),t.setTag("alphabet","PT")}var De=n(922);async function Ve(t,e){const n=new Ue(e,t),i=await n.convertToRdKitBeautifiedMolfileColumn();return i.semType=a.SEMTYPE.MOLECULE,i}class Ue{constructor(t,e){this.helmColumn=t,this.df=e,this.helmColumn=t}async convertToSmiles(){const t=await this.getSmilesList(),e=this.df.columns.getUnusedName(`smiles(${this.helmColumn.name})`);return a.Column.fromStrings(e,t.map((t=>null===t?"":t)))}async getSmilesList(){return(await this.convertToMolfileV2KColumn()).toList().map((t=>a.chem.convert(t,a.chem.Notation.MolBlock,a.chem.Notation.Smiles)))}async convertToRdKitBeautifiedMolfileColumn(){const t=await this.getSmilesList(),e=await o.functions.call("Chem:getRdKitModule"),n=t.map((t=>{if(""===t)return null;const n=e.get_mol(t);return n?(n.normalize_depiction(1),n.straighten_depiction(!0),n):null})),i=this.df.columns.getUnusedName(`molfile(${this.helmColumn.name})`);return a.Column.fromStrings(i,n.map((t=>null===t?"":t.get_molblock())))}async convertToMolfileV2KColumn(){const t=(await this.getPolymerGraphColumn()).toList().map(((t,e)=>{const n=this.helmColumn.get(e);if(!n)return"";let i="";try{i=this.getPolymerMolfile(n,t)}catch(t){const[e,n]=(0,rt.yf)(t);fn.logger.error(e,void 0,n)}finally{return i}})),e=this.df.columns.getUnusedName(`molfileV2K(${this.helmColumn.name})`);return a.Column.fromList("string",e,t)}async getPolymerGraphColumn(){return await o.functions.call("HELM:getMolfiles",{col:this.helmColumn})}getPolymerMolfile(t,e){const n=new Ze(e),i=new Qe(t);return n.monomerSymbols.forEach(((t,e)=>{const s=n.getMonomerShifts(e);i.addMonomer(t,e,s)})),i.compileToMolfile()}}class Ze{constructor(t){this.molfileHandler=De._.getInstance(t)}get monomerSymbols(){return this.molfileHandler.atomTypes}getMonomerShifts(t){return{x:this.molfileHandler.x[t],y:this.molfileHandler.y[t]}}}class Ye{constructor(t,e){this.capGroupElements=[];const n=le.NT.instance.getBioLib().getMonomer(e,t);if(!n)throw new Error(`Monomer ${t} is not found in the library`);this.molfileWrapper=new qe(n.molfile,t),this.capGroupElements=n.rgroups.map((t=>(t.capGroupSmiles||t.capGroupSMILES).replace(/(\[|\]|\*|:|\d)/g,"")))}shiftCoordinates(t){this.molfileWrapper.shiftCoordinates(t)}getAtomLines(){return this.molfileWrapper.getAtomLines()}getBondLines(){return this.molfileWrapper.getBondLines()}removeBondedRGroups(t){this.molfileWrapper.removeRGroups(t)}capTrailingRGroups(){this.molfileWrapper.capRGroups(this.capGroupElements)}replaceRGroupWithAttachmentAtom(t,e){this.molfileWrapper.replaceRGroupWithAttachmentAtom(t,e)}getAttachmentAtomByRGroupId(t){return this.molfileWrapper.getAttachmentAtomByRGroupId(t)}deleteBondLineWithSpecifiedRGroup(t){this.molfileWrapper.deleteBondLineWithSpecifiedRGroup(t)}shiftBonds(t){this.molfileWrapper.shiftBonds(t)}}class $e{constructor(t,e,n){this.atoms=e,this.bonds=n,this.rGroupBondPositionMap=new Map,this.rGroupIdToAtomicIndexMap=this.getRGroupIdToAtomicIdxMap(t)}getAtomicIdx(t){const e=this.rGroupIdToAtomicIndexMap.get(t);return void 0===e?null:e}removeRGroupsFromAtomBlock(t){t.forEach((t=>{if(void 0===this.rGroupIdToAtomicIndexMap.get(t))throw new Error(`Cannot find atomic index for R group ${t}`)}));const e=Array.from(this.rGroupIdToAtomicIndexMap.entries()).filter((([e,n])=>t.includes(e))).map((([t,e])=>e));this.atoms.deleteAtoms(e)}removeRGroups(t){this.removeRGroupsFromAtomBlock(t),t.forEach((t=>{const e=this.replaceRGroupInBondsByDummy(t);this.rGroupBondPositionMap.set(t,e)}))}replaceRGroupInBondsByDummy(t){const e=this.rGroupIdToAtomicIndexMap.get(t);if(this.rGroupBondPositionMap.has(t))throw new Error(`R group ${t} is already handled`);const n=this.bonds.getPositionsInBonds(e+1);if(0===n.length)throw new Error(`Cannot find position for R group ${t}`);if(n.length>1)throw new Error(`More than one position for R group ${t}`);const i=n[0];return this.bonds.replacePositionsInBondsByDummy([i]),this.bonds.removeAtomIdFromBonds(e+1),this.removeRGroupFromAtomicIdxMap(t,e),i}removeRGroupFromAtomicIdxMap(t,e){this.rGroupIdToAtomicIndexMap.delete(t);for(const[t,n]of this.rGroupIdToAtomicIndexMap)n>e&&this.rGroupIdToAtomicIndexMap.set(t,n-1)}getRGroupIdToAtomicIdxMap(t){const e=new Map;t.filter((t=>t.startsWith("M RGP"))).forEach((t=>{const n=function(t){const e=t.split(/\s+/).filter((t=>t)).slice(3).map((t=>parseInt(t))),n=new Array(e.length/2);for(let t=0;t<e.length;t+=2)n[t/2]=[e[t+1],e[t]-1];return n}(t);for(const[t,i]of n){if(e.has(t))throw new Error(`R group ${t} is already in the map`);e.set(t,i)}}));const n=t.map(((t,e)=>{if(t.startsWith("A "))return e})).filter((t=>void 0!==t)),i=n.map((e=>t[e])),s=n.map((e=>t[e+1]));i.forEach(((t,n)=>{const i=parseInt(t.split(/\s+/)[1])-1,o=parseInt(s[n].substring(1));if(e.has(o))throw new Error(`R group ${o} is already in the map`);e.set(o,i)}));const o=this.atoms.getRGroupAtomicIndices().filter((t=>!Array.from(e.values()).includes(t)));if(0!==o.length)throw new Error(`Unaccounted R group indices: ${o}`);return e}deleteBondLineWithSpecifiedRGroup(t){const e=this.rGroupBondPositionMap.get(t);if(!e)throw new Error(`Cannot find position for R group ${t}`);const{bondLineIdx:n}=e;this.bonds.deleteBondLines([n]),this.rGroupBondPositionMap.delete(t),this.rGroupIdToAtomicIndexMap.delete(t),this.rGroupBondPositionMap.forEach((t=>{t.bondLineIdx>n&&(t.bondLineIdx-=1)}))}replaceRGroupWithAttachmentAtom(t,e){const n=this.rGroupBondPositionMap.get(t);if(!n)throw new Error(`Cannot find position for R group ${t}`);const{bondLineIdx:i,nodeIdx:s}=n;this.bonds.bondedAtoms[i][s]=e}getAttachmentAtomIdByRGroupId(t){const e=this.rGroupBondPositionMap.get(t);if(!e)throw new Error(`Cannot find position for R group ${t}`);const{bondLineIdx:n,nodeIdx:i}=e;return this.bonds.bondedAtoms[n][(i+1)%2]}capRGroups(t){this.rGroupIdToAtomicIndexMap.forEach(((e,n)=>{const i=t[n-1];"H"===i?(this.removeRGroups([n]),this.deleteBondLineWithSpecifiedRGroup(n)):this.atoms.replaceElementSymbol(e,i)}))}}class Ke{constructor(t){this.bondedPairs=[],this.rawBondLines=[],this.rawBondLines=t,this.bondedPairs=this.rawBondLines.map((t=>[parseInt(t.substring(0,3)),parseInt(t.substring(3,6))]))}getBondLines(){return this.bondedPairs.map(((t,e)=>{if(t.some((t=>-1===t)))throw new Error(`Bonded pair ${t} contains -1`);return`${t[0].toString().padStart(3," ")}${t[1].toString().padStart(3," ")}${this.rawBondLines[e].substring(6)}`}))}get bondedAtoms(){return this.bondedPairs}deleteBondLines(t){this.rawBondLines=this.rawBondLines.filter(((e,n)=>!t.includes(n))),this.bondedPairs=this.bondedPairs.filter(((e,n)=>!t.includes(n)))}getPositionsInBonds(t){const e=[];return this.bondedPairs.forEach(((n,i)=>{n.forEach(((n,s)=>{n===t&&e.push({bondLineIdx:i,nodeIdx:s})}))})),e}replacePositionsInBondsByDummy(t,e){void 0===e&&(e=-1),t.forEach((t=>{const{bondLineIdx:n,nodeIdx:i}=t;this.bondedPairs[n][i]=e}))}removeAtomIdFromBonds(t){this.bondedPairs=this.bondedPairs.map((e=>e.map((e=>e>t?e-1:e))))}shift(t){this.bondedPairs=this.bondedPairs.map((e=>e.map((e=>e+t))))}}class Xe{constructor(t){this.coordinates=[],this.rawAtomLines=[],this.rawAtomLines=t,this.coordinates=this.rawAtomLines.map((t=>({x:parseFloat(t.substring(0,10)),y:parseFloat(t.substring(10,20))})))}get atomCoordinates(){return this.coordinates}get atomLines(){return this.rawAtomLines.map(((t,e)=>{const n=this.coordinates[e];return`${n.x.toFixed(4).padStart(10," ")}${n.y.toFixed(4).padStart(10," ")}${t.substring(20)}`}))}replaceElementSymbol(t,e){this.rawAtomLines[t]=this.rawAtomLines[t].replace("R#",e)}deleteAtoms(t){this.coordinates=this.coordinates.filter(((e,n)=>!t.includes(n))),this.rawAtomLines=this.rawAtomLines.filter(((e,n)=>!t.includes(n)))}shift(t){this.coordinates=this.coordinates.map((e=>{const n=e.x+t.x,i=e.y+t.y;if(isNaN(n)||isNaN(i))throw new Error(`Cannot shift coordinates by ${t.x}, ${t.y}`);return{x:n,y:i}}))}rotate(t){this.coordinates=this.coordinates.map((e=>{const n=e.x,i=e.y,s=n*Math.cos(t)-i*Math.sin(t),o=n*Math.sin(t)+i*Math.cos(t);if(isNaN(s)||isNaN(o))throw new Error(`Cannot rotate coordinates by ${t}`);return{x:s,y:o}}))}getRGroupAtomicIndices(){return this.rawAtomLines.map(((t,e)=>{if(t.includes("R#"))return e})).filter((t=>void 0!==t))}}class qe{constructor(t,e){this.monomerSymbol=e;const n=t.split("\n"),i=parseInt(n[3].substring(0,3)),s=parseInt(n[3].substring(3,6)),o=n.slice(4,4+i);this.atoms=new Xe(o);const r=n.slice(4+i,4+i+s);this.bonds=new Ke(r),this.rGroups=new $e(n,this.atoms,this.bonds),this.shiftMonomerToDefaultPosition()}deleteBondLineWithSpecifiedRGroup(t){this.rGroups.deleteBondLineWithSpecifiedRGroup(t)}shiftCoordinates(t){this.atoms.shift(t)}rotateCoordinates(t){this.atoms.rotate(t)}getBondLines(){return this.bonds.getBondLines()}getAtomLines(){return this.atoms.atomLines}removeRGroups(t){this.rGroups.removeRGroups(t)}replaceRGroupWithAttachmentAtom(t,e){this.rGroups.replaceRGroupWithAttachmentAtom(t,e)}getAttachmentAtomByRGroupId(t){return this.rGroups.getAttachmentAtomIdByRGroupId(t)}shiftR1GroupToOrigin(){const t=this.rGroups.getAtomicIdx(1);if(null===t)throw new Error(`Cannot find R1 group for monomer ${this.monomerSymbol}`);const{x:e,y:n}=this.atoms.atomCoordinates[t];this.atoms.shift({x:-e,y:-n})}alignR2AlongX(){const t=this.rGroups.getAtomicIdx(2);if(null===t)throw new Error(`Cannot find R2 group for monomer ${this.monomerSymbol}`);const e=this.atoms.atomCoordinates[t],n=e.y/e.x,i=Math.atan(n);if(isNaN(i))throw new Error(`Cannot calculate angle for R2 group for monomer ${this.monomerSymbol}`);this.rotateCoordinates(-i)}shiftMonomerToDefaultPosition(){this.shiftR1GroupToOrigin(),null!==this.rGroups.getAtomicIdx(2)&&this.alignR2AlongX()}shiftBonds(t){this.bonds.shift(t)}capRGroups(t){this.rGroups.capRGroups(t)}}class ze{constructor(t){this.simplePolymer=t,this.polymerType=this.getPolymerType(),this.idx=this.getIdx();const{monomers:e,monomerTypes:n}=this.getMonomerSymbolsAndTypes();this.monomers=e,this.monomerTypes=n}get id(){return this.polymerType+this.idx.toString()}getPolymerType(){const t=new RegExp("(PEPTIDE|RNA)[0-9]+{"),e=this.simplePolymer.match(t);if(!e)throw new Error(`Unsupported polymer type in ${this.simplePolymer}`);return e[1]}getIdx(){const t=new RegExp(`${this.polymerType}([0-9]+){`),e=this.simplePolymer.match(t);if(!e)throw new Error(`Cannot parse simple polymer id from ${this.simplePolymer}`);return parseInt(e[1])}getMonomerSymbolsAndTypes(){const t=new RegExp(`${this.polymerType}${this.idx}{|}`,"g"),e=this.simplePolymer.replace(t,"").split("."),n=[],i=[];return e.forEach((t=>{const e=t.split(/\(|\)/).map((t=>t.replace(/[\[\]]/g,"")));n.push(...e);const s=e.map(((t,e)=>e%2==0?0:1));i.push(...s)})),{monomers:n,monomerTypes:i}}getBondData(){const t=[],e=this.monomerTypes.map(((t,e)=>{if(0===t)return e})).filter((t=>void 0!==t)),n=this.monomerTypes.map(((t,e)=>{if(1===t)return e})).filter((t=>void 0!==t));for(let n=0;n<e.length-1;n++){const i=e[n],s=e[n+1];t.push([{monomerIdx:i,rGroupId:2},{monomerIdx:s,rGroupId:1}])}for(let e=0;e<n.length;e++){const i=n[e],s=i-1;t.push([{monomerIdx:s,rGroupId:3},{monomerIdx:i,rGroupId:1}])}return t}}class je{constructor(t){const e=t.split("|");e.forEach((t=>this.validateConnectionItem(t))),this.connectionItems=e}validateConnectionItem(t){const e="(PEPTIDE|RNA)",n=new RegExp(`${e}[0-9]+,${e}[0-9]+,[0-9]+:R[0-9]+-[0-9]+:R[0-9]+`,"g");if(!t.match(n))throw new Error(`Cannot parse connection item from ${t}`)}getConnectionData(){const t=[];return this.connectionItems.forEach((e=>{const n=[],i=e.split(",");i[2].split("-").forEach(((t,e)=>{const s=i[e],o=t.split(":"),r={monomerIdx:parseInt(o[0])-1,rGroupId:parseInt(o[1].slice(1))};n.push({polymerId:s,bond:r})})),t.push(n)})),t}}class Je{constructor(t){this.helm=t;const e=this.helm.split("$"),n=e[0].split("|");this.simplePolymers=n.map((t=>new ze(t))),""!==e[1]&&(this.connectionList=new je(e[1])),this.bondData=this.getBondData()}toString(){return this.helm}getPolymerTypeByMonomerIdx(t){return this.getSimplePolymerByMonomerIdx(t).polymerType}getSimplePolymerByMonomerIdx(t){const e=this.getMonomerIdxShifts(),n=Object.values(e).sort(((t,e)=>t-e)).find((e=>t>=e));if(void 0===n)throw new Error(`Cannot find simple polymer for monomer ${t}`);const i=Object.keys(e).find((t=>e[t]===n));return this.simplePolymers.find((t=>t.id===i))}shiftBondMonomerIds(t,e){e.forEach((e=>{e.forEach((e=>{e.monomerIdx+=t}))}))}getMonomerIdxShifts(){const t={};let e=0;return this.simplePolymers.forEach((n=>{t[n.id]=e,e+=n.monomers.length})),t}getBondData(){const t=this.getMonomerIdxShifts(),e=[];return this.simplePolymers.forEach((n=>{const i=n.getBondData(),s=t[n.id];this.shiftBondMonomerIds(s,i),e.push(...i)})),this.connectionList&&this.connectionList.getConnectionData().forEach((n=>{const i=[];n.forEach((e=>{const n=t[e.polymerId],s=e.bond;s.monomerIdx+=n,i.push(s)})),e.push(i)})),e}}class Qe{constructor(t){this.monomerWrappers=[],this.helm=new Je(t),this.bondedRGroupsMap=new Map,this.helm.bondData.forEach((t=>{t.forEach((t=>{const e=t.monomerIdx,n=t.rGroupId;this.bondedRGroupsMap.get(e)||this.bondedRGroupsMap.set(e,[]),this.bondedRGroupsMap.get(e).push(n)}))}))}addMonomer(t,e,n){const i=this.helm.getPolymerTypeByMonomerIdx(e),s=new Ye(t,i);s.shiftCoordinates(n),this.monomerWrappers.push(s)}removeRGroups(){this.monomerWrappers.forEach(((t,e)=>{this.bondedRGroupsMap.has(e)&&t.removeBondedRGroups(this.bondedRGroupsMap.get(e)),t.capTrailingRGroups()}))}getAtomNumberShifts(){const t=[];let e=0;return this.monomerWrappers.forEach((n=>{t.push(e),e+=n.getAtomLines().length})),t}restoreBondsBetweenMonomers(){this.helm.bondData.forEach((t=>{const e=t.map((t=>t.monomerIdx)),n=t.map((t=>t.rGroupId)),i=e.map((t=>this.monomerWrappers[t])),s=i[1].getAttachmentAtomByRGroupId(n[1]);i[0].replaceRGroupWithAttachmentAtom(n[0],s),i[1].deleteBondLineWithSpecifiedRGroup(n[1])}))}compileToMolfile(){const t=[],e=[];this.removeRGroups();const n=this.getAtomNumberShifts();this.monomerWrappers.forEach(((t,e)=>{t.shiftBonds(n[e])})),this.restoreBondsBetweenMonomers(),this.monomerWrappers.forEach((n=>{t.push(...n.getAtomLines()),e.push(...n.getBondLines())}));const i=t.length;if(i>999)throw new Error(`Atom count in polymer ${this.helm.toString()} is ${i} and exceeds 999`);const s=e.length;return["\nDatagrok\n",`${i.toString().padStart(3," ")}${s.toString().padStart(3," ")} 0 0 1 0 0 V2000`,t.join("\n"),e.join("\n"),"M END\n"].join("\n")}}class tn{constructor(t,e){this.helmColumn=t,this.leftTerminal=e.leftTerminal,this.rightTerminal=e.rightTerminal}transform(){return this.helmColumn.toList().map((t=>this.hasTerminals(t)?this.getTransformedHelm(t):t))}}class en extends tn{constructor(t,e){super(t,e)}hasTerminals(t){return this.getLinkedPositions(t).every((t=>t>0))}getLinkedPositions(t){return[1,t.replace("PEPTIDE1{","").replace("}$$$$","").split(".").findIndex(((t,e)=>t===this.rightTerminal&&e>0))+1]}getTransformedHelm(t){const e=this.getLinkedPositions(t);return an(t,{monomerPosition:e[0],attachmentPoint:1},{monomerPosition:e[1],attachmentPoint:3})}}class nn extends tn{constructor(t,e){super(t,e)}hasTerminals(t){return this.leftTerminal===We.M||this.rightTerminal===We.M||t.includes("PEPTIDE1{"+this.leftTerminal)&&t.includes(this.rightTerminal+"}$$$$")}getLinkedPositions(t){return[1,rn(t)]}getTransformedHelm(t){const e=this.getLinkedPositions(t);return an(t,{monomerPosition:e[0],attachmentPoint:1},{monomerPosition:e[1],attachmentPoint:2})}}class sn extends tn{constructor(t,e){super(t,e)}hasTerminals(t){return this.leftTerminal===We.M||this.rightTerminal===We.M||this.getLinkedPositions(t).every((t=>t>0))}getLinkedPositions(t){const e=t.replace("PEPTIDE1{","").replace("}$$$$","").split("."),n=e.findIndex((t=>t===this.leftTerminal)),i=e.findIndex(((t,e)=>t===this.rightTerminal&&e>n));return[n+1,i+1]}getTransformedHelm(t){const e=this.getLinkedPositions(t);return an(t,{monomerPosition:e[0],attachmentPoint:3},{monomerPosition:e[1],attachmentPoint:3})}}class on{constructor(){}static getInstance(t,e){const n=e.cyclizationType;return"R3-R3"===n?new sn(t,e):"N-Cys"===n?new en(t,e):new nn(t,e)}}function rn(t){return t.replace("PEPTIDE1{","").replace("}$$$$","").split(".").length}function an(t,e,n){return t.replace("}$$$$",`}$PEPTIDE1,PEPTIDE1,${e.monomerPosition}:R${e.attachmentPoint}-${n.monomerPosition}:R${n.attachmentPoint}${"$".repeat(6)}`)}async function ln(t,e,n){const i=t.dataFrame,s=tt.Cn.getOrCreate(t).convert(Ct.r2.HELM),r=on.getInstance(s,e).transform(),l=i.columns.getUnusedName(`${e.transformationType}(`+t.name+")"),c=a.Column.fromList("string",l,r);He(c),c.setTag("units",Ct.r2.HELM);const h=await Ve(i,c);h.name=i.columns.getUnusedName(`${e.transformationType}_molfile(`+t.name+")"),n&&(c.setTag("cell.renderer","helm"),i.columns.add(c)),i.columns.add(h,!0),await o.data.detectSemanticTypes(i)}function cn(t,e,n,i){const s=tt.Cn.getOrCreate(t);let o=null,r=null;for(let t=0;t<s.posList.length;++t)s.posList[t]==e&&(o=t),s.posList[t]==n&&(r=t);if(null===o&&null!==e)throw new Error(`Start position ${e} not found.`);if(null===r&&null!==n)throw new Error(`End position ${n} not found.`);if(s.posList.length<r)throw new Error(`End position ${r} exceeds positions length`);const a=i||`${t.name}: (${e??""}-${n??""})`;return s.getRegion(o,r,a)}const hn={df:a.DataFrame.fromCsv("seq,value\nATCCGTCGT,0.5\nTGTTCGTCA,0.4\nATGGTCGTA,0.7\nATCCGTGCA,0.1"),colName:"seq",positionNames:["1","1A","1C","2","4","4A","4B","5","6"].join(Ct.CI),regions:[{name:"first region",start:"1",end:"2"},{name:"second region",start:"1C",end:"4"},{name:"overlapping second",start:"1C",end:"4A"},{name:"whole sequence",start:"1",end:"6"},{name:"bad start",start:"0",end:"6"},{name:"bad end",start:"1",end:"4C"},{name:"bad start & end",start:"0",end:"4C"}]};class un{constructor(t,e){this.urlParams=t,this.funcName=e}async init(t){this.data=t??hn;const e=this.data.df.getCol(this.data.colName);this.data.positionNames&&e.setTag(".positionNames",this.data.positionNames),this.data.regions&&e.setTag(".regions",JSON.stringify(this.data.regions)),await this.buildView()}async buildView(){await o.data.detectSemanticTypes(this.data.df),this.view=o.shell.addTableView(this.data.df),this.view.path=this.view.basePath=`func/${fn.name}.${this.funcName}`;const t=await this.view.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:this.data.colName});this.view.dockManager.dock(t,a.DOCK_TYPE.DOWN,null,"WebLogo",.35)}}class dn{constructor(t){this.call=t,this.inputs=new class{},this.fixRegion=!1,this.defaultName=!0,this.defaultNameUpdating=!1;const e=t=>this.call.inputParams[t].property.description;this.inputs.table=r.tableInput("Table",this.call.inputParams.table.value??o.shell.tv.dataFrame,void 0,(()=>{}));const n=this.call.inputParams.sequence.value??this.inputs.table.value.columns.bySemType(a.SEMTYPE.MACROMOLECULE),i={filter:t=>t.semType===a.SEMTYPE.MACROMOLECULE};this.inputs.sequence=r.columnInput("Sequence",o.shell.tv.dataFrame,n,this.sequenceInputChanged.bind(this),i),this.inputs.start=r.choiceInput("Start",void 0,[],this.startInputChanged.bind(this)),this.inputs.end=r.choiceInput("End",void 0,[],this.endInputChanged.bind(this)),this.inputs.region=r.choiceInput("Region",null,[],this.regionInputChanged.bind(this)),this.inputs.name=r.stringInput("Column name",this.getDefaultName(),this.nameInputChanged.bind(this),{clearIcon:!0}),this.inputs.name.onInput(this.nameInputInput.bind(this));for(const t in this.call.inputParams)r.tooltip.bind(this.inputs[t].captionLabel,e(t));this.sequenceInputChanged()}sequenceInputChanged(){const t=this.inputs.sequence.value;t&&tt.Cn.getOrCreate(t),this.updateRegionItems(),this.updateStartEndInputItems(),this.updateRegion(!0),this.updateNameInput()}regionInputChanged(){this.fixRegion=!0;try{const t=this.inputs.region.stringValue,e=t?JSON.parse(t):null;if(null!==e)this.inputs.start.value=e?.start,this.inputs.end.value=e?.end;else{const t=tt.Cn.getOrCreate(this.inputs.sequence.value);this.inputs.start.value=t.posList[0],this.inputs.end.value=t.posList[t.posList.length-1]}}finally{this.fixRegion=!1}}startInputChanged(){this.updateRegion(!1),this.updateNameInput()}endInputChanged(){this.updateRegion(!1),this.updateNameInput()}nameInputChanged(){this.defaultNameUpdating||(this.defaultName=!1)}nameInputInput(){this.inputs.name.value||(this.defaultName=!0,this.inputs.name.input.focus())}updateStartEndInputItems(){const t=this.inputs.sequence.value,e=t?tt.Cn.getOrCreate(t):null,n=this.inputs.start.input,i=this.inputs.end.input;for(let t=n.options.length-1;t>=0;--t)n.options.remove(t);for(let t=i.options.length-1;t>=0;--t)i.options.remove(t);for(const t of e?.posList??[]){const e=document.createElement("option"),s=document.createElement("option");e.text=s.text=t,e.value=s.value=t,n.options.add(e),i.options.add(s)}n.value=e?.posList[0]??"",i.value=e?.posList[e?.posList.length-1]??""}updateRegionItems(){const t=this.inputs.sequence.value,e=t?t.getTag(".regions"):null,n=e?JSON.parse(e):null,i=this.inputs.region.input;for(let t=i.options.length-1;t>=0;--t)i.options.remove(t);const s=document.createElement("option");if(s.text="",s.value=JSON.stringify(null),i.options.add(s),null!=n){this.inputs.region.root.style.removeProperty("display");for(const t of n){const e=document.createElement("option");e.text=`${t.name}: ${t.start}-${t.end}`,e.value=JSON.stringify(t),i.options.add(e)}}else this.inputs.region.root.style.display="none"}updateRegion(t){const e=this.inputs.start.stringValue??"",n=this.inputs.end.stringValue??"";if(!this.fixRegion){const t=this.inputs.region.input;t.selectedIndex=-1;for(let i=t.options.length-1;i>=0;--i){const s=t.options[i],o=JSON.parse(s.value);o&&e===o.start&&n===o.end&&(t.selectedIndex=i)}}}updateNameInput(){this.defaultNameUpdating=!0;try{this.defaultName&&(this.inputs.name.value=this.getDefaultName())}finally{this.defaultNameUpdating=!1}}getDefaultName(){const t=this.inputs.region.stringValue,e=t?JSON.parse(t):null,n=this.inputs.sequence.value,i=this.inputs.start.stringValue??"",s=this.inputs.end.stringValue??"";return null!=e?`${n.name}(${e.name}): ${e.start}-${e.end}`:`${n?.name}: (${i}-${s})`}getParams(){return{table:this.inputs.table.value,sequence:this.inputs.sequence.value,start:this.getStart(),end:this.getEnd(),name:this.getName()}}getStart(){return this.inputs.start.stringValue}getEnd(){return this.inputs.end.stringValue}getName(){const t=this.inputs.name.stringValue;return""==t?null:t}dialog(){const t=r.inputs(Object.values(this.inputs),{style:{minWidth:"320px"}});r.dialog({title:"Get Region"}).add(t).onOK((()=>{(async()=>{const t=this.getParams();await this.call.func.prepare(t).call(!0)})().catch((t=>{fn.handleErrorUI(t)}))})).show()}widget(){const t=r.inputs(Object.entries(this.inputs).filter((([t,e])=>!["table","sequence"].includes(t))).map((([t,e])=>e))),e=r.button("Get Region",(()=>{(async()=>{const t=this.getParams();await this.call.func.prepare(t).call(!0)})().catch((t=>{fn.handleErrorUI(t)}))}));return a.Widget.fromRoot(r.divV([t,r.div(e)]))}}var mn=n(8601);class pn extends m{activitiesInput;activitiesInputRoot;similarityInput;constructor(t={}){super(t);const e=this.tableInput.value.columns.numerical;this.activitiesInput=r.columnInput("Activities",this.tableInput.value,a.Utils.firstOrNull(e),null,{filter:t=>Array.from(e).includes(t)}),this.activitiesInputRoot=this.activitiesInput.root,this.similarityInput=r.intInput("Similarity cutoff",80)}onTableInputChanged(){if(super.onTableInputChanged(),this.activitiesInputRoot){r.empty(this.activitiesInputRoot);const t=this.tableInput.value.columns.numerical;this.activitiesInput=r.columnInput("Activities",this.tableInput.value,a.Utils.firstOrNull(t),null,{filter:e=>Array.from(t).includes(e)}),Array.from(this.activitiesInput.root.children).forEach((t=>this.activitiesInputRoot.append(t)))}}getEditor(){return r.div([this.tableInput,this.colInputRoot,this.preprocessingFunctionInputRoot,this.preprocessingFuncSettingsDiv,this.activitiesInputRoot,this.similarityMetricInputRoot,this.methodInput,this.methodSettingsDiv,this.similarityMetricInputRoot,this.similarityInput],{style:{minWidth:"320px"},classes:"ui-form"})}getParams(){return{...super.getParams(),activities:this.activitiesInput.value,similarityThreshold:this.similarityInput.value}}}function gn(t){const e=["Embed_X","Embed_Y"],n=t.columns.names().filter((t=>t.includes(e[0]))).length+1;return e.map((t=>`${t}_${n}`))}const fn=new ke;function yn(){return le.NT.instance}let bn=null;class Cn{constructor(t){this._palette=t}get(t){return this._palette[t]}}async function wn(){fn.logger.debug("Bio: initBio(), started");const t=await o.functions.call("Chem:getRdKitModule");await Promise.all([(async()=>{await le.NT.instance.loadLibraries()})(),(async()=>{const t=await fn.getProperties(),e=new Ge(t);fn.properties=e})()]).finally((()=>{fn.completeInit()}));const e=le.NT.instance.getBioLib(),n=[],i=[],s=e.getMonomerMolsByPolymerType("PEPTIDE");Object.keys(s).forEach((e=>{n.push(e);const o=s[e].replaceAll("#R","O "),r=t.get_mol(o),a=JSON.parse(r.get_descriptors()).CrippenClogP;i.push(a),r?.delete()}));const r=i.reduce(((t,e)=>t+e),0)/i.length||0,a={};for(let t=0;t<n.length;t++)a[n[t]]=i[t]<r?"#4682B4":"#DC143C";bn=new Cn(a),fn.logger.debug("Bio: initBio(), completed")}function vn(t){const e=new Be(t);return e.init().then((()=>{})).catch((t=>{const e=t instanceof Error?t.message:t.toString();o.shell.error(e)})),e}function Sn(){return le.NT.instance.getBioLib()}function An(t){const e="getRegionTopMenu",n=a.Func.find({package:fn.name,name:e});if(1!==n.length)throw new Error(`Package '${fn.name}' func '${e}' not found`);const i=n[0].prepare({table:t.dataFrame,sequence:t});return new dn(i).widget()}async function xn(t){return(0,le.cf)()}function Tn(t){try{new dn(t).dialog()}catch(t){const e=t instanceof Error?t.message:t.toString(),n=t instanceof Error?t.stack:void 0;o.shell.error(`Get region editor error: ${e}`),fn.logger.error(e,void 0,n)}}function In(t){const e=new Le;r.dialog({title:"Split to Monomers"}).add(e.paramsUI).onOK((async()=>t.func.prepare(e.funcParams).call(!0))).show()}function Mn(t){const e=new m({semtype:a.SEMTYPE.MACROMOLECULE});r.dialog({title:"Sequence Space"}).add(e.getEditor()).onOK((async()=>{const n=e.getParams();return t.func.prepare({molecules:n.col,table:n.table,methodName:n.methodName,similarityMetric:n.similarityMetric,plotEmbeddings:n.plotEmbeddings,options:n.options,preprocessingFunction:n.preprocessingFunction,clusterEmbeddings:n.clusterEmbeddings}).call()})).show()}function Ln(t){const e=new pn({semtype:a.SEMTYPE.MACROMOLECULE});r.dialog({title:"Activity Cliffs"}).add(e.getEditor()).onOK((async()=>{const n=e.getParams();return t.func.prepare({table:n.table,molecules:n.col,activities:n.activities,similarity:n.similarityThreshold,methodName:n.methodName,similarityMetric:n.similarityMetric,preprocessingFunction:n.preprocessingFunction,options:n.options}).call()})).show()}function En(){return new Mt}function Nn(t){return function(t){const e=Array.from(t.dataFrame.columns).filter((t=>t.semType===a.SEMTYPE.MOLECULE)).map((t=>t.name));new Set(e).delete(t.name);const n=r.choiceInput("Monomer width",null!=t?.temp["monomer-width"]?t.temp["monomer-width"]:yt.short,[yt.short,yt.long],(e=>{t.temp["monomer-width"]=e,t.setTag(".mm.cellRenderer.settingsChanged",vt.true),t.dataFrame.fireValuesChanged()}));n.setTooltip("In short mode, only the 'Max monomer length' characters are displayed, followed by .. if there are more");const i=parseInt(t.getTag(pt.maxMonomerLength)),s=r.intInput("Max monomer length",isNaN(i)?fn.properties.MaxMonomerLength:i,(e=>{t.setTag(pt.maxMonomerLength,e.toString()),t.setTag(".mm.cellRenderer.settingsChanged",vt.true),t.dataFrame.fireValuesChanged()}));s.setTooltip(`The max length of monomer name displayed without shortening in '${yt.short}' monomer width mode.`);const o=r.intInput("Monomer margin",t.temp[".mm.cellRenderer.gapLength"]??0,(e=>{t.temp[".mm.cellRenderer.gapLength"]=e,t.setTag(".mm.cellRenderer.settingsChanged",vt.true),t.dataFrame.fireValuesChanged()}));o.setTooltip("The size of margin between monomers (in pixels)");const l=r.boolInput("Color code",null==t?.temp["color-code"]||t.temp["color-code"],(e=>{t.temp["color-code"]=e,t.dataFrame.fireValuesChanged()}));l.setTooltip("Color code");const c=r.stringInput("Reference sequence",null!=t?.temp["reference-sequence"]?t?.temp["reference-sequence"]:"",(e=>{t.temp["reference-sequence"]=e,t.dataFrame.fireValuesChanged()}));c.setTooltip("Reference sequence is not empty, then the sequence will be render \nas a difference from the reference sequence");const h=r.boolInput("Compare with current",null==t?.temp["compare-with-current"]||t.temp["compare-with-current"],(e=>{t.temp["compare-with-current"]=e,t.dataFrame.fireValuesChanged()}));h.setTooltip('When on, all sequences get rendered in the "diff" mode');const u=r.inputs([n,s,o,c,l,h]);return new a.Widget(u)}(t)}function Rn(t){return(0,Fe.t)(t)}function _n(){return new Mt}function On(){return new Lt}function Pn(t,e,n,i,s){const o=new Vt.k(i,s,n,e);return"Local alignment"==t?o.smithWaterman():o.needlemanWunch()}function Gn(){return new kt.OZ}function kn(){return new Dt}function Fn(t,e,n,i){return cn(t,e??null,n??null,i??null)}async function Bn(t,e,n,i,s){const r=cn(e,n??null,i??null,s??null);e.dataFrame.columns.add(r),await o.data.detectSemanticTypes(e.dataFrame)}async function Wn(t,e,n,i,s,h,u,d){if(!(0,Te.n)(e,"Activity Cliffs"))return;const m=gn(t),f={units:e.getTag(a.TAGS.UNITS),aligned:e.getTag("aligned"),separator:e.getTag("separator"),alphabet:e.getTag("alphabet")},y=h,b=e,C=async()=>await async function(t,e,n,i,s,l,c,h,u,d,m,f,y,b,C,w){Z++;const v=l/100;let S,A=!1;const x=f.inputs,T=await f.apply({[x[0].name]:e,[x[1].name]:c,...u.preprocessingFuncArgs??{}}),I=await U([T.entries],h,[c],[1],"MANHATTAN",{...u,distanceFnArgs:[T.options??{}]});if(I.length!==n.length)throw new Error("Number of axes names should be equal to number of embedding dimensions");for(let e=0;e<I.length;++e)t.columns.addNewFloat(n[e]).init((t=>I[e][t]));const M=(0,R.sQ)(c)?1-(0,g.eo)(v):v,L=await(new F).calc(T.entries,c,M,T.options),E=await async function(t,e){const n=t.distance.map(((n,i)=>{const s=Math.abs(e.get(t.i[i])-e.get(t.j[i]));return 0!=n?s/n:1/0})),i=t.distance.map((t=>1-t)),s=t.i,o=t.j,r=new Set;return t.distance.forEach(((e,n)=>{r.add(t.i[n]),r.add(t.j[n])})),{simVals:i,saliVals:n,n1:s,n2:o,cliffsMolIds:r}}(L,s),N=function(t,e,n,i,s,o){const r=new Array(t).fill(0);for(let t=0;t!=n.length;++t)e[t]!=1/0&&(o.get(n[t])>o.get(i[t])?r[n[t]]+=e[t]:r[i[t]]+=e[t]);return a.Column.fromList("double",`sali_${s[0].substring(s[0].lastIndexOf("_"))}`,r)}(e.length,E.saliVals,E.n1,E.n2,n,s);t.columns.add(N);const _=function(t,e){const n=a.BitSet.create(t.rowCount);for(let i=0;i<t.rowCount;i++)n.set(i,e.has(i));return n}(t,E.cliffsMolIds),O=function(t){const e=t.filter((t=>t!==1/0)),n=e.reduce(((t,e)=>Math.min(t,e)),Number.MAX_VALUE),i=e.reduce(((t,e)=>Math.max(t,e)),n);return{max:i,min:n}}(E.saliVals),P=.8/(O.max-O.min),G=o.shell.getTableView(t.name),k=G.addViewer(a.VIEWER.SCATTER_PLOT,{xColumnName:n[0],yColumnName:n[1],size:N.name,color:s.name,showXSelector:!1,showYSelector:!1,showSizeSelector:!1,showColorSelector:!1,markerMinSize:5,markerMaxSize:25,title:i}),W=function(t,e,n,i,s,o,r,l){const c={from:new Uint32Array(e.n1.length),to:new Uint32Array(e.n1.length),opacities:new Float32Array(e.n1.length),colors:new Array(e.n1.length),widths:new Float32Array(e.n1.length)};for(let n=0;n<e.n1.length;n++)c.from[n]=e.n1[n],c.to[n]=e.n2[n],c.opacities[n]=e.saliVals[n]===1/0?1:.2+(e.saliVals[n]-r.min)*l,c.colors[n]=t.selection.get(c.from[n])&&t.selection.get(c.to[n])?"255,255,0":"0,128,0",c.widths[n]=1;const h=a.DataFrame.create(c.from.length);return j.forEach(((t,e)=>{h.columns.addNewString(t).init((t=>n.get(0===e?c.from[t]:c.to[t]))),function(t,e){Object.keys(e).forEach((n=>{t.tags[n]=e[n]}))}(h.col(t),o),h.col(t).semType=s})),h.columns.addNewFloat(K).init((t=>Math.abs(i.get(c.from[t])-i.get(c.to[t])))),h.columns.addNewInt(z).init((t=>t)),h.columns.addNewFloat(X).init((t=>e.saliVals[t])),h.columns.addNewFloat(q).init((t=>e.simVals[t])),h.name=`${Y}${Z}`,{lines:c,linesDf:h}}(t,E,e,s,d,m,O,P),D=new H(k,n[0],n[1],W.lines,B.none),V=C?C(W.linesDf,j).sort([X],[!1]):W.linesDf.plot.grid().sort([X],[!1]);t.temp[".cliffsDfGrid"]=V;const Q=r.button(`${W.linesDf.rowCount} cliffs`,(()=>{G.dockManager.dock(V,"down",null,"Activity cliffs",w??.2)}));Q.classList.add("scatter_plot_link","cliffs_grid"),k.root.append(Q);const tt=r.switchInput("Show only cliffs",!1,(()=>{tt.value?(k.dataFrame.setTag(J,n[0]),t.filter.and(_),$.next(n[0])):(k.dataFrame.setTag(J,""),t.filter.setAll(!0),$.next(""))}));tt.root.classList.add("scatter_plot_link","show_only_cliffs"),k.root.append(tt.root),$.subscribe((t=>{tt.enabled=""===t||t===n[0]}));let et=!1;k.onEvent("d4-before-draw-scene").subscribe((e=>{et?et=!1:tt.value&&(setTimeout((()=>{t.filter.and(_)}),100),et=!0)}));const nt=o.events.onViewerClosed.subscribe((t=>{t.args.viewer===k&&(G.dockManager.close(V.root),nt.unsubscribe(),G.subs=G.subs.filter((t=>t!==nt)))}));return G.subs.push(nt),W.linesDf.onCurrentCellChanged.subscribe((()=>{for(let t=0;t<W.linesDf.rowCount;t++)W.lines.widths[t]=t===W.linesDf.currentRowIdx?3:1;D.linesToRender=W.lines;const i=W.linesDf.currentCol&&W.linesDf.currentCol.name===j[1]?W.lines.to:W.lines.from,a=-1!==W.linesDf.currentRowIdx?W.linesDf.currentRowIdx:null;if(k.dataFrame.currentRowIdx=a?i[a]:-1,null!==a){const i=W.linesDf.currentRowIdx;D.currentLineId=i;const{zoomLeft:l,zoomRight:c,zoomTop:h,zoomBottom:u}=function(t,e,n,i,s,o){const r=Math.abs(n-s),a=Math.abs(i-o),l=t/r,c=e/a,h=Math.min(l,c),u=t/h*5,d=e/h*5,m=(n<s?n:s)+r/2-u/2,p=(i>o?i:o)-a/2+d/2;return{zoomLeft:m,zoomRight:m+u,zoomTop:p,zoomBottom:p-d}}(k.viewport.width,k.viewport.height,k.dataFrame.get(n[0],W.lines.from[i]),k.dataFrame.get(n[1],W.lines.from[i]),k.dataFrame.get(n[0],W.lines.to[i]),k.dataFrame.get(n[1],W.lines.to[i]));k.zoom(l,h,c,u),tt.value?t.filter.and(_):!0===tt.enabled&&t.filter.setAll(!0),setTimeout((()=>{!function(t,e,n,i,s,a,l,c,h){const u=e.getPane("Cliff Details");r.empty(u.root);const d=h({points:[n,i],lineId:s,df:t,seqCol:a,activityCol:l,sali:c});u.root.append(d),setTimeout((()=>{o.shell.o=e.root}),500)}(t,S,W.lines.from[a],W.lines.to[a],a,e,s,W.linesDf.get(X,a),b);const n=k.dataFrame.getSortedOrder(G.grid.sortByColumns,G.grid.sortTypes);G.grid.scrollToCell(e.name,n.indexOf(k.dataFrame.currentRowIdx))}),1e3)}})),W.linesDf.onSelectionChanged.subscribe((e=>{setTimeout((()=>(()=>{const e=a.BitSet.create(t.rowCount);for(let t=0;t<W.linesDf.rowCount;t++){const n=W.linesDf.selection.get(t);n&&(e.set(W.lines.from[t],!0),e.set(W.lines.to[t],!0)),W.lines.colors[t]=n?"255,255,0":"0,128,0"}t.selection.copyFrom(e),D.linesToRender=W.lines})()),100)})),t.onSelectionChanged.subscribe((e=>{!1===t.selection.anyTrue&&"number"==typeof e&&(A?A=!1:(t=>{t.selection.setAll(!1);for(let t=0;t<W.lines.colors.length;t++)W.lines.colors[t]="0,128,0";D.linesToRender=W.lines})(V.dataFrame))})),D.lineClicked.subscribe((e=>{if(A=!0,D.currentLineId=e.id,-1!==e.id){const n=W.linesDf.selection.clone();setTimeout((()=>{e.event.ctrlKey?(n.set(e.id,!n.get(e.id)),W.linesDf.selection.copyFrom(n)):(W.linesDf.currentRowIdx!==e.id&&(W.linesDf.currentRowIdx=e.id,t.currentRowIdx=W.lines.from[e.id]),W.linesDf.selection.copyFrom(n));const i=W.linesDf.getSortedOrder(V.sortByColumns,V.sortTypes);V.scrollToCell(j[0],i.indexOf(e.id))}),500)}})),D.lineHover.pipe((0,p.debounceTime)(500)).subscribe((n=>{-1!==n.id&&-1===t.mouseOverRowIdx&&r.tooltip.show(y({lineId:n.id,points:[W.lines.from[n.id],W.lines.to[n.id]],df:t,seqCol:e,activityCol:s}),n.x,n.y)})),k.addProperty("similarityLimit","double",v),S=function(){const t=r.accordion(),e=r.element("i");return e.className="grok-icon svg-icon svg-view-layout",t.addTitle(r.span([e,r.label("Activity cliffs")])),t.addPane("Cliff Details",(()=>r.divText("Cliff has not been selected")),!0),o.shell.o=t.root,t}(),k}(t,b,m,"Activity cliffs",n,i,y,s,{...d??{}},a.SEMTYPE.MACROMOLECULE,f,u,$t,Kt,jt),w=s===c.A.UMAP?2e5:2e4,v=s===c.A.UMAP?5e3:2e3;if(t.rowCount>w)return void o.shell.warning(`Too many rows, maximum for sequence activity cliffs is ${w}`);const S=a.TaskBarProgressIndicator.create("Running sequence activity cliffs ...");return new Promise(((e,n)=>{t.rowCount>v&&!d?.[l.sS]?r.dialog().add(r.divText("Activity cliffs analysis might take several minutes.\n Do you want to continue?")).onOK((async()=>{C().then((t=>e(t))).catch((t=>n(t)))})).onCancel((()=>{e(void 0)})).show():C().then((t=>e(t))).catch((t=>n(t)))})).catch((t=>{const[e,n]=(0,rt.yf)(t);throw fn.logger.error(e,void 0,n),t})).finally((()=>{S.close()}))}async function Hn(t,e,n=1,i=.6,s="Morgan"){if(t.semType!==a.SEMTYPE.MACROMOLECULE)return{entries:t.toList(),options:{}};const{seqList:o,options:r}=await Zt(t,e,s);return{entries:o,options:{...r,gapOpen:n,gapExtend:i}}}async function Dn(t,e){t.version!==t.temp["last-invalidated-version"]&&await(0,Yt.HV)(t,!1);const n=t.temp["monomeric-mols"],i=await o.functions.call("Chem:getMorganFingerprints",{molColumn:n}),s=new Array(i.length).fill(null);for(let t=0;t<i.length;t++){if(i.isNone(t)||!i.get(t))continue;const e=i.get(t);s[t]=W.Z.fromUint32Array(e.length,new Uint32Array(e.getBuffer().buffer))}return{entries:s,options:{}}}async function Vn(t,e,i,s,c,h,u,d){if((0,Te.n)(e,"Sequence Space"))return h||(h=a.Func.find({name:"macromoleculePreprocessingFunction",package:"Bio"})[0]),u??(u={}),await async function(t,e,i,s,c,h,u,d=!0,m=!1,p={preprocessingFuncArgs:[]},g={}){const f={showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1};if(e.length!==s.length||e.length!==h.length||e.length!==c.length||e.length!==p.preprocessingFuncArgs.length)throw new Error("columns, metrics and preprocessing functions, weights and function argumentsmust have the same length");const y=async()=>{const y=a.TaskBarProgressIndicator.create(`Initializing ${g.scatterPlotName??"dimensionality reduction"} ...`);let b;try{const C=gn(t);function w(e,n,i){let s=null,c=null;t.columns.names().includes(C[0])?(s=t.columns.byName(C[0]),c=t.columns.byName(C[1])):(s=t.columns.add(a.Column.float(C[0],t.rowCount)),c=t.columns.add(a.Column.float(C[1],t.rowCount)),d&&!b&&(b=o.shell.tableView(t.name).scatterPlot({...f,x:C[0],y:C[1],title:g.scatterPlotName??"Embedding space"}))),g[l.Ec]&&(b?.root&&r.setUpdateIndicator(b.root,!1),s.init((t=>i[0]?i[0][t]:void 0)),c.init((t=>i[1]?i[1][t]:void 0)));const h=e/n*100;y.update(h,`Running ${g.scatterPlotName??"dimensionality reduction"}... ${h.toFixed(0)}%`)}async function v(){t.columns.add(a.Column.float(C[0],t.rowCount)),t.columns.add(a.Column.float(C[1],t.rowCount));let n=null;d&&(b=o.shell.tableView(t.name).scatterPlot({...f,x:C[0],y:C[1],title:g.scatterPlotName??"Embedding space"}),r.setUpdateIndicator(b.root,!0));const m=o.events.onViewerClosed.subscribe((t=>{const e=t.args.viewer;e?.getOptions()?.look?.title&&b?.getOptions()?.look?.title&&e?.getOptions()?.look?.title===b?.getOptions()?.look?.title&&(o.events.fireCustomEvent(D,{}),m.unsubscribe(),n?.(),y.close())})),v=new Promise((async(t,o)=>{try{n=t;const o=[];for(let t=0;t<h.length;++t){const n=h[t];if(p.distanceFnArgs||(p.distanceFnArgs=[]),n){const i=n.inputs[0].name,r=n.inputs[1].name,{entries:a,options:l}=await n.apply({[i]:e[t],[r]:s[t],...p.preprocessingFuncArgs[t]??{}});o.push({entries:a,options:l}),p.distanceFnArgs.push(l)}else{const n=e[t].toList(),i={};o.push({entries:n,options:i}),p.distanceFnArgs.push(i)}}t(await U(o.map((t=>t.entries)),i,s,c,u,p,g[l.sS]?void 0:w))}catch(t){o(t)}})),S=await v;return y.close(),m.unsubscribe(),S}const S=await v();if(m&&S){const A=a.TaskBarProgressIndicator.create("Clustering embeddings ...");try{const x=await function(t,e,i,s){return ye(this,void 0,void 0,(function*(){return new Promise((function(o,r){const a=new Worker(new URL(n.p+n.u(796),n.b));a.postMessage({embedX:t,embedY:e,minPts:s,epsilon:i}),a.onmessage=({data:{error:t,clusters:e}})=>{a.terminate(),t?r(t):o(e)}}))}))}(S[0],S[1],p.dbScanEpsilon??.01,p.dbScanMinPts??4),T=t.columns.getUnusedName("Cluster");t.columns.addNewString(T).init((t=>x[t].toString())),b&&(b.props.colorColumnName=T)}catch(I){o.shell.error("Clustering embeddings failed"),console.error(I)}finally{A.close()}}if(S&&d&&b){r.setUpdateIndicator(b.root,!1);const M=t.columns.byName(C[0]),L=t.columns.byName(C[1]);return M.init((t=>S[0][t])),L.init((t=>S[1][t])),b}}catch(E){o.shell.error("Dimensionality reduction failed"),console.error(E),y.close(),b&&r.setUpdateIndicator(b.root,!1)}};return new Promise((async(e,n)=>{try{if(g.fastRowCount&&t.rowCount>g.fastRowCount&&!g[l.sS])r.dialog().add(r.divText("Analysis might take several minutes. Do you want to continue?")).onOK((async()=>{try{const t=await y();e(t)}catch(t){n(t)}})).onCancel((()=>e(void 0))).show();else{const t=await y();e(t)}}catch(t){n(t)}}))}(t,[e],i,[s],[1],[h],"MANHATTAN",c,d??!1,{...u,preprocessingFuncArgs:[u.preprocessingFuncArgs??{}]},{fastRowCount:1e4,scatterPlotName:"Sequence space",bypassLargeDataWarning:u?.[l.sS]})}async function Un(t,e,n){const i=a.TaskBarProgressIndicator.create("Converting to atomic level ...");try{await async function(t,e,n){if(0===a.Func.find({package:"Chem",name:"getRdKitModule"}).length)return void o.shell.warning('Transformation to atomic level requires package "Chem" installed.');if(n){const n=tt.Cn.getOrCreate(e);return n.isHelm()||(e=n.convert(Ct.r2.HELM)),void async function(t,e){const n=await Ve(t,e);t.columns.add(n,!0),await o.data.detectSemanticTypes(t)}(t,e)}if(!(0,Te.n)(e,"To Atomic Level"))return;const i=yn().getBioLib(),s=await(0,mn.i0)(t,e,i);null!==s.col&&(t.columns.add(s.col,!0),await o.data.detectSemanticTypes(t)),s.warnings&&s.warnings.length>0&&o.shell.warning(r.list(s.warnings))}(t,e,n)}finally{i.close()}}function Zn(){(0,Ie.K)()}async function Yn(t=null,e=null){return(0,Ie.K)({col:t,clustersCol:e})}async function $n(){const t=o.shell.tv,e=t.dataFrame.columns.toList().filter((t=>t.semType==a.SEMTYPE.MACROMOLECULE&&(tt.Cn.getOrCreate(t),!0))),n=async e=>{if(!(0,Te.n)(e,"Composition"))return;const n=t.addViewer("WebLogo",{sequenceColumnName:e.name});o.shell.tv.dockManager.dock(n,a.DOCK_TYPE.DOWN,null,"Composition analysis",.25)};let i=null;if(0!=e.length){if(e.length>1){const t=e.map((t=>t.name)),i=e.find((t=>tt.Cn.getOrCreate(t).isMsa())),s=r.choiceInput("Column",i?i.name:t[0],t);r.dialog({title:"Composition Analysis",helpUrl:"https://datagrok.ai/help/datagrok/solutions/domains/bio/#sequence-composition"}).add(r.div([s])).onOK((async()=>{const t=e.find((t=>t.name==s.value))??null;t&&await n(t)})).show()}else i=e[0];i&&await n(i)}else o.shell.error("Current table does not contain sequences")}function Kn(t){return new et.i(t).importFasta()}function Xn(t){return console.log(t),[]}function qn(){const t=(0,at.B)()[0];(0,oe.O)(t)}function zn(){let t;try{t=function(){function t(t){return t===h[0]?[We.M].concat(d.getMonomerSymbolsByType("PEPTIDE")):t===h[1]?[We.M].concat(d.getMonomerSymbolsByRGroup(3,"PEPTIDE")):["C"]}function e(){"N-Cys"===u.value?(m=t("N-O"),p=t("N-Cys")):(m=t(u.value),p=[...m]),g=r.choiceInput("R1:",m[0],m,(()=>{i.next()})),y=r.choiceInput("R2:",p[0],p,(()=>{i.next()})),i.next(),r.empty(b),[g,y].forEach((t=>{b.appendChild(t.root)}))}const n=new f.Subject,i=new f.Subject;n.subscribe((()=>{s.cyclizationType=u.value,e()})),i.subscribe((()=>{s.rightTerminal=y.value,s.leftTerminal=g.value}));const s={},l=["Cyclization"],c=r.choiceInput("Modification",l[0],l,(()=>s.transformationType=c.value)),h=["N-O","R3-R3","N-Cys"],u=r.choiceInput("Type",h[2],h,(()=>{n.next()})),d=le.NT.instance.getBioLib();let m=[],p=[],g=r.choiceInput("R1:",m[0],m,(()=>{s.leftTerminal=g.value})),y=r.choiceInput("R2:",p[0],p,(()=>{s.rightTerminal=y.value}));const b=r.divV([g.root,y.root]);e(),s.cyclizationType=u.value,s.leftTerminal=g.value,s.rightTerminal=y.value,s.transformationType=c.value;const C=o.shell.t.columns.bySemTypeAll(a.SEMTYPE.MACROMOLECULE);if(!C)throw new Error("No dataframe with maceomolecule columns open");const w=r.columnInput("Column",o.shell.t,C[0],null,{filter:t=>t.semType===a.SEMTYPE.MACROMOLECULE}),v=r.boolInput("Get HELM",!0);r.tooltip.bind(v.root,"Add HELM column");const S=r.div([w,c,u,b,v]);return r.dialog("Poly Tool").add(S).onOK((async()=>{const t=w.value;t?ln(t,s,v.value):o.shell.warning("No marcomolecule column chosen!")}))}(),t.show()}catch(t){o.shell.warning("To run PolyTool, open a dataframe with macromolecules")}}function jn(){return new Pe}async function Jn(t){const e=a.TaskBarProgressIndicator.create("Test detectMacromolecule..."),n=(await o.dapi.files.list(t,!0,"")).filter((t=>t.fileName.endsWith(".csv")));let i=0;const s=[];for(const r of n)try{const e=await o.dapi.files.readAsText(t+r.fullPath),n=a.DataFrame.fromCsv(e);for(const t of n.columns)await o.functions.call("Bio:detectMacromolecule",{col:t})===a.SEMTYPE.MACROMOLECULE&&s.push({file:r.path,result:"detected",column:t.name,message:`units: ${t.getTag(a.TAGS.UNITS)}`})}catch(t){s.push({file:r.path,result:"error",column:null,message:t instanceof Error?t.message:t.toString()})}finally{i+=1,e.update(100*i/n.length,`Test ${r.fileName}`)}o.shell.info("Test Demo:Files for detectMacromolecule finished."),e.close();const r=a.DataFrame.fromObjects(s);return r.name=`datasets_detectMacromolecule_${t}`,r}async function Qn(t,e){await(0,Ee.n)(t,e)}function ti(t){const e=tt.Cn.getOrCreate(t).stats;return Object.keys(e.freq)}function ei(){return new ee}function ni(){const t=o.shell.v,e=t.addViewer("Sequence Similarity Search");t.dockManager.dock(e,"down")}function ii(){return new ie}function si(){const t=o.shell.v,e=t.addViewer("Sequence Diversity Search");t.dockManager.dock(e,"down")}function oi(t){const e=(0,at.B)();1===e.length?t.func.prepare({macromolecules:e[0]}).call(!0):new Yt.uH(e)}function ri(t){o.shell.tv.getFiltersGroup({createDefaultFilters:!1}).updateOrAdd({type:"Bio:bioSubstructureFilter",column:t.name,columnName:t.name}),o.shell.tv.grid.scrollToCell(t,0)}async function ai(t,e,n){return ot(t,e,n,Q.IDENTITY)}async function li(t,e,n){return ot(t,e,n,Q.SIMILARITY)}function ci(){(0,re.C2)()}function hi(){return new ae.ST}async function ui(){const t=a.TaskBarProgressIndicator.create("WebLogo");try{const t=new URLSearchParams(window.location.search),e=new Me(t,"webLogoLargeApp"),n=await fn.files.readCsv("data/sample_PT_100000x5.csv");await o.data.detectSemanticTypes(n),await e.init(n)}finally{t.close()}}async function di(){const t=a.TaskBarProgressIndicator.create("WebLogo ...");try{const t=new URLSearchParams(window.location.search),e=new Me(t,"webLogoAggApp"),n=await fn.files.readCsv("data/sample_FASTA_PT_activity.csv");await o.data.detectSemanticTypes(n),await e.init(n)}finally{t.close()}}async function mi(){const t=a.TaskBarProgressIndicator.create("getRegion ...");try{const t=new URLSearchParams(window.location.search),e=new un(t,"getRegionApp");await e.init()}finally{t.close()}}async function pi(){const t=a.TaskBarProgressIndicator.create("getRegion ...");try{const t=new URLSearchParams(window.location.search),e=await fn.files.readCsv("data/sample_HELM_empty_vals.csv"),n=new un(t,"getRegionHelmApp");await n.init({df:e,colName:"HELM"})}finally{t.close()}}function gi(t,e){!function(t,e){const n=tt.Cn.getOrCreate(t.column),i=Object.values(Ct.r2).filter((t=>t!==n.units));e.group("Copy").items(i,(e=>{const n=tt.Cn.getOrCreate(t.column),i=e===Ct.r2.SEPARATOR?fn.properties.DefaultSeparator:void 0,s=n.getConverter(e,i)(t.value);navigator.clipboard?(navigator.clipboard.writeText(s),o.shell.info(`Value of notation '${e}' copied to clipboard`)):o.shell.warning("The clipboard functionality requires a secure origin — either HTTPS or localhost")}))}(t,e)}async function fi(){await async function(){let t,e;try{const n=new he("Similarity, Diversity","Sequence similarity tracking and evaluation dataset diversity");await n.step("Load DNA sequences",(async()=>{o.shell.windows.showContextPanel=!1,o.shell.windows.showProperties=!1,e=await fn.files.readCsv(de),t=o.shell.addTableView(e),t.grid.columns.byName("cluster").visible=!1,t.grid.columns.byName("sequence_id").visible=!1,t.grid.columns.byName("sequence").width=300,t.grid.columns.byName("activity").visible=!1,t.grid.columns.byName("is_cliff").visible=!1}),{description:"Load dataset with macromolecules of 'fasta' notation, 'DNA' alphabet.",delay:2e3}).step("Find the most similar sequences to the current one",(async()=>{const n=await e.plot.fromType("Sequence Similarity Search",{moleculeColumnName:"sequence",similarColumnLabel:"Similar to current"});t.dockManager.dock(n,a.DOCK_TYPE.RIGHT,null,"Similarity search",.35)}),{description:"Add 'Sequence Similarity Search' viewer.",delay:2e3}).step("Explore most diverse sequences in a dataset",(async()=>{const n=await e.plot.fromType("Sequence Diversity Search",{moleculeColumnName:"sequence",diverseColumnLabel:"Top diverse sequences of all data"});t.dockManager.dock(n,a.DOCK_TYPE.DOWN,null,"Diversity search",.27)}),{description:"Add 'Sequence Deversity Search' viewer.",delay:2e3}).step("Choose another sequence for similarity search",(async()=>{e.currentRowIdx=3}),{description:"Handling current row changed of data frame showing update of similar sequences.",delay:2e3}).step("One more sequence for similarity search",(async()=>{e.currentRowIdx=7}),{description:"Just one more sequence to search similar ones.",delay:2e3}).start()}catch(t){ue(t)}}()}async function yi(){await async function(){let t,e,n,i,s;try{const r=new he("Sequence Space","Exploring sequence space of Macromolecules, comparison with hierarchical clustering results");await r.step("Load DNA sequences",(async()=>{[i,t,e]=await Promise.all([fn.files.readCsv(be),me(),pe()]),n=o.shell.addTableView(i),n.grid.props.rowHeight=22,n.grid.columns.byName("cluster").visible=!1,n.grid.columns.byName("sequence").width=200,n.grid.columns.byName("is_cliff").visible=!1,o.shell.windows.showContextPanel=!1,o.shell.windows.showProperties=!1}),{description:"Load dataset with macromolecules of 'fasta' notation, 'DNA' alphabet.",delay:2e3}).step("Build sequence space",(async()=>{s=await async function(t,e,n,i){let s;{const t=Object.values(se);for(let n=0;n<t.length;n++){const i=t[n];if(!e.col(i)){const s=n==t.length-1;e.columns.add(a.Column.float(i,e.rowCount),s)}}if(e.rowCount>=1){const i=e.getCol(n).toList(),s=Date.now();fn.logger.debug("Bio: demoBio01aUI(), calc reduceDimensionality start...");const o=await U([i],"UMAP",[k.W.Levenshtein],[1],"MANHATTAN",{distanceFnArgs:[{}]}),r=Date.now();fn.logger.debug(`Bio: demoBio01aUI(), calc reduceDimensionality ET: ${(r-s)/1e3} s`);for(let n=0;n<t.length;n++){const i=t[n],s=e.getCol(i),r=o[n];s.init((t=>r[t]))}const a=Date.now();fn.logger.debug(`MLB: MlbVrSpaceBrowser.buildView(), postprocess reduceDimensionality ET: ${(a-r)/1e3} s`)}s=await e.plot.fromType(a.VIEWER.SCATTER_PLOT,{xColumnName:se.X,yColumnName:se.Y,lassoTool:!0})}return t.dockManager.dock(s,a.DOCK_TYPE.RIGHT,null,"Sequence Space",.35),s}(n,i,Ce),s.setOptions({color:"activity"})}),{description:"Reduce sequence space dimensionality to display on 2D representation.",delay:2e3}).step("Cluster sequences",(async()=>{const s=await t.calcDistanceMatrix(i,[Ce]),o=await fe(s.data,i.rowCount,1),r=t.parseClusterMatrix(o);e.injectTreeForGrid(n.grid,r,void 0,150,void 0)}),{description:"Perform hierarchical clustering to reveal relationships between sequences.",delay:2e3}).step("Select a sequence",(async()=>{i.selection.set(65,!0)}),{description:"Handling selection of data frame row reflecting on linked viewers.",delay:2e3}).step("Select a bunch of sequences",(async()=>{[67,72,77,82,83,84,85,91,93].forEach((t=>i.selection.set(t,!0))),i.currentRowIdx=27}),{description:"Selecting a group of rows from a data frame to show their similarity and proximity to each other on a viewer..",delay:2e3}).start()}catch(t){ue(t)}}()}async function bi(){await async function(){let t,e,n,i,s;const r=c.A.UMAP;try{const l=new he("Activity Cliffs","Activity Cliffs analysis on Macromolecules data");await l.step("Load DNA sequences",(async()=>{o.shell.windows.showContextPanel=!1,o.shell.windows.showProperties=!1,[n,t,e]=await Promise.all([fn.files.readCsv(Se),me(),pe()]),i=o.shell.addTableView(n),i.grid.props.rowHeight=22,i.grid.columns.byName("cluster").visible=!1,i.grid.columns.byName("sequence").width=300,i.grid.columns.byName("is_cliff").visible=!1}),{description:"Load dataset with macromolecules of 'fasta' notation, 'DNA' alphabet.",delay:2e3}).step("Find activity cliffs",(async()=>{const t=a.Func.find({name:"macromoleculePreprocessingFunction",package:"Bio"})[0];s=await Wn(n,n.getCol("Sequence"),n.getCol("Activity"),80,r,Ut.U.LEVENSHTEIN,t,{}),i.dockManager.dock(s,a.DOCK_TYPE.RIGHT,null,"Activity Cliffs",.35),ve()(s.root).find("button.scatter_plot_link,cliffs_grid").get()[0].click()}),{description:"Reveal similar sequences with a cliff of activity.",delay:2e3}).step("Cluster sequences",(async()=>{const s=a.TaskBarProgressIndicator.create("Running sequence clustering..."),o=await t.calcDistanceMatrix(n,["sequence"]),r=await fe(o.data,n.rowCount,1),l=t.parseClusterMatrix(r);s.close(),e.injectTreeForGrid(i.grid,l,void 0,150,void 0),i.grid.columns.byName("Activity").scrollIntoView()}),{description:"Perform hierarchical clustering to reveal relationships between sequences.",delay:2e3}).step("Browse the cliff",(async()=>{const t=s.dataFrame.temp[".cliffsDfGrid"];t.dataFrame.rowCount>0&&(t.dataFrame.currentRowIdx=0)}),{description:"Zoom in to explore selected activity cliff details.",delay:2e3}).start()}catch(t){ue(t)}}()}async function Ci(){await async function(){const t="HELM";let e,n,i;try{await new he("Atomic Level","Atomic level structure of Macromolecules").step("Loading Macromolecules notation 'Helm'",(async()=>{o.shell.windows.showContextPanel=!1,o.shell.windows.showProperties=!1,e=await fn.files.readCsv("samples/HELM.csv"),n=o.shell.addTableView(e);for(let e=0;e<n.grid.columns.length;e++){const i=n.grid.columns.byIndex(e);[t,"Activity"].includes(i.name)||(i.visible=!1)}}),{description:"Load dataset with macromolecules of 'fasta' notation, 'PT' alphabet (protein, aminoacids).",delay:2e3}).step("To atomic level",(async()=>{const n=e.getCol(t);await Un(e,n,!1)}),{description:"Get atomic level structures of Macromolecules.",delay:2e3}).step("Sketcher",(async()=>{const n=`molfile(${t})`;e.currentCell=e.cell(1,n);const s=e.currentCell.value,o=new a.chem.Sketcher(a.chem.SKETCHER_MODE.INPLACE);o.setMolFile(s),i=r.dialog().add(o).show(),await(0,_t.gw)(3e3),i.close()}),{description:"Display atomic level structure within a sketcher.",delay:2e3}).start()}catch(t){ue(t)}}()}async function wi(){await async function(){let t,e,n,i,s,r;const l="msa(HELM)",h=c.A.UMAP,u=(await Ae.lp.getDockerContainer()).id,d=Ae.lp.getDockerContainer();let m,p;try{const c=new he("Helm, MSA, Sequence Space","MSA and composition analysis on Helm data");await c.step("Load peptides with non-natural aminoacids in 'HELM' notation",(async()=>{[m,e]=await Promise.all([(async()=>(await d).status)(),fn.files.readCsv(xe)]),t=o.shell.addTableView(e),o.shell.windows.showContextPanel=!1,o.shell.windows.showProperties=!1,"started"===m||"checking"===m?(fn.logger.debug(`demoBio05UI(), PepSeA ('${Ae.lp.dcName}') docker container status = '${m}'.`),p=Promise.resolve()):(fn.logger.warning(`demoBio05UI(), PepSeA ('${Ae.lp.dcName}') docker container is trying to start...`),await o.dapi.docker.dockerContainers.run(u),p=async function(t,e,n=3e4,i){const s=window.performance.now(),r=new f.Subject,a=async()=>{const n=await o.dapi.docker.dockerContainers.find(t);return n.status===e&&r.next(n),n};let l;try{await(0,_t.zg)(r,(t=>{const n=window.performance.now();i.debug(`awaitStatus(), docker container ('${t.name}') GET status = '${e}' in ${n-s} ms.`)}),(async()=>{const t=await a();i.debug(`awaitStatus(), docker container ('${t.name}') HAS status = '${t.status}'.`),l=window.setInterval(a,200)}),n)}finally{window.clearInterval(l)}}(u,"started",3e4,fn.logger))}),{description:"Load dataset with macromolecules of 'Helm' notation.",delay:2e3}).step("Align peptides with non-natural aminoacids with PepSeA",(async()=>{const t=a.TaskBarProgressIndicator.create("MSA by PepSeA ...");try{await p,n=e.getCol("HELM");const t=Ae.Jy[0],s=1.53,r=0;if(i=await(0,Ae.f3)(n,l,t,s,r,void 0),!i)throw new Error("Empty MSA result.");e.columns.add(i),await o.data.detectSemanticTypes(e)}finally{t.close()}}),{description:"Multiple sequence alignment (MSA) performed with PepSeA tool operating on non-natural aminoacids as well.",delay:2e3}).step("Build sequence space",(async()=>{const n=a.Func.find({package:"Bio",name:"macromoleculePreprocessingFunction"})[0];r=await Vn(e,i,h,Ut.U.LEVENSHTEIN,!0,n),t.dockManager.dock(r,a.DOCK_TYPE.RIGHT,null,"Sequence Space",.35)}),{description:"Reduce sequence space dimensionality to display on 2D representation.",delay:2e3}).step("Analyse sequence composition",(async()=>{s=await e.plot.fromType("WebLogo",{sequenceColumnName:l,positionWidth:40,maxHeight:50}),t.dockManager.dock(s,a.DOCK_TYPE.DOWN,null,"Composition analysis",.2)}),{description:"Composition analysis allows to reveal functional features of sequences like motifs, or variable loops.",delay:2e3}).start()}catch(t){ue(t)}}()}async function vi(t,e){var n;He(n=e),n.setTag("units",Ct.r2.SEPARATOR),n.setTag("separator","-"),await o.data.detectSemanticTypes(t)}async function Si(t){const e=(0,nt.Xk)(t),n=JSON.stringify(e);a.Utils.download(`${t.name}.json`,n)}async function Ai(t,e,n){const i=await t.readAsString();await async function(t,e,n){const i=a.TaskBarProgressIndicator.create("detectMacromolecule probe ...");try{let s=0;const r=await o.functions.call("Bio:detectMacromoleculeEnableStore");let l=0;for(let c=0;c<n;++c){const h=a.DataFrame.fromCsv(t),u=e?h.getCol(e):h.columns.byIndex(0);await o.functions.call("Bio:detectMacromolecule",{col:u})!==a.SEMTYPE.MACROMOLECULE&&(++l,console.warn(`Reject reason: ${r.last.rejectReason}`));const d=c/n;d-s>=.1&&(s=d,i.update(100*d,`detectMacromolecule probe ${l}/${c}/${n} ...`),await(0,_t.gw)(0))}l>0?o.shell.warning(`detectMacromolecule failed ${l} / ${n}`):o.shell.info(`detectMacromolecule success ${n}`)}finally{i.close()}}(i,e,n)}},9017:(t,e,n)=>{"use strict";n.d(e,{k:()=>o});class i{constructor(){this.value=0,this.parentI=0,this.parentJ=0}}class s{constructor(t,e,n){this.seq1=t,this.seq2=e,this.score=n}}class o{fillNeedleman(){for(let t=0;t<=this.len1;t++)this.dpGrid[t][0].value=-t*this.gap,this.dpGrid[t][0].parentI=t-1,this.dpGrid[t][0].parentJ=0;for(let t=1;t<=this.len2;t++)this.dpGrid[0][t].value=-t*this.gap,this.dpGrid[0][t].parentI=0,this.dpGrid[0][t].parentJ=t-1}fillOne(t,e){this.dpGrid[t][e].value=Math.max(this.dpGrid[t-1][e-1].value+this.scores[t-1][e-1],Math.max(this.dpGrid[t-1][e].value-this.gap,this.dpGrid[t][e-1].value-this.gap)),this.dpGrid[t][e].value==this.dpGrid[t-1][e-1].value+this.scores[t-1][e-1]?(this.dpGrid[t][e].parentI=t-1,this.dpGrid[t][e].parentJ=e-1):this.dpGrid[t][e].value==this.dpGrid[t-1][e].value-this.gap?(this.dpGrid[t][e].parentI=t-1,this.dpGrid[t][e].parentJ=e):(this.dpGrid[t][e].parentI=t,this.dpGrid[t][e].parentJ=e-1)}gridFromName(t){switch(t){case"BLOSUM45":this.alignGrid=this.BLOSUM45,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM50":this.alignGrid=this.BLOSUM50,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM62":this.alignGrid=this.BLOSUM62,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM80":this.alignGrid=this.BLOSUM80,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM90":this.alignGrid=this.BLOSUM90,this.connections=this.CONBLO,this.step=1;break;case"PAM30":this.alignGrid=this.PAM30,this.connections=this.CONBLO,this.step=1;break;case"PAM70":this.alignGrid=this.PAM70,this.connections=this.CONBLO,this.step=1;break;case"PAM250":this.alignGrid=this.PAM250,this.connections=this.CONBLO,this.step=1;break;case"NUCLEOTIDES":this.alignGrid=this.NUCLEOTIDES,this.connections=this.CONNUCL,this.step=1;break;case"TRANS":this.alignGrid=this.TRANS,this.connections=this.CONNUCL,this.step=1;break;case"SCHNEIDER":this.alignGrid=this.SCHNEIDER,this.connections=this.CONSCHN,this.step=3}this.fillScores()}constructResult(t,e){let n="",i="",o="";const r=this.dpGrid[t][e].value;for(let t=0;t<this.step;t++)o+="|";for(;t>0||e>0;){this.dpGrid[t][e].parentI==t?(n=o+n,i=this.seq2.substr((e-1)*this.step,this.step)+i):this.dpGrid[t][e].parentJ==e?(i=o+i,n=this.seq1.substr((t-1)*this.step,this.step)+n):(n=t-1>=0?this.seq1.substr((t-1)*this.step,this.step)+n:o+n,i=e-1>=0?this.seq2.substr((e-1)*this.step,this.step)+i:o+i);const s=t;t=this.dpGrid[t][e].parentI,e=this.dpGrid[s][e].parentJ}return new s(n,i,r)}fillScores(){this.scores=[];for(let t=0;t<this.len1;t++){this.scores.push([]);for(let e=0;e<this.len2;e++)this.scores[t].push(this.alignGrid[this.connections[this.seq1.substr(t*this.step,this.step)]][this.connections[this.seq2.substr(e*this.step,this.step)]])}}typeRec(){if(/[ATGC]*/.test(this.seq1)&&/[ATGC]*/.test(this.seq2))return"NUCLEOTIDES";if(/[ARNDCQEGHILKMFPSTWYVBZX*]*/.test(this.seq1)&&/[ARNDCQEGHILKMFPSTWYVBZX*]*/.test(this.seq2))return"BLOSUM62";throw Error("Can't recognize sequence type")}needlemanWunch(){this.dpGrid=[];for(let t=0;t<this.len1+1;t++){const t=[];for(let e=0;e<this.len2+1;e++)t.push(new i);this.dpGrid.push(t)}this.fillNeedleman();for(let t=1;t<=this.len1;t++)for(let e=1;e<=this.len2;e++)this.fillOne(t,e);return this.constructResult(this.len1,this.len2)}smithWaterman(){this.dpGrid=[];for(let t=0;t<this.len1+1;t++){const t=[];for(let e=0;e<this.len2+1;e++)t.push(new i);this.dpGrid.push(t)}let t=0,e=0,n=0;for(let i=1;i<=this.len1;i++)for(let s=1;s<=this.len2;s++)this.fillOne(i,s),this.dpGrid[i][s].value<=0?(this.dpGrid[i][s].value=0,this.dpGrid[i][s].parentI=0,this.dpGrid[i][s].parentJ=0):0==this.dpGrid[this.dpGrid[i][s].parentI][this.dpGrid[i][s].parentJ].value&&(this.dpGrid[i][s].parentI=0,this.dpGrid[i][s].parentJ=0),this.dpGrid[i][s].value>t&&(t=this.dpGrid[i][s].value,e=i,n=s);return this.constructResult(e,n)}setSequences(t,e){this.seq1=t,this.seq2=e,this.len1=this.seq1.length/this.step,this.len2=this.seq2.length/this.step,this.fillScores()}setGap(t){this.gap=t}setMethod(t=""){"AUTO"==t&&(t=this.typeRec()),this.gridFromName(t)}constructor(t,e,n,i=""){this.seq1="",this.seq2="",this.gap=1,this.len1=0,this.len2=0,this.step=1,this.alignGrid=[],this.scores=[],this.dpGrid=[],this.connections={},this.BLOSUM45=[[5,-2,-1,-2,-1,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-2,-2,0,-1,-1,0,-5],[-2,7,0,-1,-3,1,0,-2,0,-3,-2,3,-1,-2,-2,-1,-1,-2,-1,-2,-1,0,-1,-5],[-1,0,6,2,-2,0,0,0,1,-2,-3,0,-2,-2,-2,1,0,-4,-2,-3,4,0,-1,-5],[-2,-1,2,7,-3,0,2,-1,0,-4,-3,0,-3,-4,-1,0,-1,-4,-2,-3,5,1,-1,-5],[-1,-3,-2,-3,12,-3,-3,-3,-3,-3,-2,-3,-2,-2,-4,-1,-1,-5,-3,-1,-2,-3,-2,-5],[-1,1,0,0,-3,6,2,-2,1,-2,-2,1,0,-4,-1,0,-1,-2,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,-11.9,-10.5,-11.8,6.2,3.3,3.7,3.6,-50,-13.6,-50,-11.9,-5.6,-8.8,-7.2,-8.9,-50,-12.4,-14.1,-11.6,2.8,-6.4,.5,-5.2],[-13,-7.9,-13.2,-9.5,-4.6,-1.2,-4.1,-3.4,-12.5,-6.3,-12.5,-8.5,9.6,12.7,.2,10.5,-12.4,-11.6,-13.2,-12,-12.4,-10.1,-11.6,-12,-15.1,-13.1,-14.3,-13.4,-1.4,1.4,-1.6,-.5,-14.9,-14.3,-15.2,-16.8,-7.7,-4.7,-6.3,-6.6,-14.6,-10.8,-12.8,-13,2.3,6,2.5,3.6,-50,-11.2,-50,-11.9,-10.5,-9.2,-10.5,-10.5,-50,-10.3,-16.2,-11.3,-1.7,-3.7,-2.5,-5.4],[-7.1,-9.9,-5.7,-9,-.4,-3,.9,-2.3,-7.2,-8.3,-5.3,-8,3.5,.2,14.3,1,-7.3,-11.2,-6.9,-9.7,-8.5,-10.2,-7.7,-9.8,-10,-10.4,-8.4,-10.2,1,-.6,1.7,-.5,-11.1,-14.8,-9.7,-14.5,-3.7,-5.8,-3.1,-5.6,-10.4,-11.5,-8.2,-11.1,.6,-1.6,1.6,-1.1,-50,-12.4,-50,-11.5,-5.5,-8,-4.9,-7.2,-50,-12.4,-10.3,-11.6,.7,-6.8,2.4,-6],[-11.5,-9.6,-12.6,-7,-3.6,-3.3,-3.5,-.6,-11.6,-7.7,-11.9,-5.3,9.7,10.5,1,12.6,-12,-12.2,-12.5,-9.7,-11.1,-11.2,-11.9,-9.4,-12.9,-14.3,-14,-11.9,-1,-.4,-1.6,1.2,-13.9,-15.4,-13.7,-12.6,-6.2,-6.7,-6.3,-4.4,-13,-12.2,-13,-10.4,2.9,3.8,2.5,5.8,-50,-12.5,-50,-10.2,-9.6,-9.7,-9.6,-8.3,-50,-11.6,-15.4,-9.4,-1.1,-5.4,-1.6,-3.3],[.4,-5,-1.5,-4,-4.8,-7.6,-5.9,-6.5,-.7,-6.1,-2.2,-5.6,-8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5.4,-50,-9.3,-14,-8.2,-2.4,-6.3,-2.4,-3.9],[-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,33.3,-50,30.6,-50,-50,-50,-50,-50,29.2,-50,-50,-50,-50,-50,-50,-50],[-14.8,-6.2,-14.9,-7.6,-14.6,-11.6,-13,-12.2,-14,-9,-14.1,-10.1,-13.6,-11.2,-12.4,-12.5,-8.1,2.2,-8.7,.4,-15.3,-11.3,-13.2,-13.3,-11.9,-7.2,-11.8,-7.9,-10.7,-7.4,-10.8,-8.9,-15.5,-10.3,-15.5,-12.5,-14.5,-12.1,-11.9,-12.8,-18.3,-12.7,-16.4,-14.7,-14.2,-10.4,-13.7,-13,-50,15.1,-50,13.3,-9.9,-5.8,-8.9,-7.6,-50,-1.5,-7.8,-3,-8.1,3.6,-9.4,2],[-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,30.6,-50,35.2,-50,-50,-50,-50,-50,28.5,-50,-50,-50,-50,-50,-50,-50],[-13.8,-7.5,-14.4,-5.1,-12.6,-11.6,-11.5,-10.1,-13.2,-9.7,-12.7,-7.4,-11.9,-11.9,-11.5,-10.2,-7.2,.9,-8.6,2.6,-14.1,-12.8,-13.3,-11,-9.7,-8.4,-11.2,-5.3,-9.3,-8.7,-9.9,-7.1,-13.9,-11.2,-14.2,-8.9,-12.9,-12.6,-12.6,-10.9,-15.4,-13.8,-14.8,-11.4,-12.8,-11.6,-13.2,-10.3,-50,13.3,-50,15.2,-8.6,-7,-8.4,-4.8,-50,-3,-7.1,-.1,-7.3,2.3,-8.7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,.6,.8,2.3,-7.1,-6.5,-7.2,-5,-6.5,-7.4,-7.5,-5.4,-50,-7.6,-50,-4.8,9.8,10,10.2,12.1,-50,-3.1,-11.4,-.7,-4.6,-6.6,-4.9,-3.9],[-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,29.2,-50,28.5,-50,-50,-50,-50,-50,33.3,-50,-50,-50,-50,-50,-50,-50],[-13,-7,-13.1,-8.3,-9.2,-6.5,-8.9,-7.6,-9.8,-.7,-9.2,-2.1,-12.4,-10.3,-12.4,-11.6,-9.5,-4.6,-10.4,-5.7,-13.6,-10.1,-11.4,-10.9,-6.5,-1.5,-6.2,-3.6,-12.8,-8,-12.3,-9.7,-16.5,-12.7,-15.6,-14.3,-8.7,-6,-7.1,-7.5,-9.5,-4.1,-8.4,-6.1,-11,-8.6,-11.3,-9.3,-50,-1.5,-50,-3,-4.8,-1.5,-4.2,-3.1,-50,16.4,-5.1,14.2,-10.1,-4.3,-10,-5.4],[-13.5,-16.3,-11.8,-15.5,-13.6,-15.3,-12.1,-16.1,-7.7,-13.3,-4.2,-12.6,-14.1,-16.2,-10.3,-15.4,-9.6,-11.6,-7.7,-9.8,-14.3,-17.5,-11.1,-17.2,-5.3,-7.1,-2.2,-7.1,-9.6,-11.9,-8.7,-11.4,-17.1,-20.6,-15.3,-19.9,-14.1,-14.8,-12.4,-16.5,-11.7,-12.8,-6.4,-13.4,-14.3,-15.7,-12.7,-14,-50,-7.8,-50,-7.1,-8.7,-11.3,-6.1,-11.4,-50,-5.1,18.6,-4.8,-8.6,-8.1,-4.5,-7.3],[-12.4,-8.2,-13,-5.9,-7.7,-7.8,-7.4,-5.8,-8.8,-2,-9.3,-.4,-11.6,-11.3,-11.6,-9.4,-8.9,-5.6,-10,-3.2,-11.5,-11.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.4,-50,-8.7,-2.1,-5.6,-1.2,-4.9,-50,-10,-4.5,-8.9,9.7,-1.8,11.3,-.9],[-17.2,-13.3,-17.8,-11.6,-11,-11.1,-10.4,-9,-16,-12.7,-16.1,-11.1,-5.2,-5.4,-6,-3.3,-11.8,-7.3,-13.3,-5.9,-12.7,-11.9,-11.9,-9.3,-15.2,-15,-14.9,-11,-2.8,-1.8,-2.9,.4,-17.4,-18.4,-18.3,-15.9,-10.7,-11.2,-10.6,-9,-15.4,-14.8,-15.8,-13.3,-6.8,-5.9,-7.2,-3.9,-50,2,-50,3.9,-7,-6.8,-6.8,-3.9,-50,-5.4,-7.3,-3.4,-.3,11.6,-.9,14.1]],this.TRANS=[[5,0,0,4],[0,5,4,0],[0,4,5,0],[4,0,0,5]],this.CONBLO={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},this.CONNUCL={A:0,T:1,C:2,G:3},this.CONSCHN={AAA:0,AAC:1,AAG:2,AAT:3,ACA:4,ACC:5,ACG:6,ACT:7,AGA:8,AGC:9,AGG:10,AGT:11,ATA:12,ATC:13,ATG:14,ATT:15,CAA:16,CAC:17,CAG:18,CAT:19,CCA:20,CCC:21,CCG:22,CCT:23,CGA:24,CGC:25,CGG:26,CGT:27,CTA:28,CTC:29,CTG:30,CTT:31,GAA:32,GAC:33,GAG:34,GAT:35,GCA:36,GCC:37,GCG:38,GCT:39,GGA:40,GGC:41,GGG:42,GGT:43,GTA:44,GTC:45,GTG:46,GTT:47,TAA:48,TAC:49,TAG:50,TAT:51,TCA:52,TCC:53,TCG:54,TCT:55,TGA:56,TGC:57,TGG:58,TGT:59,TTA:60,TTC:61,TTG:62,TTT:63},this.setMethod(i),this.setSequences(t,e),this.setGap(n)}}},7983:(t,e,n)=>{"use strict";n.d(e,{HV:()=>p,QF:()=>m,pf:()=>d,uH:()=>u});var i=n(4469),s=n(3870),o=n(976),r=n(7241),a=n(4293),l=n(8467),c=n(8447);const h="substr_helm";class u{constructor(t){this.col=t[0],this.createUI()}editHelmLinkAction(){(0,a.Y)(this.inputsDiv,this.grid.root),s.tools.waitForElementInDom(this.grid.root).then((()=>{setTimeout((()=>{this.grid.cell(h,0).element.children[0].dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"}))}),100)}))}updateInputs(){const t=this.units===c.r2.HELM?s.divV([this.columnsInput,this.editHelmLink]):this.units===c.r2.SEPARATOR?s.inputs([this.columnsInput,this.substructureInput,this.separatorInput]):s.inputs([this.columnsInput,this.substructureInput]);(0,a.Y)(this.inputsDiv,t)}updateNotationDiv(){this.units=this.col.getTag(o.TAGS.UNITS),this.separator=this.col.getTag("separator");const t=this.dialog.root.getElementsByClassName("notation-text")[0];t&&(t.textContent=`Notation: ${this.units}`)}createUI(){const t=i.shell.tv.dataFrame,e={filter:t=>t.semType===o.SEMTYPE.MACROMOLECULE};this.columnsInput=s.columnInput("Column",t,this.col,(t=>{this.col=t,this.updateNotationDiv(),this.updateInputs()}),e),this.substructureInput=s.stringInput("Substructure",""),this.editHelmLink=s.link("Edit helm",(()=>this.editHelmLinkAction()),void 0,{style:{position:"relative",left:"95px"}});const n=o.DataFrame.create(1);n.columns.addNewString(h).init((t=>"")),n.col(h).semType=this.col.semType,n.col(h).setTag(o.TAGS.UNITS,c.r2.HELM),this.grid=n.plot.grid(),this.separatorInput=s.stringInput("Separator",this.separator),this.inputsDiv=s.div(),this.units=this.col.getTag(o.TAGS.UNITS),this.separator=this.col.getTag("separator"),this.updateInputs(),this.dialog=s.dialog("Substructure Search").add(s.divV([s.divText(`Notation: ${this.units}`,"notation-text"),this.inputsDiv])).onOK((async()=>{let t,e=this.units===c.r2.HELM?n.get(h,0):this.substructureInput.value;this.units===c.r2.SEPARATOR&&this.separatorInput.value!==this.separator&&""!==this.separatorInput.value&&(e=e.replaceAll(this.separatorInput.value,this.separator)),t=this.units===c.r2.HELM?await m(e,this.col):d(e,this.col),this.col.dataFrame.filter.and(t)})).show()}}function d(t,e,n){const i=n?function(t,e){const n=`${e}`.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),i=t.charAt(0)===e,s=t.charAt(t.length-1)===e,o=t.replace(new RegExp(`^${n}|${n}$`,"g"),"");return i?s?`${n}${o}${n}`:`${n}${o}${n}|${n}${o}$`:s?`^${o}${n}|${n}${o}${n}`:`^${o}${n}|${n}${o}${n}|${n}${o}$`}(t,n):t,s=o.BitSet.create(e.length);for(let n=0;n<e.length;n++){const o=e.get(n);(o.match(i)||o===t)&&s.set(n,!0,!1)}return s}async function m(t,e){e.version!==e.temp["last-invalidated-version"]&&await p(e,!0);const n=o.Column.string("helm",1).init((e=>t));n.semType=o.SEMTYPE.MACROMOLECULE,n.setTag(o.TAGS.UNITS,c.r2.HELM);const s=await(0,r.D)(n,!0,e.temp["monomers-dict"]);return(await i.functions.call("Chem:searchSubstructure",{molStringsColumn:e.temp["monomeric-mols"],molString:s.get(0),molBlockFailover:""})).get(0)}async function p(t,e){const n=o.TaskBarProgressIndicator.create(`Invalidating molfiles for ${t.name}`);try{await(0,l.gw)(10);const n=new Map,i=await(0,r.D)(t,e,n);t.temp["monomeric-mols"]=i,t.temp["monomers-dict"]=n,t.temp["last-invalidated-version"]=t.version}finally{n.close()}}},2568:(t,e,n)=>{"use strict";n.d(e,{n:()=>r});var i=n(4469),s=n(976),o=n(499);function r(t,e,n=[],r=[],a=!0){const[l,c]=function(t,e,n=[],r=[]){let a=!0,l="";const c=o.Cn.getOrCreate(t);if(t.semType!==s.SEMTYPE.MACROMOLECULE)i.shell.warning(e+" analysis is allowed for Macromolecules semantic type"),a=!1;else{const t=c.notation;if(n.length>0&&!n.some((e=>t.toUpperCase()==e.toUpperCase())))l=`${e} + ' analysis is allowed for Macromolecules with notation ${0==n.length?"any notation":`notation${n.length>1?"s":""} ${n.map((t=>`"${t}"`)).join(", ")} `}.`,a=!1;else if(!c.isHelm()){const t=c.alphabet;r.length>0&&!r.some((e=>t.toUpperCase()==e.toUpperCase()))&&(l=`${e} + ' analysis is allowed for Macromolecules with alphabet ${0==r.length?"any alphabet":`alphabet${r.length>1?"s":""} ${r.map((t=>`"${t}"`)).join(", ")}.`}.`,a=!1)}}return[a,l]}(t,e,n,r);return a&&!l&&i.shell.warning(c),l}},3553:(t,e,n)=>{"use strict";n.d(e,{Of:()=>o,WY:()=>c,jB:()=>h,rs:()=>a});var i,s,o,r,a,l=n(8341);!function(t){t.SPLIT_COL="~split",t.ACTIVITY="~activity",t.ACTIVITY_SCALED="activity_scaled",t.ALIGNED_SEQUENCE="~aligned_sequence",t.AMINO_ACID_RESIDUE="AAR",t.POSITION="Pos",t.P_VALUE="pValue",t.MEAN_DIFFERENCE="Mean difference"}(i||(i={})),function(t){t.AAR="AAR",t.POSITION="Pos",t.SELECTION="selection"}(s||(s={})),function(t){t.MONOMER="Monomer",t.MACROMOLECULE_DIFFERENCE="MacromoleculeDifference",t.ACTIVITY="activity",t.ACTIVITY_SCALED="activityScaled"}(o||(o={})),function(t){t.CELL_CHANGING="isCellChanging"}(r||(r={})),function(t){t.SEPARATOR="."}(a||(a={}));const c="3.3.1",h={pepsea:{gapOpen:1.53,gapExtend:0,method:l.Jy[0]},kalign:{gapOpen:-1,gapExtend:-1,terminalGap:-1}}},4004:(t,e,n)=>{"use strict";n.d(e,{O:()=>d});var i=n(976),s=n(3870),o=n(4469),r=n(3336),a=n.n(r),l=n(8447),c=n(499);let h=null,u=[];function d(t){let e=t??o.shell.t.columns.bySemType("Macromolecule");if(!e)throw new Error("No column with Macromolecule semantic type found");let n=c.Cn.getOrCreate(e),r=n.notation;const d=s.divText("Current notation: "+r,{style:{"text-align":"center","font-weight":"bold","font-size":"14px",padding:"5px"}}),m=[l.r2.FASTA,l.r2.SEPARATOR,l.r2.HELM],p=s.columnInput("Column",o.shell.t,e,(t=>{t.semType===i.SEMTYPE.MACROMOLECULE?(e=t,n=c.Cn.getOrCreate(e),r=n.notation,r===l.r2.HELM&&(y.value="/"),d.textContent="Current notation: "+r,f=m.filter((t=>t!==r)),C=s.choiceInput("Convert to",f[0],f,b),b(),h?.clear(),h?.add(s.div([d,p.root,C.root,y.root]))):p.value=e})),g=["-",".","/"];let f=m.filter((t=>t!==r));const y=s.choiceInput("Separator",g[0],g),b=()=>{C.value!==l.r2.SEPARATOR?a()(y.root).hide():a()(y.root).show()};let C=s.choiceInput("Convert to",f[0],f,b);b(),C.onChanged((()=>{b()})),null==h&&(h=s.dialog("Convert Sequence Notation").add(s.div([d,p.root,C.root,y.root])).onOK((async()=>{const t=C.value,n=y.value??void 0;await async function(t,e,n){const i=c.Cn.getOrCreate(t).convert(e,n);t.dataFrame.columns.add(i);const s=await o.functions.call("Bio:detectMacromolecule",{col:i});return s&&(i.semType=s),await o.data.detectSemanticTypes(t.dataFrame),i}(e,t,n)})).show({x:350,y:100}),u.push(h.onClose.subscribe((t=>{u.forEach((t=>{t.unsubscribe()})),u=[],h=null}))))}},2918:(t,e,n)=>{"use strict";n.d(e,{NT:()=>w,cf:()=>b});var i=n(4469),s=n(3870),o=n(976),r=n(701),a=n(6584),l=n(922),c=n(1047);class h{constructor(t){this.rawLib=t}isValid(){return this.rawLib.every((t=>"object"==typeof t&&Object.values(c.Wc).every((e=>e in t&&"string"==typeof t[e]))))}getJsonMonomerLib(){const t=[];return this.rawLib.forEach((e=>{const n=this.prepareMonomer(e);t.push(n)})),t}prepareMonomer(t){const e={...c.Z2};Object.entries(c.Wc).forEach((([n,i])=>{const s=t[i];e[n]=s}));let n="smiles";const i=t[c.Wc[n]],s=new u(i),o=s.getCappedSmiles();return e[n]=o,n="rgroups",e[n]=d.getRGroups(s.getNumberOfRGroups()),n="molfile",e[n]=new m(s.getSmilesWithRGroups()).getMolfile(),e}}class u{constructor(t){let e=0;this.smilesWithRGroups=t.replace(/\[R(\d+)\]/g,((t,n)=>(++e,`[${n}*]`))),this.numberOfRGroups=e}getSmilesWithRGroups(){return this.smilesWithRGroups}getCappedSmiles(){return this.capRGroups()}getNumberOfRGroups(){return this.numberOfRGroups}capRGroups(){let t=this.smilesWithRGroups.replace("[1*]","[H:1]");return t=t.replace("[2*]","[OH:2]"),t.replace("[3*]","[H:3]")}}class d{constructor(){}static getRGroups(t){return c.nJ.slice(0,t)}}class m{constructor(t){this.smilesWithRGroups=t}getMolfile(){let t=o.chem.convert(this.smilesWithRGroups,o.chem.Notation.Smiles,o.chem.Notation.MolBlock);return t=this.restoreRGPLine(t),t=this.fixRGroupSymbols(t),t}restoreRGPLine(t){return t.replace("M ISO","M RGP")}fixRGroupSymbols(t){return t.replace(/\bR\b/g,"R#")}}var p=n(7228),g=n(4955);async function f(){return await Promise.all((await i.dapi.files.list(a.BX,!0,"")).map((async t=>t.fullPath.substring(a.BX.length))))}async function y(){const t=s.dialog({title:"Manage files"}).add(s.fileBrowser({path:"System:AppData/Bio/libraries"}).root).addButton("OK",(()=>t.close())).show()}async function b(){const t=s.button("Manage",y),e=s.inputs([]),n=await f(),r=await(0,a.nW)();for(const t of n){const n=s.boolInput(t,!r.exclude.includes(t),(()=>{1==n.value?r.exclude=r.exclude.filter((e=>e!=t)):r.exclude.includes(t)||r.exclude.push(t),(0,a.tW)(r).then((async()=>{await w.instance.loadLibraries(!0),i.shell.info("Monomer library user settings saved.")}))}));e.append(n.root)}return new o.Widget(s.divV([e,s.div(t)]))}class C{constructor(t,e){this._monomers={},this._onChanged=new r.Subject,this._monomers=t,this.error=e}getMonomer(t,e){return t in this._monomers&&e in this._monomers[t]?this._monomers[t][e]:null}getPolymerTypes(){return Object.keys(this._monomers)}getMonomerMolsByPolymerType(t){const e={};return Object.keys(this._monomers[t]??{}).forEach((n=>{e[n]=this._monomers[t][n].molfile})),e}getMonomerSymbolsByType(t){return Object.keys(this._monomers[t])}getMonomerSymbolsByRGroup(t,e,n){let i=this.getMonomerSymbolsByType(e).map((t=>this.getMonomer(e,t)));return i=i.filter((t=>null!==t)),0===i.length?[]:(i=i.filter((e=>{if(!e?.rgroups)return!1;let n=e?.rgroups.length>=t;return l._.getInstance(e.molfile).atomTypes.map(((t,e)=>"R#"===t?e:-1)).filter((t=>-1!==t)),n&&(n=!0),n})),i.map((t=>t?.symbol)))}get onChanged(){return this._onChanged}_updateInt(t){const e=t.getPolymerTypes(),n=this.getPolymerTypes();e.forEach((e=>{n.includes(e)||(this._monomers[e]={}),t.getMonomerSymbolsByType(e).forEach((n=>{this._monomers[e][n]=t.getMonomer(e,n)}))}))}update(t){this._updateInt(t),this._onChanged.next()}updateLibs(t,e=!1){e&&(this._monomers={});for(const e of t)e.error||this._updateInt(e);this._onChanged.next()}clear(){this._monomers={},this._onChanged.next()}}class w{constructor(){this._monomerLib=new C({}),this.loadLibrariesPromise=Promise.resolve()}getBioLib(){return this._monomerLib}async loadLibraries(t=!1){return this.loadLibrariesPromise=this.loadLibrariesPromise.then((async()=>{try{const[e,n]=await Promise.all([f(),(0,a.nW)()]),i=e.filter((t=>!n.exclude.includes(t))).filter((t=>!(n.explicit.length>0)||n.explicit.includes(t))),s=await Promise.all(i.map((t=>this.readLibrary(a.BX,t).catch((e=>{const n=`Loading monomers from '${t}' error: ${e instanceof Error?e.message:e.toString()}`;return new C({},n)})))));this._monomerLib.updateLibs(s,t)}catch(t){const e=`Loading monomer libraries error: ${t instanceof Error?t.message:t.toString()}`;i.shell.warning(e);const n=t instanceof Error?t.stack:void 0;g._package.logger.error(e,void 0,n)}}))}async readLibrary(t,e){let n,s,r=[];const a=new o.FileSource(t);if(e.endsWith(".sdf"))1===o.Func.find({package:"Chem",name:"importSdf"}).length?(n=await a.readAsBytes(e),s=await i.functions.call("Chem:importSdf",{bytes:n}),r=(0,p.Xk)(s[0])):i.shell.warning("Chem package is not installed");else if(e.endsWith(".json")){const t=await a.readAsText(e);r=JSON.parse(t)}else{if(!e.endsWith(".csv"))throw new Error("Monomer library of unknown file format, supported formats: SDF, JSON, CSV");{const t=(l=await a.readCsv(e),Array.from({length:l.rowCount},((t,e)=>l.columns.names().reduce(((t,n)=>(t[n]=l.get(n,e),t)),{})))),n=new h(t);if(!n.isValid())throw new Error("Invalid format of CSV monomer lib");r=n.getJsonMonomerLib()}}var l;const c={},u=[];return r.forEach((t=>{u.includes(t.polymerType)||(c[t.polymerType]={},u.push(t.polymerType)),c[t.polymerType][t.symbol]=t})),new C(c)}async selectSpecifiedLibraries(t){const e=await this.getInvalidFileNames(t);if(e.length>0)throw new Error(`Cannot select libraries ${e}: no such library in the list`);const n=await(0,a.nW)();n.exclude=(await f()).filter((e=>!t.includes(e))),await(0,a.tW)(n)}async getInvalidFileNames(t){const e=await f();return t.filter((t=>!e.includes(t)))}static get instance(){return window.$monomerLibHelper||(window.$monomerLibHelper=new w),window.$monomerLibHelper}}},525:(t,e,n)=>{"use strict";n.d(e,{K:()=>L});var i=n(4469),s=n(976),o=n(3870),r=n(8447),a=n(499),l=n(6098),c=n(8341),h=n(2568),u=n(3553),d=n(4955),m=n(3379),p=n.n(m),g=n(7795),f=n.n(g),y=n(569),b=n.n(y),C=n(3565),w=n.n(C),v=n(9216),S=n.n(v),A=n(4589),x=n.n(A),T=n(9564),I={};I.styleTagTransform=x(),I.setAttributes=w(),I.insert=b().bind(null,"head"),I.domAPI=f(),I.insertStyleElement=S(),p()(T.Z,I),T.Z&&T.Z.locals&&T.Z.locals;class M extends Error{constructor(t,e){super(t,e)}}async function L(t={}){return new Promise((async(e,n)=>{var r,a,l;t.clustersCol??(t.clustersCol=null),t.pepsea??(t.pepsea={}),(r=t.pepsea).method??(r.method=u.jB.pepsea.method),(a=t.pepsea).gapOpen??(a.gapOpen=u.jB.pepsea.gapOpen),(l=t.pepsea).gapExtend??(l.gapExtend=u.jB.pepsea.gapExtend);const h=t.col?.dataFrame??i.shell.t,d=t.col??h.columns.bySemType(s.SEMTYPE.MACROMOLECULE);if(null==d){const t="MSAError: dataset doesn't conain any Macromolecule column";i.shell.warning(t),n(new M(t))}const m=o.choiceInput("Method",t.pepsea.method,c.Jy);m.setTooltip("Alignment method");const p=o.floatInput("Terminal gap",t?.kalign?.terminalGap??null);p.setTooltip("Penalty for opening a gap at the beginning or end of the sequence");const g=o.p(`Kalign version: ${u.WY}`,"kalign-version"),f=o.floatInput("Gap open",t.pepsea.gapOpen);f.setTooltip("Gap opening penalty at group-to-group alignment");const y=o.floatInput("Gap extend",t.pepsea.gapExtend);y.setTooltip("Gap extension penalty to skip the alignment");const b=o.inputs([f,y,p]),C=o.button("Alignment parameters",(()=>{b.hidden=!b.hidden}),"Adjust alignment parameters such as penalties for opening and extending gaps");C.classList.add("msa-params-button"),b.hidden=!0,C.prepend(o.icons.settings((()=>null)));const w=[m.root.style],v=[p.root.style,g.style];let S;const A=o.columnInput("Sequence",h,d,(async()=>{S=await N(A.value,h,w,v,m,x,f,y,p)}),{filter:t=>t.semType===s.SEMTYPE.MACROMOLECULE});A.setTooltip("Sequences column to use for alignment");const x=o.columnInput("Clusters",h,t.clustersCol);if(x.nullable=!0,A.fireChanged(),t.col)return S=await N(t.col,h,w,v,m,x,f,y,p),void await E(A,h,S,e,n);o.dialog("MSA").add(A).add(x).add(m).add(b).add(C).add(g).onOK((async()=>{await E(A,h,S,e,n)})).show()}))}async function E(t,e,n,o,r){let a=null;const l=s.TaskBarProgressIndicator.create("Analyze for MSA ...");try{if(t.fireChanged(),t.value.semType!==s.SEMTYPE.MACROMOLECULE)throw new Error("Chosen column has to be of Macromolecule semantic type");if(void 0===n)throw new Error("Invalid column format");if(a=await n(),null==a)return r("PepSeA container has not started");e.columns.add(a),await i.data.detectSemanticTypes(e),o(a)}catch(t){const e=t instanceof Error?t.message:t.toString();i.shell.error(e),r(t)}finally{l.close()}}async function N(t,e,n,o,m,p,g,f,y){try{if(t.semType!==s.SEMTYPE.MACROMOLECULE)return;const i=e.columns.getUnusedName(`msa(${t.name})`);if((0,h.n)(t,t.name,[r.r2.FASTA,r.r2.SEPARATOR],["DNA","RNA","PT"],!1)){R(n,o,"kalign"),g.value=null,f.value=null,y.value=null;const e=a.Cn.getOrCreate(t),s=e.isFasta()?t:e.convert(r.r2.FASTA);return async()=>await(0,l.U)(s,!1,i,p.value)}if((0,h.n)(t,t.name,[r.r2.HELM],[],!1))return R(n,o,"pepsea"),g.value??(g.value=u.jB.pepsea.gapOpen),f.value??(f.value=u.jB.pepsea.gapExtend),async()=>await(0,c.f3)(t,i,m.value,g.value,f.value,p.value);if((0,h.n)(t,t.name,[r.r2.SEPARATOR],["UN"],!1)){const e=a.Cn.getOrCreate(t).convert(r.r2.HELM);return R(n,o,"pepsea"),g.value??(g.value=u.jB.pepsea.gapOpen),f.value??(f.value=u.jB.pepsea.gapExtend),async()=>await(0,c.f3)(e,i,m.value,g.value,f.value,p.value)}return g.value=null,f.value=null,y.value=null,void R(n,o,"kalign")}catch(t){const e=t instanceof Error?t.message:t.toString();i.shell.error(e),d._package.logger.error(e)}}function R(t,e,n){if("kalign"===n){for(const e of t)e.display="none";for(const t of e)t.removeProperty("display")}else{for(const t of e)t.display="none";for(const e of t)e.removeProperty("display")}}},6098:(t,e,n)=>{"use strict";n.d(e,{U:()=>P});var i=n(976),s=n(5226);const o=Symbol("Comlink.proxy"),r=Symbol("Comlink.endpoint"),a=Symbol("Comlink.releaseProxy"),l=Symbol("Comlink.thrown"),c=t=>"object"==typeof t&&null!==t||"function"==typeof t,h=new Map([["proxy",{canHandle:t=>c(t)&&t[o],serialize(t){const{port1:e,port2:n}=new MessageChannel;return u(t,e),[n,[n]]},deserialize:t=>(t.start(),m(t))}],["throw",{canHandle:t=>c(t)&&l in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){throw t.isError?Object.assign(new Error(t.value.message),t.value):t.value}}]]);function u(t,e=self){e.addEventListener("message",(function n(i){if(!i||!i.data)return;const{id:s,type:r,path:a}=Object.assign({path:[]},i.data),c=(i.data.argumentList||[]).map(w);let h;try{const e=a.slice(0,-1).reduce(((t,e)=>t[e]),t),n=a.reduce(((t,e)=>t[e]),t);switch(r){case"GET":h=n;break;case"SET":e[a.slice(-1)[0]]=w(i.data.value),h=!0;break;case"APPLY":h=n.apply(e,c);break;case"CONSTRUCT":h=function(t){return Object.assign(t,{[o]:!0})}(new n(...c));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;u(t,n),h=function(t,e){return b.set(t,e),t}(e,[e])}break;case"RELEASE":h=void 0;break;default:return}}catch(t){h={value:t,[l]:0}}Promise.resolve(h).catch((t=>({value:t,[l]:0}))).then((t=>{const[i,o]=C(t);e.postMessage(Object.assign(Object.assign({},i),{id:s}),o),"RELEASE"===r&&(e.removeEventListener("message",n),d(e))}))})),e.start&&e.start()}function d(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function m(t,e){return g(t,[],e)}function p(t){if(t)throw new Error("Proxy has been released and is not useable")}function g(t,e=[],n=function(){}){let i=!1;const s=new Proxy(n,{get(n,o){if(p(i),o===a)return()=>v(t,{type:"RELEASE",path:e.map((t=>t.toString()))}).then((()=>{d(t),i=!0}));if("then"===o){if(0===e.length)return{then:()=>s};const n=v(t,{type:"GET",path:e.map((t=>t.toString()))}).then(w);return n.then.bind(n)}return g(t,[...e,o])},set(n,s,o){p(i);const[r,a]=C(o);return v(t,{type:"SET",path:[...e,s].map((t=>t.toString())),value:r},a).then(w)},apply(n,s,o){p(i);const a=e[e.length-1];if(a===r)return v(t,{type:"ENDPOINT"}).then(w);if("bind"===a)return g(t,e.slice(0,-1));const[l,c]=y(o);return v(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:l},c).then(w)},construct(n,s){p(i);const[o,r]=y(s);return v(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:o},r).then(w)}});return s}function f(t){return Array.prototype.concat.apply([],t)}function y(t){const e=t.map(C);return[e.map((t=>t[0])),f(e.map((t=>t[1])))]}const b=new WeakMap;function C(t){for(const[e,n]of h)if(n.canHandle(t)){const[i,s]=n.serialize(t);return[{type:"HANDLER",name:e,value:i},s]}return[{type:"RAW",value:t},b.get(t)||[]]}function w(t){switch(t.type){case"HANDLER":return h.get(t.name).deserialize(t.value);case"RAW":return t.value}}function v(t,e,n){return new Promise((i=>{const s=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.addEventListener("message",(function e(n){!n.data||!n.data.id||n.data.id!==s||(t.removeEventListener("message",e),i(n.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:s},e),n)}))}const S="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0ICQ9U3ltYm9sKCJDb21saW5rLnByb3h5IiksQT1TeW1ib2woIkNvbWxpbmsuZW5kcG9pbnQiKSxSPVN5bWJvbCgiQ29tbGluay5yZWxlYXNlUHJveHkiKSx5PVN5bWJvbCgiQ29tbGluay50aHJvd24iKSxfPWU9PnR5cGVvZiBlPT0ib2JqZWN0IiYmZSE9PW51bGx8fHR5cGVvZiBlPT0iZnVuY3Rpb24iLEw9e2NhbkhhbmRsZTplPT5fKGUpJiZlWyRdLHNlcmlhbGl6ZShlKXtjb25zdHtwb3J0MTpyLHBvcnQyOml9PW5ldyBNZXNzYWdlQ2hhbm5lbDtyZXR1cm4gdyhlLHIpLFtpLFtpXV19LGRlc2VyaWFsaXplKGUpe3JldHVybiBlLnN0YXJ0KCksQyhlKX19LE89e2NhbkhhbmRsZTplPT5fKGUpJiZ5IGluIGUsc2VyaWFsaXplKHt2YWx1ZTplfSl7bGV0IHI7cmV0dXJuIGUgaW5zdGFuY2VvZiBFcnJvcj9yPXtpc0Vycm9yOiEwLHZhbHVlOnttZXNzYWdlOmUubWVzc2FnZSxuYW1lOmUubmFtZSxzdGFjazplLnN0YWNrfX06cj17aXNFcnJvcjohMSx2YWx1ZTplfSxbcixbXV19LGRlc2VyaWFsaXplKGUpe3Rocm93IGUuaXNFcnJvcj9PYmplY3QuYXNzaWduKG5ldyBFcnJvcihlLnZhbHVlLm1lc3NhZ2UpLGUud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uUFJPWFlGUyx7cm9vdDpzLGZzOml9LG8pKX19LF9maWxlb3AoZSxyKXt0Ll9sb2coYFJ1bm5pbmcgJHtlfSAke3J9YCk7Y29uc3QgaT10LmZzLmFuYWx5emVQYXRoKHIpO2lmKCFpLmV4aXN0cylyZXR1cm4gdC5fbG9nKGBGaWxlICR7cn0gbm90IGZvdW5kLmApLCExO3N3aXRjaChlKXtjYXNlImNhdCI6cmV0dXJuIHQuZnMucmVhZEZpbGUocix7ZW5jb2Rpbmc6InV0ZjgifSk7Y2FzZSJscyI6cmV0dXJuIHQuZnMuaXNGaWxlKGkub2JqZWN0Lm1vZGUpP3QuZnMuc3RhdChyKTp0LmZzLnJlYWRkaXIocik7Y2FzZSJkb3dubG9hZCI6Y29uc3Qgcz1uZXcgQmxvYihbdGhpcy5jYXQocildKTtyZXR1cm4gVVJMLmNyZWF0ZU9iamVjdFVSTChzKX1yZXR1cm4hMX0sX2xvZyhlKXtpZighdC5jb25maWcuZGVidWcpcmV0dXJuO2xldCByPVsuLi5hcmd1bWVudHNdO3Iuc2hpZnQoKSxjb25zb2xlLmxvZyhgJWNbV2ViV29ya2VyXSVjICR7ZX1gLCJmb250LXdlaWdodDpib2xkIiwiIiwuLi5yKX19O3codCl9KSgpOwo=",A=typeof window<"u"&&window.Blob&&new Blob([atob(S)],{type:"text/javascript;charset=utf-8"});function x(){const t=A&&(window.URL||window.webkitURL).createObjectURL(A);try{return t?new Worker(t):new Worker("data:application/javascript;base64,"+S)}finally{t&&(window.URL||window.webkitURL).revokeObjectURL(t)}}const T={urlCDN:"https://biowasm.com/cdn/v3",urlCDNStg:"https://stg.biowasm.com/cdn/v3",dirShared:"/shared",dirMounted:"/mnt",dirData:"/data",printInterleaved:!0,callback:null,debug:!1,env:"prd"};class I{constructor(t,e={}){if(null==t)throw"Expecting array of tools as input to Aioli constructor.";return Array.isArray(t)||(t=[t]),e=Object.assign({},T,e),t=t.map(this._parseTool),"stg"===e.env&&(e.urlCDN=e.urlCDNStg),this.tools=t,this.config=e,null!=this.config.callback&&(this.callback=this.config.callback),delete this.config.callback,this.init()}async init(){const t=new x;this.callback&&(t.onmessage=t=>{"biowasm"===t.data.type&&this.callback(t.data.value)});const e=m(t);return e.tools=this.tools,e.config=this.config,await e.init(),e}_parseTool(t){if("string"!=typeof t)return t;const e=t.split("/");if(2!=e.length&&3!=e.length)throw"Expecting '<tool>/<version>' or '<tool>/<program>/<version>'";return{tool:e[0],program:3==e.length?e[1]:e[0],version:e[e.length-1]}}}var M=n(850);class L{static getAvailableScales(){return Object.entries(this.scales).map((([t,e])=>t))}static getScale(t){return(0,M.hu)(!(void 0===this.scales[t]),`Scale '${t}' was not found.`),this.scales[t]}}L.scales={WimleyWhite:{"-":0,A:.17,C:-.24,D:-.07,E:-.01,F:-1.13,G:.01,H:.17,I:-.31,K:.99,L:-.56,M:-.23,N:.42,P:.45,Q:.58,R:.81,S:.13,T:.14,V:.07,W:-1.85,Y:-.94},categorial:{"-":0,A:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,K:9,L:10,M:11,N:12,P:13,Q:14,R:15,S:16,T:17,V:18,W:19,Y:20}};class E{constructor(t="categorial"){this.aa2num=L.getScale(t),this.num2aa={},Object.entries(this.aa2num).forEach((([t,e])=>this.num2aa[e]=t))}static _truncateSequence(t){let e=0,n=t.length;const i=["NH2","COOH"];if(t.startsWith(i[0])){const n=i[0].length;(0,M.hu)("-"==t[n],`Wrong sequence format: ${i[0]} without following '-' in '${t}'.`),e=n}if(t.endsWith(i[1])){const e=i[1].length+1;(0,M.hu)("-"==t[n-e],`Wrong sequence format: ${i[1]} without '-' precending in '${t}'.`),n-=e}return t.substring(e,n)}static _dropDefises(t){return t.replace(/(-)([^-]+)/g,"$2")}static clean(t){return E._dropDefises(E._truncateSequence(t))}encode(t){const e=t.length,n=new Array(e).fill(0);for(let i=0;i<e;++i){const e=t[i];(0,M.hu)(e in this.aa2num,`Unknown char '${e}' found in sequence '${t}'`),n[i]=this.encodeLettter(e)}return n}encodeLettter(t){return this.aa2num[t]}decode(t){let e="";for(let n=0;n<t.length;++n){const i=t[n];(0,M.hu)(i in this.num2aa,`Unknown code '${i}' found in vector '${t}'`),e+=this.num2aa[i]}return e}}var N=n(3553);const R="input.fa",_="result.fasta";function O(t){return t.reduce(((t,e,n)=>t+`>sample${n+1}\n${e}\n`),"")}async function P(t,e=!1,n="",o=null,r,a,l){let c=t.toList();e&&(c=c.map((t=>E.clean(t).replace(/\-/g,""))));const h=t.length;o??(o=i.Column.string("Clusters",h).init("0")),o.type!=i.COLUMN_TYPE.STRING&&(o=o.convertTo(i.TYPE.STRING)),o.compact();const u=o.categories,d=o.getRawData(),m=new Array(u.length),p=new Array(u.length);for(let t=0;t<h;++t){const e=d[t];(m[e]??(m[e]=[])).push(c[t]),(p[e]??(p[e]=[])).push(t)}const g=await new I(["base/1.0.0",{tool:"kalign",version:N.WY,reinit:!0}]),f=i.Column.string(n,h);for(let t=0;t<u.length;++t){const e=O(m[t]);await g.fs.writeFile(R,e);const n=`${void 0!==r?` --gpo ${r}`:""}${void 0!==a?` --gpe ${a}`:""}${void 0!==l?` --tgpe ${l}`:""}`,i=await g.exec(`kalign ${R} -f fasta -o ${_}${n}`);console.warn(i);const o=await g.cat(_);if(!o)throw new Error("kalign output no result");const c=new s.i(o).sequencesArray,h=p[t];for(let t=0;t<c.length;++t)f.set(h[t],c[t])}const y=t.getTag(i.TAGS.UNITS),b=t.getTag("alphabet");return f.setTag(i.TAGS.UNITS,y),f.setTag("aligned","SEQ.MSA"),f.setTag("alphabet",b),f.semType=i.SEMTYPE.MACROMOLECULE,f}},8341:(t,e,n)=>{"use strict";n.d(e,{Jy:()=>l,f3:()=>h,lp:()=>a});var i=n(4469),s=n(976),o=n(8447),r=n(3553);const a=new class{constructor(){this.dcName="bio"}async getDockerContainer(){return await i.dapi.docker.dockerContainers.filter(this.dcName).first()}},l=["mafft --auto","mafft","linsi","ginsi","einsi","fftns","fftnsi","nwns","nwnsi"],c=["AlignedSeq","AlignedSubpeptide","HELM","ID","PolymerID"];async function h(t,e,n="ginsi",l=1.53,h=0,d=null){const m=await a.getDockerContainer();if("started"!==m.status&&"checking"!==m.status)return i.log.warning("PepSeA container has not started yet"),null;const p=t.length;d??(d=s.Column.int("Clusters",p).init(0)),d.type!=s.COLUMN_TYPE.STRING&&(d=d.convertTo(s.TYPE.STRING));const g=d.categories,f=new Array(g.length);for(let e=0;e<p;++e){const n=d.get(e);if(""===n)continue;const i=g.indexOf(n),s=t.get(e);s&&(f[i]??(f[i]=[])).push({ID:e.toString(),HELM:s})}const y=new Array(p);for(const t of f){const e=(await u(m.id,t,n,l,h)).Alignment;for(const t of e)y[parseInt(t.ID)]=Object.entries(t).filter((t=>!c.includes(t[0]))).map((t=>"-"!==t[1]?t[1]:"")).join(r.rs.SEPARATOR)}const b=s.Column.fromStrings(e,y);return b.setTag(s.TAGS.UNITS,o.r2.SEPARATOR),b.setTag("separator",r.rs.SEPARATOR),b.setTag("aligned","SEQ.MSA"),b.setTag("alphabet","UN"),b.setTag(".alphabetIsMultichar","true"),b.semType=s.SEMTYPE.MACROMOLECULE,b}async function u(t,e,n,s,o){const r={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)},a=`/align?method=${n}&gap_open=${s}&gap_extend=${o}`,l=await i.dapi.docker.dockerContainers.request(t,a,r);return JSON.parse(l??"{}")}},9953:(t,e,n)=>{"use strict";n.d(e,{M:()=>i});const i="<All>"},9943:(t,e,n)=>{"use strict";n.d(e,{C2:()=>u});var i=n(976),s=n(3870),o=n(4469),r=n(6414),a=n.n(r),l=n(8447),c=n(499);const h=60;function u(){const t=o.shell.tv.grid,e=a().count(0).take(t.columns.length).map((e=>t.columns.byIndex(e))).filter((t=>!!t.column&&t.column.semType!==i.SEMTYPE.MACROMOLECULE)).toArray(),n=e.find((t=>-1!==t.name.toLowerCase().indexOf("id"))),r=n?[n.name]:[],u=s.multiChoiceInput("Seq id columns",r,e.map((t=>t.name))),m=a().count(0).take(t.columns.length).map((e=>t.columns.byIndex(e))).filter((t=>{const e=t.column;return!(!e||e.semType!==i.SEMTYPE.MACROMOLECULE)&&c.Cn.getOrCreate(e).isFasta()})).toArray(),p=m.length>0?m[0].name:[],g=s.choiceInput("Seq column",p,m.map((t=>t.name))),f=s.intInput("FASTA line width",h);s.dialog({title:"Save as FASTA"}).add(s.inputs([u,g,f])).onOK((()=>{const e=u.value?u.value.map((e=>t.columns.byName(e).column)):[],n=g.value?t.columns.byName(g.value).column:null,i=f.value??h;n||o.shell.warning("Seq column is mandatory to save as FASTA.");const s=function(t,e,n=h,i="\n"){const s=l.kB,o=[];for(let r=0;r<e.length;r++){const a=t.map((t=>t.get(r).toString())).join("|"),l=d(e.get(r),s,n);o.push(`>${a}${i}`);for(const t of l)o.push(`${t}${i}`)}return"".concat(...o)}(e,n,i),r=document.createElement("a");r.setAttribute("href",`data:text/plain;charset=utf-8,${encodeURIComponent(s)}`),r.setAttribute("download",`${t.dataFrame.name}.fasta`),r.click()})).show()}function d(t,e,n=h){const i=e(t);let s=0;const o=i.length,r=[];for(;s<o;){const t=a()(i).slice(s,s+n).toArray(),e=t.map((t=>t.length>1?`[${t}]`:t)).join("");r.push(e),s+=t.length}return r}},9416:(t,e,n)=>{"use strict";n.d(e,{n:()=>c});var i=n(4469),s=n(976),o=n(8467),r=n(2568),a=n(8457),l=n(3553);async function c(t,e){if(await(0,o.gw)(10),!(0,r.n)(e,"Sequence space"))return t;const n=(0,a.O)(e);n.name="splitToMonomers";const c=e.dataFrame;for(const t of n.columns)t.semType=l.Of.MONOMER,t.setTag("alphabet",e.getTag("alphabet"));const h=/(\d+)(?: \((\d+)\))?/,u=t=>{h.lastIndex=0;const e=t.match(h);return e?`${e[1]} (${parseInt(e[2]??0)+1})`:t};for(let t=0;t<n.columns.length;t++){const i=n.columns.byIndex(t);i.semType=l.Of.MONOMER,i.setTag("alphabet",e.getTag("alphabet"));const s=100;let o=0;for(;c.columns.byName(i.name)&&o<s;)i.name=u(i.name),o++;c.columns.add(i)}await i.data.detectSemanticTypes(c);for(let t=0;t<n.columns.length;t++){const e=n.columns.byIndex(t);e.setTag(s.TAGS.CELL_RENDERER,"Monomer"),e.setTag(".use-as-filter","false")}return c}},4293:(t,e,n)=>{"use strict";n.d(e,{B:()=>o,Y:()=>r});var i=n(4469),s=n(976);function o(){const t=i.shell.t.columns.bySemTypeAll(s.SEMTYPE.MACROMOLECULE);if(null!==t)return t;i.shell.error("Current table does not contain macromolecules")}function r(t,e){t.innerHTML="",t.append(e)}},8415:(t,e,n)=>{"use strict";n.d(e,{bo:()=>C,OZ:()=>M});var i=n(4469),s=n(3870),o=n(976),r=n(3336),a=n.n(r),l=n(6414),c=n.n(l),h=n(701),u=n(499),d=n(8447),m=n(9298);function p(t){var e;return"string"==typeof t||t instanceof String?t:("object"==typeof t||t instanceof Object)&&"$thrownJsError"in t?p(t.$thrownJsError):t instanceof Error?null!==(e=t.stack)&&void 0!==e?e:t.message:t.toString()}var g=n(7945),f=n(8467),y=n(172);var b,C,w=n(8770),v=n(4955);HTMLCanvasElement.prototype.getCursorPosition=function(t,e){const n=this.getBoundingClientRect();return new o.Point((t.clientX-n.left)*e,(t.clientY-n.top)*e)},o.Rect.prototype.contains=function(t,e){return this.left<=t&&t<=this.right&&this.top<=e&&e<=this.bottom};class S{constructor(t=0,e){this.valueList=null,this.valueIdx=0,this.value=this.rowCount=t,this.bounds=e}push(t){this.valueList||(this.valueList=new Array(this.rowCount),this.valueIdx=0),this.valueList[this.valueIdx]=t,++this.valueIdx}aggregate(t){this.value=t(this.valueList)??0,this.valueList=null}}class A{get label(){return this._label?this._label:this.name}constructor(t,e,n,i){this.sumRowCount=0,this.pos=t,this.name=e,this._freqs=n??{},i?.sumRowCount&&(this.sumRowCount=i.sumRowCount),i?.sumValueForHeight&&(this.sumPlotValue=i.sumValueForHeight),i?.label&&(this._label=i.label)}getMonomers(){return Object.keys(this._freqs)}hasMonomer(t){return t in this._freqs}getFreq(t){let e=this._freqs[t];return e||(e=this._freqs[t]=new S),e}aggregate(t){const e=function(t){return e=>{const n=function(t){let e;const n="agg";return e=t instanceof Float32Array?o.Column.fromFloat32Array(n,t):t instanceof Int32Array?o.Column.fromInt32Array(n,t):o.Column.fromList(o.COLUMN_TYPE.FLOAT,n,t),e}(e);return n.aggregate(t)}}(t);for(const[t,n]of Object.entries(this._freqs))n.aggregate(e)}getMinValue(){return Math.min(...Object.values(this._freqs).map((t=>t.value)))}calcPlotValue(t){for(const e of Object.values(this._freqs))e.plotValue=e.value-t}calcHeights(t){this.sumPlotValue=0;for(const t of Object.values(this._freqs))this.sumPlotValue+=t.plotValue;if(this.sumPlotValueForHeight=0,t===m.ES.Entropy){const t=Object.keys(this._freqs).length,e=.01*this.sumPlotValue,n=e/t;for(const t of Object.values(this._freqs)){const i=(t.plotValue+n)/(this.sumPlotValue+e);this.sumPlotValueForHeight+=-i*Math.log2(i)}}else if(t===m.ES.full)for(const[t,e]of Object.entries(this._freqs)){const t=e.plotValue/this.sumPlotValue;this.sumPlotValueForHeight+=t}}calcScreen(t,e,n,i,s,r,a,l,c,h){const u=s===m.ES.Entropy?i*(r-this.sumPlotValueForHeight)/r:i;let d=h*c+(i-u-1);const p=Object.entries(this._freqs).sort(((e,n)=>t(e[0])||t(n[0])?t(e[0])&&t(n[0])?0:t(e[0])?-1:1:n[1].value-e[1].value));for(const[t,i]of p){const t=u*i.plotValue/this.sumPlotValue;i.bounds=new o.Rect((e-n)*c*a,d,l*c,t),d+=t}}render(t,e,n,i,s,o){for(const[r,a]of Object.entries(this._freqs))if(!e(r)){const e=(0,d.GU)(r,5),l=a.bounds,c=l.left;t.resetTransform(),t.strokeStyle="lightgray",t.lineWidth=1,t.rect(c,l.top,l.width,l.height),t.fillStyle=o.get(r)??o.get("other"),t.textAlign="left",t.font=n;const h=t.measureText(e);t.setTransform(l.width/h.width,0,0,l.height/s,c,l.top),t.fillText(e,0,-i)}}getMonomerAt(t,e){const n=Object.entries(this._freqs).find((([n,i])=>i.bounds.contains(t,e)));return n?n[0]:void 0}buildCompositionTable(t){return(0,w._)(t,Object.assign({},...Object.entries(this._freqs).map((([t,e])=>({[t]:e.rowCount})))))}}!function(t){t.STYLE="Style",t.BEHAVIOR="Behavior",t.LAYOUT="Layout",t.DATA="Data"}(b||(b={})),function(t){t.sequenceColumnName="sequenceColumnName",t.valueAggrType="valueAggrType",t.valueColumnName="valueColumnName",t.startPositionName="startPositionName",t.endPositionName="endPositionName",t.skipEmptySequences="skipEmptySequences",t.skipEmptyPositions="skipEmptyPositions",t.shrinkEmptyTail="shrinkEmptyTail",t.backgroundColor="backgroundColor",t.positionHeight="positionHeight",t.positionWidth="positionWidth",t.verticalAlignment="verticalAlignment",t.horizontalAlignment="horizontalAlignment",t.fixWidth="fixWidth",t.fitArea="fitArea",t.minHeight="minHeight",t.maxHeight="maxHeight",t.showPositionLabels="showPositionLabels",t.positionMarginState="positionMarginState",t.positionMargin="positionMargin",t.filterSource="filterSource"}(C||(C={}));const x=m.vS;var T;!function(t){t[t.None=0]="None",t[t.Render=1]="Render",t[t.Layout=1]="Layout",t[t.Freqs=2]="Freqs"}(T||(T={}));const I=new class{constructor(){this.render=20}};class M extends o.JsViewer{get positionWidthWithMargin(){return this._positionWidthWithMargin}get Length(){return this.skipEmptyPositions?this.positions.length:this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0}get positionMarginValue(){return this.positionMarginState===m.dE.AUTO&&!0===this.unitsHandler.getAlphabetIsMultichar()||this.positionMarginState===m.dE.ON?this.positionMargin:0}constructor(){super(),this.viewed=!1,this.initialized=!1,this.palette=null,this.seqCol=null,this.positions=[],this.visibleSlider=!1,this.allowResize=!0,this.turnOfResizeForOneSetValue=!1,this.backgroundColor=4294967295,this.positionMargin=0,this.positionNames=[],this.positionLabels=void 0,this.startPosition=-1,this.endPosition=-1,this.error=null,this.viewerId=++M.viewerCounter,this.setDataInProgress=!1,this.viewSubs=[],this._onSizeChanged=new h.Subject,this._onFreqsCalculated=new h.Subject,this._onLayoutCalculated=new h.Subject,this.requestedRenderLevel=T.Freqs,this.renderRequest=new h.Subject,this._onRendered=new h.Subject,this.textBaseline="top",this.unitsHandler=null,this.sequenceColumnName=this.string(C.sequenceColumnName,x.sequenceColumnName,{category:b.DATA});const t=[o.AGG.KEY,o.AGG.PIVOT,o.AGG.MISSING_VALUE_COUNT,o.AGG.SKEW,o.AGG.KURT,o.AGG.SELECTED_ROWS_COUNT],e=Object.values(o.AGG).filter((e=>!t.includes(e)));this.valueAggrType=this.string(C.valueAggrType,x.valueAggrType,{category:b.DATA,choices:e}),this.valueColumnName=this.string(C.valueColumnName,x.valueColumnName,{category:b.DATA}),this.startPositionName=this.string(C.startPositionName,x.startPositionName,{category:b.DATA}),this.endPositionName=this.string(C.endPositionName,x.endPositionName,{category:b.DATA}),this.skipEmptySequences=this.bool(C.skipEmptySequences,x.skipEmptySequences,{category:b.DATA}),this.skipEmptyPositions=this.bool(C.skipEmptyPositions,x.skipEmptyPositions,{category:b.DATA}),this.shrinkEmptyTail=this.bool(C.shrinkEmptyTail,x.shrinkEmptyTail,{category:b.DATA}),this.backgroundColor=this.int(C.backgroundColor,x.backgroundColor,{category:b.STYLE}),this.positionHeight=this.string(C.positionHeight,x.positionHeight,{category:b.STYLE,choices:Object.values(m.ES)}),this._positionWidth=this.positionWidth=this.float(C.positionWidth,x.positionWidth,{category:b.STYLE}),this.verticalAlignment=this.string(C.verticalAlignment,x.verticalAlignment,{category:b.LAYOUT,choices:Object.values(m.vw)}),this.horizontalAlignment=this.string(C.horizontalAlignment,x.horizontalAlignment,{category:b.LAYOUT,choices:Object.values(m.iD)}),this.fixWidth=this.bool(C.fixWidth,x.fixWidth,{category:b.LAYOUT,userEditable:!1}),this.fitArea=this.bool(C.fitArea,x.fitArea,{category:b.LAYOUT}),this.minHeight=this.float(C.minHeight,x.minHeight,{category:b.LAYOUT}),this.maxHeight=this.float(C.maxHeight,x.maxHeight,{category:b.LAYOUT}),this.showPositionLabels=this.bool(C.showPositionLabels,x.showPositionLabels,{category:b.LAYOUT}),this.positionMarginState=this.string(C.positionMarginState,x.positionMarginState,{category:b.LAYOUT,choices:Object.values(m.dE)});let n=0;"auto"===this.positionMarginState&&(n=4),this.positionMargin=this.int(C.positionMargin,n,{category:b.LAYOUT,min:0,max:16}),this.filterSource=this.string(C.filterSource,x.filterSource,{category:b.BEHAVIOR,choices:Object.values(m.Ct)}),this.slider=s.rangeSlider(0,100,0,20,!1,{style:"barbell"}),this.canvas=s.canvas(),this.canvas.classList.value="bio-wl-canvas",this.canvas.style.width="100%",this.viewSyncer=new y.c(v._package.logger)}viewerToLog(){return`WebLogoViewer<${this.viewerId}>`}setData(){const t=`${this.viewerToLog()}.setData()`;v._package.logger.debug(`${t}, in`),this.viewSyncer.sync(`${t}`,(async()=>{if(!this.setDataInProgress){this.setDataInProgress=!0;try{this.viewed&&(this.renderRequestSub.unsubscribe(),await this.destroyView(),this.viewed=!1),this.updateSeqCol(),this.updateEditors(),this.viewed||(await this.buildView(),this.viewed=!0)}finally{this.setDataInProgress=!1}}})),v._package.logger.debug(`${t}, out`)}async destroyView(){for(const t of this.viewSubs)t.unsubscribe();this.viewSubs=[];const t=this.dataFrame?"data":"null";v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.destroyView( dataFrame = ${t} ) start`),this.host.remove(),this.msgHost=void 0,this.host=void 0,v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.destroyView() end`)}async buildView(){const t=this.dataFrame?"data":"null";v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.buildView( dataFrame = ${t} ) start`),window.devicePixelRatio,this.viewSubs.push(o.debounce(this.renderRequest,I.render).subscribe(this.renderRequestOnDebounce.bind(this))),this.helpUrl="/help/visualize/viewers/web-logo.md",this.msgHost=s.div("No message",{classes:"bio-wl-msg"}),this.msgHost.style.display="none",this.canvas=s.canvas(),this.canvas.style.width="100%",this.slider.root.style.position="absolute",this.slider.root.style.zIndex="999",this.slider.root.style.display="none",this.slider.root.style.height="0.7em",this.visibleSlider=!1,this.host=s.div([this.msgHost,this.canvas],{classes:"bio-wl-host",style:{display:"flex",flexDirection:"row",flexWrap:"wrap"}}),this.root.append(this.host),this.root.append(this.slider.root),this.error&&(this.msgHost.innerText=this.error.message,s.tooltip.bind(this.msgHost,this.error.stack),this.msgHost.style.setProperty("display",null)),this.dataFrame&&(this.viewSubs.push(this.dataFrame.filter.onChanged.subscribe(this.dataFrameFilterOnChanged.bind(this))),this.viewSubs.push(this.dataFrame.selection.onChanged.subscribe(this.dataFrameSelectionOnChanged.bind(this)))),this.viewSubs.push(s.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),this.viewSubs.push(this.slider.onValuesChanged.subscribe(this.sliderOnValuesChanged.bind(this))),this.viewSubs.push((0,h.fromEvent)(this.canvas,"mousemove").subscribe(this.canvasOnMouseMove.bind(this))),this.viewSubs.push((0,h.fromEvent)(this.canvas,"mousedown").subscribe(this.canvasOnMouseDown.bind(this))),this.viewSubs.push((0,h.fromEvent)(this.canvas,"wheel").subscribe(this.canvasOnWheel.bind(this))),this.render(T.Freqs,"buildView"),v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.buildView() end`)}rootOnSizeChanged(){v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.rootOnSizeChanged(), start `),this.render(T.Layout,"rootOnSizeChanged")}updateEditors(){this.props.getProperty(C.valueColumnName).choices=c()(this.dataFrame.columns.numerical).map((t=>t.name)).toArray()}updateSeqCol(){if(this.dataFrame&&(this.seqCol=this.sequenceColumnName?this.dataFrame.col(this.sequenceColumnName):null,null==this.seqCol&&(this.seqCol=(0,d.up)(this.dataFrame),this.sequenceColumnName=this.seqCol?this.seqCol.name:null),this.seqCol)){try{this.unitsHandler=u.Cn.getOrCreate(this.seqCol),this.palette=(0,d.dQ)(this.seqCol),this.render(T.Freqs,"updateSeqCol()"),this.error=null}catch(t){throw this.seqCol=null,this.error=t instanceof Error?t:new Error(t.toString()),t}this.seqCol||(this.unitsHandler=null,this.positionNames=[],this.positionLabels=[],this.startPosition=-1,this.endPosition=-1,this.palette=null)}}getFilter(){let t;switch(this.filterSource){case m.Ct.Filtered:t=this.dataFrame.filter;break;case m.Ct.Selected:t=0===this.dataFrame.selection.trueCount?this.dataFrame.filter:this.dataFrame.selection}return t}setSliderVisibility(t){t?(this.slider.root.style.display="inherit",this.visibleSlider=!0):(this.slider.root.style.display="none",this.visibleSlider=!1)}calcLayout(t){this.host&&this.canvas&&this.slider&&(this.host.classList.remove("bio-wl-fixWidth","bio-wl-fitArea"),this.canvas.classList.remove("bio-wl-fixWidth","bio-wl-fitArea"),this._positionWidth=this.positionWidth,this._positionMargin=this.positionMargin,this._positionWidthWithMargin=this._positionWidth+this.positionMarginValue,this.fixWidth?this.calcLayoutFixWidth(t):this.fitArea?this.calcLayoutFitArea(t):this.calcLayoutNoFitArea(t),this.slider.root.style.width=`${this.host.clientWidth}px`)}calcLayoutFixWidth(t){if(!this.host||!this.canvas||!this.slider)return;this.host.classList.add("bio-wl-fixWidth"),this.canvas.classList.add("bio-wl-fitArea");const e=this._positionWidthWithMargin*this.Length,n=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight);this.host.style.justifyContent=m.iD.LEFT,this.host.style.removeProperty("margin-left"),this.host.style.removeProperty("margin-top"),this.host.style.width=this.canvas.style.width=`${e}px`,this.host.style.height=this.canvas.style.height=`${n}px`,this.host.style.left=this.canvas.style.left="0",this.host.style.top=this.canvas.style.top="0",this.host.style.setProperty("overflow","hidden","important"),this.slider.root.style.display="none",this.slider.setValues(0,Math.max(0,this.Length-1),0,Math.max(0,this.Length-1)),this.canvas.width=e*t,this.canvas.height=n*t}calcLayoutNoFitArea(t){if(!this.host||!this.canvas||!this.slider)return;const e=this._positionWidthWithMargin*this.Length,n=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight),i=Math.min(this.root.clientWidth,e);this.canvas.style.width=`${i}px`,this.canvas.style.height=`${n}px`,this.host.style.width=`${i}px`,this.host.style.height=`${this.root.clientHeight}px`,this.host.style.justifyContent=this.horizontalAlignment,this.host.style.alignContent=this.verticalAlignment===m.vw.TOP?"start":this.verticalAlignment===m.vw.MIDDLE?"center":this.verticalAlignment===m.vw.BOTTOM?"end":"inherit",this.root.clientHeight<this.minHeight&&(this.host.style.alignContent="start",this.host.style.width=`${i+6}px`),this.host.style.width=`${this.host}px`;const s=e>i;if(this.setSliderVisibility(s),s){this.slider.root.style.removeProperty("display"),this.host.style.justifyContent="left",this.host.style.height=this.root.clientHeight-this.slider.root.offsetHeight+"px",this.slider.root.style.top=`${this.host.offsetHeight}px`;let t=Math.min(Math.max(0,this.slider.min),this.Length-.001),e=Math.min(Math.max(0,this.slider.max),this.Length-.001);const n=this.root.clientWidth/this._positionWidthWithMargin;e=Math.min(Math.max(t,0)+n,this.Length-.001),t=Math.max(0,Math.min(e,this.Length-.001)-n),this.slider.setValues(0,Math.max(this.Length-.001),t,e)}else this.slider.setValues(0,Math.max(0,this.Length-.001),0,Math.max(0,this.Length-.001));this.canvas.width=i*t,this.canvas.height=n*t}calcLayoutFitArea(t){if(!this.host||!this.canvas||!this.slider)return;const e=this._positionWidth*this.Length,n=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight),i=e>0?(this.root.clientWidth-this.positionMarginValue*this.Length)/e:0,s=this.root.clientHeight/n,o=Math.max(1,Math.min(i,s));this._positionWidth=this.positionWidth*o,this._positionWidthWithMargin=this._positionWidth+this.positionMarginValue;const r=(this._positionWidth+this.positionMarginValue)*this.Length,a=o*n,l=Math.min(this.root.clientWidth,r);this.canvas.style.width=`${l}px`,this.canvas.style.height=`${a}px`,this.host.style.width=`${l}px`,this.host.style.height=`${this.root.clientHeight}px`,this.host.style.justifyContent=this.horizontalAlignment,this.host.style.alignContent=this.verticalAlignment===m.vw.TOP?"start":this.verticalAlignment===m.vw.MIDDLE?"center":this.verticalAlignment===m.vw.BOTTOM?"end":"inherit",this.root.clientHeight<this.minHeight&&(this.host.style.alignContent="start",this.host.style.width=`${l+6}px`),this.host.style.width=`${this.host}px`;const c=r>l;if(this.setSliderVisibility(c),c){this.slider.root.style.removeProperty("display"),this.host.style.justifyContent="left",this.host.style.height=this.root.clientHeight-this.slider.root.offsetHeight+"px",this.slider.root.style.top=`${this.host.offsetHeight}px`;let t=Math.min(Math.max(0,this.slider.min),this.Length-.001),e=Math.min(Math.max(0,this.slider.max),this.Length-.001);const n=this.root.clientWidth/this._positionWidthWithMargin;e=Math.min(Math.max(t,0)+n,this.Length-.001),t=Math.max(0,Math.min(e,this.Length-.001)-n),this.slider.setValues(0,Math.max(0,this.Length-.001),t,e)}else this.slider.setValues(0,Math.max(0,this.Length-.001),0,Math.max(0,this.Length-.001));this.canvas.width=l*t,this.canvas.height=a*t}onPropertyChanged(t){switch(super.onPropertyChanged(t),t.name){case C.sequenceColumnName:this.updateSeqCol();break;case C.sequenceColumnName:case C.startPositionName:case C.endPositionName:case C.filterSource:case C.shrinkEmptyTail:case C.skipEmptyPositions:case C.positionHeight:case C.valueColumnName:case C.valueAggrType:this.render(T.Freqs,`onPropertyChanged( ${t.name} )`);break;case C.minHeight:case C.maxHeight:case C.positionWidth:case C.showPositionLabels:case C.fixWidth:case C.fitArea:case C.horizontalAlignment:case C.verticalAlignment:case C.positionMargin:case C.positionMarginState:this.render(T.Layout,`onPropertyChanged(${t.name})`);break;case C.backgroundColor:this.render(T.Render,`onPropertyChanged(${t.name})`)}}onTableAttached(){v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.onTableAttached(), `),super.onTableAttached(),this.setData()}detach(){const t=`${this.viewerToLog()}.detach()`;v._package.logger.debug(`${t}, in`);const e=super.detach.bind(this);this.viewSyncer.sync(`${t}`,(async()=>{this.setDataInProgress||(this.viewed&&(await this.destroyView(),this.viewed=!1),e())})),v._package.logger.debug(`${t}, out`)}get onSizeChanged(){return this._onSizeChanged}get onFreqsCalculated(){return this._onFreqsCalculated}get onLayoutCalculated(){return this._onLayoutCalculated}getMonomer(t,e){const n=t.x,i=Math.floor(t.x/(this._positionWidthWithMargin*e)+Math.floor(this.slider.min)),s=this.positions[i];if(!s)return[null,null,null];const o=s.getMonomerAt(n,t.y);return void 0===o?[s,null,null]:[s,o,s.getFreq(o)]}_nullSequence(t="X"){return this.skipEmptySequences?"":new Array(this.Length).fill(t).join("")}_removeEmptyPositions(){this.skipEmptyPositions&&(this.positions=c()(this.positions).filter((t=>{const e=this.unitsHandler.defaultGapSymbol;return!t.hasMonomer(e)||t.getFreq(e).rowCount!==t.sumRowCount})).toArray())}render(t,e){v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render( recalcLevelVal=${t}, reason='${e}' )`),this.requestedRenderLevel=Math.max(this.requestedRenderLevel,t),this.renderRequest.next(this.requestedRenderLevel)}async renderInt(t){if(v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.renderInt( renderLevel=${t} ), start `),this.msgHost&&(this.seqCol&&!this.palette?(this.msgHost.innerText=`Unknown palette (column semType: '${this.seqCol.semType}').`,this.msgHost.style.display=""):this.msgHost.style.display="none"),!this.seqCol||!this.dataFrame||!this.palette||null==this.host||null==this.slider)return;const e=window.devicePixelRatio,n=this.showPositionLabels?12:0;if(t>=T.Freqs&&(()=>{if(v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateFreqsInt(), start `),!this.host||!this.seqCol||!this.dataFrame)return;const t=this.getFilter(),e=0===t.trueCount?this.unitsHandler.maxLength:c().enumerate(this.unitsHandler.splitted).map((([e,n])=>t.get(n)&&e?e.length:0)).reduce(((t,e)=>Math.max(t,e)),0),n=this.seqCol.getTag(".positionNames"),i=this.seqCol.getTag(".positionLabels");this.positionNames=n?n.split(d.CI).map((t=>t.trim())):[...Array(e).keys()].map((t=>`${t+1}`)),this.positionLabels=i?i.split(d.CI).map((t=>t.trim())):void 0,this.startPosition=this.startPositionName&&this.positionNames&&this.positionNames.includes(this.startPositionName)?this.positionNames.indexOf(this.startPositionName):0,this.endPosition=this.endPositionName&&this.positionNames&&this.positionNames.includes(this.endPositionName)?this.positionNames.indexOf(this.endPositionName):e-1;const s=this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0;this.unitsHandler=u.Cn.getOrCreate(this.seqCol);const r=this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0;this.positions=new Array(r);for(let t=0;t<s;t++){const e=this.positionNames[this.startPosition+t],n=this.positionLabels?this.positionLabels[this.startPosition+t]:void 0;this.positions[t]=new A(this.startPosition+t,e,{},{label:n})}const a=this.dataFrame.rowCount,l=this.unitsHandler.splitted;for(let e=0;e<s;++e){for(let n=0;n<a;++n)if(t.get(n)){const t=l[n][this.startPosition+e]||this.unitsHandler.defaultGapSymbol,i=this.positions[e],s=i.getFreq(t);++i.sumRowCount,s.value=++s.rowCount}if(this.valueAggrType===o.AGG.TOTAL_COUNT)continue;let n=null;try{n=this.dataFrame.getCol(this.valueColumnName),n.matches("numerical")||(n=null)}catch{n=null}if(n){for(let i=0;i<a;++i)if(t.get(i)){const t=l[i][this.startPosition+e]||this.unitsHandler.defaultGapSymbol,s=n.get(i);this.positions[e].getFreq(t).push(s)}this.positions[e].aggregate(this.valueAggrType)}}const h=this.valueAggrType===o.AGG.TOTAL_COUNT?0:Math.min(0,Math.min(...this.positions.map((t=>t.getMinValue()))));for(let t=0;t<s;++t)this.positions[t].calcPlotValue(h),this.positions[t].calcHeights(this.positionHeight);this._removeEmptyPositions(),this._onFreqsCalculated.next()})(),this.calcLayout(e),-1===this.startPosition)return;const s=Math.max(Math.floor(this.slider.min),0),r=Math.min(this.positions.length-1,Math.floor(this.slider.max));t>=T.Layout&&((t,e,n,s)=>{v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateLayoutInt(), start `);const r=this.canvas.height-s*n;let a;if(this.valueAggrType===o.AGG.TOTAL_COUNT){const t=this.getAlphabetSize();this.positionHeight==m.ES.Entropy&&null==t&&i.shell.error("WebLogo: alphabet is undefined."),a=Math.log2(t)}else a=Math.max(...c().count(t).takeWhile((t=>t<=e)).map((t=>this.positions[t].sumPlotValueForHeight)));for(let i=t;i<=e;++i)i in this.positions?this.positions[i].calcScreen((t=>this.unitsHandler.isGap(t)),i,this.slider.min,r,this.positionHeight,a,this._positionWidthWithMargin,this._positionWidth,n,s):v._package.logger.warning(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateLayoutInt() this.positions.length = ${this.positions.length}, jPos = ${i}`);v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateLayoutInt(), end `),this._onLayoutCalculated.next()})(s,r,window.devicePixelRatio,n);const a=this.canvas.getContext("2d");if(a){a.save();try{this.Length,a.resetTransform(),a.fillStyle=function(t){const e=o.Color.a(t);return`#${(16777215&t).toString(16).padStart(6,"0")}`+e.toString(16).padStart(2,"0")}(this.backgroundColor),a.fillRect(0,0,this.canvas.width,this.canvas.height),a.textBaseline=this.textBaseline;const t=10*e;a.resetTransform(),a.fillStyle="black",a.textAlign="center",a.font=`${t.toFixed(1)}px Roboto, Roboto Local, sans-serif`,n>0&&this.positions.length>0&&function(t,e,n,i,s,o,r,a){t.save();try{t.textAlign="center";let l=null,c=null;for(let e=Math.floor(r);e<=Math.floor(a);e++){const n=o[e],i=t.measureText(n.name),s=i.actualBoundingBoxDescent-i.actualBoundingBoxAscent;l=null===l?i.width:Math.max(l,i.width),c=null===c?s:Math.max(c,s)}const h=l<i*e-2?1:(i*e-2)/l;for(let l=Math.floor(r);l<=Math.floor(a);l++){const a=o[l],u=(l-r)*n*e+i*e/2,d=(s*e-c)/2;t.setTransform(h,0,0,1,u,d),t.measureText(a.label),t.fillText(a.label,0,0)}}finally{t.restore()}}(a,e,this._positionWidthWithMargin,this._positionWidth,n,this.positions,this.slider.min,this.slider.max);const i="16px Roboto, Roboto Local, sans-serif",l=.25,c=12.2;for(let t=s;t<=r;t++)this.positions[t].render(a,(t=>this.unitsHandler.isGap(t)),i,l,c,this.palette)}finally{a.restore()}v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.renderInt( recalcLevel=${t} ), end`)}}renderRequestOnDebounce(t){const e=`${this.viewerToLog()}.renderRequestOnDebounce()`;"HTML"!==a()(this.root).offsetParent().get()[0]?.tagName?(this.requestedRenderLevel=T.None,this.renderInt(t).catch((t=>{const[e,n]=(0,g.yf)(t);v._package.logger.error(e,void 0,n)}))):v._package.logger.warning(`${e}, $(this.root).offsetParent() is the 'HTML' tag.`)}getAlphabetSize(){return this.unitsHandler?.getAlphabetSize()??0}sliderOnValuesChanged(t){try{const t={minRange:this.slider.minRange,min:this.slider.min,max:this.slider.max,maxRange:this.slider.maxRange};v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.sliderOnValuesChanged( ${JSON.stringify(t)} ), start`),this.render(T.Layout,"sliderOnValuesChanged")}catch(t){const e=p(t);v._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.sliderOnValuesChanged() error:\n`+e)}}dataFrameFilterOnChanged(t){v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameFilterChanged()`);try{this.filterSource===m.Ct.Filtered&&this.render(T.Freqs,"dataFrameFilterOnChanged")}catch(t){const e=p(t);v._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameFilterOnChanged() error:\n`+e)}}dataFrameSelectionOnChanged(t){v._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameSelectionOnChanged()`);try{this.filterSource===m.Ct.Selected&&this.render(T.Freqs,"dataFrameSelectionOnChanged")}catch(t){const e=p(t);v._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameSelectionOnChanged() error:\n`+e)}}canvasOnMouseMove(t){const e=window.devicePixelRatio;try{const n=t,i=this.canvas.getCursorPosition(n,e),[r,a]=this.getMonomer(i,e),l=this.showPositionLabels?12*e:0;if(null!==r&&null===a&&0<=i.y&&i.y<=l){const t=[s.divText(`Position ${r.label}`)];this.valueAggrType===o.AGG.TOTAL_COUNT&&t.push(r.buildCompositionTable(this.palette));const e=s.divV(t);s.tooltip.show(e,n.x+16,n.y+16)}else if(null!==r&&a&&this.dataFrame&&this.seqCol&&this.unitsHandler){const t=r.getFreq(a),e=[s.div(`${a}`),s.div(`${t.rowCount} rows`)];this.valueAggrType!==o.AGG.TOTAL_COUNT&&e.push(s.div(`${this.valueAggrType}: ${t.value.toFixed(3)}`));const i=s.divV(e);s.tooltip.show(i,n.x+16,n.y+16)}else s.tooltip.hide()}catch(t){const e=p(t);v._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.canvasOnMouseMove() error:\n`+e)}}canvasOnMouseDown(t){try{const e=t,n=window.devicePixelRatio,[i,s]=this.getMonomer(this.canvas.getCursorPosition(e,n),n);if(null!==i&&null!==s&&this.dataFrame&&this.seqCol&&this.unitsHandler){const t=o.BitSet.create(this.dataFrame.selection.length,(t=>function(t,e,n,i,s,o){const r=e.splitted[i],a=o.pos<r.length?r[o.pos]:null;return a===s||""===a&&s===e.defaultGapSymbol}(this.dataFrame,this.unitsHandler,this.getFilter(),t,s,i)));this.dataFrame.selection.init((e=>t.get(e)))}}catch(t){const e=p(t);v._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.canvasOnMouseDown() error:\n`+e)}}canvasOnWheel(t){const e=window.devicePixelRatio;try{if(!this.visibleSlider)return;const n=this.canvas.width/(this._positionWidthWithMargin*e),i=t.deltaY/100*Math.max(Math.floor(n/5),1);this.slider.scrollBy(this.slider.min+i)}catch(t){const e=p(t);v._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.canvasOnWheel() error:\n`+e)}}get onRendered(){return this._onRendered}invalidate(){const t=`${this.viewerToLog()}.invalidate()`;this.viewSyncer.sync(`${t}`,(async()=>{this.invalidate(),this._onRendered.next()}))}async awaitRendered(t=5e3){await(0,f.zg)(this.onRendered,(()=>{}),(()=>{this.invalidate()}),t)}}M.residuesSet="nucleotides",M.viewerCounter=-1},6099:(t,e,n)=>{"use strict";n.d(e,{ST:()=>f});var i=n(3870),s=n(976),o=n(4469),r=n(6414),a=n.n(r),l=n(701),c=n(442),h=n(8447),u=n(7945),d=n(8467),m=n(7983),p=n(4293),g=n(4955);class f extends s.Filter{get calculating(){return"initial"==this.loader.style.display}set calculating(t){this.loader.style.display=t?"initial":"none"}get filterSummary(){return this.bioFilter.substructure}get isFiltering(){return super.isFiltering&&""!==this.bioFilter.substructure}get isReadyToApplyFilter(){return!this.calculating&&null!=this.bitset}get _debounceTime(){if(null==this.column)return 1e3;const t=this.column.length;return t<500?0:t>1e4?1e3:Math.floor((t-500)/9500*1e3)}constructor(){super(),this.bioFilter=null,this.bitset=null,this.loader=i.loader(),this.notation=void 0,this.root=i.divV([]),this.calculating=!1}attach(t){super.attach(t),this.column=t.columns.bySemType(s.SEMTYPE.MACROMOLECULE),this.columnName??(this.columnName=this.column?.name),this.notation??(this.notation=this.column?.getTag(s.TAGS.UNITS)),this.bioFilter=this.notation===h.r2.FASTA?new b:this.notation===h.r2.SEPARATOR?new C(this.column.getTag("separator")):new w,this.root.appendChild(this.bioFilter.filterPanel),this.root.appendChild(this.loader),this.onBioFilterChangedSubs?.unsubscribe();let e=this.bioFilter.onChanged;e=e.pipe((0,c.debounceTime)(this._debounceTime)),this.onBioFilterChangedSubs=e.subscribe((async t=>await this._onInputChanged())),this.subs.push(o.events.onResetFilterRequest.subscribe((t=>{this.bioFilter?.resetFilter()})))}detach(){this.bioFilter&&this.bioFilter.detach(),super.detach()}applyFilter(){this.bitset&&!this.isDetached&&this.dataFrame?.filter.and(this.bitset)}saveState(){const t=super.saveState();return t.bioSubstructure=this.bioFilter?.substructure,t}applyState(t){super.applyState(t),t.bioSubstructure&&(this.bioFilter.substructure=t.bioSubstructure);const e=this;t.bioSubstructure&&setTimeout((function(){e._onInputChanged()}),1e3)}async _onInputChanged(){if(g._package.logger.debug("Bio: BioSubstructureFilter._onInputChanged(), start"),this.isFiltering){if(a()(this.dataFrame.rows.filters).has(`${this.columnName}: ${this.filterSummary}`))return;this.calculating=!0;try{this.bitset=await(this.bioFilter?.substructureSearch(this.column)),this.calculating=!1,this.dataFrame?.rows.requestFilter()}finally{this.calculating=!1}}else this.bitset=null,this.dataFrame?.rows.requestFilter()}}class y{constructor(){this.onChanged=new l.Subject}get filterPanel(){return new HTMLElement}async substructureSearch(t){return null}}class b extends y{constructor(){super(),this.substructureInput=i.stringInput("","",(()=>{this.onChanged.next()}),{placeholder:"Substructure"})}get filterPanel(){return this.substructureInput.root}get substructure(){return this.substructureInput.value}set substructure(t){this.substructureInput.value=t}async substructureSearch(t){return(0,m.pf)(this.substructure,t)}resetFilter(){this.substructureInput.value=""}detach(){}}class C extends b{constructor(t){super(),this.colSeparator="",this.separatorInput=i.stringInput("","",(()=>{this.onChanged.next()}),{placeholder:"Separator"}),this.colSeparator=t,this.separatorInput.value=t}get filterPanel(){return i.divV([this.substructureInput.root,this.separatorInput.root])}get substructure(){return this.separatorInput.value&&this.separatorInput.value!==this.colSeparator?this.substructureInput.value.replaceAll(this.separatorInput.value,this.colSeparator):this.substructureInput.value}set substructure(t){this.substructureInput.value=t}async substructureSearch(t){return(0,m.pf)(this.substructure,t,this.colSeparator)}detach(){}}class w extends y{constructor(){super(),this._filterPanel=i.div("",{style:{cursor:"pointer"}}),this.helmSubstructure="",this.viewSubs=[],this.init()}async init(){let t,e;this.helmEditor=await o.functions.call("Helm:helmWebEditor"),await i.tools.waitForElementInDom(this._filterPanel),this.updateFilterPanel(),this.viewSubs.push((0,l.fromEvent)(this._filterPanel,"click").subscribe((()=>{({editorDiv:t,webEditor:e}=this.helmEditor.createWebEditor(this.helmSubstructure));const n=i.dialog({showHeader:!1,showFooter:!0}).add(t).onOK((()=>{const t=e.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.helmSubstructure=t,this.updateFilterPanel(this.substructure),setTimeout((()=>{this.onChanged.next()}),10)})).show({modal:!0,fullScreen:!0}).onClose.subscribe((()=>{n.unsubscribe(),t=void 0,e=void 0}))}))),this.viewSubs.push(i.onSizeChanged(this._filterPanel).subscribe((t=>{try{if(e){const t=e.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.updateFilterPanel(t)}}catch(t){const[e,n]=(0,u.yf)(t);g._package.logger.error(e,void 0,n)}})))}get filterPanel(){return this._filterPanel}get substructure(){return this.helmSubstructure}set substructure(t){this.helmEditor.editor.setHelm(t)}updateFilterPanel(t){const e=this._filterPanel.parentElement.clientWidth<100?100:this._filterPanel.parentElement.clientWidth,n=e/2;if(t)(0,p.Y)(this._filterPanel,this.helmEditor.host),this.helmEditor.editor.setHelm(t),this.helmEditor.resizeEditor(e,n);else{const t=i.divText("Click to edit","helm-substructure-filter");(0,p.Y)(this._filterPanel,t)}}async substructureSearch(t){i.setUpdateIndicator(this._filterPanel,!0),await(0,d.gw)(10);const e=await(0,m.QF)(this.substructure,t);return i.setUpdateIndicator(this._filterPanel,!1),e}resetFilter(){console.debug("Bio: HelmFilter.resetFilter()"),this.helmSubstructure="",this.updateFilterPanel(this.substructure)}detach(){for(const t of this.viewSubs)t.unsubscribe()}}},8770:(t,e,n)=>{"use strict";n.d(e,{_:()=>T,t:()=>x});var i=n(3870),s=n(976),o=n(6414),r=n.n(o),a=n(8447),l=n(7331),c=n(3379),h=n.n(c),u=n(7795),d=n.n(u),m=n(569),p=n.n(m),g=n(3565),f=n.n(g),y=n(9216),b=n.n(y),C=n(4589),w=n.n(C),v=n(5362),S={};S.styleTagTransform=w(),S.setAttributes=f(),S.insert=p().bind(null,"head"),S.domAPI=d(),S.insertStyleElement=b(),h()(v.Z,S),v.Z&&v.Z.locals&&v.Z.locals;var A=n(499);function x(t){const e=i.div();e.classList.add("macromolecule-cell-comp-analysis-host");const n=t.cell.column.tags.alphabet;let o=l.UE.Color;switch(n){case"DNA":case"RNA":o=(0,a.py)("DNA");break;case"PT":o=(0,a.py)("PT")}const c={},h=A.Cn.getOrCreate(t.cell.column).getSplitter()(t.value);r()(h).filter((t=>!!t&&""!==t)).forEach((t=>{const e=c[t]||0;c[t]=e+1}));const u=T(o,c);return Array.from(u.rows).forEach((t=>{const e=t.getElementsByClassName("macromolecule-cell-comp-analysis-bar")[0].style.backgroundColor;t.cells[0].style.color=e})),e.appendChild(u),new s.Widget(e)}function T(t,e){let n=0,s=null;for(const t of Object.values(e))n+=t,s=null===s?t:Math.max(s,t);const o=s/n,r=Object.assign({},...Array.from(Object.entries(e)).sort(((t,e)=>e[1]-t[1])).map((([e,s])=>{const r=s/n,a=t.get(e),l=i.div("",{classes:"macromolecule-cell-comp-analysis-bar"});l.style.width=50*r/o+"px",l.style.backgroundColor=a;const c=i.div(`${(100*r).toFixed(2)}%`);return{[e]:i.div([l,c],{classes:"macromolecule-cell-comp-analysis-value"})}}))),a=i.tableFromMap(r);return Array.from(a.rows).forEach((t=>{const e=t.getElementsByClassName("macromolecule-cell-comp-analysis-bar")[0].style.backgroundColor;t.cells[0].style.color=e})),a}},3336:t=>{"use strict";t.exports=$},976:t=>{"use strict";t.exports=DG},4469:t=>{"use strict";t.exports=grok},701:t=>{"use strict";t.exports=rxjs},442:t=>{"use strict";t.exports=rxjs.operators},3870:t=>{"use strict";t.exports=ui},6414:t=>{"use strict";t.exports=wu}},e={};function n(i){var s=e[i];if(void 0!==s)return s.exports;var o=e[i]={id:i,loaded:!1,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}n.m=t,n.amdO={},n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.u=t=>t+".js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.hmd=t=>((t=Object.create(t)).children||(t.children=[]),Object.defineProperty(t,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+t.id)}}),t),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 t;n.g.importScripts&&(t=n.g.location+"");var e=n.g.document;if(!t&&e&&(e.currentScript&&(t=e.currentScript.src),!t)){var i=e.getElementsByTagName("script");if(i.length)for(var s=i.length-1;s>-1&&!t;)t=i[s--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t})(),n.b=document.baseURI||self.location.href,n.nc=void 0;var i=n(4955);bio=i})();
2
2
  //# sourceMappingURL=package.js.map