@datagrok/helm 2.1.22 → 2.1.23

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.
@@ -1,2 +1,2 @@
1
- var helm_test;(()=>{"use strict";var t={n:e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return t.d(n,{a:n}),n},d:(e,n)=>{for(var s in n)t.o(n,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:n[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{_package:()=>it,test:()=>ot,tests:()=>r});const n=DG,s=grok;var i=function(t,e,n,s){return new(n||(n=Promise))((function(i,o){function r(t){try{l(s.next(t))}catch(t){o(t)}}function a(t){try{l(s.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((s=s.apply(t,e||[])).next())}))};const o=3e4,r={},a="Auto Tests",l={};let c;var u;!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(u||(u={}));class d{constructor(t,e){this.catchUnhandled=!0,this.report=!1,void 0!==t&&(this.catchUnhandled=t),void 0!==e&&(this.report=e)}}class h{constructor(t,e,n,s){var r;this.category=t,this.name=e,null!=s||(s={}),null!==(r=s.timeout)&&void 0!==r||(s.timeout=o),this.options=s,this.test=()=>i(this,void 0,void 0,(function*(){return new Promise(((t,e)=>i(this,void 0,void 0,(function*(){let s="";try{s=yield n()}catch(t){e(t)}t(s)}))))}))}}function C(t,e,n){null==r[c]&&(r[c]={}),null==r[c].tests&&(r[c].tests=[]),r[c].tests.push(new h(c,t,e,n))}function f(t,e=!0,n){if(n=n?`${n}, `:"",t!==e)throw new Error(`${n}Expected "${e}", got "${t}"`)}function g(t,e,n=.001,s){if(t===Number.POSITIVE_INFINITY&&e===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY&&e===Number.NEGATIVE_INFINITY||t===Number.NaN&&e===Number.NaN||isNaN(t)&&isNaN(e))return;const i=Math.abs(t-e)<n;if(f(i,!0,`${null!=s?s:""} (tolerance = ${n})`),!i)throw new Error(`Expected ${e}, got ${t} (tolerance = ${n})`)}function p(t,e){for(const[n,s]of Object.entries(e)){if(!t.hasOwnProperty(n))throw new Error(`Expected property "${n}" not found`);const e=t[n];if(e instanceof Array&&s instanceof Array)m(e,s);else if(e instanceof Object&&s instanceof Object)p(e,s);else if(Number.isFinite(e)&&Number.isFinite(s))g(e,s);else if(e!=s)throw new Error(`Expected (${s}) for key '${n}', got (${e})`)}}function m(t,e){const n=t.length,s=e.length;if(n!=s)throw new Error(`Arrays are of different length: actual array length is ${n} and expected array length is ${s}`);for(let s=0;s<n;s++)if(t[s]instanceof Array&&e[s]instanceof Array)m(t[s],e[s]);else if(t[s]instanceof Object&&e[s]instanceof Object)p(t[s],e[s]);else if(t[s]!=e[s])throw new Error(`Expected ${e[s]} at position ${s}, got ${t[s]}`)}function A(t,e,n){var s;c=t,e(),r[c]&&(r[c].clear=null===(s=null==n?void 0:n.clear)||void 0===s||s,r[c].timeout=null==n?void 0:n.timeout)}function y(t){null==r[c]&&(r[c]={}),r[c].before=t}function T(t){null==r[c]&&(r[c]={}),r[c].after=t}function E(t,e){return t.replace(new RegExp(e.name,"gi"),e.nqName)}function b(t,e,r,a){var l,c,u,d,h;return i(this,void 0,void 0,(function*(){let i;const C=null!=e&&t.name.toLowerCase()!==e.toLowerCase(),f=(null===(l=t.options)||void 0===l?void 0:l.skipReason)||C,g=C?"skipped":null===(c=t.options)||void 0===c?void 0:c.skipReason;f||console.log(`Started ${t.category} ${t.name}`);const p=new Date;try{if(f)i={success:!0,result:g,ms:0,skipped:!0};else{let e=(null===(u=t.options)||void 0===u?void 0:u.timeout)===o&&r?r:null===(d=t.options)||void 0===d?void 0:d.timeout;e=n.Test.isInBenchmark&&e===o?108e5:e,i={success:!0,result:null!==(h=yield O(t.test,e))&&void 0!==h?h:"OK",ms:0,skipped:!1}}}catch(t){i={success:!1,result:t.toString(),ms:0,skipped:!1}}const m=new Date;if(i.ms=m-p,f||console.log(`Finished ${t.category} ${t.name} for ${i.ms} ms`),i.category=t.category,i.name=t.name,!C){let e={success:i.success,result:i.result,ms:i.ms,skipped:i.skipped,type:"package",packageName:a,category:t.category,test:t.name};if(i.result.constructor==Object){const t=Object.keys(i.result).reduce(((t,e)=>Object.assign(Object.assign({},t),{["result."+e]:i.result[e]})),{});e=Object.assign(Object.assign({},e),t)}s.log.usage(`${a}: ${t.category}: ${t.name}`,e,`test-package ${a}: ${t.category}: ${t.name}`)}return i}))}function N(t){return i(this,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,t)))}))}function O(t,e){return i(this,void 0,void 0,(function*(){let n=null;const s=new Promise(((t,s)=>{n=setTimeout((()=>{s("EXECUTION TIMEOUT")}),e)}));try{return yield Promise.race([t(),s])}finally{n&&clearTimeout(n)}}))}function I(t){t=v(t,"$")[0];const e=[];if(!scil.Utils.isNullOrEmpty(t)){const n=v(t,"|");for(let s=0;s<n.length;++s){let i=(t=x(n[s]).str).indexOf("{");i=(t=t.substring(i+1)).indexOf("}");const o=v(t=t.substring(0,i),".");for(const t of o)if(t&&""!==t)if(t.startsWith("[")&&t.includes("]")){const n=t.substring(1,t.indexOf("]"));e.push(n);const s=t.substring(t.indexOf("]")+1);o.push(s)}else if(t.includes("[")&&t.endsWith("]")){const n=t.substring(t.lastIndexOf("[")+1,t.length-1);e.push(n);const s=t.substring(0,t.lastIndexOf("["));o.push(s)}else if(t.includes("(")&&t.includes(")")){const e=t.substring(0,t.indexOf("(")),n=t.substring(t.lastIndexOf(")")+1),s=[e,t.substring(e.length+1,t.length-n.length-1),n];for(const t of s)o.push(t)}else e.push(t)}}return e}function v(t,e){const n=[];let s="",i=0,o=0,r=0,a=0;for(let l=0;l<t.length;++l){let c=t.substring(l,l+1);if(c==e&&0==o&&0==i&&0==r&&0==a)n.push(s),s="";else{if(s+=c,a>0&&"\\"==c&&l+1<t.length){++l;const e=t.substring(l,l+1);s+=e,c+=e}'"'==c?l>0&&"\\"==t.substring(l-1,l)||(a=0==a?1:0):"["==c?++o:"]"==c?--o:"("==c?++i:")"==c?--i:"{"==c?++r:"}"==c&&--r}}return n.push(s),n}function x(t){const e=P(t,'"');if(null!=e.tag)return e;const n=P(t,"'");return{tag:e.tag,repeat:n.tag,str:n.str}}function P(t,e){let n=null;if(scil.Utils.endswith(t,e)){let s=t.length-1;for(;s>0&&(s=t.lastIndexOf(e,s-1),!(s<=0||"\\"!=t.substring(s-1,s))););s>0&&s<t.length-1&&(n=t.substring(s+1,t.length-1),t=t.substring(0,s))}return null!=n&&(n=function(t){return scil.Utils.isNullOrEmpty(t)?t:t.replace(/[\\]./g,(function(t){switch(t){case"\\r":return"\r";case"\\n":return"\n";case"\\t":return"\t";default:return t.substring(1)}}))}(n.replace(new RegExp("\\"+e,"g"),e))),{tag:n,str:t}}var _,w,S=function(t,e,n,s){return new(n||(n=Promise))((function(i,o){function r(t){try{l(s.next(t))}catch(t){o(t)}}function a(t){try{l(s.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((s=s.apply(t,e||[])).next())}))};A("Helm",(()=>{const t=[["L-hArg(Et,Et)","E","F","G","C","E"],["L-hArg(Et,Et)","L-hArg(Et,Et)","E","F","G"],["dhp","m1A","p","r","T","p","r","T","p","r","G","p"],["r","mo6pur","p","r","T","p","r","T","p","r","G","p"],["afhna","mo6pur","36SS","r","T","p"]],e=["comples-monomer","complex-monomer+side-chain","complex-monomer+side-chain-RNA","complex-side-chain","complex+side-chain+linker"];C("parseHelm",(()=>S(void 0,void 0,void 0,(function*(){const t=[["meI","hHis","Aca","N","T","dK","Thr_PO3H2","D-Tyr_Et","Aze","dV","E","Phe_4Me"],["A","C","T","G","W","E","Q"],["R","U","P","T","A"],["A","*","G","C"]],e=["PEPTIDE1{meI.hHis.Aca.N.T.dK.Thr_PO3H2.Aca.D-Tyr_Et.Aze.dV.E.N.dV.Phe_4Me}$$$","PEPTIDE1{A.C.T.G.C.T.W.G.T.W.E.C.W.C.Q.W}|PEPTIDE2{A.C.T.G.C.T.W.G.T.W.E.Q}$PEPTIDE1,PEPTIDE1,5:R3-14:R3|PEPTIDE2,PEPTIDE1,2:R3-12:R3$$$","RNA1{R(U)P.R(T)P}|RNA2{P.R(A)P.R(A)}$RNA1,RNA2,2:pair-6:pair|RNA1,RNA2,5:pair-3:pair$$$","PEPTIDE1{A.*.G.C}$$$$V2.0"];for(let n=0;n<e.length;++n){const s=new Set(I(e[n])),i=Array.from(s);f(JSON.stringify(i),JSON.stringify(t[n]))}})))),["PEPTIDE1{[L-hArg(Et,Et)].E.F.G}|PEPTIDE2{C.E}$PEPTIDE1,PEPTIDE2,2:R3-1:R1$$$V2.0","PEPTIDE1{[L-hArg(Et,Et)]([L-hArg(Et,Et)]).E.F.G}$$$$","RNA1{[dhp]([m1A])p.r(T)p.r(T)p.r(G)p}$$$$V2.0","RNA1{r([mo6pur])p.r(T)p.r(T)p.r(G)p}$$$$V2.0","RNA1{[afhna]([mo6pur])[36SS].r(T)p}$$$$V2.0"].forEach(((n,s)=>{C(e[s],(()=>S(void 0,void 0,void 0,(function*(){const e=I(n);e.sort();const i=t[s];i.sort(),m(e,i)}))))}))})),new RegExp("[rd]\\((\\w)\\)p?","g"),wu;class L{constructor(t,e,n){this.name=t,this.alphabet=e,this.cutoff=n}}(w=_||(_={})).FASTA="fasta",w.SEPARATOR="separator",w.HELM="helm";const M=new class{constructor(){this.fasta={peptide:new Set(["G","L","Y","S","E","Q","D","N","F","A","K","R","H","C","V","P","W","I","M","T"]),dna:new Set(["A","C","G","T"]),rna:new Set(["A","C","G","U"])}}};new L("PT",M.fasta.peptide,.5),new L("DNA",M.fasta.dna,.55),new L("RNA",M.fasta.rna,.55),Float32Array;class H{static makePalette(t,e=!1,n=H){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]}}H.undefinedColor="rgb(100,100,100)",H.colourPalette={orange:["rgb(255,187,120)","rgb(245,167,100)","rgb(235,137,70)","rgb(205, 111, 71)"],all_green:["rgb(44,160,44)","rgb(74,160,74)","rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)","rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],all_blue:["rgb(31,119,180)","rgb(23,190,207)","rgb(122, 102, 189)","rgb(158,218,229)","rgb(141, 124, 217)","rgb(31, 120, 150)"],magenta:["rgb(162,106,192)","rgb(197,165,224)","rgb(208,113,218)"],red:["rgb(214,39,40)","rgb(255,152,150)"],st_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(31,119,180)"],dark_blue:["rgb(31,119,180)","rgb(31, 120, 150)"],light_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(108, 218, 229)","rgb(23,190,227)"],lilac_blue:["rgb(124,102,211)","rgb(149,134,217)","rgb(97, 81, 150)"],dark_green:["rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)"],green:["rgb(44,160,44)","rgb(74,160,74)"],light_green:["rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],st_green:["rgb(44,160,44)","rgb(152,223,138)","rgb(39, 174, 96)","rgb(74,160,74)"],pink:["rgb(247,182,210)"],brown:["rgb(140,86,75)","rgb(102, 62, 54)"],gray:["rgb(127,127,127)","rgb(199,199,199)","rgb(196,156,148)","rgb(222, 222, 180)"],yellow:["rgb(188,189,34)"],white:["rgb(230,230,230)"]};class D extends H{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,D)),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,D)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new D({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 D.aaSynonyms?D.aaSynonyms[t]:t;return super.get(e)}}D.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class k{static getPalette(t="grok"){switch(t){case"grok":return D.GrokGroups;case"lesk":return D.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,n="",s="";for(const i of t)"("==i?e++:")"==i?e--:e?n+=i:s+=i;return isNaN(parseInt(n))?[s,n]:[s,""]}static getColorAAPivot(t="",e="grok"){const n=this.getPalette(e);let[s,i]=this.getInnerOuter(t);if(s=s.length>6?`${s.slice(0,3)}...`:s,i=i.length>6?`${i.slice(0,3)}...`:i,1==t.length||"("==t[1]){const e=t[0]?.toUpperCase();return e in n?[n.get(e),e,i,1]:[this.undefinedColor,s,i,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,i,2]:[this.undefinedColor,s,i,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,i,3]:[this.undefinedColor,s,i,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,i,4]:[this.undefinedColor,s,i,4]}return[this.undefinedColor,s,i,0]}}k.SemType="Aminoacids",k.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",k.undefinedColor="rgb(100,100,100)",k.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"},k.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"},k.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(*)*"},k.AAFullNames={Ala:"A",Arg:"R",Asn:"N",Asp:"D",Cys:"C",Gln:"Q",Glu:"E",Gly:"G",His:"H",Ile:"I",Leu:"L",Lys:"K",Met:"M",Phe:"F",Pro:"P",Ser:"S",Thr:"T",Trp:"W",Tyr:"Y",Val:"V"};class F{}F.SemType="Nucleotides",F.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",F.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"};class R extends class{}{static buildPalette(){return[].concat(...Object.values(H.colourPalette))}get(t){const e=class{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}}.hashCode(t)%R.palette.length;return function(t){if(null==t)return"rgb(100,100,100)";const e=n.Color.fromHtml(t),s=n.Color.g(e),i=n.Color.r(e),o=n.Color.b(e),r=Math.sqrt(Math.pow(0-i,2)+Math.pow(0-s,2)+Math.pow(0-o,2));return r>210?`rgb(${i/r*210},${s/r*210},${o/r*210})`:n.Color.toRgb(e)}(R.palette[e])}}R.palette=R.buildPalette();new Uint32Array(65536);var G,B;async function V(){const t=n.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()}(B=G||(G={})).HAMMING="Hamming",B.LEVENSHTEIN="Levenshtein",B.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",B.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance",G.HAMMING,G.LEVENSHTEIN,G.NEEDLEMANN_WUNSCH,G.MONOMER_CHEMICAL_DISTANCE,new class{constructor(){this.uhTemp=`units-handler.${n.SEMTYPE.MACROMOLECULE}`}},_.FASTA,_.SEPARATOR,_.HELM;const U="Libraries",W={explicit:["HELMCoreLibrary.json"],exclude:[]};let j=Promise.resolve();async function Y(){let t;return j=j.then((async()=>{const e=await s.dapi.userDataStorage.getValue(U,"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 j,t}async function Q(t){j=j.then((async()=>{console.debug(`Bio: setUserLibSettings()\n${JSON.stringify(t,void 0,2)}`),await s.dapi.userDataStorage.postValue(U,"Settings",JSON.stringify(t),!0)})),await j}async function z(){await Q(W)}var K=function(t,e,n,s){return new(n||(n=Promise))((function(i,o){function r(t){try{l(s.next(t))}catch(t){o(t)}}function a(t){try{l(s.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((s=s.apply(t,e||[])).next())}))};A("findMonomers",(()=>{let t,e;y((()=>K(void 0,void 0,void 0,(function*(){t=yield V(),e=yield Y(),yield z(),yield t.loadLibraries(!0)})))),T((()=>K(void 0,void 0,void 0,(function*(){yield Q(e),yield t.loadLibraries(!0)}))));const n={withoutMissed:{test:"PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et}$$$$",tgt:new Set},withMissed:{test:"PEPTIDE1{meI.missed2.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et}$$$$",tgt:new Set(["missed2"])}};for(const[t,e]of Object.entries(n))C(t,(()=>K(void 0,void 0,void 0,(function*(){s(e.test,e.tgt)}))));function s(t,e){p(function(t){const e=Object.keys(org.helm.webeditor.monomerTypeList()),n=[],s=[];for(let t=0;t<e.length;t++)n.push(new scil.helm.Monomers.getMonomerSet(e[t])),Object.keys(n[t]).forEach((e=>{s.push(n[t][e].id)}));return new Set(t.filter((t=>!s.includes(t))))}(I(t)),e)}}));const J=$;var X,q=t.n(J),Z=function(t,e,n,s){return new(n||(n=Promise))((function(i,o){function r(t){try{l(s.next(t))}catch(t){o(t)}}function a(t){try{l(s.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((s=s.apply(t,e||[])).next())}))};A("renderers",(()=>{C("missedInLib",(()=>Z(void 0,void 0,void 0,(function*(){yield function(){return Z(this,void 0,void 0,(function*(){const t=yield s.dapi.files.readCsv("System:AppData/Helm/tests/sample_HELM-missedInLib.csv"),e=t.getCol("HELM"),o=s.shell.addTableView(t);yield function(t,e="Timeout exceeded",n=500,s=50){return i(this,void 0,void 0,(function*(){return new Promise(((i,o)=>{setTimeout((()=>{clearInterval(r),o(new Error(e))}),n);const r=setInterval((()=>{t()&&(clearInterval(r),i())}),s)}))}))}((()=>q()(o.root).find(".d4-grid canvas").length>0),"Table view canvas not found",100),f(e.semType,n.SEMTYPE.MACROMOLECULE),f(e.getTag(n.TAGS.UNITS),_.HELM),f(e.getTag(n.TAGS.CELL_RENDERER),"helm");const r=e.getTag(".cell-renderer.render.error");if(r){const t=JSON.parse(r),e=new Error(t.message);throw e.stack=t.stack,e}}))}()}))))}));class tt extends class{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 s=this.isWhitespace(n)?e:e-1;for(let t=0;t<s;t++)n=this.getNextColumnIdx(n);return n}parseAtomTypes(){const t=this.atomCount,e=new Array(t);let n=this.getAtomBlockIdx();for(let s=0;s<t;s++)n=this.shiftIdxToAtomType(n),e[s]=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 s=this.getAtomBlockIdx();for(let i=0;i<this.atomCount;i++){s=this.shiftIdxToXColumn(s);for(const o of[t,e,n])o[i]=this.parseFloatValue(s),s=this.getNextColumnIdx(s);s=this.getNextLineIdx(s)}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 s=new Uint16Array(2);s[0]=this.parseIntValue(e),e=this.getNextColumnIdx(e),s[1]=this.parseIntValue(e),t[n]=s,e=this.getNextLineIdx(e)}return t}parseBondTypes(){const t=this.bondCount,e=new Uint16Array(t);let n=this.getBondBlockIdx();for(let s=0;s<t;s++)n=this.shiftIdxToBondType(n),e[s]=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))}}{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 s=0;s<e;s++){if(n=this.shiftIdxToAtomType(n),t(this.fileContent.charCodeAt(n),n))return!0;n=this.getNextLineIdx(n)}return!1}}!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"}(X||(X={}));class et extends tt{constructor(t){super(t)}static validate(t){return-1!==t.indexOf(X.HEADER)&&-1!==t.indexOf(X.END)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,X.ATOM_TYPE_COL)}getCountsLineIdx(){let t=0;for(let e=0;e<X.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,X.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,X.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+X.NUM_OF_COUNTS_DIGITS;const n=parseInt(this.fileContent.substring(t,e));return t=e,e+=X.NUM_OF_COUNTS_DIGITS,{atomCount:n,bondCount:parseInt(this.fileContent.substring(t,e))}}}class nt extends tt{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))}}}var st=function(t,e,n,s){return new(n||(n=Promise))((function(i,o){function r(t){try{l(s.next(t))}catch(t){o(t)}}function a(t){try{l(s.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((s=s.apply(t,e||[])).next())}))};A("getMolfiles",(()=>{let t,e;y((()=>st(void 0,void 0,void 0,(function*(){t=yield V(),e=yield Y(),yield z(),yield t.loadLibraries(!0)})))),T((()=>st(void 0,void 0,void 0,(function*(){yield Q(e),yield t.loadLibraries(!0)})))),C("linear1",(()=>st(void 0,void 0,void 0,(function*(){const t=n.DataFrame.fromCsv("Helm, atoms, bonds\nPEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Tyr_ab-dehydroMe.dV}$$$$,11,10\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.D-Chg.dV}$$$$,11,10\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$$,9,8"),e=t.getCol("Helm"),o=s.shell.addTableView(t),r=yield s.functions.call("Helm:getMolfiles",{col:e});yield N(100),yield function(t,e,n,s=0){return i(this,void 0,void 0,(function*(){let i;return new Promise(((o,r)=>{i=t.subscribe((t=>{try{e(t)}catch(t){r(t)}i.unsubscribe(),o("OK")})),setTimeout((()=>{i.unsubscribe(),r("timeout")}),s),n()}))}))}(o.grid.onAfterDrawContent,(()=>{}),(()=>{o.grid.invalidate()})),f(r.length,e.length);const a=r.toList().map((t=>class{constructor(){}static getInstance(t){if(et.validate(t))return new et(t);if(nt.validate(t))return new nt(t);throw new Error("Malformed molfile")}}.getInstance(t)));m(a.map((t=>t.atomCount)),t.getCol("atoms").toList()),m(a.map((t=>t.bondCount)),t.getCol("bonds").toList())}))))}));const it=new n.Package;function ot(t,e,o){return c=this,u=void 0,f=function*(){const c=yield function(t){var e,o,c,u,C;return i(this,void 0,void 0,(function*(){const f=null===(o=null===(e=s.functions.getCurrentCall())||void 0===e?void 0:e.func)||void 0===o?void 0:o.package;yield function(t,e){return i(this,void 0,void 0,(function*(){if(l[t])return;const e=r;if(void 0!==e["Auto Tests"]||Object.keys(e).find((t=>t.startsWith(a))))return void(l[t]=!0);const n=[],o=yield s.dapi.functions.filter(`package.id = "${t}"`).list(),c=new RegExp(/skip:\s*([^,\s]+)|wait:\s*(\d+)|cat:\s*([^,\s]+)/g);for(const t of o){const o=t.options.test;if(o&&Array.isArray(o)&&o.length)for(let r=0;r<o.length;r++){const l=o[r].matchAll(c),u={};Array.from(l).forEach((t=>{t[0].startsWith("skip")?u.skip=t[1]:t[0].startsWith("wait")?u.wait=parseInt(t[2]):t[0].startsWith("cat")&&(u.cat=t[3])}));const d=new h(a,1===o.length?t.name:`${t.name} ${r+1}`,(()=>i(this,void 0,void 0,(function*(){const e=yield s.functions.eval(E(o[r],t));if(u.wait&&(yield N(u.wait)),"boolean"==typeof e&&!e)throw`Failed: ${o[r]}, expected true, got ${e}`}))),{skipReason:u.skip});if(u.cat){const t="Auto Tests: "+u.cat;d.category=t,void 0===e[t]&&(e[t]={tests:[],clear:!0}),e[t].tests.push(d)}else n.push(d)}}l[t]=!0,n.length&&(e["Auto Tests"]={tests:n,clear:!0})}))}(f.id);const g=[];console.log("Running tests"),null!=t||(t={}),null!==(c=(C=t).testContext)&&void 0!==c||(C.testContext=new d),s.shell.lastError="";for(const[e,i]of Object.entries(r)){if(null!=(null==t?void 0:t.category)&&!e.toLowerCase().startsWith(null==t?void 0:t.category.toLowerCase()))continue;console.log(`Started ${e} category`);try{i.before&&(yield i.before())}catch(t){i.beforeStatus=t.toString()}const o=null!==(u=i.tests)&&void 0!==u?u:[],r=[];if(i.clear)for(let e=0;e<o.length;e++)r.push(yield b(o[e],null==t?void 0:t.test,i.timeout,f.name)),s.shell.closeAll(),n.Balloon.closeAll();else for(let e=0;e<o.length;e++)r.push(yield b(o[e],null==t?void 0:t.test,i.timeout,f.name));const a=(yield Promise.all(r)).filter((t=>"skipped"!=t.result));try{i.after&&(yield i.after())}catch(t){i.afterStatus=t.toString()}i.afterStatus&&a.push({category:e,name:"init",result:i.afterStatus,success:!1,ms:0,skipped:!1}),i.beforeStatus&&a.push({category:e,name:"init",result:i.beforeStatus,success:!1,ms:0,skipped:!1}),g.push(...a)}if(t.testContext.catchUnhandled&&(yield N(1e3),s.shell.lastError.length>0&&g.push({category:"Unhandled exceptions",name:"exceptions",result:s.shell.lastError,success:!1,ms:0,skipped:!1})),t.testContext.report){const t=new n.Logger,e=g.filter((t=>t.success)).length,s=g.filter((t=>t.skipped)).length,i=g.filter((t=>!t.success)),o="Package @package tested: @successful successful, @skipped skipped, @failed failed tests",r={successful:e,skipped:s,failed:i.length,package:f};for(const t of i)Object.assign(r,{[`${t.category} | ${t.name}`]:t.result});t.log(o,r,"package-tested")}return g}))}({category:t,test:e,testContext:o});return n.DataFrame.fromObjects(c)},new((C=void 0)||(C=Promise))((function(t,e){function n(t){try{i(f.next(t))}catch(t){e(t)}}function s(t){try{i(f.throw(t))}catch(t){e(t)}}function i(e){var i;e.done?t(e.value):(i=e.value,i instanceof C?i:new C((function(t){t(i)}))).then(n,s)}i((f=f.apply(c,u||[])).next())}));var c,u,C,f}helm_test=e})();
1
+ var helm_test;(()=>{"use strict";var t={n:e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return t.d(n,{a:n}),n},d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{_package:()=>ot,test:()=>rt,tests:()=>r});const n=DG,i=grok;var s=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())}))};const o=3e4,r={},a="Auto Tests",l={};let c;var u;!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(u||(u={}));class d{constructor(t,e){this.catchUnhandled=!0,this.report=!1,void 0!==t&&(this.catchUnhandled=t),void 0!==e&&(this.report=e)}}class h{constructor(t,e,n,i){var r;this.category=t,this.name=e,null!=i||(i={}),null!==(r=i.timeout)&&void 0!==r||(i.timeout=o),this.options=i,this.test=()=>s(this,void 0,void 0,(function*(){return new Promise(((t,e)=>s(this,void 0,void 0,(function*(){let i="";try{i=yield n()}catch(t){e(t)}t(i)}))))}))}}function C(t,e,n){null==r[c]&&(r[c]={}),null==r[c].tests&&(r[c].tests=[]),r[c].tests.push(new h(c,t,e,n))}function f(t,e=!0,n){if(n=n?`${n}, `:"",t!==e)throw new Error(`${n}Expected "${e}", got "${t}"`)}function g(t,e,n=.001,i){if(t===Number.POSITIVE_INFINITY&&e===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY&&e===Number.NEGATIVE_INFINITY||t===Number.NaN&&e===Number.NaN||isNaN(t)&&isNaN(e))return;const s=Math.abs(t-e)<n;if(f(s,!0,`${null!=i?i:""} (tolerance = ${n})`),!s)throw new Error(`Expected ${e}, got ${t} (tolerance = ${n})`)}function p(t,e){for(const[n,i]of Object.entries(e)){if(!t.hasOwnProperty(n))throw new Error(`Expected property "${n}" not found`);const e=t[n];if(e instanceof Array&&i instanceof Array)m(e,i);else if(e instanceof Object&&i instanceof Object)p(e,i);else if(Number.isFinite(e)&&Number.isFinite(i))g(e,i);else if(e!=i)throw new Error(`Expected (${i}) for key '${n}', got (${e})`)}}function m(t,e){const n=t.length,i=e.length;if(n!=i)throw new Error(`Arrays are of different length: actual array length is ${n} and expected array length is ${i}`);for(let i=0;i<n;i++)if(t[i]instanceof Array&&e[i]instanceof Array)m(t[i],e[i]);else if(t[i]instanceof Object&&e[i]instanceof Object)p(t[i],e[i]);else if(t[i]!=e[i])throw new Error(`Expected ${e[i]} at position ${i}, got ${t[i]}`)}function A(t,e,n){var i;c=t,e(),r[c]&&(r[c].clear=null===(i=null==n?void 0:n.clear)||void 0===i||i,r[c].timeout=null==n?void 0:n.timeout)}function y(t){null==r[c]&&(r[c]={}),r[c].before=t}function T(t){null==r[c]&&(r[c]={}),r[c].after=t}function E(t,e){return t.replace(new RegExp(e.name,"gi"),e.nqName)}function b(t,e,r,a){var l,c,u,d,h;return s(this,void 0,void 0,(function*(){let s;const C=null!=e&&t.name.toLowerCase()!==e.toLowerCase(),f=(null===(l=t.options)||void 0===l?void 0:l.skipReason)||C,g=C?"skipped":null===(c=t.options)||void 0===c?void 0:c.skipReason;f||console.log(`Started ${t.category} ${t.name}`);const p=new Date;try{if(f)s={success:!0,result:g,ms:0,skipped:!0};else{let e=(null===(u=t.options)||void 0===u?void 0:u.timeout)===o&&r?r:null===(d=t.options)||void 0===d?void 0:d.timeout;e=n.Test.isInBenchmark&&e===o?108e5:e,s={success:!0,result:null!==(h=yield O(t.test,e))&&void 0!==h?h:"OK",ms:0,skipped:!1}}}catch(t){s={success:!1,result:t.toString(),ms:0,skipped:!1}}const m=new Date;if(s.ms=m-p,f||console.log(`Finished ${t.category} ${t.name} for ${s.ms} ms`),s.category=t.category,s.name=t.name,!C){let e={success:s.success,result:s.result,ms:s.ms,skipped:s.skipped,type:"package",packageName:a,category:t.category,test:t.name};if(s.result.constructor==Object){const t=Object.keys(s.result).reduce(((t,e)=>Object.assign(Object.assign({},t),{["result."+e]:s.result[e]})),{});e=Object.assign(Object.assign({},e),t)}i.log.usage(`${a}: ${t.category}: ${t.name}`,e,`test-package ${a}: ${t.category}: ${t.name}`)}return s}))}function N(t){return s(this,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,t)))}))}function O(t,e){return s(this,void 0,void 0,(function*(){let n=null;const i=new Promise(((t,i)=>{n=setTimeout((()=>{i("EXECUTION TIMEOUT")}),e)}));try{return yield Promise.race([t(),i])}finally{n&&clearTimeout(n)}}))}function v(t){t=I(t,"$")[0];const e=[];if(!scil.Utils.isNullOrEmpty(t)){const n=I(t,"|");for(let i=0;i<n.length;++i){let s=(t=x(n[i]).str).indexOf("{");s=(t=t.substring(s+1)).indexOf("}");const o=I(t=t.substring(0,s),".");for(const t of o)if(t&&""!==t)if(t.startsWith("[")&&t.includes("]")){const n=t.substring(1,t.indexOf("]"));e.push(n);const i=t.substring(t.indexOf("]")+1);o.push(i)}else if(t.includes("[")&&t.endsWith("]")){const n=t.substring(t.lastIndexOf("[")+1,t.length-1);e.push(n);const i=t.substring(0,t.lastIndexOf("["));o.push(i)}else if(t.includes("(")&&t.includes(")")){const e=t.substring(0,t.indexOf("(")),n=t.substring(t.lastIndexOf(")")+1),i=[e,t.substring(e.length+1,t.length-n.length-1),n];for(const t of i)o.push(t)}else e.push(t)}}return e}function I(t,e){const n=[];let i="",s=0,o=0,r=0,a=0;for(let l=0;l<t.length;++l){let c=t.substring(l,l+1);if(c==e&&0==o&&0==s&&0==r&&0==a)n.push(i),i="";else{if(i+=c,a>0&&"\\"==c&&l+1<t.length){++l;const e=t.substring(l,l+1);i+=e,c+=e}'"'==c?l>0&&"\\"==t.substring(l-1,l)||(a=0==a?1:0):"["==c?++o:"]"==c?--o:"("==c?++s:")"==c?--s:"{"==c?++r:"}"==c&&--r}}return n.push(i),n}function x(t){const e=w(t,'"');if(null!=e.tag)return e;const n=w(t,"'");return{tag:e.tag,repeat:n.tag,str:n.str}}function w(t,e){let n=null;if(scil.Utils.endswith(t,e)){let i=t.length-1;for(;i>0&&(i=t.lastIndexOf(e,i-1),!(i<=0||"\\"!=t.substring(i-1,i))););i>0&&i<t.length-1&&(n=t.substring(i+1,t.length-1),t=t.substring(0,i))}return null!=n&&(n=function(t){return scil.Utils.isNullOrEmpty(t)?t:t.replace(/[\\]./g,(function(t){switch(t){case"\\r":return"\r";case"\\n":return"\n";case"\\t":return"\t";default:return t.substring(1)}}))}(n.replace(new RegExp("\\"+e,"g"),e))),{tag:n,str:t}}var P,_,S=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())}))};A("Helm",(()=>{const t=[["L-hArg(Et,Et)","E","F","G","C","E"],["L-hArg(Et,Et)","L-hArg(Et,Et)","E","F","G"],["dhp","m1A","p","r","T","p","r","T","p","r","G","p"],["r","mo6pur","p","r","T","p","r","T","p","r","G","p"],["afhna","mo6pur","36SS","r","T","p"]],e=["comples-monomer","complex-monomer+side-chain","complex-monomer+side-chain-RNA","complex-side-chain","complex+side-chain+linker"];C("parseHelm",(()=>S(void 0,void 0,void 0,(function*(){const t=[["meI","hHis","Aca","N","T","dK","Thr_PO3H2","D-Tyr_Et","Aze","dV","E","Phe_4Me"],["A","C","T","G","W","E","Q"],["R","U","P","T","A"],["A","*","G","C"]],e=["PEPTIDE1{meI.hHis.Aca.N.T.dK.Thr_PO3H2.Aca.D-Tyr_Et.Aze.dV.E.N.dV.Phe_4Me}$$$","PEPTIDE1{A.C.T.G.C.T.W.G.T.W.E.C.W.C.Q.W}|PEPTIDE2{A.C.T.G.C.T.W.G.T.W.E.Q}$PEPTIDE1,PEPTIDE1,5:R3-14:R3|PEPTIDE2,PEPTIDE1,2:R3-12:R3$$$","RNA1{R(U)P.R(T)P}|RNA2{P.R(A)P.R(A)}$RNA1,RNA2,2:pair-6:pair|RNA1,RNA2,5:pair-3:pair$$$","PEPTIDE1{A.*.G.C}$$$$V2.0"];for(let n=0;n<e.length;++n){const i=new Set(v(e[n])),s=Array.from(i);f(JSON.stringify(s),JSON.stringify(t[n]))}})))),["PEPTIDE1{[L-hArg(Et,Et)].E.F.G}|PEPTIDE2{C.E}$PEPTIDE1,PEPTIDE2,2:R3-1:R1$$$V2.0","PEPTIDE1{[L-hArg(Et,Et)]([L-hArg(Et,Et)]).E.F.G}$$$$","RNA1{[dhp]([m1A])p.r(T)p.r(T)p.r(G)p}$$$$V2.0","RNA1{r([mo6pur])p.r(T)p.r(T)p.r(G)p}$$$$V2.0","RNA1{[afhna]([mo6pur])[36SS].r(T)p}$$$$V2.0"].forEach(((n,i)=>{C(e[i],(()=>S(void 0,void 0,void 0,(function*(){const e=v(n);e.sort();const s=t[i];s.sort(),m(e,s)}))))}))})),new RegExp("[rd]\\((\\w)\\)p?","g"),wu;class M{constructor(t,e,n){this.name=t,this.alphabet=e,this.cutoff=n}}(_=P||(P={})).FASTA="fasta",_.SEPARATOR="separator",_.HELM="helm";const L=new class{constructor(){this.fasta={peptide:new Set(["G","L","Y","S","E","Q","D","N","F","A","K","R","H","C","V","P","W","I","M","T"]),dna:new Set(["A","C","G","T"]),rna:new Set(["A","C","G","U"])}}};new M("PT",L.fasta.peptide,.5),new M("DNA",L.fasta.dna,.55),new M("RNA",L.fasta.rna,.55),Float32Array;class H{static makePalette(t,e=!1,n=H){const i={};return t.forEach((t=>{const n=t[0],s=t[1];n.forEach(((t,n)=>{i[t]=this.colourPalette[s][e?0:n]}))})),new n(i)}constructor(t){this._palette=t}get(t){return this._palette[t]}}H.undefinedColor="rgb(100,100,100)",H.colourPalette={orange:["rgb(255,187,120)","rgb(245,167,100)","rgb(235,137,70)","rgb(205, 111, 71)"],all_green:["rgb(44,160,44)","rgb(74,160,74)","rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)","rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],all_blue:["rgb(31,119,180)","rgb(23,190,207)","rgb(122, 102, 189)","rgb(158,218,229)","rgb(141, 124, 217)","rgb(31, 120, 150)"],magenta:["rgb(162,106,192)","rgb(197,165,224)","rgb(208,113,218)"],red:["rgb(214,39,40)","rgb(255,152,150)"],st_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(31,119,180)"],dark_blue:["rgb(31,119,180)","rgb(31, 120, 150)"],light_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(108, 218, 229)","rgb(23,190,227)"],lilac_blue:["rgb(124,102,211)","rgb(149,134,217)","rgb(97, 81, 150)"],dark_green:["rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)"],green:["rgb(44,160,44)","rgb(74,160,74)"],light_green:["rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],st_green:["rgb(44,160,44)","rgb(152,223,138)","rgb(39, 174, 96)","rgb(74,160,74)"],pink:["rgb(247,182,210)"],brown:["rgb(140,86,75)","rgb(102, 62, 54)"],gray:["rgb(127,127,127)","rgb(199,199,199)","rgb(196,156,148)","rgb(222, 222, 180)"],yellow:["rgb(188,189,34)"],white:["rgb(230,230,230)"]};class D extends H{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,D)),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,D)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new D({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 D.aaSynonyms?D.aaSynonyms[t]:t;return super.get(e)}}D.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class k{static getPalette(t="grok"){switch(t){case"grok":return D.GrokGroups;case"lesk":return D.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]}}k.SemType="Aminoacids",k.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",k.undefinedColor="rgb(100,100,100)",k.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"},k.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"},k.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(*)*"},k.AAFullNames={Ala:"A",Arg:"R",Asn:"N",Asp:"D",Cys:"C",Gln:"Q",Glu:"E",Gly:"G",His:"H",Ile:"I",Leu:"L",Lys:"K",Met:"M",Phe:"F",Pro:"P",Ser:"S",Thr:"T",Trp:"W",Tyr:"Y",Val:"V"};class F{}F.SemType="Nucleotides",F.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",F.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"};class R extends class{}{static buildPalette(){return[].concat(...Object.values(H.colourPalette))}get(t){const e=class{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}}.hashCode(t)%R.palette.length;return function(t){if(null==t)return"rgb(100,100,100)";const e=n.Color.fromHtml(t),i=n.Color.g(e),s=n.Color.r(e),o=n.Color.b(e),r=Math.sqrt(Math.pow(0-s,2)+Math.pow(0-i,2)+Math.pow(0-o,2));return r>210?`rgb(${s/r*210},${i/r*210},${o/r*210})`:n.Color.toRgb(e)}(R.palette[e])}}R.palette=R.buildPalette();new Uint32Array(65536);var G,B;async function V(){const t=n.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()}(B=G||(G={})).HAMMING="Hamming",B.LEVENSHTEIN="Levenshtein",B.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",B.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance",G.HAMMING,G.LEVENSHTEIN,G.NEEDLEMANN_WUNSCH,G.MONOMER_CHEMICAL_DISTANCE,new class{constructor(){this.uhTemp=`units-handler.${n.SEMTYPE.MACROMOLECULE}`}},P.FASTA,P.SEPARATOR,P.HELM;const U="Libraries",W={explicit:["HELMCoreLibrary.json"],exclude:[]};let j=Promise.resolve();async function Y(){let t;return j=j.then((async()=>{const e=await i.dapi.userDataStorage.getValue(U,"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 j,t}async function Q(t){j=j.then((async()=>{console.debug(`Bio: setUserLibSettings()\n${JSON.stringify(t,void 0,2)}`),await i.dapi.userDataStorage.postValue(U,"Settings",JSON.stringify(t),!0)})),await j}async function z(){await Q(W)}var K=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())}))};A("findMonomers",(()=>{let t,e;y((()=>K(void 0,void 0,void 0,(function*(){t=yield V(),e=yield Y(),yield z(),yield t.loadLibraries(!0)})))),T((()=>K(void 0,void 0,void 0,(function*(){yield Q(e),yield t.loadLibraries(!0)}))));const n={withoutMissed:{test:"PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et}$$$$",tgt:new Set},withMissed:{test:"PEPTIDE1{meI.missed2.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et}$$$$",tgt:new Set(["missed2"])}};for(const[t,e]of Object.entries(n))C(t,(()=>K(void 0,void 0,void 0,(function*(){i(e.test,e.tgt)}))));function i(t,e){p(function(t){const e=Object.keys(org.helm.webeditor.monomerTypeList()),n=[],i=[];for(let t=0;t<e.length;t++)n.push(new scil.helm.Monomers.getMonomerSet(e[t])),Object.keys(n[t]).forEach((e=>{i.push(n[t][e].id)}));return new Set(t.filter((t=>!i.includes(t))))}(v(t)),e)}}));const J=$;var X,q=t.n(J),Z=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())}))};A("renderers",(()=>{C("missedInLib",(()=>Z(void 0,void 0,void 0,(function*(){yield function(){return Z(this,void 0,void 0,(function*(){const t=yield i.dapi.files.readCsv("System:AppData/Helm/tests/sample_HELM-missedInLib.csv"),e=t.getCol("HELM"),o=i.shell.addTableView(t);yield function(t,e="Timeout exceeded",n=500,i=50){return s(this,void 0,void 0,(function*(){return new Promise(((s,o)=>{setTimeout((()=>{clearInterval(r),o(new Error(e))}),n);const r=setInterval((()=>{t()&&(clearInterval(r),s())}),i)}))}))}((()=>q()(o.root).find(".d4-grid canvas").length>0),"Table view canvas not found",100),f(e.semType,n.SEMTYPE.MACROMOLECULE),f(e.getTag(n.TAGS.UNITS),P.HELM),f(e.getTag(n.TAGS.CELL_RENDERER),"helm");const r=e.getTag(".cell-renderer.render.error");if(r){const t=JSON.parse(r),e=new Error(t.message);throw e.stack=t.stack,e}}))}()}))))}));class tt extends class{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))}}{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}}!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"}(X||(X={}));class et extends tt{constructor(t){super(t)}static validate(t){return-1!==t.indexOf(X.HEADER)&&-1!==t.indexOf(X.END)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,X.ATOM_TYPE_COL)}getCountsLineIdx(){let t=0;for(let e=0;e<X.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,X.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,X.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+X.NUM_OF_COUNTS_DIGITS;const n=parseInt(this.fileContent.substring(t,e));return t=e,e+=X.NUM_OF_COUNTS_DIGITS,{atomCount:n,bondCount:parseInt(this.fileContent.substring(t,e))}}}class nt extends tt{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))}}}function it(t,e=5e3){return n=this,i=void 0,r=function*(){yield N(100),yield function(t,e,n,i=0){return s(this,void 0,void 0,(function*(){let s;return new Promise(((o,r)=>{s=t.subscribe((t=>{try{e(t)}catch(t){r(t)}s.unsubscribe(),o("OK")})),setTimeout((()=>{s.unsubscribe(),r("timeout")}),i),n()}))}))}(t.onAfterDrawContent,(()=>{}),(()=>{t.invalidate()}),e)},new((o=void 0)||(o=Promise))((function(t,e){function s(t){try{l(r.next(t))}catch(t){e(t)}}function a(t){try{l(r.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(s,a)}l((r=r.apply(n,i||[])).next())}));var n,i,o,r}var st=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())}))};A("getMolfiles",(()=>{let t,e;y((()=>st(void 0,void 0,void 0,(function*(){t=yield V(),e=yield Y(),yield z(),yield t.loadLibraries(!0)})))),T((()=>st(void 0,void 0,void 0,(function*(){yield Q(e),yield t.loadLibraries(!0)})))),C("linear1",(()=>st(void 0,void 0,void 0,(function*(){const t=n.DataFrame.fromCsv("Helm, atoms, bonds\nPEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Tyr_ab-dehydroMe.dV}$$$$,11,10\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.D-Chg.dV}$$$$,11,10\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$$,9,8"),e=t.getCol("Helm"),s=i.shell.addTableView(t);ot.logger.debug("Helm/getMolfiles/linear1, grid awaiting 1"),yield it(s.grid,5e3),ot.logger.debug("Helm/getMolfiles/linear1, grid awaited 1");const o=yield i.functions.call("Helm:getMolfiles",{col:e});f(o.length,e.length);const r=o.toList().map((t=>class{constructor(){}static getInstance(t){if(et.validate(t))return new et(t);if(nt.validate(t))return new nt(t);throw new Error("Malformed molfile")}}.getInstance(t)));m(r.map((t=>t.atomCount)),t.getCol("atoms").toList()),m(r.map((t=>t.bondCount)),t.getCol("bonds").toList()),ot.logger.debug("Helm/getMolfiles/linear1, grid awaiting 2"),yield it(s.grid,5e3),ot.logger.debug("Helm/getMolfiles/linear1, grid awaited 2")}))))}));const ot=new n.Package;function rt(t,e,o){return c=this,u=void 0,f=function*(){const c=yield function(t){var e,o,c,u,C;return s(this,void 0,void 0,(function*(){const f=null===(o=null===(e=i.functions.getCurrentCall())||void 0===e?void 0:e.func)||void 0===o?void 0:o.package;yield function(t,e){return s(this,void 0,void 0,(function*(){if(l[t])return;const e=r;if(void 0!==e["Auto Tests"]||Object.keys(e).find((t=>t.startsWith(a))))return void(l[t]=!0);const n=[],o=yield i.dapi.functions.filter(`package.id = "${t}"`).list(),c=new RegExp(/skip:\s*([^,\s]+)|wait:\s*(\d+)|cat:\s*([^,\s]+)/g);for(const t of o){const o=t.options.test;if(o&&Array.isArray(o)&&o.length)for(let r=0;r<o.length;r++){const l=o[r].matchAll(c),u={};Array.from(l).forEach((t=>{t[0].startsWith("skip")?u.skip=t[1]:t[0].startsWith("wait")?u.wait=parseInt(t[2]):t[0].startsWith("cat")&&(u.cat=t[3])}));const d=new h(a,1===o.length?t.name:`${t.name} ${r+1}`,(()=>s(this,void 0,void 0,(function*(){const e=yield i.functions.eval(E(o[r],t));if(u.wait&&(yield N(u.wait)),"boolean"==typeof e&&!e)throw`Failed: ${o[r]}, expected true, got ${e}`}))),{skipReason:u.skip});if(u.cat){const t="Auto Tests: "+u.cat;d.category=t,void 0===e[t]&&(e[t]={tests:[],clear:!0}),e[t].tests.push(d)}else n.push(d)}}l[t]=!0,n.length&&(e["Auto Tests"]={tests:n,clear:!0})}))}(f.id);const g=[];console.log("Running tests"),null!=t||(t={}),null!==(c=(C=t).testContext)&&void 0!==c||(C.testContext=new d),i.shell.lastError="";for(const[e,s]of Object.entries(r)){if(null!=(null==t?void 0:t.category)&&!e.toLowerCase().startsWith(null==t?void 0:t.category.toLowerCase()))continue;console.log(`Started ${e} category`);try{s.before&&(yield s.before())}catch(t){s.beforeStatus=t.toString()}const o=null!==(u=s.tests)&&void 0!==u?u:[],r=[];if(s.clear)for(let e=0;e<o.length;e++)r.push(yield b(o[e],null==t?void 0:t.test,s.timeout,f.name)),i.shell.closeAll(),n.Balloon.closeAll();else for(let e=0;e<o.length;e++)r.push(yield b(o[e],null==t?void 0:t.test,s.timeout,f.name));const a=(yield Promise.all(r)).filter((t=>"skipped"!=t.result));try{s.after&&(yield s.after())}catch(t){s.afterStatus=t.toString()}s.afterStatus&&a.push({category:e,name:"init",result:s.afterStatus,success:!1,ms:0,skipped:!1}),s.beforeStatus&&a.push({category:e,name:"init",result:s.beforeStatus,success:!1,ms:0,skipped:!1}),g.push(...a)}if(t.testContext.catchUnhandled&&(yield N(1e3),i.shell.lastError.length>0&&g.push({category:"Unhandled exceptions",name:"exceptions",result:i.shell.lastError,success:!1,ms:0,skipped:!1})),t.testContext.report){const t=new n.Logger,e=g.filter((t=>t.success)).length,i=g.filter((t=>t.skipped)).length,s=g.filter((t=>!t.success)),o="Package @package tested: @successful successful, @skipped skipped, @failed failed tests",r={successful:e,skipped:i,failed:s.length,package:f};for(const t of s)Object.assign(r,{[`${t.category} | ${t.name}`]:t.result});t.log(o,r,"package-tested")}return g}))}({category:t,test:e,testContext:o});return n.DataFrame.fromObjects(c)},new((C=void 0)||(C=Promise))((function(t,e){function n(t){try{s(f.next(t))}catch(t){e(t)}}function i(t){try{s(f.throw(t))}catch(t){e(t)}}function s(e){var s;e.done?t(e.value):(s=e.value,s instanceof C?s:new C((function(t){t(s)}))).then(n,i)}s((f=f.apply(c,u||[])).next())}));var c,u,C,f}helm_test=e})();
2
2
  //# sourceMappingURL=package-test.js.map