diff --git a/CHANGELOG.md b/CHANGELOG.md index 27ef4b28..67e8eba7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ ## Change Log +[icn3d-3.29.0](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-3.29.0.zip) was release on December 13, 2023. Added the feature to load electron density maps from ccp4 or MTZ files either locally or via URLs. + [icn3d-3.28.4](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-3.28.4.zip) was release on November 7, 2023. Enabled to show DelPhi potential for multiple structures. [icn3d-3.28.3](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-3.28.3.zip) was release on October 5, 2023. Fixed the async/await issue for electron density maps and EM density maps. @@ -307,7 +309,7 @@ [icn3d-2.15.0](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-2.15.0.zip) was release on April 21, 2020. Enabled to show the same structure "Side by Side" in two views in the "View" menu. Each view has the same orientation, but can have independent 3D display. Enabled to add multiple sequence alignments as tracks when clicking "Add Track" in the "Sequences & Annotations" window. Added "Hide Selection" in the "View" menu. Improved selection on "H-Bonds & Interactions". Improved the UI for "Realign Selection" in the "File" menu. The gallery shows COVID-19-related structures at the top. -[icn3d-2.14.0](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-2.14.0.zip) was release on April 15, 2020. Added the features to load Electron Density data in the menu "File > Open File > Electron Density (DSN6)", resize the 3D window, realign two structures in the menu "File > Realign", color residues with custom colors in the menu "Color > Residue > Custom", and add custom colors when aligning a sequence to a structure. +[icn3d-2.14.0](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-2.14.0.zip) was release on April 15, 2020. Added the features to load Electron Density data in the menu "File > Open File > Electron Density", resize the 3D window, realign two structures in the menu "File > Realign", color residues with custom colors in the menu "Color > Residue > Custom", and add custom colors when aligning a sequence to a structure. [icn3d-2.13.1](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-2.13.1.zip) was release on March 26, 2020. Showed membranes for transmembrane proteins in VAST+ alignment. diff --git a/README.md b/README.md index a499f103..330d7e2a 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ * Contact Map for any Selected Residues: You can click the menu "Analysis > Contact Map" to show the interactive [contact map](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?rnMbe26tNsAjJLGK9) for any selected residues. You can export the map in PNG or SVG. -* More features are listed at [www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html): [binding site](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?JR5B), [interaction interface](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?CuXYgGLCukDeUKnJ6), [3D printing](https://www.ncbi.nlm.nih.gov/Structure/icn3d/?mmdbid=1tup&command=export+stl+stabilizer+file), [transmembrane proteins](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?TuSd), [surface](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?aYAjP4S3NbrBJX3x6), [EM map](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?L4C4WYE85tYRiFeK7), [electron density map](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?QpqNZ3k65ToYFvUB6), 1D sequences and 2D interactions, [align two structures](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?PfsQFtZRTgFAW2LG6), [align multiple chains](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?ijnf), [align a protein sequence to a structure](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?Mmm82craCwGMAxru9), [realign](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?UccFrXLDNeVB7Jk16), [custom tracks](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?pUzP), [force-directed graph for interactions](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?rshvjTFXpAFu8GDa9), [solvent accessible surface area](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?xKSyfd1umbKstGh29), etc. +* More features are listed at [www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html): [binding site](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?JR5B), [interaction interface](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?CuXYgGLCukDeUKnJ6), [3D printing](https://www.ncbi.nlm.nih.gov/Structure/icn3d/?mmdbid=1tup&command=export+stl+stabilizer+file), [transmembrane proteins](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?TuSd), [surface](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?aYAjP4S3NbrBJX3x6), [EM map](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?L4C4WYE85tYRiFeK7), [electron density map from MTZ, CCP4, or DSN6](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?QpqNZ3k65ToYFvUB6), 1D sequences and 2D interactions, [align two structures](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?PfsQFtZRTgFAW2LG6), [align multiple chains](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?ijnf), [align a protein sequence to a structure](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?Mmm82craCwGMAxru9), [realign](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?UccFrXLDNeVB7Jk16), [custom tracks](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?pUzP), [force-directed graph for interactions](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?rshvjTFXpAFu8GDa9), [solvent accessible surface area](https://structure.ncbi.nlm.nih.gov/icn3d/share.html?xKSyfd1umbKstGh29), etc. ## Embed iCn3D with iframe or JavaScript libraries @@ -123,6 +123,7 @@ iCn3D also accepts the following file types: PDB, mmCIF, Mol2, SDF, XYZ, and iCn * **[Orientations of Proteins in Membranes (OPM)](https://opm.phar.umich.edu/)**: The membrane data of transmembrane proteins are from OPM. * **[Membranome](https://membranome.org)**: For AlphaFold Structures, the membrane data of single-spanning transmembrane proteins are from Membranome. * **[Post-Translational Modification (PTM)](https://www.ebi.ac.uk/proteins/api/doc/#/features)**: The PTM data are from UniProt. +* **[UglyMol](https://github.com/uglymol/uglymol.github.io)**: The electron density maps from CCP4 map or MTZ format are based on UglyMol. ## Building diff --git a/build/icn3d.js b/build/icn3d.js index 91f1142d..57c77c79 100644 --- a/build/icn3d.js +++ b/build/icn3d.js @@ -8195,6 +8195,8 @@ var icn3d = (function (exports) { let sigma2fofc = parseFloat($("#" + me.pre + "sigma2fofc" ).val()); let type = '2fofc'; await ic.dsn6ParserCls.dsn6Parser(ic.inputid, type, sigma2fofc); + //ic.densityCifParserCls.densityCifParser(ic.inputid, type, sigma2fofc); + //ic.setOptionCls.setOption('map', '2fofc'); thisClass.setLogCmd('set map 2fofc sigma ' + sigma2fofc, true); }); @@ -9457,6 +9459,8 @@ var icn3d = (function (exports) { html += this.getLink('mn1_dsn6url', 'URL(CORS) ' + me.htmlCls.wifiStr, undefined, 3); html += ""; + html += "

  • "; + html += ""; html += ""; @@ -11879,24 +11883,18 @@ var icn3d = (function (exports) { html += me.htmlCls.divStr + "dl_dsn6' class='" + dialogClass + "'>"; html += this.addNotebookTitle('dl_dsn6', 'Load a map file'); - html += "Note: Always load a PDB file before loading map files.


    "; - - html += "2fofc contour at: σ
    "; - html += me.htmlCls.inputFileStr + "id='" + me.pre + "dsn6file2fofc'> " + me.htmlCls.buttonStr + "reload_dsn6file2fofc' style='margin: 6px 20px 0 0;'>Load DSN6


    "; - //html += me.htmlCls.inputFileStr + "id='" + me.pre + "dsn6file2fofc'> " + me.htmlCls.buttonStr + "reload_dsn6file2fofc' style='margin: 6px 20px 0 0;'>Load DSN6" + me.htmlCls.buttonStr + "reload_ccp4file2fofc' style='margin-top: 6px;'>Load CCP4


    "; + html += "Note: Always load a PDB file before loading map files. If you don't specify the threshold
    below, a default one will be chosen.


    "; - html += "fofc contour at: σ
    "; - html += me.htmlCls.inputFileStr + "id='" + me.pre + "dsn6filefofc'> " + me.htmlCls.buttonStr + "reload_dsn6filefofc' style='margin: 6px 20px 0 0;'>Load DSN6


    "; - //html += me.htmlCls.inputFileStr + "id='" + me.pre + "dsn6filefofc'> " + me.htmlCls.buttonStr + "reload_dsn6filefofc' style='margin: 6px 20px 0 0;'>Load DSN6" + me.htmlCls.buttonStr + "reload_ccp4filefofc' style='margin-top: 6px;'>Load CCP4


    "; + //html += me.htmlCls.inputFileStr + "id='" + me.pre + "dsn6filefofc'> " + me.htmlCls.buttonStr + "reload_dsn6filefofc' style='margin: 6px 20px 0 0;'>Load DSN6


    "; + html += me.htmlCls.inputFileStr + "id='" + me.pre + "dsn6filefofc'> " + me.htmlCls.buttonStr + "reload_dsn6filefofc' style='margin: 6px 20px 0 0;'>Load DSN6" + me.htmlCls.buttonStr + "reload_ccp4filefofc' style='margin: 6px 20px 0 0;'>Load CCP4" + me.htmlCls.buttonStr + "reload_mtzfilefofc' style='margin-top: 6px;'>Load MTZ


    "; html += me.htmlCls.buttonStr + "elecmapNo4'>Remove Map
    "; @@ -11904,21 +11902,17 @@ var icn3d = (function (exports) { html += me.htmlCls.divStr + "dl_dsn6url' class='" + dialogClass + "'>"; html += this.addNotebookTitle('dl_dsn6url', 'Load a selection file via a URL'); - html += "Note: Always load a PDB file before loading map files.


    "; - - html += "2fofc contour at: σ
    "; - html += "URL in the same host: " + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6fileurl2fofc' size=20>" + me.htmlCls.space3 + me.htmlCls.buttonStr + "reload_dsn6fileurl2fofc' style='margin-top: 6px;'>Load


    "; + html += "2fofc contour at default threshold or at: " + + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6sigmaurl2fofc' value='' size=8> σ
    "; - html += "fofc contour at: σ
    "; - html += "URL in the same host: " + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6fileurlfofc' size=20>" + me.htmlCls.space3 + me.htmlCls.buttonStr + "reload_dsn6fileurlfofc' style='margin-top: 6px;'>Load


    "; + html += "URL in the same host: " + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6fileurlfofc' size=20>" + me.htmlCls.space3 + me.htmlCls.buttonStr + "reload_dsn6fileurlfofc' style='margin: 6px 20px 0 0;'>Load DSN6" + me.htmlCls.buttonStr + "reload_ccp4fileurlfofc' style='margin: 6px 20px 0 0;'>Load CCP4" + me.htmlCls.buttonStr + "reload_mtzfileurlfofc' style='margin-top: 6px;'>Load MTZ


    "; html += me.htmlCls.buttonStr + "elecmapNo5'>Remove Map
    "; @@ -12258,6 +12252,7 @@ var icn3d = (function (exports) { html += this.addNotebookTitle('dl_elecmap2fofc', 'Electron Density 2F0-Fc Map'); html += "Contour at: σ " + me.htmlCls.buttonStr + "applymap2fofc'>Display " + me.htmlCls.buttonStr + "elecmapNo2'>Remove Map"; @@ -12904,7 +12899,7 @@ var icn3d = (function (exports) { } } - readFile(bAppend, files, index, dataStrAll) { let me = this.icn3dui, ic = me.icn3d, thisClass = this; + async readFile(bAppend, files, index, dataStrAll) { let me = this.icn3dui, ic = me.icn3d, thisClass = this; let file = files[index]; let commandName = (bAppend) ? 'append': 'load'; @@ -12941,7 +12936,20 @@ var icn3d = (function (exports) { await ic.pdbParserCls.loadPdbData(dataStrAll, undefined, undefined, bAppend); } else { - thisClass.readFile(bAppend, files, index + 1, dataStrAll); + await thisClass.readFile(bAppend, files, index + 1, dataStrAll); + } + + if(bAppend) { + if(ic.bSetChainsAdvancedMenu) ic.definedSetsCls.showSets(); + //if(ic.bSetChainsAdvancedMenu) ic.legendTableCls.showSets(); + + ic.bResetAnno = true; + + if(ic.bAnnoShown) { + await ic.showAnnoCls.showAnnotations(); + + ic.annotationCls.resetAnnoTabAll(); + } } }; @@ -12976,13 +12984,7 @@ var icn3d = (function (exports) { ic.dataStrAll = ''; - this.readFile(bAppend, files, 0, ''); - - if(bAppend) { - if(ic.bSetChainsAdvancedMenu) ic.definedSetsCls.showSets(); - //if(ic.bSetChainsAdvancedMenu) ic.legendTableCls.showSets(); - if(ic.bAnnoShown) await ic.showAnnoCls.showAnnotations(); - } + await this.readFile(bAppend, files, 0, ''); } } @@ -13066,7 +13068,10 @@ var icn3d = (function (exports) { if(bStructures) { if(ic.bSetChainsAdvancedMenu) ic.definedSetsCls.showSets(); - if(ic.bAnnoShown) await ic.showAnnoCls.showAnnotations(); + if(ic.bAnnoShown) { + await ic.showAnnoCls.showAnnotations(); + ic.annotationCls.resetAnnoTabAll(); + } } } } @@ -14076,24 +14081,35 @@ var icn3d = (function (exports) { me.myEventCls.onIds("#" + me.pre + "reload_dsn6file2fofc", "click", function(e) { let ic = me.icn3d; e.preventDefault(); - if(!me.cfg.notebook) dialog.dialog( "close" ); + //if(!me.cfg.notebook) dialog.dialog( "close" ); ic.dsn6ParserCls.loadDsn6File('2fofc'); }); me.myEventCls.onIds("#" + me.pre + "reload_dsn6filefofc", "click", function(e) { let ic = me.icn3d; e.preventDefault(); - if(!me.cfg.notebook) dialog.dialog( "close" ); + //if(!me.cfg.notebook) dialog.dialog( "close" ); ic.dsn6ParserCls.loadDsn6File('fofc'); }); me.myEventCls.onIds("#" + me.pre + "reload_ccp4file2fofc", "click", function(e) { let ic = me.icn3d; e.preventDefault(); - if(!me.cfg.notebook) dialog.dialog( "close" ); - ic.dsn6ParserCls.loadDsn6File('2fofc', true); + //if(!me.cfg.notebook) dialog.dialog( "close" ); + ic.ccp4ParserCls.loadCcp4File('2fofc'); }); me.myEventCls.onIds("#" + me.pre + "reload_ccp4filefofc", "click", function(e) { let ic = me.icn3d; e.preventDefault(); - if(!me.cfg.notebook) dialog.dialog( "close" ); - ic.dsn6ParserCls.loadDsn6File('fofc', true); + //if(!me.cfg.notebook) dialog.dialog( "close" ); + ic.ccp4ParserCls.loadCcp4File('fofc'); + }); + + me.myEventCls.onIds("#" + me.pre + "reload_mtzfile2fofc", "click", function(e) { let ic = me.icn3d; + e.preventDefault(); + //if(!me.cfg.notebook) dialog.dialog( "close" ); + ic.mtzParserCls.loadMtzFile('2fofc'); + }); + me.myEventCls.onIds("#" + me.pre + "reload_mtzfilefofc", "click", function(e) { let ic = me.icn3d; + e.preventDefault(); + //if(!me.cfg.notebook) dialog.dialog( "close" ); + ic.mtzParserCls.loadMtzFile('fofc'); }); me.myEventCls.onIds("#" + me.pre + "reload_delphifile", "click", async function(e) { let ic = me.icn3d; @@ -14185,15 +14201,37 @@ var icn3d = (function (exports) { me.myEventCls.onIds("#" + me.pre + "reload_dsn6fileurl2fofc", "click", function(e) { let ic = me.icn3d; e.preventDefault(); - if(!me.cfg.notebook) dialog.dialog( "close" ); + //if(!me.cfg.notebook) dialog.dialog( "close" ); ic.dsn6ParserCls.loadDsn6FileUrl('2fofc'); }); me.myEventCls.onIds("#" + me.pre + "reload_dsn6fileurlfofc", "click", function(e) { let ic = me.icn3d; e.preventDefault(); - if(!me.cfg.notebook) dialog.dialog( "close" ); + //if(!me.cfg.notebook) dialog.dialog( "close" ); ic.dsn6ParserCls.loadDsn6FileUrl('fofc'); }); + me.myEventCls.onIds("#" + me.pre + "reload_ccp4fileurl2fofc", "click", function(e) { let ic = me.icn3d; + e.preventDefault(); + //if(!me.cfg.notebook) dialog.dialog( "close" ); + ic.ccp4ParserCls.loadCcp4FileUrl('2fofc'); + }); + me.myEventCls.onIds("#" + me.pre + "reload_ccp4fileurlfofc", "click", function(e) { let ic = me.icn3d; + e.preventDefault(); + //if(!me.cfg.notebook) dialog.dialog( "close" ); + ic.ccp4ParserCls.loadCcp4FileUrl('fofc'); + }); + + me.myEventCls.onIds("#" + me.pre + "reload_mtzfileurl2fofc", "click", function(e) { let ic = me.icn3d; + e.preventDefault(); + //if(!me.cfg.notebook) dialog.dialog( "close" ); + ic.mtzParserCls.loadMtzFileUrl('2fofc'); + }); + me.myEventCls.onIds("#" + me.pre + "reload_mtzfileurlfofc", "click", function(e) { let ic = me.icn3d; + e.preventDefault(); + //if(!me.cfg.notebook) dialog.dialog( "close" ); + ic.mtzParserCls.loadMtzFileUrl('fofc'); + }); + me.myEventCls.onIds("#" + me.pre + "reload_pdbfile", "click", async function(e) { me.icn3d; e.preventDefault(); @@ -15581,7 +15619,7 @@ var icn3d = (function (exports) { // for(let i in ic.alnChains) { for (let m = 0, ml = alignChainArray.length; m < ml; ++m) { let i = alignChainArray[m]; - + if (index == 0) firstChainid = i; if (bOnechain && index > 0) { @@ -29356,8 +29394,8 @@ var icn3d = (function (exports) { this.pLength = 0; this.cutRadius = 0; this.vpBits = null; // uint8 array of bitmasks - this.vpDistance = null; // floatarray of _squared_ distances - this.vpAtomID = null; // intarray + this.vpGridTrans = null; // array of translated number of grids + this.vpAtomID = null; // uint8 array this.vertnumber = 0; this.facenumber = 0; this.pminx = 0; @@ -29407,12 +29445,27 @@ var icn3d = (function (exports) { atomsToShow[atomlist[i]] = 1; let vertices = this.verts; + let vertTrans = {}; for(i = 0, il = vertices.length; i < il; i++) { let r; if(this.type == 'phi') { r = new THREE.Vector3(vertices[i].x, vertices[i].y, vertices[i].z).multiplyScalar(1.0/this.header.scale).applyMatrix4(this.matrix); } else { + // ccp4 has no translation vector. Only translated vertices are used. + if(this.header.ccp4) { + let index = vertices[i].index; + let finalIndex; + if(this.vpGridTrans[index]) { + finalIndex = index; + + vertices[i].x += this.vpGridTrans[finalIndex][0] * this.header.xExtent * this.scaleFactor; + vertices[i].y += this.vpGridTrans[finalIndex][1] * this.header.xExtent * this.scaleFactor; + vertices[i].z += this.vpGridTrans[finalIndex][2] * this.header.xExtent * this.scaleFactor; + + vertTrans[finalIndex] = 1; + } + } r = new THREE.Vector3(vertices[i].x, vertices[i].y, vertices[i].z).applyMatrix4(this.matrix); } // vertices[i].x = r.x / this.scaleFactor - this.ptranx; @@ -29431,13 +29484,22 @@ var icn3d = (function (exports) { let fa = this.faces[i], fb = this.faces[i+1], fc = this.faces[i+2]; if(fa !== fb && fb !== fc && fa !== fc){ - finalfaces.push({"a":fa, "b":fb, "c":fc}); + if(this.header.ccp4) { + // only transfered vertices will be used + if(vertTrans.hasOwnProperty(vertices[fa].index) && vertTrans.hasOwnProperty(vertices[fb].index) + && vertTrans.hasOwnProperty(vertices[fc].index)) { + finalfaces.push({"a":fa, "b":fb, "c":fc}); + } + } + else { + finalfaces.push({"a":fa, "b":fb, "c":fc}); + } } } //try to help the garbage collector this.vpBits = null; // uint8 array of bitmasks - this.vpDistance = null; // floatarray + this.vpGridTrans = null; // uint8 array this.vpAtomID = null; // intarray return { @@ -29496,6 +29558,8 @@ var icn3d = (function (exports) { this.cutRadius = this.probeRadius * this.scaleFactor; this.vpBits = new Uint8Array(this.pLength * this.pWidth * this.pHeight); + if(this.header.ccp4) this.vpGridTrans = new Array(this.pLength * this.pWidth * this.pHeight); + this.vpAtomID = new Uint8Array(this.pLength * this.pWidth * this.pHeight); }; @@ -29521,7 +29585,6 @@ var icn3d = (function (exports) { let i, j, k, il, jl, kl; for(i = 0, il = this.vpBits.length; i < il; i++) { this.vpBits[i] = 0; - //this.vpDistance[i] = -1.0; this.vpAtomID[i] = 0; } @@ -29683,6 +29746,7 @@ var icn3d = (function (exports) { } } else { + // let index2ori = {}; for(let serial in atomlist) { let atom = atoms[atomlist[serial]]; @@ -29713,6 +29777,7 @@ var icn3d = (function (exports) { for(i = 0, il = indexArray.length; i < il; ++i) { let index = indexArray[i]; + if(this.type == '2fofc') { this.vpBits[index] =(this.dataArray[index] >= this.isovalue) ? 1 : 0; //this.vpAtomID[index] =(this.dataArray[index] >= 0) ? 1 : 0; // determine whether it's positive @@ -29726,6 +29791,7 @@ var icn3d = (function (exports) { //this.vpAtomID[index] =(this.dataArray[index] >= 0) ? 1 : 0; // determine whether it's positive } } + } } @@ -29949,7 +30015,18 @@ var icn3d = (function (exports) { cfg.isovalue = ic.mapData.sigma2; cfg.type = '2fofc'; - ps = this.SetupMap(cfg); + //ccp4 + cfg.ccp4 = ic.mapData.ccp4; + cfg.grid = ic.mapData.grid2; + cfg.unit_cell = ic.mapData.unit_cell2; + + if(cfg.header || cfg.ccp4) ps = this.SetupMap(cfg); + else return; + + if(cfg.ccp4) { + ic.mapData = {}; + return; + } } else if(type == 12) { // fofc cfg.header = ic.mapData.header; @@ -29958,7 +30035,18 @@ var icn3d = (function (exports) { cfg.isovalue = ic.mapData.sigma; cfg.type = 'fofc'; - ps = this.SetupMap(cfg); + //ccp4 + cfg.ccp4 = ic.mapData.ccp4; + cfg.grid = ic.mapData.grid; + cfg.unit_cell = ic.mapData.unit_cell; + + if(cfg.header || cfg.ccp4) ps = this.SetupMap(cfg); + else return; + + if(cfg.ccp4) { + ic.mapData = {}; + return; + } } else if(type == 13) { // em cfg.maxdist = 3; // EM map has no unit cell. It could include more gird space. @@ -30446,29 +30534,60 @@ var icn3d = (function (exports) { } SetupMap(data) { let ic = this.icn3d; ic.icn3dui; - let ps = new ElectronMap(ic); - - ps.initparm(data.header, data.data, data.matrix, data.isovalue, data.center, data.maxdist, - data.pmin, data.pmax, data.water, data.type, data.rmsd_supr, data.loadPhiFrom, data.icn3d); + if(data.ccp4) { + let radius = 10; + let center = (ic.center) ? [ic.center.x, ic.center.y, ic.center.z] : [0,0,0]; + + let typeDetail; + if(data.type == '2fofc') { + typeDetail = '2fofc'; + let result = ic.ccp4ParserCls.extract_block(data.grid, data.unit_cell, radius, center, typeDetail); + let iso = ic.ccp4ParserCls.marchingCubes(result.size, result.values, result.points, data.isovalue, 'marching cubes'); + ic.ccp4ParserCls.makeChickenWire(iso, typeDetail); + + result = null; + iso = null; + } + else if(data.type == 'fofc') { + typeDetail = 'fofc_neg'; + let result = ic.ccp4ParserCls.extract_block(data.grid, data.unit_cell, radius, center, typeDetail); + let iso = ic.ccp4ParserCls.marchingCubes(result.size, result.values, result.points, data.isovalue, 'marching cubes'); + ic.ccp4ParserCls.makeChickenWire(iso, typeDetail); + + typeDetail = 'fofc_pos'; + result = ic.ccp4ParserCls.extract_block(data.grid, data.unit_cell, radius, center, typeDetail); + iso = ic.ccp4ParserCls.marchingCubes(result.size, result.values, result.points, data.isovalue, 'marching cubes'); + ic.ccp4ParserCls.makeChickenWire(iso, typeDetail); - ps.fillvoxels(data.allatoms, data.extendedAtoms); + result = null; + iso = null; + } + } + else { + let ps = new ElectronMap(ic); + + ps.initparm(data.header, data.data, data.matrix, data.isovalue, data.center, data.maxdist, + data.pmin, data.pmax, data.water, data.type, data.rmsd_supr, data.loadPhiFrom, data.icn3d); - if(!data.header.bSurface) ps.buildboundary(); + ps.fillvoxels(data.allatoms, data.extendedAtoms); - if(!data.header.bSurface) ps.marchingcube(); - - ps.vpBits = null; // uint8 array of bitmasks - //ps.vpDistance = null; // floatarray of _squared_ distances - ps.vpAtomID = null; // intarray + if(!data.header.bSurface) ps.buildboundary(); - let result; + if(!data.header.bSurface) ps.marchingcube(); + + ps.vpBits = null; // uint8 array of bitmasks + //ps.vpDistance = null; // floatarray of _squared_ distances + ps.vpAtomID = null; // intarray - if(!data.header.bSurface) result = ps.getFacesAndVertices(data.allatoms, data.atomsToShow); + let result; - ps.faces = null; - ps.verts = null; + if(!data.header.bSurface) result = ps.getFacesAndVertices(data.allatoms, data.atomsToShow); - return result; + ps.faces = null; + ps.verts = null; + + return result; + } } } @@ -35955,7 +36074,7 @@ var icn3d = (function (exports) { for(let resid in residueHash) { if(!ic.resid2refnum[resid]) { - color = me.parasCls.thr('#FFFFFF'); + color = me.parasCls.thr('#00FFFF'); //('#FFFFFF'); } else { let refnumLabel = ic.resid2refnum[resid]; @@ -35990,7 +36109,7 @@ var icn3d = (function (exports) { let residueHash = ic.firstAtomObjCls.getResiduesFromAtoms(atoms); for(let resid in residueHash) { if(!ic.resid2refnum[resid]) { - color = me.parasCls.thr('#FFFFFF'); + color = me.parasCls.thr('#00FFFF'); //('#FFFFFF'); } else { let refnumLabel = ic.resid2refnum[resid]; @@ -38203,14 +38322,14 @@ var icn3d = (function (exports) { let pdbid = pdbArray[index]; //let url = me.htmlCls.baseUrl + "mmdb/mmdb_strview.cgi?v=2&program=icn3d&domain&molinfor&uid=" + pdbid; - if(index == 0 && ic.mmdb_data !== undefined) { + if(!ic.bResetAnno && index == 0 && ic.mmdb_data !== undefined) { for(let chnid in ic.protein_chainid) { if(chnid.indexOf(pdbid) !== -1) { this.showDomainWithData(chnid, ic.mmdb_data); } } } - else if(ic.mmdb_dataArray[index] !== undefined) { + else if(!ic.bResetAnno && ic.mmdb_dataArray[index] !== undefined) { for(let chnid in ic.protein_chainid) { if(chnid.indexOf(pdbid) !== -1) { this.showDomainWithData(chnid, ic.mmdb_dataArray[index]); @@ -39297,6 +39416,9 @@ var icn3d = (function (exports) { //this.dcut = 7; // threshold for C-alpha interactions this.dcut = 8; // threshold for C-alpha interactions + // added by Jiyao + this.min_contacts = 5; //3; // minimum number of contacts to be considered as neighbors + this.MAX_SSE = 512; //let this.ctc_cnt[this.MAX_SSE][this.MAX_SSE]; // contact count matrix @@ -39329,9 +39451,6 @@ var icn3d = (function (exports) { this.c_delta = 3; // cut set parameter this.nc_fact = 0.0; // size factor for internal contacts - // added by Jiyao - this.min_contacts = 3; // minimum number of contacts to be considered as neighbors - //let this.elements[2*this.MAX_SSE]; // sets of this.elements to be split this.elements = []; this.elements.length = 2*this.MAX_SSE; @@ -44185,8 +44304,10 @@ var icn3d = (function (exports) { let result = ic.refnumCls.getTemplateList(chnid); let refpdbnameList = result.refpdbnameList; let scoreList = result.scoreList; + let seqidList = result.seqidList; + let nresAlignList = result.nresAlignList; - let refStruTitle = (refpdbnameList) ? "based on " + refpdbnameList + ". The TM-scores are " + scoreList + "." : ""; + let refStruTitle = (refpdbnameList) ? "based on " + refpdbnameList + ". The TM-score(s) is(are) " + scoreList + ". The sequence identitie(s) is(are) " + seqidList + ". The number of aligned residue(s) is(are) " + nresAlignList + "." : ""; let htmlTmp = '
    '; htmlTmp += '
    '; @@ -46808,13 +46929,22 @@ var icn3d = (function (exports) { if(i < il - 1) refpdbnameList += ", "; } - let scoreList = ''; + let scoreList = '', seqidList = '', nresAlignList = ''; for(let i = 0, il = domainidArray.length; i < il; ++i) { - scoreList += domainid2score[domainidArray[i]]; - if(i < il - 1) scoreList += ", "; + let itemArray = domainid2score[domainidArray[i]].split('_'); + + scoreList += itemArray[0]; + seqidList += itemArray[1]; + nresAlignList += itemArray[2]; + + if(i < il - 1) { + scoreList += ", "; + seqidList += ", "; + nresAlignList += ", "; + } } - return {'refpdbnameList': refpdbnameList, 'scoreList': scoreList}; + return {'refpdbnameList': refpdbnameList, 'scoreList': scoreList, 'seqidList': seqidList, 'nresAlignList': nresAlignList}; } async parseAlignData(dataArray, domainidpairArray, bRound1) { let ic = this.icn3d, me = ic.icn3dui; @@ -46909,28 +47039,15 @@ var icn3d = (function (exports) { if(!bRound1) { console.log("domainid: " + domainid); - - if(!ic.domainid2score.hasOwnProperty(domainid) || queryData[0].score >= ic.domainid2score[domainid]) { - ic.domainid2score[domainid] = queryData[0].score; - - ic.domainid2refpdbname[domainid] = refpdbname; - domainid2segs[domainid] = queryData[0].segs; - ic.domainid2ig2kabat[domainid] = queryData[0].ig2kabat; - ic.domainid2ig2imgt[domainid] = queryData[0].ig2imgt; - } } - else { - //let mixScore = 10 / queryData[0].super_rmsd + queryData[0].num_seg / 5; - let mixScore = queryData[0].score; - if(!ic.domainid2score.hasOwnProperty(domainid) || mixScore > ic.domainid2score[domainid]) { - ic.domainid2score[domainid] = mixScore; - - ic.domainid2refpdbname[domainid] = refpdbname; - domainid2segs[domainid] = queryData[0].segs; - ic.domainid2ig2kabat[domainid] = queryData[0].ig2kabat; - ic.domainid2ig2imgt[domainid] = queryData[0].ig2imgt; - } + if(!ic.domainid2score.hasOwnProperty(domainid) || queryData[0].score >= ic.domainid2score[domainid].split('_')[0]) { + ic.domainid2score[domainid] = queryData[0].score + '_' + queryData[0].frac_identical + '_' + queryData[0].num_res ; + + ic.domainid2refpdbname[domainid] = refpdbname; + domainid2segs[domainid] = queryData[0].segs; + ic.domainid2ig2kabat[domainid] = queryData[0].ig2kabat; + ic.domainid2ig2imgt[domainid] = queryData[0].ig2imgt; } } @@ -47001,7 +47118,7 @@ var icn3d = (function (exports) { // end of round 2 return; } - + // combine domainid into chainid let processedChainid = {}; for(let domainid in ic.domainid2refpdbname) { @@ -47049,8 +47166,10 @@ var icn3d = (function (exports) { let result = this.getTemplateList(chainid); let refpdbnameList = result.refpdbnameList; let scoreList = result.scoreList; + let seqidList = result.seqidList; + let nresAlignList = result.nresAlignList; - let message = "The reference PDBs for chain " + chainid + " are " + refpdbnameList + ". The TM-scores are " + scoreList + "."; + let message = "The reference PDB(s) for chain " + chainid + " is(are) " + refpdbnameList + ". The TM-score(s) is(are) " + scoreList + ". The sequence identitie(s) is(are) " + seqidList + ". The number of aligned residue(s) is(are) " + nresAlignList + "."; if(!me.bNode) { console.log(message); me.htmlCls.clickMenuCls.setLogCmd(message, true); @@ -48686,7 +48805,7 @@ var icn3d = (function (exports) { if(ic.bD3 === undefined) { //let url = "https://d3js.org/d3.v4.min.js"; - let url = "https://www.ncbi.nlm.nih.gov/Structure/icn3d/script/d3v4-force-all.min.js"; + let url = "./script/d3v4-force-all.min.js"; await me.getAjaxPromise(url, 'script'); ic.bD3 = true; @@ -49961,7 +50080,7 @@ var icn3d = (function (exports) { for(let j = 0, jl = mmdbTmp.molecules.length; j < jl; ++j) { let molecule = mmdbTmp.molecules[j]; let molid = molecule.moleculeId; - let chainName = molecule.chain.trim(); + let chainName = molecule.chain.trim().replace(/_/g, ''); // change "A_1" to "A1" if(chainNameHash[chainName] === undefined) { chainNameHash[chainName] = 1; } @@ -51255,10 +51374,10 @@ var icn3d = (function (exports) { // https://edmaps.rcsb.org/maps/1kq2_fofc.dsn6 let url = "https://edmaps.rcsb.org/maps/" + pdbid.toLowerCase() + "_" + type + ".dsn6"; - await this.dsn6ParserBase(url, type, sigma); + await this.dsn6ParserBase(url, type, sigma, 'url', true); } - async dsn6ParserBase(url, type, sigma) { let ic = this.icn3d, me = ic.icn3dui; + async dsn6ParserBase(url, type, sigma, location, bInputSigma) { let ic = this.icn3d, me = ic.icn3dui; let thisClass = this; //https://stackoverflow.com/questions/33902299/using-jquery-ajax-to-download-a-binary-file @@ -51272,7 +51391,7 @@ var icn3d = (function (exports) { } else { let arrayBuffer = await me.getXMLHttpRqstPromise(url, 'GET', 'arraybuffer', 'rcsbEdmaps'); - thisClass.loadDsn6Data(arrayBuffer, type, sigma); + sigma = thisClass.loadDsn6Data(arrayBuffer, type, sigma, location, bInputSigma); if(type == '2fofc') { ic.bAjax2fofc = true; @@ -51283,9 +51402,11 @@ var icn3d = (function (exports) { ic.setOptionCls.setOption('map', type); } + + return sigma; } - loadDsn6Data(dsn6data, type, sigma) { let ic = this.icn3d; ic.icn3dui; + loadDsn6Data(dsn6data, type, sigma, location, bInputSigma) { let ic = this.icn3d; ic.icn3dui; // DSN6 http://www.uoxray.uoregon.edu/tnt/manual/node104.html // BRIX http://svn.cgl.ucsf.edu/svn/chimera/trunk/libs/VolumeData/dsn6/brix-1.html @@ -51334,9 +51455,9 @@ var icn3d = (function (exports) { } } - header.zStart = intView[ 2 ]; header.xStart = intView[ 0 ]; // NXSTART header.yStart = intView[ 1 ]; + header.zStart = intView[ 2 ]; header.xExtent = intView[ 3 ]; // NX header.yExtent = intView[ 4 ]; @@ -51372,6 +51493,7 @@ var icn3d = (function (exports) { let zBlocks = Math.ceil(header.zExtent / 8); // loop over blocks + let maxValue = -999; for(let zz = 0; zz < zBlocks; ++zz) { for(let yy = 0; yy < yBlocks; ++yy) { for(let xx = 0; xx < xBlocks; ++xx) { @@ -51387,6 +51509,7 @@ var icn3d = (function (exports) { if(x < header.xExtent && y < header.yExtent && z < header.zExtent) { let idx =((((x * header.yExtent) + y) * header.zExtent) + z); data[ idx ] =(byteView[ offset ] - summand) / divisor; + if(data[ idx ] > maxValue) maxValue = data[ idx ]; ++offset; } else { offset += 8 - i; @@ -51399,6 +51522,10 @@ var icn3d = (function (exports) { } } + if(!bInputSigma) { + sigma = this.setSigma(maxValue, location, type, sigma); + } + if(type == '2fofc') { ic.mapData.header2 = header; ic.mapData.data2 = data; @@ -51413,6 +51540,32 @@ var icn3d = (function (exports) { ic.mapData.type = type; ic.mapData.sigma = sigma; } + + return sigma; + } + + setSigma(maxValue, location, type, sigma) { let ic = this.icn3d, me = ic.icn3dui; + let inputId; + if(location == 'file') { + inputId = 'dsn6sigma' + type; + } + else if(location == 'url') { + inputId = 'dsn6sigmaurl' + type; + } + + let factor = (type == '2fofc') ? 0.5 : 0.3; + + if(inputId) { + if(!($("#" + me.pre + inputId).val())) { + sigma = (factor * maxValue).toFixed(2); + $("#" + me.pre + inputId).val(sigma); + } + else { + sigma = $("#" + me.pre + inputId).val(); + } + } + + return sigma; } getMatrix(header) { let ic = this.icn3d; ic.icn3dui; @@ -51473,7 +51626,7 @@ var icn3d = (function (exports) { return matrix; } - loadDsn6File(type, bCcp4) {var ic = this.icn3d, me = ic.icn3dui; + loadDsn6File(type) {var ic = this.icn3d, me = ic.icn3dui; let thisClass = this; let file = $("#" + ic.pre + "dsn6file" + type)[0].files[0]; @@ -51486,12 +51639,8 @@ var icn3d = (function (exports) { let reader = new FileReader(); reader.onload = function(e) { let ic = thisClass.icn3d; let arrayBuffer = e.target.result; // or = reader.result; - if(bCcp4) { - ic.densityCifParserCls.parseChannels(arrayBuffer, type, sigma); - } - else { - thisClass.loadDsn6Data(arrayBuffer, type, sigma); - } + + sigma = thisClass.loadDsn6Data(arrayBuffer, type, sigma, 'file'); if(type == '2fofc') { ic.bAjax2fofc = true; @@ -51500,21 +51649,1006 @@ var icn3d = (function (exports) { ic.bAjaxfofc = true; } ic.setOptionCls.setOption('map', type); - me.htmlCls.clickMenuCls.setLogCmd('load map file ' + $("#" + ic.pre + "dsn6file" + type).val(), false); + me.htmlCls.clickMenuCls.setLogCmd('load map file ' + $("#" + ic.pre + "dsn6file" + type).val() + ' with sigma ' + sigma, false); }; reader.readAsArrayBuffer(file); } } loadDsn6FileUrl(type) {var ic = this.icn3d, me = ic.icn3dui; + let url = $("#" + ic.pre + "dsn6fileurl" + type).val(); + let sigma = $("#" + ic.pre + "dsn6sigmaurl" + type).val(); + if(!url) { + alert("Please input the file URL before clicking 'Load'"); + } + else { + sigma = this.dsn6ParserBase(url, type, sigma, 'url'); + me.htmlCls.clickMenuCls.setLogCmd('set map ' + type + ' sigma ' + sigma + ' file dsn6 | ' + encodeURIComponent(url), true); + } + } + + } + + /** + * @file Ccp4 Parser + * @author Marcin Wojdyr + * @private + * Modified by Jiyao Wang / https://github.com/ncbi/icn3d + */ + + class Ccp4Parser { + constructor(icn3d) { + this.icn3d = icn3d; + } + + async ccp4ParserBase(url, type, sigma, location) { let ic = this.icn3d, me = ic.icn3dui; + let thisClass = this; + + //https://stackoverflow.com/questions/33902299/using-jquery-ajax-to-download-a-binary-file + // if(type == '2fofc' && ic.bAjax2fofcccp4) { + // ic.mapData.sigma2 = sigma; + // ic.setOptionCls.setOption('map', type); + // } + // else if(type == 'fofc' && ic.bAjaxfofcccp4) { + // ic.mapData.sigma = sigma; + // ic.setOptionCls.setOption('map', type); + // } + // else { + let arrayBuffer = await me.getXMLHttpRqstPromise(url, 'GET', 'arraybuffer', ''); + let bInputSigma = true; + sigma = thisClass.load_map_from_buffer(arrayBuffer, type, sigma, location, bInputSigma); + + // if(type == '2fofc') { + // ic.bAjax2fofcccp4 = true; + // } + // else if(type == 'fofc') { + // ic.bAjaxfofcccp4 = true; + // } + + ic.setOptionCls.setOption('map', type); + + return sigma; + // } + } + + // modified from_ccp4() at https://github.com/uglymol/uglymol.github.io/blob/master/src/elmap.js + load_map_from_buffer(buf, type, sigma, location, bInputSigma) { let ic = this.icn3d; ic.icn3dui; + if (buf.byteLength < 1024) throw Error('File shorter than 1024 bytes.'); + + //console.log('buf type: ' + Object.prototype.toString.call(buf)); + // for now we assume both file and host are little endian + const iview = new Int32Array(buf, 0, 256); + // word 53 - character string 'MAP ' to identify file type + if (iview[52] !== 0x2050414d) throw Error('not a CCP4 map'); + + // map has 3 dimensions referred to as columns (fastest changing), rows + // and sections (c-r-s) + const n_crs = [iview[0], iview[1], iview[2]]; // 108, 108, 108 + const mode = iview[3]; //2 + let nb; + if (mode === 2) nb = 4; + else if (mode === 0) nb = 1; + else throw Error('Only Mode 2 and Mode 0 of CCP4 map is supported.'); + + const start = [iview[4], iview[5], iview[6]]; // 0,0,0 + const n_grid = [iview[7], iview[8], iview[9]]; // 108,108,108 + const nsymbt = iview[23]; // size of extended header in bytes + // nsymbt = 1920 + + if (1024 + nsymbt + nb*n_crs[0]*n_crs[1]*n_crs[2] !== buf.byteLength) { + throw Error('ccp4 file too short or too long'); + } + + const fview = new Float32Array(buf, 0, buf.byteLength / 4); + const grid = new GridArray(n_grid); + const unit_cell = new UnitCell(fview[10], fview[11], fview[12], fview[13], fview[14], fview[15]); // 79.1, 79.1, 79.1, 90, 90, 90 + + // MAPC, MAPR, MAPS - axis corresp to cols, rows, sections (1,2,3 for X,Y,Z) + const map_crs = [iview[16], iview[17], iview[18]]; // 2,1,3 + const ax = map_crs.indexOf(1); + const ay = map_crs.indexOf(2); + const az = map_crs.indexOf(3); + + const min = fview[19]; // -0.49 + const max = fview[20]; // 0.94 + //const sg_number = iview[22]; + //const lskflg = iview[24]; + + if (nsymbt % 4 !== 0) { + throw Error('CCP4 map with NSYMBT not divisible by 4 is not supported.'); + } + let data_view; + if (mode === 2) data_view = fview; + else /* mode === 0 */ data_view = new Int8Array(buf); + let idx = (1024 + nsymbt) / nb | 0; //736 + + // We assume that if DMEAN and RMS from the header are not clearly wrong + // they are what the user wants. Because the map can cover a small part + // of the asu and its rmsd may be different than the total rmsd. + // let stats = { mean: 0.0, rms: 1.0 }; + // stats.mean = fview[21]; //0 + // stats.rms = fview[54]; //0.15 + // if (stats.mean < min || stats.mean > max || stats.rms <= 0) { + // stats = this.calculate_stddev(data_view, idx); + // } + + let b1 = 1; + let b0 = 0; + // if the file was converted by mapmode2to0 - scale the data + if (mode === 0 && iview[39] === -128 && iview[40] === 127) { //39:0, 40:0 + // scaling f(x)=b1*x+b0 such that f(-128)=min and f(127)=max + b1 = (max - min) / 255.0; + b0 = 0.5 * (min + max + b1); + } + + const end = [start[0] + n_crs[0], start[1] + n_crs[1], start[2] + n_crs[2]]; + let it = [0, 0, 0]; + let maxValue = -999; + for (it[2] = start[2]; it[2] < end[2]; it[2]++) { // sections + for (it[1] = start[1]; it[1] < end[1]; it[1]++) { // rows + for (it[0] = start[0]; it[0] < end[0]; it[0]++) { // cols + let value = b1 * data_view[idx] + b0; + grid.set_grid_value(it[ax], it[ay], it[az], value); + + if(value > maxValue) maxValue = value; + idx++; + } + } + } + + /* + if (expand_symmetry && nsymbt > 0) { + const u8view = new Uint8Array(buf); + for (let i = 0; i+80 <= nsymbt; i += 80) { + let j; + let symop = ''; + for (j = 0; j < 80; ++j) { + symop += String.fromCharCode(u8view[1024 + i + j]); + } + if (/^\s*x\s*,\s*y\s*,\s*z\s*$/i.test(symop)) continue; // skip x,y,z + //console.log('sym ops', symop.trim()); + let mat = this.parse_symop(symop); + // Note: we apply here symops to grid points instead of coordinates. + // In the cases we came across it is equivalent, but in general not. + for (j = 0; j < 3; ++j) { + mat[j][3] = Math.round(mat[j][3] * n_grid[j]) | 0; + } + idx = (1024 + nsymbt) / nb | 0; + let xyz = [0, 0, 0]; + for (it[2] = start[2]; it[2] < end[2]; it[2]++) { // sections + for (it[1] = start[1]; it[1] < end[1]; it[1]++) { // rows + for (it[0] = start[0]; it[0] < end[0]; it[0]++) { // cols + for (j = 0; j < 3; ++j) { + xyz[j] = it[ax] * mat[j][0] + it[ay] * mat[j][1] + + it[az] * mat[j][2] + mat[j][3]; + } + let value = b1 * data_view[idx] + b0; + grid.set_grid_value(xyz[0], xyz[1], xyz[2], value); + + if(value > maxValue) maxValue = value; + idx++; + } + } + } + } + } + */ + + if(!bInputSigma) { + sigma = ic.dsn6ParserCls.setSigma(maxValue, location, type, sigma); + } + + if(type == '2fofc') { + ic.mapData.ccp4 = 1; + ic.mapData.grid2 = grid; + ic.mapData.unit_cell2 = unit_cell; + ic.mapData.type2 = type; + ic.mapData.sigma2 = sigma; + } + else { + ic.mapData.ccp4 = 1; + ic.mapData.grid = grid; + ic.mapData.unit_cell = unit_cell; + ic.mapData.type = type; + ic.mapData.sigma = sigma; + } + + return sigma; + } + + load_maps_from_mtz_buffer(mtz, type, sigma, location, bInputSigma) { let ic = this.icn3d; ic.icn3dui; + let is_diff = (type == 'fofc'); // diff: fofc, non-diff: 2fofc + let dataArray = mtz.calculate_map(is_diff); + + let mc = mtz.cell; + const unit_cell = new UnitCell(mc.a, mc.b, mc.c, mc.alpha, mc.beta, mc.gamma); + + let maxValue = -999; + for(let i = 0, il = dataArray.length; i < il; ++i) { + if(dataArray[i] > maxValue) maxValue = dataArray[i]; + } + + if(!bInputSigma) { + sigma = ic.dsn6ParserCls.setSigma(maxValue, location, type, sigma); + } + + const grid = new GridArray([mtz.nx, mtz.ny, mtz.nz]); + grid.values.set(dataArray); + + if(type == '2fofc') { + ic.mapData.ccp4 = 1; + ic.mapData.grid2 = grid; + ic.mapData.unit_cell2 = unit_cell; + ic.mapData.type2 = type; + ic.mapData.sigma2 = sigma; + } + else { + ic.mapData.ccp4 = 1; + ic.mapData.grid = grid; + ic.mapData.unit_cell = unit_cell; + ic.mapData.type = type; + ic.mapData.sigma = sigma; + } + + mtz.delete(); + + return sigma; + } + + // calculate_stddev(a, offset) { + // let sum = 0; + // let sq_sum = 0; + // const alen = a.length; + // for (let i = offset; i < alen; i++) { + // sum += a[i]; + // sq_sum += a[i] * a[i]; + // } + // const mean = sum / (alen - offset); + // const variance = sq_sum / (alen - offset) - mean * mean; + // return {mean: mean, rms: Math.sqrt(variance)}; + // } + + parse_symop(symop) { + const ops = symop.toLowerCase().replace(/\s+/g, '').split(','); + if (ops.length !== 3) throw Error('Unexpected symop: ' + symop); + let mat = []; + for (let i = 0; i < 3; i++) { + const terms = ops[i].split(/(?=[+-])/); + let row = [0, 0, 0, 0]; + for (let j = 0; j < terms.length; j++) { + const term = terms[j]; + const sign = (term[0] === '-' ? -1 : 1); + let m = terms[j].match(/^[+-]?([xyz])$/); + if (m) { + const pos = {x: 0, y: 1, z: 2}[m[1]]; + row[pos] = sign; + } else { + m = terms[j].match(/^[+-]?(\d)\/(\d)$/); + if (!m) throw Error('What is ' + terms[j] + ' in ' + symop); + row[3] = sign * Number(m[1]) / Number(m[2]); + } + } + mat.push(row); + } + return mat; + } + + loadCcp4File(type) {let ic = this.icn3d, me = ic.icn3dui; + let thisClass = this; + + let file = $("#" + ic.pre + "dsn6file" + type)[0].files[0]; + let sigma = $("#" + ic.pre + "dsn6sigma" + type).val(); + if(!file) { + alert("Please select a file before clicking 'Load'"); + } + else { + me.utilsCls.checkFileAPI(); + let reader = new FileReader(); + reader.onload = function(e) { let ic = thisClass.icn3d; + let arrayBuffer = e.target.result; // or = reader.result; + sigma = thisClass.load_map_from_buffer(arrayBuffer, type, sigma, 'file'); + + // if(type == '2fofc') { + // ic.bAjax2fofcCcp4 = true; + // } + // else if(type == 'fofc') { + // ic.bAjaxfofcCcp4 = true; + // } + ic.setOptionCls.setOption('map', type); + me.htmlCls.clickMenuCls.setLogCmd('load map file ' + $("#" + ic.pre + "dsn6file" + type).val() + ' with sigma ' + sigma, false); + }; + reader.readAsArrayBuffer(file); + } + } + + async loadCcp4FileUrl(type) { let ic = this.icn3d, me = ic.icn3dui; let url = $("#" + ic.pre + "dsn6fileurl" + type).val(); let sigma = $("#" + ic.pre + "dsn6sigmaurl" + type).val(); if(!url) { alert("Please input the file URL before clicking 'Load'"); } else { - this.dsn6ParserBase(url, type, sigma); - me.htmlCls.clickMenuCls.setLogCmd('set map ' + type + ' sigma ' + sigma + ' | ' + encodeURIComponent(url), true); + sigma = await this.ccp4ParserBase(url, type, sigma, 'file'); + + me.htmlCls.clickMenuCls.setLogCmd('set map ' + type + ' sigma ' + sigma + ' file ccp4 | ' + encodeURIComponent(url), true); + } + } + + // Extract a block of density for calculating an isosurface using the + // separate marching cubes implementation. + extract_block(grid, unit_cell, radius, center, typeDetail) { let ic = this.icn3d; ic.icn3dui; + // let grid = this.grid; + // let unit_cell = this.unit_cell; + if (grid == null || unit_cell == null) { return; } + let fc = unit_cell.fractionalize(center); + + let r = [radius / unit_cell.parameters[0], + radius / unit_cell.parameters[1], + radius / unit_cell.parameters[2]]; + let grid_min = grid.frac2grid([fc[0] - r[0], fc[1] - r[1], fc[2] - r[2]]); + let grid_max = grid.frac2grid([fc[0] + r[0], fc[1] + r[1], fc[2] + r[2]]); + + let size = [grid_max[0] - grid_min[0] + 1, + grid_max[1] - grid_min[1] + 1, + grid_max[2] - grid_min[2] + 1]; + let points = []; + let values = []; + let threshold = 1; + let bAtoms = ic.hAtoms && Object.keys(ic.hAtoms).length > 0; + for (let i = grid_min[0]; i <= grid_max[0]; i++) { + for (let j = grid_min[1]; j <= grid_max[1]; j++) { + for (let k = grid_min[2]; k <= grid_max[2]; k++) { + let frac = grid.grid2frac(i, j, k); + let orth = unit_cell.orthogonalize(frac); + points.push(orth); + + // get overlap between map and atoms + let positoin = new THREE.Vector3(orth[0], orth[1], orth[2]); + let atomsNear = ic.rayCls.getAtomsFromPosition(positoin, threshold, ic.hAtoms); + + let map_value = (atomsNear || !bAtoms) ? grid.get_grid_value(i, j, k) : 0; + + if(typeDetail == 'fofc_pos' && map_value < 0) map_value = 0; + if(typeDetail == 'fofc_neg') map_value = (map_value > 0) ? 0 : -map_value; + + values.push(map_value); + } + } + } + + return {size: size, values: values, points: points}; + // this.block.set(points, values, size); + }; + + marchingCubes(dims, values, points, isolevel, method) { let ic = this.icn3d; ic.icn3dui; + const edgeTable = new Int32Array([ + 0x0 , 0x0 , 0x202, 0x302, 0x406, 0x406, 0x604, 0x704, + 0x804, 0x805, 0xa06, 0xa06, 0xc0a, 0xd03, 0xe08, 0xf00, + 0x90 , 0x98 , 0x292, 0x292, 0x496, 0x49e, 0x694, 0x694, + 0x894, 0x894, 0xa96, 0xa96, 0xc9a, 0xc92, 0xe91, 0xe90, + 0x230, 0x230, 0x33 , 0x13a, 0x636, 0x636, 0x434, 0x43c, + 0xa34, 0xa35, 0x837, 0x936, 0xe3a, 0xf32, 0xc31, 0xd30, + 0x2a0, 0x2a8, 0xa3 , 0xaa , 0x6a6, 0x6af, 0x5a4, 0x4ac, + 0xaa4, 0xaa4, 0x9a6, 0x8a6, 0xfaa, 0xea3, 0xca1, 0xca0, + 0x460, 0x460, 0x662, 0x762, 0x66 , 0x66 , 0x265, 0x364, + 0xc64, 0xc65, 0xe66, 0xe66, 0x86a, 0x863, 0xa69, 0xa60, + 0x4f0, 0x4f8, 0x6f2, 0x6f2, 0xf6 , 0xfe , 0x2f5, 0x2fc, + 0xcf4, 0xcf4, 0xef6, 0xef6, 0x8fa, 0x8f3, 0xaf9, 0xaf0, + 0x650, 0x650, 0x453, 0x552, 0x256, 0x256, 0x54 , 0x154, + 0xe54, 0xf54, 0xc57, 0xd56, 0xa5a, 0xb52, 0x859, 0x950, + 0x7c0, 0x6c1, 0x5c2, 0x4c2, 0x3c6, 0x2ce, 0xc5 , 0xc4 , + 0xfc4, 0xec5, 0xdc6, 0xcc6, 0xbca, 0xac2, 0x8c1, 0x8c0, + 0x8c0, 0x8c0, 0xac2, 0xbc2, 0xcc6, 0xcc6, 0xec4, 0xfcc, + 0xc4 , 0xc5 , 0x2c6, 0x3c6, 0x4c2, 0x5c2, 0x6c1, 0x7c0, + 0x950, 0x859, 0xb52, 0xa5a, 0xd56, 0xc57, 0xe54, 0xe5c, + 0x154, 0x54 , 0x25e, 0x256, 0x552, 0x453, 0x658, 0x650, + 0xaf0, 0xaf0, 0x8f3, 0x8fa, 0xef6, 0xef6, 0xcf4, 0xcfc, + 0x2f4, 0x3f5, 0xff , 0x1f6, 0x6f2, 0x6f3, 0x4f9, 0x5f0, + 0xa60, 0xa69, 0x863, 0x86a, 0xe66, 0xe67, 0xd65, 0xc6c, + 0x364, 0x265, 0x166, 0x66 , 0x76a, 0x663, 0x460, 0x460, + 0xca0, 0xca0, 0xea2, 0xfa2, 0x8a6, 0x8a6, 0xaa4, 0xba4, + 0x4ac, 0x5a4, 0x6ae, 0x7a6, 0xaa , 0xa3 , 0x2a8, 0x2a0, + 0xd30, 0xc31, 0xf32, 0xe3a, 0x936, 0x837, 0xb35, 0xa34, + 0x43c, 0x434, 0x73e, 0x636, 0x13a, 0x33 , 0x339, 0x230, + 0xe90, 0xe90, 0xc92, 0xc9a, 0xa96, 0xa96, 0x894, 0x89c, + 0x694, 0x695, 0x49f, 0x496, 0x292, 0x392, 0x98 , 0x90 , + 0xf00, 0xe08, 0xd03, 0xc0a, 0xa06, 0xa0e, 0x805, 0x804, + 0x704, 0x604, 0x506, 0x406, 0x302, 0x202, 0x0 , 0x0]); + + const segTable = [ + [], + [], + [1, 9], + [1, 8, 1, 9], + [2, 10, 10, 1], + [2, 10, 10, 1], + [9, 2, 2, 10, 10, 9], + [2, 8, 2, 10, 10, 8, 10, 9], + [11, 2], + [0, 11, 11, 2], + [1, 9, 11, 2], + [1, 11, 11, 2, 1, 9, 9, 11], + [3, 10, 10, 1, 11, 10], + [0, 10, 10, 1, 8, 10, 11, 10], + [3, 9, 11, 9, 11, 10, 10, 9], + [8, 10, 10, 9, 11, 10], + [4, 7], + [4, 3, 4, 7], + [1, 9, 4, 7], + [4, 1, 1, 9, 4, 7, 7, 1], + [2, 10, 10, 1, 4, 7], + [3, 4, 4, 7, 2, 10, 10, 1], + [9, 2, 2, 10, 10, 9, 4, 7], + [2, 10, 10, 9, 9, 2, 9, 7, 7, 2, 4, 7], + [4, 7, 11, 2], + [11, 4, 4, 7, 11, 2, 2, 4], + [1, 9, 4, 7, 11, 2], + [4, 7, 11, 4, 11, 9, 11, 2, 2, 9, 1, 9], + [3, 10, 10, 1, 11, 10, 4, 7], + [1, 11, 11, 10, 10, 1, 1, 4, 4, 11, 4, 7], + [4, 7, 0, 11, 11, 9, 11, 10, 10, 9], + [4, 7, 11, 4, 11, 9, 11, 10, 10, 9], + [9, 5, 5, 4], + [9, 5, 5, 4], + [0, 5, 5, 4, 1, 5], + [8, 5, 5, 4, 3, 5, 1, 5], + [2, 10, 10, 1, 9, 5, 5, 4], + [2, 10, 10, 1, 9, 5, 5, 4], + [5, 2, 2, 10, 10, 5, 5, 4, 4, 2], + [2, 10, 10, 5, 5, 2, 5, 3, 5, 4, 4, 3], + [9, 5, 5, 4, 11, 2], + [0, 11, 11, 2, 9, 5, 5, 4], + [0, 5, 5, 4, 1, 5, 11, 2], + [1, 5, 5, 2, 5, 8, 8, 2, 11, 2, 5, 4], + [10, 3, 11, 10, 10, 1, 9, 5, 5, 4], + [9, 5, 5, 4, 8, 1, 8, 10, 10, 1, 11, 10], + [5, 4, 0, 5, 0, 11, 11, 5, 11, 10, 10, 5], + [5, 4, 8, 5, 8, 10, 10, 5, 11, 10], + [9, 7, 5, 7, 9, 5], + [9, 3, 9, 5, 5, 3, 5, 7], + [0, 7, 1, 7, 1, 5, 5, 7], + [1, 5, 5, 3, 5, 7], + [9, 7, 9, 5, 5, 7, 10, 1, 2, 10], + [10, 1, 2, 10, 9, 5, 5, 0, 5, 3, 5, 7], + [2, 8, 2, 5, 5, 8, 5, 7, 10, 5, 2, 10], + [2, 10, 10, 5, 5, 2, 5, 3, 5, 7], + [7, 9, 9, 5, 5, 7, 11, 2], + [9, 5, 5, 7, 7, 9, 7, 2, 2, 9, 11, 2], + [11, 2, 1, 8, 1, 7, 1, 5, 5, 7], + [11, 2, 1, 11, 1, 7, 1, 5, 5, 7], + [9, 5, 5, 8, 5, 7, 10, 1, 3, 10, 11, 10], + [5, 7, 7, 0, 0, 5, 9, 5, 11, 0, 0, 10, 10, 1, 11, 10], + [11, 10, 10, 0, 0, 11, 10, 5, 5, 0, 0, 7, 5, 7], + [11, 10, 10, 5, 5, 11, 5, 7], + [10, 6, 6, 5, 5, 10], + [5, 10, 10, 6, 6, 5], + [1, 9, 5, 10, 10, 6, 6, 5], + [1, 8, 1, 9, 5, 10, 10, 6, 6, 5], + [1, 6, 6, 5, 5, 1, 2, 6], + [1, 6, 6, 5, 5, 1, 2, 6], + [9, 6, 6, 5, 5, 9, 0, 6, 2, 6], + [5, 9, 8, 5, 8, 2, 2, 5, 2, 6, 6, 5], + [11, 2, 10, 6, 6, 5, 5, 10], + [11, 0, 11, 2, 10, 6, 6, 5, 5, 10], + [1, 9, 11, 2, 5, 10, 10, 6, 6, 5], + [5, 10, 10, 6, 6, 5, 1, 9, 9, 2, 9, 11, 11, 2], + [6, 3, 11, 6, 6, 5, 5, 3, 5, 1], + [11, 0, 11, 5, 5, 0, 5, 1, 11, 6, 6, 5], + [11, 6, 6, 3, 6, 0, 6, 5, 5, 0, 5, 9], + [6, 5, 5, 9, 9, 6, 9, 11, 11, 6], + [5, 10, 10, 6, 6, 5, 4, 7], + [4, 3, 4, 7, 6, 5, 5, 10, 10, 6], + [1, 9, 5, 10, 10, 6, 6, 5, 4, 7], + [10, 6, 6, 5, 5, 10, 1, 9, 9, 7, 7, 1, 4, 7], + [6, 1, 2, 6, 6, 5, 5, 1, 4, 7], + [2, 5, 5, 1, 2, 6, 6, 5, 4, 3, 4, 7], + [4, 7, 0, 5, 5, 9, 0, 6, 6, 5, 2, 6], + [3, 9, 9, 7, 4, 7, 2, 9, 5, 9, 9, 6, 6, 5, 2, 6], + [11, 2, 4, 7, 10, 6, 6, 5, 5, 10], + [5, 10, 10, 6, 6, 5, 4, 7, 7, 2, 2, 4, 11, 2], + [1, 9, 4, 7, 11, 2, 5, 10, 10, 6, 6, 5], + [9, 2, 1, 9, 9, 11, 11, 2, 4, 11, 4, 7, 5, 10, 10, 6, 6, 5], + [4, 7, 11, 5, 5, 3, 5, 1, 11, 6, 6, 5], + [5, 1, 1, 11, 11, 5, 11, 6, 6, 5, 0, 11, 11, 4, 4, 7], + [0, 5, 5, 9, 0, 6, 6, 5, 3, 6, 11, 6, 4, 7], + [6, 5, 5, 9, 9, 6, 9, 11, 11, 6, 4, 7, 7, 9], + [10, 4, 9, 10, 6, 4, 10, 6], + [4, 10, 10, 6, 6, 4, 9, 10], + [10, 0, 1, 10, 10, 6, 6, 0, 6, 4], + [1, 8, 1, 6, 6, 8, 6, 4, 1, 10, 10, 6], + [1, 4, 9, 1, 2, 4, 2, 6, 6, 4], + [2, 9, 9, 1, 2, 4, 2, 6, 6, 4], + [2, 4, 2, 6, 6, 4], + [2, 8, 2, 4, 2, 6, 6, 4], + [10, 4, 9, 10, 10, 6, 6, 4, 11, 2], + [8, 2, 11, 2, 9, 10, 10, 4, 10, 6, 6, 4], + [11, 2, 1, 6, 6, 0, 6, 4, 1, 10, 10, 6], + [6, 4, 4, 1, 1, 6, 1, 10, 10, 6, 8, 1, 1, 11, 11, 2], + [9, 6, 6, 4, 9, 3, 3, 6, 9, 1, 11, 6], + [11, 1, 1, 8, 11, 6, 6, 1, 9, 1, 1, 4, 6, 4], + [11, 6, 6, 3, 6, 0, 6, 4], + [6, 4, 8, 6, 11, 6], + [7, 10, 10, 6, 6, 7, 8, 10, 9, 10], + [0, 7, 0, 10, 10, 7, 9, 10, 6, 7, 10, 6], + [10, 6, 6, 7, 7, 10, 1, 10, 7, 1, 8, 1], + [10, 6, 6, 7, 7, 10, 7, 1, 1, 10], + [2, 6, 6, 1, 6, 8, 8, 1, 9, 1, 6, 7], + [2, 6, 6, 9, 9, 2, 9, 1, 6, 7, 7, 9, 9, 3], + [0, 7, 0, 6, 6, 7, 2, 6], + [2, 7, 6, 7, 2, 6], + [11, 2, 10, 6, 6, 8, 8, 10, 9, 10, 6, 7], + [0, 7, 7, 2, 11, 2, 9, 7, 6, 7, 7, 10, 10, 6, 9, 10], + [1, 8, 1, 7, 1, 10, 10, 7, 6, 7, 10, 6, 11, 2], + [11, 2, 1, 11, 1, 7, 10, 6, 6, 1, 1, 10, 6, 7], + [9, 6, 6, 8, 6, 7, 9, 1, 1, 6, 11, 6, 6, 3], + [9, 1, 11, 6, 6, 7], + [0, 7, 0, 6, 6, 7, 11, 0, 11, 6], + [11, 6, 6, 7], + [7, 6, 6, 11], + [7, 6, 6, 11], + [1, 9, 7, 6, 6, 11], + [8, 1, 1, 9, 7, 6, 6, 11], + [10, 1, 2, 10, 6, 11, 7, 6], + [2, 10, 10, 1, 6, 11, 7, 6], + [2, 9, 2, 10, 10, 9, 6, 11, 7, 6], + [6, 11, 7, 6, 2, 10, 10, 3, 10, 8, 10, 9], + [7, 2, 6, 2, 7, 6], + [7, 0, 7, 6, 6, 0, 6, 2], + [2, 7, 7, 6, 6, 2, 1, 9], + [1, 6, 6, 2, 1, 8, 8, 6, 1, 9, 7, 6], + [10, 7, 7, 6, 6, 10, 10, 1, 1, 7], + [10, 7, 7, 6, 6, 10, 1, 7, 10, 1, 1, 8], + [7, 0, 7, 10, 10, 0, 10, 9, 6, 10, 7, 6], + [7, 6, 6, 10, 10, 7, 10, 8, 10, 9], + [6, 8, 4, 6, 6, 11], + [3, 6, 6, 11, 0, 6, 4, 6], + [8, 6, 6, 11, 4, 6, 1, 9], + [4, 6, 6, 9, 6, 3, 3, 9, 1, 9, 6, 11], + [6, 8, 4, 6, 6, 11, 2, 10, 10, 1], + [2, 10, 10, 1, 0, 11, 0, 6, 6, 11, 4, 6], + [4, 11, 4, 6, 6, 11, 2, 9, 2, 10, 10, 9], + [10, 9, 9, 3, 3, 10, 2, 10, 4, 3, 3, 6, 6, 11, 4, 6], + [8, 2, 4, 2, 4, 6, 6, 2], + [4, 2, 4, 6, 6, 2], + [1, 9, 3, 4, 4, 2, 4, 6, 6, 2], + [1, 9, 4, 1, 4, 2, 4, 6, 6, 2], + [8, 1, 8, 6, 6, 1, 4, 6, 6, 10, 10, 1], + [10, 1, 0, 10, 0, 6, 6, 10, 4, 6], + [4, 6, 6, 3, 3, 4, 6, 10, 10, 3, 3, 9, 10, 9], + [10, 9, 4, 10, 6, 10, 4, 6], + [9, 5, 5, 4, 7, 6, 6, 11], + [9, 5, 5, 4, 7, 6, 6, 11], + [5, 0, 1, 5, 5, 4, 7, 6, 6, 11], + [7, 6, 6, 11, 3, 4, 3, 5, 5, 4, 1, 5], + [9, 5, 5, 4, 10, 1, 2, 10, 7, 6, 6, 11], + [6, 11, 7, 6, 2, 10, 10, 1, 9, 5, 5, 4], + [7, 6, 6, 11, 5, 4, 4, 10, 10, 5, 4, 2, 2, 10], + [3, 4, 3, 5, 5, 4, 2, 5, 10, 5, 2, 10, 7, 6, 6, 11], + [7, 2, 7, 6, 6, 2, 5, 4, 9, 5], + [9, 5, 5, 4, 8, 6, 6, 0, 6, 2, 7, 6], + [3, 6, 6, 2, 7, 6, 1, 5, 5, 0, 5, 4], + [6, 2, 2, 8, 8, 6, 7, 6, 1, 8, 8, 5, 5, 4, 1, 5], + [9, 5, 5, 4, 10, 1, 1, 6, 6, 10, 1, 7, 7, 6], + [1, 6, 6, 10, 10, 1, 1, 7, 7, 6, 0, 7, 9, 5, 5, 4], + [0, 10, 10, 4, 10, 5, 5, 4, 3, 10, 6, 10, 10, 7, 7, 6], + [7, 6, 6, 10, 10, 7, 10, 8, 5, 4, 4, 10, 10, 5], + [6, 9, 9, 5, 5, 6, 6, 11, 11, 9], + [3, 6, 6, 11, 0, 6, 0, 5, 5, 6, 9, 5], + [0, 11, 0, 5, 5, 11, 1, 5, 5, 6, 6, 11], + [6, 11, 3, 6, 3, 5, 5, 6, 1, 5], + [2, 10, 10, 1, 9, 5, 5, 11, 11, 9, 5, 6, 6, 11], + [0, 11, 0, 6, 6, 11, 9, 6, 5, 6, 9, 5, 2, 10, 10, 1], + [8, 5, 5, 11, 5, 6, 6, 11, 0, 5, 10, 5, 5, 2, 2, 10], + [6, 11, 3, 6, 3, 5, 5, 6, 2, 10, 10, 3, 10, 5], + [5, 8, 9, 5, 5, 2, 2, 8, 5, 6, 6, 2], + [9, 5, 5, 6, 6, 9, 6, 0, 6, 2], + [1, 5, 5, 8, 8, 1, 5, 6, 6, 8, 8, 2, 6, 2], + [1, 5, 5, 6, 6, 1, 6, 2], + [3, 6, 6, 1, 6, 10, 10, 1, 8, 6, 5, 6, 6, 9, 9, 5], + [10, 1, 0, 10, 0, 6, 6, 10, 9, 5, 5, 0, 5, 6], + [5, 6, 6, 10, 10, 5], + [10, 5, 5, 6, 6, 10], + [11, 5, 5, 10, 10, 11, 7, 5], + [11, 5, 5, 10, 10, 11, 7, 5], + [5, 11, 7, 5, 5, 10, 10, 11, 1, 9], + [10, 7, 7, 5, 5, 10, 10, 11, 8, 1, 1, 9], + [11, 1, 2, 11, 7, 1, 7, 5, 5, 1], + [2, 7, 7, 1, 7, 5, 5, 1, 2, 11], + [9, 7, 7, 5, 5, 9, 9, 2, 2, 7, 2, 11], + [7, 5, 5, 2, 2, 7, 2, 11, 5, 9, 9, 2, 2, 8], + [2, 5, 5, 10, 10, 2, 3, 5, 7, 5], + [8, 2, 8, 5, 5, 2, 7, 5, 10, 2, 5, 10], + [1, 9, 5, 10, 10, 3, 3, 5, 7, 5, 10, 2], + [8, 2, 2, 9, 1, 9, 7, 2, 10, 2, 2, 5, 5, 10, 7, 5], + [3, 5, 5, 1, 7, 5], + [7, 0, 7, 1, 7, 5, 5, 1], + [3, 9, 3, 5, 5, 9, 7, 5], + [7, 9, 5, 9, 7, 5], + [5, 8, 4, 5, 5, 10, 10, 8, 10, 11], + [5, 0, 4, 5, 5, 11, 11, 0, 5, 10, 10, 11], + [1, 9, 4, 10, 10, 8, 10, 11, 4, 5, 5, 10], + [10, 11, 11, 4, 4, 10, 4, 5, 5, 10, 3, 4, 4, 1, 1, 9], + [2, 5, 5, 1, 2, 8, 8, 5, 2, 11, 4, 5], + [4, 11, 11, 0, 4, 5, 5, 11, 2, 11, 11, 1, 5, 1], + [2, 5, 5, 0, 5, 9, 2, 11, 11, 5, 4, 5, 5, 8], + [4, 5, 5, 9, 2, 11], + [2, 5, 5, 10, 10, 2, 3, 5, 3, 4, 4, 5], + [5, 10, 10, 2, 2, 5, 2, 4, 4, 5], + [3, 10, 10, 2, 3, 5, 5, 10, 8, 5, 4, 5, 1, 9], + [5, 10, 10, 2, 2, 5, 2, 4, 4, 5, 1, 9, 9, 2], + [4, 5, 5, 8, 5, 3, 5, 1], + [4, 5, 5, 0, 5, 1], + [4, 5, 5, 8, 5, 3, 0, 5, 5, 9], + [4, 5, 5, 9], + [4, 11, 7, 4, 9, 11, 9, 10, 10, 11], + [9, 7, 7, 4, 9, 11, 9, 10, 10, 11], + [1, 10, 10, 11, 11, 1, 11, 4, 4, 1, 7, 4], + [1, 4, 4, 3, 1, 10, 10, 4, 7, 4, 4, 11, 10, 11], + [4, 11, 7, 4, 9, 11, 9, 2, 2, 11, 9, 1], + [9, 7, 7, 4, 9, 11, 9, 1, 1, 11, 2, 11], + [7, 4, 4, 11, 4, 2, 2, 11], + [7, 4, 4, 11, 4, 2, 2, 11, 3, 4], + [2, 9, 9, 10, 10, 2, 2, 7, 7, 9, 7, 4], + [9, 10, 10, 7, 7, 9, 7, 4, 10, 2, 2, 7, 7, 0], + [7, 10, 10, 3, 10, 2, 7, 4, 4, 10, 1, 10, 10, 0], + [1, 10, 10, 2, 7, 4], + [9, 1, 1, 4, 1, 7, 7, 4], + [9, 1, 1, 4, 1, 7, 7, 4, 8, 1], + [3, 4, 7, 4], + [7, 4], + [9, 10, 10, 8, 10, 11], + [9, 3, 9, 11, 9, 10, 10, 11], + [1, 10, 10, 0, 10, 8, 10, 11], + [1, 10, 10, 3, 10, 11], + [2, 11, 11, 1, 11, 9, 9, 1], + [9, 3, 9, 11, 2, 9, 9, 1, 2, 11], + [2, 11, 11, 0], + [2, 11], + [8, 2, 8, 10, 10, 2, 9, 10], + [9, 10, 10, 2, 2, 9], + [8, 2, 8, 10, 10, 2, 1, 8, 1, 10], + [1, 10, 10, 2], + [8, 1, 9, 1], + [9, 1], + [], + []]; + + const snap = (method === 'snapped MC'); + // const seg_table = (method === 'squarish' ? segTable2 : segTable); + const seg_table = segTable; + + let vlist = new Array(12); + const vert_offsets = this.calculateVertOffsets(dims); + + const edgeIndex = [[0,1], [1,2], [2,3], [3,0], [4,5], [5,6], + [6,7], [7,4], [0,4], [1,5], [2,6], [3,7]]; + + let vertex_values = new Float32Array(8); + let p0 = [0, 0, 0]; // unused initial value - to make Flow happy + let vertex_points = [p0, p0, p0, p0, p0, p0, p0, p0]; + const size_x = dims[0]; + const size_y = dims[1]; + const size_z = dims[2]; + if (values == null || points == null) return; + let vertices = []; + let segments = []; + let vertex_count = 0; + for (let x = 0; x < size_x - 1; x++) { + for (let y = 0; y < size_y - 1; y++) { + for (let z = 0; z < size_z - 1; z++) { + const offset0 = z + size_z * (y + size_y * x); + let cubeindex = 0; + let i; + let j; + for (i = 0; i < 8; ++i) { + j = offset0 + vert_offsets[i]; + cubeindex |= (values[j] < isolevel) ? 1 << i : 0; + } + if (cubeindex === 0 || cubeindex === 255) continue; + for (i = 0; i < 8; ++i) { + j = offset0 + vert_offsets[i]; + vertex_values[i] = values[j]; + vertex_points[i] = points[j]; + } + + // 12 bit number, indicates which edges are crossed by the isosurface + const edge_mask = edgeTable[cubeindex]; + + // check which edges are crossed, and estimate the point location + // using a weighted average of scalar values at edge endpoints. + for (i = 0; i < 12; ++i) { + if ((edge_mask & (1 << i)) !== 0) { + const e = edgeIndex[i]; + let mu = (isolevel - vertex_values[e[0]]) / + (vertex_values[e[1]] - vertex_values[e[0]]); + if (snap === true) { + if (mu > 0.85) mu = 1; + else if (mu < 0.15) mu = 0; + } + const p1 = vertex_points[e[0]]; + const p2 = vertex_points[e[1]]; + // The number of added vertices could be roughly halved + // if we avoided duplicates between neighbouring cells. + // Using a map for lookups is too slow, perhaps a big + // array would do? + vertices.push(p1[0] + (p2[0] - p1[0]) * mu, + p1[1] + (p2[1] - p1[1]) * mu, + p1[2] + (p2[2] - p1[2]) * mu); + vlist[i] = vertex_count++; + } + } + const t = seg_table[cubeindex]; + for (i = 0; i < t.length; i++) { + segments.push(vlist[t[i]]); + } + } + } + } + + return { vertices: vertices, segments: segments }; + } + + // return offsets relative to vertex [0,0,0] + calculateVertOffsets(dims) { let ic = this.icn3d; ic.icn3dui; + let vert_offsets = []; + const cubeVerts = [[0,0,0], [1,0,0], [1,1,0], [0,1,0], + [0,0,1], [1,0,1], [1,1,1], [0,1,1]]; + + for (let i = 0; i < 8; ++i) { + const v = cubeVerts[i]; + vert_offsets.push(v[0] + dims[2] * (v[1] + dims[1] * v[2])); + } + return vert_offsets; + } + + makeChickenWire(data, typeDetail) { let ic = this.icn3d, me = ic.icn3dui; + let geom = new THREE.BufferGeometry(); + let position = new Float32Array(data.vertices); + geom.setAttribute('position', new THREE.BufferAttribute(position, 3)); + + // Although almost all browsers support OES_element_index_uint nowadays, + // use Uint32 indexes only when needed. + let arr = (data.vertices.length < 3*65536 ? new Uint16Array(data.segments) : new Uint32Array(data.segments)); + + geom.setIndex(new THREE.BufferAttribute(arr, 1)); + + let colorFor2fofc = me.parasCls.thr('#00FFFF'); + let colorForfofcPos = me.parasCls.thr('#00FF00'); + let colorForfofcNeg = me.parasCls.thr('#ff0000'); + + let color = (typeDetail == '2fofc') ? colorFor2fofc : ((typeDetail == 'fofc_pos') ? colorForfofcPos : colorForfofcNeg); + let material = new THREE.LineBasicMaterial({ linewidth: 1, color: color }); + //return new THREE.LineSegments(geom, material); + + let mesh = new THREE.LineSegments(geom, material); + ic.mdl.add(mesh); + + ic.prevMaps.push(mesh); + } + } + + + class UnitCell { + /*:: + parameters: number[] + orth: number[] + frac: number[] + */ + // eslint-disable-next-line max-params + constructor(a /*:number*/, b /*:number*/, c /*:number*/, + alpha /*:number*/, beta /*:number*/, gamma /*:number*/) { + if (a <= 0 || b <= 0 || c <= 0 || alpha <= 0 || beta <= 0 || gamma <= 0) { + throw Error('Zero or negative unit cell parameter(s).'); + } + this.parameters = [a, b, c, alpha, beta, gamma]; + const deg2rad = Math.PI / 180.0; + const cos_alpha = Math.cos(deg2rad * alpha); + const cos_beta = Math.cos(deg2rad * beta); + const cos_gamma = Math.cos(deg2rad * gamma); + const sin_alpha = Math.sin(deg2rad * alpha); + const sin_beta = Math.sin(deg2rad * beta); + const sin_gamma = Math.sin(deg2rad * gamma); + if (sin_alpha === 0 || sin_beta === 0 || sin_gamma === 0) { + throw Error('Impossible angle - N*180deg.'); + } + const cos_alpha_star_sin_beta = (cos_beta * cos_gamma - cos_alpha) / + sin_gamma; + const cos_alpha_star = cos_alpha_star_sin_beta / sin_beta; + const s1rca2 = Math.sqrt(1.0 - cos_alpha_star * cos_alpha_star); + // The orthogonalization matrix we use is described in ITfC B p.262: + // "An alternative mode of orthogonalization, used by the Protein + // Data Bank and most programs, is to align the a1 axis of the unit + // cell with the Cartesian X_1 axis, and to align the a*_3 axis with the + // Cartesian X_3 axis." + // + // Zeros in the matrices below are kept to make matrix multiplication + // faster: they make extract_block() 2x (!) faster on V8 4.5.103, + // no difference on FF 50. + /* eslint-disable no-multi-spaces, comma-spacing */ + this.orth = [a, b * cos_gamma, c * cos_beta, + 0.0, b * sin_gamma, -c * cos_alpha_star_sin_beta, + 0.0, 0.0 , c * sin_beta * s1rca2]; + // based on xtal.js which is based on cctbx.uctbx + this.frac = [ + 1.0 / a, + -cos_gamma / (sin_gamma * a), + -(cos_gamma * cos_alpha_star_sin_beta + cos_beta * sin_gamma) / + (sin_beta * s1rca2 * sin_gamma * a), + 0.0, + 1.0 / (sin_gamma * b), + cos_alpha_star / (s1rca2 * sin_gamma * b), + 0.0, + 0.0, + 1.0 / (sin_beta * s1rca2 * c), + ]; + } + + // This function is only used with matrices frac and orth, which have 3 zeros. + // We skip these elements, but it doesn't affect performance (on FF50 and V8). + multiply(xyz, mat) { + /* eslint-disable indent */ + return [mat[0] * xyz[0] + mat[1] * xyz[1] + mat[2] * xyz[2], + /*mat[3] * xyz[0]*/+ mat[4] * xyz[1] + mat[5] * xyz[2], + /*mat[6] * xyz[0] + mat[7] * xyz[1]*/+ mat[8] * xyz[2]]; + } + + fractionalize(xyz /*:[number,number,number]*/) { + return this.multiply(xyz, this.frac); + } + + orthogonalize(xyz /*:[number,number,number]*/) { + return this.multiply(xyz, this.orth); + } + } + + + class GridArray { + /*:: + dim: number[] + values: Float32Array + */ + constructor(dim /*:number[]*/) { + this.dim = dim; // dimensions of the grid for the entire unit cell + this.values = new Float32Array(dim[0] * dim[1] * dim[2]); + } + + modulo(a, b) { + const reminder = a % b; + return reminder >= 0 ? reminder : reminder + b; + } + + grid2index(i/*:number*/, j/*:number*/, k/*:number*/) { + i = this.modulo(i, this.dim[0]); + j = this.modulo(j, this.dim[1]); + k = this.modulo(k, this.dim[2]); + return this.dim[2] * (this.dim[1] * i + j) + k; + } + + grid2index_unchecked(i/*:number*/, j/*:number*/, k/*:number*/) { + return this.dim[2] * (this.dim[1] * i + j) + k; + } + + grid2frac(i/*:number*/, j/*:number*/, k/*:number*/) { + return [i / this.dim[0], j / this.dim[1], k / this.dim[2]]; + } + + // return grid coordinates (rounded down) for the given fractional coordinates + frac2grid(xyz/*:number[]*/) { + // at one point "| 0" here made extract_block() 40% faster on V8 3.14, + // but I don't see any effect now + return [Math.floor(xyz[0] * this.dim[0]) | 0, + Math.floor(xyz[1] * this.dim[1]) | 0, + Math.floor(xyz[2] * this.dim[2]) | 0]; + } + + set_grid_value(i/*:number*/, j/*:number*/, k/*:number*/, value/*:number*/) { + const idx = this.grid2index(i, j, k); + this.values[idx] = value; + } + + get_grid_value(i/*:number*/, j/*:number*/, k/*:number*/) { + const idx = this.grid2index(i, j, k); + return this.values[idx]; + } + } + + /** + * @file Mtz Parser + * @author Marcin Wojdyr + * @private + * Modified by Jiyao Wang / https://github.com/ncbi/icn3d + */ + + class MtzParser { + constructor(icn3d) { + this.icn3d = icn3d; + } + + async mtzParserBase(url, type, sigma, location, bInputSigma) { let ic = this.icn3d, me = ic.icn3dui; + let thisClass = this; + + //https://stackoverflow.com/questions/33902299/using-jquery-ajax-to-download-a-binary-file + // if(type == '2fofc' && ic.bAjax2fofcccp4) { + // ic.mapData.sigma2 = sigma; + // ic.setOptionCls.setOption('map', type); + // } + // else if(type == 'fofc' && ic.bAjaxfofcccp4) { + // ic.mapData.sigma = sigma; + // ic.setOptionCls.setOption('map', type); + // } + // else { + let arrayBuffer = await me.getXMLHttpRqstPromise(url, 'GET', 'arraybuffer', ''); + sigma = await thisClass.loadMtzFileBase(arrayBuffer, type, sigma, location, bInputSigma, url); + + // if(type == '2fofc') { + // ic.bAjax2fofcccp4 = true; + // } + // else if(type == 'fofc') { + // ic.bAjaxfofcccp4 = true; + // } + + ic.setOptionCls.setOption('map', type); + + return sigma; + // } + } + + loadMtzFile(type) {var ic = this.icn3d, me = ic.icn3dui; + let thisClass = this; + + let file = $("#" + ic.pre + "dsn6file" + type)[0].files[0]; + let sigma = $("#" + ic.pre + "dsn6sigma" + type).val(); + if(!file) { + alert("Please select a file before clicking 'Load'"); + } + else { + me.utilsCls.checkFileAPI(); + let reader = new FileReader(); + reader.onload = async function(e) { let ic = thisClass.icn3d; + sigma = await thisClass.loadMtzFileBase(e.target.result, type, sigma, 'file'); + me.htmlCls.clickMenuCls.setLogCmd('load map file ' + $("#" + ic.pre + "dsn6file" + type).val() + ' with sigma ' + sigma, false); + }; + reader.readAsArrayBuffer(file); + } + } + + async loadMtzFileBase(data, type, sigma, location, bInputSigma, url) {var ic = this.icn3d, me = ic.icn3dui; + if(ic.bMtz === undefined) { + let url = "./script/mtz.js"; + await me.getAjaxPromise(url, 'script'); + + ic.bMtz = true; + } + + GemmiMtz().then(function(Gemmi) { + let mtz = Gemmi.readMtz(data); + + sigma = ic.ccp4ParserCls.load_maps_from_mtz_buffer(mtz, type, sigma, location, bInputSigma); + + // if(type == '2fofc') { + // ic.bAjax2fofcCcp4 = true; + // } + // else if(type == 'fofc') { + // ic.bAjaxfofcCcp4 = true; + // } + ic.setOptionCls.setOption('map', type); + if(url) me.htmlCls.clickMenuCls.setLogCmd('set map ' + type + ' sigma ' + sigma + ' file mtz | ' + encodeURIComponent(url), true); + + return sigma; + }); + } + + async loadMtzFileUrl(type) {var ic = this.icn3d; ic.icn3dui; + let url = $("#" + ic.pre + "dsn6fileurl" + type).val(); + let sigma = $("#" + ic.pre + "dsn6sigmaurl" + type).val(); + if(!url) { + alert("Please input the file URL before clicking 'Load'"); + } + else { + sigma = await this.mtzParserBase(url, type, sigma, 'url'); + + console.log("### sigma " + sigma); + //me.htmlCls.clickMenuCls.setLogCmd('set map ' + type + ' sigma ' + sigma + ' file mtz | ' + encodeURIComponent(url), true); } } @@ -54348,6 +55482,9 @@ var icn3d = (function (exports) { ic.mapData.header2 = header; ic.mapData.data2 = density.data; + for(let i = 0; i < density.data.length; ++i) { + density.data[i]; + } let origin = density.box.origin; let dimensions = density.box.dimensions; @@ -54382,6 +55519,7 @@ var icn3d = (function (exports) { origin = density.box.origin; dimensions = density.box.dimensions; basis = density.spacegroup.basis; + scale = new THREE.Matrix4().makeScale( dimensions[0] / (sampleCount[0] ), dimensions[1] / (sampleCount[1] ), @@ -56010,7 +57148,10 @@ var icn3d = (function (exports) { if(bAppend) { if(ic.bSetChainsAdvancedMenu) ic.definedSetsCls.showSets(); - if(ic.bAnnoShown) await ic.showAnnoCls.showAnnotations(); + if(ic.bAnnoShown) { + await ic.showAnnoCls.showAnnotations(); + ic.annotationCls.resetAnnoTabAll(); + } } // Realign by sequence alignment with the residues in "segment", i.e., transmembrane helix @@ -57340,12 +58481,12 @@ var icn3d = (function (exports) { if(i > 0) { let index1 = alignIndex; - + for(let j = prevIndex1 + 1, jl = start1; j < jl; ++j) { - if(posChain1[j]) continue; + //if(posChain1[j]) continue; posChain1[j] = 1; - if(ic.chainsSeq[chainid1] === undefined || ic.chainsSeq[chainid1][j] === undefined) break; + //if(ic.chainsSeq[chainid1] === undefined || ic.chainsSeq[chainid1][j] === undefined) break; //let resi = this.getResiAferAlign(chainid1, bRealign, j + 1); let resi = this.getResiAferAlign(chainid1, bRealign, j); @@ -57356,18 +58497,19 @@ var icn3d = (function (exports) { color = me.htmlCls.GREY8; classname = 'icn3d-nalign'; - + ic.nalignHash1[chainid1 + '_' + resi] = 1; this.setSeqPerResi(chainid1, chainid1, chainid2, resi, resn, false, color, undefined, classname, true, false, index1); ++index1; } let index2 = alignIndex; + for(let j = prevIndex2 + 1, jl = start2; j < jl; ++j) { - if(posChain2[j]) continue; + //if(posChain2[j]) continue; posChain2[j] = 1; - if(ic.chainsSeq[chainid2] === undefined || ic.chainsSeq[chainid2] === undefined) break; + //if(ic.chainsSeq[chainid2] === undefined || ic.chainsSeq[chainid2] === undefined) break; //let resi = this.getResiAferAlign(chainid2, bRealign, j + 1); let resi = this.getResiAferAlign(chainid2, bRealign, j); @@ -57413,7 +58555,7 @@ var icn3d = (function (exports) { } for(let j = 0; j <= end1 - start1; ++j) { - if(ic.chainsSeq[chainid1] === undefined || ic.chainsSeq[chainid2] === undefined) break; + ///if(ic.chainsSeq[chainid1] === undefined || ic.chainsSeq[chainid2] === undefined) break; let resi1, resi2, resn1, resn2; /* @@ -57443,15 +58585,17 @@ var icn3d = (function (exports) { if(resn1 == '?' || resn2 == '?') continue; } else { - if(ic.chainsSeq[chainid1][j + start1] === undefined || ic.chainsSeq[chainid2][j + start2] === undefined) continue; + ///if(ic.chainsSeq[chainid1][j + start1] === undefined || ic.chainsSeq[chainid2][j + start2] === undefined) continue; // resi1 = ic.chainsSeq[chainid1][j + start1].resi; // resi2 = ic.chainsSeq[chainid2][j + start2].resi; // resn1 = ic.chainsSeq[chainid1][j + start1].name.toUpperCase(); // resn2 = ic.chainsSeq[chainid2][j + start2].name.toUpperCase(); - resi1 = this.getResiAferAlign(chainid1, bRealign, j + start1 + 1); - resi2 = this.getResiAferAlign(chainid2, bRealign, j + start2 + 1); + // resi1 = this.getResiAferAlign(chainid1, bRealign, j + start1 + 1); + // resi2 = this.getResiAferAlign(chainid2, bRealign, j + start2 + 1); + resi1 = this.getResiAferAlign(chainid1, bRealign, j + start1); + resi2 = this.getResiAferAlign(chainid2, bRealign, j + start2); resn1 = this.getResnFromResi(chainid1, resi1).toUpperCase(); resn2 = this.getResnFromResi(chainid2, resi2).toUpperCase(); } @@ -62507,7 +63651,8 @@ var icn3d = (function (exports) { let strArray = ic.commands[i].split("|||"); let command = strArray[0].trim(); - if(ic.inputid) ic.bNotLoadStructure = true; + // sometimes URL has an ID input, then load a structure in commands + //if(ic.inputid) ic.bNotLoadStructure = true; if(command.indexOf('load') !== -1) { if(end === 0 && start === end) { @@ -62543,18 +63688,7 @@ var icn3d = (function (exports) { } } else if(command.indexOf('set map') == 0 && command.indexOf('set map wireframe') == -1) { - //set map 2fofc sigma 1.5 - let urlArray = strArray[0].trim().split(' | '); - - let str = urlArray[0].substr(8); - let paraArray = str.split(" "); - - if(paraArray.length == 3 && paraArray[1] == 'sigma') { - paraArray[2]; - paraArray[0]; - - await thisClass.applyCommandMap(strArray[0].trim()); - } + await thisClass.applyCommandMap(strArray[0].trim()); } else if(command.indexOf('set emmap') == 0 && command.indexOf('set emmap wireframe') == -1) { //set emmap percentage 70 @@ -63054,17 +64188,34 @@ var icn3d = (function (exports) { // ic.deferredMap = $.Deferred(function() { let ic = thisClass.icn3d; //"set map 2fofc sigma 1.5" // or "set map 2fofc sigma 1.5 | [url]" + + // added more para later + //"set map 2fofc sigma 1.5 file dsn6" + // or "set map 2fofc sigma 1.5 file dsn6 | [url]" let urlArray = command.split(" | "); let str = urlArray[0].substr(8); let paraArray = str.split(" "); - if(paraArray.length == 3 && paraArray[1] == 'sigma') { + //if(paraArray.length == 3 && paraArray[1] == 'sigma') { + if(paraArray[1] == 'sigma') { let sigma = paraArray[2]; let type = paraArray[0]; + let fileType = 'dsn6'; + if(paraArray.length == 5) fileType = paraArray[4]; + if(urlArray.length == 2) { - await ic.dsn6ParserCls.dsn6ParserBase(urlArray[1], type, sigma); + let bInputSigma = true; + if(fileType == 'dsn6') { + await ic.dsn6ParserCls.dsn6ParserBase(urlArray[1], type, sigma, 'url', bInputSigma); + } + else if(fileType == 'ccp4') { + await ic.ccp4ParserCls.ccp4ParserBase(urlArray[1], type, sigma, 'url', bInputSigma); + } + else if(fileType == 'mtz') { + await ic.mtzParserCls.mtzParserBase(urlArray[1], type, sigma, 'url', bInputSigma); + } } else { await ic.dsn6ParserCls.dsn6Parser(ic.inputid, type, sigma); @@ -72008,7 +73159,7 @@ var icn3d = (function (exports) { } // from iview (http://istar.cse.cuhk.edu.hk/iview/) - getAtomsFromPosition(point, threshold) { let ic = this.icn3d, me = ic.icn3dui; + getAtomsFromPosition(point, threshold, atoms) { let ic = this.icn3d, me = ic.icn3dui; let i; if(threshold === undefined || threshold === null) { @@ -72016,7 +73167,8 @@ var icn3d = (function (exports) { } //for (i in ic.atoms) { - for (i in ic.dAtoms) { + let atomHash = (atoms) ? atoms : ic.dAtoms; + for (i in atomHash) { let atom = ic.atoms[i]; if(ic.ions.hasOwnProperty(i) && ic.opts['ions'] === 'sphere') { @@ -73588,6 +74740,8 @@ var icn3d = (function (exports) { this.alignParserCls = new AlignParser(this); this.chainalignParserCls = new ChainalignParser(this); this.dsn6ParserCls = new Dsn6Parser(this); + this.ccp4ParserCls = new Ccp4Parser(this); + this.mtzParserCls = new MtzParser(this); this.mmcifParserCls = new MmcifParser(this); this.mmdbParserCls = new MmdbParser(this); this.mmtfParserCls = new MmtfParser(this); @@ -73850,7 +75004,7 @@ var icn3d = (function (exports) { //even when multiple iCn3D viewers are shown together. this.pre = this.cfg.divid + "_"; - this.REVISION = '3.28.4'; + this.REVISION = '3.29.0'; // In nodejs, iCn3D defines "window = {navigator: {}}" this.bNode = (Object.keys(window).length < 2) ? true : false; diff --git a/build/icn3d.min.js b/build/icn3d.min.js index d2c65baa..b5d61ea9 100644 --- a/build/icn3d.min.js +++ b/build/icn3d.min.js @@ -1,5 +1,5 @@ var $NGL_shaderTextHash={};$NGL_shaderTextHash["SphereImpostor.frag"]=["#define STANDARD","#define IMPOSTOR","","uniform vec3 diffuse;","uniform vec3 emissive;","uniform float roughness;","uniform float metalness;","uniform float opacity;","uniform float nearClip;","uniform mat4 projectionMatrix;","uniform float ortho;","","varying float vRadius;","varying float vRadiusSq;","varying vec3 vPoint;","varying vec3 vPointViewPosition;","","#ifdef PICKING"," uniform float objectId;"," varying vec3 vPickingColor;","#else"," #include common"," #include color_pars_fragment"," #include fog_pars_fragment"," #include bsdfs"," #include lights_pars_begin"," #include lights_physical_pars_fragment","#endif","","bool flag2 = false;","bool interior = false;","vec3 cameraPos;","vec3 cameraNormal;","","// Calculate depth based on the given camera position.","float calcDepth( in vec3 cameraPos ){"," vec2 clipZW = cameraPos.z * projectionMatrix[2].zw + projectionMatrix[3].zw;"," return 0.5 + 0.5 * clipZW.x / clipZW.y;","}","","float calcClip( vec3 cameraPos ){"," return dot( vec4( cameraPos, 1.0 ), vec4( 0.0, 0.0, 1.0, nearClip - 0.5 ) );","}","","bool Impostor( out vec3 cameraPos, out vec3 cameraNormal ){",""," vec3 cameraSpherePos = -vPointViewPosition;"," cameraSpherePos.z += vRadius;",""," vec3 rayOrigin = mix( vec3( 0.0, 0.0, 0.0 ), vPoint, ortho );"," vec3 rayDirection = mix( normalize( vPoint ), vec3( 0.0, 0.0, 1.0 ), ortho );"," vec3 cameraSphereDir = mix( cameraSpherePos, rayOrigin - cameraSpherePos, ortho );",""," float B = dot( rayDirection, cameraSphereDir );"," float det = B * B + vRadiusSq - dot( cameraSphereDir, cameraSphereDir );",""," if( det < 0.0 ){"," discard;"," return false;"," }"," float sqrtDet = sqrt( det );"," float posT = mix( B + sqrtDet, B + sqrtDet, ortho );"," float negT = mix( B - sqrtDet, sqrtDet - B, ortho );",""," cameraPos = rayDirection * negT + rayOrigin;",""," #ifdef NEAR_CLIP","if( calcDepth( cameraPos ) <= 0.0 ){"," cameraPos = rayDirection * posT + rayOrigin;"," interior = true;"," return false;","}else if( calcClip( cameraPos ) > 0.0 ){"," cameraPos = rayDirection * posT + rayOrigin;"," interior = true;"," flag2 = true;"," return false;","}else{"," cameraNormal = normalize( cameraPos - cameraSpherePos );","}"," #else","if( calcDepth( cameraPos ) <= 0.0 ){"," cameraPos = rayDirection * posT + rayOrigin;"," interior = true;"," return false;","}else{"," cameraNormal = normalize( cameraPos - cameraSpherePos );","}"," #endif",""," cameraNormal = normalize( cameraPos - cameraSpherePos );"," cameraNormal *= float(!interior) * 2.0 - 1.0;"," return !interior;","","}","","void main(void){",""," bool flag = Impostor( cameraPos, cameraNormal );",""," #ifdef NEAR_CLIP"," if( calcClip( cameraPos ) > 0.0 )"," discard;"," #endif",""," // FIXME not compatible with custom clipping plane"," //Set the depth based on the new cameraPos."," gl_FragDepthEXT = calcDepth( cameraPos );"," if( !flag ){",""," // clamp to near clipping plane and add a tiny value to"," // make spheres with a greater radius occlude smaller ones"," #ifdef NEAR_CLIP","if( flag2 ){"," gl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( nearClip - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );","}else if( gl_FragDepthEXT >= 0.0 ){"," gl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );","}"," #else","if( gl_FragDepthEXT >= 0.0 ){"," gl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );","}"," #endif",""," }",""," // bugfix (mac only?)"," if (gl_FragDepthEXT < 0.0)"," discard;"," if (gl_FragDepthEXT > 1.0)"," discard;",""," #ifdef PICKING",""," gl_FragColor = vec4( vPickingColor, objectId );",""," #else",""," vec3 vNormal = cameraNormal;"," vec3 vViewPosition = -cameraPos;",""," vec4 diffuseColor = vec4( diffuse, opacity );"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveLight = emissive;",""," #include color_fragment"," #include roughnessmap_fragment"," #include metalnessmap_fragment",""," // don't use include normal_fragment"," vec3 normal = normalize( vNormal );",""," #include lights_physical_fragment"," //include lights_template"," #include lights_fragment_begin"," #include lights_fragment_end",""," vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;",""," gl_FragColor = vec4( outgoingLight, diffuseColor.a );"," //gl_FragColor = vec4( reflectedLight.directSpecular, diffuseColor.a );",""," #include premultiplied_alpha_fragment"," #include tonemapping_fragment"," #include encodings_fragment"," //include fog_fragment"," #ifdef USE_FOG"," #ifdef USE_LOGDEPTHBUF_EXT"," float depth = gl_FragDepthEXT / gl_FragCoord.w;"," #else"," float depth = gl_FragCoord.z / gl_FragCoord.w;"," #endif"," #ifdef FOG_EXP2"," float fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );"," #else"," float fogFactor = smoothstep( fogNear, fogFar, depth );"," #endif"," gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );"," #endif",""," #endif","","}"].join("\n"),$NGL_shaderTextHash["SphereImpostor.vert"]=["uniform mat4 projectionMatrixInverse;","uniform float nearClip;","","varying float vRadius;","varying float vRadiusSq;","varying vec3 vPoint;","varying vec3 vPointViewPosition;","varying float fogDepth;","varying float fogNear;","varying float fogFar;","","attribute vec2 mapping;","//attribute vec3 position;","attribute float radius;","","#ifdef PICKING"," #include unpack_clr"," attribute float primitiveId;"," varying vec3 vPickingColor;","#else"," #include color_pars_vertex","#endif","","//include matrix_scale","float matrixScale( in mat4 m ){"," vec4 r = m[ 0 ];"," return sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );","}","","const mat4 D = mat4("," 1.0, 0.0, 0.0, 0.0,"," 0.0, 1.0, 0.0, 0.0,"," 0.0, 0.0, 1.0, 0.0,"," 0.0, 0.0, 0.0, -1.0",");","","mat4 transposeTmp( in mat4 inMatrix ) {"," vec4 i0 = inMatrix[0];"," vec4 i1 = inMatrix[1];"," vec4 i2 = inMatrix[2];"," vec4 i3 = inMatrix[3];",""," mat4 outMatrix = mat4("," vec4(i0.x, i1.x, i2.x, i3.x),"," vec4(i0.y, i1.y, i2.y, i3.y),"," vec4(i0.z, i1.z, i2.z, i3.z),"," vec4(i0.w, i1.w, i2.w, i3.w)"," );"," return outMatrix;","}","","//------------------------------------------------------------------------------","// Compute point size and center using the technique described in:","// 'GPU-Based Ray-Casting of Quadratic Surfaces'","// by Christian Sigg, Tim Weyrich, Mario Botsch, Markus Gross.","//","// Code based on","/*=========================================================================",""," Program: Visualization Toolkit"," Module: Quadrics_fs.glsl and Quadrics_vs.glsl",""," Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen"," All rights reserved."," See Copyright.txt or http://www.kitware.com/Copyright.htm for details.",""," This software is distributed WITHOUT ANY WARRANTY; without even"," the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR"," PURPOSE. See the above copyright notice for more information.",""," =========================================================================*/","","// .NAME Quadrics_fs.glsl and Quadrics_vs.glsl","// .SECTION Thanks","// ","//","// This file is part of the PointSprites plugin developed and contributed by","//","// Copyright (c) CSCS - Swiss National Supercomputing Centre","// EDF - Electricite de France","//","// John Biddiscombe, Ugo Varetto (CSCS)","// Stephane Ploix (EDF)","//","// ","//","// Contributions by Alexander Rose","// - ported to WebGL","// - adapted to work with quads","void ComputePointSizeAndPositionInClipCoordSphere(){",""," vec2 xbc;"," vec2 ybc;",""," mat4 T = mat4("," radius, 0.0, 0.0, 0.0,"," 0.0, radius, 0.0, 0.0,"," 0.0, 0.0, radius, 0.0,"," position.x, position.y, position.z, 1.0"," );",""," mat4 R = transposeTmp( projectionMatrix * modelViewMatrix * T );"," float A = dot( R[ 3 ], D * R[ 3 ] );"," float B = -2.0 * dot( R[ 0 ], D * R[ 3 ] );"," float C = dot( R[ 0 ], D * R[ 0 ] );"," xbc[ 0 ] = ( -B - sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," xbc[ 1 ] = ( -B + sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," float sx = abs( xbc[ 0 ] - xbc[ 1 ] ) * 0.5;",""," A = dot( R[ 3 ], D * R[ 3 ] );"," B = -2.0 * dot( R[ 1 ], D * R[ 3 ] );"," C = dot( R[ 1 ], D * R[ 1 ] );"," ybc[ 0 ] = ( -B - sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," ybc[ 1 ] = ( -B + sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," float sy = abs( ybc[ 0 ] - ybc[ 1 ] ) * 0.5;",""," gl_Position.xy = vec2( 0.5 * ( xbc.x + xbc.y ), 0.5 * ( ybc.x + ybc.y ) );"," gl_Position.xy -= mapping * vec2( sx, sy );"," gl_Position.xy *= gl_Position.w;","","}","","void main(void){",""," #ifdef PICKING"," vPickingColor = unpackColor( primitiveId );"," #else"," #include color_vertex"," #endif",""," vRadius = radius * matrixScale( modelViewMatrix );",""," vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );"," // avoid clipping, added again in fragment shader"," mvPosition.z -= vRadius;",""," gl_Position = projectionMatrix * vec4( mvPosition.xyz, 1.0 );"," ComputePointSizeAndPositionInClipCoordSphere();","",""," vRadiusSq = vRadius * vRadius;"," vec4 vPoint4 = projectionMatrixInverse * gl_Position;"," vPoint = vPoint4.xyz / vPoint4.w;"," vPointViewPosition = -mvPosition.xyz / mvPosition.w;","","}"].join("\n"),$NGL_shaderTextHash["CylinderImpostor.frag"]=["#define STANDARD","#define IMPOSTOR","","// Open-Source PyMOL is Copyright (C) Schrodinger, LLC.","//","// All Rights Reserved","//","// Permission to use, copy, modify, distribute, and distribute modified","// versions of this software and its built-in documentation for any","// purpose and without fee is hereby granted, provided that the above","// copyright notice appears in all copies and that both the copyright","// notice and this permission notice appear in supporting documentation,","// and that the name of Schrodinger, LLC not be used in advertising or","// publicity pertaining to distribution of the software without specific,","// written prior permission.","//","// SCHRODINGER, LLC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,","// INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN","// NO EVENT SHALL SCHRODINGER, LLC BE LIABLE FOR ANY SPECIAL, INDIRECT OR","// CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS","// OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE","// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE","// USE OR PERFORMANCE OF THIS SOFTWARE.","","// Contributions by Alexander Rose","// - ported to WebGL","// - dual color","// - pk color","// - custom clipping","// - three.js lighting","","uniform vec3 diffuse;","uniform vec3 emissive;","uniform float roughness;","uniform float metalness;","uniform float opacity;","uniform float nearClip;","uniform mat4 projectionMatrix;","uniform float ortho;","","varying vec3 axis;","varying vec4 base_radius;","varying vec4 end_b;","varying vec3 U;","varying vec3 V;","varying vec4 w;","","#ifdef PICKING"," uniform float objectId;"," varying vec3 vPickingColor;","#else"," varying vec3 vColor1;"," varying vec3 vColor2;"," #include common"," #include fog_pars_fragment"," #include bsdfs"," #include lights_pars_begin"," #include lights_physical_pars_fragment","#endif","","bool interior = false;","","float distSq3( vec3 v3a, vec3 v3b ){"," return ("," ( v3a.x - v3b.x ) * ( v3a.x - v3b.x ) +"," ( v3a.y - v3b.y ) * ( v3a.y - v3b.y ) +"," ( v3a.z - v3b.z ) * ( v3a.z - v3b.z )"," );","}","","// Calculate depth based on the given camera position.","float calcDepth( in vec3 cameraPos ){"," vec2 clipZW = cameraPos.z * projectionMatrix[2].zw + projectionMatrix[3].zw;"," return 0.5 + 0.5 * clipZW.x / clipZW.y;","}","","float calcClip( vec3 cameraPos ){"," return dot( vec4( cameraPos, 1.0 ), vec4( 0.0, 0.0, 1.0, nearClip - 0.5 ) );","}","","void main(){",""," vec3 point = w.xyz / w.w;",""," // unpacking"," vec3 base = base_radius.xyz;"," float vRadius = base_radius.w;"," vec3 end = end_b.xyz;"," float b = end_b.w;",""," vec3 end_cyl = end;"," vec3 surface_point = point;",""," vec3 ray_target = surface_point;"," vec3 ray_origin = vec3(0.0);"," vec3 ray_direction = mix(normalize(ray_origin - ray_target), vec3(0.0, 0.0, 1.0), ortho);"," mat3 basis = mat3( U, V, axis );",""," vec3 diff = ray_target - 0.5 * (base + end_cyl);"," vec3 P = diff * basis;",""," // angle (cos) between cylinder cylinder_axis and ray direction"," float dz = dot( axis, ray_direction );",""," float radius2 = vRadius*vRadius;",""," // calculate distance to the cylinder from ray origin"," vec3 D = vec3(dot(U, ray_direction),"," dot(V, ray_direction),"," dz);"," float a0 = P.x*P.x + P.y*P.y - radius2;"," float a1 = P.x*D.x + P.y*D.y;"," float a2 = D.x*D.x + D.y*D.y;",""," // calculate a dicriminant of the above quadratic equation"," float d = a1*a1 - a0*a2;"," if (d < 0.0)"," // outside of the cylinder"," discard;",""," float dist = (-a1 + sqrt(d)) / a2;",""," // point of intersection on cylinder surface"," vec3 new_point = ray_target + dist * ray_direction;",""," vec3 tmp_point = new_point - base;"," vec3 _normal = normalize( tmp_point - axis * dot(tmp_point, axis) );",""," ray_origin = mix( ray_origin, surface_point, ortho );",""," // test caps"," float front_cap_test = dot( tmp_point, axis );"," float end_cap_test = dot((new_point - end_cyl), axis);",""," // to calculate caps, simply check the angle between"," // the point of intersection - cylinder end vector"," // and a cap plane normal (which is the cylinder cylinder_axis)"," // if the angle < 0, the point is outside of cylinder"," // test front cap",""," #ifndef CAP"," vec3 new_point2 = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;"," vec3 tmp_point2 = new_point2 - base;"," #endif",""," // flat"," if (front_cap_test < 0.0)"," {"," // ray-plane intersection"," float dNV = dot(-axis, ray_direction);"," if (dNV < 0.0)"," discard;"," float near = dot(-axis, (base)) / dNV;"," vec3 front_point = ray_direction * near + ray_origin;"," // within the cap radius?"," if (dot(front_point - base, front_point-base) > radius2)"," discard;",""," #ifdef CAP"," new_point = front_point;"," _normal = axis;"," #else"," new_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;"," dNV = dot(-axis, ray_direction);"," near = dot(axis, end_cyl) / dNV;"," new_point2 = ray_direction * near + ray_origin;"," if (dot(new_point2 - end_cyl, new_point2-base) < radius2)"," discard;"," interior = true;"," #endif"," }",""," // test end cap","",""," // flat"," if( end_cap_test > 0.0 )"," {"," // ray-plane intersection"," float dNV = dot(axis, ray_direction);"," if (dNV < 0.0)"," discard;"," float near = dot(axis, end_cyl) / dNV;"," vec3 end_point = ray_direction * near + ray_origin;"," // within the cap radius?"," if( dot(end_point - end_cyl, end_point-base) > radius2 )"," discard;",""," #ifdef CAP"," new_point = end_point;"," _normal = axis;"," #else"," new_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;"," dNV = dot(-axis, ray_direction);"," near = dot(-axis, (base)) / dNV;"," new_point2 = ray_direction * near + ray_origin;"," if (dot(new_point2 - base, new_point2-base) < radius2)"," discard;"," interior = true;"," #endif"," }",""," gl_FragDepthEXT = calcDepth( new_point );",""," #ifdef NEAR_CLIP"," if( calcClip( new_point ) > 0.0 ){"," dist = (-a1 - sqrt(d)) / a2;"," new_point = ray_target + dist * ray_direction;"," if( calcClip( new_point ) > 0.0 )"," discard;"," interior = true;"," gl_FragDepthEXT = calcDepth( new_point );"," if( gl_FragDepthEXT >= 0.0 ){"," gl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( nearClip - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );"," }"," }else if( gl_FragDepthEXT <= 0.0 ){"," dist = (-a1 - sqrt(d)) / a2;"," new_point = ray_target + dist * ray_direction;"," interior = true;"," gl_FragDepthEXT = calcDepth( new_point );"," if( gl_FragDepthEXT >= 0.0 ){"," gl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );"," }"," }"," #else"," if( gl_FragDepthEXT <= 0.0 ){"," dist = (-a1 - sqrt(d)) / a2;"," new_point = ray_target + dist * ray_direction;"," interior = true;"," gl_FragDepthEXT = calcDepth( new_point );"," if( gl_FragDepthEXT >= 0.0 ){"," gl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );"," }"," }"," #endif",""," // this is a workaround necessary for Mac"," // otherwise the modified fragment won't clip properly"," if (gl_FragDepthEXT < 0.0)"," discard;"," if (gl_FragDepthEXT > 1.0)"," discard;",""," #ifdef PICKING",""," gl_FragColor = vec4( vPickingColor, objectId );",""," #else",""," vec3 vViewPosition = -new_point;"," vec3 vNormal = _normal;"," vec3 vColor;",""," if( distSq3( new_point, end_cyl ) < distSq3( new_point, base ) ){"," if( b < 0.0 ){"," vColor = vColor1;"," }else{"," vColor = vColor2;"," }"," }else{"," if( b > 0.0 ){"," vColor = vColor1;"," }else{"," vColor = vColor2;"," }"," }",""," vec4 diffuseColor = vec4( diffuse, opacity );"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveLight = emissive;",""," #include color_fragment"," //ifdef USE_COLOR"," //diffuseColor.r *= vColor[0];"," //diffuseColor.g *= vColor[1];"," //diffuseColor.b *= vColor[2];"," //endif"," #include roughnessmap_fragment"," #include metalnessmap_fragment",""," // don't use include normal_fragment"," vec3 normal = normalize( vNormal );",""," #include lights_physical_fragment"," //include lights_template"," #include lights_fragment_begin"," #include lights_fragment_end",""," vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;",""," gl_FragColor = vec4( outgoingLight, diffuseColor.a );"," //gl_FragColor = vec4( reflectedLight.directSpecular, diffuseColor.a );",""," #include premultiplied_alpha_fragment"," #include tonemapping_fragment"," #include encodings_fragment"," //include fog_fragment"," #ifdef USE_FOG"," #ifdef USE_LOGDEPTHBUF_EXT"," float depth = gl_FragDepthEXT / gl_FragCoord.w;"," #else"," float depth = gl_FragCoord.z / gl_FragCoord.w;"," #endif"," #ifdef FOG_EXP2"," float fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );"," #else"," float fogFactor = smoothstep( fogNear, fogFar, depth );"," #endif"," gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );"," #endif",""," #endif","","}"].join("\n"),$NGL_shaderTextHash["CylinderImpostor.vert"]=["// Open-Source PyMOL is Copyright (C) Schrodinger, LLC.","//","// All Rights Reserved","//","// Permission to use, copy, modify, distribute, and distribute modified","// versions of this software and its built-in documentation for any","// purpose and without fee is hereby granted, provided that the above","// copyright notice appears in all copies and that both the copyright","// notice and this permission notice appear in supporting documentation,","// and that the name of Schrodinger, LLC not be used in advertising or","// publicity pertaining to distribution of the software without specific,","// written prior permission.","//","// SCHRODINGER, LLC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,","// INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN","// NO EVENT SHALL SCHRODINGER, LLC BE LIABLE FOR ANY SPECIAL, INDIRECT OR","// CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS","// OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE","// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE","// USE OR PERFORMANCE OF THIS SOFTWARE.","","// Contributions by Alexander Rose","// - ported to WebGL","// - dual color","// - pk color","// - shift","","attribute vec3 mapping;","attribute vec3 position1;","attribute vec3 position2;","attribute float radius;","","varying vec3 axis;","varying vec4 base_radius;","varying vec4 end_b;","varying vec3 U;","varying vec3 V;","varying vec4 w;","varying float fogDepth;","varying float fogNear;","varying float fogFar;","","#ifdef PICKING"," #include unpack_clr"," attribute float primitiveId;"," varying vec3 vPickingColor;","#else"," //attribute vec3 color;"," attribute vec3 color2;"," varying vec3 vColor1;"," varying vec3 vColor2;","#endif","","uniform mat4 modelViewMatrixInverse;","uniform float ortho;","","//include matrix_scale","float matrixScale( in mat4 m ){"," vec4 r = m[ 0 ];"," return sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );","}","","void main(){",""," #ifdef PICKING"," vPickingColor = unpackColor( primitiveId );"," #else"," vColor1 = color;"," vColor2 = color2;"," #endif",""," // vRadius = radius;"," base_radius.w = radius * matrixScale( modelViewMatrix );",""," //vec3 center = position;"," vec3 center = ( position2 + position1 ) / 2.0;"," vec3 dir = normalize( position2 - position1 );"," float ext = length( position2 - position1 ) / 2.0;",""," // using cameraPosition fails on some machines, not sure why"," // vec3 cam_dir = normalize( cameraPosition - mix( center, vec3( 0.0 ), ortho ) );"," vec3 cam_dir;"," if( ortho == 0.0 ){"," cam_dir = ( modelViewMatrixInverse * vec4( 0, 0, 0, 1 ) ).xyz - center;"," }else{"," cam_dir = ( modelViewMatrixInverse * vec4( 0, 0, 1, 0 ) ).xyz;"," }"," cam_dir = normalize( cam_dir );",""," vec3 ldir;",""," float b = dot( cam_dir, dir );"," end_b.w = b;"," // direction vector looks away, so flip"," if( b < 0.0 )"," ldir = -ext * dir;"," // direction vector already looks in my direction"," else"," ldir = ext * dir;",""," vec3 left = normalize( cross( cam_dir, ldir ) );"," left = radius * left;"," vec3 up = radius * normalize( cross( left, ldir ) );",""," // transform to modelview coordinates"," axis = normalize( normalMatrix * ldir );"," U = normalize( normalMatrix * up );"," V = normalize( normalMatrix * left );",""," vec4 base4 = modelViewMatrix * vec4( center - ldir, 1.0 );"," base_radius.xyz = base4.xyz / base4.w;",""," vec4 top_position = modelViewMatrix * vec4( center + ldir, 1.0 );"," vec4 end4 = top_position;"," end_b.xyz = end4.xyz / end4.w;",""," w = modelViewMatrix * vec4("," center + mapping.x*ldir + mapping.y*left + mapping.z*up, 1.0"," );",""," gl_Position = projectionMatrix * w;",""," // avoid clipping (1.0 seems to induce flickering with some drivers)"," gl_Position.z = 0.99;","","}"].join("\n"),$NGL_shaderTextHash["SphereInstancing.frag"]=$NGL_shaderTextHash["SphereImpostor.frag"],$NGL_shaderTextHash["SphereInstancing.vert"]=["uniform mat4 projectionMatrixInverse;","uniform float nearClip;","","varying float vRadius;","varying float vRadiusSq;","varying vec3 vPoint;","varying vec3 vPointViewPosition;","varying float fogDepth;","varying float fogNear;","varying float fogFar;","","attribute vec2 mapping;","//attribute vec3 position;","attribute float radius;","attribute vec4 matrix1;","attribute vec4 matrix2;","attribute vec4 matrix3;","attribute vec4 matrix4;","","#ifdef PICKING"," #include unpack_clr"," attribute float primitiveId;"," varying vec3 vPickingColor;","#else"," #include color_pars_vertex","#endif","","//include matrix_scale","float matrixScale( in mat4 m ){"," vec4 r = m[ 0 ];"," return sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );","}","","const mat4 D = mat4("," 1.0, 0.0, 0.0, 0.0,"," 0.0, 1.0, 0.0, 0.0,"," 0.0, 0.0, 1.0, 0.0,"," 0.0, 0.0, 0.0, -1.0",");","","mat4 transposeTmp( in mat4 inMatrix ) {"," vec4 i0 = inMatrix[0];"," vec4 i1 = inMatrix[1];"," vec4 i2 = inMatrix[2];"," vec4 i3 = inMatrix[3];",""," mat4 outMatrix = mat4("," vec4(i0.x, i1.x, i2.x, i3.x),"," vec4(i0.y, i1.y, i2.y, i3.y),"," vec4(i0.z, i1.z, i2.z, i3.z),"," vec4(i0.w, i1.w, i2.w, i3.w)"," );"," return outMatrix;","}","","//------------------------------------------------------------------------------","// Compute point size and center using the technique described in:","// 'GPU-Based Ray-Casting of Quadratic Surfaces'","// by Christian Sigg, Tim Weyrich, Mario Botsch, Markus Gross.","//","// Code based on","/*=========================================================================",""," Program: Visualization Toolkit"," Module: Quadrics_fs.glsl and Quadrics_vs.glsl",""," Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen"," All rights reserved."," See Copyright.txt or http://www.kitware.com/Copyright.htm for details.",""," This software is distributed WITHOUT ANY WARRANTY; without even"," the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR"," PURPOSE. See the above copyright notice for more information.",""," =========================================================================*/","","// .NAME Quadrics_fs.glsl and Quadrics_vs.glsl","// .SECTION Thanks","// ","//","// This file is part of the PointSprites plugin developed and contributed by","//","// Copyright (c) CSCS - Swiss National Supercomputing Centre","// EDF - Electricite de France","//","// John Biddiscombe, Ugo Varetto (CSCS)","// Stephane Ploix (EDF)","//","// ","//","// Contributions by Alexander Rose","// - ported to WebGL","// - adapted to work with quads","void ComputePointSizeAndPositionInClipCoordSphere(vec4 updatePosition){",""," vec2 xbc;"," vec2 ybc;",""," mat4 T = mat4("," radius, 0.0, 0.0, 0.0,"," 0.0, radius, 0.0, 0.0,"," 0.0, 0.0, radius, 0.0,"," updatePosition.x, updatePosition.y, updatePosition.z, 1.0"," );",""," mat4 R = transposeTmp( projectionMatrix * modelViewMatrix * T );"," float A = dot( R[ 3 ], D * R[ 3 ] );"," float B = -2.0 * dot( R[ 0 ], D * R[ 3 ] );"," float C = dot( R[ 0 ], D * R[ 0 ] );"," xbc[ 0 ] = ( -B - sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," xbc[ 1 ] = ( -B + sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," float sx = abs( xbc[ 0 ] - xbc[ 1 ] ) * 0.5;",""," A = dot( R[ 3 ], D * R[ 3 ] );"," B = -2.0 * dot( R[ 1 ], D * R[ 3 ] );"," C = dot( R[ 1 ], D * R[ 1 ] );"," ybc[ 0 ] = ( -B - sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," ybc[ 1 ] = ( -B + sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );"," float sy = abs( ybc[ 0 ] - ybc[ 1 ] ) * 0.5;",""," gl_Position.xy = vec2( 0.5 * ( xbc.x + xbc.y ), 0.5 * ( ybc.x + ybc.y ) );"," gl_Position.xy -= mapping * vec2( sx, sy );"," gl_Position.xy *= gl_Position.w;","","}",""," mat4 computeMat(vec4 v1, vec4 v2, vec4 v3, vec4 v4) {"," return mat4("," v1.x, v1.y, v1.z, v1.w,"," v2.x, v2.y, v2.z, v2.w,"," v3.x, v3.y, v3.z, v3.w,"," v4.x, v4.y, v4.z, v4.w"," );"," }","","void main(void){",""," #ifdef PICKING"," vPickingColor = unpackColor( primitiveId );"," #else"," #include color_vertex"," #endif",""," vRadius = radius * matrixScale( modelViewMatrix );",""," mat4 matrix = computeMat(matrix1, matrix2, matrix3, matrix4);"," vec4 updatePosition = matrix * vec4(position, 1.0);","","// vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );"," vec4 mvPosition = modelViewMatrix * vec4( updatePosition.xyz, 1.0 );"," // avoid clipping, added again in fragment shader"," mvPosition.z -= vRadius;","","// gl_Position = projectionMatrix * vec4( mvPosition.xyz, 1.0 );"," gl_Position = projectionMatrix * vec4( mvPosition.xyz, 1.0 );"," ComputePointSizeAndPositionInClipCoordSphere(updatePosition);","",""," vRadiusSq = vRadius * vRadius;"," vec4 vPoint4 = projectionMatrixInverse * gl_Position;"," vPoint = vPoint4.xyz / vPoint4.w;"," vPointViewPosition = -mvPosition.xyz / mvPosition.w;","","}"].join("\n"),$NGL_shaderTextHash["CylinderInstancing.frag"]=$NGL_shaderTextHash["CylinderImpostor.frag"],$NGL_shaderTextHash["CylinderInstancing.vert"]=["// Open-Source PyMOL is Copyright (C) Schrodinger, LLC.","//","// All Rights Reserved","//","// Permission to use, copy, modify, distribute, and distribute modified","// versions of this software and its built-in documentation for any","// purpose and without fee is hereby granted, provided that the above","// copyright notice appears in all copies and that both the copyright","// notice and this permission notice appear in supporting documentation,","// and that the name of Schrodinger, LLC not be used in advertising or","// publicity pertaining to distribution of the software without specific,","// written prior permission.","//","// SCHRODINGER, LLC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,","// INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN","// NO EVENT SHALL SCHRODINGER, LLC BE LIABLE FOR ANY SPECIAL, INDIRECT OR","// CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS","// OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE","// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE","// USE OR PERFORMANCE OF THIS SOFTWARE.","","// Contributions by Alexander Rose","// - ported to WebGL","// - dual color","// - pk color","// - shift","","attribute vec3 mapping;","attribute vec3 position1;","attribute vec3 position2;","attribute float radius;","attribute vec4 matrix1;","attribute vec4 matrix2;","attribute vec4 matrix3;","attribute vec4 matrix4;","","varying vec3 axis;","varying vec4 base_radius;","varying vec4 end_b;","varying vec3 U;","varying vec3 V;","varying vec4 w;","varying float fogDepth;","varying float fogNear;","varying float fogFar;","","#ifdef PICKING"," #include unpack_clr"," attribute float primitiveId;"," varying vec3 vPickingColor;","#else"," //attribute vec3 color;"," attribute vec3 color2;"," varying vec3 vColor1;"," varying vec3 vColor2;","#endif","","uniform mat4 modelViewMatrixInverse;","uniform float ortho;","","//include matrix_scale","float matrixScale( in mat4 m ){"," vec4 r = m[ 0 ];"," return sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );","}",""," mat4 computeMat(vec4 v1, vec4 v2, vec4 v3, vec4 v4) {"," return mat4("," v1.x, v1.y, v1.z, v1.w,"," v2.x, v2.y, v2.z, v2.w,"," v3.x, v3.y, v3.z, v3.w,"," v4.x, v4.y, v4.z, v4.w"," );"," }","","void main(){",""," #ifdef PICKING"," vPickingColor = unpackColor( primitiveId );"," #else"," vColor1 = color;"," vColor2 = color2;"," #endif",""," // vRadius = radius;"," base_radius.w = radius * matrixScale( modelViewMatrix );",""," //vec3 center = ( position2 + position1 ) / 2.0;",""," mat4 matrix = computeMat(matrix1, matrix2, matrix3, matrix4);"," vec4 updatePosition1 = matrix * vec4(position1, 1.0);"," vec4 updatePosition2 = matrix * vec4(position2, 1.0);"," vec3 center = ( updatePosition2.xyz + updatePosition1.xyz ) / 2.0;",""," //vec3 dir = normalize( position2 - position1 );"," vec3 dir = normalize( updatePosition2.xyz - updatePosition1.xyz );"," float ext = length( position2 - position1 ) / 2.0;",""," // using cameraPosition fails on some machines, not sure why"," // vec3 cam_dir = normalize( cameraPosition - mix( center, vec3( 0.0 ), ortho ) );"," vec3 cam_dir;"," if( ortho == 0.0 ){"," cam_dir = ( modelViewMatrixInverse * vec4( 0, 0, 0, 1 ) ).xyz - center;"," }else{"," cam_dir = ( modelViewMatrixInverse * vec4( 0, 0, 1, 0 ) ).xyz;"," }"," cam_dir = normalize( cam_dir );",""," vec3 ldir;",""," float b = dot( cam_dir, dir );"," end_b.w = b;"," // direction vector looks away, so flip"," if( b < 0.0 )"," ldir = -ext * dir;"," // direction vector already looks in my direction"," else"," ldir = ext * dir;",""," vec3 left = normalize( cross( cam_dir, ldir ) );"," left = radius * left;"," vec3 up = radius * normalize( cross( left, ldir ) );",""," // transform to modelview coordinates"," axis = normalize( normalMatrix * ldir );"," U = normalize( normalMatrix * up );"," V = normalize( normalMatrix * left );",""," vec4 base4 = modelViewMatrix * vec4( center - ldir, 1.0 );"," base_radius.xyz = base4.xyz / base4.w;",""," vec4 top_position = modelViewMatrix * vec4( center + ldir, 1.0 );"," vec4 end4 = top_position;"," end_b.xyz = end4.xyz / end4.w;",""," w = modelViewMatrix * vec4("," center + mapping.x*ldir + mapping.y*left + mapping.z*up, 1.0"," );",""," gl_Position = projectionMatrix * w;",""," // avoid clipping (1.0 seems to induce flickering with some drivers)"," gl_Position.z = 0.99;","","}"].join("\n"),$NGL_shaderTextHash["Instancing.frag"]=["#define STANDARD","uniform vec3 diffuse;","uniform vec3 emissive;","uniform float roughness;","uniform float metalness;","uniform float opacity;","uniform float nearClip;","uniform float clipRadius;","uniform mat4 projectionMatrix;","uniform float ortho;","varying float bCylinder;","","#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || ( !defined( PICKING ) && !defined( NOLIGHT ) )"," varying vec3 vViewPosition;","#endif","","#if defined( RADIUS_CLIP )"," varying vec3 vClipCenter;","#endif","","#if defined( PICKING )"," uniform float objectId;"," varying vec3 vPickingColor;","#elif defined( NOLIGHT )"," varying vec3 vColor;","#else"," #ifndef FLAT_SHADED"," varying vec3 vNormal;"," #endif"," #include common"," #include color_pars_fragment"," #include fog_pars_fragment"," #include bsdfs"," #include lights_pars_begin"," #include lights_physical_pars_fragment","#endif","","void main(){"," #include nearclip_fragment"," #include radiusclip_fragment",""," #if defined( PICKING )",""," gl_FragColor = vec4( vPickingColor, objectId );",""," #elif defined( NOLIGHT )",""," gl_FragColor = vec4( vColor, opacity );",""," #else",""," vec4 diffuseColor = vec4( diffuse, opacity );"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveLight = emissive;",""," #include color_fragment"," #include roughnessmap_fragment"," #include metalnessmap_fragment"," #include normal_flip"," #include normal_fragment_begin",""," //include dull_interior_fragment",""," #include lights_physical_fragment"," //include lights_template"," #include lights_fragment_begin"," #include lights_fragment_end",""," vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;",""," #include interior_fragment",""," gl_FragColor = vec4( outgoingLight, diffuseColor.a );",""," #include premultiplied_alpha_fragment"," #include tonemapping_fragment"," #include encodings_fragment"," #include fog_fragment",""," #include opaque_back_fragment",""," #endif","","}"].join("\n"),$NGL_shaderTextHash["Instancing.vert"]=["#define STANDARD","","uniform mat4 projectionMatrixInverse;","uniform float nearClip;","uniform vec3 clipCenter;","attribute vec4 matrix1;","attribute vec4 matrix2;","attribute vec4 matrix3;","attribute vec4 matrix4;","attribute float cylinder;","varying float bCylinder;","","#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || ( !defined( PICKING ) && !defined( NOLIGHT ) )"," varying vec3 vViewPosition;","#endif","","#if defined( RADIUS_CLIP )"," varying vec3 vClipCenter;","#endif","","#if defined( PICKING )"," #include unpack_color"," attribute float primitiveId;"," varying vec3 vPickingColor;","#elif defined( NOLIGHT )"," varying vec3 vColor;","#else"," #include color_pars_vertex"," #ifndef FLAT_SHADED"," varying vec3 vNormal;"," #endif","#endif","","#include common",""," mat4 computeMat(vec4 v1, vec4 v2, vec4 v3, vec4 v4) {"," return mat4("," v1.x, v1.y, v1.z, v1.w,"," v2.x, v2.y, v2.z, v2.w,"," v3.x, v3.y, v3.z, v3.w,"," v4.x, v4.y, v4.z, v4.w"," );"," }","","void main(){"," bCylinder = cylinder;",""," mat4 matrix = computeMat(matrix1, matrix2, matrix3, matrix4);"," vec4 updatePosition = matrix * vec4(position, 1.0);",""," #if defined( PICKING )"," vPickingColor = unpackColor( primitiveId );"," #elif defined( NOLIGHT )"," vColor = color;"," #else"," #include color_vertex"," //include beginnormal_vertex"," //vec3 objectNormal = vec3( normal );"," vec3 objectNormal = vec3(matrix * vec4(normal,0.0));"," #include defaultnormal_vertex"," // Normal computed with derivatives when FLAT_SHADED"," #ifndef FLAT_SHADED"," vNormal = normalize( transformedNormal );"," #endif"," #endif",""," //include begin_vertex"," vec3 transformed = updatePosition.xyz;"," //include project_vertex"," vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );"," gl_Position = projectionMatrix * mvPosition;",""," #if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || ( !defined( PICKING ) && !defined( NOLIGHT ) )"," vViewPosition = -mvPosition.xyz;"," #endif",""," #if defined( RADIUS_CLIP )"," vClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;"," #endif",""," #include nearclip_vertex","","}"].join("\n"),THREE.RenderableObject=function(){"use strict";this.id=0,this.object=null,this.z=0},THREE.RenderableFace=function(){"use strict";this.id=0,this.v1=new THREE.RenderableVertex,this.v2=new THREE.RenderableVertex,this.v3=new THREE.RenderableVertex,this.normalModel=new THREE.Vector3,this.vertexNormalsModel=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3],this.vertexNormalsLength=0,this.color=new THREE.Color,this.material=null,this.uvs=[new THREE.Vector2,new THREE.Vector2,new THREE.Vector2],this.z=0},THREE.RenderableVertex=function(){"use strict";this.position=new THREE.Vector3,this.positionWorld=new THREE.Vector3,this.positionScreen=new THREE.Vector4,this.visible=!0},THREE.RenderableVertex.prototype.copy=function(e){"use strict";this.positionWorld.copy(e.positionWorld),this.positionScreen.copy(e.positionScreen)},THREE.RenderableLine=function(){"use strict";this.id=0,this.v1=new THREE.RenderableVertex,this.v2=new THREE.RenderableVertex,this.vertexColors=[new THREE.Color,new THREE.Color],this.material=null,this.z=0},THREE.RenderableSprite=function(){"use strict";this.id=0,this.object=null,this.x=0,this.y=0,this.z=0,this.rotation=0,this.scale=new THREE.Vector2,this.material=null},THREE.Projector=function(){"use strict";var e,t,i,o,n,r,a,s,c,d,l,u=[],p=0,f=[],v=0,h=[],m=0,g=[],y=0,E=[],_=0,b={objects:[],lights:[],elements:[]},w=(new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3),T=new THREE.Vector4,x=new THREE.Box3(new THREE.Vector3(-1,-1,-1),new THREE.Vector3(1,1,1)),C=new THREE.Box3,R=new Array(3),S=(new Array(4),new THREE.Matrix4),L=new THREE.Matrix4,A=(new THREE.Matrix4,new THREE.Matrix3,new THREE.Frustum);new THREE.Vector4,new THREE.Vector4;this.projectVector=function(e,t){console.warn("THREE.Projector: .projectVector() is now vector.project()."),e.project(t)},this.unprojectVector=function(e,t){console.warn("THREE.Projector: .unprojectVector() is now vector.unproject()."),e.unproject(t)},this.pkRay=function(e,t){console.error("THREE.Projector: .pkRay() is now raycaster.setFromCamera().")};var I=new function(){var e=[],t=[],c=null,d=null,u=new THREE.Matrix3,p=function(e){var t=e.position,i=e.positionWorld,o=e.positionScreen;i.copy(t).applyMatrix4(l),o.copy(i).applyMatrix4(L);var n=1/o.w;o.x*=n,o.y*=n,o.z*=n,e.visible=o.x>=-1&&o.x<=1&&o.y>=-1&&o.y<=1&&o.z>=-1&&o.z<=1},E=function(e,t,i){return!0===e.visible||!0===t.visible||!0===i.visible||(R[0]=e.positionScreen,R[1]=t.positionScreen,R[2]=i.positionScreen,x.isIntersectionBox(C.setFromPoints(R)))},_=function(e,t,i){return(i.positionScreen.x-e.positionScreen.x)*(t.positionScreen.y-e.positionScreen.y)-(i.positionScreen.y-e.positionScreen.y)*(t.positionScreen.x-e.positionScreen.x)<0};return{setObject:function(i){d=(c=i).material,u.getNormalMatrix(c.matrixWorld),e.length=0,t.length=0},projectVertex:p,checkTriangleVisibility:E,checkBackfaceCulling:_,pushVertex:function(e,t,n){(i=function(){if(o===v){var e=new THREE.RenderableVertex;return f.push(e),v++,o++,e}return f[o++]}()).position.set(e,t,n),p(i)},pushNormal:function(t,i,o){e.push(t,i,o)},pushUv:function(e,i){t.push(e,i)},pushLine:function(e,t){var i=f[e],o=f[t];(a=function(){if(s===y){var e=new THREE.RenderableLine;return g.push(e),y++,s++,e}return g[s++]}()).id=c.id,a.v1.copy(i),a.v2.copy(o),a.z=(i.positionScreen.z+o.positionScreen.z)/2,a.material=c.material,b.elements.push(a)},pushTriangle:function(i,o,a){var s=f[i],l=f[o],p=f[a];if(!1!==E(s,l,p)&&(d.side===THREE.DoubleSide||!0===_(s,l,p))){(n=function(){if(r===m){var e=new THREE.RenderableFace;return h.push(e),m++,r++,e}return h[r++]}()).id=c.id,n.v1.copy(s),n.v2.copy(l),n.v3.copy(p),n.z=(s.positionScreen.z+l.positionScreen.z+p.positionScreen.z)/3;for(var v=0;v<3;v++){var g=3*arguments[v],y=n.vertexNormalsModel[v];y.set(e[g],e[g+1],e[g+2]),y.applyMatrix3(u).normalize();var w=2*arguments[v];n.uvs[v].set(t[w],t[w+1])}n.vertexNormalsLength=3,n.material=c.material,b.elements.push(n)}}}};function O(){if(d===_){var e=new THREE.RenderableSprite;return E.push(e),_++,d++,e}return E[d++]}function N(e,t){return e.z!==t.z?t.z-e.z:e.id!==t.id?e.id-t.id:0}this.projectScene=function(i,n,a,f){r=0,s=0,d=0,b.elements.length=0,!0===i.autoUpdate&&i.updateMatrixWorld(),void 0===n.parent&&n.updateMatrixWorld(),S.copy(n.matrixWorldInverse.copy(n.matrixWorld).invert()),L.multiplyMatrices(n.projectionMatrix,S),A.setFromMatrix(L),t=0,b.objects.length=0,b.lights.length=0,i.traverseVisible(function(i){if(i instanceof THREE.Light)b.lights.push(i);else if(i instanceof THREE.Mesh||i instanceof THREE.Line||i instanceof THREE.Sprite){if(!1===i.material.visible)return;!1!==i.frustumCulled&&!0!==A.intersectsObject(i)||((e=function(){if(t===p){var e=new THREE.RenderableObject;return u.push(e),p++,t++,e}return u[t++]}()).id=i.id,e.object=i,w.setFromMatrixPosition(i.matrixWorld),w.applyProjection(L),e.z=w.z,b.objects.push(e))}}),!0===a&&b.objects.sort(N);for(var v=0,h=b.objects.length;v0)for(v=0;v=-1&&T.z<=1&&((c=O()).id=m.id,c.x=T.x*j,c.y=T.y*j,c.z=T.z,c.object=m,c.rotation=m.rotation,c.scale.x=m.scale.x*Math.abs(c.x-(T.x+n.projectionMatrix.elements[0])/(T.w+n.projectionMatrix.elements[12])),c.scale.y=m.scale.y*Math.abs(c.y-(T.y+n.projectionMatrix.elements[5])/(T.w+n.projectionMatrix.elements[13])),c.material=m.material,b.elements.push(c))}}return!0===f&&b.elements.sort(N),b}},THREE.TrackballControls=function(e,t,i){"use strict";var o=this;this.STATE={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4},this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=1,this.zoomSpeed=1.2,this.panSpeed=.3,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.noRoll=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.minDistance=0,this.maxDistance=1/0,this.keys=[65,83,68],this.target=new THREE.Vector3;var n=new THREE.Vector3;this._state=this.STATE.NONE;var r=this.STATE.NONE,a=new THREE.Vector3;this._rotateStart=new THREE.Vector3,this._rotateEnd=new THREE.Vector3,this._zoomStart=new THREE.Vector2,this._zoomEnd=new THREE.Vector2;var s=0,c=0;this._panStart=new THREE.Vector2,this._panEnd=new THREE.Vector2,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.up0=this.object.up.clone();var d={type:"change"},l={type:"start"},u={type:"end"};this.handleResize=function(){if(this.domElement===document)this.screen.left=0,this.screen.top=0,this.screen.width=window.innerWidth,this.screen.height=window.innerHeight;else if(this.domElement){var e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}},this.handleEvent=function(e){"function"==typeof this[e.type]&&this[e.type](e)};var p,f,v,h,m,g,y,E,_,b=(p=new THREE.Vector2,function(e,t){return p.set((e-o.screen.left)/o.screen.width,(t-o.screen.top)/o.screen.height),p}),w=(f=new THREE.Vector3,v=new THREE.Vector3,h=new THREE.Vector3,function(e,t){h.set((e-.5*o.screen.width-o.screen.left)/(.5*o.screen.width),(.5*o.screen.height+o.screen.top-t)/(.5*o.screen.height),0);var i=h.length();return o.noRoll?i1?h.normalize():h.z=Math.sqrt(1-i*i),a.copy(o.object.position).sub(o.target),f.copy(o.object.up).setLength(h.y),f.add(v.copy(o.object.up).cross(a).setLength(h.x)),f.add(a.setLength(h.z)),f});function T(e){!1===o.enabled||Object.keys(window).length<2||(window.removeEventListener("keydown",T),r=o._state,o._state===o.STATE.NONE&&(e.keyCode!==o.keys[o.STATE.ROTATE]||o.noRotate?e.keyCode!==o.keys[o.STATE.ZOOM]||o.noZoom?e.keyCode!==o.keys[o.STATE.PAN]||o.noPan||(o._state=o.STATE.PAN):o._state=o.STATE.ZOOM:o._state=o.STATE.ROTATE))}function x(e){!1===o.enabled||Object.keys(window).length<2||(e.stopPropagation(),o._state!==o.STATE.ROTATE||o.noRotate?o._state!==o.STATE.ZOOM||o.noZoom?o._state!==o.STATE.PAN||o.noPan||o._panEnd.copy(b(e.pageX,e.pageY)):o._zoomEnd.copy(b(e.pageX,e.pageY)):o._rotateEnd.copy(w(e.pageX,e.pageY)))}function C(e){!1===o.enabled||Object.keys(window).length<2||(e.stopPropagation(),o._state=o.STATE.NONE,document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",C),o.dispatchEvent(u))}function R(e){if(!(!1===o.enabled||Object.keys(window).length<2)){e.stopPropagation();var t=0;e.wheelDelta?t=e.wheelDelta/40:e.detail&&(t=-e.detail/3),o._zoomStart.y=.005*t,o.dispatchEvent(l),o.dispatchEvent(u)}}this.rotateCamera=(m=new THREE.Vector3,g=new THREE.Quaternion,function(e,t){var n;void 0===e&&(n=Math.acos(o._rotateStart.dot(o._rotateEnd)/o._rotateStart.length()/o._rotateEnd.length())),(n||void 0!==e)&&(void 0===e?(m.crossVectors(o._rotateStart,o._rotateEnd).normalize(),n*=o.rotateSpeed,g.setFromAxisAngle(m,-n)):g.copy(e),void 0===i||void 0===i.quaternion||void 0!==t&&!0!==t||i.quaternion.multiplyQuaternions(g,i.quaternion),a.applyQuaternion(g),o.object.up.applyQuaternion(g),o._rotateEnd.applyQuaternion(g),o.staticMoving?o._rotateStart.copy(o._rotateEnd):(g.setFromAxisAngle(m,n*(o.dynamicDampingFactor-1)),o._rotateStart.applyQuaternion(g)))}),this.zoomCamera=function(e,t){var n;o._state===o.STATE.TOUCH_ZOOM_PAN?(void 0!==e?n=e:(n=s/c,s=c),a.multiplyScalar(n),void 0===i||void 0===i._zoomFactor||void 0!==t&&!0!==t||(i._zoomFactor*=n,i.fogCls.setFog())):(n=void 0!==e?e:1+(o._zoomEnd.y-o._zoomStart.y)*o.zoomSpeed,void 0===i||void 0===i._zoomFactor||void 0!==t&&!0!==t||(i._zoomFactor*=n,i.fogCls.setFog()),1!==n&&(a.multiplyScalar(n),o.staticMoving?o._zoomStart.copy(o._zoomEnd):o._zoomStart.y+=(o._zoomEnd.y-o._zoomStart.y)*this.dynamicDampingFactor))},this.panCamera=(y=new THREE.Vector2,E=new THREE.Vector3,_=new THREE.Vector3,function(e,t){void 0!==e?(y=e,void 0===i||void 0===i.mouseChange||void 0!==t&&!0!==t||i.mouseChange.add(e)):(y.copy(o._panEnd).sub(o._panStart),void 0===i||void 0===i.mouseChange||void 0!==t&&!0!==t||i.mouseChange.add(o._panEnd).sub(o._panStart)),y.lengthSq()&&(y.multiplyScalar(a.length()*o.panSpeed),_.copy(a).cross(o.object.up).setLength(y.x),_.add(E.copy(o.object.up).setLength(y.y)),o.object.position.add(_),o.target.add(_),o.staticMoving?o._panStart.copy(o._panEnd):o._panStart.add(y.subVectors(o._panEnd,o._panStart).multiplyScalar(o.dynamicDampingFactor)))}),this.checkDistances=function(){o.noZoom&&o.noPan||(a.lengthSq()>o.maxDistance*o.maxDistance&&o.object.position.addVectors(o.target,a.setLength(o.maxDistance)),a.lengthSq()1e-6&&(o.dispatchEvent(d),n.copy(o.object.position))},this.reset=function(){o._state=o.STATE.NONE,r=o.STATE.NONE,o.target.copy(o.target0),o.object.position.copy(o.position0),o.object.up.copy(o.up0),a.subVectors(o.object.position,o.target),o.object.lookAt(o.target),o.dispatchEvent(d),n.copy(o.object.position)},Object.keys(window).length>=2&&this.domElement&&(this.domElement.addEventListener("contextmn",function(e){},!1),this.domElement.addEventListener("mousedown",function(e){!1===o.enabled||Object.keys(window).length<2||(e.stopPropagation(),o._state===o.STATE.NONE&&(o._state=e.button),o._state!==o.STATE.ROTATE||o.noRotate?o._state!==o.STATE.ZOOM||o.noZoom?o._state!==o.STATE.PAN||o.noPan||(o._panStart.copy(b(e.pageX,e.pageY)),o._panEnd.copy(o._panStart)):(o._zoomStart.copy(b(e.pageX,e.pageY)),o._zoomEnd.copy(o._zoomStart)):(o._rotateStart.copy(w(e.pageX,e.pageY)),o._rotateEnd.copy(o._rotateStart)),document.addEventListener("mousemove",x,!1),document.addEventListener("mouseup",C,!1),o.dispatchEvent(l))},!1),this.domElement.addEventListener("mousewheel",R,!1),this.domElement.addEventListener("DOMMouseScroll",R,!1),this.domElement.addEventListener("touchstart",function(e){if(!(!1===o.enabled||Object.keys(window).length<2)){switch(e.touches.length){case 1:o._state=o.STATE.TOUCH_ROTATE,o._rotateStart.copy(w(e.touches[0].pageX,e.touches[0].pageY)),o._rotateEnd.copy(o._rotateStart);break;case 2:o._state=o.STATE.TOUCH_ZOOM_PAN;var t=e.touches[0].pageX-e.touches[1].pageX,i=e.touches[0].pageY-e.touches[1].pageY;c=s=Math.sqrt(t*t+i*i);var n=(e.touches[0].pageX+e.touches[1].pageX)/2,r=(e.touches[0].pageY+e.touches[1].pageY)/2;o._panStart.copy(b(n,r)),o._panEnd.copy(o._panStart);break;default:o._state=o.STATE.NONE}o.dispatchEvent(l)}},!1),this.domElement.addEventListener("touchend",function(e){if(!(!1===o.enabled||Object.keys(window).length<2)){switch(e.touches.length){case 1:o._rotateEnd.copy(w(e.touches[0].pageX,e.touches[0].pageY)),o._rotateStart.copy(o._rotateEnd);break;case 2:s=c=0;var t=(e.touches[0].pageX+e.touches[1].pageX)/2,i=(e.touches[0].pageY+e.touches[1].pageY)/2;o._panEnd.copy(b(t,i)),o._panStart.copy(o._panEnd)}o._state=o.STATE.NONE,o.dispatchEvent(u)}},!1),this.domElement.addEventListener("touchmove",function(e){if(!(!1===o.enabled||Object.keys(window).length<2))switch(e.stopPropagation(),e.touches.length){case 1:o._rotateEnd.copy(w(e.touches[0].pageX,e.touches[0].pageY));break;case 2:var t=e.touches[0].pageX-e.touches[1].pageX,i=e.touches[0].pageY-e.touches[1].pageY;c=Math.sqrt(t*t+i*i);var n=(e.touches[0].pageX+e.touches[1].pageX)/2,r=(e.touches[0].pageY+e.touches[1].pageY)/2;o._panEnd.copy(b(n,r));break;default:o._state=o.STATE.NONE}},!1),Object.keys(window).length>=2&&window.addEventListener("keydown",T,!1),Object.keys(window).length>=2&&window.addEventListener("keyup",function(e){!1===o.enabled||Object.keys(window).length<2||(o._state=r,window.addEventListener("keydown",T,!1))},!1)),this.handleResize(),this.update()},THREE.TrackballControls.prototype=Object.create(THREE.EventDispatcher.prototype),THREE.TrackballControls.prototype.constructor=THREE.TrackballControls,THREE.OrthographicTrackballControls=function(e,t,i){this.icn3d;var o=this,n={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4};this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=.5,this.zoomSpeed=1.2;this.zoomSpeed*=.01,this.panSpeed=.03,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.noRoll=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.keys=[65,83,68],this.target=new THREE.Vector3;var r=new THREE.Vector3;this._state=n.NONE;var a=n.NONE,s=new THREE.Vector3;this._rotateStart=new THREE.Vector3,this._rotateEnd=new THREE.Vector3,this._zoomStart=new THREE.Vector2,this._zoomEnd=new THREE.Vector2;var c=1,d=0,l=0;this._panStart=new THREE.Vector2,this._panEnd=new THREE.Vector2,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.up0=this.object.up.clone(),this.left0=this.object.left,this.right0=this.object.right,this.top0=this.object.top,this.bottom0=this.object.bottom,this.center0=new THREE.Vector2((this.left0+this.right0)/2,(this.top0+this.bottom0)/2);var u={type:"change"},p={type:"start"},f={type:"end"};this.handleResize=function(){if(this.domElement===document)this.screen.left=0,this.screen.top=0,this.screen.width=window.innerWidth,this.screen.height=window.innerHeight;else if(this.domElement){var e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}this.left0=this.object.left,this.right0=this.object.right,this.top0=this.object.top,this.bottom0=this.object.bottom,this.center0.set((this.left0+this.right0)/2,(this.top0+this.bottom0)/2)},this.handleEvent=function(e){"function"==typeof this[e.type]&&this[e.type](e)};var v,h,m,g,y,E,_,b,w,T=(v=new THREE.Vector2,function(e,t){return v.set((e-o.screen.left)/o.screen.width,(t-o.screen.top)/o.screen.height),v}),x=(h=new THREE.Vector3,m=new THREE.Vector3,g=new THREE.Vector3,function(e,t){g.set((e-.5*o.screen.width-o.screen.left)/(.5*o.screen.width),(.5*o.screen.height+o.screen.top-t)/(.5*o.screen.height),0);var i=g.length();return o.noRoll?i1?g.normalize():g.z=Math.sqrt(1-i*i),s.copy(o.object.position).sub(o.target),h.copy(o.object.up).setLength(g.y),h.add(m.copy(o.object.up).cross(s).setLength(g.x)),h.add(s.setLength(g.z)),h});function C(e){!1===o.enabled||Object.keys(window).length<2||(window.removeEventListener("keydown",C),a=o._state,o._state===n.NONE&&(e.keyCode!==o.keys[n.ROTATE]||o.noRotate?e.keyCode!==o.keys[n.ZOOM]||o.noZoom?e.keyCode!==o.keys[n.PAN]||o.noPan||(o._state=n.PAN):o._state=n.ZOOM:o._state=n.ROTATE))}function R(e){!1===o.enabled||Object.keys(window).length<2||(e.stopPropagation(),o._state!==n.ROTATE||o.noRotate?o._state!==n.ZOOM||o.noZoom?o._state!==n.PAN||o.noPan||o._panEnd.copy(T(e.pageX,e.pageY)):o._zoomEnd.copy(T(e.pageX,e.pageY)):o._rotateEnd.copy(x(e.pageX,e.pageY)))}function S(e){!1===o.enabled||Object.keys(window).length<2||(e.stopPropagation(),o._state=n.NONE,document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",S),o.dispatchEvent(f))}function L(e){if(!(!1===o.enabled||Object.keys(window).length<2)){e.stopPropagation();var t=0;e.wheelDelta?t=e.wheelDelta/40:e.detail&&(t=-e.detail/3),o._zoomStart.y=.01*t,o.dispatchEvent(p),o.dispatchEvent(f)}}this.rotateCamera=(y=new THREE.Vector3,E=new THREE.Quaternion,function(e,t){var n;void 0===e&&(n=Math.acos(o._rotateStart.dot(o._rotateEnd)/o._rotateStart.length()/o._rotateEnd.length())),(n||void 0!==e)&&(void 0===e?(y.crossVectors(o._rotateStart,o._rotateEnd).normalize(),n*=o.rotateSpeed,E.setFromAxisAngle(y,-n)):E.copy(e),void 0===i||void 0===i.quaternion||void 0!==t&&!0!==t||i.quaternion.multiplyQuaternions(E,i.quaternion),s.applyQuaternion(E),o.object.up.applyQuaternion(E),o._rotateEnd.applyQuaternion(E),o.staticMoving?o._rotateStart.copy(o._rotateEnd):(E.setFromAxisAngle(y,n*(o.dynamicDampingFactor-1)),o._rotateStart.applyQuaternion(E)))}),this.zoomCamera=function(e,t){var r;o._state===n.TOUCH_ZOOM_PAN?void 0!==e?r=e:(r=d/l,d=l):r=void 0!==e?e:1+(o._zoomEnd.y-o._zoomStart.y)*o.zoomSpeed/.01,void 0===i||void 0===i._zoomFactor||void 0!==t&&!0!==t||(i._zoomFactor*=r),1!==r&&(c=r,o.object.left=c*o.left0+(1-c)*o.center0.x,o.object.right=c*o.right0+(1-c)*o.center0.x,o.object.top=c*o.top0+(1-c)*o.center0.y,o.object.bottom=c*o.bottom0+(1-c)*o.center0.y,o.staticMoving?o._zoomStart.copy(o._zoomEnd):o._zoomStart.y+=(o._zoomEnd.y-o._zoomStart.y)*this.dynamicDampingFactor)},this.panCamera=(_=new THREE.Vector2,b=new THREE.Vector3,w=new THREE.Vector3,function(e,t){void 0!==e?(_=e,void 0===i||void 0===i.mouseChange||void 0!==t&&!0!==t||i.mouseChange.add(e)):(_.copy(o._panEnd).sub(o._panStart),void 0===i||void 0===i.mouseChange||void 0!==t&&!0!==t||i.mouseChange.add(o._panEnd).sub(o._panStart)),_.lengthSq()&&(_.multiplyScalar(s.length()*o.panSpeed),w.copy(s).cross(o.object.up).setLength(_.x),w.add(b.copy(o.object.up).setLength(_.y)),o.object.position.add(w),o.target.add(w),o.staticMoving?o._panStart.copy(o._panEnd):o._panStart.add(_.subVectors(o._panEnd,o._panStart).multiplyScalar(o.dynamicDampingFactor)))}),this.update=function(e){s.subVectors(o.object.position,o.target),o.noRotate||(void 0!==e&&void 0!==e.quaternion?o.rotateCamera(e.quaternion,e.update):o.rotateCamera()),o.noZoom||(void 0!==e&&void 0!==e._zoomFactor?o.zoomCamera(e._zoomFactor,e.update):o.zoomCamera(),o.object.updateProjectionMatrix()),o.noPan||(void 0!==e&&void 0!==e.mouseChange?o.panCamera(e.mouseChange,e.update):o.panCamera()),o.object.position.addVectors(o.target,s),o.object.lookAt(o.target),r.distanceToSquared(o.object.position)>1e-6&&(o.dispatchEvent(u),r.copy(o.object.position))},this.reset=function(){o._state=n.NONE,a=n.NONE,o.target.copy(o.target0),o.object.position.copy(o.position0),o.object.up.copy(o.up0),s.subVectors(o.object.position,o.target),o.object.left=o.left0,o.object.right=o.right0,o.object.top=o.top0,o.object.bottom=o.bottom0,o.object.lookAt(o.target),o.dispatchEvent(u),r.copy(o.object.position)},Object.keys(window).length>=2&&this.domElement&&(this.domElement.addEventListener("contextmn",function(e){},!1),this.domElement.addEventListener("mousedown",function(e){!1===o.enabled||Object.keys(window).length<2||(e.stopPropagation(),o._state===n.NONE&&(o._state=e.button),o._state!==n.ROTATE||o.noRotate?o._state!==n.ZOOM||o.noZoom?o._state!==n.PAN||o.noPan||(o._panStart.copy(T(e.pageX,e.pageY)),o._panEnd.copy(o._panStart)):(o._zoomStart.copy(T(e.pageX,e.pageY)),o._zoomEnd.copy(o._zoomStart)):(o._rotateStart.copy(x(e.pageX,e.pageY)),o._rotateEnd.copy(o._rotateStart)),document.addEventListener("mousemove",R,!1),document.addEventListener("mouseup",S,!1),o.dispatchEvent(p))},!1),this.domElement.addEventListener("mousewheel",L,!1),this.domElement.addEventListener("DOMMouseScroll",L,!1),this.domElement.addEventListener("touchstart",function(e){if(!(!1===o.enabled||Object.keys(window).length<2)){switch(e.touches.length){case 1:o._state=n.TOUCH_ROTATE,o._rotateStart.copy(x(e.touches[0].pageX,e.touches[0].pageY)),o._rotateEnd.copy(o._rotateStart);break;case 2:o._state=n.TOUCH_ZOOM_PAN;var t=e.touches[0].pageX-e.touches[1].pageX,i=e.touches[0].pageY-e.touches[1].pageY;l=d=Math.sqrt(t*t+i*i);var r=(e.touches[0].pageX+e.touches[1].pageX)/2,a=(e.touches[0].pageY+e.touches[1].pageY)/2;o._panStart.copy(T(r,a)),o._panEnd.copy(o._panStart);break;default:o._state=n.NONE}o.dispatchEvent(p)}},!1),this.domElement.addEventListener("touchend",function(e){if(!(!1===o.enabled||Object.keys(window).length<2)){switch(e.touches.length){case 1:o._rotateEnd.copy(x(e.touches[0].pageX,e.touches[0].pageY)),o._rotateStart.copy(o._rotateEnd);break;case 2:d=l=0;var t=(e.touches[0].pageX+e.touches[1].pageX)/2,i=(e.touches[0].pageY+e.touches[1].pageY)/2;o._panEnd.copy(T(t,i)),o._panStart.copy(o._panEnd)}o._state=n.NONE,o.dispatchEvent(f)}},!1),this.domElement.addEventListener("touchmove",function(e){if(!(!1===o.enabled||Object.keys(window).length<2))switch(e.stopPropagation(),e.touches.length){case 1:o._rotateEnd.copy(x(e.touches[0].pageX,e.touches[0].pageY));break;case 2:var t=e.touches[0].pageX-e.touches[1].pageX,i=e.touches[0].pageY-e.touches[1].pageY;l=Math.sqrt(t*t+i*i);var r=(e.touches[0].pageX+e.touches[1].pageX)/2,a=(e.touches[0].pageY+e.touches[1].pageY)/2;o._panEnd.copy(T(r,a));break;default:o._state=n.NONE}},!1),window.addEventListener("keydown",C,!1),window.addEventListener("keyup",function(e){!1===o.enabled||Object.keys(window).length<2||(o._state=a,window.addEventListener("keydown",C,!1))},!1)),this.handleResize(),this.update()},THREE.OrthographicTrackballControls.prototype=Object.create(THREE.EventDispatcher.prototype),THREE.OrthographicTrackballControls.prototype.constructor=THREE.OrthographicTrackballControls;var MMTF={};function initIcn3dpyMMTF(e){function t(e,t,i){for(var o=(e.byteLength,0),n=i.length;n>o;o++){var r=i.charCodeAt(o);if(128>r)e.setUint8(t++,r>>>0&127|0);else if(2048>r)e.setUint8(t++,r>>>6&31|192),e.setUint8(t++,r>>>0&63|128);else if(65536>r)e.setUint8(t++,r>>>12&15|224),e.setUint8(t++,r>>>6&63|128),e.setUint8(t++,r>>>0&63|128);else{if(!(1114112>r))throw new Error("bad codepoint "+r);e.setUint8(t++,r>>>18&7|240),e.setUint8(t++,r>>>12&63|128),e.setUint8(t++,r>>>6&63|128),e.setUint8(t++,r>>>0&63|128)}}}function i(e){for(var t=0,i=0,o=e.length;o>i;i++){var n=e.charCodeAt(i);if(128>n)t+=1;else if(2048>n)t+=2;else if(65536>n)t+=3;else{if(!(1114112>n))throw new Error("bad codepoint "+n);t+=4}}return t}function o(e){var o=new ArrayBuffer(function e(t){var o=typeof t;if("string"===o){if(32>(n=i(t)))return 1+n;if(256>n)return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if(t instanceof Uint8Array){if(256>(n=t.byteLength))return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if("number"===o){if(Math.floor(t)!==t)return 9;if(t>=0){if(128>t)return 1;if(256>t)return 2;if(65536>t)return 3;if(4294967296>t)return 5;throw new Error("Number too big 0x"+t.toString(16))}if(t>=-32)return 1;if(t>=-128)return 2;if(t>=-32768)return 3;if(t>=-2147483648)return 5;throw new Error("Number too small -0x"+t.toString(16).substr(1))}if("boolean"===o||null===t)return 1;if("object"===o){var n,r=0;if(Array.isArray(t)){n=t.length;for(var a=0;n>a;a++)r+=e(t[a])}else{var s=Object.keys(t);for(n=s.length,a=0;n>a;a++){var c=s[a];r+=e(c)+e(t[c])}}if(16>n)return 1+r;if(65536>n)return 3+r;if(4294967296>n)return 5+r;throw new Error("Array or object too long 0x"+n.toString(16))}throw new Error("Unknown type "+o)}(e));return function e(o,n,r){var a=typeof o;if("string"===a){if(32>(s=i(o)))return n.setUint8(r,160|s),t(n,r+1,o),1+s;if(256>s)return n.setUint8(r,217),n.setUint8(r+1,s),t(n,r+2,o),2+s;if(65536>s)return n.setUint8(r,218),n.setUint16(r+1,s),t(n,r+3,o),3+s;if(4294967296>s)return n.setUint8(r,219),n.setUint32(r+1,s),t(n,r+5,o),5+s}if(o instanceof Uint8Array){var s=o.byteLength,c=new Uint8Array(n.buffer);if(256>s)return n.setUint8(r,196),n.setUint8(r+1,s),c.set(o,r+2),2+s;if(65536>s)return n.setUint8(r,197),n.setUint16(r+1,s),c.set(o,r+3),3+s;if(4294967296>s)return n.setUint8(r,198),n.setUint32(r+1,s),c.set(o,r+5),5+s}if("number"===a){if(!isFinite(o))throw new Error("Number not finite: "+o);if(Math.floor(o)!==o)return n.setUint8(r,203),n.setFloat64(r+1,o),9;if(o>=0){if(128>o)return n.setUint8(r,o),1;if(256>o)return n.setUint8(r,204),n.setUint8(r+1,o),2;if(65536>o)return n.setUint8(r,205),n.setUint16(r+1,o),3;if(4294967296>o)return n.setUint8(r,206),n.setUint32(r+1,o),5;throw new Error("Number too big 0x"+o.toString(16))}if(o>=-32)return n.setInt8(r,o),1;if(o>=-128)return n.setUint8(r,208),n.setInt8(r+1,o),2;if(o>=-32768)return n.setUint8(r,209),n.setInt16(r+1,o),3;if(o>=-2147483648)return n.setUint8(r,210),n.setInt32(r+1,o),5;throw new Error("Number too small -0x"+(-o).toString(16).substr(1))}if(null===o)return n.setUint8(r,192),1;if("boolean"===a)return n.setUint8(r,o?195:194),1;if("object"===a){var d=0,l=Array.isArray(o);if(l)s=o.length;else{var u=Object.keys(o);s=u.length}if(16>s?(n.setUint8(r,s|(l?144:128)),d=1):65536>s?(n.setUint8(r,l?220:222),n.setUint16(r+1,s),d=3):4294967296>s&&(n.setUint8(r,l?221:223),n.setUint32(r+1,s),d=5),l)for(var p=0;s>p;p++)d+=e(o[p],n,r+d);else for(p=0;s>p;p++){var f=u[p];d+=e(f,n,r+d),d+=e(o[f],n,r+d)}return d}throw new Error("Unknown type "+a)}(e,new DataView(o),0),new Uint8Array(o)}function n(e,t,i){return t?new e(t.buffer,t.byteOffset,t.byteLength/(i||1)):void 0}function r(e){return n(DataView,e)}function a(e){return n(Uint8Array,e)}function s(e){return n(Int8Array,e)}function c(e){return n(Int32Array,e,4)}function d(e,t){var i=e.length/2;t||(t=new Int16Array(i));for(var o=0,n=0;i>o;++o,n+=2)t[o]=e[n]<<8^e[n+1]<<0;return t}function l(e,t){var i=e.length/4;t||(t=new Int32Array(i));for(var o=0,n=0;i>o;++o,n+=4)t[o]=e[n]<<24^e[n+1]<<16^e[n+2]<<8^e[n+3]<<0;return t}function u(e,t){var i=e.length;t||(t=new Uint8Array(4*i));for(var o=r(t),n=0;i>n;++n)o.setInt32(4*n,e[n]);return a(t)}function p(e,t,i){var o=e.length,n=1/t;i||(i=new Float32Array(o));for(var r=0;o>r;++r)i[r]=e[r]*n;return i}function f(e,t,i){var o=e.length;i||(i=new Int32Array(o));for(var n=0;o>n;++n)i[n]=Math.round(e[n]*t);return i}function v(e,t){var i,o;if(!t){var n=0;for(i=0,o=e.length;o>i;i+=2)n+=e[i+1];t=new e.constructor(n)}var r=0;for(i=0,o=e.length;o>i;i+=2)for(var a=e[i],s=e[i+1],c=0;s>c;++c)t[r]=a,++r;return t}function h(e){if(0===e.length)return new Int32Array;var t,i,o=2;for(t=1,i=e.length;i>t;++t)e[t-1]!==e[t]&&(o+=2);var n=new Int32Array(o),r=0,a=1;for(t=1,i=e.length;i>t;++t)e[t-1]!==e[t]?(n[r]=e[t-1],n[r+1]=a,a=1,r+=2):++a;return n[r]=e[e.length-1],n[r+1]=a,n}function m(e,t){var i=e.length;t||(t=new e.constructor(i)),i&&(t[0]=e[0]);for(var o=1;i>o;++o)t[o]=e[o]+t[o-1];return t}function g(e,t){var i=e.length;t||(t=new e.constructor(i)),t[0]=e[0];for(var o=1;i>o;++o)t[o]=e[o]-e[o-1];return t}function y(e,t){var i,o,n=e instanceof Int8Array?127:32767,r=-n-1,a=e.length;if(!t){var s=0;for(i=0;a>i;++i)e[i]r&&++s;t=new Int32Array(s)}for(i=0,o=0;a>i;){for(var c=0;e[i]===n||e[i]===r;)c+=e[i],++i;c+=e[i],++i,t[o]=c,++o}return t}function E(e,t,i){return p(y(e,c(i)),t,i)}function _(e,t,i){var o,r,a,s=y(e,c(i));return o=s,r=t,a=n(Float32Array,s,4),p(m(o,c(a)),r,a)}function b(e,t,i){return function(e,t){var i,o=t?127:32767,n=-o-1,r=e.length,a=0;for(i=0;r>i;++i)0===(d=e[i])?++a:d>0?(a+=Math.ceil(d/o),d%o==0&&(a+=1)):(a+=Math.ceil(d/n),d%n==0&&(a+=1));var s=t?new Int8Array(a):new Int16Array(a),c=0;for(i=0;r>i;++i){var d;if((d=e[i])>=0)for(;d>=o;)s[c]=o,++c,d-=o;else for(;n>=d;)s[c]=n,++c,d-=n;s[c]=d,++c}return s}(g(f(e,t),o),i);var o}function w(e,t,i,o){var n=new ArrayBuffer(12+o.byteLength),r=new Uint8Array(n),a=new DataView(n);return a.setInt32(0,e),a.setInt32(4,t),i&&r.set(i,8),r.set(o,12),r}function T(e){return w(2,e.length,void 0,a(e))}function x(e){return w(4,e.length,void 0,u(e))}function C(e,t){return w(5,e.length/t,u([t]),a(e))}function R(e){return w(6,e.length,void 0,u(h(e)))}function S(e){return w(8,e.length,void 0,u(h(g(e))))}function L(e,t){return w(9,e.length,u([t]),u(h(f(e,t))))}function A(e,t){return w(10,e.length,u([t]),function(e,t){var i=e.length;t||(t=new Uint8Array(2*i));for(var o=r(t),n=0;i>n;++n)o.setInt16(2*n,e[n]);return a(t)}(b(e,t)))}function I(e){var t={};return D.forEach(function(i){void 0!==e[i]&&(t[i]=e[i])}),e.bondAtomList&&(t.bondAtomList=x(e.bondAtomList)),e.bondOrderList&&(t.bondOrderList=T(e.bondOrderList)),t.xCoordList=A(e.xCoordList,1e3),t.yCoordList=A(e.yCoordList,1e3),t.zCoordList=A(e.zCoordList,1e3),e.bFactorList&&(t.bFactorList=A(e.bFactorList,100)),e.atomIdList&&(t.atomIdList=S(e.atomIdList)),e.altLocList&&(t.altLocList=R(e.altLocList)),e.occupancyList&&(t.occupancyList=L(e.occupancyList,100)),t.groupIdList=S(e.groupIdList),t.groupTypeList=x(e.groupTypeList),e.secStructList&&(t.secStructList=T(e.secStructList)),e.insCodeList&&(t.insCodeList=R(e.insCodeList)),e.sequenceIndexList&&(t.sequenceIndexList=S(e.sequenceIndexList)),t.chainIdList=C(e.chainIdList,4),e.chainNameList&&(t.chainNameList=C(e.chainNameList,4)),t}function O(e){function t(e){for(var t={},i=0;e>i;i++){t[r()]=r()}return t}function i(t){var i=e.subarray(a,a+t);return a+=t,i}function o(t){var i=e.subarray(a,a+t);a+=t;if(t>65535){for(var o=[],n=0;ni;i++)t[i]=r();return t}function r(){var r,c,d=e[a];if(0==(128&d))return a++,d;if(128==(240&d))return a++,t(c=15&d);if(144==(240&d))return a++,n(c=15&d);if(160==(224&d))return a++,o(c=31&d);if(224==(224&d))return r=s.getInt8(a),a++,r;switch(d){case 192:return a++,null;case 194:return a++,!1;case 195:return a++,!0;case 196:return c=s.getUint8(a+1),a+=2,i(c);case 197:return c=s.getUint16(a+1),a+=3,i(c);case 198:return c=s.getUint32(a+1),a+=5,i(c);case 202:return r=s.getFloat32(a+1),a+=5,r;case 203:return r=s.getFloat64(a+1),a+=9,r;case 204:return r=e[a+1],a+=2,r;case 205:return r=s.getUint16(a+1),a+=3,r;case 206:return r=s.getUint32(a+1),a+=5,r;case 208:return r=s.getInt8(a+1),a+=2,r;case 209:return r=s.getInt16(a+1),a+=3,r;case 210:return r=s.getInt32(a+1),a+=5,r;case 217:return c=s.getUint8(a+1),a+=2,o(c);case 218:return c=s.getUint16(a+1),a+=3,o(c);case 219:return c=s.getUint32(a+1),a+=5,o(c);case 220:return c=s.getUint16(a+1),a+=3,n(c);case 221:return c=s.getUint32(a+1),a+=5,n(c);case 222:return c=s.getUint16(a+1),a+=3,t(c);case 223:return c=s.getUint32(a+1),a+=5,t(c)}throw new Error("Unknown type 0x"+d.toString(16))}var a=0,s=new DataView(e.buffer);return r()}function N(e,t,i,o){switch(e){case 1:return function(e,t){var i=e.length;t||(t=new Float32Array(i/4));for(var o=r(t),n=r(e),a=0,s=0,c=i/4;c>a;++a,s+=4)o.setFloat32(s,n.getFloat32(s),!0);return t}(t);case 2:return s(t);case 3:return d(t);case 4:return l(t);case 5:return a(t);case 6:return v(l(t),new Uint8Array(i));case 7:return v(l(t));case 8:return m(v(l(t)),h);case 9:return n=l(t),u=l(o)[0],p(v(n,c(f)),u,f);case 10:return _(d(t),l(o)[0]);case 11:return p(d(t),l(o)[0]);case 12:return E(d(t),l(o)[0]);case 13:return E(s(t),l(o)[0]);case 14:return y(d(t));case 15:return y(s(t))}var n,u,f,h}function P(e,t){var i=(t=t||{}).ignoreFields,o={};return j.forEach(function(t){var n,a,s,c,d,l=!!i&&-1!==i.indexOf(t),u=e[t];l||void 0===u||(u instanceof Uint8Array?o[t]=N.apply(null,(a=r(n=u),s=a.getInt32(0),c=a.getInt32(4),d=n.subarray(8,12),[s,n=n.subarray(12),c,d])):o[t]=u)}),o}function M(e){return String.fromCharCode.apply(null,e).replace(/\0/g,"")}function H(e,t){return e instanceof ArrayBuffer&&(e=new Uint8Array(e)),P(e instanceof Uint8Array?O(e):e,t)}function z(e,t,i,o){var n=new XMLHttpRequest;n.addEventListener("load",function(){try{var e=H(n.response);i(e)}catch(e){o(e)}},!0),n.addEventListener("error",o,!0),n.responseType="arraybuffer",n.open("GET",t+e.toUpperCase()),n.send()}var D=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"],j=D.concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]),F="//mmtf.rcsb.org/v1.0/",V=F+"full/",U=F+"reduced/";return e.encode=function(e){return o(I(e))},e.decode=H,e.traverse=function(e,t,i){var o,n,r,a,s,c,d=(i=i||{}).firstModelOnly,l=t.onModel,u=t.onChain,p=t.onGroup,f=t.onAtom,v=t.onBond,h=0,m=0,g=0,y=0,E=0,_=-1,b=e.chainNameList,w=e.secStructList,T=e.insCodeList,x=e.sequenceIndexList,C=e.atomIdList,R=e.bFactorList,S=e.altLocList,L=e.occupancyList,A=e.bondAtomList,I=e.bondOrderList;for(o=0,n=e.chainsPerModel.length;n>o&&!(d&&h>0);++o){var O=e.chainsPerModel[h];for(l&&l({chainCount:O,modelIndex:h}),r=0;O>r;++r){var N=e.groupsPerChain[m];if(u){var P=M(e.chainIdList.subarray(4*m,4*m+4)),H=null;b&&(H=M(b.subarray(4*m,4*m+4))),u({groupCount:N,chainIndex:m,modelIndex:h,chainId:P,chainName:H})}for(a=0;N>a;++a){var z=e.groupList[e.groupTypeList[g]],D=z.atomNameList.length;if(p){var j=null;w&&(j=w[g]);var F=null;e.insCodeList&&(F=String.fromCharCode(T[g]));var V=null;x&&(V=x[g]),p({atomCount:D,groupIndex:g,chainIndex:m,modelIndex:h,groupId:e.groupIdList[g],groupType:e.groupTypeList[g],groupName:z.groupName,singleLetterCode:z.singleLetterCode,chemCompType:z.chemCompType,secStruct:j,insCode:F,sequenceIndex:V})}for(s=0;D>s;++s){if(f){var U=null;C&&(U=C[y]);var k=null;R&&(k=R[y]);var G=null;S&&(G=String.fromCharCode(S[y]));var B=null;L&&(B=L[y]),f({atomIndex:y,groupIndex:g,chainIndex:m,modelIndex:h,atomId:U,element:z.elementList[s],atomName:z.atomNameList[s],formalCharge:z.formalChargeList[s],xCoord:e.xCoordList[y],yCoord:e.yCoordList[y],zCoord:e.zCoordList[y],bFactor:k,altLoc:G,occupancy:B})}y+=1}if(v){var X=z.bondAtomList;for(s=0,c=z.bondOrderList.length;c>s;++s)v({atomIndex1:y-D+X[2*s],atomIndex2:y-D+X[2*s+1],bondOrder:z.bondOrderList[s]})}g+=1}m+=1}if(E=_+1,_=y-1,v&&A)for(s=0,c=A.length;c>s;s+=2){var q=A[s],W=A[s+1];(q>=E&&_>=q||W>=E&&_>=W)&&v({atomIndex1:q,atomIndex2:W,bondOrder:I?I[s/2]:null})}h+=1}},e.fetch=function(e,t,i){z(e,V,t,i)},e.fetchReduced=function(e,t,i){z(e,U,t,i)},e.version="v1.0.1",e.fetchUrl=V,e.fetchReducedUrl=U,e.encodeMsgpack=o,e.encodeMmtf=I,e.decodeMsgpack=O,e.decodeMmtf=P,e}MMTF=initIcn3dpyMMTF(MMTF),function(e,t,i){var o,n="__instance__",r="firstChild",a=setTimeout;function s(e){return void 0!==e}function c(e){return"object"==typeof e}function d(e){return Object.keys(e).length}function l(e,t,i){return ei?i:e}function u(e,t){return parseInt(e,t||10)}function p(e){return Math.round(e)}function f(e){var t,i,o,n,r,a,s,c,d=+e[0],l=+e[1],u=+e[2];switch(a=u*(1-l),s=u*(1-(r=6*d-(n=Math.floor(6*d)))*l),c=u*(1-(1-r)*l),n=n||0,s=s||0,c=c||0,n%6){case 0:t=u,i=c,o=a;break;case 1:t=s,i=u,o=a;break;case 2:t=a,i=u,o=c;break;case 3:t=a,i=s,o=u;break;case 4:t=c,i=a,o=u;break;case 5:t=u,i=a,o=s}return[p(255*t),p(255*i),p(255*o)]}function v(e){return m(f(e))}function h(e){var t,i=+e[0],o=+e[1],n=+e[2],r=Math.max(i,o,n),a=Math.min(i,o,n),s=r-a,c=0===r?0:s/r,d=r/255;switch(r){case a:t=0;break;case i:t=o-n+s*(o
    ';var H,z=_[r].children,D=N([0,1,1]),j=z[0],F=z[1],V=j[r],U=F[r],k=0,G=0,B=0,X=0,q=0,W=0,Y=0,Z=0,Q=v(D);function K(e,t){e&&"h"!==e||M("change:h",t),e&&"sv"!==e||M("change:sv",t),M("change",t)}function $(){return _.parentNode}function J(n,r){n||((u||r||p).appendChild(_),m.visible=!0),Y=O(_).w,Z=O(_).h;var a=O(F),s=O(U),c=O(j).h,d=a.w,h=a.h,g=O(V).h,y=s.w,E=s.h;if(n){function L(e){var t=e.target,o=t===i||A(t,i)===i;o?J():m.exit(),M(o?"enter":"exit",[m])}_.style.left=_.style.top="-9999px",!1!==o&&C(o,i,L),m.create=function(){return J(1),M("create",[m]),m},m.destroy=function(){return!1!==o&&R(o,i,L),m.exit(),P(!1),M("destroy",[m]),m}}else ee();function z(e){f(D);var t=f([D[0],1,1]);F.style.backgroundColor="rgb("+t.join(",")+")",P(D),I(e)}function q(e){var t,i,o,n,r,a;B&&(i=l(S(j,t=e).y,0,c),D[0]=(c-i)/c,V.style.top=i-g/2+"px",z(t),Q=v(D),k||(M("drag:h",[Q,m]),M("drag",[Q,m]),K("h",[Q,m]))),X&&(n=S(F,o=e),r=l(n.x,0,d),a=l(n.y,0,h),D[1]=1-(d-r)/d,D[2]=(h-a)/h,U.style.right=d-r-y/2+"px",U.style.top=a-E/2+"px",z(o),Q=v(D),G||(M("drag:sv",[Q,m]),M("drag",[Q,m]),K("sv",[Q,m]))),k=0,G=0}function W(e){var t=e.target,n=B?"h":"sv",r=[v(D),m],a=t===i||A(t,i)===i,s=t===_||A(t,_)===_;a||s?s&&(M("stop:"+n,r),M("stop",r),K(n,r)):$()&&!1!==o&&(m.exit(),M("exit",[m]),K(0,r)),B=0,X=0}function te(e){k=1,B=1,q(e),I(e),M("start:h",[Q,m]),M("start",[Q,m]),K("h",[Q,m])}function ie(e){G=1,X=1,q(e),I(e),M("start:sv",[Q,m]),M("start",[Q,m]),K("sv",[Q,m])}H=function(){D=N(D),z(),V.style.top=c-g/2-c*+D[0]+"px",U.style.right=d-y/2-d*+D[1]+"px",U.style.top=h-E/2-h*+D[2]+"px"},m.exit=function(i){return $()&&($().removeChild(_),m.visible=!1),R(b,j,te),R(b,F,ie),R(w,t,q),R(T,t,W),R(x,e,ee),m},H(),n||(C(b,j,te),C(b,F,ie),C(w,t,q),C(T,t,W),C(x,e,ee))}function ee(){return m.fit()}return J(1),a(function(){var e=[v(D),m];M("create",e),K(0,e)},0),m.fit=function(t){var o=O(e),n=O(h),r=o.w-n.w,a=o.h-h.clientHeight,d=L(e),u=L(i);if(q=u.l+d.l,W=u.t+d.t+O(i).h,c(t))s(t[0])&&(q=t[0]),s(t[1])&&(W=t[1]);else{var p=d.l,f=d.t,v=d.l+o.w-Y-r,g=d.t+o.h-Z-a;q=l(q,p,v)>>0,W=l(W,f,g)>>0}return _.style.left=q+"px",_.style.top=W+"px",M("fit",[m]),m},m.set=function(e){return s(e)?("string"==typeof e&&(e=g.parse(e)),P(e),H(),m):N()},m.get=function(e){return N(e)},m.target=i,m.picker=_,m.visible=!1,m.on=function(e,t,i){return s(e)?s(t)?(s(E[e])||(E[e]={}),s(i)||(i=d(E[e])),E[e][i]=t,m):E[e]:E},m.off=function(e,t){return s(e)?s(t)?(delete E[e][t],m):(E[e]={},m):(E={},m)},m.fire=M,m.hooks=E,m.enter=function(e){return J(0,e)},m}).version="1.3.9",o[n]={},o.each=function(e,t){return a(function(){var t,i=o[n];for(t in i)e(i[t],t,i)},0===t?0:t||1),o},o.parse=b,o._HSV2RGB=f,o._HSV2HEX=v,o._RGB2HSV=h,o._HEX2HSV=g,o._HEX2RGB=function(e){return[+(t=y(e))[0]/255,+t[1]/255,+t[2]/255];var t},o.HSV2RGB=function(e){return f(E(e))},o.HSV2HEX=function(e){return v(E(e))},o.RGB2HSV=function(e){return _(h(e))},o.RGB2HEX=m,o.HEX2HSV=function(e){return _(g(e))},o.HEX2RGB=y}(window,document);var saveAs=function(e){"use strict";if(!(void 0===e||"undefined"!=typeof navigator&&/MSIE [1-9]\./.test(navigator.userAgent))){var t=function(){return e.URL||e.webkitURL||e},i=e.document.createElementNS("http://www.w3.org/1999/xhtml","a"),o="download"in i,n=/constructor/i.test(e.HTMLElement)||e.safari,r=/CriOS\/[\d]+/.test(navigator.userAgent),a=e.setImmediate||e.setTimeout,s=function(e){a(function(){throw e},0)},c=function(e){setTimeout(function(){"string"==typeof e?t().revokeObjectURL(e):e.remove()},4e4)},d=function(e){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob([String.fromCharCode(65279),e],{type:e.type}):e},l=function(l,u,p){p||(l=d(l));var f,v=this,h="application/octet-stream"===(l?l.type:void 0),m=function(){!function(e,t,i){for(var o=(t=[].concat(t)).length;o--;){var n=e["on"+t[o]];if("function"==typeof n)try{n.call(e,i||e)}catch(e){s(e)}}}(v,"writestart progress write writeend".split(" "))};if(v.readyState=v.INIT,o)return f||(f=t().createObjectURL(l)),void a(function(){var e,t;i.href=f,i.download=u,e=i,t=new MouseEvent("click"),e.dispatchEvent(t),m(),c(f),v.readyState=v.DONE},0);!function(){if((r||h&&n)&&e.FileReader){var i=new FileReader;return i.onloadend=function(){var t=r?i.result:i.result.replace(/^data:[^;]*;/,"data:attachment/file;");e.open(t,"_blank")||(e.location.href=t),t=void 0,v.readyState=v.DONE,m()},i.readAsDataURL(l),void(v.readyState=v.INIT)}f||(f=t().createObjectURL(l)),h?e.location.href=f:e.open(f,"_blank")||(e.location.href=f);v.readyState=v.DONE,m(),c(f)}()},u=l.prototype;return"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(e,t,i){return t=t||e.name||"download",i||(e=d(e)),navigator.msSaveOrOpenBlob(e,t)}:(u.abort=function(){},u.readyState=u.INIT=0,u.WRITING=1,u.DONE=2,u.error=u.onwritestart=u.onprogress=u.onwrite=u.onabort=u.onerror=u.onwriteend=null,function(e,t,i){return new l(e,t||e.name||"download",i)})}}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this);!function(e){"use strict";var t=e.HTMLCanvasElement&&e.HTMLCanvasElement.prototype,i=e.Blob&&function(){try{return Boolean(new Blob)}catch(e){return!1}}(),o=i&&e.Uint8Array&&function(){try{return 100===new Blob([new Uint8Array(100)]).size}catch(e){return!1}}(),n=e.BlobBuilder||e.WebKitBlobBuilder||e.MozBlobBuilder||e.MSBlobBuilder,r=/^data:((.*?)(;charset=.*?)?)(;base64)?,/,a=(i||n)&&e.atob&&e.ArrayBuffer&&e.Uint8Array&&function(e){var t,a,s,c,d,l,u,p,f;if(!(t=e.match(r)))throw new Error("invalid data URI");for(a=t[2]?t[1]:"text/plain"+(t[3]||";charset=US-ASCII"),s=!!t[4],c=e.slice(t[0].length),d=s?atob(c):decodeURIComponent(c),l=new ArrayBuffer(d.length),u=new Uint8Array(l),p=0;p0||window.navigator.userAgent.match(/Trident.*rv\:11\./))}isMobile(){return this.icn3dui,/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)}isMac(){return this.icn3dui,/Mac/i.test(window.navigator.userAgent)}isAndroid(){return this.icn3dui,/android/i.test(window.navigator.userAgent.toLowerCase())}isChrome(){return this.icn3dui,navigator.userAgent.includes("Chrome")&&navigator.vendor.includes("Google Inc")}isSessionStorageSupported(){return this.icn3dui,window.sessionStorage}isLocalStorageSupported(){return this.icn3dui,window.localStorage}hexToRgb(e,t){this.icn3dui;let s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return s?{r:parseInt(s[1],16),g:parseInt(s[2],16),b:parseInt(s[3],16),a:t}:null}isCalphaPhosOnly(e){this.icn3dui;let t=!1,s=0,i=0;for(let t in e){if(!(s<100))break;{let s=e[t].name.trim();"CA"!==s&&"P"!==s&&"O3'"!==s&&"O3*"!==s&&++i}++s}return i<.5*s&&(t=!0),t}hasCovalentBond(e,t){let s=this.icn3dui,i=s.parasCls.covalentRadii[e.elem.toUpperCase()]+s.parasCls.covalentRadii[t.elem.toUpperCase()],n=e.coord.x-t.coord.x,l=e.coord.y-t.coord.y,r=e.coord.z-t.coord.z;return n*n+l*l+r*r<("N"==e.elem&&"H"==t.elem.substr(0,1)||"N"==t.elem&&"H"==e.elem.substr(0,1)?2.2:1.3)*i*i}residueName2Abbr(e){this.icn3dui;let t=e.indexOf(" ");switch(t>0&&(e=e.substr(0,t)),e){case" A":case" DA":case"DA":case"ALA":return"A";case" C":case" DC":case"DC":case"CYS":return"C";case" G":case" DG":case"DG":case"GLY":return"G";case" T":case" DT":case"DT":case"THR":return"T";case" U":case" DU":case"DU":case"SEC":return"U";case" I":case" DI":case"DI":case"ILE":return"I";case"ARG":return"R";case"ASN":return"N";case"ASP":return"D";case"GLU":return"E";case"GLN":return"Q";case"HIS":return"H";case"LEU":return"L";case"LYS":return"K";case"MET":return"M";case"PHE":return"F";case"PRO":return"P";case"SER":return"S";case"TRP":return"W";case"TYR":return"Y";case"VAL":return"V";case"HOH":case"WAT":return"O";default:return e.trim()}}residueAbbr2Name(e){if(this.icn3dui,(e=e.toUpperCase()).length>1)return e;switch(e){case"A":return"ALA";case"R":return"ARG";case"N":return"ASN";case"D":return"ASP";case"C":return"CYS";case"E":return"GLU";case"Q":return"GLN";case"G":return"GLY";case"H":return"HIS";case"I":return"ILE";case"L":return"LEU";case"K":return"LYS";case"M":return"MET";case"F":return"PHE";case"P":return"PRO";case"S":return"SER";case"T":return"THR";case"W":return"TRP";case"Y":return"TYR";case"V":return"VAL";case"O":return"HOH";default:return e.trim()}}getJSONFromArray(e){this.icn3dui;let t="";for(let s=0,i=e.length;sd?1:ah?1:cs&&(e.htmlCls.WIDTH=s),i&&e.htmlCls.HEIGHT>i&&(e.htmlCls.HEIGHT=i)}sumArray(e){let t=0;for(let s=0,i=e.length;sRed and blue membranes indicate extracellular and intracellular membranes, respectively.

    "}getStructures(e){let t=this.icn3dui,s={};for(let i in e){s[t.icn3d.atoms[i].structure]=1}return s}getHlStructures(e){let t=this.icn3dui;return e||(e=t.icn3d.hAtoms),this.getStructures(e)}getDisplayedStructures(e){let t=this.icn3dui;return e||(e=t.icn3d.dAtoms),this.getStructures(e)}getDateDigitStr(){this.icn3dui;let e=new Date,t=(e.getMonth()+1).toString();e.getMonth()+1<10&&(t="0"+t);let s=e.getDate().toString();return e.getDate()<10&&(s="0"+s),e.getFullYear().toString()+t+s}}class i{constructor(e){this.icn3dui=e,this.glycanHash={GLC:{c:"1E90FF",s:"sphere"},BGC:{c:"1E90FF",s:"sphere"},NAG:{c:"1E90FF",s:"cube"},NDG:{c:"1E90FF",s:"cube"},GCS:{c:"1E90FF",s:"cube"},PA1:{c:"1E90FF",s:"cube"},GCU:{c:"1E90FF",s:"cone"},BDP:{c:"1E90FF",s:"cone"},G6D:{c:"1E90FF",s:"cone"},DDA:{c:"1E90FF",s:"cylinder"},B6D:{c:"1E90FF",s:"cylinder"},XXM:{c:"1E90FF",s:"cylinder"},MAN:{c:"00FF00",s:"sphere"},BMA:{c:"00FF00",s:"sphere"},BM3:{c:"00FF00",s:"cube"},"95Z":{c:"00FF00",s:"cube"},MAV:{c:"00FF00",s:"cone"},BEM:{c:"00FF00",s:"cone"},RAM:{c:"00FF00",s:"cone"},RM4:{c:"00FF00",s:"cone"},TYV:{c:"00FF00",s:"cylinder"},ARA:{c:"00FF00",s:"cylinder"},ARB:{c:"00FF00",s:"cylinder"},KDN:{c:"00FF00",s:"cylinder"},KDM:{c:"00FF00",s:"cylinder"},"6PZ":{c:"00FF00",s:"cylinder"},GMH:{c:"00FF00",s:"cylinder"},BDF:{c:"00FF00",s:"cylinder"},GAL:{c:"FFFF00",s:"sphere"},GLA:{c:"FFFF00",s:"sphere"},NGA:{c:"FFFF00",s:"cube"},A2G:{c:"FFFF00",s:"cube"},X6X:{c:"FFFF00",s:"cube"},"1GN":{c:"FFFF00",s:"cube"},ADA:{c:"FFFF00",s:"cone"},GTR:{c:"FFFF00",s:"cone"},LDY:{c:"FFFF00",s:"cylinder"},KDO:{c:"FFFF00",s:"cylinder"},T6T:{c:"FFFF00",s:"cylinder"},GUP:{c:"A52A2A",s:"sphere"},GL0:{c:"A52A2A",s:"sphere"},LGU:{c:"A52A2A",s:"cone"},ABE:{c:"A52A2A",s:"cylinder"},XYS:{c:"A52A2A",s:"cylinder"},XYP:{c:"A52A2A",s:"cylinder"},SOE:{c:"A52A2A",s:"cylinder"},PZU:{c:"FF69B4",s:"cylinder"},RIP:{c:"FF69B4",s:"cylinder"},"0MK":{c:"FF69B4",s:"cylinder"},ALL:{c:"8A2BE2",s:"sphere"},AFD:{c:"8A2BE2",s:"sphere"},NAA:{c:"8A2BE2",s:"cube"},SIA:{c:"8A2BE2",s:"cylinder"},SIB:{c:"8A2BE2",s:"cylinder"},AMU:{c:"8A2BE2",s:"cylinder"},X0X:{c:"1E90FF",s:"cone"},X1X:{c:"1E90FF",s:"cone"},NGC:{c:"1E90FF",s:"cylinder"},NGE:{c:"1E90FF",s:"cylinder"},"4N2":{c:"A0522D",s:"sphere"},HSQ:{c:"A0522D",s:"cube"},IDR:{c:"A0522D",s:"cone"},MUR:{c:"A0522D",s:"cylinder"},FUC:{c:"FF0000",s:"cone"},FUL:{c:"FF0000",s:"cone"}},this.nucleotidesArray=[" G"," A"," T"," C"," U"," DG"," DA"," DT"," DC"," DU","G","A","T","C","U","DG","DA","DT","DC","DU"],this.ionsArray=[" K"," NA"," MG"," AL"," CA"," TI"," MN"," FE"," NI"," CU"," ZN"," AG"," BA"," F"," CL"," BR"," I","K","NA","MG","AL","CA","TI","MN","FE","NI","CU","ZN","AG","BA","F","CL","BR","I"],this.cationsTrimArray=["K","NA","MG","AL","CA","TI","MN","FE","NI","CU","ZN","AG","BA"],this.anionsTrimArray=["F","CL","BR","I"],this.ionCharges={K:1,NA:1,MG:2,AL:3,CA:2,TI:3,MN:2,FE:3,NI:2,CU:2,ZN:2,AG:1,BA:2},this.vdwRadii={H:1.08,HE:1.34,LI:1.75,BE:2.05,B:1.47,C:1.49,N:1.41,O:1.4,F:1.39,NE:1.68,NA:1.84,MG:2.05,AL:2.11,SI:2.07,P:1.92,S:1.82,CL:1.83,AR:1.93,K:2.05,CA:2.21,SC:2.16,TI:1.87,V:1.79,CR:1.89,MN:1.97,FE:1.94,CO:1.92,NI:1.84,CU:1.86,ZN:2.1,GA:2.08,GE:2.15,AS:2.06,SE:1.93,BR:1.98,KR:2.12,RB:2.16,SR:2.24,Y:2.19,ZR:1.86,NB:2.07,MO:2.09,TC:2.09,RU:2.07,RH:1.95,PD:2.02,AG:2.03,CD:2.3,IN:2.36,SN:2.33,SB:2.25,TE:2.23,I:2.23,XE:2.21,CS:2.22,BA:2.51,LA:2.4,CE:2.35,PR:2.39,ND:2.29,PM:2.36,SM:2.29,EU:2.33,GD:2.37,TB:2.21,DY:2.29,HO:2.16,ER:2.35,TM:2.27,YB:2.42,LU:2.21,HF:2.12,TA:2.17,W:2.1,RE:2.17,OS:2.16,IR:2.02,PT:2.09,AU:2.17,HG:2.09,TL:2.35,PB:2.32,BI:2.43,PO:2.29,AT:2.36,RN:2.43,FR:2.56,RA:2.43,AC:2.6,TH:2.37,PA:2.43,U:2.4,NP:2.21,PU:2.56,AM:2.56,CM:2.56,BK:2.56,CF:2.56,ES:2.56,FM:2.56},this.covalentRadii={H:.31,HE:.28,LI:1.28,BE:.96,B:.84,C:.76,N:.71,O:.66,F:.57,NE:.58,NA:1.66,MG:1.41,AL:1.21,SI:1.11,P:1.07,S:1.05,CL:1.02,AR:1.06,K:2.03,CA:1.76,SC:1.7,TI:1.6,V:1.53,CR:1.39,MN:1.39,FE:1.32,CO:1.26,NI:1.24,CU:1.32,ZN:1.22,GA:1.22,GE:1.2,AS:1.19,SE:1.2,BR:1.2,KR:1.16,RB:2.2,SR:1.95,Y:1.9,ZR:1.75,NB:1.64,MO:1.54,TC:1.47,RU:1.46,RH:1.42,PD:1.39,AG:1.45,CD:1.44,IN:1.42,SN:1.39,SB:1.39,TE:1.38,I:1.39,XE:1.4,CS:2.44,BA:2.15,LA:2.07,CE:2.04,PR:2.03,ND:2.01,PM:1.99,SM:1.98,EU:1.98,GD:1.96,TB:1.94,DY:1.92,HO:1.92,ER:1.89,TM:1.9,YB:1.87,LU:1.87,HF:1.75,TA:1.7,W:1.62,RE:1.51,OS:1.44,IR:1.41,PT:1.36,AU:1.36,HG:1.32,TL:1.45,PB:1.46,BI:1.48,PO:1.4,AT:1.5,RN:1.5,FR:2.6,RA:2.21,AC:2.15,TH:2.06,PA:2,U:1.96,NP:1.9,PU:1.87,AM:1.8,CM:1.69},this.atomColors={H:this.thr(16777215),He:this.thr(16761035),HE:this.thr(16761035),Li:this.thr(11674146),LI:this.thr(11674146),B:this.thr(65280),C:this.thr(11184810),N:this.thr(255),O:this.thr(15728640),F:this.thr(14329120),Na:this.thr(255),NA:this.thr(255),Mg:this.thr(2263842),MG:this.thr(2263842),Al:this.thr(8421520),AL:this.thr(8421520),Si:this.thr(14329120),SI:this.thr(14329120),P:this.thr(16753920),S:this.thr(16762930),Cl:this.thr(65280),CL:this.thr(65280),Ca:this.thr(8421520),CA:this.thr(8421520),Ti:this.thr(8421520),TI:this.thr(8421520),Cr:this.thr(8421520),CR:this.thr(8421520),Mn:this.thr(8421520),MN:this.thr(8421520),Fe:this.thr(16753920),FE:this.thr(16753920),Ni:this.thr(10824234),NI:this.thr(10824234),Cu:this.thr(10824234),CU:this.thr(10824234),Zn:this.thr(10824234),ZN:this.thr(10824234),Br:this.thr(10824234),BR:this.thr(10824234),Ag:this.thr(8421520),AG:this.thr(8421520),I:this.thr(10494192),Ba:this.thr(16753920),BA:this.thr(16753920),Au:this.thr(14329120),AU:this.thr(14329120)},this.atomnames={H:"Hydrogen",HE:"Helium",LI:"Lithium",B:"Boron",C:"Carbon",N:"Nitrogen",O:"Oxygen",F:"Fluorine",NA:"Sodium",MG:"Magnesium",AL:"Aluminum",SI:"Silicon",P:"Phosphorus",S:"Sulfur",CL:"Chlorine",CA:"Calcium",TI:"Titanium",CR:"Chromium",MN:"Manganese",FE:"Iron",NI:"Nickel",CU:"Copper",ZN:"Zinc",BR:"Bromine",AG:"Silver",I:"Iodine",BA:"Barium",AU:"Gold"},this.defaultAtomColor=this.thr(13421772),this.stdChainColors=[this.thr(16711935),this.thr(255),this.thr(10053171),this.thr(65433),this.thr(16750848),this.thr(16737894),this.thr(3329330),this.thr(2003199),this.thr(16416882),this.thr(16753920),this.thr(52945),this.thr(16738740),this.thr(65280),this.thr(255),this.thr(16711680),this.thr(16776960),this.thr(65535),this.thr(16711935),this.thr(3978097),this.thr(4620980),this.thr(13458524),this.thr(16770229),this.thr(11529966),this.thr(15631086),this.thr(25600),this.thr(139),this.thr(9109504),this.thr(13468991),this.thr(35723),this.thr(9699539)],this.backgroundColors={black:this.thr(0),grey:this.thr(13421772),white:this.thr(16777215),transparent:this.thr(16777215)},this.residueColors={ALA:this.thr(13158600),ARG:this.thr(1334015),ASN:this.thr(56540),ASP:this.thr(15075850),CYS:this.thr(15132160),GLN:this.thr(56540),GLU:this.thr(15075850),GLY:this.thr(15461355),HIS:this.thr(8553170),ILE:this.thr(1016335),LEU:this.thr(1016335),LYS:this.thr(1334015),MET:this.thr(15132160),PHE:this.thr(3289770),PRO:this.thr(14456450),SER:this.thr(16422400),THR:this.thr(16422400),TRP:this.thr(11819700),TYR:this.thr(3289770),VAL:this.thr(1016335),ASX:this.thr(16738740),GLX:this.thr(16738740),G:this.thr(32768),A:this.thr(6324479),T:this.thr(16744448),C:this.thr(16711680),U:this.thr(16744448),DG:this.thr(32768),DA:this.thr(6324479),DT:this.thr(16744448),DC:this.thr(16711680),DU:this.thr(16744448)},this.residueArea={ALA:247,ARG:366,ASN:290,ASP:285,CYS:271,GLN:336,GLU:325,GLY:217,HIS:340,ILE:324,LEU:328,LYS:373,MET:346,PHE:366,PRO:285,SER:265,THR:288,TRP:414,TYR:387,VAL:293,ASX:290,GLX:336,G:520,A:507,T:515,C:467,U:482,DG:520,DA:507,DT:515,DC:467,DU:482},this.defaultResidueColor=this.thr(12492910),this.chargeColors={" G":this.thr(16711680)," A":this.thr(16711680)," T":this.thr(16711680)," C":this.thr(16711680)," U":this.thr(16711680)," DG":this.thr(16711680)," DA":this.thr(16711680)," DT":this.thr(16711680)," DC":this.thr(16711680)," DU":this.thr(16711680),G:this.thr(16711680),A:this.thr(16711680),T:this.thr(16711680),C:this.thr(16711680),U:this.thr(16711680),DG:this.thr(16711680),DA:this.thr(16711680),DT:this.thr(16711680),DC:this.thr(16711680),DU:this.thr(16711680),ARG:this.thr(255),LYS:this.thr(255),ASP:this.thr(16711680),GLU:this.thr(16711680),HIS:this.thr(8421631),GLY:this.thr(8947848),PRO:this.thr(8947848),ALA:this.thr(8947848),VAL:this.thr(8947848),LEU:this.thr(8947848),ILE:this.thr(8947848),PHE:this.thr(8947848),SER:this.thr(8947848),THR:this.thr(8947848),ASN:this.thr(8947848),GLN:this.thr(8947848),TYR:this.thr(8947848),MET:this.thr(8947848),CYS:this.thr(8947848),TRP:this.thr(8947848)},this.hydrophobicColors={" G":this.thr(16711680)," A":this.thr(16711680)," T":this.thr(16711680)," C":this.thr(16711680)," U":this.thr(16711680)," DG":this.thr(16711680)," DA":this.thr(16711680)," DT":this.thr(16711680)," DC":this.thr(16711680)," DU":this.thr(16711680),G:this.thr(16711680),A:this.thr(16711680),T:this.thr(16711680),C:this.thr(16711680),U:this.thr(16711680),DG:this.thr(16711680),DA:this.thr(16711680),DT:this.thr(16711680),DC:this.thr(16711680),DU:this.thr(16711680),ARG:this.thr(255),LYS:this.thr(255),ASP:this.thr(16711680),GLU:this.thr(16711680),HIS:this.thr(8421631),TRP:this.thr().setHSL(1/3,1,.5),PHE:this.thr().setHSL(1/3,1,.5909090909090908),LEU:this.thr().setHSL(1/3,1,.700956937799043),ILE:this.thr().setHSL(1/3,1,.7320574162679425),TYR:this.thr().setHSL(1/3,1,.5+.69/2.09),MET:this.thr().setHSL(1/3,1,.5+.71/2.09),VAL:this.thr().setHSL(1/3,1,.5+.815/2.09),CYS:this.thr().setHSL(1/3,1,.5+1.035/2.09),PRO:this.thr().setHSL(1/6,1,.9391304347826086),THR:this.thr().setHSL(1/6,1,.8913043478260869),SER:this.thr().setHSL(1/6,1,.8),ALA:this.thr().setHSL(1/6,1,.7826086956521738),GLN:this.thr().setHSL(1/6,1,.6652173913043478),ASN:this.thr().setHSL(1/6,1,.6304347826086956),GLY:this.thr().setHSL(1/6,1,.5)},this.normalizedHPColors={" G":this.thr(16777215)," A":this.thr(16777215)," T":this.thr(16777215)," C":this.thr(16777215)," U":this.thr(16777215)," DG":this.thr(16777215)," DA":this.thr(16777215)," DT":this.thr(16777215)," DC":this.thr(16777215)," DU":this.thr(16777215),G:this.thr(16777215),A:this.thr(16777215),T:this.thr(16777215),C:this.thr(16777215),U:this.thr(16777215),DG:this.thr(16777215),DA:this.thr(16777215),DT:this.thr(16777215),DC:this.thr(16777215),DU:this.thr(16777215),ARG:this.thr(16777215),LYS:this.thr(16777215),ASP:this.thr(16777215),GLU:this.thr(16777215),HIS:this.thr(16777215),TRP:this.thr().setHSL(1/3,1,.5),PHE:this.thr().setHSL(1/3,1,.558641975308642),LEU:this.thr().setHSL(1/3,1,.6296296296296295),ILE:this.thr().setHSL(1/3,1,.6496913580246912),TYR:this.thr().setHSL(1/3,1,.5+.69/3.24),MET:this.thr().setHSL(1/3,1,.5+.71/3.24),VAL:this.thr().setHSL(1/3,1,.5+.815/3.24),CYS:this.thr().setHSL(1/3,1,.5+1.035/3.24),PRO:this.thr().setHSL(1/3,1,.5+1.115/3.24),THR:this.thr().setHSL(1/3,1,.5+1.17/3.24),SER:this.thr().setHSL(1/3,1,.5+1.275/3.24),ALA:this.thr().setHSL(1/3,1,.5+1.295/3.24),GLN:this.thr().setHSL(1/3,1,.5+1.43/3.24),ASN:this.thr().setHSL(1/3,1,.5+1.47/3.24),GLY:this.thr().setHSL(1/3,1,1)},this.hydrophobicValues={" G":3," A":3," T":3," C":3," U":3," DG":3," DA":3," DT":3," DC":3," DU":3,G:3,A:3,T:3,C:3,U:3,DG:3,DA:3,DT:3,DC:3,DU:3,ARG:1.5,LYS:1.5,ASP:3,GLU:3,HIS:2,TRP:-2.09,PHE:-1.71,LEU:-1.25,ILE:-1.12,TYR:-.71,MET:-.67,VAL:-.46,CYS:-.02,PRO:.14,THR:.25,SER:.46,ALA:.5,GLN:.77,ASN:.85,GLY:1.15},this.residueAbbrev={ALA:"A (Ala)",ARG:"R (Arg)",ASN:"N (Asn)",ASP:"D (Asp)",CYS:"C (Cys)",GLN:"Q (Gln)",GLU:"E (Glu)",GLY:"G (Gly)",HIS:"H (His)",ILE:"I (Ile)",LEU:"L (Leu)",LYS:"K (Lys)",MET:"M (Met)",PHE:"F (Phe)",PRO:"P (Pro)",SER:"S (Ser)",THR:"T (Thr)",TRP:"W (Trp)",TYR:"Y (Tyr)",VAL:"V (Val)",ASX:"X (Asx)",GLX:"X (Glx)",G:"Guanine",A:"Adenine",T:"Thymine",C:"Cytosine",U:"Uracil",DG:"deoxy-Guanine",DA:"deoxy-Adenine",DT:"deoxy-Thymine",DC:"deoxy-Cytosine",DU:"deoxy-Uracil"},this.ssColors={helix:this.thr(16711680),sheet:this.thr(32768),coil:this.thr(6324479)},this.ssColors2={helix:this.thr(16711680),sheet:this.thr(16762880),coil:this.thr(6324479)},this.resn2restype={ALA:1,ARG:4,ASN:7,ASP:10,CYS:13,GLN:16,GLU:19,GLY:22,HIS:25,ILE:28,LEU:31,LYS:34,MET:37,PHE:40,PRO:43,SER:46,THR:49,TRP:52,TYR:55,VAL:58},this.nuclMainArray=["C1'","C1*","C2'","C2*","C3'","C3*","C4'","C4*","C5'","C5*","O3'","O3*","O4'","O4*","O5'","O5*","P","OP1","O1P","OP2","O2P"],this.b62ResArray=["A","R","N","D","C","Q","E","G","H","I","L","K","M","F","P","S","T","W","Y","V","B","Z","X","*"],this.b62Matrix=[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1,-4],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1,-4],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2,-4],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1,-4],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1,-4],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1,-4],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2,-4],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0,-4],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0,-4],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]]}thr(e){return this.icn3dui,"#0"==e&&(e="#000"),new THREE.Color(e)}}class n{constructor(e){this.icn3dui=e}onId(e,t,s){if(this.icn3dui,!(Object.keys(window).length<2)&&("#"==e.substr(0,1)&&(e=e.substr(1)),document.getElementById(e))){t.split(" ").forEach((t=>{document.getElementById(e).addEventListener(t,s)}))}}onIds(e,t,s){let i=this.icn3dui;Array.isArray(e)?e.forEach((e=>{i.myEventCls.onId(e,t,s)})):i.myEventCls.onId(e,t,s)}}class l{constructor(e){this.icn3dui=e}getRmsdSuprCls(e,t,s){let i,n,l,r,o,a,d,c,h,p,m,u,g,f=this.icn3dui,b=new Array(9),C=new THREE.Vector3,y=new THREE.Vector3,v=[],_=[],w=new Array(3),S=new Array(3),A=new Array(3),x=new Array(3),k=new Array(3),O=new Array(3);if(i=0,s<=1)return{rot:void 0,trans1:void 0,trans2:void 0,rmsd:999};let R=s;for(n=0;n0?(b[0]=x[0]*w[0]+k[0]*S[0]+O[0]*A[0],b[1]=x[0]*w[1]+k[0]*S[1]+O[0]*A[1],b[2]=x[0]*w[2]+k[0]*S[2]+O[0]*A[2],b[3]=x[1]*w[0]+k[1]*S[0]+O[1]*A[0],b[4]=x[1]*w[1]+k[1]*S[1]+O[1]*A[1],b[5]=x[1]*w[2]+k[1]*S[2]+O[1]*A[2],b[6]=x[2]*w[0]+k[2]*S[0]+O[2]*A[0],b[7]=x[2]*w[1]+k[2]*S[1]+O[2]*A[1],b[8]=x[2]*w[2]+k[2]*S[2]+O[2]*A[2]):(b[0]=x[0]*w[0]+k[0]*S[0]-O[0]*A[0],b[1]=x[0]*w[1]+k[0]*S[1]-O[0]*A[1],b[2]=x[0]*w[2]+k[0]*S[2]-O[0]*A[2],b[3]=x[1]*w[0]+k[1]*S[0]-O[1]*A[0],b[4]=x[1]*w[1]+k[1]*S[1]-O[1]*A[1],b[5]=x[1]*w[2]+k[1]*S[2]-O[1]*A[2],b[6]=x[2]*w[0]+k[2]*S[0]-O[2]*A[0],b[7]=x[2]*w[1]+k[2]*S[1]-O[2]*A[1],b[8]=x[2]*w[2]+k[2]*S[2]-O[2]*A[2]),c=Math.sqrt(c),h=Math.sqrt(h),p=Math.sqrt(p),g=c+h+u*p,m=a+d-2*g,i=m>0?Math.sqrt(m):void 0,{rot:b,trans1:I,trans2:T,rmsd:i})}eigen_values(e){let t,s,i,n,l,r,o,a,d,c,h,p,m,u,g,f,b,C,y,v;if(this.icn3dui,t=e[0],s=e[1],i=e[2],n=e[3],l=e[4],r=e[5],o=e[6],a=e[7],d=e[8],c=-(t+l+d),h=t*l+(t+l)*d-r*a-s*n-i*o,p=-t*l*d+t*r*a+s*n*d-s*r*o-i*n*a+i*l*o,m=-c*c/3+h,u=c*c*c/13.5-c*h/3+p,g=.25*u*u+m*m*m/27,g<0){let e,t;e=Math.sqrt(.25*u*u-g),t=Math.acos(-.5*u/e),C=2*Math.cbrt(e)*Math.cos(t/3)}else f=Math.cbrt(-.5*u+Math.sqrt(g)),b=Math.cbrt(-.5*u-Math.sqrt(g)),C=f+b;return C-=c/3,c+=C,p/=-C,y=.5*(-c+Math.sqrt(c*c-4*p)),v=.5*(-c-Math.sqrt(c*c-4*p)),yw&&(w=Math.abs(d)),Math.abs(c)>w&&(w=Math.abs(c)),Math.abs(h)>w&&(w=Math.abs(h)),Math.abs(p)>w&&(w=Math.abs(p)),Math.abs(m)>w&&(w=Math.abs(m)),Math.abs(u)>w&&(w=Math.abs(u)),Math.abs(g)>w&&(w=Math.abs(g)),Math.abs(f)>w&&(w=Math.abs(f)),w<1e-10)return r=3,{k:r,v1:t,v2:s,v3:i};if(o=0,a/=w,d/=w,c/=w,h/=w,p/=w,m/=w,u/=w,g/=w,f/=w,Math.abs(a)w&&(_=a,a=h,h=_,_=d,d=p,p=_,_=c,c=m,m=_,w=Math.abs(d)),Math.abs(g)>w&&(_=a,a=u,u=_,_=d,d=g,g=_,_=c,c=f,f=_),y=m-p*c/d,v=f-g*c/d,Math.abs(y)w&&(_=a,a=h,h=_,_=d,d=p,p=_,_=c,c=m,m=_,w=Math.abs(a)),Math.abs(c)>w&&(_=a,a=u,u=_,_=d,d=g,g=_,_=c,c=f,f=_),b=p-h*d/a,C=m-h*c/a,y=g-u*d/a,v=f-u*c/a,Math.abs(b)0&&(1==o?(a=s[0],d=s[1],c=s[2],_=Math.sqrt(a*a+d*d+c*c),s[0]=a/_,s[1]=d/_,s[2]=c/_):2==o?(a=t[0],d=t[1],c=t[2],h=s[0],p=s[1],m=s[2],_=a*h+d*p+c*m,Math.abs(_)>=n&&(s[0]=a+_*h,s[1]=d+_*p,s[2]=c+_*m,h=s[0],p=s[1],m=s[2]),_=Math.sqrt(a*a+d*d+c*c),t[0]=a/_,t[1]=d/_,t[2]=c/_,_=Math.sqrt(h*h+p*p+m*m),s[0]=h/_,s[1]=p/_,s[2]=m/_):(a=t[0],d=t[1],c=t[2],_=Math.sqrt(a*a+d*d+c*c),t[0]=a/_,t[1]=d/_,t[2]=c/_)),{k:r,v1:t,v2:s,v3:i}}getEigenForSelection(e,t){let s,i=this.icn3dui,n=new THREE.Vector3,l=[];for(s=0;s0&&Math.abs(l[0].x-e[0].x)<=6&&Math.abs(l[0].y-e[0].y)<=6&&Math.abs(l[0].z-e[0].z)<=6?(p.push(l[0]),m=1):m=0,p.push(e[0]);for(let t=1,s=e.length-1;t0&&Math.abs(r[0].x-e[e.length-1].x)<=6&&Math.abs(r[0].y-e[e.length-1].y)<=6&&Math.abs(r[0].z-e[e.length-1].z)<=6&&(p.push(r[0]),++g),u>1&&Math.abs(r[0].x-r[1].x)<=6&&Math.abs(r[0].y-r[1].y)<=6&&Math.abs(r[0].z-r[1].z)<=6&&(p.push(r[1]),++g);let f=[],b=[],C=[];o&&(g=u>0?u-1:0);let y;for(let e=-1,n=p.length,l=1/s;e<=n-3;++e){y=e-m;let r=p[-1===e?0:e],o=p[e+1],u=p[e+2],v=p[e===n-3?n-1:e+3],_=0,w=a.subdivideCls.getKnot(1,_,r,o),S=a.subdivideCls.getKnot(1,w,o,u),A=a.subdivideCls.getKnot(1,S,u,v);w-_<1e-4&&(w=_+1),S-w<1e-4&&(S=w+1),A-S<1e-4&&(A=S+1),e>-1&&(void 0===i||i[y+1])&&e>=-1+m&&e<=n-3-g+1&&(d=d.concat(f),c=c.concat(b),h=h.concat(C)),f=[],b=[],C=[];let x=(S-w)*l;for(let l=0;l=-1+m&&e<=n-3-g&&i[y+1]&&l<=parseInt(s/2)&&(d.push(new THREE.Vector3(k,O,R)),c.push(i[y+1]),h.push(t[y+1])),e>=-1+m&&e<=n-3-g+1&&i[y+2]&&l>parseInt(s/2)&&(f.push(new THREE.Vector3(k,O,R)),b.push(i[y+2]),C.push(t[y+2]))):e>=-1+m&&e<=n-3-g&&(d.push(new THREE.Vector3(k,O,R)),c.push(y+1),h.push(t[y+1]))}}i&&!i[y+1]||(d=d.concat(f),c=c.concat(b),h=h.concat(C),d.push(p[p.length-1-g]),c.push(p.length-1-g),h.push(t[p.length-1-g])),f=[],b=[],C=[],p=[];let v=[];return v.push(d),v.push(c),v.push(h),v}getKnot(e,t,s,i){return this.icn3dui,s.distanceTo(i)+t}getValueFromKnot(e,t,s,i,n,l,r,o,a){this.icn3dui;let d,c,h=(r-l)/(s-t),p=(o-r)/(i-s),m=(a-o)/(n-i),u=(s+i)*(s+i)-4*(t*s+i*n-t*n);return 0==u?(d=9999,c=9999):(d=6*(3*p*s+2*h*n+m*s-2*h*s-2*p*n-p*i-m*s)/u,c=6*(3*p*i+2*m*t+h*s-2*p*t-2*m*i-h*i-p*s)/u),p*(e-s)+r+((2*d+c)/6/(s-i)*(e-s)*(e-i)*(e-i)+(2*c+d)/6/(i-s)*(e-s)*(e-s)*(e-i))}}class o{constructor(e){this.icn3dui=e}passFloat32(e,t){let s=this.icn3dui,i=e.length;t||(t=new Uint8Array(4*i));let n=s.convertTypeCls.getDataView(t);for(let t=0;t  Very high (pLDDT > 90)
      Confident (90 > pLDDT > 70)
      Low (70 > pLDDT > 50)
      Very low (pLDDT < 50)
    '}setLegendHtml(e){let t=this.icn3dui.icn3d,s="
    ";if(e)s+=this.setAlphaFoldLegend();else{s+="
    "+t.startValue+""+t.midValue+""+t.endValue+"
    "}return s}SetChainsAdvancedMenu(){let e=this.icn3dui,t=e.icn3d;if(void 0===t.bSetChainsAdvancedMenu||!t.bSetChainsAdvancedMenu){let s=e.hashUtilsCls.cloneHash(t.hAtoms);t.definedSetsCls.setPredefinedInMenu(),t.bSetChainsAdvancedMenu=!0,t.hAtoms=e.hashUtilsCls.cloneHash(s)}}setSetsMenus(e,t){let s=this.icn3dui,i=s.icn3d;this.SetChainsAdvancedMenu();let n=e,l=e+"2",r=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+s.pre+n).length&&$("#"+s.pre+n).html(" "+r),!t&&$("#"+s.pre+l).length&&$("#"+s.pre+l).html(" "+r),$("#"+s.pre+n).resizable(),t||$("#"+s.pre+l).resizable()}applyShownMenus(e){let t=this.icn3dui;t.icn3d;let s=[];for(let e in t.htmlCls.allMenus)t.htmlCls.shownMenus.hasOwnProperty(e)?$("#"+t.pre+e).parent().show():($("#"+t.pre+e).parent().hide(),s.push(e));Object.keys(t.htmlCls.shownMenus).length==Object.keys(t.htmlCls.allMenus).length?$(".icn3d-menusep").show():$(".icn3d-menusep").hide(),localStorage&&!e&&localStorage.setItem("hiddenmenus",JSON.stringify(s))}getHiddenMenusFromCache(){let e=this.icn3dui;e.icn3d,e.htmlCls.shownMenus={};let t=localStorage?localStorage.getItem("hiddenmenus"):"";if(t&&"[]"!=t){let s=JSON.parse(t);for(let t in e.htmlCls.allMenus)-1==s.indexOf(t)&&(e.htmlCls.shownMenus[t]=1)}else e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus)}displayShownMenus(){let e=this.icn3dui;e.icn3d;let t="
    ";t+="",t+="";for(let s in e.htmlCls.allMenusSel){if("uniclr"==s.substr(0,6)||"mn5_opacity"==s.substr(0,11)||"mn6_labelscale"==s.substr(0,14)||"faq_"==s.substr(0,4)||"dev_"==s.substr(0,4))continue;"mn1_searchgrooup"==s?t+="
    FileSelectViewStyleColorAnalysisHelp
    ":("mn2_definedsets"==s||"mn2_show_selected"==s||"mn3_proteinwrap"==s||e.cfg.cid&&"mn3_ligwrap"==s||"mn4_clrwrap"==s||"mn6_selectannotations"==s||"abouticn3d"==s)&&(t+="");let i=e.htmlCls.shownMenus.hasOwnProperty(s)?"checked":"",n=e.htmlCls.allMenusSel[s];t+=""+e.htmlCls.allMenus[s]+"
    "}t+="
    ",$("#"+e.pre+"menulist").html(t)}clickMenu1(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn1_vastplus","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_vastplus","Please input PDB ID for VAST+")})),e.myEventCls.onIds("#"+e.pre+"mn1_vast","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_vast","Please input chain or PDB file for VAST")})),e.myEventCls.onIds("#"+e.pre+"mn1_foldseek","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_foldseek","Submit your selection to Foldseek")})),e.myEventCls.onIds("#"+e.pre+"mn1_mmtfid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmtfid","Please input MMTF ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_pdbid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pdbid","Please input PDB ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_afid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_afid","Please input AlphaFold UniProt ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_refseqid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_refseqid","Please input NCBI Protein Accession")})),e.myEventCls.onIds("#"+e.pre+"mn1_opmid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_opmid","Please input OPM PDB ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_align","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_align","Align two PDB structures")})),e.myEventCls.onIds("#"+e.pre+"mn1_alignaf","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_alignaf","Align two AlphaFold structures")})),e.myEventCls.onIds("#"+e.pre+"mn1_chainalign","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_chainalign","Align multiple chains by structure alignment")})),e.myEventCls.onIds("#"+e.pre+"mn1_chainalign2","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_chainalign2","Align multiple chains by sequence alignment")})),e.myEventCls.onIds("#"+e.pre+"mn1_chainalign3","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_chainalign3","Align multiple chains residue by residue")})),e.myEventCls.onIds("#"+e.pre+"mn1_mutation","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mutation","Show the mutations in 3D")})),e.myEventCls.onIds("#"+e.pre+"mn1_pdbfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pdbfile","Please input PDB File")})),e.myEventCls.onIds(["#"+e.pre+"mn1_pdbfile_app","#"+e.pre+"tool_pdbfile"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pdbfile_app","Please append PDB Files")})),e.myEventCls.onIds("#"+e.pre+"mn1_mol2file","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mol2file","Please input Mol2 File")})),e.myEventCls.onIds("#"+e.pre+"mn1_sdffile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_sdffile","Please input SDF File")})),e.myEventCls.onIds("#"+e.pre+"mn1_xyzfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_xyzfile","Please input XYZ File")})),e.myEventCls.onIds("#"+e.pre+"mn1_afmapfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_afmapfile","Please input AlphaFold PAE File")})),e.myEventCls.onIds("#"+e.pre+"mn1_urlfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_urlfile","Load data by URL")})),e.myEventCls.onIds("#"+e.pre+"mn1_fixedversion","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_fixedversion","Open Share Link URL in the archived version of iCn3D")})),e.myEventCls.onIds("#"+e.pre+"reload_fixedversion","click",(function(s){let i=e.icn3d,n=$("#"+e.pre+"sharelinkurl").val();t.setLogCmd("open "+n,!1),localStorage.setItem("fixedversion","1");let l=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(n,l)})),e.myEventCls.onIds("#"+e.pre+"mn1_mmciffile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmciffile","Please input mmCIF File")})),e.myEventCls.onIds("#"+e.pre+"mn1_mmcifid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmcifid","Please input mmCIF ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_mmdbid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmdbid","Please input MMDB or PDB ID")})),e.myEventCls.onIds(["#"+e.pre+"mn1_mmdbafid",,"#"+e.pre+"tool_mmdbafid"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmdbafid","Please input PDB/MMDB/AlphaFold UniProt IDs")})),e.myEventCls.onIds("#"+e.pre+"mn1_blast_rep_id","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_blast_rep_id","Align sequence to structure")})),e.myEventCls.onIds("#"+e.pre+"mn1_esmfold","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_esmfold","Sequence to structure prediction with ESMFold")})),e.myEventCls.onIds("#"+e.pre+"mn1_proteinname","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_proteinname","Please input protein or gene name")})),e.myEventCls.onIds("#"+e.pre+"mn1_cid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_cid","Please input PubChem CID")})),e.myEventCls.onIds("#"+e.pre+"mn1_pngimage","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pngimage","Please input the PNG image")})),e.myEventCls.onIds("#"+e.pre+"mn1_state","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_state","Please input the state file")})),e.myEventCls.onIds("#"+e.pre+"mn1_selection","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_selection","Please input the selection file")})),e.myEventCls.onIds("#"+e.pre+"mn1_dsn6","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_dsn6","Please input the map file to display electron density map")})),e.myEventCls.onIds(["#"+e.pre+"mn1_delphi","#"+e.pre+"mn1_delphi2","#"+e.pre+"tool_delphi"],"click",(function(t){e.icn3d.loadPhiFrom="delphi",$("#"+e.pre+"dl_delphi_tabs").tabs(),e.htmlCls.dialogCls.openDlg("dl_delphi","Please set parameters to display DelPhi potential map")})),e.myEventCls.onIds("#"+e.pre+"mn1_phi","click",(function(t){e.icn3d.loadPhiFrom="phi",$("#"+e.pre+"dl_phi_tabs").tabs(),$("#"+e.pre+"phitab1_tabs").tabs(),$("#"+e.pre+"phitab2_tabs").tabs(),e.htmlCls.dialogCls.openDlg("dl_phi","Please input local phi or cube file to display DelPhi potential map")})),e.myEventCls.onIds("#"+e.pre+"mn1_phiurl","click",(function(t){e.icn3d.loadPhiFrom="phiurl",$("#"+e.pre+"dl_phiurl_tabs").tabs(),$("#"+e.pre+"phiurltab1_tabs").tabs(),$("#"+e.pre+"phiurltab2_tabs").tabs(),e.htmlCls.dialogCls.openDlg("dl_phiurl","Please input URL phi or cube file to display DelPhi potential map")})),e.myEventCls.onIds("#"+e.pre+"mn1_dsn6url","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_dsn6url","Please input the map file to display electron density map")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportState","click",(function(s){let i=e.icn3d;t.setLogCmd("export state file",!1);let n=Object.keys(i.structures).join(",");i.saveFileCls.saveFile(n+"_statefile.txt","command")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportPdbRes","click",(function(s){e.icn3d,e.htmlCls.setHtmlCls.exportPdb(),t.setLogCmd("export pdb",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSecondary","click",(function(s){e.icn3d,e.htmlCls.setHtmlCls.exportSecondary(),t.setLogCmd("export secondary structure",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphipdb","#"+e.pre+"phipdb"],"click",(function(s){let i=e.icn3d,n=i.saveFileCls.getSelectedResiduePDB();t.setLogCmd("export PDB of selected residues",!1);let l=Object.keys(i.structures).join(",");i.saveFileCls.saveFile(l+"_icn3d_residues.pdb","text",[n])})),e.myEventCls.onIds(["#"+e.pre+"delphipqr","#"+e.pre+"phipqr","#"+e.pre+"phiurlpqr"],"click",(async function(s){e.icn3d,await e.htmlCls.setHtmlCls.exportPqr(),t.setLogCmd("export pqr",!0)})),e.myEventCls.onIds("#"+e.pre+"profixpdb","click",(async function(s){let i=e.icn3d;await i.scapCls.exportPdbProfix(!1),t.setLogCmd("export pdb missing atoms",!0)})),e.myEventCls.onIds("#"+e.pre+"profixpdbh","click",(async function(s){let i=e.icn3d;await i.scapCls.exportPdbProfix(!0),t.setLogCmd("export pdb hydrogen",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportIgstrand","click",(async function(s){e.icn3d.refnumCls.exportRefnum("igstrand"),t.setLogCmd("export refnum igstrand",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportKabat","click",(async function(s){e.icn3d.refnumCls.exportRefnum("kabat"),t.setLogCmd("export refnum kabat",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportImgt","click",(async function(s){e.icn3d.refnumCls.exportRefnum("imgt"),t.setLogCmd("export refnum imgt",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportStl","click",(function(s){let i=e.icn3d;t.setLogCmd("export stl file",!1),i.export3DCls.exportStlFile("")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportVrml","click",(function(s){let i=e.icn3d;t.setLogCmd("export vrml file",!1),i.export3DCls.exportVrmlFile("")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportStlStab","click",(function(s){let i=e.icn3d;t.setLogCmd("export stl stabilizer file",!1),i.threeDPrintCls.hideStabilizer(),i.threeDPrintCls.resetAfter3Dprint(),i.threeDPrintCls.addStabilizer(),i.export3DCls.exportStlFile("_stab")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportVrmlStab","click",(function(s){let i=e.icn3d;t.setLogCmd("export vrml stabilizer file",!1),i.threeDPrintCls.hideStabilizer(),i.threeDPrintCls.resetAfter3Dprint(),i.threeDPrintCls.addStabilizer(),i.export3DCls.exportVrmlFile("_stab")})),e.myEventCls.onIds("#"+e.pre+"mn6_exportInteraction","click",(async function(s){let i=e.icn3d;t.setLogCmd("export interactions",!1),void 0!==e.cfg.mmdbid&&await i.viewInterPairsCls.retrieveInteractionData(),i.viewInterPairsCls.exportInteractions()})),e.myEventCls.onIds(["#"+e.pre+"mn1_exportCanvas","#"+e.pre+"saveimage"],"click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas",!1);await i.shareLinkCls.shareLink(!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas1","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 1",!0),i.scaleFactor=1,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas2","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 2",!0),i.scaleFactor=2,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas4","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 4",!0),i.scaleFactor=4,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas8","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 8",!0),i.scaleFactor=8,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCounts","click",(function(s){let i=e.icn3d;t.setLogCmd("export counts",!1);let n='

    Total Count for atoms with coordinates:
    ';n+="",n+="
    Structure CountChain CountResidue CountAtom Count
    "+Object.keys(i.structures).length+""+Object.keys(i.chains).length+""+Object.keys(i.residues).length+""+Object.keys(i.atoms).length+"

    ",n+="Counts by Chain for atoms with coordinates:
    ";let l=Object.keys(i.chains);for(let e=0,t=l.length;e"}n+="
    StructureChainResidue CountAtom Count
    "+r+""+o+""+Object.keys(a).length+""+Object.keys(i.chains[t]).length+"

    ";let r=Object.keys(i.structures).join(",");i.saveFileCls.saveFile(r+"_counts.html","html",n)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSelections","click",(function(s){let i=e.icn3d;t.setLogCmd("export all selections",!1),t.SetChainsAdvancedMenu();let n=i.saveFileCls.exportCustomAtoms(),l=Object.keys(i.structures).join(",");i.saveFileCls.saveFile(l+"_selections.txt","text",[n])})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSelDetails","click",(function(s){let i=e.icn3d;t.setLogCmd("export all selections with details",!1),t.SetChainsAdvancedMenu();let n=i.saveFileCls.exportCustomAtoms(!0),l=Object.keys(i.structures).join(",");i.saveFileCls.saveFile(l+"_sel_details.txt","text",[n])})),e.myEventCls.onIds(["#"+e.pre+"mn1_sharelink","#"+e.pre+"tool_sharelink"],"click",(async function(t){let s=e.icn3d;await s.shareLinkCls.shareLink()})),e.myEventCls.onIds("#"+e.pre+"mn1_replayon","click",(async function(s){let i=e.icn3d;await i.resizeCanvasCls.replayon(),t.setLogCmd("replay on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_replayoff","click",(async function(s){let i=e.icn3d;await i.resizeCanvasCls.replayoff(),t.setLogCmd("replay off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_menuall","click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus),t.applyShownMenus()})),e.myEventCls.onIds("#"+e.pre+"mn1_menusimple","click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.simpleMenus),t.applyShownMenus()})),e.myEventCls.onIds("#"+e.pre+"mn1_menupref","click",(function(s){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_menupref","Select Menus"),t.getHiddenMenusFromCache(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"apply_menupref","#"+e.pre+"apply_menupref2"],"click",(function(s){e.icn3d;var i=document.querySelectorAll('form[name="'+e.pre+'selmenu"] input:checked');for(var n of(e.htmlCls.shownMenus={},i))e.htmlCls.shownMenus[n.value]=1;t.applyShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"reset_menupref","#"+e.pre+"reset_menupref2"],"click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.simpleMenus),t.applyShownMenus(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"reset_menupref_all","#"+e.pre+"reset_menupref_all2"],"click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus),t.applyShownMenus(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"savepref","#"+e.pre+"savepref2"],"click",(function(t){let s=e.icn3d,i="[";var n=document.querySelectorAll('form[name="'+e.pre+'selmenu"] input:not(:checked)');let l=0;for(var r of n)l>0&&(i+=", "),i+='"'+r.value+'"',++l;i+="]",s.saveFileCls.saveFile("icn3d_menus_pref.txt","text",[i])})),e.myEventCls.onIds("#"+e.pre+"reload_menupreffile","click",(function(s){e.icn3d,s.preventDefault(),e.cfg.notebook||dialog.dialog("close");let i=$("#"+e.pre+"menupreffile")[0].files[0];if(i){e.htmlCls.setHtmlCls.fileSupport();let s=new FileReader;s.onload=function(s){let i=s.target.result,n=JSON.parse(i);e.htmlCls.shownMenus={};for(let t in e.htmlCls.allMenus)-1==n.indexOf(t)&&(e.htmlCls.shownMenus[t]=1);t.applyShownMenus(),t.displayShownMenus()},s.readAsText(i)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"mn1_menuloadpref","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_menuloadpref","Please input the menu preference file")})),e.myEventCls.onIds("#"+e.pre+"mn1_link_structure","click",(function(t){let s=e.icn3d,i=s.saveFileCls.getLinkToStructureSummary(!0),n=s.structures&&Object.keys(s.structures).length>0?"_blank":"_self";window.open(i,n)})),e.myEventCls.onIds("#"+e.pre+"mn1_alphafold","click",(function(t){e.icn3d;window.open("https://github.com/sokrypton/ColabFold","_blank")})),e.myEventCls.onIds("#"+e.pre+"mn1_link_bind","click",(function(s){let i=e.icn3d,n="https://www.ncbi.nlm.nih.gov/pccompound?LinkName=pccompound_structure&from_uid="+i.inputid;t.setLogCmd("link to 3D protein structures bound to CID "+i.inputid+": "+n,!1);let l=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(n,l)})),e.myEventCls.onIds("#"+e.pre+"mn1_link_vast","click",(function(s){let i,n=e.icn3d;if(void 0===n.inputid)i="https://www.ncbi.nlm.nih.gov/pccompound?term="+n.molTitle,t.setLogCmd("link to compounds "+n.molTitle+": "+i,!1);else if(void 0!==e.cfg.cid)i="https://www.ncbi.nlm.nih.gov/pccompound?LinkName=pccompound_pccompound_3d&from_uid="+n.inputid,t.setLogCmd("link to compounds with structure similar to CID "+n.inputid+": "+i,!1);else{let s=n.inputid.split("_");1===s.length?(i=e.htmlCls.baseUrl+"vastplus/vastplus.cgi?uid="+n.inputid,t.setLogCmd("link to structures similar to "+n.inputid+": "+i,!1)):2===s.length&&(i=e.htmlCls.baseUrl+"vastplus/vastplus.cgi?uid="+s[0],t.setLogCmd("link to structures similar to "+s[0]+": "+i,!1))}let l=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i,l)})),e.myEventCls.onIds("#"+e.pre+"mn1_link_pubmed","click",(function(s){let i,n=e.icn3d;if(void 0===n.inputid){i="https://www.ncbi.nlm.nih.gov/pubmed/?term="+n.molTitle,t.setLogCmd("link to literature about "+n.molTitle+": "+i,!1);let e=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i,e)}else if(n.pmid){let e=n.pmid.toString().split("_");1===e.length?(i="https://www.ncbi.nlm.nih.gov/pubmed/"+n.pmid,t.setLogCmd("link to PubMed ID "+n.pmid+": "+i,!1)):2===e.length&&(i="https://www.ncbi.nlm.nih.gov/pubmed/?term="+e[0]+" OR "+e[1],t.setLogCmd("link to PubMed IDs "+e[0]+", "+e[1]+": "+i,!1));let s=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i,s)}else if(isNaN(n.inputid)){let e=n.inputid.toString().split("_");1===e.length?(i="https://www.ncbi.nlm.nih.gov/pubmed/?term="+n.inputid,t.setLogCmd("link to literature about PDB "+n.inputid+": "+i,!1)):2===e.length&&(i="https://www.ncbi.nlm.nih.gov/pubmed/?term="+e[0]+" OR "+e[1],t.setLogCmd("link to literature about PDB "+e[0]+" OR "+e[1]+": "+i,!1));let s=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i,s)}else void 0!==e.cfg.cid?alert("No literature information is available for this compound in the SDF file."):alert("No literature information is available for this structure.")})),e.myEventCls.onIds("#"+e.pre+"mn1_link_protein","click",(function(s){let i=e.icn3d,n=Object.keys(i.structures),l=Object.keys(i.chains),r="";for(let e=0,t=l.length;e0&&(r=r.substr(0,r.length-4));let o="https://www.ncbi.nlm.nih.gov/protein/?term="+r;t.setLogCmd("link to Entrez protein about PDB "+n+": "+o,!1);let a=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(o,a)}))}clickMenu2(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds(["#"+e.pre+"mn6_selectannotations","#"+e.pre+"tool_selectannotations"],"click",(async function(s){let i=e.icn3d;await i.showAnnoCls.showAnnotations(),t.setLogCmd("view annotations",!0)})),e.myEventCls.onIds("#"+e.pre+"mn2_selectall","click",(function(s){let i=e.icn3d;t.setLogCmd("select all",!0),i.selectionCls.selectAll(),i.hlUpdateCls.removeHlAll(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"clearall","click",(function(s){let i=e.icn3d;t.setLogCmd("clear all",!0),i.bSelectResidue=!1,i.selectionCls.selectAll(),i.hlUpdateCls.removeHlAll(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn2_selectdisplayed","click",(function(s){let i=e.icn3d;t.setLogCmd("select displayed set",!0),i.hAtoms=e.hashUtilsCls.cloneHash(i.viewSelectionAtoms),i.hlUpdateCls.updateHlAll()})),e.myEventCls.onIds("#"+e.pre+"mn2_fullstru","click",(function(s){let i=e.icn3d;t.setLogCmd("show all",!0),i.selectionCls.showAll()})),e.myEventCls.onIds("#"+e.pre+"mn2_selectcomplement","click",(function(s){let i=e.icn3d;Object.keys(i.hAtoms).lengthnon-selected"+n),$("#"+e.pre+"atomsCustomSphere2").length&&$("#"+e.pre+"atomsCustomSphere2").html(" "+n),e.htmlCls.dialogCls.openDlg("dl_aroundsphere","Select a sphere around a set of residues"),i.bSphereCalc=!1,$("#"+e.pre+"atomsCustomSphere").resizable(),$("#"+e.pre+"atomsCustomSphere2").resizable()})),e.myEventCls.onIds(["#"+e.pre+"mn2_select_chain","#"+e.pre+"definedSets"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_select_chain","Select Structure/Chain/Custom Selection")}))}clickMenu3(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsRibbon","#"+e.pre+"tool_proteinsRibbon"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","ribbon"),t.setLogCmd("style proteins ribbon",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsStrand","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","strand"),t.setLogCmd("style proteins strand",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsCylinder","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","cylinder and plate"),t.setLogCmd("style proteins cylinder and plate",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","schematic"),t.setLogCmd("style proteins schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsCalpha","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","c alpha trace"),t.setLogCmd("style proteins c alpha trace",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsBackbone","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","backbone"),t.setLogCmd("style proteins backbone",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsBfactor","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","b factor tube"),t.setLogCmd("style proteins b factor tube",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsLines","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","lines"),t.setLogCmd("style proteins lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsStick","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","stick"),t.setLogCmd("style proteins stick",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsBallstick","#"+e.pre+"tool_proteinsBallstick"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","ball and stick"),t.setLogCmd("style proteins ball and stick",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsSphere","#"+e.pre+"tool_proteinsSphere"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","sphere"),t.setLogCmd("style proteins sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsNo","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","nothing"),t.setLogCmd("style proteins nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecLines","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","lines2"),t.setLogCmd("style sidec lines2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecStick","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","stick2"),t.setLogCmd("style sidec stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","ball and stick2"),t.setLogCmd("style sidec ball and stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","sphere2"),t.setLogCmd("style sidec sphere2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecNo","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","nothing"),t.setLogCmd("style sidec nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseLines","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","lines2"),t.setLogCmd("style ntbase lines2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseStick","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","stick2"),t.setLogCmd("style ntbase stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","ball and stick2"),t.setLogCmd("style ntbase ball and stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","sphere2"),t.setLogCmd("style ntbase sphere2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseNo","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","nothing"),t.setLogCmd("style ntbase nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclCartoon","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","nucleotide cartoon"),t.setLogCmd("style nucleotides nucleotide cartoon",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclBackbone","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","backbone"),t.setLogCmd("style nucleotides backbone",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","schematic"),t.setLogCmd("style nucleotides schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclPhos","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","o3 trace"),t.setLogCmd("style nucleotides o3 trace",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclLines","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","lines"),t.setLogCmd("style nucleotides lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclStick","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","stick"),t.setLogCmd("style nucleotides stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","ball and stick"),t.setLogCmd("style nucleotides ball and stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","sphere"),t.setLogCmd("style nucleotides sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclNo","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","nothing"),t.setLogCmd("style nucleotides nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligLines","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","lines"),t.setLogCmd("style chemicals lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligStick","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","stick"),t.setLogCmd("style chemicals stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","ball and stick"),t.setLogCmd("style chemicals ball and stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","schematic"),t.setLogCmd("style chemicals schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","sphere"),t.setLogCmd("style chemicals sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligNo","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","nothing"),t.setLogCmd("style chemicals nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_glycansCartYes","click",(function(s){let i=e.icn3d;i.bGlycansCartoon=!0,i.drawCls.draw(),t.setLogCmd("glycans cartoon yes",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_glycansCartNo","click",(function(s){let i=e.icn3d;i.bGlycansCartoon=!1,i.drawCls.draw(),t.setLogCmd("glycans cartoon no",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_hydrogensYes","click",(function(s){let i=e.icn3d;i.showInterCls.showHydrogens(),i.drawCls.draw(),t.setLogCmd("hydrogens",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_hydrogensNo","click",(function(s){let i=e.icn3d;i.showInterCls.hideHydrogens(),i.drawCls.draw(),t.setLogCmd("set hydrogens off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","sphere"),t.setLogCmd("style ions sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsDot","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","dot"),t.setLogCmd("style ions dot",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsNo","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","nothing"),t.setLogCmd("style ions nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("water","sphere"),t.setLogCmd("style water sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterDot","click",(function(s){e.icn3d.setOptionCls.setStyle("water","dot"),t.setLogCmd("style water dot",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterNo","click",(function(s){e.icn3d.setOptionCls.setStyle("water","nothing"),t.setLogCmd("style water nothing",!0)}))}clickMenu4(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrum","click",(function(s){e.icn3d.setOptionCls.setOption("color","spectrum"),t.setLogCmd("color spectrum",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumChain","click",(function(s){e.icn3d.setOptionCls.setOption("color","spectrum for chains"),t.setLogCmd("color spectrum for chains",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumAcrossSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorSpectrumAcross").length&&$("#"+e.pre+"atomsCustomColorSpectrumAcross").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorspectrumacrosssets","Please select sets to apply spectrum color for sets"),$("#"+e.pre+"atomsCustomColorSpectrumAcross").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorSpectrum").length&&$("#"+e.pre+"atomsCustomColorSpectrum").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorspectrumbysets","Please select sets to apply spectrum color for residues"),$("#"+e.pre+"atomsCustomColorSpectrum").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbowAcrossSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorRainbowAcross").length&&$("#"+e.pre+"atomsCustomColorRainbowAcross").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorrainbowacrosssets","Please select sets to apply rainbow color for sets"),$("#"+e.pre+"atomsCustomColorRainbowAcross").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbowSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorRainbow").length&&$("#"+e.pre+"atomsCustomColorRainbow").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorrainbowbysets","Please select sets to apply rainbow color for residues"),$("#"+e.pre+"atomsCustomColorRainbow").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbow","click",(function(s){e.icn3d.setOptionCls.setOption("color","rainbow"),t.setLogCmd("color rainbow",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrRainbowChain","#"+e.pre+"tool_clrRainbowChain"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","rainbow for chains"),t.setLogCmd("color rainbow for chains",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrChain","#"+e.pre+"tool_clrChain"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","chain"),t.setLogCmd("color chain",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrStructure","click",(function(s){e.icn3d.setOptionCls.setOption("color","structure"),t.setLogCmd("color structure",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrdomain","click",(function(s){e.icn3d.setOptionCls.setOption("color","domain"),t.setLogCmd("color domain",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrsets","click",(function(s){e.icn3d.setOptionCls.setOption("color","defined sets"),t.setLogCmd("color defined sets",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrSSGreen","#"+e.pre+"tool_clrSSGreen"],"click",(function(s){let i=e.icn3d;i.sheetcolor="green",i.setOptionCls.setOption("color","secondary structure green"),t.setLogCmd("color secondary structure green",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSSYellow","click",(function(s){let i=e.icn3d;i.sheetcolor="yellow",i.setOptionCls.setOption("color","secondary structure yellow"),t.setLogCmd("color secondary structure yellow",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSSSpectrum","click",(function(s){e.icn3d.setOptionCls.setOption("color","secondary structure spectrum"),t.setLogCmd("color secondary structure spectrum",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrResidue","click",(function(s){e.icn3d.setOptionCls.setOption("color","residue"),t.setLogCmd("color residue",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrResidueCustom","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_rescolorfile","Please input the file on residue colors")})),e.myEventCls.onIds("#"+e.pre+"reload_rescolorfile","click",(function(s){let i=e.icn3d;s.preventDefault(),e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"rescolorfile")[0].files[0];if(n){e.htmlCls.setHtmlCls.fileSupport();let s=new FileReader;s.onload=function(s){let n=s.target.result.replace(/#/g,"");i.customResidueColors=JSON.parse(n);for(let t in i.customResidueColors)i.customResidueColors[t.toUpperCase()]=e.parasCls.thr("#"+i.customResidueColors[t]);i.setOptionCls.setOption("color","residue custom"),t.setLogCmd("color residue custom | "+n,!0)},s.readAsText(n)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"reload_customcolorfile","click",(function(s){let i=e.icn3d;s.preventDefault(),e.cfg.notebook||dialog.dialog("close"),i.startColor=$("#"+e.pre+"startColor").val(),i.midColor=$("#"+e.pre+"midColor").val(),i.endColor=$("#"+e.pre+"endColor").val();let n=t.setLegendHtml();$("#"+e.pre+"dl_legend_html").html(n),e.htmlCls.dialogCls.openDlg("dl_legend","Color range"),i.addTrackCls.setCustomFile("color",i.startColor,i.midColor,i.endColor)})),e.myEventCls.onIds("#"+e.pre+"mn6_customref","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_customref","Set custom reference numbers")})),e.myEventCls.onIds("#"+e.pre+"reload_customreffile","click",(function(s){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close");let n=$("#"+i.pre+"cstreffile")[0].files[0];if(n){e.utilsCls.checkFileAPI();let s=new FileReader;s.onload=async function(e){let s=e.target.result;await i.refnumCls.parseCustomRefFile(s),s=s.replace(/\r/g,"").replace(/\n/g,"\\n"),t.setLogCmd("custom refnum | "+s,!0)},s.readAsText(n)}else alert("Please select a file before clicking 'Apply'")})),e.myEventCls.onIds("#"+e.pre+"remove_legend","click",(function(s){e.icn3d,s.preventDefault(),$("#"+e.pre+"legend").hide(),t.setLogCmd("remove legend",!0)})),e.myEventCls.onIds("#"+e.pre+"reload_customtubefile","click",(function(t){let s=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),s.addTrackCls.setCustomFile("tube")})),e.myEventCls.onIds("#"+e.pre+"mn4_clrCharge","click",(function(s){e.icn3d.setOptionCls.setOption("color","charge"),t.setLogCmd("color charge",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrHydrophobic","click",(function(s){e.icn3d.setOptionCls.setOption("color","hydrophobic"),t.setLogCmd("color hydrophobic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrNormalizedHP","click",(function(s){e.icn3d.setOptionCls.setOption("color","normalized hydrophobic"),t.setLogCmd("color normalized hydrophobic",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrAtom","#"+e.pre+"tool_clrAtom"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","atom"),t.setLogCmd("color atom",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrBfactor","click",(function(s){e.icn3d.setOptionCls.setOption("color","b factor"),t.setLogCmd("color b factor",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrConfidence","click",(function(s){e.icn3d.setOptionCls.setOption("color","confidence"),t.setLogCmd("color confidence",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrIgstrand","click",(function(s){e.icn3d.setOptionCls.setOption("color","ig strand"),t.setLogCmd("color ig strand",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrIgproto","click",(function(s){e.icn3d.setOptionCls.setOption("color","ig protodomain"),t.setLogCmd("color ig protodomain",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrArea","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_colorbyarea","Color based on residue's solvent accessibility")})),e.myEventCls.onIds("#"+e.pre+"applycolorbyarea","click",(function(s){let i=e.icn3d;i.midpercent=$("#"+e.pre+"midpercent").val(),i.setOptionCls.setOption("color","area"),t.setLogCmd("color area | "+i.midpercent,!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrBfactorNorm","click",(function(s){e.icn3d.setOptionCls.setOption("color","b factor percentile"),t.setLogCmd("color b factor percentile",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrIdentity","click",(function(s){e.icn3d.setOptionCls.setOption("color","identity"),t.setLogCmd("color identity",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrConserved","click",(function(s){e.icn3d.setOptionCls.setOption("color","conservation"),t.setLogCmd("color conservation",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrCustom","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_clr","Color picker")})),$(document).on("click",".icn3d-color-rad-text",(function(s){let i=e.icn3d;s.stopImmediatePropagation();let n=$(this).attr("color");i.setOptionCls.setOption("color",n),t.setLogCmd("color "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSave","click",(function(s){e.icn3d.setOptionCls.saveColor(),t.setLogCmd("save color",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrApplySave","click",(function(s){e.icn3d.setOptionCls.applySavedColor(),t.setLogCmd("apply saved color",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_styleSave","click",(function(s){e.icn3d.setOptionCls.saveStyle(),t.setLogCmd("save style",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_styleApplySave","click",(function(s){e.icn3d.setOptionCls.applySavedStyle(),t.setLogCmd("apply saved style",!0)}))}clickMenu5(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn5_neighborsYes","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.applyMapCls.removeLastSurface(),i.applyMapCls.applySurfaceOptions(),i.bRender&&i.drawCls.render(),t.setLogCmd("set surface neighbors on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_neighborsNo","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.applyMapCls.removeLastSurface(),i.applyMapCls.applySurfaceOptions(),i.bRender&&i.drawCls.render(),t.setLogCmd("set surface neighbors off",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn5_surfaceVDW","#"+e.pre+"tool_surfaceVDW"],"click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","Van der Waals surface"),t.setLogCmd("set surface Van der Waals surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceSAS","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","solvent accessible surface"),t.setLogCmd("set surface solvent accessible surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceMolecular","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","molecular surface"),t.setLogCmd("set surface molecular surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceVDWContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","Van der Waals surface with context"),t.setLogCmd("set surface Van der Waals surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceSASContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","solvent accessible surface with context"),t.setLogCmd("set surface solvent accessible surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceMolecularContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","molecular surface with context"),t.setLogCmd("set surface molecular surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceNo","click",(function(s){e.icn3d.setOptionCls.setOption("surface","nothing"),t.setLogCmd("set surface nothing",!0)})),$(document).on("click","."+e.pre+"mn5_opacity",(function(s){let i=e.icn3d;i.transparentRenderOrder=!1;let n=$(this).attr("v");i.setOptionCls.setOption("opacity",n),t.setLogCmd("set surface opacity "+n,!0)})),$(document).on("click","."+e.pre+"mn5_opacityslow",(function(s){let i=e.icn3d;i.transparentRenderOrder=!0;let n=$(this).attr("v");i.setOptionCls.setOption("opacity",n),t.setLogCmd("set surface2 opacity "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_wireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("wireframe","yes"),t.setLogCmd("set surface wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_wireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("wireframe","no"),t.setLogCmd("set surface wireframe off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_elecmap2fofc","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_elecmap2fofc","2Fo-Fc Electron Density Map")})),e.myEventCls.onIds("#"+e.pre+"mn5_elecmapfofc","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_elecmapfofc","Fo-Fc Electron Density Map")})),e.myEventCls.onIds(["#"+e.pre+"mn5_elecmapNo","#"+e.pre+"elecmapNo2","#"+e.pre+"elecmapNo3","#"+e.pre+"elecmapNo4","#"+e.pre+"elecmapNo5"],"click",(function(s){e.icn3d.setOptionCls.setOption("map","nothing"),t.setLogCmd("setoption map nothing",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphimapNo","#"+e.pre+"phimapNo","#"+e.pre+"phiurlmapNo","#"+e.pre+"mn1_phimapNo"],"click",(function(s){e.icn3d.setOptionCls.setOption("phimap","nothing"),t.setLogCmd("setoption phimap nothing",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphimapNo2","#"+e.pre+"phimapNo2","#"+e.pre+"phiurlmapNo2"],"click",(function(s){e.icn3d.setOptionCls.setOption("phisurface","nothing"),t.setLogCmd("setoption phisurface nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"applymap2fofc","click",(async function(s){let i=e.icn3d;s.preventDefault();let n=parseFloat($("#"+e.pre+"sigma2fofc").val());await i.dsn6ParserCls.dsn6Parser(i.inputid,"2fofc",n),t.setLogCmd("set map 2fofc sigma "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"applymapfofc","click",(async function(s){let i=e.icn3d;s.preventDefault();let n=parseFloat($("#"+e.pre+"sigmafofc").val());await i.dsn6ParserCls.dsn6Parser(i.inputid,"fofc",n),t.setLogCmd("set map fofc sigma "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_mapwireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("mapwireframe","yes"),t.setLogCmd("set map wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_mapwireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("mapwireframe","no"),t.setLogCmd("set map wireframe off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmap","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_emmap","EM Density Map")})),e.myEventCls.onIds(["#"+e.pre+"mn5_emmapNo","#"+e.pre+"emmapNo2"],"click",(function(s){e.icn3d.setOptionCls.setOption("emmap","nothing"),t.setLogCmd("setoption emmap nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"applyemmap","click",(async function(s){let i=e.icn3d;s.preventDefault();let n=parseFloat($("#"+e.pre+"empercentage").val());await i.densityCifParserCls.densityCifParser(i.inputid,"em",n,i.emd),t.setLogCmd("set emmap percentage "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmapwireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("emmapwireframe","yes"),t.setLogCmd("set emmap wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmapwireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("emmapwireframe","no"),t.setLogCmd("set emmap wireframe off",!0)}))}clickMenu6(){let e=this.icn3dui,t=e.icn3d;if(e.bNode)return;let s=this;e.myEventCls.onIds("#"+e.pre+"mn6_assemblyYes","click",(function(t){let i=e.icn3d;i.bAssembly=!0,s.setLogCmd("set assembly on",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_assemblyNo","click",(function(t){let i=e.icn3d;i.bAssembly=!1,s.setLogCmd("set assembly off",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_igrefYes","click",(async function(t){let i=e.icn3d;s.setLogCmd("ig refnum on",!0),await i.refnumCls.showIgRefNum()})),e.myEventCls.onIds("#"+e.pre+"mn6_igrefTpl","click",(async function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_igrefTpl","Choose an Ig template")})),e.myEventCls.onIds("#"+e.pre+"mn6_igrefTpl_apply","click",(async function(t){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"igrefTpl").val();s.setLogCmd("ig template "+n,!0),await i.refnumCls.showIgRefNum(n)})),e.myEventCls.onIds("#"+e.pre+"mn6_igrefNo","click",(async function(t){let i=e.icn3d;s.setLogCmd("ig refnum off",!0),await i.refnumCls.hideIgRefNum(),i.opts.color="chain",i.setColorCls.setColorByOptions(i.opts,i.atoms),i.selectionCls.selectAll_base(),i.hlUpdateCls.updateHlAll(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelAtoms","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addAtomLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add atom labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelElements","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addAtomLabels(i.hAtoms,!0),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add element labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelResidues","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addResidueLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add residue labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelResnum","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addResidueLabels(i.hAtoms,void 0,void 0,!0),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add residue number labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelRefnum","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addResidueLabels(i.hAtoms,void 0,void 0,void 0,!0),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add reference number labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelChains","click",(function(t){let i=e.icn3d;i.analysisCls.addChainLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add chain labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelTermini","click",(function(t){let i=e.icn3d;i.analysisCls.addTerminiLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add terminal labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelYes","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_addlabel","Add custom labels by selection"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelSelection","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_addlabelselection","Add custom labels by the selected")})),e.myEventCls.onIds("#"+e.pre+"mn6_labelColor","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_labelColor","Change color for all labels")})),e.myEventCls.onIds(["#"+e.pre+"mn2_saveselection","#"+e.pre+"tool_saveselection"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_saveselection","Save the selected")})),e.myEventCls.onIds(["#"+e.pre+"mn6_addlabelNo","#"+e.pre+"removeLabels"],"click",(function(t){let i=e.icn3d;i.labelcolor=void 0,i.pickpair=!1;s.setLogCmd("set labels off",!0);for(let e in i.labels)i.labels[e]=[];i.drawCls.draw()})),$(document).on("click","."+e.pre+"mn6_labelscale",(function(t){let i=e.icn3d,n=$(this).attr("v");i.labelScale=n,i.drawCls.draw(),s.setLogCmd("set label scale "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_distanceYes","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_distance","Measure the distance of atoms"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0,s.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distTwoSets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_disttwosets","Measure the distance between two sets"),s.setSetsMenus("atomsCustomDist"),i.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distManySets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_distmanysets","Measure the pairwise distance among many sets"),s.setSetsMenus("atomsCustomDistTable"),i.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distanceNo","click",(function(t){let i=e.icn3d;i.pickpair=!1;s.setLogCmd("set lines off",!0),i.labels.distance=[],i.lines.distance=[],i.distPnts=[],i.pk=2,i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn5_cartoonshape","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_cartoonshape","Draw cartoon for a set");s.setSetsMenus("cartoonshape",!0),i.bCartoonshape=!0})),e.myEventCls.onIds("#"+e.pre+"mn5_linebtwsets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_linebtwsets","Draw a line between two sets"),s.setSetsMenus("linebtwsets"),i.bLinebtwsets=!0})),e.myEventCls.onIds(["#"+e.pre+"mn2_selectedcenter","#"+e.pre+"zoomin_selection","#"+e.pre+"tool_selectedcenter"],"click",(function(t){let i=e.icn3d;i.transformCls.zoominSelection(),i.drawCls.draw(),s.setLogCmd("zoom selection",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_center","click",(function(t){let i=e.icn3d;i.applyCenterCls.centerSelection(),i.drawCls.draw(),s.setLogCmd("center selection",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_resetOrientation","#"+e.pre+"resetOrientation","#"+e.pre+"tool_resetOrientation"],"click",(function(t){let i=e.icn3d;i.transformCls.resetOrientation(),i.drawCls.draw(),s.setLogCmd("reset orientation",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_chemicalbindingshow","#"+e.pre+"chemicalbindingshow"],"click",(function(t){e.icn3d.setOptionCls.setOption("chemicalbinding","show"),s.setLogCmd("set chemicalbinding show",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_chemicalbindinghide","#"+e.pre+"chemicalbindinghide"],"click",(function(t){e.icn3d.setOptionCls.setOption("chemicalbinding","hide"),s.setLogCmd("set chemicalbinding hide",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_sidebyside","click",(function(t){let i=e.icn3d;if(i.bInputfile)return void alert("Side-by-Side does NOT work when the input is from a local file.");let n=i.shareLinkCls.shareLinkUrl(void 0);n=n.replace("icn3d/full.html?","icn3d/full2.html?"),n=n.replace("icn3d/?","icn3d/full2.html?"),n+="&closepopup=1";let l=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(n,l),s.setLogCmd("side by side | "+n,!0)})),$(document).on("click","."+e.pre+"mn6_rotate",(function(t){let i=e.icn3d,n=$(this).attr("v").toLowerCase(),l=n.split(" ")[1];s.setLogCmd(n,!0),i.bStopRotate=!1,i.transformCls.rotateCount=0,i.transformCls.rotateCountMax=6e3,i.ROT_DIR=l,i.resizeCanvasCls.rotStruc(l)})),$(document).on("click","."+e.pre+"mn6_rotate90",(function(t){let i,n=e.icn3d,l=$(this).attr("v").toLowerCase(),r=l.split("-")[0];s.setLogCmd(l,!0),"x"==r?i=new THREE.Vector3(1,0,0):"y"==r?i=new THREE.Vector3(0,1,0):"z"==r&&(i=new THREE.Vector3(0,0,1));let o=.5*Math.PI;n.transformCls.setRotation(i,o)})),e.myEventCls.onIds("#"+e.pre+"mn6_cameraPers","click",(function(t){e.icn3d.setOptionCls.setOption("camera","perspective"),s.setLogCmd("set camera perspective",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_cameraOrth","click",(function(t){e.icn3d.setOptionCls.setOption("camera","orthographic"),s.setLogCmd("set camera orthographic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdBlack","click",(function(t){e.icn3d.setStyleCls.setBackground("black")})),e.myEventCls.onIds("#"+e.pre+"tool_bkgd","click",(function(t){let s=e.icn3d;"black"==s.opts.background?s.setStyleCls.setBackground("white"):s.setStyleCls.setBackground("black")})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdGrey","click",(function(t){e.icn3d.setStyleCls.setBackground("grey")})),e.myEventCls.onIds(["#"+e.pre+"mn6_bkgdWhite","#"+e.pre+"tool_bkgdWhite"],"click",(function(t){e.icn3d.setStyleCls.setBackground("white")})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdTransparent","click",(function(t){e.icn3d.setStyleCls.setBackground("transparent")})),e.myEventCls.onIds("#"+e.pre+"mn6_showfogYes","click",(function(t){let i=e.icn3d;i.opts.fog="yes",i.fogCls.setFog(!0),i.drawCls.draw(),s.setLogCmd("set fog on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showfogNo","click",(function(t){let i=e.icn3d;i.opts.fog="no",i.fogCls.setFog(!0),i.drawCls.draw(),s.setLogCmd("set fog off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showslabYes","click",(function(t){e.icn3d.setOptionCls.setOption("slab","yes"),s.setLogCmd("set slab on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showslabNo","click",(function(t){e.icn3d.setOptionCls.setOption("slab","no"),s.setLogCmd("set slab off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisYes","click",(function(t){e.icn3d.setOptionCls.setOption("axis","yes"),s.setLogCmd("set axis on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisSel","click",(function(t){let i=e.icn3d;i.pc1=!0,i.axesCls.setPc1Axes(),s.setLogCmd("set pc1 axis",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisNo","click",(function(t){let i=e.icn3d;i.pc1=!1,i.axes=[],i.setOptionCls.setOption("axis","no"),s.setLogCmd("set axis off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_symmetry","click",(async function(t){let s=e.icn3d;s.bAxisOnly=!1,await s.symdCls.retrieveSymmetry(Object.keys(s.structures)[0])})),e.myEventCls.onIds("#"+e.pre+"mn6_symd","click",(async function(t){let i=e.icn3d;i.bAxisOnly=!1,await i.symdCls.retrieveSymd(),i.bSymd=!0,s.setLogCmd("symd symmetry",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_clear_sym","click",(function(t){let i=e.icn3d;i.symdArray=[],i.drawCls.draw(),s.setLogCmd("clear symd symmetry",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_axes_only","click",(function(t){let i=e.icn3d;i.bAxisOnly=!0,i.drawCls.draw(),s.setLogCmd("show axis",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_area","click",(function(t){e.icn3d.analysisCls.calculateArea(),s.setLogCmd("area",!0)})),e.myEventCls.onIds("#"+e.pre+"applysymmetry","click",(function(t){let i=e.icn3d;i.bAxisOnly=!1;let n=$("#"+e.pre+"selectSymmetry").val();i.symmetrytitle="none"===n?void 0:n,i.drawCls.draw(),s.setLogCmd("symmetry "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"clearsymmetry","click",(function(t){let i=e.icn3d;i.symmetrytitle=void 0,i.drawCls.draw(),s.setLogCmd("symmetry none",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_hbondsYes","#"+e.pre+"hbondsYes"],"click",(function(t){let i=e.icn3d;s.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomHbond").length&&$("#"+e.pre+"atomsCustomHbond").html(" "+n),$("#"+e.pre+"atomsCustomHbond2").length&&$("#"+e.pre+"atomsCustomHbond2").html(" "+n),e.htmlCls.dialogCls.openDlg("dl_hbonds","Hydrogen bonds/interactions between two sets of atoms"),i.bHbondCalc=!1,$("#"+e.pre+"atomsCustomHbond").resizable(),$("#"+e.pre+"atomsCustomHbond2").resizable()})),e.myEventCls.onIds(["#"+e.pre+"mn6_contactmap"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_contact","Set contact map")})),e.myEventCls.onIds("#"+e.pre+"mn6_hbondsNo","click",(function(t){let s=e.icn3d;s.showInterCls.hideHbondsContacts(),s.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerYes","click",(function(t){let i=e.icn3d;i.threeDPrintCls.addStabilizer(),i.threeDPrintCls.prepareFor3Dprint(),s.setLogCmd("stabilizer",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerNo","click",(function(t){let i=e.icn3d;s.setLogCmd("set stabilizer off",!0),i.threeDPrintCls.hideStabilizer(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerOne","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_stabilizer","Add One Stabilizer"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerRmOne","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_stabilizer_rm","Remove One Stabilizer"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn1_thicknessSet","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_thickness","Set Thickness for 3D Printing")})),e.myEventCls.onIds("#"+e.pre+"mn3_setThickness","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_thickness2","Style Preferences")})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsYes","click",(function(t){let i=e.icn3d;s.setLogCmd("disulfide bonds",!0),i.showInterCls.showSsbonds()})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsExport","click",(function(t){e.icn3d.viewInterPairsCls.exportSsbondPairs(),s.setLogCmd("export disulfide bond pairs",!1)})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsNo","click",(function(t){let i=e.icn3d;i.opts.ssbonds="no";s.setLogCmd("set disulfide bonds off",!0),i.lines.ssbond=[],i.setOptionCls.setStyle("sidec","nothing")})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsYes","click",(function(t){let i=e.icn3d;s.setLogCmd("cross linkage",!0),i.showInterCls.showClbonds()})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsExport","click",(function(t){e.icn3d.viewInterPairsCls.exportClbondPairs(),s.setLogCmd("export cross linkage pairs",!1)})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsNo","click",(function(t){let i=e.icn3d;i.opts.clbonds="no";s.setLogCmd("set cross linkage off",!0),i.lines.clbond=[],i.setOptionCls.setStyle("sidec","nothing")})),$("#"+e.pre+"newvs2").on("submit",(function(){let s=t.saveFileCls.getAtomPDB(t.hAtoms);return $("#"+e.pre+"pdbstr").val(s),!0})),$("#"+e.pre+"fssubmit").on("click",(function(){let e=t.saveFileCls.getAtomPDB(t.hAtoms),s=window.open("","_blank");s.document.body.innerHTML="\n\nLoading Foldseek\n\n\n\n
    Foldseek is loading...
    \n",$.ajax({url:"https://search.foldseek.com/api/ticket",type:"POST",data:{q:e,database:["afdb50","afdb-swissprot","gmgcl_id","pdb100","afdb-proteome","mgnify_esm30"],mode:"3diaa"},dataType:"text",success:function(e){s.location="https://search.foldseek.com/queue/"+JSON.parse(e).id},error:function(e,t,s){console.log("Error in submitting data to Foldseek...")}})})),e.myEventCls.onIds("#"+e.pre+"jn_copy","click",(function(t){e.icn3d;let s=$("#"+e.pre+"jn_commands").val();navigator.clipboard.writeText(s)}))}setLogCmd(e,t,s){var i=this.icn3dui,n=i.icn3d;if(""===e.trim())return!1;let l=e.indexOf("|||");-1!==l&&(e=e.substr(0,l));let r={};if(n.quaternion||(n._zoomFactor=1,n.mouseChange=new THREE.Vector2(0,0),n.quaternion=new THREE.Quaternion(0,0,0,1)),r.factor=n._zoomFactor,r.mouseChange=n.mouseChange,r.quaternion={},r.quaternion._x=parseFloat(n.quaternion._x).toPrecision(5),r.quaternion._y=parseFloat(n.quaternion._y).toPrecision(5),r.quaternion._z=parseFloat(n.quaternion._z).toPrecision(5),r.quaternion._w=parseFloat(n.quaternion._w).toPrecision(5),t&&n.bAddCommands)if(n.STATENUMBER "+n.logs.join("\n> ")+"\n> "),$("#"+i.pre+"logtext")[0]&&$("#"+i.pre+"logtext").scrollTop($("#"+i.pre+"logtext")[0].scrollHeight)}n.setStyleCls.adjustIcon()}}class d{constructor(e){this.icn3dui=e}getLink(e,t,s,i){return this.icn3dui.htmlCls.setHtmlCls.getLink(e,t,s,i)}getMenuText(e,t,s,i,n){return this.icn3dui.htmlCls.setHtmlCls.getMenuText(e,t,s,i,n)}getMenuUrl(e,t,s,i,n){return this.icn3dui.htmlCls.setHtmlCls.getMenuUrl(e,t,s,i,n)}getMenuSep(){return this.icn3dui.htmlCls.setHtmlCls.getMenuSep()}getLinkWrapper(e,t,s,i,n,l){let r=this.icn3dui;return r.icn3d,r.htmlCls.setHtmlCls.getLinkWrapper(e,t,s,i,n,l)}getLinkWrapper2(e,t,s,i,n){let l=this.icn3dui;return l.icn3d,l.htmlCls.setHtmlCls.getLinkWrapper2(e,t,s,i,n)}getRadio(e,t,s,i,n,l){return this.icn3dui.htmlCls.setHtmlCls.getRadio(e,t,s,i,n,l)}getRadClr(e,t,s,i,n,l,r){return this.icn3dui.htmlCls.setHtmlCls.getRadioColor(e,t,s,i,n,l,r)}setTopMenusHtml(e,t,s){let i=this.icn3dui;if(i.bNode)return"";let n="black"==i.htmlCls.opts.background?i.htmlCls.GREYD:"black",l="";l+="
    ",l+=i.htmlCls.divStr+"popup' class='icn3d-text icn3d-popup'>
    ",l+=this.setReplayHtml(),l+="\x3c!--https://forum.jquery.com/topic/looking-for-a-jquery-horizontal-menu-bar--\x3e",l+=i.htmlCls.divStr+"mnlist' style='position:absolute; z-index:999; float:left; display:table-row; margin-top: -2px;'>",l+="";let r='",l+=r+this.setMenu2()+"",l+=r+this.setMenu2b()+"",l+=r+this.setMenu3()+"",l+=r+this.setMenu4()+"",l+=r+this.setMenu5()+"",l+=r+this.setMenu6()+"",i.htmlCls.shownMenus=i.hashUtilsCls.cloneHash(i.htmlCls.simpleMenus),l+=r+"
    "+t,l+="
    "+s,l+=r+'
    '+i.htmlCls.space2+'Toolbar '+i.htmlCls.space2+'
    ",l+=r+'
    '+i.htmlCls.space2+' ?
    ',l+="
    ",l+="
    ';if(l+=r+this.setMenu1()+"
    ",l+="",l+=this.setTools(),l+=i.htmlCls.divStr+"title' class='icn3d-commandTitle' style='font-size:1.2em; font-weight:normal; position:absolute; z-index:1; float:left; display:table-row; margin: 85px 0px 0px 5px; color:"+n+"; width:"+i.htmlCls.WIDTH+"px'>",l+=i.htmlCls.divStr+"viewer' style='position:relative; width:100%; height:100%; background-color: "+i.htmlCls.GREYD+";'>",l+=i.htmlCls.divStr+"mnLogSection'>",l+="
    ",l+=" ",void 0===i.cfg.mmtfid){let e="top:180px; font-size: 1.8em;";l+=i.htmlCls.divStr+"wait' style='position:absolute; left:50px; "+e+" color: #444444;'>Loading data..."}l+="Your browser does not support WebGL.",(void 0===i.cfg.showcommand||i.cfg.showcommand)&&(l+=this.setLogWindow()),l+="",l+="",l+=i.htmlCls.setDialogCls.setDialogs(),l+=i.htmlCls.setDialogCls.setCustomDialogs(),$("#"+e).html(l),$("accordion").accordion({collapsible:!0,active:!1,heightStyle:"content"}),$("accordion div").removeClass("ui-accordion-content ui-corner-all ui-corner-bottom ui-widget-content"),$(".icn3d-mn-item").menu({position:{my:"left top",at:"right top"}}),$(".icn3d-mn-item").hover((function(){}),(function(){$("accordion").accordion("option","active","none")})),$("#"+i.pre+"accordion1").hover((function(){$("#"+i.pre+"accordion1 div").css("display","block")}),(function(){$("#"+i.pre+"accordion1 div").css("display","none")})),$("#"+i.pre+"accordion2").hover((function(){$("#"+i.pre+"accordion2 div").css("display","block")}),(function(){$("#"+i.pre+"accordion2 div").css("display","none")})),$("#"+i.pre+"accordion2b").hover((function(){$("#"+i.pre+"accordion2b div").css("display","block")}),(function(){$("#"+i.pre+"accordion2b div").css("display","none")})),$("#"+i.pre+"accordion3").hover((function(){$("#"+i.pre+"accordion3 div").css("display","block")}),(function(){$("#"+i.pre+"accordion3 div").css("display","none")})),$("#"+i.pre+"accordion4").hover((function(){$("#"+i.pre+"accordion4 div").css("display","block")}),(function(){$("#"+i.pre+"accordion4 div").css("display","none")})),$("#"+i.pre+"accordion5").hover((function(){$("#"+i.pre+"accordion5 div").css("display","block")}),(function(){$("#"+i.pre+"accordion5 div").css("display","none")})),$("#"+i.pre+"accordion6").hover((function(){$("#"+i.pre+"accordion6 div").css("display","block")}),(function(){$("#"+i.pre+"accordion6 div").css("display","none")}))}setTopMenusHtmlMobile(e,t,s){let i=this.icn3dui;if(i.bNode)return"";let n="black"==i.htmlCls.opts.background?i.htmlCls.GREYD:"black",l="";if(l+="
    ",l+=i.htmlCls.divStr+"popup' class='icn3d-text icn3d-popup'>
    ",l+=this.setReplayHtml(),!i.utilsCls.isMobile()){let e=i.htmlCls.WIDTH-40+5;l+=i.htmlCls.buttonStr+"fullscreen' style='position:absolute; z-index:1999; display:block; padding:0px; margin: 12px 0px 0px "+e+"px; width:30px; height:34px; border-radius:4px; border:none; background-color:#f6f6f6;' title='Full screen'>",l+="",l+="",l+="",l+="",l+=""}l+="\x3c!--https://forum.jquery.com/topic/looking-for-a-jquery-horizontal-menu-bar--\x3e",l+=i.htmlCls.divStr+"mnlist' style='position:absolute; z-index:999; float:left; display:block; margin: 5px 0px 0px 5px;'>",l+="
    ",l+="",i.cfg.notebook?l+="

    ":l+="

    ",l+="
    ";let r="
  • File",l+=this.setMenu1_base(),l+=r+">Select",l+=this.setMenu2_base(),l+=r+">View",l+=this.setMenu2b_base(),l+=r+" id='"+i.pre+"style'>Style",l+=this.setMenu3_base(),l+=r+" id='"+i.pre+"color'>Color",l+=this.setMenu4_base(),l+=r+">Analysis",l+=this.setMenu5_base(),l+=r+">Help",l+=this.setMenu6_base(),i.htmlCls.shownMenus=i.hashUtilsCls.cloneHash(i.htmlCls.simpleMenus),l+="
  • "+t,l+="
    "+s,l+="
  • Alternate",l+="",l+="
  • ",l+="
    ",l+="
    ",l+="",l+=i.htmlCls.divStr+"title' class='icn3d-commandTitle' style='font-size:1.2em; font-weight:normal; position:absolute; z-index:1; float:left; display:block; margin: 12px 0px 0px 40px; color:"+n+"; width:"+(i.htmlCls.WIDTH-40).toString()+"px'>",l+=i.htmlCls.divStr+"viewer' style='position:relative; width:100%; height:100%; background-color: "+i.htmlCls.GREYD+";'>",l+=i.htmlCls.divStr+"mnLogSection'>",l+="
    ",l+="",void 0===i.cfg.mmtfid){let e="top:180px; font-size: 1.8em;";l+=i.htmlCls.divStr+"wait' style='position:absolute; left:50px; "+e+" color: #444444;'>Loading data..."}l+="Your browser does not support WebGL.",(void 0===i.cfg.showcommand||i.cfg.showcommand)&&(l+=this.setLogWindow()),l+="",l+="",l+=i.htmlCls.setDialogCls.setDialogs(),l+=i.htmlCls.setDialogCls.setCustomDialogs(),$("#"+e).html(l),$("accordion").accordion({collapsible:!0,active:!1,heightStyle:"content"}),$("accordion div").removeClass("ui-accordion-content ui-corner-all ui-corner-bottom ui-widget-content"),$(".icn3d-mn-item").menu({position:{my:"left top",at:"right top"}}),$(".icn3d-mn-item").hover((function(){}),(function(){$("accordion").accordion("option","active","none")})),$("#"+i.pre+"accordion0").hover((function(){$("#"+i.pre+"accordion0 div").css("display","block")}),(function(){$("#"+i.pre+"accordion0 div").css("display","none")}))}setReplayHtml(e){let t=this.icn3dui;if(t.bNode)return"";let s="";return s+=t.htmlCls.divStr+"replay' style='display:none; position:absolute; z-index:9999; top:"+parseInt(t.htmlCls.HEIGHT-100).toString()+"px; left:20px;'>",s+="
    ",s+='',s+="",s+='',s+='',s+="",s+="
    ",s+=t.htmlCls.divStr+"replay_menu' style='background-color:#DDDDDD; padding:3px; font-weight:bold;'>",s+=t.htmlCls.divStr+"replay_cmd' style='background-color:#DDDDDD; padding:3px; max-width:250px'>",s+="",s}setTools(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+=e.htmlCls.divStr+"selection' style='display:none;'>
    ",t+="",t+=this.setTools_base(),t+="
    ",t+="
    ",t}setButton(e,t,s,i,n){let l=this.icn3dui;return l.bNode?"":(n=void 0!==n?"color:"+n:"","
    ")}setIcon(e,t,s,i,n,l,r){let o=this.icn3dui;if(o.bNode)return"";let a,d=r?"color:#f8b84e; ":"color:#1c94c4; ",c=" background-color:#EEE; ",h="text"==e?"":"cursor:pointer;";return a=l?'
    '+i+"
    ":'',"link"==e?''+a+"":a}setTools_base(){if(this.icn3dui.bNode)return"";let e="",t="regular",s="",i="";return e+=s+this.setIcon(t,"tool_mmdbafid","Input PDB/MMDB/AlphaFold IDs","id",void 0,!0)+"",e+=s+this.setIcon(t,"tool_pdbfile","Input PDB Files (appendable)","file-alt")+"",e+=s+this.setIcon(t,"tool_sharelink","Get Share Link","link")+"",e+=s+this.setIcon(t,"saveimage","Save iCn3D PNG Image","camera")+"",e+=i+this.setIcon(t,"tool_definedsets","Defined Sets","object-group")+"",e+=s+this.setIcon(t,"tool_aroundsphere","Select by Distance","dot-circle")+"",e+=s+this.setIcon(t,"tool_saveselection","Save Selection as a Set","save")+"",e+=s+this.setIcon(t,"toggleHighlight","Toggle Highlight","highlighter")+"",e+=i+this.setIcon(t,"show_selected","View Selection","eye")+"",e+=s+this.setIcon(t,"tool_selectedcenter","Zoom in Selection","search-plus")+"",e+=s+this.setIcon(t,"alternate","Alternate the Structures by keying the letter 'a'","a",void 0,!0,!0)+"",e+=s+this.setIcon(t,"tool_resetOrientation","Reset Orientation","undo-alt")+"",e+=i+this.setIcon(t,"tool_proteinsRibbon","Style Ribbon for proteins","dna")+"",e+=s+this.setIcon(t,"tool_proteinsSphere","Style Sphere for proteins","volleyball-ball")+"",e+=s+this.setIcon(t,"tool_surfaceVDW","Show Van der Waals Surface","cloud")+"",e+=s+this.setIcon(t,"tool_bkgd","Toggle Background Color","adjust")+"",e+=i+this.setIcon(t,"tool_clrRainbowChain","Color Rainbow for Chains","rainbow")+"",e+=s+this.setIcon(t,"tool_clrSSGreen","Color by Secondary Structures","ring")+"",e+=s+this.setIcon(t,"tool_clrChain","Color by Chains","layer-group")+"",e+=s+this.setIcon(t,"tool_clrAtom","Color by Atoms","atom")+"",e+=i+this.setIcon(t,"tool_selectannotations","Sequences & Annotations","grip-lines")+"",e+=s+this.setIcon(t,"hbondsYes","Interactions","users")+"",e+=s+this.setIcon(t,"tool_delphi","Delphi Potentials","cloud-meatball")+"",e+=s+this.setIcon(t,"removeLabels","Remove Labels","remove-format")+"",e+=i+this.setIcon("link","tool-gallery","Gallery","image","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#gallery")+"",e+=s+this.setIcon("link","tool-video","Videos","file-video","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#videos")+"",e+=s+this.setIcon("link","tool-github","iCn3D GitHub","code","https://github.com/ncbi/icn3d")+"",e+=s+this.setIcon("link","tool-hints","Transform Hints","info-circle","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#useicn3d")+"",e+="",e}setTheme(e){let t,s,i,n,l,r=this.icn3dui;if(r.bNode)return"";r.htmlCls.themecolor=e,"orange"==e?(t="#e78f08",s="#f6a828",i="ui-bg_gloss-wave_35_f6a828_500x100.png",n="ui-icons_ef8c08_256x240.png",l="#eb8f00"):"black"==e?(t="#333333",s="#333333",i="ui-bg_gloss-wave_25_333333_500x100.png",n="ui-icons_222222_256x240.png",l="#222222"):"blue"==e&&(t="#4297d7",s="#5c9ccc",i="ui-bg_gloss-wave_55_5c9ccc_500x100.png",n="ui-icons_228ef1_256x240.png",l="#444"),$(".ui-widget-header").css({border:"1px solid "+t,background:s+' url("https://www.ncbi.nlm.nih.gov/Structure/icn3d/lib/images/'+i+'") 50% 50% repeat-x',color:"#fff","font-weight":"bold"}),$(".ui-button .ui-icon").css({"background-image":"url(https://www.ncbi.nlm.nih.gov/Structure/icn3d/lib/images/"+n+")"}),$(".ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited").css({color:l,"text-decoration":"none"})}setLogWindow(e,t){let s=this.icn3dui;if(s.bNode)return"";let i,n="",l=s.htmlCls.setHtmlCls.getCookie("cmdwindow");return""!=l?(i=void 0!==t?t:parseInt(l),1==i?(s.htmlCls.LOG_HEIGHT=180,s.htmlCls.CMD_HEIGHT=.8*s.htmlCls.LOG_HEIGHT,e||(n+=s.htmlCls.divStr+"cmdlog' style='float:left; margin-top: 5px; width: 100%;'>"),n+=""):(s.htmlCls.LOG_HEIGHT=65,s.htmlCls.CMD_HEIGHT=.8*s.htmlCls.LOG_HEIGHT,e||(n+=s.htmlCls.divStr+"cmdlog' style='float:left; margin-top: 5px; width: 100%;'>"),n+="")):(i=0,s.htmlCls.LOG_HEIGHT=65,s.htmlCls.CMD_HEIGHT=.8*s.htmlCls.LOG_HEIGHT,e||(n+=s.htmlCls.divStr+"cmdlog' style='float:left; margin-top: 5px; width: 100%;'>"),n+=""),e||(n+=""),e&&(s.htmlCls.clickMenuCls.setLogCmd("set cmdwindow "+i,!0),$("#"+s.pre+"cmdlog").html(n)),n}setMenu1(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
    ",t+="",t+="

    File

    ",t+="
    ",t+=this.setMenu1_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu1_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getMenuText("mn1_searchgrooup","Search Structure "+e.htmlCls.wifiStr,void 0,1,1),t+="
        ",t+=this.getMenuUrl("mn1_searchstru","https://www.ncbi.nlm.nih.gov/structure","PDB Structures "+e.htmlCls.wifiStr,1,2),t+=this.getLink("mn1_proteinname","AlphaFold Structures "+e.htmlCls.wifiStr,1,2),t+=this.getMenuUrl("mn1_afdatabase","https://alphafold.ebi.ac.uk","AlphaFold UniProt Database "+e.htmlCls.wifiStr,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn1_searchsimilar","Search Similar"+e.htmlCls.wifiStr,void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_vastplus","NCBI VAST+ (PDB Complex)"+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_vast","NCBI VAST (PDB Chain)"+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_foldseek","Foldseek (PDB & AlphaFold)"+e.htmlCls.wifiStr,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn1_retrievebyid","Retrieve by ID",void 0,1,1),t+="
        ",t+=this.getLink("mn1_mmdbafid","PDB/MMDB/AlphaFold IDs"+e.htmlCls.wifiStr,1,2),t+=this.getLink("mn1_mmdbid","NCBI MMDB ID (annotation) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_mmtfid","RCSB MMTF ID (fast) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_pdbid","RCSB PDB ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getMenuText("mn1_afwrap","AlphaFold Structures",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_afid","UniProt ID "+e.htmlCls.wifiStr,void 0,3),t+=this.getLink("mn1_refseqid","NCBI Protein Accession "+e.htmlCls.wifiStr,void 0,3),t+="
        ",t+=this.getLink("mn1_opmid","OPM PDB ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_mmcifid","RCSB mmCIF ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_cid","PubChem CID "+e.htmlCls.wifiStr,1,2),t+="
      ",t+="",t+=this.getMenuText("mn1_openfile","Open File",void 0,1,1),t+="
        ",t+=this.getLink("mn1_pdbfile_app","PDB Files (appendable)",1,2),t+=this.getLink("mn1_mmciffile","mmCIF File",void 0,2),t+=this.getLink("mn1_mol2file","Mol2 File",void 0,2),t+=this.getLink("mn1_sdffile","SDF File",void 0,2),t+=this.getLink("mn1_xyzfile","XYZ File",void 0,2),t+=this.getLink("mn1_afmapfile","AlphaFold PAE File",void 0,2),t+=this.getLink("mn1_urlfile","URL(CORS) "+e.htmlCls.wifiStr,void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_pngimage","iCn3D PNG Image",1,2),t+=this.getLink("mn1_state","State/Script File",void 0,2),t+=this.getLink("mn1_fixedversion","Share Link in Archived Ver. "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_selection","Selection File",void 0,2),t+=this.getMenuSep(),t+=this.getMenuText("mn1_dsn6wrap","Electron Density",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_dsn6","Local File",void 0,3),t+=this.getLink("mn1_dsn6url","URL(CORS) "+e.htmlCls.wifiStr,void 0,3),t+="
        ",t+="
      ",t+="",t+=this.getMenuText("mn1_fold","Predict by Seq.",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_esmfold","ESMFold",void 0,2),t+=this.getLink("mn1_alphafold","AlphaFold2 via ColabFold"+e.htmlCls.wifiStr,void 0,2),t+="
      ",t+=this.getMenuText("mn1_alignwrap","Align",void 0,1,1),t+="
        ",t+=this.getMenuText("mn1_chainalignwrap","Multiple Chains",void 0,1,2),t+="
          ",t+=this.getRadio("mn1_chainalignRad","mn1_chainalign","by Structure Alignment "+e.htmlCls.wifiStr,void 0,1,3),t+=this.getRadio("mn1_chainalignRad","mn1_chainalign2","by Sequence Alignment "+e.htmlCls.wifiStr,void 0,1,3),t+=this.getRadio("mn1_chainalignRad","mn1_chainalign3","Residue by Residue",void 0,void 0,3),t+="
        ",t+="",t+=this.getMenuText("mn1_aligntwostru","Protein Complexes",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_align","Two PDB Structures "+e.htmlCls.wifiStr,void 0,3),t+=this.getLink("mn1_alignaf","Two AlphaFold Structures "+e.htmlCls.wifiStr,void 0,3),t+="
        ",t+=this.getLink("mn1_blast_rep_id","Sequence to Structure",void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn2_realignWrap","Realign Selection",void 0,void 0,1),t+="
        ",t+=this.getMenuText("mn2_chainrealignwrap","Multiple Chains",void 0,void 0,2),t+="
          ",t+=this.getRadio("mn2_realign","mn2_realignonstruct","by Structure Alignment "+e.htmlCls.wifiStr,void 0,void 0,3),t+=this.getRadio("mn2_realign","mn2_realignonseqalign","by Sequence Alignment "+e.htmlCls.wifiStr,void 0,void 0,3),t+=this.getRadio("mn2_realign","mn2_realignresbyres","Residue by Residue",void 0,void 0,3),t+="
        ",t+=this.getLink("mn2_realigntwostru","Protein Complexes",void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn1_3dpprint","3D Printing",void 0,1,1),t+="
        ",void 0===e.cfg.cid?(t+=this.getLink("mn1_exportVrmlStab","WRL/VRML(Color, W/ Stab.)",1,2),t+=this.getLink("mn1_exportStlStab","STL(W/ Stabilizers)",1,2),t+=this.getMenuSep(),t+=this.getLink("mn1_exportVrml","WRL/VRML(Color)",void 0,2),t+=this.getLink("mn1_exportStl","STL",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_stabilizerYes","Add All Stabilizers",void 0,2),t+=this.getLink("mn1_stabilizerNo","Remove All Stabilizers",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_stabilizerOne","Add One Stabilizer",void 0,2),t+=this.getLink("mn1_stabilizerRmOne","Remove One Stabilizer",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_thicknessSet","Set Thickness",void 0,2)):(t+=this.getLink("mn1_exportVrml","VRML(Color)",1,2),t+=this.getLink("mn1_exportStl","STL",1,2)),t+="
      ",t+="",t+=this.getMenuText("mn1_savefile","Save File",void 0,1,1),t+="
        ",t+=this.getMenuText("mn1_savepngimage","iCn3D PNG Image",void 0,1,2),t+="
          ",t+=this.getLink("mn1_exportCanvas","Original Size & HTML",1,3),t+=this.getLink("mn1_exportCanvas1","Original Size",void 0,3),t+=this.getLink("mn1_exportCanvas2","2X Large",void 0,3),t+=this.getLink("mn1_exportCanvas4","4X Large",void 0,3),t+=this.getLink("mn1_exportCanvas8","8X Large",void 0,3),t+="
        ",t+="",t+=this.getLink("mn1_exportState","State File",void 0,2),t+=this.getLink("mn1_exportSelections","Selection File",void 0,2),t+=this.getLink("mn1_exportSelDetails","Selection Details",void 0,2),t+=this.getLink("mn1_exportCounts","Residue Counts",void 0,2),t+=this.getLink("mn1_exportPdbRes","PDB",1,2),t+=this.getLink("profixpdb","PDB with Missing Atoms",void 0,2),void 0===e.cfg.cid&&(t+=this.getLink("mn1_exportSecondary","Secondary Structure",void 0,2)), +var icn3d=function(e){"use strict";class t{constructor(e){this.icn3dui=e}cloneHash(e){this.icn3dui;let t={};void 0===e&&(e={});for(let s in e)t[s]=e[s];return t}intHash(e,t){this.icn3dui;let s={};if(void 0===e&&(e={}),void 0===t&&(t={}),Object.keys(e).length0||window.navigator.userAgent.match(/Trident.*rv\:11\./))}isMobile(){return this.icn3dui,/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)}isMac(){return this.icn3dui,/Mac/i.test(window.navigator.userAgent)}isAndroid(){return this.icn3dui,/android/i.test(window.navigator.userAgent.toLowerCase())}isChrome(){return this.icn3dui,navigator.userAgent.includes("Chrome")&&navigator.vendor.includes("Google Inc")}isSessionStorageSupported(){return this.icn3dui,window.sessionStorage}isLocalStorageSupported(){return this.icn3dui,window.localStorage}hexToRgb(e,t){this.icn3dui;let s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return s?{r:parseInt(s[1],16),g:parseInt(s[2],16),b:parseInt(s[3],16),a:t}:null}isCalphaPhosOnly(e){this.icn3dui;let t=!1,s=0,i=0;for(let t in e){if(!(s<100))break;{let s=e[t].name.trim();"CA"!==s&&"P"!==s&&"O3'"!==s&&"O3*"!==s&&++i}++s}return i<.5*s&&(t=!0),t}hasCovalentBond(e,t){let s=this.icn3dui,i=s.parasCls.covalentRadii[e.elem.toUpperCase()]+s.parasCls.covalentRadii[t.elem.toUpperCase()],n=e.coord.x-t.coord.x,l=e.coord.y-t.coord.y,r=e.coord.z-t.coord.z;return n*n+l*l+r*r<("N"==e.elem&&"H"==t.elem.substr(0,1)||"N"==t.elem&&"H"==e.elem.substr(0,1)?2.2:1.3)*i*i}residueName2Abbr(e){this.icn3dui;let t=e.indexOf(" ");switch(t>0&&(e=e.substr(0,t)),e){case" A":case" DA":case"DA":case"ALA":return"A";case" C":case" DC":case"DC":case"CYS":return"C";case" G":case" DG":case"DG":case"GLY":return"G";case" T":case" DT":case"DT":case"THR":return"T";case" U":case" DU":case"DU":case"SEC":return"U";case" I":case" DI":case"DI":case"ILE":return"I";case"ARG":return"R";case"ASN":return"N";case"ASP":return"D";case"GLU":return"E";case"GLN":return"Q";case"HIS":return"H";case"LEU":return"L";case"LYS":return"K";case"MET":return"M";case"PHE":return"F";case"PRO":return"P";case"SER":return"S";case"TRP":return"W";case"TYR":return"Y";case"VAL":return"V";case"HOH":case"WAT":return"O";default:return e.trim()}}residueAbbr2Name(e){if(this.icn3dui,(e=e.toUpperCase()).length>1)return e;switch(e){case"A":return"ALA";case"R":return"ARG";case"N":return"ASN";case"D":return"ASP";case"C":return"CYS";case"E":return"GLU";case"Q":return"GLN";case"G":return"GLY";case"H":return"HIS";case"I":return"ILE";case"L":return"LEU";case"K":return"LYS";case"M":return"MET";case"F":return"PHE";case"P":return"PRO";case"S":return"SER";case"T":return"THR";case"W":return"TRP";case"Y":return"TYR";case"V":return"VAL";case"O":return"HOH";default:return e.trim()}}getJSONFromArray(e){this.icn3dui;let t="";for(let s=0,i=e.length;sd?1:ah?1:cs&&(e.htmlCls.WIDTH=s),i&&e.htmlCls.HEIGHT>i&&(e.htmlCls.HEIGHT=i)}sumArray(e){let t=0;for(let s=0,i=e.length;sRed and blue membranes indicate extracellular and intracellular membranes, respectively.

        "}getStructures(e){let t=this.icn3dui,s={};for(let i in e){s[t.icn3d.atoms[i].structure]=1}return s}getHlStructures(e){let t=this.icn3dui;return e||(e=t.icn3d.hAtoms),this.getStructures(e)}getDisplayedStructures(e){let t=this.icn3dui;return e||(e=t.icn3d.dAtoms),this.getStructures(e)}getDateDigitStr(){this.icn3dui;let e=new Date,t=(e.getMonth()+1).toString();e.getMonth()+1<10&&(t="0"+t);let s=e.getDate().toString();return e.getDate()<10&&(s="0"+s),e.getFullYear().toString()+t+s}}class i{constructor(e){this.icn3dui=e,this.glycanHash={GLC:{c:"1E90FF",s:"sphere"},BGC:{c:"1E90FF",s:"sphere"},NAG:{c:"1E90FF",s:"cube"},NDG:{c:"1E90FF",s:"cube"},GCS:{c:"1E90FF",s:"cube"},PA1:{c:"1E90FF",s:"cube"},GCU:{c:"1E90FF",s:"cone"},BDP:{c:"1E90FF",s:"cone"},G6D:{c:"1E90FF",s:"cone"},DDA:{c:"1E90FF",s:"cylinder"},B6D:{c:"1E90FF",s:"cylinder"},XXM:{c:"1E90FF",s:"cylinder"},MAN:{c:"00FF00",s:"sphere"},BMA:{c:"00FF00",s:"sphere"},BM3:{c:"00FF00",s:"cube"},"95Z":{c:"00FF00",s:"cube"},MAV:{c:"00FF00",s:"cone"},BEM:{c:"00FF00",s:"cone"},RAM:{c:"00FF00",s:"cone"},RM4:{c:"00FF00",s:"cone"},TYV:{c:"00FF00",s:"cylinder"},ARA:{c:"00FF00",s:"cylinder"},ARB:{c:"00FF00",s:"cylinder"},KDN:{c:"00FF00",s:"cylinder"},KDM:{c:"00FF00",s:"cylinder"},"6PZ":{c:"00FF00",s:"cylinder"},GMH:{c:"00FF00",s:"cylinder"},BDF:{c:"00FF00",s:"cylinder"},GAL:{c:"FFFF00",s:"sphere"},GLA:{c:"FFFF00",s:"sphere"},NGA:{c:"FFFF00",s:"cube"},A2G:{c:"FFFF00",s:"cube"},X6X:{c:"FFFF00",s:"cube"},"1GN":{c:"FFFF00",s:"cube"},ADA:{c:"FFFF00",s:"cone"},GTR:{c:"FFFF00",s:"cone"},LDY:{c:"FFFF00",s:"cylinder"},KDO:{c:"FFFF00",s:"cylinder"},T6T:{c:"FFFF00",s:"cylinder"},GUP:{c:"A52A2A",s:"sphere"},GL0:{c:"A52A2A",s:"sphere"},LGU:{c:"A52A2A",s:"cone"},ABE:{c:"A52A2A",s:"cylinder"},XYS:{c:"A52A2A",s:"cylinder"},XYP:{c:"A52A2A",s:"cylinder"},SOE:{c:"A52A2A",s:"cylinder"},PZU:{c:"FF69B4",s:"cylinder"},RIP:{c:"FF69B4",s:"cylinder"},"0MK":{c:"FF69B4",s:"cylinder"},ALL:{c:"8A2BE2",s:"sphere"},AFD:{c:"8A2BE2",s:"sphere"},NAA:{c:"8A2BE2",s:"cube"},SIA:{c:"8A2BE2",s:"cylinder"},SIB:{c:"8A2BE2",s:"cylinder"},AMU:{c:"8A2BE2",s:"cylinder"},X0X:{c:"1E90FF",s:"cone"},X1X:{c:"1E90FF",s:"cone"},NGC:{c:"1E90FF",s:"cylinder"},NGE:{c:"1E90FF",s:"cylinder"},"4N2":{c:"A0522D",s:"sphere"},HSQ:{c:"A0522D",s:"cube"},IDR:{c:"A0522D",s:"cone"},MUR:{c:"A0522D",s:"cylinder"},FUC:{c:"FF0000",s:"cone"},FUL:{c:"FF0000",s:"cone"}},this.nucleotidesArray=[" G"," A"," T"," C"," U"," DG"," DA"," DT"," DC"," DU","G","A","T","C","U","DG","DA","DT","DC","DU"],this.ionsArray=[" K"," NA"," MG"," AL"," CA"," TI"," MN"," FE"," NI"," CU"," ZN"," AG"," BA"," F"," CL"," BR"," I","K","NA","MG","AL","CA","TI","MN","FE","NI","CU","ZN","AG","BA","F","CL","BR","I"],this.cationsTrimArray=["K","NA","MG","AL","CA","TI","MN","FE","NI","CU","ZN","AG","BA"],this.anionsTrimArray=["F","CL","BR","I"],this.ionCharges={K:1,NA:1,MG:2,AL:3,CA:2,TI:3,MN:2,FE:3,NI:2,CU:2,ZN:2,AG:1,BA:2},this.vdwRadii={H:1.08,HE:1.34,LI:1.75,BE:2.05,B:1.47,C:1.49,N:1.41,O:1.4,F:1.39,NE:1.68,NA:1.84,MG:2.05,AL:2.11,SI:2.07,P:1.92,S:1.82,CL:1.83,AR:1.93,K:2.05,CA:2.21,SC:2.16,TI:1.87,V:1.79,CR:1.89,MN:1.97,FE:1.94,CO:1.92,NI:1.84,CU:1.86,ZN:2.1,GA:2.08,GE:2.15,AS:2.06,SE:1.93,BR:1.98,KR:2.12,RB:2.16,SR:2.24,Y:2.19,ZR:1.86,NB:2.07,MO:2.09,TC:2.09,RU:2.07,RH:1.95,PD:2.02,AG:2.03,CD:2.3,IN:2.36,SN:2.33,SB:2.25,TE:2.23,I:2.23,XE:2.21,CS:2.22,BA:2.51,LA:2.4,CE:2.35,PR:2.39,ND:2.29,PM:2.36,SM:2.29,EU:2.33,GD:2.37,TB:2.21,DY:2.29,HO:2.16,ER:2.35,TM:2.27,YB:2.42,LU:2.21,HF:2.12,TA:2.17,W:2.1,RE:2.17,OS:2.16,IR:2.02,PT:2.09,AU:2.17,HG:2.09,TL:2.35,PB:2.32,BI:2.43,PO:2.29,AT:2.36,RN:2.43,FR:2.56,RA:2.43,AC:2.6,TH:2.37,PA:2.43,U:2.4,NP:2.21,PU:2.56,AM:2.56,CM:2.56,BK:2.56,CF:2.56,ES:2.56,FM:2.56},this.covalentRadii={H:.31,HE:.28,LI:1.28,BE:.96,B:.84,C:.76,N:.71,O:.66,F:.57,NE:.58,NA:1.66,MG:1.41,AL:1.21,SI:1.11,P:1.07,S:1.05,CL:1.02,AR:1.06,K:2.03,CA:1.76,SC:1.7,TI:1.6,V:1.53,CR:1.39,MN:1.39,FE:1.32,CO:1.26,NI:1.24,CU:1.32,ZN:1.22,GA:1.22,GE:1.2,AS:1.19,SE:1.2,BR:1.2,KR:1.16,RB:2.2,SR:1.95,Y:1.9,ZR:1.75,NB:1.64,MO:1.54,TC:1.47,RU:1.46,RH:1.42,PD:1.39,AG:1.45,CD:1.44,IN:1.42,SN:1.39,SB:1.39,TE:1.38,I:1.39,XE:1.4,CS:2.44,BA:2.15,LA:2.07,CE:2.04,PR:2.03,ND:2.01,PM:1.99,SM:1.98,EU:1.98,GD:1.96,TB:1.94,DY:1.92,HO:1.92,ER:1.89,TM:1.9,YB:1.87,LU:1.87,HF:1.75,TA:1.7,W:1.62,RE:1.51,OS:1.44,IR:1.41,PT:1.36,AU:1.36,HG:1.32,TL:1.45,PB:1.46,BI:1.48,PO:1.4,AT:1.5,RN:1.5,FR:2.6,RA:2.21,AC:2.15,TH:2.06,PA:2,U:1.96,NP:1.9,PU:1.87,AM:1.8,CM:1.69},this.atomColors={H:this.thr(16777215),He:this.thr(16761035),HE:this.thr(16761035),Li:this.thr(11674146),LI:this.thr(11674146),B:this.thr(65280),C:this.thr(11184810),N:this.thr(255),O:this.thr(15728640),F:this.thr(14329120),Na:this.thr(255),NA:this.thr(255),Mg:this.thr(2263842),MG:this.thr(2263842),Al:this.thr(8421520),AL:this.thr(8421520),Si:this.thr(14329120),SI:this.thr(14329120),P:this.thr(16753920),S:this.thr(16762930),Cl:this.thr(65280),CL:this.thr(65280),Ca:this.thr(8421520),CA:this.thr(8421520),Ti:this.thr(8421520),TI:this.thr(8421520),Cr:this.thr(8421520),CR:this.thr(8421520),Mn:this.thr(8421520),MN:this.thr(8421520),Fe:this.thr(16753920),FE:this.thr(16753920),Ni:this.thr(10824234),NI:this.thr(10824234),Cu:this.thr(10824234),CU:this.thr(10824234),Zn:this.thr(10824234),ZN:this.thr(10824234),Br:this.thr(10824234),BR:this.thr(10824234),Ag:this.thr(8421520),AG:this.thr(8421520),I:this.thr(10494192),Ba:this.thr(16753920),BA:this.thr(16753920),Au:this.thr(14329120),AU:this.thr(14329120)},this.atomnames={H:"Hydrogen",HE:"Helium",LI:"Lithium",B:"Boron",C:"Carbon",N:"Nitrogen",O:"Oxygen",F:"Fluorine",NA:"Sodium",MG:"Magnesium",AL:"Aluminum",SI:"Silicon",P:"Phosphorus",S:"Sulfur",CL:"Chlorine",CA:"Calcium",TI:"Titanium",CR:"Chromium",MN:"Manganese",FE:"Iron",NI:"Nickel",CU:"Copper",ZN:"Zinc",BR:"Bromine",AG:"Silver",I:"Iodine",BA:"Barium",AU:"Gold"},this.defaultAtomColor=this.thr(13421772),this.stdChainColors=[this.thr(16711935),this.thr(255),this.thr(10053171),this.thr(65433),this.thr(16750848),this.thr(16737894),this.thr(3329330),this.thr(2003199),this.thr(16416882),this.thr(16753920),this.thr(52945),this.thr(16738740),this.thr(65280),this.thr(255),this.thr(16711680),this.thr(16776960),this.thr(65535),this.thr(16711935),this.thr(3978097),this.thr(4620980),this.thr(13458524),this.thr(16770229),this.thr(11529966),this.thr(15631086),this.thr(25600),this.thr(139),this.thr(9109504),this.thr(13468991),this.thr(35723),this.thr(9699539)],this.backgroundColors={black:this.thr(0),grey:this.thr(13421772),white:this.thr(16777215),transparent:this.thr(16777215)},this.residueColors={ALA:this.thr(13158600),ARG:this.thr(1334015),ASN:this.thr(56540),ASP:this.thr(15075850),CYS:this.thr(15132160),GLN:this.thr(56540),GLU:this.thr(15075850),GLY:this.thr(15461355),HIS:this.thr(8553170),ILE:this.thr(1016335),LEU:this.thr(1016335),LYS:this.thr(1334015),MET:this.thr(15132160),PHE:this.thr(3289770),PRO:this.thr(14456450),SER:this.thr(16422400),THR:this.thr(16422400),TRP:this.thr(11819700),TYR:this.thr(3289770),VAL:this.thr(1016335),ASX:this.thr(16738740),GLX:this.thr(16738740),G:this.thr(32768),A:this.thr(6324479),T:this.thr(16744448),C:this.thr(16711680),U:this.thr(16744448),DG:this.thr(32768),DA:this.thr(6324479),DT:this.thr(16744448),DC:this.thr(16711680),DU:this.thr(16744448)},this.residueArea={ALA:247,ARG:366,ASN:290,ASP:285,CYS:271,GLN:336,GLU:325,GLY:217,HIS:340,ILE:324,LEU:328,LYS:373,MET:346,PHE:366,PRO:285,SER:265,THR:288,TRP:414,TYR:387,VAL:293,ASX:290,GLX:336,G:520,A:507,T:515,C:467,U:482,DG:520,DA:507,DT:515,DC:467,DU:482},this.defaultResidueColor=this.thr(12492910),this.chargeColors={" G":this.thr(16711680)," A":this.thr(16711680)," T":this.thr(16711680)," C":this.thr(16711680)," U":this.thr(16711680)," DG":this.thr(16711680)," DA":this.thr(16711680)," DT":this.thr(16711680)," DC":this.thr(16711680)," DU":this.thr(16711680),G:this.thr(16711680),A:this.thr(16711680),T:this.thr(16711680),C:this.thr(16711680),U:this.thr(16711680),DG:this.thr(16711680),DA:this.thr(16711680),DT:this.thr(16711680),DC:this.thr(16711680),DU:this.thr(16711680),ARG:this.thr(255),LYS:this.thr(255),ASP:this.thr(16711680),GLU:this.thr(16711680),HIS:this.thr(8421631),GLY:this.thr(8947848),PRO:this.thr(8947848),ALA:this.thr(8947848),VAL:this.thr(8947848),LEU:this.thr(8947848),ILE:this.thr(8947848),PHE:this.thr(8947848),SER:this.thr(8947848),THR:this.thr(8947848),ASN:this.thr(8947848),GLN:this.thr(8947848),TYR:this.thr(8947848),MET:this.thr(8947848),CYS:this.thr(8947848),TRP:this.thr(8947848)},this.hydrophobicColors={" G":this.thr(16711680)," A":this.thr(16711680)," T":this.thr(16711680)," C":this.thr(16711680)," U":this.thr(16711680)," DG":this.thr(16711680)," DA":this.thr(16711680)," DT":this.thr(16711680)," DC":this.thr(16711680)," DU":this.thr(16711680),G:this.thr(16711680),A:this.thr(16711680),T:this.thr(16711680),C:this.thr(16711680),U:this.thr(16711680),DG:this.thr(16711680),DA:this.thr(16711680),DT:this.thr(16711680),DC:this.thr(16711680),DU:this.thr(16711680),ARG:this.thr(255),LYS:this.thr(255),ASP:this.thr(16711680),GLU:this.thr(16711680),HIS:this.thr(8421631),TRP:this.thr().setHSL(1/3,1,.5),PHE:this.thr().setHSL(1/3,1,.5909090909090908),LEU:this.thr().setHSL(1/3,1,.700956937799043),ILE:this.thr().setHSL(1/3,1,.7320574162679425),TYR:this.thr().setHSL(1/3,1,.5+.69/2.09),MET:this.thr().setHSL(1/3,1,.5+.71/2.09),VAL:this.thr().setHSL(1/3,1,.5+.815/2.09),CYS:this.thr().setHSL(1/3,1,.5+1.035/2.09),PRO:this.thr().setHSL(1/6,1,.9391304347826086),THR:this.thr().setHSL(1/6,1,.8913043478260869),SER:this.thr().setHSL(1/6,1,.8),ALA:this.thr().setHSL(1/6,1,.7826086956521738),GLN:this.thr().setHSL(1/6,1,.6652173913043478),ASN:this.thr().setHSL(1/6,1,.6304347826086956),GLY:this.thr().setHSL(1/6,1,.5)},this.normalizedHPColors={" G":this.thr(16777215)," A":this.thr(16777215)," T":this.thr(16777215)," C":this.thr(16777215)," U":this.thr(16777215)," DG":this.thr(16777215)," DA":this.thr(16777215)," DT":this.thr(16777215)," DC":this.thr(16777215)," DU":this.thr(16777215),G:this.thr(16777215),A:this.thr(16777215),T:this.thr(16777215),C:this.thr(16777215),U:this.thr(16777215),DG:this.thr(16777215),DA:this.thr(16777215),DT:this.thr(16777215),DC:this.thr(16777215),DU:this.thr(16777215),ARG:this.thr(16777215),LYS:this.thr(16777215),ASP:this.thr(16777215),GLU:this.thr(16777215),HIS:this.thr(16777215),TRP:this.thr().setHSL(1/3,1,.5),PHE:this.thr().setHSL(1/3,1,.558641975308642),LEU:this.thr().setHSL(1/3,1,.6296296296296295),ILE:this.thr().setHSL(1/3,1,.6496913580246912),TYR:this.thr().setHSL(1/3,1,.5+.69/3.24),MET:this.thr().setHSL(1/3,1,.5+.71/3.24),VAL:this.thr().setHSL(1/3,1,.5+.815/3.24),CYS:this.thr().setHSL(1/3,1,.5+1.035/3.24),PRO:this.thr().setHSL(1/3,1,.5+1.115/3.24),THR:this.thr().setHSL(1/3,1,.5+1.17/3.24),SER:this.thr().setHSL(1/3,1,.5+1.275/3.24),ALA:this.thr().setHSL(1/3,1,.5+1.295/3.24),GLN:this.thr().setHSL(1/3,1,.5+1.43/3.24),ASN:this.thr().setHSL(1/3,1,.5+1.47/3.24),GLY:this.thr().setHSL(1/3,1,1)},this.hydrophobicValues={" G":3," A":3," T":3," C":3," U":3," DG":3," DA":3," DT":3," DC":3," DU":3,G:3,A:3,T:3,C:3,U:3,DG:3,DA:3,DT:3,DC:3,DU:3,ARG:1.5,LYS:1.5,ASP:3,GLU:3,HIS:2,TRP:-2.09,PHE:-1.71,LEU:-1.25,ILE:-1.12,TYR:-.71,MET:-.67,VAL:-.46,CYS:-.02,PRO:.14,THR:.25,SER:.46,ALA:.5,GLN:.77,ASN:.85,GLY:1.15},this.residueAbbrev={ALA:"A (Ala)",ARG:"R (Arg)",ASN:"N (Asn)",ASP:"D (Asp)",CYS:"C (Cys)",GLN:"Q (Gln)",GLU:"E (Glu)",GLY:"G (Gly)",HIS:"H (His)",ILE:"I (Ile)",LEU:"L (Leu)",LYS:"K (Lys)",MET:"M (Met)",PHE:"F (Phe)",PRO:"P (Pro)",SER:"S (Ser)",THR:"T (Thr)",TRP:"W (Trp)",TYR:"Y (Tyr)",VAL:"V (Val)",ASX:"X (Asx)",GLX:"X (Glx)",G:"Guanine",A:"Adenine",T:"Thymine",C:"Cytosine",U:"Uracil",DG:"deoxy-Guanine",DA:"deoxy-Adenine",DT:"deoxy-Thymine",DC:"deoxy-Cytosine",DU:"deoxy-Uracil"},this.ssColors={helix:this.thr(16711680),sheet:this.thr(32768),coil:this.thr(6324479)},this.ssColors2={helix:this.thr(16711680),sheet:this.thr(16762880),coil:this.thr(6324479)},this.resn2restype={ALA:1,ARG:4,ASN:7,ASP:10,CYS:13,GLN:16,GLU:19,GLY:22,HIS:25,ILE:28,LEU:31,LYS:34,MET:37,PHE:40,PRO:43,SER:46,THR:49,TRP:52,TYR:55,VAL:58},this.nuclMainArray=["C1'","C1*","C2'","C2*","C3'","C3*","C4'","C4*","C5'","C5*","O3'","O3*","O4'","O4*","O5'","O5*","P","OP1","O1P","OP2","O2P"],this.b62ResArray=["A","R","N","D","C","Q","E","G","H","I","L","K","M","F","P","S","T","W","Y","V","B","Z","X","*"],this.b62Matrix=[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1,-4],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1,-4],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2,-4],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1,-4],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1,-4],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1,-4],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2,-4],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0,-4],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0,-4],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]]}thr(e){return this.icn3dui,"#0"==e&&(e="#000"),new THREE.Color(e)}}class n{constructor(e){this.icn3dui=e}onId(e,t,s){if(this.icn3dui,!(Object.keys(window).length<2)&&("#"==e.substr(0,1)&&(e=e.substr(1)),document.getElementById(e))){t.split(" ").forEach((t=>{document.getElementById(e).addEventListener(t,s)}))}}onIds(e,t,s){let i=this.icn3dui;Array.isArray(e)?e.forEach((e=>{i.myEventCls.onId(e,t,s)})):i.myEventCls.onId(e,t,s)}}class l{constructor(e){this.icn3dui=e}getRmsdSuprCls(e,t,s){let i,n,l,r,o,a,d,c,h,p,m,u,g,f=this.icn3dui,b=new Array(9),C=new THREE.Vector3,y=new THREE.Vector3,v=[],_=[],w=new Array(3),S=new Array(3),A=new Array(3),x=new Array(3),k=new Array(3),O=new Array(3);if(i=0,s<=1)return{rot:void 0,trans1:void 0,trans2:void 0,rmsd:999};let R=s;for(n=0;n0?(b[0]=x[0]*w[0]+k[0]*S[0]+O[0]*A[0],b[1]=x[0]*w[1]+k[0]*S[1]+O[0]*A[1],b[2]=x[0]*w[2]+k[0]*S[2]+O[0]*A[2],b[3]=x[1]*w[0]+k[1]*S[0]+O[1]*A[0],b[4]=x[1]*w[1]+k[1]*S[1]+O[1]*A[1],b[5]=x[1]*w[2]+k[1]*S[2]+O[1]*A[2],b[6]=x[2]*w[0]+k[2]*S[0]+O[2]*A[0],b[7]=x[2]*w[1]+k[2]*S[1]+O[2]*A[1],b[8]=x[2]*w[2]+k[2]*S[2]+O[2]*A[2]):(b[0]=x[0]*w[0]+k[0]*S[0]-O[0]*A[0],b[1]=x[0]*w[1]+k[0]*S[1]-O[0]*A[1],b[2]=x[0]*w[2]+k[0]*S[2]-O[0]*A[2],b[3]=x[1]*w[0]+k[1]*S[0]-O[1]*A[0],b[4]=x[1]*w[1]+k[1]*S[1]-O[1]*A[1],b[5]=x[1]*w[2]+k[1]*S[2]-O[1]*A[2],b[6]=x[2]*w[0]+k[2]*S[0]-O[2]*A[0],b[7]=x[2]*w[1]+k[2]*S[1]-O[2]*A[1],b[8]=x[2]*w[2]+k[2]*S[2]-O[2]*A[2]),c=Math.sqrt(c),h=Math.sqrt(h),p=Math.sqrt(p),g=c+h+u*p,m=a+d-2*g,i=m>0?Math.sqrt(m):void 0,{rot:b,trans1:I,trans2:T,rmsd:i})}eigen_values(e){let t,s,i,n,l,r,o,a,d,c,h,p,m,u,g,f,b,C,y,v;if(this.icn3dui,t=e[0],s=e[1],i=e[2],n=e[3],l=e[4],r=e[5],o=e[6],a=e[7],d=e[8],c=-(t+l+d),h=t*l+(t+l)*d-r*a-s*n-i*o,p=-t*l*d+t*r*a+s*n*d-s*r*o-i*n*a+i*l*o,m=-c*c/3+h,u=c*c*c/13.5-c*h/3+p,g=.25*u*u+m*m*m/27,g<0){let e,t;e=Math.sqrt(.25*u*u-g),t=Math.acos(-.5*u/e),C=2*Math.cbrt(e)*Math.cos(t/3)}else f=Math.cbrt(-.5*u+Math.sqrt(g)),b=Math.cbrt(-.5*u-Math.sqrt(g)),C=f+b;return C-=c/3,c+=C,p/=-C,y=.5*(-c+Math.sqrt(c*c-4*p)),v=.5*(-c-Math.sqrt(c*c-4*p)),yw&&(w=Math.abs(d)),Math.abs(c)>w&&(w=Math.abs(c)),Math.abs(h)>w&&(w=Math.abs(h)),Math.abs(p)>w&&(w=Math.abs(p)),Math.abs(m)>w&&(w=Math.abs(m)),Math.abs(u)>w&&(w=Math.abs(u)),Math.abs(g)>w&&(w=Math.abs(g)),Math.abs(f)>w&&(w=Math.abs(f)),w<1e-10)return r=3,{k:r,v1:t,v2:s,v3:i};if(o=0,a/=w,d/=w,c/=w,h/=w,p/=w,m/=w,u/=w,g/=w,f/=w,Math.abs(a)w&&(_=a,a=h,h=_,_=d,d=p,p=_,_=c,c=m,m=_,w=Math.abs(d)),Math.abs(g)>w&&(_=a,a=u,u=_,_=d,d=g,g=_,_=c,c=f,f=_),y=m-p*c/d,v=f-g*c/d,Math.abs(y)w&&(_=a,a=h,h=_,_=d,d=p,p=_,_=c,c=m,m=_,w=Math.abs(a)),Math.abs(c)>w&&(_=a,a=u,u=_,_=d,d=g,g=_,_=c,c=f,f=_),b=p-h*d/a,C=m-h*c/a,y=g-u*d/a,v=f-u*c/a,Math.abs(b)0&&(1==o?(a=s[0],d=s[1],c=s[2],_=Math.sqrt(a*a+d*d+c*c),s[0]=a/_,s[1]=d/_,s[2]=c/_):2==o?(a=t[0],d=t[1],c=t[2],h=s[0],p=s[1],m=s[2],_=a*h+d*p+c*m,Math.abs(_)>=n&&(s[0]=a+_*h,s[1]=d+_*p,s[2]=c+_*m,h=s[0],p=s[1],m=s[2]),_=Math.sqrt(a*a+d*d+c*c),t[0]=a/_,t[1]=d/_,t[2]=c/_,_=Math.sqrt(h*h+p*p+m*m),s[0]=h/_,s[1]=p/_,s[2]=m/_):(a=t[0],d=t[1],c=t[2],_=Math.sqrt(a*a+d*d+c*c),t[0]=a/_,t[1]=d/_,t[2]=c/_)),{k:r,v1:t,v2:s,v3:i}}getEigenForSelection(e,t){let s,i=this.icn3dui,n=new THREE.Vector3,l=[];for(s=0;s0&&Math.abs(l[0].x-e[0].x)<=6&&Math.abs(l[0].y-e[0].y)<=6&&Math.abs(l[0].z-e[0].z)<=6?(p.push(l[0]),m=1):m=0,p.push(e[0]);for(let t=1,s=e.length-1;t0&&Math.abs(r[0].x-e[e.length-1].x)<=6&&Math.abs(r[0].y-e[e.length-1].y)<=6&&Math.abs(r[0].z-e[e.length-1].z)<=6&&(p.push(r[0]),++g),u>1&&Math.abs(r[0].x-r[1].x)<=6&&Math.abs(r[0].y-r[1].y)<=6&&Math.abs(r[0].z-r[1].z)<=6&&(p.push(r[1]),++g);let f=[],b=[],C=[];o&&(g=u>0?u-1:0);let y;for(let e=-1,n=p.length,l=1/s;e<=n-3;++e){y=e-m;let r=p[-1===e?0:e],o=p[e+1],u=p[e+2],v=p[e===n-3?n-1:e+3],_=0,w=a.subdivideCls.getKnot(1,_,r,o),S=a.subdivideCls.getKnot(1,w,o,u),A=a.subdivideCls.getKnot(1,S,u,v);w-_<1e-4&&(w=_+1),S-w<1e-4&&(S=w+1),A-S<1e-4&&(A=S+1),e>-1&&(void 0===i||i[y+1])&&e>=-1+m&&e<=n-3-g+1&&(d=d.concat(f),c=c.concat(b),h=h.concat(C)),f=[],b=[],C=[];let x=(S-w)*l;for(let l=0;l=-1+m&&e<=n-3-g&&i[y+1]&&l<=parseInt(s/2)&&(d.push(new THREE.Vector3(k,O,R)),c.push(i[y+1]),h.push(t[y+1])),e>=-1+m&&e<=n-3-g+1&&i[y+2]&&l>parseInt(s/2)&&(f.push(new THREE.Vector3(k,O,R)),b.push(i[y+2]),C.push(t[y+2]))):e>=-1+m&&e<=n-3-g&&(d.push(new THREE.Vector3(k,O,R)),c.push(y+1),h.push(t[y+1]))}}i&&!i[y+1]||(d=d.concat(f),c=c.concat(b),h=h.concat(C),d.push(p[p.length-1-g]),c.push(p.length-1-g),h.push(t[p.length-1-g])),f=[],b=[],C=[],p=[];let v=[];return v.push(d),v.push(c),v.push(h),v}getKnot(e,t,s,i){return this.icn3dui,s.distanceTo(i)+t}getValueFromKnot(e,t,s,i,n,l,r,o,a){this.icn3dui;let d,c,h=(r-l)/(s-t),p=(o-r)/(i-s),m=(a-o)/(n-i),u=(s+i)*(s+i)-4*(t*s+i*n-t*n);return 0==u?(d=9999,c=9999):(d=6*(3*p*s+2*h*n+m*s-2*h*s-2*p*n-p*i-m*s)/u,c=6*(3*p*i+2*m*t+h*s-2*p*t-2*m*i-h*i-p*s)/u),p*(e-s)+r+((2*d+c)/6/(s-i)*(e-s)*(e-i)*(e-i)+(2*c+d)/6/(i-s)*(e-s)*(e-s)*(e-i))}}class o{constructor(e){this.icn3dui=e}passFloat32(e,t){let s=this.icn3dui,i=e.length;t||(t=new Uint8Array(4*i));let n=s.convertTypeCls.getDataView(t);for(let t=0;t  Very high (pLDDT > 90)
          Confident (90 > pLDDT > 70)
          Low (70 > pLDDT > 50)
          Very low (pLDDT < 50)
        '}setLegendHtml(e){let t=this.icn3dui.icn3d,s="
        ";if(e)s+=this.setAlphaFoldLegend();else{s+="
        "+t.startValue+""+t.midValue+""+t.endValue+"
        "}return s}SetChainsAdvancedMenu(){let e=this.icn3dui,t=e.icn3d;if(void 0===t.bSetChainsAdvancedMenu||!t.bSetChainsAdvancedMenu){let s=e.hashUtilsCls.cloneHash(t.hAtoms);t.definedSetsCls.setPredefinedInMenu(),t.bSetChainsAdvancedMenu=!0,t.hAtoms=e.hashUtilsCls.cloneHash(s)}}setSetsMenus(e,t){let s=this.icn3dui,i=s.icn3d;this.SetChainsAdvancedMenu();let n=e,l=e+"2",r=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+s.pre+n).length&&$("#"+s.pre+n).html(" "+r),!t&&$("#"+s.pre+l).length&&$("#"+s.pre+l).html(" "+r),$("#"+s.pre+n).resizable(),t||$("#"+s.pre+l).resizable()}applyShownMenus(e){let t=this.icn3dui;t.icn3d;let s=[];for(let e in t.htmlCls.allMenus)t.htmlCls.shownMenus.hasOwnProperty(e)?$("#"+t.pre+e).parent().show():($("#"+t.pre+e).parent().hide(),s.push(e));Object.keys(t.htmlCls.shownMenus).length==Object.keys(t.htmlCls.allMenus).length?$(".icn3d-menusep").show():$(".icn3d-menusep").hide(),localStorage&&!e&&localStorage.setItem("hiddenmenus",JSON.stringify(s))}getHiddenMenusFromCache(){let e=this.icn3dui;e.icn3d,e.htmlCls.shownMenus={};let t=localStorage?localStorage.getItem("hiddenmenus"):"";if(t&&"[]"!=t){let s=JSON.parse(t);for(let t in e.htmlCls.allMenus)-1==s.indexOf(t)&&(e.htmlCls.shownMenus[t]=1)}else e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus)}displayShownMenus(){let e=this.icn3dui;e.icn3d;let t="
        ";t+="",t+="";for(let s in e.htmlCls.allMenusSel){if("uniclr"==s.substr(0,6)||"mn5_opacity"==s.substr(0,11)||"mn6_labelscale"==s.substr(0,14)||"faq_"==s.substr(0,4)||"dev_"==s.substr(0,4))continue;"mn1_searchgrooup"==s?t+="
        FileSelectViewStyleColorAnalysisHelp
        ":("mn2_definedsets"==s||"mn2_show_selected"==s||"mn3_proteinwrap"==s||e.cfg.cid&&"mn3_ligwrap"==s||"mn4_clrwrap"==s||"mn6_selectannotations"==s||"abouticn3d"==s)&&(t+="");let i=e.htmlCls.shownMenus.hasOwnProperty(s)?"checked":"",n=e.htmlCls.allMenusSel[s];t+=""+e.htmlCls.allMenus[s]+"
        "}t+="
        ",$("#"+e.pre+"menulist").html(t)}clickMenu1(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn1_vastplus","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_vastplus","Please input PDB ID for VAST+")})),e.myEventCls.onIds("#"+e.pre+"mn1_vast","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_vast","Please input chain or PDB file for VAST")})),e.myEventCls.onIds("#"+e.pre+"mn1_foldseek","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_foldseek","Submit your selection to Foldseek")})),e.myEventCls.onIds("#"+e.pre+"mn1_mmtfid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmtfid","Please input MMTF ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_pdbid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pdbid","Please input PDB ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_afid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_afid","Please input AlphaFold UniProt ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_refseqid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_refseqid","Please input NCBI Protein Accession")})),e.myEventCls.onIds("#"+e.pre+"mn1_opmid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_opmid","Please input OPM PDB ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_align","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_align","Align two PDB structures")})),e.myEventCls.onIds("#"+e.pre+"mn1_alignaf","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_alignaf","Align two AlphaFold structures")})),e.myEventCls.onIds("#"+e.pre+"mn1_chainalign","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_chainalign","Align multiple chains by structure alignment")})),e.myEventCls.onIds("#"+e.pre+"mn1_chainalign2","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_chainalign2","Align multiple chains by sequence alignment")})),e.myEventCls.onIds("#"+e.pre+"mn1_chainalign3","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_chainalign3","Align multiple chains residue by residue")})),e.myEventCls.onIds("#"+e.pre+"mn1_mutation","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mutation","Show the mutations in 3D")})),e.myEventCls.onIds("#"+e.pre+"mn1_pdbfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pdbfile","Please input PDB File")})),e.myEventCls.onIds(["#"+e.pre+"mn1_pdbfile_app","#"+e.pre+"tool_pdbfile"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pdbfile_app","Please append PDB Files")})),e.myEventCls.onIds("#"+e.pre+"mn1_mol2file","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mol2file","Please input Mol2 File")})),e.myEventCls.onIds("#"+e.pre+"mn1_sdffile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_sdffile","Please input SDF File")})),e.myEventCls.onIds("#"+e.pre+"mn1_xyzfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_xyzfile","Please input XYZ File")})),e.myEventCls.onIds("#"+e.pre+"mn1_afmapfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_afmapfile","Please input AlphaFold PAE File")})),e.myEventCls.onIds("#"+e.pre+"mn1_urlfile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_urlfile","Load data by URL")})),e.myEventCls.onIds("#"+e.pre+"mn1_fixedversion","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_fixedversion","Open Share Link URL in the archived version of iCn3D")})),e.myEventCls.onIds("#"+e.pre+"reload_fixedversion","click",(function(s){let i=e.icn3d,n=$("#"+e.pre+"sharelinkurl").val();t.setLogCmd("open "+n,!1),localStorage.setItem("fixedversion","1");let l=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(n,l)})),e.myEventCls.onIds("#"+e.pre+"mn1_mmciffile","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmciffile","Please input mmCIF File")})),e.myEventCls.onIds("#"+e.pre+"mn1_mmcifid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmcifid","Please input mmCIF ID")})),e.myEventCls.onIds("#"+e.pre+"mn1_mmdbid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmdbid","Please input MMDB or PDB ID")})),e.myEventCls.onIds(["#"+e.pre+"mn1_mmdbafid",,"#"+e.pre+"tool_mmdbafid"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_mmdbafid","Please input PDB/MMDB/AlphaFold UniProt IDs")})),e.myEventCls.onIds("#"+e.pre+"mn1_blast_rep_id","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_blast_rep_id","Align sequence to structure")})),e.myEventCls.onIds("#"+e.pre+"mn1_esmfold","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_esmfold","Sequence to structure prediction with ESMFold")})),e.myEventCls.onIds("#"+e.pre+"mn1_proteinname","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_proteinname","Please input protein or gene name")})),e.myEventCls.onIds("#"+e.pre+"mn1_cid","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_cid","Please input PubChem CID")})),e.myEventCls.onIds("#"+e.pre+"mn1_pngimage","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_pngimage","Please input the PNG image")})),e.myEventCls.onIds("#"+e.pre+"mn1_state","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_state","Please input the state file")})),e.myEventCls.onIds("#"+e.pre+"mn1_selection","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_selection","Please input the selection file")})),e.myEventCls.onIds("#"+e.pre+"mn1_dsn6","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_dsn6","Please input the map file to display electron density map")})),e.myEventCls.onIds(["#"+e.pre+"mn1_delphi","#"+e.pre+"mn1_delphi2","#"+e.pre+"tool_delphi"],"click",(function(t){e.icn3d.loadPhiFrom="delphi",$("#"+e.pre+"dl_delphi_tabs").tabs(),e.htmlCls.dialogCls.openDlg("dl_delphi","Please set parameters to display DelPhi potential map")})),e.myEventCls.onIds("#"+e.pre+"mn1_phi","click",(function(t){e.icn3d.loadPhiFrom="phi",$("#"+e.pre+"dl_phi_tabs").tabs(),$("#"+e.pre+"phitab1_tabs").tabs(),$("#"+e.pre+"phitab2_tabs").tabs(),e.htmlCls.dialogCls.openDlg("dl_phi","Please input local phi or cube file to display DelPhi potential map")})),e.myEventCls.onIds("#"+e.pre+"mn1_phiurl","click",(function(t){e.icn3d.loadPhiFrom="phiurl",$("#"+e.pre+"dl_phiurl_tabs").tabs(),$("#"+e.pre+"phiurltab1_tabs").tabs(),$("#"+e.pre+"phiurltab2_tabs").tabs(),e.htmlCls.dialogCls.openDlg("dl_phiurl","Please input URL phi or cube file to display DelPhi potential map")})),e.myEventCls.onIds("#"+e.pre+"mn1_dsn6url","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_dsn6url","Please input the map file to display electron density map")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportState","click",(function(s){let i=e.icn3d;t.setLogCmd("export state file",!1);let n=Object.keys(i.structures).join(",");i.saveFileCls.saveFile(n+"_statefile.txt","command")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportPdbRes","click",(function(s){e.icn3d,e.htmlCls.setHtmlCls.exportPdb(),t.setLogCmd("export pdb",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSecondary","click",(function(s){e.icn3d,e.htmlCls.setHtmlCls.exportSecondary(),t.setLogCmd("export secondary structure",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphipdb","#"+e.pre+"phipdb"],"click",(function(s){let i=e.icn3d,n=i.saveFileCls.getSelectedResiduePDB();t.setLogCmd("export PDB of selected residues",!1);let l=Object.keys(i.structures).join(",");i.saveFileCls.saveFile(l+"_icn3d_residues.pdb","text",[n])})),e.myEventCls.onIds(["#"+e.pre+"delphipqr","#"+e.pre+"phipqr","#"+e.pre+"phiurlpqr"],"click",(async function(s){e.icn3d,await e.htmlCls.setHtmlCls.exportPqr(),t.setLogCmd("export pqr",!0)})),e.myEventCls.onIds("#"+e.pre+"profixpdb","click",(async function(s){let i=e.icn3d;await i.scapCls.exportPdbProfix(!1),t.setLogCmd("export pdb missing atoms",!0)})),e.myEventCls.onIds("#"+e.pre+"profixpdbh","click",(async function(s){let i=e.icn3d;await i.scapCls.exportPdbProfix(!0),t.setLogCmd("export pdb hydrogen",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportIgstrand","click",(async function(s){e.icn3d.refnumCls.exportRefnum("igstrand"),t.setLogCmd("export refnum igstrand",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportKabat","click",(async function(s){e.icn3d.refnumCls.exportRefnum("kabat"),t.setLogCmd("export refnum kabat",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportImgt","click",(async function(s){e.icn3d.refnumCls.exportRefnum("imgt"),t.setLogCmd("export refnum imgt",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportStl","click",(function(s){let i=e.icn3d;t.setLogCmd("export stl file",!1),i.export3DCls.exportStlFile("")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportVrml","click",(function(s){let i=e.icn3d;t.setLogCmd("export vrml file",!1),i.export3DCls.exportVrmlFile("")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportStlStab","click",(function(s){let i=e.icn3d;t.setLogCmd("export stl stabilizer file",!1),i.threeDPrintCls.hideStabilizer(),i.threeDPrintCls.resetAfter3Dprint(),i.threeDPrintCls.addStabilizer(),i.export3DCls.exportStlFile("_stab")})),e.myEventCls.onIds("#"+e.pre+"mn1_exportVrmlStab","click",(function(s){let i=e.icn3d;t.setLogCmd("export vrml stabilizer file",!1),i.threeDPrintCls.hideStabilizer(),i.threeDPrintCls.resetAfter3Dprint(),i.threeDPrintCls.addStabilizer(),i.export3DCls.exportVrmlFile("_stab")})),e.myEventCls.onIds("#"+e.pre+"mn6_exportInteraction","click",(async function(s){let i=e.icn3d;t.setLogCmd("export interactions",!1),void 0!==e.cfg.mmdbid&&await i.viewInterPairsCls.retrieveInteractionData(),i.viewInterPairsCls.exportInteractions()})),e.myEventCls.onIds(["#"+e.pre+"mn1_exportCanvas","#"+e.pre+"saveimage"],"click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas",!1);await i.shareLinkCls.shareLink(!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas1","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 1",!0),i.scaleFactor=1,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas2","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 2",!0),i.scaleFactor=2,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas4","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 4",!0),i.scaleFactor=4,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCanvas8","click",(async function(s){let i=e.icn3d;t.setLogCmd("export canvas 8",!0),i.scaleFactor=8,await i.shareLinkCls.shareLink(!0,!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportCounts","click",(function(s){let i=e.icn3d;t.setLogCmd("export counts",!1);let n='

        Total Count for atoms with coordinates:
        ';n+="",n+="
        Structure CountChain CountResidue CountAtom Count
        "+Object.keys(i.structures).length+""+Object.keys(i.chains).length+""+Object.keys(i.residues).length+""+Object.keys(i.atoms).length+"

        ",n+="Counts by Chain for atoms with coordinates:
        ";let l=Object.keys(i.chains);for(let e=0,t=l.length;e"}n+="
        StructureChainResidue CountAtom Count
        "+r+""+o+""+Object.keys(a).length+""+Object.keys(i.chains[t]).length+"

        ";let r=Object.keys(i.structures).join(",");i.saveFileCls.saveFile(r+"_counts.html","html",n)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSelections","click",(function(s){let i=e.icn3d;t.setLogCmd("export all selections",!1),t.SetChainsAdvancedMenu();let n=i.saveFileCls.exportCustomAtoms(),l=Object.keys(i.structures).join(",");i.saveFileCls.saveFile(l+"_selections.txt","text",[n])})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSelDetails","click",(function(s){let i=e.icn3d;t.setLogCmd("export all selections with details",!1),t.SetChainsAdvancedMenu();let n=i.saveFileCls.exportCustomAtoms(!0),l=Object.keys(i.structures).join(",");i.saveFileCls.saveFile(l+"_sel_details.txt","text",[n])})),e.myEventCls.onIds(["#"+e.pre+"mn1_sharelink","#"+e.pre+"tool_sharelink"],"click",(async function(t){let s=e.icn3d;await s.shareLinkCls.shareLink()})),e.myEventCls.onIds("#"+e.pre+"mn1_replayon","click",(async function(s){let i=e.icn3d;await i.resizeCanvasCls.replayon(),t.setLogCmd("replay on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_replayoff","click",(async function(s){let i=e.icn3d;await i.resizeCanvasCls.replayoff(),t.setLogCmd("replay off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_menuall","click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus),t.applyShownMenus()})),e.myEventCls.onIds("#"+e.pre+"mn1_menusimple","click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.simpleMenus),t.applyShownMenus()})),e.myEventCls.onIds("#"+e.pre+"mn1_menupref","click",(function(s){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_menupref","Select Menus"),t.getHiddenMenusFromCache(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"apply_menupref","#"+e.pre+"apply_menupref2"],"click",(function(s){e.icn3d;var i=document.querySelectorAll('form[name="'+e.pre+'selmenu"] input:checked');for(var n of(e.htmlCls.shownMenus={},i))e.htmlCls.shownMenus[n.value]=1;t.applyShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"reset_menupref","#"+e.pre+"reset_menupref2"],"click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.simpleMenus),t.applyShownMenus(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"reset_menupref_all","#"+e.pre+"reset_menupref_all2"],"click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus),t.applyShownMenus(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"savepref","#"+e.pre+"savepref2"],"click",(function(t){let s=e.icn3d,i="[";var n=document.querySelectorAll('form[name="'+e.pre+'selmenu"] input:not(:checked)');let l=0;for(var r of n)l>0&&(i+=", "),i+='"'+r.value+'"',++l;i+="]",s.saveFileCls.saveFile("icn3d_menus_pref.txt","text",[i])})),e.myEventCls.onIds("#"+e.pre+"reload_menupreffile","click",(function(s){e.icn3d,s.preventDefault(),e.cfg.notebook||dialog.dialog("close");let i=$("#"+e.pre+"menupreffile")[0].files[0];if(i){e.htmlCls.setHtmlCls.fileSupport();let s=new FileReader;s.onload=function(s){let i=s.target.result,n=JSON.parse(i);e.htmlCls.shownMenus={};for(let t in e.htmlCls.allMenus)-1==n.indexOf(t)&&(e.htmlCls.shownMenus[t]=1);t.applyShownMenus(),t.displayShownMenus()},s.readAsText(i)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"mn1_menuloadpref","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_menuloadpref","Please input the menu preference file")})),e.myEventCls.onIds("#"+e.pre+"mn1_link_structure","click",(function(t){let s=e.icn3d,i=s.saveFileCls.getLinkToStructureSummary(!0),n=s.structures&&Object.keys(s.structures).length>0?"_blank":"_self";window.open(i,n)})),e.myEventCls.onIds("#"+e.pre+"mn1_alphafold","click",(function(t){e.icn3d;window.open("https://github.com/sokrypton/ColabFold","_blank")})),e.myEventCls.onIds("#"+e.pre+"mn1_link_bind","click",(function(s){let i=e.icn3d,n="https://www.ncbi.nlm.nih.gov/pccompound?LinkName=pccompound_structure&from_uid="+i.inputid;t.setLogCmd("link to 3D protein structures bound to CID "+i.inputid+": "+n,!1);let l=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(n,l)})),e.myEventCls.onIds("#"+e.pre+"mn1_link_vast","click",(function(s){let i,n=e.icn3d;if(void 0===n.inputid)i="https://www.ncbi.nlm.nih.gov/pccompound?term="+n.molTitle,t.setLogCmd("link to compounds "+n.molTitle+": "+i,!1);else if(void 0!==e.cfg.cid)i="https://www.ncbi.nlm.nih.gov/pccompound?LinkName=pccompound_pccompound_3d&from_uid="+n.inputid,t.setLogCmd("link to compounds with structure similar to CID "+n.inputid+": "+i,!1);else{let s=n.inputid.split("_");1===s.length?(i=e.htmlCls.baseUrl+"vastplus/vastplus.cgi?uid="+n.inputid,t.setLogCmd("link to structures similar to "+n.inputid+": "+i,!1)):2===s.length&&(i=e.htmlCls.baseUrl+"vastplus/vastplus.cgi?uid="+s[0],t.setLogCmd("link to structures similar to "+s[0]+": "+i,!1))}let l=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i,l)})),e.myEventCls.onIds("#"+e.pre+"mn1_link_pubmed","click",(function(s){let i,n=e.icn3d;if(void 0===n.inputid){i="https://www.ncbi.nlm.nih.gov/pubmed/?term="+n.molTitle,t.setLogCmd("link to literature about "+n.molTitle+": "+i,!1);let e=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i,e)}else if(n.pmid){let e=n.pmid.toString().split("_");1===e.length?(i="https://www.ncbi.nlm.nih.gov/pubmed/"+n.pmid,t.setLogCmd("link to PubMed ID "+n.pmid+": "+i,!1)):2===e.length&&(i="https://www.ncbi.nlm.nih.gov/pubmed/?term="+e[0]+" OR "+e[1],t.setLogCmd("link to PubMed IDs "+e[0]+", "+e[1]+": "+i,!1));let s=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i,s)}else if(isNaN(n.inputid)){let e=n.inputid.toString().split("_");1===e.length?(i="https://www.ncbi.nlm.nih.gov/pubmed/?term="+n.inputid,t.setLogCmd("link to literature about PDB "+n.inputid+": "+i,!1)):2===e.length&&(i="https://www.ncbi.nlm.nih.gov/pubmed/?term="+e[0]+" OR "+e[1],t.setLogCmd("link to literature about PDB "+e[0]+" OR "+e[1]+": "+i,!1));let s=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i,s)}else void 0!==e.cfg.cid?alert("No literature information is available for this compound in the SDF file."):alert("No literature information is available for this structure.")})),e.myEventCls.onIds("#"+e.pre+"mn1_link_protein","click",(function(s){let i=e.icn3d,n=Object.keys(i.structures),l=Object.keys(i.chains),r="";for(let e=0,t=l.length;e0&&(r=r.substr(0,r.length-4));let o="https://www.ncbi.nlm.nih.gov/protein/?term="+r;t.setLogCmd("link to Entrez protein about PDB "+n+": "+o,!1);let a=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(o,a)}))}clickMenu2(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds(["#"+e.pre+"mn6_selectannotations","#"+e.pre+"tool_selectannotations"],"click",(async function(s){let i=e.icn3d;await i.showAnnoCls.showAnnotations(),t.setLogCmd("view annotations",!0)})),e.myEventCls.onIds("#"+e.pre+"mn2_selectall","click",(function(s){let i=e.icn3d;t.setLogCmd("select all",!0),i.selectionCls.selectAll(),i.hlUpdateCls.removeHlAll(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"clearall","click",(function(s){let i=e.icn3d;t.setLogCmd("clear all",!0),i.bSelectResidue=!1,i.selectionCls.selectAll(),i.hlUpdateCls.removeHlAll(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn2_selectdisplayed","click",(function(s){let i=e.icn3d;t.setLogCmd("select displayed set",!0),i.hAtoms=e.hashUtilsCls.cloneHash(i.viewSelectionAtoms),i.hlUpdateCls.updateHlAll()})),e.myEventCls.onIds("#"+e.pre+"mn2_fullstru","click",(function(s){let i=e.icn3d;t.setLogCmd("show all",!0),i.selectionCls.showAll()})),e.myEventCls.onIds("#"+e.pre+"mn2_selectcomplement","click",(function(s){let i=e.icn3d;Object.keys(i.hAtoms).lengthnon-selected"+n),$("#"+e.pre+"atomsCustomSphere2").length&&$("#"+e.pre+"atomsCustomSphere2").html(" "+n),e.htmlCls.dialogCls.openDlg("dl_aroundsphere","Select a sphere around a set of residues"),i.bSphereCalc=!1,$("#"+e.pre+"atomsCustomSphere").resizable(),$("#"+e.pre+"atomsCustomSphere2").resizable()})),e.myEventCls.onIds(["#"+e.pre+"mn2_select_chain","#"+e.pre+"definedSets"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_select_chain","Select Structure/Chain/Custom Selection")}))}clickMenu3(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsRibbon","#"+e.pre+"tool_proteinsRibbon"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","ribbon"),t.setLogCmd("style proteins ribbon",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsStrand","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","strand"),t.setLogCmd("style proteins strand",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsCylinder","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","cylinder and plate"),t.setLogCmd("style proteins cylinder and plate",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","schematic"),t.setLogCmd("style proteins schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsCalpha","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","c alpha trace"),t.setLogCmd("style proteins c alpha trace",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsBackbone","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","backbone"),t.setLogCmd("style proteins backbone",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsBfactor","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","b factor tube"),t.setLogCmd("style proteins b factor tube",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsLines","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","lines"),t.setLogCmd("style proteins lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsStick","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","stick"),t.setLogCmd("style proteins stick",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsBallstick","#"+e.pre+"tool_proteinsBallstick"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","ball and stick"),t.setLogCmd("style proteins ball and stick",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsSphere","#"+e.pre+"tool_proteinsSphere"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","sphere"),t.setLogCmd("style proteins sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsNo","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","nothing"),t.setLogCmd("style proteins nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecLines","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","lines2"),t.setLogCmd("style sidec lines2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecStick","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","stick2"),t.setLogCmd("style sidec stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","ball and stick2"),t.setLogCmd("style sidec ball and stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","sphere2"),t.setLogCmd("style sidec sphere2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecNo","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","nothing"),t.setLogCmd("style sidec nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseLines","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","lines2"),t.setLogCmd("style ntbase lines2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseStick","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","stick2"),t.setLogCmd("style ntbase stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","ball and stick2"),t.setLogCmd("style ntbase ball and stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","sphere2"),t.setLogCmd("style ntbase sphere2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseNo","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","nothing"),t.setLogCmd("style ntbase nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclCartoon","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","nucleotide cartoon"),t.setLogCmd("style nucleotides nucleotide cartoon",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclBackbone","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","backbone"),t.setLogCmd("style nucleotides backbone",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","schematic"),t.setLogCmd("style nucleotides schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclPhos","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","o3 trace"),t.setLogCmd("style nucleotides o3 trace",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclLines","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","lines"),t.setLogCmd("style nucleotides lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclStick","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","stick"),t.setLogCmd("style nucleotides stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","ball and stick"),t.setLogCmd("style nucleotides ball and stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","sphere"),t.setLogCmd("style nucleotides sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclNo","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","nothing"),t.setLogCmd("style nucleotides nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligLines","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","lines"),t.setLogCmd("style chemicals lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligStick","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","stick"),t.setLogCmd("style chemicals stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","ball and stick"),t.setLogCmd("style chemicals ball and stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","schematic"),t.setLogCmd("style chemicals schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","sphere"),t.setLogCmd("style chemicals sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligNo","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","nothing"),t.setLogCmd("style chemicals nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_glycansCartYes","click",(function(s){let i=e.icn3d;i.bGlycansCartoon=!0,i.drawCls.draw(),t.setLogCmd("glycans cartoon yes",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_glycansCartNo","click",(function(s){let i=e.icn3d;i.bGlycansCartoon=!1,i.drawCls.draw(),t.setLogCmd("glycans cartoon no",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_hydrogensYes","click",(function(s){let i=e.icn3d;i.showInterCls.showHydrogens(),i.drawCls.draw(),t.setLogCmd("hydrogens",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_hydrogensNo","click",(function(s){let i=e.icn3d;i.showInterCls.hideHydrogens(),i.drawCls.draw(),t.setLogCmd("set hydrogens off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","sphere"),t.setLogCmd("style ions sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsDot","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","dot"),t.setLogCmd("style ions dot",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsNo","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","nothing"),t.setLogCmd("style ions nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("water","sphere"),t.setLogCmd("style water sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterDot","click",(function(s){e.icn3d.setOptionCls.setStyle("water","dot"),t.setLogCmd("style water dot",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterNo","click",(function(s){e.icn3d.setOptionCls.setStyle("water","nothing"),t.setLogCmd("style water nothing",!0)}))}clickMenu4(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrum","click",(function(s){e.icn3d.setOptionCls.setOption("color","spectrum"),t.setLogCmd("color spectrum",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumChain","click",(function(s){e.icn3d.setOptionCls.setOption("color","spectrum for chains"),t.setLogCmd("color spectrum for chains",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumAcrossSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorSpectrumAcross").length&&$("#"+e.pre+"atomsCustomColorSpectrumAcross").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorspectrumacrosssets","Please select sets to apply spectrum color for sets"),$("#"+e.pre+"atomsCustomColorSpectrumAcross").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorSpectrum").length&&$("#"+e.pre+"atomsCustomColorSpectrum").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorspectrumbysets","Please select sets to apply spectrum color for residues"),$("#"+e.pre+"atomsCustomColorSpectrum").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbowAcrossSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorRainbowAcross").length&&$("#"+e.pre+"atomsCustomColorRainbowAcross").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorrainbowacrosssets","Please select sets to apply rainbow color for sets"),$("#"+e.pre+"atomsCustomColorRainbowAcross").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbowSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorRainbow").length&&$("#"+e.pre+"atomsCustomColorRainbow").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorrainbowbysets","Please select sets to apply rainbow color for residues"),$("#"+e.pre+"atomsCustomColorRainbow").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbow","click",(function(s){e.icn3d.setOptionCls.setOption("color","rainbow"),t.setLogCmd("color rainbow",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrRainbowChain","#"+e.pre+"tool_clrRainbowChain"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","rainbow for chains"),t.setLogCmd("color rainbow for chains",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrChain","#"+e.pre+"tool_clrChain"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","chain"),t.setLogCmd("color chain",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrStructure","click",(function(s){e.icn3d.setOptionCls.setOption("color","structure"),t.setLogCmd("color structure",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrdomain","click",(function(s){e.icn3d.setOptionCls.setOption("color","domain"),t.setLogCmd("color domain",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrsets","click",(function(s){e.icn3d.setOptionCls.setOption("color","defined sets"),t.setLogCmd("color defined sets",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrSSGreen","#"+e.pre+"tool_clrSSGreen"],"click",(function(s){let i=e.icn3d;i.sheetcolor="green",i.setOptionCls.setOption("color","secondary structure green"),t.setLogCmd("color secondary structure green",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSSYellow","click",(function(s){let i=e.icn3d;i.sheetcolor="yellow",i.setOptionCls.setOption("color","secondary structure yellow"),t.setLogCmd("color secondary structure yellow",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSSSpectrum","click",(function(s){e.icn3d.setOptionCls.setOption("color","secondary structure spectrum"),t.setLogCmd("color secondary structure spectrum",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrResidue","click",(function(s){e.icn3d.setOptionCls.setOption("color","residue"),t.setLogCmd("color residue",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrResidueCustom","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_rescolorfile","Please input the file on residue colors")})),e.myEventCls.onIds("#"+e.pre+"reload_rescolorfile","click",(function(s){let i=e.icn3d;s.preventDefault(),e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"rescolorfile")[0].files[0];if(n){e.htmlCls.setHtmlCls.fileSupport();let s=new FileReader;s.onload=function(s){let n=s.target.result.replace(/#/g,"");i.customResidueColors=JSON.parse(n);for(let t in i.customResidueColors)i.customResidueColors[t.toUpperCase()]=e.parasCls.thr("#"+i.customResidueColors[t]);i.setOptionCls.setOption("color","residue custom"),t.setLogCmd("color residue custom | "+n,!0)},s.readAsText(n)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"reload_customcolorfile","click",(function(s){let i=e.icn3d;s.preventDefault(),e.cfg.notebook||dialog.dialog("close"),i.startColor=$("#"+e.pre+"startColor").val(),i.midColor=$("#"+e.pre+"midColor").val(),i.endColor=$("#"+e.pre+"endColor").val();let n=t.setLegendHtml();$("#"+e.pre+"dl_legend_html").html(n),e.htmlCls.dialogCls.openDlg("dl_legend","Color range"),i.addTrackCls.setCustomFile("color",i.startColor,i.midColor,i.endColor)})),e.myEventCls.onIds("#"+e.pre+"mn6_customref","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_customref","Set custom reference numbers")})),e.myEventCls.onIds("#"+e.pre+"reload_customreffile","click",(function(s){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close");let n=$("#"+i.pre+"cstreffile")[0].files[0];if(n){e.utilsCls.checkFileAPI();let s=new FileReader;s.onload=async function(e){let s=e.target.result;await i.refnumCls.parseCustomRefFile(s),s=s.replace(/\r/g,"").replace(/\n/g,"\\n"),t.setLogCmd("custom refnum | "+s,!0)},s.readAsText(n)}else alert("Please select a file before clicking 'Apply'")})),e.myEventCls.onIds("#"+e.pre+"remove_legend","click",(function(s){e.icn3d,s.preventDefault(),$("#"+e.pre+"legend").hide(),t.setLogCmd("remove legend",!0)})),e.myEventCls.onIds("#"+e.pre+"reload_customtubefile","click",(function(t){let s=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),s.addTrackCls.setCustomFile("tube")})),e.myEventCls.onIds("#"+e.pre+"mn4_clrCharge","click",(function(s){e.icn3d.setOptionCls.setOption("color","charge"),t.setLogCmd("color charge",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrHydrophobic","click",(function(s){e.icn3d.setOptionCls.setOption("color","hydrophobic"),t.setLogCmd("color hydrophobic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrNormalizedHP","click",(function(s){e.icn3d.setOptionCls.setOption("color","normalized hydrophobic"),t.setLogCmd("color normalized hydrophobic",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrAtom","#"+e.pre+"tool_clrAtom"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","atom"),t.setLogCmd("color atom",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrBfactor","click",(function(s){e.icn3d.setOptionCls.setOption("color","b factor"),t.setLogCmd("color b factor",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrConfidence","click",(function(s){e.icn3d.setOptionCls.setOption("color","confidence"),t.setLogCmd("color confidence",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrIgstrand","click",(function(s){e.icn3d.setOptionCls.setOption("color","ig strand"),t.setLogCmd("color ig strand",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrIgproto","click",(function(s){e.icn3d.setOptionCls.setOption("color","ig protodomain"),t.setLogCmd("color ig protodomain",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrArea","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_colorbyarea","Color based on residue's solvent accessibility")})),e.myEventCls.onIds("#"+e.pre+"applycolorbyarea","click",(function(s){let i=e.icn3d;i.midpercent=$("#"+e.pre+"midpercent").val(),i.setOptionCls.setOption("color","area"),t.setLogCmd("color area | "+i.midpercent,!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrBfactorNorm","click",(function(s){e.icn3d.setOptionCls.setOption("color","b factor percentile"),t.setLogCmd("color b factor percentile",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrIdentity","click",(function(s){e.icn3d.setOptionCls.setOption("color","identity"),t.setLogCmd("color identity",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrConserved","click",(function(s){e.icn3d.setOptionCls.setOption("color","conservation"),t.setLogCmd("color conservation",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrCustom","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_clr","Color picker")})),$(document).on("click",".icn3d-color-rad-text",(function(s){let i=e.icn3d;s.stopImmediatePropagation();let n=$(this).attr("color");i.setOptionCls.setOption("color",n),t.setLogCmd("color "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSave","click",(function(s){e.icn3d.setOptionCls.saveColor(),t.setLogCmd("save color",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrApplySave","click",(function(s){e.icn3d.setOptionCls.applySavedColor(),t.setLogCmd("apply saved color",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_styleSave","click",(function(s){e.icn3d.setOptionCls.saveStyle(),t.setLogCmd("save style",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_styleApplySave","click",(function(s){e.icn3d.setOptionCls.applySavedStyle(),t.setLogCmd("apply saved style",!0)}))}clickMenu5(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn5_neighborsYes","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.applyMapCls.removeLastSurface(),i.applyMapCls.applySurfaceOptions(),i.bRender&&i.drawCls.render(),t.setLogCmd("set surface neighbors on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_neighborsNo","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.applyMapCls.removeLastSurface(),i.applyMapCls.applySurfaceOptions(),i.bRender&&i.drawCls.render(),t.setLogCmd("set surface neighbors off",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn5_surfaceVDW","#"+e.pre+"tool_surfaceVDW"],"click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","Van der Waals surface"),t.setLogCmd("set surface Van der Waals surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceSAS","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","solvent accessible surface"),t.setLogCmd("set surface solvent accessible surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceMolecular","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","molecular surface"),t.setLogCmd("set surface molecular surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceVDWContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","Van der Waals surface with context"),t.setLogCmd("set surface Van der Waals surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceSASContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","solvent accessible surface with context"),t.setLogCmd("set surface solvent accessible surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceMolecularContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","molecular surface with context"),t.setLogCmd("set surface molecular surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceNo","click",(function(s){e.icn3d.setOptionCls.setOption("surface","nothing"),t.setLogCmd("set surface nothing",!0)})),$(document).on("click","."+e.pre+"mn5_opacity",(function(s){let i=e.icn3d;i.transparentRenderOrder=!1;let n=$(this).attr("v");i.setOptionCls.setOption("opacity",n),t.setLogCmd("set surface opacity "+n,!0)})),$(document).on("click","."+e.pre+"mn5_opacityslow",(function(s){let i=e.icn3d;i.transparentRenderOrder=!0;let n=$(this).attr("v");i.setOptionCls.setOption("opacity",n),t.setLogCmd("set surface2 opacity "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_wireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("wireframe","yes"),t.setLogCmd("set surface wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_wireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("wireframe","no"),t.setLogCmd("set surface wireframe off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_elecmap2fofc","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_elecmap2fofc","2Fo-Fc Electron Density Map")})),e.myEventCls.onIds("#"+e.pre+"mn5_elecmapfofc","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_elecmapfofc","Fo-Fc Electron Density Map")})),e.myEventCls.onIds(["#"+e.pre+"mn5_elecmapNo","#"+e.pre+"elecmapNo2","#"+e.pre+"elecmapNo3","#"+e.pre+"elecmapNo4","#"+e.pre+"elecmapNo5"],"click",(function(s){e.icn3d.setOptionCls.setOption("map","nothing"),t.setLogCmd("setoption map nothing",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphimapNo","#"+e.pre+"phimapNo","#"+e.pre+"phiurlmapNo","#"+e.pre+"mn1_phimapNo"],"click",(function(s){e.icn3d.setOptionCls.setOption("phimap","nothing"),t.setLogCmd("setoption phimap nothing",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphimapNo2","#"+e.pre+"phimapNo2","#"+e.pre+"phiurlmapNo2"],"click",(function(s){e.icn3d.setOptionCls.setOption("phisurface","nothing"),t.setLogCmd("setoption phisurface nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"applymap2fofc","click",(async function(s){let i=e.icn3d;s.preventDefault();let n=parseFloat($("#"+e.pre+"sigma2fofc").val());await i.dsn6ParserCls.dsn6Parser(i.inputid,"2fofc",n),t.setLogCmd("set map 2fofc sigma "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"applymapfofc","click",(async function(s){let i=e.icn3d;s.preventDefault();let n=parseFloat($("#"+e.pre+"sigmafofc").val());await i.dsn6ParserCls.dsn6Parser(i.inputid,"fofc",n),t.setLogCmd("set map fofc sigma "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_mapwireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("mapwireframe","yes"),t.setLogCmd("set map wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_mapwireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("mapwireframe","no"),t.setLogCmd("set map wireframe off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmap","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_emmap","EM Density Map")})),e.myEventCls.onIds(["#"+e.pre+"mn5_emmapNo","#"+e.pre+"emmapNo2"],"click",(function(s){e.icn3d.setOptionCls.setOption("emmap","nothing"),t.setLogCmd("setoption emmap nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"applyemmap","click",(async function(s){let i=e.icn3d;s.preventDefault();let n=parseFloat($("#"+e.pre+"empercentage").val());await i.densityCifParserCls.densityCifParser(i.inputid,"em",n,i.emd),t.setLogCmd("set emmap percentage "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmapwireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("emmapwireframe","yes"),t.setLogCmd("set emmap wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmapwireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("emmapwireframe","no"),t.setLogCmd("set emmap wireframe off",!0)}))}clickMenu6(){let e=this.icn3dui,t=e.icn3d;if(e.bNode)return;let s=this;e.myEventCls.onIds("#"+e.pre+"mn6_assemblyYes","click",(function(t){let i=e.icn3d;i.bAssembly=!0,s.setLogCmd("set assembly on",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_assemblyNo","click",(function(t){let i=e.icn3d;i.bAssembly=!1,s.setLogCmd("set assembly off",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_igrefYes","click",(async function(t){let i=e.icn3d;s.setLogCmd("ig refnum on",!0),await i.refnumCls.showIgRefNum()})),e.myEventCls.onIds("#"+e.pre+"mn6_igrefTpl","click",(async function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_igrefTpl","Choose an Ig template")})),e.myEventCls.onIds("#"+e.pre+"mn6_igrefTpl_apply","click",(async function(t){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"igrefTpl").val();s.setLogCmd("ig template "+n,!0),await i.refnumCls.showIgRefNum(n)})),e.myEventCls.onIds("#"+e.pre+"mn6_igrefNo","click",(async function(t){let i=e.icn3d;s.setLogCmd("ig refnum off",!0),await i.refnumCls.hideIgRefNum(),i.opts.color="chain",i.setColorCls.setColorByOptions(i.opts,i.atoms),i.selectionCls.selectAll_base(),i.hlUpdateCls.updateHlAll(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelAtoms","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addAtomLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add atom labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelElements","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addAtomLabels(i.hAtoms,!0),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add element labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelResidues","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addResidueLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add residue labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelResnum","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addResidueLabels(i.hAtoms,void 0,void 0,!0),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add residue number labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelRefnum","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addResidueLabels(i.hAtoms,void 0,void 0,void 0,!0),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add reference number labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelChains","click",(function(t){let i=e.icn3d;i.analysisCls.addChainLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add chain labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelTermini","click",(function(t){let i=e.icn3d;i.analysisCls.addTerminiLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add terminal labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelYes","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_addlabel","Add custom labels by selection"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelSelection","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_addlabelselection","Add custom labels by the selected")})),e.myEventCls.onIds("#"+e.pre+"mn6_labelColor","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_labelColor","Change color for all labels")})),e.myEventCls.onIds(["#"+e.pre+"mn2_saveselection","#"+e.pre+"tool_saveselection"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_saveselection","Save the selected")})),e.myEventCls.onIds(["#"+e.pre+"mn6_addlabelNo","#"+e.pre+"removeLabels"],"click",(function(t){let i=e.icn3d;i.labelcolor=void 0,i.pickpair=!1;s.setLogCmd("set labels off",!0);for(let e in i.labels)i.labels[e]=[];i.drawCls.draw()})),$(document).on("click","."+e.pre+"mn6_labelscale",(function(t){let i=e.icn3d,n=$(this).attr("v");i.labelScale=n,i.drawCls.draw(),s.setLogCmd("set label scale "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_distanceYes","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_distance","Measure the distance of atoms"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0,s.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distTwoSets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_disttwosets","Measure the distance between two sets"),s.setSetsMenus("atomsCustomDist"),i.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distManySets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_distmanysets","Measure the pairwise distance among many sets"),s.setSetsMenus("atomsCustomDistTable"),i.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distanceNo","click",(function(t){let i=e.icn3d;i.pickpair=!1;s.setLogCmd("set lines off",!0),i.labels.distance=[],i.lines.distance=[],i.distPnts=[],i.pk=2,i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn5_cartoonshape","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_cartoonshape","Draw cartoon for a set");s.setSetsMenus("cartoonshape",!0),i.bCartoonshape=!0})),e.myEventCls.onIds("#"+e.pre+"mn5_linebtwsets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_linebtwsets","Draw a line between two sets"),s.setSetsMenus("linebtwsets"),i.bLinebtwsets=!0})),e.myEventCls.onIds(["#"+e.pre+"mn2_selectedcenter","#"+e.pre+"zoomin_selection","#"+e.pre+"tool_selectedcenter"],"click",(function(t){let i=e.icn3d;i.transformCls.zoominSelection(),i.drawCls.draw(),s.setLogCmd("zoom selection",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_center","click",(function(t){let i=e.icn3d;i.applyCenterCls.centerSelection(),i.drawCls.draw(),s.setLogCmd("center selection",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_resetOrientation","#"+e.pre+"resetOrientation","#"+e.pre+"tool_resetOrientation"],"click",(function(t){let i=e.icn3d;i.transformCls.resetOrientation(),i.drawCls.draw(),s.setLogCmd("reset orientation",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_chemicalbindingshow","#"+e.pre+"chemicalbindingshow"],"click",(function(t){e.icn3d.setOptionCls.setOption("chemicalbinding","show"),s.setLogCmd("set chemicalbinding show",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_chemicalbindinghide","#"+e.pre+"chemicalbindinghide"],"click",(function(t){e.icn3d.setOptionCls.setOption("chemicalbinding","hide"),s.setLogCmd("set chemicalbinding hide",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_sidebyside","click",(function(t){let i=e.icn3d;if(i.bInputfile)return void alert("Side-by-Side does NOT work when the input is from a local file.");let n=i.shareLinkCls.shareLinkUrl(void 0);n=n.replace("icn3d/full.html?","icn3d/full2.html?"),n=n.replace("icn3d/?","icn3d/full2.html?"),n+="&closepopup=1";let l=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(n,l),s.setLogCmd("side by side | "+n,!0)})),$(document).on("click","."+e.pre+"mn6_rotate",(function(t){let i=e.icn3d,n=$(this).attr("v").toLowerCase(),l=n.split(" ")[1];s.setLogCmd(n,!0),i.bStopRotate=!1,i.transformCls.rotateCount=0,i.transformCls.rotateCountMax=6e3,i.ROT_DIR=l,i.resizeCanvasCls.rotStruc(l)})),$(document).on("click","."+e.pre+"mn6_rotate90",(function(t){let i,n=e.icn3d,l=$(this).attr("v").toLowerCase(),r=l.split("-")[0];s.setLogCmd(l,!0),"x"==r?i=new THREE.Vector3(1,0,0):"y"==r?i=new THREE.Vector3(0,1,0):"z"==r&&(i=new THREE.Vector3(0,0,1));let o=.5*Math.PI;n.transformCls.setRotation(i,o)})),e.myEventCls.onIds("#"+e.pre+"mn6_cameraPers","click",(function(t){e.icn3d.setOptionCls.setOption("camera","perspective"),s.setLogCmd("set camera perspective",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_cameraOrth","click",(function(t){e.icn3d.setOptionCls.setOption("camera","orthographic"),s.setLogCmd("set camera orthographic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdBlack","click",(function(t){e.icn3d.setStyleCls.setBackground("black")})),e.myEventCls.onIds("#"+e.pre+"tool_bkgd","click",(function(t){let s=e.icn3d;"black"==s.opts.background?s.setStyleCls.setBackground("white"):s.setStyleCls.setBackground("black")})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdGrey","click",(function(t){e.icn3d.setStyleCls.setBackground("grey")})),e.myEventCls.onIds(["#"+e.pre+"mn6_bkgdWhite","#"+e.pre+"tool_bkgdWhite"],"click",(function(t){e.icn3d.setStyleCls.setBackground("white")})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdTransparent","click",(function(t){e.icn3d.setStyleCls.setBackground("transparent")})),e.myEventCls.onIds("#"+e.pre+"mn6_showfogYes","click",(function(t){let i=e.icn3d;i.opts.fog="yes",i.fogCls.setFog(!0),i.drawCls.draw(),s.setLogCmd("set fog on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showfogNo","click",(function(t){let i=e.icn3d;i.opts.fog="no",i.fogCls.setFog(!0),i.drawCls.draw(),s.setLogCmd("set fog off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showslabYes","click",(function(t){e.icn3d.setOptionCls.setOption("slab","yes"),s.setLogCmd("set slab on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showslabNo","click",(function(t){e.icn3d.setOptionCls.setOption("slab","no"),s.setLogCmd("set slab off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisYes","click",(function(t){e.icn3d.setOptionCls.setOption("axis","yes"),s.setLogCmd("set axis on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisSel","click",(function(t){let i=e.icn3d;i.pc1=!0,i.axesCls.setPc1Axes(),s.setLogCmd("set pc1 axis",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisNo","click",(function(t){let i=e.icn3d;i.pc1=!1,i.axes=[],i.setOptionCls.setOption("axis","no"),s.setLogCmd("set axis off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_symmetry","click",(async function(t){let s=e.icn3d;s.bAxisOnly=!1,await s.symdCls.retrieveSymmetry(Object.keys(s.structures)[0])})),e.myEventCls.onIds("#"+e.pre+"mn6_symd","click",(async function(t){let i=e.icn3d;i.bAxisOnly=!1,await i.symdCls.retrieveSymd(),i.bSymd=!0,s.setLogCmd("symd symmetry",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_clear_sym","click",(function(t){let i=e.icn3d;i.symdArray=[],i.drawCls.draw(),s.setLogCmd("clear symd symmetry",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_axes_only","click",(function(t){let i=e.icn3d;i.bAxisOnly=!0,i.drawCls.draw(),s.setLogCmd("show axis",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_area","click",(function(t){e.icn3d.analysisCls.calculateArea(),s.setLogCmd("area",!0)})),e.myEventCls.onIds("#"+e.pre+"applysymmetry","click",(function(t){let i=e.icn3d;i.bAxisOnly=!1;let n=$("#"+e.pre+"selectSymmetry").val();i.symmetrytitle="none"===n?void 0:n,i.drawCls.draw(),s.setLogCmd("symmetry "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"clearsymmetry","click",(function(t){let i=e.icn3d;i.symmetrytitle=void 0,i.drawCls.draw(),s.setLogCmd("symmetry none",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_hbondsYes","#"+e.pre+"hbondsYes"],"click",(function(t){let i=e.icn3d;s.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomHbond").length&&$("#"+e.pre+"atomsCustomHbond").html(" "+n),$("#"+e.pre+"atomsCustomHbond2").length&&$("#"+e.pre+"atomsCustomHbond2").html(" "+n),e.htmlCls.dialogCls.openDlg("dl_hbonds","Hydrogen bonds/interactions between two sets of atoms"),i.bHbondCalc=!1,$("#"+e.pre+"atomsCustomHbond").resizable(),$("#"+e.pre+"atomsCustomHbond2").resizable()})),e.myEventCls.onIds(["#"+e.pre+"mn6_contactmap"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_contact","Set contact map")})),e.myEventCls.onIds("#"+e.pre+"mn6_hbondsNo","click",(function(t){let s=e.icn3d;s.showInterCls.hideHbondsContacts(),s.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerYes","click",(function(t){let i=e.icn3d;i.threeDPrintCls.addStabilizer(),i.threeDPrintCls.prepareFor3Dprint(),s.setLogCmd("stabilizer",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerNo","click",(function(t){let i=e.icn3d;s.setLogCmd("set stabilizer off",!0),i.threeDPrintCls.hideStabilizer(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerOne","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_stabilizer","Add One Stabilizer"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerRmOne","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_stabilizer_rm","Remove One Stabilizer"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn1_thicknessSet","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_thickness","Set Thickness for 3D Printing")})),e.myEventCls.onIds("#"+e.pre+"mn3_setThickness","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_thickness2","Style Preferences")})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsYes","click",(function(t){let i=e.icn3d;s.setLogCmd("disulfide bonds",!0),i.showInterCls.showSsbonds()})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsExport","click",(function(t){e.icn3d.viewInterPairsCls.exportSsbondPairs(),s.setLogCmd("export disulfide bond pairs",!1)})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsNo","click",(function(t){let i=e.icn3d;i.opts.ssbonds="no";s.setLogCmd("set disulfide bonds off",!0),i.lines.ssbond=[],i.setOptionCls.setStyle("sidec","nothing")})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsYes","click",(function(t){let i=e.icn3d;s.setLogCmd("cross linkage",!0),i.showInterCls.showClbonds()})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsExport","click",(function(t){e.icn3d.viewInterPairsCls.exportClbondPairs(),s.setLogCmd("export cross linkage pairs",!1)})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsNo","click",(function(t){let i=e.icn3d;i.opts.clbonds="no";s.setLogCmd("set cross linkage off",!0),i.lines.clbond=[],i.setOptionCls.setStyle("sidec","nothing")})),$("#"+e.pre+"newvs2").on("submit",(function(){let s=t.saveFileCls.getAtomPDB(t.hAtoms);return $("#"+e.pre+"pdbstr").val(s),!0})),$("#"+e.pre+"fssubmit").on("click",(function(){let e=t.saveFileCls.getAtomPDB(t.hAtoms),s=window.open("","_blank");s.document.body.innerHTML="\n\nLoading Foldseek\n\n\n\n
        Foldseek is loading...
        \n",$.ajax({url:"https://search.foldseek.com/api/ticket",type:"POST",data:{q:e,database:["afdb50","afdb-swissprot","gmgcl_id","pdb100","afdb-proteome","mgnify_esm30"],mode:"3diaa"},dataType:"text",success:function(e){s.location="https://search.foldseek.com/queue/"+JSON.parse(e).id},error:function(e,t,s){console.log("Error in submitting data to Foldseek...")}})})),e.myEventCls.onIds("#"+e.pre+"jn_copy","click",(function(t){e.icn3d;let s=$("#"+e.pre+"jn_commands").val();navigator.clipboard.writeText(s)}))}setLogCmd(e,t,s){var i=this.icn3dui,n=i.icn3d;if(""===e.trim())return!1;let l=e.indexOf("|||");-1!==l&&(e=e.substr(0,l));let r={};if(n.quaternion||(n._zoomFactor=1,n.mouseChange=new THREE.Vector2(0,0),n.quaternion=new THREE.Quaternion(0,0,0,1)),r.factor=n._zoomFactor,r.mouseChange=n.mouseChange,r.quaternion={},r.quaternion._x=parseFloat(n.quaternion._x).toPrecision(5),r.quaternion._y=parseFloat(n.quaternion._y).toPrecision(5),r.quaternion._z=parseFloat(n.quaternion._z).toPrecision(5),r.quaternion._w=parseFloat(n.quaternion._w).toPrecision(5),t&&n.bAddCommands)if(n.STATENUMBER "+n.logs.join("\n> ")+"\n> "),$("#"+i.pre+"logtext")[0]&&$("#"+i.pre+"logtext").scrollTop($("#"+i.pre+"logtext")[0].scrollHeight)}n.setStyleCls.adjustIcon()}}class d{constructor(e){this.icn3dui=e}getLink(e,t,s,i){return this.icn3dui.htmlCls.setHtmlCls.getLink(e,t,s,i)}getMenuText(e,t,s,i,n){return this.icn3dui.htmlCls.setHtmlCls.getMenuText(e,t,s,i,n)}getMenuUrl(e,t,s,i,n){return this.icn3dui.htmlCls.setHtmlCls.getMenuUrl(e,t,s,i,n)}getMenuSep(){return this.icn3dui.htmlCls.setHtmlCls.getMenuSep()}getLinkWrapper(e,t,s,i,n,l){let r=this.icn3dui;return r.icn3d,r.htmlCls.setHtmlCls.getLinkWrapper(e,t,s,i,n,l)}getLinkWrapper2(e,t,s,i,n){let l=this.icn3dui;return l.icn3d,l.htmlCls.setHtmlCls.getLinkWrapper2(e,t,s,i,n)}getRadio(e,t,s,i,n,l){return this.icn3dui.htmlCls.setHtmlCls.getRadio(e,t,s,i,n,l)}getRadClr(e,t,s,i,n,l,r){return this.icn3dui.htmlCls.setHtmlCls.getRadioColor(e,t,s,i,n,l,r)}setTopMenusHtml(e,t,s){let i=this.icn3dui;if(i.bNode)return"";let n="black"==i.htmlCls.opts.background?i.htmlCls.GREYD:"black",l="";l+="
        ",l+=i.htmlCls.divStr+"popup' class='icn3d-text icn3d-popup'>
        ",l+=this.setReplayHtml(),l+="\x3c!--https://forum.jquery.com/topic/looking-for-a-jquery-horizontal-menu-bar--\x3e",l+=i.htmlCls.divStr+"mnlist' style='position:absolute; z-index:999; float:left; display:table-row; margin-top: -2px;'>",l+="";let r='",l+=r+this.setMenu2()+"",l+=r+this.setMenu2b()+"",l+=r+this.setMenu3()+"",l+=r+this.setMenu4()+"",l+=r+this.setMenu5()+"",l+=r+this.setMenu6()+"",i.htmlCls.shownMenus=i.hashUtilsCls.cloneHash(i.htmlCls.simpleMenus),l+=r+"
        "+t,l+="
        "+s,l+=r+'
        '+i.htmlCls.space2+'Toolbar '+i.htmlCls.space2+'
        ",l+=r+'
        '+i.htmlCls.space2+' ?
        ',l+="
        ",l+="
        ';if(l+=r+this.setMenu1()+"
        ",l+="",l+=this.setTools(),l+=i.htmlCls.divStr+"title' class='icn3d-commandTitle' style='font-size:1.2em; font-weight:normal; position:absolute; z-index:1; float:left; display:table-row; margin: 85px 0px 0px 5px; color:"+n+"; width:"+i.htmlCls.WIDTH+"px'>",l+=i.htmlCls.divStr+"viewer' style='position:relative; width:100%; height:100%; background-color: "+i.htmlCls.GREYD+";'>",l+=i.htmlCls.divStr+"mnLogSection'>",l+="
        ",l+=" ",void 0===i.cfg.mmtfid){let e="top:180px; font-size: 1.8em;";l+=i.htmlCls.divStr+"wait' style='position:absolute; left:50px; "+e+" color: #444444;'>Loading data..."}l+="Your browser does not support WebGL.",(void 0===i.cfg.showcommand||i.cfg.showcommand)&&(l+=this.setLogWindow()),l+="",l+="",l+=i.htmlCls.setDialogCls.setDialogs(),l+=i.htmlCls.setDialogCls.setCustomDialogs(),$("#"+e).html(l),$("accordion").accordion({collapsible:!0,active:!1,heightStyle:"content"}),$("accordion div").removeClass("ui-accordion-content ui-corner-all ui-corner-bottom ui-widget-content"),$(".icn3d-mn-item").menu({position:{my:"left top",at:"right top"}}),$(".icn3d-mn-item").hover((function(){}),(function(){$("accordion").accordion("option","active","none")})),$("#"+i.pre+"accordion1").hover((function(){$("#"+i.pre+"accordion1 div").css("display","block")}),(function(){$("#"+i.pre+"accordion1 div").css("display","none")})),$("#"+i.pre+"accordion2").hover((function(){$("#"+i.pre+"accordion2 div").css("display","block")}),(function(){$("#"+i.pre+"accordion2 div").css("display","none")})),$("#"+i.pre+"accordion2b").hover((function(){$("#"+i.pre+"accordion2b div").css("display","block")}),(function(){$("#"+i.pre+"accordion2b div").css("display","none")})),$("#"+i.pre+"accordion3").hover((function(){$("#"+i.pre+"accordion3 div").css("display","block")}),(function(){$("#"+i.pre+"accordion3 div").css("display","none")})),$("#"+i.pre+"accordion4").hover((function(){$("#"+i.pre+"accordion4 div").css("display","block")}),(function(){$("#"+i.pre+"accordion4 div").css("display","none")})),$("#"+i.pre+"accordion5").hover((function(){$("#"+i.pre+"accordion5 div").css("display","block")}),(function(){$("#"+i.pre+"accordion5 div").css("display","none")})),$("#"+i.pre+"accordion6").hover((function(){$("#"+i.pre+"accordion6 div").css("display","block")}),(function(){$("#"+i.pre+"accordion6 div").css("display","none")}))}setTopMenusHtmlMobile(e,t,s){let i=this.icn3dui;if(i.bNode)return"";let n="black"==i.htmlCls.opts.background?i.htmlCls.GREYD:"black",l="";if(l+="
        ",l+=i.htmlCls.divStr+"popup' class='icn3d-text icn3d-popup'>
        ",l+=this.setReplayHtml(),!i.utilsCls.isMobile()){let e=i.htmlCls.WIDTH-40+5;l+=i.htmlCls.buttonStr+"fullscreen' style='position:absolute; z-index:1999; display:block; padding:0px; margin: 12px 0px 0px "+e+"px; width:30px; height:34px; border-radius:4px; border:none; background-color:#f6f6f6;' title='Full screen'>",l+="",l+="",l+="",l+="",l+=""}l+="\x3c!--https://forum.jquery.com/topic/looking-for-a-jquery-horizontal-menu-bar--\x3e",l+=i.htmlCls.divStr+"mnlist' style='position:absolute; z-index:999; float:left; display:block; margin: 5px 0px 0px 5px;'>",l+="
        ",l+="",i.cfg.notebook?l+="

        ":l+="

        ",l+="
        ";let r="
      • File",l+=this.setMenu1_base(),l+=r+">Select",l+=this.setMenu2_base(),l+=r+">View",l+=this.setMenu2b_base(),l+=r+" id='"+i.pre+"style'>Style",l+=this.setMenu3_base(),l+=r+" id='"+i.pre+"color'>Color",l+=this.setMenu4_base(),l+=r+">Analysis",l+=this.setMenu5_base(),l+=r+">Help",l+=this.setMenu6_base(),i.htmlCls.shownMenus=i.hashUtilsCls.cloneHash(i.htmlCls.simpleMenus),l+="
      • "+t,l+="
        "+s,l+="
      • Alternate",l+="
      ",l+="",l+="",l+="",l+="",l+=i.htmlCls.divStr+"title' class='icn3d-commandTitle' style='font-size:1.2em; font-weight:normal; position:absolute; z-index:1; float:left; display:block; margin: 12px 0px 0px 40px; color:"+n+"; width:"+(i.htmlCls.WIDTH-40).toString()+"px'>",l+=i.htmlCls.divStr+"viewer' style='position:relative; width:100%; height:100%; background-color: "+i.htmlCls.GREYD+";'>",l+=i.htmlCls.divStr+"mnLogSection'>",l+="
      ",l+="",void 0===i.cfg.mmtfid){let e="top:180px; font-size: 1.8em;";l+=i.htmlCls.divStr+"wait' style='position:absolute; left:50px; "+e+" color: #444444;'>Loading data..."}l+="Your browser does not support WebGL.",(void 0===i.cfg.showcommand||i.cfg.showcommand)&&(l+=this.setLogWindow()),l+="",l+="",l+=i.htmlCls.setDialogCls.setDialogs(),l+=i.htmlCls.setDialogCls.setCustomDialogs(),$("#"+e).html(l),$("accordion").accordion({collapsible:!0,active:!1,heightStyle:"content"}),$("accordion div").removeClass("ui-accordion-content ui-corner-all ui-corner-bottom ui-widget-content"),$(".icn3d-mn-item").menu({position:{my:"left top",at:"right top"}}),$(".icn3d-mn-item").hover((function(){}),(function(){$("accordion").accordion("option","active","none")})),$("#"+i.pre+"accordion0").hover((function(){$("#"+i.pre+"accordion0 div").css("display","block")}),(function(){$("#"+i.pre+"accordion0 div").css("display","none")}))}setReplayHtml(e){let t=this.icn3dui;if(t.bNode)return"";let s="";return s+=t.htmlCls.divStr+"replay' style='display:none; position:absolute; z-index:9999; top:"+parseInt(t.htmlCls.HEIGHT-100).toString()+"px; left:20px;'>",s+="
      ",s+='',s+="",s+='',s+='',s+="",s+="
      ",s+=t.htmlCls.divStr+"replay_menu' style='background-color:#DDDDDD; padding:3px; font-weight:bold;'>",s+=t.htmlCls.divStr+"replay_cmd' style='background-color:#DDDDDD; padding:3px; max-width:250px'>",s+="",s}setTools(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+=e.htmlCls.divStr+"selection' style='display:none;'>
      ",t+="",t+=this.setTools_base(),t+="
      ",t+="
      ",t}setButton(e,t,s,i,n){let l=this.icn3dui;return l.bNode?"":(n=void 0!==n?"color:"+n:"","
      ")}setIcon(e,t,s,i,n,l,r){let o=this.icn3dui;if(o.bNode)return"";let a,d=r?"color:#f8b84e; ":"color:#1c94c4; ",c=" background-color:#EEE; ",h="text"==e?"":"cursor:pointer;";return a=l?'
      '+i+"
      ":'',"link"==e?''+a+"":a}setTools_base(){if(this.icn3dui.bNode)return"";let e="",t="regular",s="",i="";return e+=s+this.setIcon(t,"tool_mmdbafid","Input PDB/MMDB/AlphaFold IDs","id",void 0,!0)+"",e+=s+this.setIcon(t,"tool_pdbfile","Input PDB Files (appendable)","file-alt")+"",e+=s+this.setIcon(t,"tool_sharelink","Get Share Link","link")+"",e+=s+this.setIcon(t,"saveimage","Save iCn3D PNG Image","camera")+"",e+=i+this.setIcon(t,"tool_definedsets","Defined Sets","object-group")+"",e+=s+this.setIcon(t,"tool_aroundsphere","Select by Distance","dot-circle")+"",e+=s+this.setIcon(t,"tool_saveselection","Save Selection as a Set","save")+"",e+=s+this.setIcon(t,"toggleHighlight","Toggle Highlight","highlighter")+"",e+=i+this.setIcon(t,"show_selected","View Selection","eye")+"",e+=s+this.setIcon(t,"tool_selectedcenter","Zoom in Selection","search-plus")+"",e+=s+this.setIcon(t,"alternate","Alternate the Structures by keying the letter 'a'","a",void 0,!0,!0)+"",e+=s+this.setIcon(t,"tool_resetOrientation","Reset Orientation","undo-alt")+"",e+=i+this.setIcon(t,"tool_proteinsRibbon","Style Ribbon for proteins","dna")+"",e+=s+this.setIcon(t,"tool_proteinsSphere","Style Sphere for proteins","volleyball-ball")+"",e+=s+this.setIcon(t,"tool_surfaceVDW","Show Van der Waals Surface","cloud")+"",e+=s+this.setIcon(t,"tool_bkgd","Toggle Background Color","adjust")+"",e+=i+this.setIcon(t,"tool_clrRainbowChain","Color Rainbow for Chains","rainbow")+"",e+=s+this.setIcon(t,"tool_clrSSGreen","Color by Secondary Structures","ring")+"",e+=s+this.setIcon(t,"tool_clrChain","Color by Chains","layer-group")+"",e+=s+this.setIcon(t,"tool_clrAtom","Color by Atoms","atom")+"",e+=i+this.setIcon(t,"tool_selectannotations","Sequences & Annotations","grip-lines")+"",e+=s+this.setIcon(t,"hbondsYes","Interactions","users")+"",e+=s+this.setIcon(t,"tool_delphi","Delphi Potentials","cloud-meatball")+"",e+=s+this.setIcon(t,"removeLabels","Remove Labels","remove-format")+"",e+=i+this.setIcon("link","tool-gallery","Gallery","image","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#gallery")+"",e+=s+this.setIcon("link","tool-video","Videos","file-video","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#videos")+"",e+=s+this.setIcon("link","tool-github","iCn3D GitHub","code","https://github.com/ncbi/icn3d")+"",e+=s+this.setIcon("link","tool-hints","Transform Hints","info-circle","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#useicn3d")+"",e+="",e}setTheme(e){let t,s,i,n,l,r=this.icn3dui;if(r.bNode)return"";r.htmlCls.themecolor=e,"orange"==e?(t="#e78f08",s="#f6a828",i="ui-bg_gloss-wave_35_f6a828_500x100.png",n="ui-icons_ef8c08_256x240.png",l="#eb8f00"):"black"==e?(t="#333333",s="#333333",i="ui-bg_gloss-wave_25_333333_500x100.png",n="ui-icons_222222_256x240.png",l="#222222"):"blue"==e&&(t="#4297d7",s="#5c9ccc",i="ui-bg_gloss-wave_55_5c9ccc_500x100.png",n="ui-icons_228ef1_256x240.png",l="#444"),$(".ui-widget-header").css({border:"1px solid "+t,background:s+' url("https://www.ncbi.nlm.nih.gov/Structure/icn3d/lib/images/'+i+'") 50% 50% repeat-x',color:"#fff","font-weight":"bold"}),$(".ui-button .ui-icon").css({"background-image":"url(https://www.ncbi.nlm.nih.gov/Structure/icn3d/lib/images/"+n+")"}),$(".ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited").css({color:l,"text-decoration":"none"})}setLogWindow(e,t){let s=this.icn3dui;if(s.bNode)return"";let i,n="",l=s.htmlCls.setHtmlCls.getCookie("cmdwindow");return""!=l?(i=void 0!==t?t:parseInt(l),1==i?(s.htmlCls.LOG_HEIGHT=180,s.htmlCls.CMD_HEIGHT=.8*s.htmlCls.LOG_HEIGHT,e||(n+=s.htmlCls.divStr+"cmdlog' style='float:left; margin-top: 5px; width: 100%;'>"),n+=""):(s.htmlCls.LOG_HEIGHT=65,s.htmlCls.CMD_HEIGHT=.8*s.htmlCls.LOG_HEIGHT,e||(n+=s.htmlCls.divStr+"cmdlog' style='float:left; margin-top: 5px; width: 100%;'>"),n+="")):(i=0,s.htmlCls.LOG_HEIGHT=65,s.htmlCls.CMD_HEIGHT=.8*s.htmlCls.LOG_HEIGHT,e||(n+=s.htmlCls.divStr+"cmdlog' style='float:left; margin-top: 5px; width: 100%;'>"),n+=""),e||(n+=""),e&&(s.htmlCls.clickMenuCls.setLogCmd("set cmdwindow "+i,!0),$("#"+s.pre+"cmdlog").html(n)),n}setMenu1(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+="",t+="

      File

      ",t+="
      ",t+=this.setMenu1_base(),t+="
      ",t+="
      ",t+="
      ",t}setMenu1_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
        ",t+=this.getMenuText("mn1_searchgrooup","Search Structure "+e.htmlCls.wifiStr,void 0,1,1),t+="
          ",t+=this.getMenuUrl("mn1_searchstru","https://www.ncbi.nlm.nih.gov/structure","PDB Structures "+e.htmlCls.wifiStr,1,2),t+=this.getLink("mn1_proteinname","AlphaFold Structures "+e.htmlCls.wifiStr,1,2),t+=this.getMenuUrl("mn1_afdatabase","https://alphafold.ebi.ac.uk","AlphaFold UniProt Database "+e.htmlCls.wifiStr,void 0,2),t+="
        ",t+="",t+=this.getMenuText("mn1_searchsimilar","Search Similar"+e.htmlCls.wifiStr,void 0,void 0,1),t+="
          ",t+=this.getLink("mn1_vastplus","NCBI VAST+ (PDB Complex)"+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_vast","NCBI VAST (PDB Chain)"+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_foldseek","Foldseek (PDB & AlphaFold)"+e.htmlCls.wifiStr,void 0,2),t+="
        ",t+="",t+=this.getMenuText("mn1_retrievebyid","Retrieve by ID",void 0,1,1),t+="
          ",t+=this.getLink("mn1_mmdbafid","PDB/MMDB/AlphaFold IDs"+e.htmlCls.wifiStr,1,2),t+=this.getLink("mn1_mmdbid","NCBI MMDB ID (annotation) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_mmtfid","RCSB MMTF ID (fast) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_pdbid","RCSB PDB ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getMenuText("mn1_afwrap","AlphaFold Structures",void 0,void 0,2),t+="
            ",t+=this.getLink("mn1_afid","UniProt ID "+e.htmlCls.wifiStr,void 0,3),t+=this.getLink("mn1_refseqid","NCBI Protein Accession "+e.htmlCls.wifiStr,void 0,3),t+="
          ",t+=this.getLink("mn1_opmid","OPM PDB ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_mmcifid","RCSB mmCIF ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_cid","PubChem CID "+e.htmlCls.wifiStr,1,2),t+="
        ",t+="",t+=this.getMenuText("mn1_openfile","Open File",void 0,1,1),t+="
          ",t+=this.getLink("mn1_pdbfile_app","PDB Files (appendable)",1,2),t+=this.getLink("mn1_mmciffile","mmCIF File",void 0,2),t+=this.getLink("mn1_mol2file","Mol2 File",void 0,2),t+=this.getLink("mn1_sdffile","SDF File",void 0,2),t+=this.getLink("mn1_xyzfile","XYZ File",void 0,2),t+=this.getLink("mn1_afmapfile","AlphaFold PAE File",void 0,2),t+=this.getLink("mn1_urlfile","URL(CORS) "+e.htmlCls.wifiStr,void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_pngimage","iCn3D PNG Image",1,2),t+=this.getLink("mn1_state","State/Script File",void 0,2),t+=this.getLink("mn1_fixedversion","Share Link in Archived Ver. "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_selection","Selection File",void 0,2),t+=this.getMenuSep(),t+=this.getMenuText("mn1_dsn6wrap","Electron Density",void 0,void 0,2),t+="
            ",t+=this.getLink("mn1_dsn6","Local File",void 0,3),t+=this.getLink("mn1_dsn6url","URL(CORS) "+e.htmlCls.wifiStr,void 0,3),t+="
          ",t+="

        • ",t+="
        ",t+="",t+=this.getMenuText("mn1_fold","Predict by Seq.",void 0,void 0,1),t+="
          ",t+=this.getLink("mn1_esmfold","ESMFold",void 0,2),t+=this.getLink("mn1_alphafold","AlphaFold2 via ColabFold"+e.htmlCls.wifiStr,void 0,2),t+="
        ",t+=this.getMenuText("mn1_alignwrap","Align",void 0,1,1),t+="
          ",t+=this.getMenuText("mn1_chainalignwrap","Multiple Chains",void 0,1,2),t+="
            ",t+=this.getRadio("mn1_chainalignRad","mn1_chainalign","by Structure Alignment "+e.htmlCls.wifiStr,void 0,1,3),t+=this.getRadio("mn1_chainalignRad","mn1_chainalign2","by Sequence Alignment "+e.htmlCls.wifiStr,void 0,1,3),t+=this.getRadio("mn1_chainalignRad","mn1_chainalign3","Residue by Residue",void 0,void 0,3),t+="
          ",t+="",t+=this.getMenuText("mn1_aligntwostru","Protein Complexes",void 0,void 0,2),t+="
            ",t+=this.getLink("mn1_align","Two PDB Structures "+e.htmlCls.wifiStr,void 0,3),t+=this.getLink("mn1_alignaf","Two AlphaFold Structures "+e.htmlCls.wifiStr,void 0,3),t+="
          ",t+=this.getLink("mn1_blast_rep_id","Sequence to Structure",void 0,2),t+="
        ",t+="",t+=this.getMenuText("mn2_realignWrap","Realign Selection",void 0,void 0,1),t+="
          ",t+=this.getMenuText("mn2_chainrealignwrap","Multiple Chains",void 0,void 0,2),t+="
            ",t+=this.getRadio("mn2_realign","mn2_realignonstruct","by Structure Alignment "+e.htmlCls.wifiStr,void 0,void 0,3),t+=this.getRadio("mn2_realign","mn2_realignonseqalign","by Sequence Alignment "+e.htmlCls.wifiStr,void 0,void 0,3),t+=this.getRadio("mn2_realign","mn2_realignresbyres","Residue by Residue",void 0,void 0,3),t+="
          ",t+=this.getLink("mn2_realigntwostru","Protein Complexes",void 0,2),t+="
        ",t+="",t+=this.getMenuText("mn1_3dpprint","3D Printing",void 0,1,1),t+="
          ",void 0===e.cfg.cid?(t+=this.getLink("mn1_exportVrmlStab","WRL/VRML(Color, W/ Stab.)",1,2),t+=this.getLink("mn1_exportStlStab","STL(W/ Stabilizers)",1,2),t+=this.getMenuSep(),t+=this.getLink("mn1_exportVrml","WRL/VRML(Color)",void 0,2),t+=this.getLink("mn1_exportStl","STL",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_stabilizerYes","Add All Stabilizers",void 0,2),t+=this.getLink("mn1_stabilizerNo","Remove All Stabilizers",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_stabilizerOne","Add One Stabilizer",void 0,2),t+=this.getLink("mn1_stabilizerRmOne","Remove One Stabilizer",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn1_thicknessSet","Set Thickness",void 0,2)):(t+=this.getLink("mn1_exportVrml","VRML(Color)",1,2),t+=this.getLink("mn1_exportStl","STL",1,2)),t+="
        ",t+="",t+=this.getMenuText("mn1_savefile","Save File",void 0,1,1),t+="
          ",t+=this.getMenuText("mn1_savepngimage","iCn3D PNG Image",void 0,1,2),t+="
            ",t+=this.getLink("mn1_exportCanvas","Original Size & HTML",1,3),t+=this.getLink("mn1_exportCanvas1","Original Size",void 0,3),t+=this.getLink("mn1_exportCanvas2","2X Large",void 0,3),t+=this.getLink("mn1_exportCanvas4","4X Large",void 0,3),t+=this.getLink("mn1_exportCanvas8","8X Large",void 0,3),t+="
          ",t+="",t+=this.getLink("mn1_exportState","State File",void 0,2),t+=this.getLink("mn1_exportSelections","Selection File",void 0,2),t+=this.getLink("mn1_exportSelDetails","Selection Details",void 0,2),t+=this.getLink("mn1_exportCounts","Residue Counts",void 0,2),t+=this.getLink("mn1_exportPdbRes","PDB",1,2),t+=this.getLink("profixpdb","PDB with Missing Atoms",void 0,2),void 0===e.cfg.cid&&(t+=this.getLink("mn1_exportSecondary","Secondary Structure",void 0,2)), //!!! t+=this.getMenuText("m1_exportrefnum","Reference Numbers",void 0,void 0,2),t+="
            ",t+=this.getLink("mn1_exportIgstrand","Ig Strand",void 0,3),t+=this.getLink("mn1_exportKabat","Kabat",void 0,3),t+=this.getLink("mn1_exportImgt","IMGT",void 0,3),t+="
          ",t+="

        • ",t+="
        ",t+="",t+=this.getLink("mn1_sharelink","Share Link "+e.htmlCls.wifiStr,1,1),t+=this.getLink("mn1_replayon","Replay Each Step",void 0,1),t+=this.getMenuSep(),t+=this.getMenuText("mn1_menuwrap","Customize Menus",void 0,1,1),t+="
          ",t+=this.getLink("mn1_menuall","All Menus",1,2),t+=this.getLink("mn1_menusimple","Simple Menus",1,2),t+=this.getMenuSep(),t+=this.getLink("mn1_menupref","Preferences",1,2),t+=this.getLink("mn1_menuloadpref","Load Preferences",1,2),t+="
        ",t+="",t+="

      • ",t+="
      ",t}setMenu2(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+="",t+="

      Select

      ",t+="
      ",t+=this.setMenu2_base(),t+="
      ",t+="
      ",t+="
      ",t}setMenu2_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
        ",t+=this.getLink("mn2_definedsets","Defined Sets",1,1),t+=this.getLink("mn2_selectall","All",void 0,1),t+=this.getLink("mn2_selectdisplayed","Displayed Set",void 0,1),t+=this.getLink("mn2_aroundsphere","by Distance",1,1),t+=this.getMenuText("mn2_selbyprop","by Property",void 0,void 0,1),t+="
          ",t+=this.getLink("mn2_propPos","Positive",void 0,2),t+=this.getLink("mn2_propNeg","Negative",void 0,2),t+=this.getLink("mn2_propHydro","Hydrophobic",void 0,2),t+=this.getLink("mn2_propPolar","Polar",void 0,2),t+=this.getLink("mn2_propBfactor","B-factor/pLDDT",void 0,2),t+=this.getLink("mn2_propSolAcc","Solvent Accessibility",void 0,2),t+="
        ",t+="",t+=this.getLink("mn2_selectcomplement","Inverse",void 0,1),t+=this.getLink("mn2_selectmainchains","Main Chains",void 0,1),t+=this.getLink("mn2_selectsidechains","Side Chains",void 0,1),t+=this.getLink("mn2_selectmainsidechains","Main & Side Chains",void 0,1),t+=this.getLink("mn2_command","Advanced",void 0,1),void 0===e.cfg.cid?(t+=this.getMenuText("mn2_selon3d","Select on 3D",void 0,1,1),t+="
          ",t+='
        • "Alt"+Click: start selection
        • ',t+='
        • "Ctrl"+Click: union selection
        • ',t+='
        • "Shift"+Click: range Selection
        • ',t+=this.getMenuSep(),t+=this.getRadio("mn2_pk","mn2_pkChain","Chain",void 0,1,2),void 0===e.cfg.mmdbid&&void 0===e.cfg.gi||(t+=this.getRadio("mn2_pk","mn2_pkDomain","3D Domain",void 0,void 0,2)),t+=this.getRadio("mn2_pk","mn2_pkStrand","Strand/Helix",void 0,void 0,2),t+=this.getRadio("mn2_pk","mn2_pkResidue","Residue",!0,1,2),t+=this.getRadio("mn2_pk","mn2_pkYes","Atom",void 0,1,2),t+=this.getRadio("mn2_pk","mn2_pkNo","None",void 0,void 0,2),t+="
        ",t+=""):e.utilsCls.isMobile()?t+="
      • Touch to pick
      • ":t+='
      • Picking with
        "Alt" + Click
      • ',t+=this.getMenuSep(),t+=this.getLink("mn2_saveselection","Save Selection",1,1),t+=this.getLink("clearall","Clear Selection",void 0,1),t+=this.getLink("mn2_saveresidue","Save Res. in Sel.",1,1),t+=this.getMenuSep(),t+=this.getMenuText("mn2_hlcolor","Highlight Color",void 0,void 0,1),t+="
          ",t+=this.getRadio("mn2_hl_clr","mn2_hl_clrYellow","Yellow",!0,void 0,2),t+=this.getRadio("mn2_hl_clr","mn2_hl_clrGreen","Green",void 0,void 0,2),t+=this.getRadio("mn2_hl_clr","mn2_hl_clrRed","Red",void 0,void 0,2),t+="
        ",t+="",t+=this.getMenuText("mn2_hlstyle","Highlight Style",void 0,void 0,1),t+="
          ",t+=this.getRadio("mn2_hl_style","mn2_hl_styleOutline","Outline",!0,void 0,2),t+=this.getRadio("mn2_hl_style","mn2_hl_styleObject","3D Objects",void 0,void 0,2),t+="
        ",t+="",t+=this.getLink("toggleHighlight2","Toggle Highlight",1,1),t+="

      • ",t+="
      ",t}setMenu2b(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+="",t+="

      View

      ",t+="
      ",t+=this.setMenu2b_base(),t+="
      ",t+="
      ",t+="
      ",t}setMenu2b_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
        ",t+=this.getLink("mn2_show_selected","View Selection",1,1),t+=this.getLink("mn2_hide_selected","Hide Selection",1,1),t+=this.getLink("mn2_selectedcenter","Zoom in Selection",1,1),t+=this.getLink("mn6_center","Center Selection",1,1),t+=this.getLink("mn2_fullstru","View Full Structure"),t+=this.getLinkWrapper("mn2_alternate",'Alternate(Key "a")',"mn2_alternateWrap",void 0,1),void 0!==e.cfg.opmid?t+=this.getLinkWrapper("togglemem","Toggle Membrane","togglememli",void 0,1):void 0===e.cfg.cid&&(t+=this.getLinkWrapper("togglemem","Toggle Membrane","togglememli",void 0,1,!0)),void 0!==e.cfg.opmid&&(t+=this.getLinkWrapper("adjustmem","Adjust Membrane","adjustmemli",void 0,1),t+=this.getLinkWrapper("selectplane","Select between
        Two X-Y Planes","selectplaneli",void 0,1)),t+=this.getMenuSep(),t+=this.getMenuText("mn2_vrarhints","VR & AR Hints",void 0,1,1),t+="
          ",t+=this.getMenuUrl("vrhint",e.htmlCls.baseUrl+"icn3d/icn3d.html#vr","VR: VR Headsets",1,2),t+=this.getMenuUrl("arhint",e.htmlCls.baseUrl+"icn3d/icn3d.html#ar","AR: Chrome in Android",1,2),t+="
        ",t+="",t+=this.getLink("mn6_sidebyside","Side by Side",1,1),t+=this.getMenuText("mn2_rotate","Rotate",void 0,1,1),t+="
          ",t+=this.getMenuText("mn2_rotate90","Rotate 90°",void 0,void 0,2),t+="
            ",t+=this.getRadio("mn6_rotate90","mn6_rotatex","rotate x",void 0,void 0,2),t+=this.getRadio("mn6_rotate90","mn6_rotatey","rotate y",void 0,void 0,2),t+=this.getRadio("mn6_rotate90","mn6_rotatez","rotate z",void 0,void 0,2),t+="
          ",t+="",t+=this.getMenuText("mn2_rotateauto","Auto Rotation",void 0,1,2),t+="
            ",t+=this.getRadio("mn6_rotate","mn6_rotateleft","Rotate Left",void 0,1,3),t+=this.getRadio("mn6_rotate","mn6_rotateright","Rotate Right",void 0,1,3),t+=this.getRadio("mn6_rotate","mn6_rotateup","Rotate Up",void 0,1,3),t+=this.getRadio("mn6_rotate","mn6_rotatedown","Rotate Down",void 0,1,3),t+="
          ",t+="",t+="
        ",t+="",t+=this.getMenuText("mn2_camera","Camera",void 0,void 0,1),t+="
          ",t+=this.getRadio("mn6_camera","mn6_cameraPers","Perspective",!0,void 0,2),t+=this.getRadio("mn6_camera","mn6_cameraOrth","Orthographic",void 0,void 0,2),t+="
        ",t+="",t+=this.getMenuText("mn2_fog","Fog for Selection",void 0,void 0,1),t+="
          ",t+=this.getRadio("mn6_showfog","mn6_showfogYes","On",void 0,void 0,2),t+=this.getRadio("mn6_showfog","mn6_showfogNo","Off",!0,void 0,2),t+="
        ",t+="",t+=this.getMenuText("mn2_slab","Slab for Selection",void 0,void 0,1),t+="
          ",t+=this.getRadio("mn6_showslab","mn6_showslabYes","On",void 0,void 0,2),t+=this.getRadio("mn6_showslab","mn6_showslabNo","Off",!0,void 0,2),t+="
        ",t+="",t+=this.getMenuText("mn2_axes","XYZ-axes",void 0,void 0,1),t+="
          ",t+=this.getRadio("mn6_showaxis","mn6_showaxisYes","Original",void 0,void 0,2),t+=this.getRadio("mn6_showaxis","mn6_showaxisSel","Prin. Axes on Sel.",void 0,void 0,2),t+=this.getRadio("mn6_showaxis","mn6_showaxisNo","Hide",!0,void 0,2),t+="
        ",t+="",t+=this.getMenuSep(),t+=this.getMenuText("mn2_resetwrap","Reset",void 0,1,1),t+="
          ",t+=this.getRadio("mn6_reset","reset","All",void 0,1,2),t+=this.getRadio("mn6_reset","mn6_resetOrientation","Orientation",void 0,1,2),t+="
        ",t+="",t+=this.getLink("mn6_back","Undo",void 0,1),t+=this.getLink("mn6_forward","Redo",void 0,1),t+=this.getLink("mn6_fullscreen","Full Screen",void 0,1),t+="

      • ",t+="
      ",t}setMenu3(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+="",t+="

      Style

      ",t+="
      ",t+=this.setMenu3_base(),t+="
      ",t+="
      ",t+="
      ",t}setMenu3_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";t+="
        ",void 0===e.cfg.cid&&(t+=this.getMenuText("mn3_proteinwrap","Proteins",void 0,1,1),t+="
          ",void 0!==e.cfg.align||void 0!==e.cfg.chainalign?t+=this.getRadio("mn3_proteins","mn3_proteinsRibbon","Ribbon",void 0,1,2):t+=this.getRadio("mn3_proteins","mn3_proteinsRibbon","Ribbon",!0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsStrand","Strand",void 0,void 0,2),t+=this.getRadio("mn3_proteins","mn3_proteinsCylinder","Cylinder and Plate",void 0,void 0,2),t+=this.getRadio("mn3_proteins","mn3_proteinsSchematic","Schematic",void 0,1,2),void 0!==e.cfg.align||void 0!==e.cfg.chainalign?t+=this.getRadio("mn3_proteins","mn3_proteinsCalpha","C Alpha Trace",!0,1,2):t+=this.getRadio("mn3_proteins","mn3_proteinsCalpha","C Alpha Trace",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsBackbone","Backbone",void 0,void 0,2),t+=this.getRadio("mn3_proteins","mn3_proteinsBfactor","B-factor Tube",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsLines","Lines",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsStick","Stick",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_proteins","mn3_proteinsNo","Hide",void 0,1,2),t+="
        ",t+="",t+=this.getMenuText("mn3_sidecwrap","Side Chains",void 0,1,1),t+="
          ",t+=this.getRadio("mn3_sidec","mn3_sidecLines","Lines",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecStick","Stick",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_sidec","mn3_sidecNo","Hide",!0,1,2),t+="
        ",t+="",t+=this.getMenuText("mn3_nuclwrap","Nucleotides",void 0,1,1),t+="
          ",t+=this.getRadio("mn3_nucl","mn3_nuclCartoon","Cartoon",!0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclPhos","O3' Trace",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclBackbone","Backbone",void 0,void 0,2),t+=this.getRadio("mn3_nucl","mn3_nuclSchematic","Schematic",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclLines","Lines",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclStick","Stick",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_nucl","mn3_nuclNo","Hide",void 0,1,2),t+="
        ",t+="",t+=this.getMenuText("mn3_ntbasewrap","Nucl. Bases",void 0,1,1),t+="
          ",t+=this.getRadio("mn3_ntbase","mn3_ntbaseLines","Lines",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseStick","Stick",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseBallstick","Ball and Stick",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_ntbase","mn3_ntbaseNo","Hide",!0,1,2),t+="
        ",t+=""),t+=this.getMenuText("mn3_ligwrap","Chemicals",void 0,1,1),t+="
          ",t+=this.getRadio("mn3_lig","mn3_ligLines","Lines",void 0,1,2),void 0===e.cfg.cid?(t+=this.getRadio("mn3_lig","mn3_ligStick","Stick",!0,1,2),t+=this.getRadio("mn3_lig","mn3_ligBallstick","Ball and Stick",void 0,1,2)):(t+=this.getRadio("mn3_lig","mn3_ligStick","Stick",void 0,1,2),t+=this.getRadio("mn3_lig","mn3_ligBallstick","BalHydrogensl and Stick",!0,1,2)),t+=this.getRadio("mn3_lig","mn3_ligSchematic","Schematic",void 0,1,2),t+=this.getRadio("mn3_lig","mn3_ligSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_lig","mn3_ligNo","Hide",void 0,1,2),t+="
        ",t+="",t+=this.getMenuText("mn3_hydrogenswrap","Hydrogens",void 0,1,1),t+="
          ",t+=this.getRadio("mn3_hydrogens","mn3_hydrogensYes","Show",!0,1,2),t+=this.getRadio("mn3_hydrogens","mn3_hydrogensNo","Hide",void 0,1,2),t+="
        ",t+="",void 0===e.cfg.cid&&(t+=this.getMenuText("mn3_glycanwrap","Glycans",void 0,void 0,1),t+="
          ",t+=this.getRadio("mn3_glycansCart","mn3_glycansCartYes","Show Cartoon",void 0,void 0,2),t+=this.getRadio("mn3_glycansCart","mn3_glycansCartNo","Hide Cartoon",!0,void 0,2),t+="
        ",t+=""),t+=this.getMenuText("mn3_ionswrap","Ions",void 0,1,1),t+="
          ",t+=this.getRadio("mn3_ions","mn3_ionsSphere","Sphere",!0,1,2),t+=this.getRadio("mn3_ions","mn3_ionsDot","Dot",void 0,1,2),t+=this.getRadio("mn3_ions","mn3_ionsNo","Hide",void 0,1,2),t+="
        ",t+="",t+=this.getMenuText("mn3_waterwrap","Water",void 0,1,1),t+="
          ",t+=this.getRadio("mn3_water","mn3_waterSphere","Sphere",void 0,1,2),t+=this.getRadio("mn3_water","mn3_waterDot","Dot",void 0,1,2),t+=this.getRadio("mn3_water","mn3_waterNo","Hide",!0,1,2),t+="
        ",t+="",t+=this.getLink("mn3_setThickness","Preferences",void 0,1),t+=this.getMenuSep(),t+=this.getLink("mn3_styleSave","Save Style",void 0,2),t+=this.getLink("mn3_styleApplySave","Apply Saved Style",void 0,2),t+=this.getMenuSep(),t+=this.getMenuText("mn5_surfacewrap","Surface Type",void 0,1,1),t+="
          ",t+=this.getRadio("mn5_surface","mn5_surfaceVDW","Van der Waals",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceVDWContext","VDW with Context",void 0,void 0,2),t+=this.getRadio("mn5_surface","mn5_surfaceMolecular","Molecular Surface",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceMolecularContext","MS with Context",void 0,void 0,2),t+=this.getRadio("mn5_surface","mn5_surfaceSAS","Solvent Accessible",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceSASContext","SA with Context",void 0,void 0,2),t+="
        ",t+="",t+=this.getLink("mn5_surfaceNo","Remove Surface",1,1),t+=this.getMenuText("mn5_surfaceop","Surface Opacity",void 0,1,1),t+="
          ",t+=this.getMenuText("mn5_surfaceopfast","Fast Transparency",void 0,1,2),t+="
            ",t+=this.getRadio("mn5_opacity","mn5_opacity10","1.0",!0,1,3);for(let e=9;e>0;--e)t+=this.getRadio("mn5_opacity","mn5_opacity0"+e,"0."+e,1,3);t+="
          ",t+="",t+=this.getMenuText("mn5_surfaceopslow","Slow Transparency",void 0,void 0,2),t+="
            ",t+=this.getRadio("mn5_opacityslow","mn5_opacityslow10","1.0",!0,void 0,3);for(let e=9;e>0;--e)t+=this.getRadio("mn5_opacityslow","mn5_opacityslow0"+e,"0."+e,void 0,void 0,3);return t+="
          ",t+="",t+="
        ",t+=this.getMenuText("mn5_wireframewrap","Surface Wireframe",void 0,1,1),t+="
          ",t+=this.getRadio("mn5_wireframe","mn5_wireframeYes","Yes",void 0,1,2),t+=this.getRadio("mn5_wireframe","mn5_wireframeNo","No",!0,1,2),t+="
        ",t+="",t+=this.getMenuSep(),t+=this.getLink("mn5_cartoonshape","Cartoon for a Set",void 0,1),t+=this.getLink("mn5_linebtwsets","Line btw. Two Sets",void 0,1),void 0===e.cfg.cid&&void 0===e.cfg.align&&void 0===e.cfg.chainalign&&void 0===e.cfg.mmdbaf&&(t+=this.getMenuSep(),t+=this.getLinkWrapper2("mn5_map","Electron Density","mapWrapper1",void 0,1),t+="
          ",t+=this.getLink("mn5_elecmap2fofc","2Fo-Fc Map",void 0,2),t+=this.getLink("mn5_elecmapfofc","Fo-Fc Map",void 0,2),t+=this.getLinkWrapper("mn5_elecmapNo","Remove Map","mapWrapper2",void 0,2),t+="
        ",t+="",t+=this.getLinkWrapper2("mn5_map3","Map Wireframe","mapWrapper3",void 0,1),t+="
          ",t+=this.getRadio("mn5_mapwireframe","mn5_mapwireframeYes","Yes",!0,void 0,2),t+=this.getRadio("mn5_mapwireframe","mn5_mapwireframeNo","No",void 0,void 0,2),t+="
        ",t+="",void 0===e.cfg.mmtfid&&(t+=this.getLinkWrapper("mn5_emmap","EM Density Map","emmapWrapper1",void 0,1),t+=this.getLinkWrapper("mn5_emmapNo","Remove EM Map","emmapWrapper2",void 0,1),t+=this.getLinkWrapper2("mn5_emmap3","EM Map Wireframe","emmapWrapper3",void 0,1),t+="
          ",t+=this.getRadio("mn5_emmapwireframe","mn5_emmapwireframeYes","Yes",!0,void 0,2),t+=this.getRadio("mn5_emmapwireframe","mn5_emmapwireframeNo","No",void 0,void 0,2),t+="
        ",t+="")),t+=this.getMenuSep(),t+=this.getMenuText("mn6_bkgdwrap","Background",void 0,1,1),t+="
          ",t+=this.getRadio("mn6_bkgd","mn6_bkgdTransparent","Transparent",void 0,1,2),t+=this.getRadio("mn6_bkgd","mn6_bkgdBlack","Black",!0,1,2),t+=this.getRadio("mn6_bkgd","mn6_bkgdGrey","Gray",void 0,1,2),t+=this.getRadio("mn6_bkgd","mn6_bkgdWhite","White",void 0,1,2),t+="
        ",t+="",t+=this.getMenuText("mn6_themewrap","Dialog Color",void 0,void 0,1),t+="
          ",t+=this.getRadio("mn6_theme","mn6_themeBlue","Blue",!0,void 0,2),t+=this.getRadio("mn6_theme","mn6_themeOrange","Orange",void 0,void 0,2),t+=this.getRadio("mn6_theme","mn6_themeBlack","Black",void 0,void 0,2),t+="
        ",t+="",t+="

      • ",t+="
      ",t}setMenu4(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+="",t+="

      Color

      ",t+="
      ",t+=this.setMenu4_base(),t+="
      ",t+="
      ",t+="
      ",t}setMenu4_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
        ",t+=this.getMenuText("mn4_clrwrap","Unicolor","icn3d-menupd",1,1),t+="
          ",t+=this.getMenuText("uniclrRedwrap","Red",void 0,1,2),t+="
            ",t+=this.getRadClr("mn4_clr","uniclrRed1","Red","F00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed2","Indian Red","CD5C5C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed3","Light Coral","F08080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed4","Salmon","FA8072",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed5","Dark Salmon","E9967A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed6","Light Salmon","FFA07A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed7","Crimson","DC143C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed8","Fire Brick","B22222",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrRed9","Dark Red","8B0000",void 0,1,3),t+="
          ",t+=this.getMenuText("uniclrPinkwrap","Pink",void 0,1,2),t+="
            ",t+=this.getRadClr("mn4_clr","uniclrPink1","Pink","FFC0CB",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink2","Light Pink","FFB6C1",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink3","Hot Pink","FF69B4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink4","Deep Pink","FF1493",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink5","Medium Violet Red","C71585",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrPink6","Pale Violet Red","DB7093",void 0,1,3),t+="
          ",t+=this.getMenuText("uniclrOrangewrap","Orange",void 0,1,2),t+="
            ",t+=this.getRadClr("mn4_clr","uniclrOran1","Orange","FFA500",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran2","Dark Orange","FF8C00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran3","Orange Red","FF4500",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran4","Tomato","FF6347",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran5","Coral","FF7F50",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrOran6","Light Salmon","FFA07A",void 0,1,3),t+="
          ",t+=this.getMenuText("uniclrYellowwrap","Yellow",void 0,1,2),t+="
            ",t+=this.getRadClr("mn4_clr","uniclrYllw1","Yellow","FF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw2","Gold","FFD700",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw3","Light Yellow","FFFFE0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw4","Lemon Chiffon","FFFACD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw5","Light Golden Rod","FAFAD2",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw6","Papaya Whip","FFEFD5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw7","Moccasin","FFE4B5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw8","Peach Puff","FFDAB9",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw9","Pale Golden Rod","EEE8AA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw10","Khaki","F0E68C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrYllw11","Dark Khaki","BDB76B",void 0,1,3),t+="
          ",t+=this.getMenuText("uniclrMagentawrap","Magenta",void 0,1,2),t+="
            ",t+=this.getRadClr("mn4_clr","uniclrMgnt1","Magenta","F0F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt2","Orchid","DA70D6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt3","Violet","EE82EE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt4","Plum","DDA0DD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt5","Thistle","D8BFD8",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt6","Lavender","E6E6FA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt7","Medium Orchid","BA55D3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt8","Medium Purple","9370DB",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt9","Rebecca Purple","663399",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt10","Blue Violet","8A2BE2",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt11","Dark Violet","9400D3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt12","Dark Orchid","9932CC",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt13","Dark Magenta","8B008B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt14","Purple","800080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt15","Indigo","4B0082",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt16","Slat Blue","6A5ACD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt17","Dark Slate Blue","483D8B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrMgnt18","Medium Slat Blue","6A5ACD",void 0,1,3),t+="
          ",t+=this.getMenuText("uniclrGreenwrap","Green",void 0,1,2),t+="
            ",t+=this.getRadClr("mn4_clr","uniclrGrn1","Green","0F0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn2","Dark Green","006400",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn3","Yellow Green","9ACD32",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn4","Olive Drab","6B8E23",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn5","Olive","808000",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn6","Dark Olive Green","556B2F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn7","Medium Aquamarine","66CDAA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn8","Dark Sea Green","8FBC8B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn9","Lignt Sea Green","20B2AA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn10","Dark Cyan","008B8B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn11","Teal","008080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn12","Forest Green","228B22",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn13","Sea Green","2E8B57",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn14","Medium Sea Green","3CB371",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn15","Spring Green","00FF7F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn16","Medium Spring","00FA9A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn17","Light Green","90EE90",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn18","Pale Green","98FB98",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn19","Lime Green","32CD32",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn20","Lawn Green","7CFC00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn21","Chartreuse","7FFF00",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGrn22","Green Yellow","ADFF2F",void 0,1,3),t+="
          ",t+=this.getMenuText("uniclrCyanwrap","Cyan",void 0,1,2),t+="
            ",t+=this.getRadClr("mn4_clr","uniclrCyan1","Cyan","0FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan2","Light Cyan","E0FFFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan3","Pale Turquoise","AFEEEE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan4","Aquamarine","7FFFD4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan5","Turquoise","40E0D0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan6","Medium Turquoise","48D1CC",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrCyan7","Dark Turquoise","00CED1",void 0,1,3),t+="
          ",t+=this.getMenuText("uniclrBluewrap","Blue",void 0,1,2),t+="
            ",t+=this.getRadClr("mn4_clr","uniclrBlue1","Blue","00F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue2","Medium Blue","0000CD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue3","Dark Blue","00008B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue4","Navy","000080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue5","Midnight Blue","191970",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue6","Royal Blue","4169E1",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue7","Medium Slate Blue","7B68EE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue8","Corn Flower Blue","6495ED",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue9","Dodger Blue","1E90FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue10","Deep Sky Blue","00BFFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue11","Light Sky Blue","87CEFA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue12","Sky Blue","87CEEB",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue13","Light Blue","ADD8E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue14","Powder Blue","B0E0E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue15","Light Steel Blue","B0C4DE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue16","Steel Blue","4682B4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBlue17","Cadet Blue","5F9EA0",void 0,1,3),t+="
          ",t+=this.getMenuText("uniclrBrownwrap","Brown",void 0,1,2),t+="
            ",t+=this.getRadClr("mn4_clr","uniclrBrown1","Brown","A52A2A",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown2","Maroon","800000",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown3","Sienna","A0522D",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown4","Saddle Brown","8B4513",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown5","Chocolate","D2691E",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown6","Peru","CD853F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown7","Dark Golden Rod","B8860B",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown8","Golden Rod","DAA520",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown9","Sandy Brown","F4A460",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown10","Rosy Brown","BC8F8F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown11","Tan","D2B48C",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown12","Burlywood","DEB887",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown13","Wheat","F5DEB3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown14","Navajo White","FFDEAD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown15","Bisque","FFE4C4",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown16","Blanched Almond","FFEBCD",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrBrown17","Corn Silk","FFF8DC",void 0,1,3),t+="
          ",t+=this.getMenuText("uniclrWhitewrap","White",void 0,1,2),t+="
            ",t+=this.getRadClr("mn4_clr","uniclrWhite1","White","FFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite2","Snow","FFFAFA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite3","Honey Dew","F0FFF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite4","Mint Cream","F5FFFA",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite5","Azure","F0FFFF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite6","Alice Blue","F0F8FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite7","Ghost White","F8F8FF",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite8","White Smoke","F5F5F5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite9","Sea Shell","FFF5EE",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite10","Beige","F5F5DC",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite11","Old Lace","FDF5E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite12","Floral White","FFFAF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite13","Ivory","FFFFF0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite14","Antique White","FAEBD7",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite15","Linen","FAF0E6",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite16","Lavenderblush","FFF0F5",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrWhite17","Misty Rose","FFE4E1",void 0,1,3),t+="
          ",t+=this.getMenuText("uniclrGraywrap","Gray",void 0,1,2),t+="
            ",t+=this.getRadClr("mn4_clr","uniclrGray1","Gray","808080",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray2","Dim Gray","696969",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray3","Light Slate Gray","778899",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray4","Slate Gray","708090",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray5","Dark Slate Gray","2F4F4F",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray6","Black","000000",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray7","Dark Gray","A9A9A9",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray8","Silver","C0C0C0",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray9","Light Gray","D3D3D3",void 0,1,3),t+=this.getRadClr("mn4_clr","uniclrGray10","Gainsboro","DCDCDC",void 0,1,3),t+="
          ",t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrCustom","Color Picker",void 0,void 0,1),t+=this.getMenuSep(),void 0===e.cfg.cid?(t+=this.getMenuText("mn4_clrRainbowwrap","Rainbow (R-V)","icn3d-menupd",1,1),t+="
          ",t+=this.getRadio("mn4_clr","mn4_clrRainbow","for Selection",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrRainbowChain","for Chains",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrRainbowSets","for Sets",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrRainbowAcrossSets","across Sets",void 0,void 0,2),t+="
        ",t+=this.getMenuText("mn4_clrSpectrumwrap","Spectrum (V-R)","icn3d-menupd",1,1),t+="
          ",t+=this.getRadio("mn4_clr","mn4_clrSpectrum","for Selection",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSpectrumChain","for Chains",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSpectrumSets","for Sets",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrSpectrumAcrossSets","across Sets",void 0,void 0,2),t+="
        ",t+=this.getMenuText("mn4_clrSSwrap","Secondary","icn3d-menupd",1,1),t+="
          ",t+=this.getRadio("mn4_clr","mn4_clrSSGreen","Sheet in Green",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSSYellow","Sheet in Yellow",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSSSpectrum","Spectrum",void 0,void 0,2),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrCharge","Charge",void 0,1,1),t+=this.getMenuText("mn4_hydrophobicwrap","Hydrophobicity","icn3d-menupd",1,1),t+="
          ",t+=this.getRadio("mn4_clr","mn4_clrNormalizedHP","Normalized",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrHydrophobic","Wimley-White",void 0,void 0,2),t+="
        ",t+=this.getMenuText("mn4_clrBfactorwrap","B-factor","icn3d-menupd",1,1),t+="
          ",t+=this.getRadio("mn4_clr","mn4_clrBfactor","Original",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrBfactorNorm","Percentile",void 0,1,2),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrArea",'Solvent
        Accessibility',void 0,void 0,1),t+=this.getRadio("mn4_clr","mn4_clrStructure","Structure",void 0,1,1),void 0!==e.cfg.align||void 0!==e.cfg.chainalign||void 0!==e.cfg.blast_rep_id?t+=this.getRadio("mn4_clr","mn4_clrChain","Chain",void 0,1,1):t+=this.getRadio("mn4_clr","mn4_clrChain","Chain",!0,1,1),t+=this.getRadio("mn4_clr","mn4_clrdomain","3D Domain",void 0,void 0,1),void 0===e.cfg.cid&&(t+=this.getMenuText("mn4_clrsetswrap","Defined Sets","icn3d-menupd",void 0,1),t+="
          ",t+=this.getRadio("mn4_clr","mn4_clrsets",'Rainbow for Selected Sets
          in "Analysis > Defined Sets"',void 0,void 0,2),t+="
        ",t+=""),t+=this.getMenuText("mn4_clrResiduewrap","Residue","icn3d-menupd",1,1),t+="
          ",t+=this.getRadio("mn4_clr","mn4_clrResidue","Default",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrResidueCustom","Custom",void 0,void 0,2),t+="
        ",t+=this.getRadio("mn4_clr","mn4_clrAtom","Atom",void 0,1,1),void 0!==e.cfg.align||void 0!==e.cfg.chainalign?(t+=this.getRadio("mn4_clr","mn4_clrIdentity","Identity",!0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrConserved","Conservation",void 0,void 0,2)):void 0!==e.cfg.blast_rep_id?(t+=this.getRadio("mn4_clr","mn4_clrIdentity","Identity",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrConserved","Conservation",!0,void 0,2)):(t+=this.getRadio("mn4_clr","mn4_clrIdentity","Identity",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrConserved","Conservation",void 0,void 0,2)),t+=this.getRadio("mn4_clr","mn4_clrConfidence","pLDDT",void 0,1,1), //!!! @@ -7,5 +7,5 @@ t+=this.getRadio("mn4_clr","mn4_clrIgstrand","Ig Strand",void 0,void 0,2),t+=thi //!!! t+=this.getRadio("mn6_addlabel","mn6_addlabelRefnum","per Reference Number",void 0,1,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelChains","per Chain",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelTermini","N- & C-Termini",void 0,1,2)),t+=this.getMenuSep(),t+=this.getRadio("mn6_addlabel","mn6_labelColor","Change Label Color",void 0,1,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelNo","Remove",!0,1,2),t+="
      ",t+="",t+=this.getMenuText("labelscalewrap","Label Scale",void 0,1,1),t+="
        ";for(let e=1;e<=4;++e){let s=2*e;t+=this.getRadio("mn6_labelscale","mn6_labelscale0"+s,"0."+s,void 0,1,2)}for(let e=1;e<=5;++e)t+=1==e?this.getRadio("mn6_labelscale","mn6_labelscale"+e+"0",e+".0",!0,1,2):this.getRadio("mn6_labelscale","mn6_labelscale"+e+"0",e+".0",void 0,1,2);if(t+="
      ",t+="",t+=this.getMenuSep(),void 0===e.cfg.cid){t+=this.getMenuText("mn6_chemicalbindingwrap","Chem. Binding",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_chemicalbinding","mn6_chemicalbindingshow","Show",void 0,void 0,2),t+=this.getRadio("mn6_chemicalbinding","mn6_chemicalbindinghide","Hide",!0,void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn6_ssbondswrap","Disulfide Bonds",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_ssbonds","mn6_ssbondsYes","Show",!0,1,2),t+=this.getRadio("mn6_ssbonds","mn6_ssbondsExport","Export Pairs",void 0,void 0,2),t+=this.getRadio("mn6_ssbonds","mn6_ssbondsNo","Hide",void 0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn6_clbondswrap","Cross-Linkages",void 0,void 0,1),t+="
        ",t+=this.getRadio("mn6_clbonds","mn6_clbondsYes","Show",!0,void 0,2),t+=this.getRadio("mn6_clbonds","mn6_clbondsExport","Export Pairs",void 0,void 0,2),t+=this.getRadio("mn6_clbonds","mn6_clbondsNo","Hide",void 0,void 0,2),t+="
      ",t+="";let s=void 0!==e.cfg.mmtfid||void 0!==e.cfg.pdbid||void 0!==e.cfg.opmid||void 0!==e.cfg.mmcifid||void 0!==e.cfg.mmdbid||void 0!==e.cfg.mmdbafid||void 0!==e.cfg.gi||void 0!==e.cfg.blast_rep_id;s&&(t+=this.getMenuText("assemblyWrapper","Assembly",void 0,1,1),t+="
        ",e.cfg.bu?(t+=this.getRadio("mn6_assembly","mn6_assemblyYes","Biological Assembly",!0,1,2),t+=this.getRadio("mn6_assembly","mn6_assemblyNo","Asymmetric Unit",void 0,1,2)):(t+=this.getRadio("mn6_assembly","mn6_assemblyYes","Biological Assembly",void 0,1,2),t+=this.getRadio("mn6_assembly","mn6_assemblyNo","Asymmetric Unit",!0,1,2)),t+="
      ",t+=""),t+=this.getMenuText("mn6_symmetrywrap","Symmetry",void 0,void 0,1),t+="
        ",s&&(t+=this.getLink("mn6_symmetry","from PDB(precalculated) "+e.htmlCls.wifiStr,void 0,2)),t+=this.getLink("mn6_symd","from SymD(Dynamic) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn6_clear_sym","Clear SymD Symmetry",void 0,2),t+=this.getLink("mn6_axes_only","Show Axes Only",void 0,2),t+="
      ",t+="",t+=this.getMenuText("mn6_igrefwrap","Ref. Number",void 0,void 0,1),t+="
        ", //!!! -t+=this.getLink("mn6_igrefYes","Show Ig Ref. Number",void 0,2),t+=this.getLink("mn6_igrefTpl","Ig w/ Specified Template",void 0,2),t+=this.getLink("mn6_igrefNo","Hide Ig Ref. Number",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn6_customref","Custom Ref. Number",void 0,2),t+="
      ",t+="",t+=this.getMenuSep()}return t+=this.getLink("mn6_yournote","Window Title",void 0,1),void 0!==e.cfg.cid?(t+=this.getMenuText("mn1_linkwrap","Links",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_link_structure","Compound Summary "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_vast","Similar Compounds "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_bind","Structures Bound "+e.htmlCls.wifiStr,void 0,2),t+="
      ",t+=""):(t+=this.getMenuText("mn1_linkwrap","Links",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_link_structure","Structure Summary "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_vast","Similar Structures "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_pubmed","Literature "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_protein","Protein "+e.htmlCls.wifiStr,void 0,2),t+="
      ",t+=""),t+="

    • ",t+="
    ",t}setMenu6(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
    ",t+="",t+="

    Help

    ",t+="
    ",t+=this.setMenu6_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu6_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getMenuUrl("abouticn3d",e.htmlCls.baseUrl+"icn3d/icn3d.html#about","About iCn3D "+e.REVISION+"",1,1),t+=this.getMenuUrl("gallery",e.htmlCls.baseUrl+"icn3d/icn3d.html#gallery","Live Gallery "+e.htmlCls.wifiStr,1,1),t+=this.getMenuUrl("video",e.htmlCls.baseUrl+"icn3d/icn3d.html#videos","Videos & Tutorials",1,1),t+=this.getMenuText("mn6_faq","FAQ",void 0,1,1),t+="
        ",t+=this.getMenuUrl("faq_viewstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#viewstru","View structure",1,2),t+=this.getMenuUrl("faq_tfstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#tfstru","Transform Structure",1,2),t+=this.getMenuUrl("faq_selsubset",e.htmlCls.baseUrl+"icn3d/icn3d.html#selsubset","Select Subsets",1,2),t+=this.getMenuUrl("faq_stylecolor",e.htmlCls.baseUrl+"icn3d/icn3d.html#changestylecolor","Change Style/Color",1,2),t+=this.getMenuUrl("faq_savework",e.htmlCls.baseUrl+"icn3d/icn3d.html#saveview","Save Work",1,2),t+=this.getMenuUrl("faq_showanno",e.htmlCls.baseUrl+"icn3d/icn3d.html#showanno","Show Annotations",1,2),t+=this.getMenuUrl("faq_exportanno",e.htmlCls.baseUrl+"icn3d/icn3d.html#exportanno","Export Annotations",1,2),t+=this.getMenuUrl("faq_interanal",e.htmlCls.baseUrl+"icn3d/icn3d.html#interanalysis","Interaction Analysis",1,2),t+=this.getMenuUrl("faq_mutanal",e.htmlCls.baseUrl+"icn3d/icn3d.html#mutationanalysis","Mutation Analysis",1,2),t+=this.getMenuUrl("faq_elecpot",e.htmlCls.baseUrl+"icn3d/icn3d.html#elecpot","Electrostatic Pot.",1,2),t+=this.getMenuUrl("faq_simipdb",e.htmlCls.baseUrl+"icn3d/icn3d.html#simivast","Similar PDB",1,2),t+=this.getMenuUrl("faq_simialphapdb",e.htmlCls.baseUrl+"icn3d/icn3d.html#simifoldseek","Similar AlphaFold/PDB",1,2),t+=this.getMenuUrl("faq_alnstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#alignmul","Align Multiple Structures",1,2),t+=this.getMenuUrl("faq_batchanal",e.htmlCls.baseUrl+"icn3d/icn3d.html#batchanalysis","Batch Analysis",1,2),t+=this.getMenuUrl("faq_embedicn3d",e.htmlCls.baseUrl+"icn3d/icn3d.html#embedicn3d","Embed iCn3D",1,2),t+="
      ",t+="",t+=this.getMenuUrl("citing",e.htmlCls.baseUrl+"icn3d/icn3d.html#citing","Citing iCn3D",void 0,1),t+=this.getMenuText("mn6_source","Source Code",void 0,1,1),t+="
        ",t+=this.getMenuUrl("github","https://github.com/ncbi/icn3d","GitHub (browser) "+e.htmlCls.wifiStr,1,2),t+=this.getMenuUrl("npm","https://www.npmjs.com/package/icn3d","npm (Node.js) "+e.htmlCls.wifiStr,1,2),t+=this.getMenuUrl("notebook","https://pypi.org/project/icn3dpy","Jupyter Notebook "+e.htmlCls.wifiStr,1,2),t+="
      ",t+="",t+=this.getMenuText("mn6_develop","Develop",void 0,void 0,1),t+="
        ",t+=this.getMenuUrl("dev_embedicn3d2",e.htmlCls.baseUrl+"icn3d/icn3d.html#HowToUse","Embed iCn3D",void 0,2),t+=this.getMenuUrl("dev_urlpara",e.htmlCls.baseUrl+"icn3d/icn3d.html#parameters","URL Parameters",void 0,2),t+=this.getMenuUrl("dev_command",e.htmlCls.baseUrl+"icn3d/icn3d.html#commands","Commands",void 0,2),t+=this.getMenuUrl("dev_datastru",e.htmlCls.baseUrl+"icn3d/icn3d.html#datastructure","Data Structure",void 0,2),t+=this.getMenuUrl("dev_classstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#classstructure","Class Structure",void 0,2),t+=this.getMenuUrl("dev_addclass",e.htmlCls.baseUrl+"icn3d/icn3d.html#addclass","Add New Classes",void 0,2),t+=this.getMenuUrl("dev_modfunc",e.htmlCls.baseUrl+"icn3d/icn3d.html#modifyfunction","Modify Functions",void 0,2),t+=this.getMenuUrl("dev_restful",e.htmlCls.baseUrl+"icn3d/icn3d.html#restfulapi","RESTful APIs",void 0,2),t+=this.getMenuUrl("dev_contributor",e.htmlCls.baseUrl+"icn3d/icn3d.html#contributors","iCn3D Contributors",void 0,2),t+="
      ",t+="",t+=this.getMenuUrl("helpdoc",e.htmlCls.baseUrl+"icn3d/docs/icn3d_help.html","Help Doc "+e.htmlCls.wifiStr,1,1),t+=this.getMenuSep(),t+=this.getMenuText("mn6_tfhint","Transform Hints",void 0,1,1),t+="
        ",t+=this.getMenuText("mn6_rotate","Rotate",void 0,1,2),t+="
          ",t+="
        • Left Mouse (Click & Drag)
        • ",t+="
        • Key l: Left
        • ",t+="
        • Key j: Right
        • ",t+="
        • Key i: Up
        • ",t+="
        • Key m: Down
        • ",t+="
        • Shift + Key l: Left 90°
        • ",t+="
        • Shift + Key j: Right 90°
        • ",t+="
        • Shift + Key i: Up 90°
        • ",t+="
        • Shift + Key m: Down 90°
        • ",t+="
        ",t+="",t+=this.getMenuText("mn6_zoom","Zoom",void 0,1,2),t+="
          ",t+="
        • Middle Mouse
          (Pinch & Spread)
        • ",t+="
        • Key z: Zoom in
        • ",t+="
        • Key x: Zoom out
        • ",t+="
        ",t+="",t+=this.getMenuText("mn6_translate","Translate",void 0,1,2),t+="
          ",t+="
        • Right Mouse
          (Two Finger Click & Drag)
        • ",t+="
        ",t+="",t+="
      ",t+="",t+=this.getMenuUrl("selhints",e.htmlCls.baseUrl+"icn3d/icn3d.html#selsubset","Selection Hints",void 0,1),t+=this.getMenuUrl("helpdesk","https://support.nlm.nih.gov/support/create-case/","Write to Help Desk",1,1),t+="

    • ",t+="
    ",t}hideMenu(){let e=this.icn3dui;e.bNode||(void 0!==$("#"+e.pre+"mnlist")[0]&&($("#"+e.pre+"mnlist")[0].style.display="none"),void 0!==$("#"+e.pre+"mnLogSection")[0]&&($("#"+e.pre+"mnLogSection")[0].style.display="none"),void 0!==$("#"+e.pre+"cmdlog")[0]&&($("#"+e.pre+"cmdlog")[0].style.display="none"),$("#"+e.pre+"title")[0].style.margin="10px 0 0 10px")}showMenu(){let e=this.icn3dui;e.bNode||(void 0!==$("#"+e.pre+"mnlist")[0]&&($("#"+e.pre+"mnlist")[0].style.display="block"),void 0!==$("#"+e.pre+"mnLogSection")[0]&&($("#"+e.pre+"mnLogSection")[0].style.display="block"),void 0!==$("#"+e.pre+"cmdlog")[0]&&($("#"+e.pre+"cmdlog")[0].style.display="block"))}}class c{constructor(e){this.icn3dui=e}openDlg(e,t){let s=this.icn3dui;s.icn3d,s.bNode||(e=s.pre+e,s.cfg.notebook?this.openDlgNotebook(e,t):this.openDlgRegular(e,t),s.htmlCls.themecolor||(s.htmlCls.themecolor="blue"),s.htmlCls.setMenuCls.setTheme(s.htmlCls.themecolor))}addSaveButton(e){let t=this.icn3dui;t.icn3d,t.bNode||void 0!==this.dialogHashSave&&this.dialogHashSave.hasOwnProperty(e)||($("#"+e).parent().children(".ui-dialog-titlebar").append("
    "),void 0===this.dialogHashSave&&(this.dialogHashSave={}),this.dialogHashSave[e]=1)}addHideButton(e){let t=this.icn3dui;t.icn3d,t.bNode||void 0!==this.dialogHashHide&&this.dialogHashHide.hasOwnProperty(e)||($("#"+e).parent().children(".ui-dialog-titlebar").append("
    "),void 0===this.dialogHashHide&&(this.dialogHashHide={}),this.dialogHashHide[e]=1)}getDialogStatus(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t={},s={},i=$("#"+e.pre+"dl_selectannotations").hasClass("ui-dialog-content"),n=$("#"+e.pre+"dl_graph").hasClass("ui-dialog-content"),l=$("#"+e.pre+"dl_linegraph").hasClass("ui-dialog-content"),r=$("#"+e.pre+"dl_scatterplot").hasClass("ui-dialog-content"),o=$("#"+e.pre+"dl_contactmap").hasClass("ui-dialog-content"),a=$("#"+e.pre+"dl_alignerrormap").hasClass("ui-dialog-content"),d=$("#"+e.pre+"dl_interactionsorted").hasClass("ui-dialog-content"),c=$("#"+e.pre+"dl_alignment").hasClass("ui-dialog-content"),h=$("#"+e.pre+"dl_2ddgm").hasClass("ui-dialog-content"),p=$("#"+e.pre+"dl_2dctn").hasClass("ui-dialog-content"),m=$("#"+e.pre+"dl_definedsets").hasClass("ui-dialog-content");return t.bSelectannotationsInit2=!1,t.bGraph2=!1,t.bLineGraph2=!1,t.bScatterplot2=!1,t.bTable2=!1,t.bAlignmentInit2=!1,t.bTwoddgmInit2=!1,t.bTwodctnInit2=!1,t.bSetsInit2=!1,s.dl_selectannotations="bSelectannotationsInit2",s.dl_graph="bGraph2",s.dl_linegraph="bLineGraph2",s.dl_scatterplot="bScatterplot2",s.dl_contactmap="bContactmap2",s.dl_alignerrormap="bAlignerrormap2",s.dl_interactionsorted="bTable2",s.dl_alignment="bAlignmentInit2",s.dl_2ddgm="bTwoddgmInit2",s.dl_2dctn="bTwodctnInit2",s.dl_definedsets="bSetsInit2",i&&(t.bSelectannotationsInit2=$("#"+e.pre+"dl_selectannotations").dialog("isOpen")),n&&(t.bGraph2=$("#"+e.pre+"dl_graph").dialog("isOpen")),l&&(t.bLineGraph2=$("#"+e.pre+"dl_linegraph").dialog("isOpen")),r&&(t.bScatterplot2=$("#"+e.pre+"dl_scatterplot").dialog("isOpen")),o&&(t.bContactmap2=$("#"+e.pre+"dl_contactmap").dialog("isOpen")),a&&(t.bAlignerror2=$("#"+e.pre+"dl_alignerrormap").dialog("isOpen")),d&&(t.bTable2=$("#"+e.pre+"dl_interactionsorted").dialog("isOpen")),c&&(t.bAlignmentInit2=$("#"+e.pre+"dl_alignment").dialog("isOpen")),h&&(t.bTwoddgmInit2=$("#"+e.pre+"dl_2ddgm").dialog("isOpen")),p&&(t.bTwodctnInit2=$("#"+e.pre+"dl_2dctn").dialog("isOpen")),m&&(t.bSetsInit2=$("#"+e.pre+"dl_definedsets").dialog("isOpen")),{status:t,id2flag:s}}openDlgHalfWindow(e,t,s,i){let n=this.icn3dui,l=n.icn3d;if(n.bNode)return;let r=this,o=n.htmlCls.width2d+20;l.resizeCanvasCls.resizeCanvas(n.htmlCls.WIDTH-s,n.htmlCls.HEIGHT,i);let a,d=n.htmlCls.HEIGHT,c=s;a=!n.cfg.showmenu||n.utilsCls.isMobile()||n.cfg.mobilemenu?{my:"left top",at:"right top",of:"#"+n.pre+"viewer",collision:"none"}:{my:"left top",at:"right top+40",of:"#"+n.pre+"viewer",collision:"none"},n.cfg.resize=!1,window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:d,width:c,modal:!1,position:a,close:function(t){let s=r.getDialogStatus(),i=s.status,a=s.id2flag,d=!1;for(let t in a){let s=e===n.pre+t;for(let e in i)i.hasOwnProperty(e)||(s=s&&!i[e]);d=d||s}if(d)if(i.bTwoddgmInit2||i.bTwodctnInit2||i.bSetsInit2){let e=n.utilsCls.isMobile()?n.htmlCls.WIDTH:n.htmlCls.WIDTH-o;l.resizeCanvasCls.resizeCanvas(e,n.htmlCls.HEIGHT,!0),i.bTwoddgmInit2&&r.openDlg2Ddgm(n.pre+"dl_2ddgm",void 0,i.bSetsInit2),i.bTwodctnInit2&&r.openDlg2Ddgm(n.pre+"dl_2dctn",void 0,i.bSetsInit2),i.bSetsInit2&&r.openDlg2Ddgm(n.pre+"dl_definedsets")}else l.resizeCanvasCls.resizeCanvas(n.htmlCls.WIDTH,n.htmlCls.HEIGHT,!0)},resize:function(t){if(e==n.pre+"dl_selectannotations")l.annotationCls.hideFixedTitle();else if(e==n.pre+"dl_graph"){let t=$("#"+e).width(),s=$("#"+e).height();d3.select("#"+n.svgid).attr("width",t).attr("height",s)}else if(e==n.pre+"dl_linegraph"||e==n.pre+"dl_scatterplot"||e==n.pre+"dl_contactmap"||e==n.pre+"dl_alignerrormap"){let t=status.bTwoddgmInit2||status.bSetsInit2?(n.htmlCls.WIDTH-o)/2:n.htmlCls.WIDTH/2,s=$("#"+e).width()/t;if(e==n.pre+"dl_linegraph"){let e=l.linegraphWidth*s;$("#"+n.linegraphid).attr("width",e)}else if(e==n.pre+"dl_scatterplot"){let e=l.scatterplotWidth*s;$("#"+n.scatterplotid).attr("width",e)}else if(e==n.pre+"dl_contactmap"){let e=l.contactmapWidth*s;$("#"+n.contactmapid).attr("width",e)}else if(e==n.pre+"dl_alignerrormap"){let e=l.alignerrormapWidth*s;$("#"+n.alignerrormapid).attr("width",e)}}}}),this.addSaveButton(e),this.addHideButton(e)}openDlg2Ddgm(e,t,s){let i=this.icn3dui,n=i.icn3d;if(i.bNode)return;let l,r,o=this,a=i.htmlCls.width2d+20;e===i.pre+"dl_definedsets"?(l="right top",r="Select sets"):e!==i.pre+"dl_2ddgm"&&e!==i.pre+"dl_2dctn"||(l=s?"right top+240":"right top",r=e===i.pre+"dl_2ddgm"?"2D Diagram":"2D Cartoon");let d={my:"left top+"+i.htmlCls.MENU_HEIGHT,at:l,of:"#"+i.pre+"viewer",collision:"none"};window.dialog=$("#"+e).dialog({autoOpen:!0,title:r,height:"auto",width:a,modal:!1,position:d,close:function(e){let t=o.getDialogStatus().status;t.bSelectannotationsInit2||t.bGraph2||t.bLineGraph2||t.bScatterplot2||t.bTable2||t.bAlignmentInit2||n.resizeCanvasCls.resizeCanvas(i.htmlCls.WIDTH,i.htmlCls.HEIGHT,!0)},resize:function(t,s){e==i.pre+"dl_2dctn"&&(n.resizeRatioX=s.size.width/i.htmlCls.width2d,n.resizeRatioY=s.size.height/(i.htmlCls.width2d+70))},resizeStop:function(e,t){n.resizeRatioX=t.size.width/i.htmlCls.width2d,n.resizeRatioY=t.size.height/(i.htmlCls.width2d+70)}}),this.addSaveButton(e),this.addHideButton(e)}openDlgRegular(e,t){let s=this.icn3dui,i=s.icn3d;if(s.bNode)return;let n=400,l=150,r=s.htmlCls.width2d+20,o=this.getDialogStatus().status;if(e===s.pre+"dl_selectannotations"||e===s.pre+"dl_graph"||e===s.pre+"dl_linegraph"||e===s.pre+"dl_scatterplot"||e===s.pre+"dl_contactmap"||e===s.pre+"dl_alignerrormap"||e===s.pre+"dl_interactionsorted"||e===s.pre+"dl_alignment"){let a=.5*s.htmlCls.WIDTH-.5*r;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)this.openDlgHalfWindow(e,t,a,!0),(o.bTwoddgmInit2||o.bTwodctnInit2||o.bSetsInit2)&&(i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-a-r,s.htmlCls.HEIGHT,!0),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,o.bSetsInit2),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,o.bSetsInit2),o.bSetsInit2&&this.openDlg2Ddgm(s.pre+"dl_definedsets"));else{i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,.5*s.htmlCls.HEIGHT,!0),l=.5*s.htmlCls.HEIGHT,n=s.htmlCls.WIDTH;let a={my:"left top",at:"left bottom+32",of:"#"+s.pre+"canvas",collision:"none"};window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:l,width:n,modal:!1,position:a,close:function(t){if(!((e!==s.pre+"dl_selectannotations"||o.bAlignmentInit2||o.bGraph2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_graph"||o.bSelectannotationsInit2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_alignment"||o.bSelectannotationsInit2||o.bGraph2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_interactionsorted"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_linegraph"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_scatterplot"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_contactmap"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bAlignerrormap2)&&(e!==s.pre+"dl_alignerrormap"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2)))if(o.bTwoddgmInit2||o.bTwodctnInit2||o.bSetsInit2){let e=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(e,s.htmlCls.HEIGHT,!0),o.bTwoddgmInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,o.bSetsInit2),o.bTwodctnInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,o.bSetsInit2),o.bSetsInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_definedsets")}else i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,s.htmlCls.HEIGHT,!0)},resize:function(t){if(e==s.pre+"dl_selectannotations")i.annotationCls.hideFixedTitle();else if(e==s.pre+"dl_graph"){let t=$("#"+e).width(),i=$("#"+e).height();d3.select("#"+s.svgid).attr("width",t).attr("height",i)}else if(e==s.pre+"dl_linegraph"||e==s.pre+"dl_scatterplot"||e==s.pre+"dl_contactmap"||e==s.pre+"dl_alignerrormap"){let t=o.bTwoddgmInit2||o.bSetsInit2?(s.htmlCls.WIDTH-r)/2:s.htmlCls.WIDTH/2,n=$("#"+e).width()/t;if(e==s.pre+"dl_linegraph"){let e=i.linegraphWidth*n;$("#"+s.linegraphid).attr("width",e)}else if(e==s.pre+"dl_scatterplot"){let e=i.scatterplotWidth*n;$("#"+s.scatterplotid).attr("width",e)}else if(e==s.pre+"dl_contactmap"){let e=i.contactmapWidth*n;$("#"+s.contactmapid).attr("width",e)}else if(e==s.pre+"dl_alignerrormap"){let e=i.alignerrormapWidth*n;$("#"+s.alignerrormapid).attr("width",e)}}}}),this.addSaveButton(e),this.addHideButton(e)}}else if(e===s.pre+"dl_2ddgm"||e===s.pre+"dl_2dctn"){let t=0;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)(o.bSelectannotationsInit2||o.bGraph2||o.bLineGraph2||o.bScatterplot2||o.bTable2||o.bAlignmentInit2)&&(t=.5*s.htmlCls.WIDTH-.5*r),i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-t-r,s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,void 0,o.bSetsInit2);else{let t=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(t,.5*s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT,o.bSetsInit2)}}else{let a;if(l="auto",n="auto",e===s.pre+"dl_addtrack"?n="50%":e===s.pre+"dl_menupref"&&(n=600,l=500),e===s.pre+"dl_definedsets"){let t=0;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)(o.bSelectannotationsInit2||o.bGraph2||o.bLineGraph2||o.bScatterplot2||o.bTable2||o.bAlignmentInit2)&&(t=.5*s.htmlCls.WIDTH-.5*r),i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-t-r,s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,!0),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,!0);else{let t=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(t,.5*s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",.5*s.htmlCls.HEIGHT,!0),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",.5*s.htmlCls.HEIGHT,!0)}}else s.utilsCls.isMobile()?a={my:"left top",at:"left bottom-50",of:"#"+s.pre+"canvas",collision:"none"}:e===s.pre+"dl_allinteraction"||e===s.pre+"dl_buriedarea"?(a={my:"right top",at:"right top+50",of:"#"+i.divid,collision:"none"},n=700,l=500):a=e===s.pre+"dl_rmsd"||e===s.pre+"dl_legend"?{my:"left bottom",at:"left+20 bottom-20",of:"#"+s.pre+"canvas",collision:"none"}:e===s.pre+"dl_symd"?{my:"left top",at:"right-200 bottom-200",of:"#"+s.pre+"canvas",collision:"none"}:s.cfg.align?{my:"left top",at:"left top+90",of:"#"+s.pre+"canvas",collision:"none"}:e===s.pre+"dl_mmdbafid"?{my:"left top",at:"left top+130",of:"#"+s.pre+"canvas",collision:"none"}:{my:"left top",at:"left top+50",of:"#"+s.pre+"canvas",collision:"none"},window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:l,width:n,modal:!1,position:a}),this.addSaveButton(e),this.addHideButton(e)}$(".ui-dialog .ui-button span").removeClass("ui-icon-closethick").addClass("ui-icon-close")}openDlgNotebook(e,t){let s=this.icn3dui,i=s.icn3d;if(s.bNode)return;let n=400,l=150,r=s.htmlCls.width2d+20;e===s.pre+"dl_selectannotations"||e===s.pre+"dl_graph"||e===s.pre+"dl_linegraph"||e===s.pre+"dl_scatterplot"||e===s.pre+"dl_contactmap"||e===s.pre+"dl_alignerrormap"||e===s.pre+"dl_interactionsorted"||e===s.pre+"dl_alignment"?($("#"+e).show(),$("#"+e+"_nb").show(),$("#"+e+"_title").html(t),l=.5*s.htmlCls.HEIGHT,n=s.htmlCls.WIDTH,$("#"+e).width(n),$("#"+e).height(l),$("#"+e).resize((function(t){let n=s.htmlCls.WIDTH/2,l=$("#"+e).width()/n;if(e==s.pre+"dl_selectannotations")i.annotationCls.hideFixedTitle();else if(e==s.pre+"dl_graph"){let t=$("#"+e).width(),i=$("#"+e).height();d3.select("#"+s.svgid).attr("width",t).attr("height",i)}else if(e==s.pre+"dl_linegraph"){let e=i.linegraphWidth*l;$("#"+s.linegraphid).attr("width",e)}else if(e==s.pre+"dl_scatterplot"){let e=i.scatterplotWidth*l;$("#"+s.scatterplotid).attr("width",e)}else if(e==s.pre+"dl_contactmap"){let e=i.contactmapWidth*l;$("#"+s.contactmapid).attr("width",e)}else if(e==s.pre+"dl_alignerrormap"){let e=i.alignerrormapWidth*l;$("#"+s.alignerrormapid).attr("width",e)}}))):(i.bRender&&($("#"+e).show(),$("#"+e+"_nb").show(),$("#"+e+"_title").html(t)),l="auto",n="auto",e===s.pre+"dl_addtrack"?n="50%":e===s.pre+"dl_2ddgm"||e===s.pre+"dl_2dctn"||e===s.pre+"dl_definedsets"?n=r:e!==s.pre+"dl_allinteraction"&&e!==s.pre+"dl_buriedarea"||(n=700,l=500),$("#"+e).width(n),$("#"+e).height(l))}}class h{constructor(e){this.icn3dui=e}setCustomDialogs(){let e=this.icn3dui;if(e.icn3d,e.bNode)return"";return""}getHtmlAlignResidueByResidue(e,t,s){let i=this.icn3dui;i.icn3d;let n="";return n+="All chains will be aligned to the first chain in the comma-separated chain IDs. Each chain ID has the form of PDBID_chain (e.g., 1HHO_A, case sensitive) or UniprotID (e.g., P69905 for AlphaFold structures).

    ",n+="Chain IDs: "+i.htmlCls.inputTextStr+"id='"+i.pre+e+"' value='P69905,P01942,1HHO_A' size=50>

    ",n+='Each alignment is defined as " | "-separated residue lists in one line. "10-50" means a range of residues from 10 to 50.

    ",n+=i.htmlCls.buttonStr+s+"'>Align Residue by Residue
    ",n}addNotebookTitle(e,t,s){let i=this.icn3dui;i.icn3d;let n='';return s&&(n+='
    '),n}setDialogs(){let e=this.icn3dui,t=e.icn3d;if(e.bNode)return"";let s="";e.htmlCls.optionStr="":s.htmlCls.optionStr+"'"+l+"'>"+l+""}return i}setColorHints(){let e=this.icn3dui;e.icn3d;let t="";return t+=e.htmlCls.divNowrapStr+'Green: H-Bonds; ',t+='Cyan: Salt Bridge/Ionic; ',t+='Grey: contacts',t+=e.htmlCls.divNowrapStr+'Magenta: Halogen Bonds; ',t+='Red: π-Cation; ',t+='Blue: π-Stacking',t}setThicknessHtml(e){let t=this.icn3dui,s=t.icn3d,i="",n="3dprint"==e?"1":"0.1",l="3dprint"==e?"1.2":"0.3",r="3dprint"==e?"0.8":"0.4",o="3dprint"==e?"0.8":"0.4",a="3dprint"==e?"1":"0.4",d="3dprint"==e?"0.6":"0.3",c="3dprint"==e?"1":"0.2",h="3dprint"==e?"2":"1.3",p="3dprint"==e?"1.4":"0.8",m=40,u=.8,g=.4,f=.2,b=0,C=1,y=0;if("style"==e){if(""!=this.getCookie("shininess")&&(m=parseFloat(this.getCookie("shininess"))),""!=this.getCookie("light1")&&(u=parseFloat(this.getCookie("light1")),g=parseFloat(this.getCookie("light2")),f=parseFloat(this.getCookie("light3"))),""!=this.getCookie("lineRadius")){n=parseFloat(this.getCookie("lineRadius")),l=parseFloat(this.getCookie("coilWidth")),r=parseFloat(this.getCookie("cylinderRadius"));let e=this.getCookie("crosslinkRadius");o=isNaN(e)?s.crosslinkRadius:parseFloat(e),a=parseFloat(this.getCookie("traceRadius")),d=parseFloat(this.getCookie("dotSphereScale")),c=parseFloat(this.getCookie("ribbonthickness")),h=parseFloat(this.getCookie("helixSheetWidth")),p=parseFloat(this.getCookie("nucleicAcidWidth"))}""!=this.getCookie("glycan")&&(b=parseFloat(this.getCookie("glycan"))),""!=this.getCookie("membrane")&&(C=parseFloat(this.getCookie("membrane"))),""!=this.getCookie("cmdwindow")&&(y=parseFloat(this.getCookie("cmdwindow"))),i+="Note: The following parameters will be saved in cache. You just need to set them once.

    ",i+="1. Shininess: "+t.htmlCls.inputTextStr+"id='"+t.pre+"shininess' value='"+m+"' size=4>"+t.htmlCls.space3+"(for the shininess of the 3D objects, default 40)

    ",i+="2. Three directional lights:
    ",i+="Key Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light1' value='"+u+"' size=4>"+t.htmlCls.space3+"(for the light strength of the key light, default 0.8)
    ",i+="Fill Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light2' value='"+g+"' size=4>"+t.htmlCls.space3+"(for the light strength of the fill light, default 0.4)
    ",i+="Back Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light3' value='"+f+"' size=4>"+t.htmlCls.space3+"(for the light strength of the back light, default 0.2)

    ",i+="3. Thickness:
    "}return i+="Line Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"linerad_"+e+"' value='"+n+"' size=4>"+t.htmlCls.space3+"(for stabilizers, hydrogen bonds, distance lines, default 0.1)
    ",i+="Coil Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"coilrad_"+e+"' value='"+l+"' size=4>"+t.htmlCls.space3+"(for coils, default 0.3)
    ",i+="Stick Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"stickrad_"+e+"' value='"+r+"' size=4>"+t.htmlCls.space3+"(for sticks, default 0.4)
    ",i+="Cross-Linkage Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"crosslinkrad_"+e+"' value='"+o+"' size=4>"+t.htmlCls.space3+"(for cross-linkages, default 0.4)
    ",i+="Trace Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"tracerad_"+e+"' value='"+a+"' size=4>"+t.htmlCls.space3+"(for C alpha trace, O3' trace, default 0.4)
    ",i+="Ribbon Thickness: "+t.htmlCls.inputTextStr+"id='"+t.pre+"ribbonthick_"+e+"' value='"+c+"' size=4>"+t.htmlCls.space3+"(for helix and sheet ribbons, nucleotide ribbons, default 0.2)
    ",i+="Protein Ribbon Width: "+t.htmlCls.inputTextStr+"id='"+t.pre+"prtribbonwidth_"+e+"' value='"+h+"' size=4>"+t.htmlCls.space3+"(for helix and sheet ribbons, default 1.3)
    ",i+="Nucleotide Ribbon Width: "+t.htmlCls.inputTextStr+"id='"+t.pre+"nucleotideribbonwidth_"+e+"' value='"+p+"' size=4>"+t.htmlCls.space3+"(for nucleotide ribbons, default 0.8)
    ",i+="Ball Scale: "+t.htmlCls.inputTextStr+"id='"+t.pre+"ballscale_"+e+"' value='"+d+"' size=4>"+t.htmlCls.space3+"(for styles 'Ball and Stick' and 'Dot', default 0.3)
    ","style"==e&&(i+="
    4. Show Glycan Cartoon: "+t.htmlCls.inputTextStr+"id='"+t.pre+"glycan' value='"+b+"' size=4>"+t.htmlCls.space3+"(0: hide, 1: show, default 0)
    ",i+="
    5. Show Membrane: "+t.htmlCls.inputTextStr+"id='"+t.pre+"membrane' value='"+C+"' size=4>"+t.htmlCls.space3+"(0: hide, 1: show, default 1)
    ",i+="
    6. Enlarge Command Window: "+t.htmlCls.inputTextStr+"id='"+t.pre+"cmdwindow' value='"+y+"' size=4>"+t.htmlCls.space3+"(0: Regular, 1: Large, default 0)

    "),i+=t.htmlCls.spanNowrapStr+""+t.htmlCls.buttonStr+"apply_thickness_"+e+"'>Apply   ",i+=t.htmlCls.spanNowrapStr+""+t.htmlCls.buttonStr+"reset_thickness_"+e+"'>Reset",i}getCookie(e){let t=e+"=",s=decodeURIComponent(document.cookie).split(";");for(let e=0;e":(n+='
    ',n+="
    Selection: Name: "+s.htmlCls.inputTextStr+"id='"+s.pre+"seq_command_name"+e+"' value='seq_"+l+"' size='5'> "+s.htmlCls.space2+"

    ",n+=s.htmlCls.divStr+"seqguide"+e+"' style='display:none; white-space:normal;' class='icn3d-box'>"),n+=this.getSelectionHints();return n+="Residue labeling: standard residue with coordinates: UPPER case letter; nonstandard residue with coordinates: the first UPPER case letter plus a period except that water residue uses the letter 'O'; residue missing coordinates: lower case letter."+(s.utilsCls.isMac()&&!s.utilsCls.isMobile()?"

    Turn on scroll bar: System preferences -> General -> show scroll bars -> check Always":"")+"
    ",n}setAlignSequenceGuide(e,t){let s=this.icn3dui,i=s.icn3d,n="";let l=i&&i.defNames2Atoms?Object.keys(i.defNames2Atoms).length:1;n+='
    ',n+="
    Selection: Name: "+s.htmlCls.inputTextStr+"id='"+s.pre+"alignseq_command_name' value='alseq_"+l+"' size='10'> "+s.htmlCls.space2+"

    ",n+=s.htmlCls.divStr+"alignseqguide' style='display:none; white-space:normal;' class='icn3d-box'>",n+=this.getSelectionHints();return n+="Residue labeling: aligned residue with coordinates: UPPER case letter; non-aligned residue with coordinates: lower case letter which can be highlighted; residue missing coordinates: lower case letter which can NOT be highlighted."+(s.utilsCls.isMac()&&!s.utilsCls.isMobile()?"

    Turn on scroll bar: System preferences -> General -> show scroll bars -> check Always":"")+"
    ",n}getSelectionHints(){let e=this.icn3dui;e.icn3d;let t="";if(e.utilsCls.isMobile())t+='Select Aligned Sequences: touch to select, touch again to deselect, multiple selection is allowed without Ctrl key, click "Save Selection" to save the current selection.
    ';else{t+='Select on 1D sequences: drag to select, drag again to deselect, multiple selection is allowed without Ctrl key, click "Save Selection" to save the current selection.

    ',t+="Select on 2D interaction diagram: click on the nodes or lines. The nodes are chains and can be united with the Ctrl key. The lines are interactions and can NOT be united. Each click on the lines selects half of the lines, i.e., select the interacting residues in one of the two chains.

    ",t+="Select on 3D structures: "+(e.utilsCls.isMobile()?"use finger to pick":'hold "Alt" and use mouse to pick')+', click the second time to deselect, hold "Ctrl" to union selection, hold "Shift" to select a range, press the up/down arrow to switch among atom/residue/strand/chain/structure, click "Save Selection" to save the current selection.

    ',t+='Save the current selection(either on 3D structure, 2D interactions, or 1D sequence): open the menu "Select -> Save Selection", specify the name and description for the selection, and click "Save".

    '}return t}addGsizeSalt(e){let t=this.icn3dui;t.icn3d;let s="";s+="Grid Size: ",s+="Salt Concentration: M
    ",s}getFootHtml(e,t){let s=this.icn3dui;s.icn3d;let i="
    ";return"delphi"==e?s.cfg.cid?i+="Note: Partial charges(MMFF94) are from PubChem Compound SDF files.

    ":(i+="Note: Only the selected residues are used for DelPhi potential calculation by solving linear Poisson-Boltzmann equation.",i+='

    ',i+=s.htmlCls.divStr+t+"' style='display:none;'>",i+="
    The hydrogens and partial charges of proteins and nucleotides are added using DelPhiPKa with the Amber charge and size files. The hydrogens of ligands are added using Open Babel. The partial charges of ligands are calculated using Antechamber with the Gasteiger charge method. All partial charges are calculated at pH 7.

    ",i+='Lipids are treated as ligands. Please use "HETATM" instead of "ATOM " for each lipid atom in your PDB file. Each phosphate in lipids is assigned with a charge of -1. You can download PQR and modify it, or prepare your PQR file using other tools. Then load the PQR file at the menu "Analysis > Load PQR/Potential".

    ',i+="
    "):(i+="Note: Always load a PDB file before loading a PQR or DelPhi potential file.",i+='

    ',i+=s.htmlCls.divStr+t+"' style='display:none;'>",i+='The PDB file can be loaded in the URL with "pdbid=" or at "File > Open File". The PQR file can be prepared at the menu "Analysis > Download PQR" with your modification or using other tools. The DelPhi potential file can be calculated at DelPhi Web Server and be exported as a Cube file. ',"url"==e&&(i+="The PQR or potential file can be accessed in a URL if it is located in the same host as iCn3D."),i+="

    ",i+=""),i+="",i}getPotentialHtml(e,t){let s=this.icn3dui;s.icn3d;let i,n,l,r,o,a="";r="Equipotential Map",o="Surface with Potential","delphi"==e?n="delphi":"local"==e?(i="pqr",n="phi",l="cube"):"url"==e&&(i="pqrurl",n="phiurl",l="cubeurl"),a+=s.htmlCls.divStr+"dl_"+n+"' class='"+t+"'>",a+=s.htmlCls.setDialogCls.addNotebookTitle("dl_"+n,"DelPhi Potential"),a+=s.htmlCls.divStr+"dl_"+n+"_tabs' style='border:0px;'>",a+="",a+=s.htmlCls.divStr+n+"tab1'>","delphi"==e&&(a+=this.addGsizeSalt(n+"1")+"
    "),a+="Potential contour at: kT/e(25.6mV at 298K)

    ","delphi"==e?(a+=s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map",a+=s.htmlCls.buttonStr+n+"mapNo' style='margin-left:30px;'>Remove Map
    "):"local"==e?(a+=s.htmlCls.divStr+n+"tab1_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo'>Remove Map",a+=s.htmlCls.divStr+n+"tab1_"+i+"'>",a+=this.addGsizeSalt(i)+"
    ",a+="PQR File: "+s.htmlCls.inputFileStr+"id='"+s.pre+i+"file'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+n+"'>",a+="Phi File: "+s.htmlCls.inputFileStr+"id='"+s.pre+n+"file'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+l+"'>",a+="Cube File: "+s.htmlCls.inputFileStr+"id='"+s.pre+l+"file'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=""):"url"==e&&(a+=s.htmlCls.divStr+n+"tab1_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo'>Remove Map",a+=s.htmlCls.divStr+n+"tab1_"+i+"2'>",a+=this.addGsizeSalt(i)+"
    ",a+="PQR URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+i+"file'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+n+"2'>",a+="Phi URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+n+"file'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+l+"2'>",a+="Cube URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+l+"file'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=""),a+="
    "+this.getFootHtml(e,n+"tab1_foot"),a+="",a+=s.htmlCls.divStr+n+"tab2'>","delphi"==e&&(a+=this.addGsizeSalt(n+"2")+"
    "),a+="Surface with max potential at: kT/e(25.6mV at 298K)

    ",a+="Surface: ",a+="Opacity: ",a+="Wireframe:
    ",a+="
    ","delphi"==e?(a+=s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential",a+=s.htmlCls.buttonStr+n+"mapNo2' style='margin-left:30px;'>Remove Surface
    "):"local"==e?(a+=s.htmlCls.divStr+n+"tab2_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo2'>Remove Surface",a+=s.htmlCls.divStr+n+"tab2_"+i+"'>",a+=this.addGsizeSalt(i+"2")+"
    ",a+="PQR File: "+s.htmlCls.inputFileStr+"id='"+s.pre+i+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+n+"'>",a+="Phi File: "+s.htmlCls.inputFileStr+"id='"+s.pre+n+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+l+"'>",a+="Cube File: "+s.htmlCls.inputFileStr+"id='"+s.pre+l+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=""):"url"==e&&(a+=s.htmlCls.divStr+n+"tab2_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo2'>Remove Surface",a+=s.htmlCls.divStr+n+"tab2_"+i+"2'>",a+=this.addGsizeSalt(i+"2")+"
    ",a+="PQR URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+i+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+n+"2'>",a+="Phi URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+n+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+l+"2'>",a+="Cube URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+l+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=""),a+="
    "+this.getFootHtml(e,n+"tab2_foot"),a+="",a+="",a+="",a}async exportPqr(e){let t=this.icn3dui,s=t.icn3d,i={},n={},l=t.hashUtilsCls.intHash(s.dAtoms,s.hAtoms);for(let e in l)s.atoms[e],s.ions.hasOwnProperty(e)?i[e]=1:n[e]=1;let r=e?"pdb":"pqr";if(t.cfg.cid){let l="",o=!e;l+=s.saveFileCls.getAtomPDB(n,o)+s.saveFileCls.getAtomPDB(i,o);let a=Object.keys(t.utilsCls.getHlStructures()).join(",");s.saveFileCls.saveFile(a+"_icn3d."+r,"text",[l])}else{if(t.utilsCls.isCalphaPhosOnly(t.hashUtilsCls.hash2Atoms(n,s.atoms)))return void alert("The potential will not be shown because the side chains are missing in the structure...");let l="",o=!0;l+=s.saveFileCls.getAtomPDB(n,void 0,void 0,void 0,void 0,void 0,o),l+=s.saveFileCls.getAtomPDB(i,!0,void 0,!0);let a=t.htmlCls.baseUrl+"delphi/delphi.cgi",d={pdb2pqr:l,pdbid:t.cfg.cid?t.cfg.cid:Object.keys(s.structures).toString()},c=await t.getAjaxPostPromise(a,d,!0,void 0,void 0,!0,"text");if(e){let e=c.split("\n"),s="";for(let i=0,n=e.length;i Save File > iCn3D PNG Image"...');else if(-1!=l){let t=e.substr(l+n.length);s.htmlCls.clickMenuCls.setLogCmd("load iCn3D PNG image "+$("#"+s.pre+"pngimage").val(),!1),window.open(t,"_self")}else if(-1!=o){let n="Start of data file======\n",l=e.indexOf(n);i.bInputfile=-1!=l,i.bInputPNGWithData=i.bInputfile;let a,d=t?t.replace(/;/g,"\n"):"";if(i.bInputfile){let t=e.indexOf("End of data file======\n"),s=e.substr(l+n.length,t-l-n.length);i.InputfileData=i.InputfileData?i.InputfileData+"\nENDMDL\n"+s:s;let c="Start of type file======\n",h=e.indexOf(c),p=e.indexOf("End of type file======\n"),m=e.substr(h+c.length,p-h-c.length-1);i.InputfileType=m;let u=e.indexOf("End of state file======\n");a=e.substr(o+r.length,u-o-r.length),a=decodeURIComponent(a+"\n"+d),"pdb"===m?(await i.pdbParserCls.loadPdbData(s),i.commands=[],i.optsHistory=[]):("mol2"===m?await i.mol2ParserCls.loadMol2Data(s):"sdf"===m?await i.sdfParserCls.loadSdfData(s):"xyz"===m?await i.xyzParserCls.loadXyzData(s):"mmcif"===m&&await i.mmcifParserCls.loadMmcifData(s),i.commands=[],i.optsHistory=[])}else{let t=e.indexOf("End of state file======\n");a=e.substr(o+r.length,t-o-r.length),a=decodeURIComponent(a+"\n"+d),i.commands=[],i.optsHistory=[]}await i.loadScriptCls.loadScript(a,!0),s.htmlCls.clickMenuCls.setLogCmd("load iCn3D PNG image "+$("#"+s.pre+"pngimage").val(),!1)}}fileSupport(){window.File&&window.FileReader&&window.FileList&&window.Blob||alert("The File APIs are not fully supported in this browser.")}getLinkColor(){let e="";return e+=", linkmap: {\n",e+='3: {"type": "peptidebond", "c":""},\n',e+='4: {"type": "ssbond", "c":"FFA500"},\n',e+='5: {"type": "ionic", "c":"0FF"},\n',e+='6: {"type": "ionicInside", "c":"FFF"},\n',e+='11: {"type": "contact", "c":"888"},\n',e+='12: {"type": "contactInside", "c":"FFF"},\n',e+='13: {"type": "hbond", "c":"0F0"},\n',e+='14: {"type": "hbondInside", "c":"FFF"},\n',e+='15: {"type": "clbond", "c":"006400"},\n',e+='17: {"type": "halogen", "c":"F0F"},\n',e+='18: {"type": "halogenInside", "c":"FFF"},\n',e+='19: {"type": "pication", "c":"F00"},\n',e+='20: {"type": "picationInside", "c":"FFF"},\n',e+='21: {"type": "pistacking", "c":"00F"},\n',e+='22: {"type": "pistackingInside", "c":"FFF"}\n',e+="}}\n",', linkmap: {\n3: {"type": "peptidebond", "c":""},\n4: {"type": "ssbond", "c":"FFA500"},\n5: {"type": "ionic", "c":"0FF"},\n6: {"type": "ionicInside", "c":"FFF"},\n11: {"type": "contact", "c":"888"},\n12: {"type": "contactInside", "c":"FFF"},\n13: {"type": "hbond", "c":"0F0"},\n14: {"type": "hbondInside", "c":"FFF"},\n15: {"type": "clbond", "c":"006400"},\n17: {"type": "halogen", "c":"F0F"},\n18: {"type": "halogenInside", "c":"FFF"},\n19: {"type": "pication", "c":"F00"},\n20: {"type": "picationInside", "c":"FFF"},\n21: {"type": "pistacking", "c":"00F"},\n22: {"type": "pistackingInside", "c":"FFF"}\n}}\n'}setCookieForThickness(){let e=this.icn3dui,t=e.icn3d;if(!e.bNode){let e=3650;this.setCookie("lineRadius",t.lineRadius,e),this.setCookie("coilWidth",t.coilWidth,e),this.setCookie("cylinderRadius",t.cylinderRadius,e),this.setCookie("crosslinkRadius",t.crosslinkRadius,e),this.setCookie("traceRadius",t.traceRadius,e),this.setCookie("dotSphereScale",t.dotSphereScale,e),this.setCookie("ribbonthickness",t.ribbonthickness,e),this.setCookie("helixSheetWidth",t.helixSheetWidth,e),this.setCookie("nucleicAcidWidth",t.nucleicAcidWidth,e)}}setLineThickness(e,t){let s=this.icn3dui,i=s.icn3d;if(i.bSetThickness=!0,"style"==e&&(t&&($("#"+s.pre+"shininess").val("40"),$("#"+s.pre+"light1").val("0.8"),$("#"+s.pre+"light2").val("0.4"),$("#"+s.pre+"light3").val("0.2"),$("#"+s.pre+"glycan").val("0"),$("#"+s.pre+"membrane").val("1"),$("#"+s.pre+"cmdwindow").val("0")),i.shininess=parseFloat($("#"+s.pre+"shininess").val()),i.light1=parseFloat($("#"+s.pre+"light1").val()),i.light2=parseFloat($("#"+s.pre+"light2").val()),i.light3=parseFloat($("#"+s.pre+"light3").val()),i.bGlycansCartoon=parseInt($("#"+s.pre+"glycan").val()),i.bMembrane=parseInt($("#"+s.pre+"membrane").val()),i.bCmdWindow=parseInt($("#"+s.pre+"cmdwindow").val())),t&&($("#"+s.pre+"linerad_"+e).val(.1),$("#"+s.pre+"coilrad_"+e).val(.3),$("#"+s.pre+"stickrad_"+e).val(.4),$("#"+s.pre+"crosslinkrad_"+e).val(.4),$("#"+s.pre+"tracerad_"+e).val(.4),$("#"+s.pre+"ballscale_"+e).val(.3),$("#"+s.pre+"ribbonthick_"+e).val(.2),$("#"+s.pre+"prtribbonwidth_"+e).val(1.3),$("#"+s.pre+"nucleotideribbonwidth_"+e).val(.8)),i.lineRadius=parseFloat($("#"+s.pre+"linerad_"+e).val()),i.coilWidth=parseFloat($("#"+s.pre+"coilrad_"+e).val()),i.cylinderRadius=parseFloat($("#"+s.pre+"stickrad_"+e).val()),i.crosslinkRadius=parseFloat($("#"+s.pre+"crosslinkrad_"+e).val()),i.traceRadius=parseFloat($("#"+s.pre+"tracerad_"+e).val()),i.dotSphereScale=parseFloat($("#"+s.pre+"ballscale_"+e).val()),i.ribbonthickness=parseFloat($("#"+s.pre+"ribbonthick_"+e).val()),i.helixSheetWidth=parseFloat($("#"+s.pre+"prtribbonwidth_"+e).val()),i.nucleicAcidWidth=parseFloat($("#"+s.pre+"nucleotideribbonwidth_"+e).val()),!s.bNode){let e=3650;this.setCookie("shininess",i.shininess,e),this.setCookie("light1",i.light1,e),this.setCookie("light2",i.light2,e),this.setCookie("light3",i.light3,e),this.setCookie("glycan",i.bGlycansCartoon,e),this.setCookie("membrane",i.bMembrane,e),this.setCookie("cmdwindow",i.bCmdWindow,e)}if(this.setCookieForThickness(),e=t){let e="reset thickness";s.htmlCls.clickMenuCls.setLogCmd(e,!0),i.bSetThickness=!1,i.threeDPrintCls.resetAfter3Dprint()}else s.htmlCls.clickMenuCls.setLogCmd("set thickness | linerad "+i.lineRadius+" | coilrad "+i.coilWidth+" | stickrad "+i.cylinderRadius+" | crosslinkrad "+i.crosslinkRadius+" | tracerad "+i.traceRadius+" | ribbonthick "+i.ribbonthickness+" | proteinwidth "+i.helixSheetWidth+" | nucleotidewidth "+i.nucleicAcidWidth+" | ballscale "+i.dotSphereScale,!0),s.htmlCls.clickMenuCls.setLogCmd("set glycan "+i.bGlycansCartoon,!0),s.htmlCls.clickMenuCls.setLogCmd("set membrane "+i.bMembrane,!0),s.htmlCls.clickMenuCls.setLogCmd("set cmdwindow "+i.bCmdWindow,!0);i.drawCls.draw()}setCookie(e,t,s){let i=new Date;i.setTime(i.getTime()+24*s*60*60*1e3);let n="expires="+i.toUTCString();document.cookie=e+"="+t+";"+n+";path=/"}updateSurfPara(e){let t=this.icn3dui,s=t.icn3d;s.phisurftype=$("#"+t.pre+e+"surftype").val(),s.phisurfop=$("#"+t.pre+e+"surfop").val(),s.phisurfwf=$("#"+t.pre+e+"surfwf").val()}exportPdb(){let e=this.icn3dui,t=e.icn3d,s="",i=e.hashUtilsCls.intHash(t.dAtoms,t.hAtoms);if(s+=t.saveFileCls.getAtomPDB(i),!e.bNode){let i=Object.keys(e.utilsCls.getHlStructures()).join(",");t.saveFileCls.saveFile(i+"_icn3d.pdb","text",[s])}return s}exportSecondary(){let e=this.icn3dui,t=e.icn3d,s="",i=e.hashUtilsCls.intHash(t.dAtoms,t.hAtoms);if(s+=t.saveFileCls.getSecondary(i),!e.bNode){let i=Object.keys(e.utilsCls.getHlStructures()).join(",");t.saveFileCls.saveFile(i+"_icn3d_ss.txt","text",[s])}return s}}class g{constructor(e){let t=e;this.icn3dui=e,this.cfg=this.icn3dui.cfg,this.opts={},this.opts.background="black",this.allMenus={},this.allMenusSel={},this.simpleMenus={},this.shownMenus={},this.WIDTH=400,this.HEIGHT=400,this.RESIDUE_WIDTH=10,t.utilsCls.isMobile()||this.cfg.mobilemenu?this.MENU_HEIGHT=0:this.MENU_HEIGHT=40,this.LOG_HEIGHT=65,this.MENU_WIDTH=750,this.LESSWIDTH=20,this.LESSWIDTH_RESIZE=20,this.LESSHEIGHT=20,this.width2d=200,this.CMD_HEIGHT=.8*this.LOG_HEIGHT,this.EXTRAHEIGHT=this.MENU_HEIGHT+this.CMD_HEIGHT,null!=this.cfg.showmenu&&0==this.cfg.showmenu&&(this.EXTRAHEIGHT-=this.MENU_HEIGHT),null!=this.cfg.showcommand&&0==this.cfg.showcommand&&(this.EXTRAHEIGHT-=this.CMD_HEIGHT),this.GREY8="#AAAAAA",this.GREYB="#CCCCCC",this.GREYC="#DDDDDD",this.GREYD="#EEEEEE",this.ORANGE="#FFA500",this.themecolor="blue",this.defaultValue=1,this.ssValue=3,this.coilValue=3,this.contactValue=11,this.contactInsideValue=12,this.hbondValue=13,this.hbondInsideValue=14,this.ssbondValue=4,this.ionicValue=5,this.ionicInsideValue=6,this.clbondValue=15,this.halogenValue=17,this.halogenInsideValue=18,this.picationValue=19,this.picationInsideValue=20,this.pistackingValue=21,this.pistackingInsideValue=22,this.contactColor="888",this.contactInsideColor="FFF",this.hbondColor="0F0",this.hbondInsideColor="FFF",this.ssbondColor="FFA500",this.ionicColor="0FF",this.ionicInsideColor="FFF",this.clbondColor="006400",this.halogenColor="F0F",this.halogenInsideColor="FFF",this.picationColor="F00",this.picationInsideColor="FFF",this.pistackingColor="00F",this.pistackingInsideColor="FFF",this.hideedges=1,this.force=4,this.simulation=void 0,this.baseUrl=window&&window.location&&"structure.ncbi.nlm.nih.gov"==window.location.hostname?"https://structure.ncbi.nlm.nih.gov/Structure/":"https://www.ncbi.nlm.nih.gov/Structure/",this.divStr="
    ",this.spanNowrapStr="",this.inputTextStr="=2.0 are supported.")));const a=new pe(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});a.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===r[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}a.setExtensions(l),a.setPlugins(r),a.parse(s,i)}parseAsync(e,t){const s=this;return new Promise((function(i,n){s.parse(e,t,i,n)}))}}function b(){let e={};return{get:function(t){return e[t]},add:function(t,s){e[t]=s},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const C={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class y{constructor(e){this.parser=e,this.name=C.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,i=t.length;s=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,n.source,l)}}class R{constructor(e){this.parser=e,this.name=C.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,i=s.json,n=i.textures[e];if(!n.extensions||!n.extensions[t])return null;const l=n.extensions[t],r=i.images[l.source];let o=s.textureLoader;if(r.uri){const e=s.options.manager.getHandler(r.uri);null!==e&&(o=e)}return this.detectSupport().then((function(n){if(n)return s.loadTextureImage(e,l.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class I{constructor(e){this.name=C.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const e=s.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),n=this.parser.options.meshoptDecoder;if(!n||!n.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([i,n.ready]).then((function(t){const s=e.byteOffset||0,i=e.byteLength||0,l=e.count,r=e.byteStride,o=new ArrayBuffer(l*r),a=new Uint8Array(t[0],s,i);return n.decodeGltfBuffer(new Uint8Array(o),l,r,a,e.mode,e.filter),o}))}return null}}const T="glTF",E=1313821514,P=5130562;class M{constructor(e){this.name=C.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:THREE.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==T)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-12,i=new DataView(e,12);let n=0;for(;n",t).replace("#include ",s).replace("#include ",i).replace("#include ",n).replace("#include ",l)},Object.defineProperties(this,{specular:{get:function(){return r.specular.value},set:function(e){r.specular.value=e}},specularMap:{get:function(){return r.specularMap.value},set:function(e){r.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return r.glossiness.value},set:function(e){r.glossiness.value=e}},glossinessMap:{get:function(){return r.glossinessMap.value},set:function(e){r.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class L{constructor(){this.name=C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity"]}getMaterialType(){return F}extendParams(e,t,s){const i=t.extensions[this.name];e.color=new Color(1,1,1),e.opacity=1;const n=[];if(Array.isArray(i.diffuseFactor)){const t=i.diffuseFactor;e.color.fromArray(t),e.opacity=t[3]}if(void 0!==i.diffuseTexture&&n.push(s.assignTexture(e,"map",i.diffuseTexture,sRGBEncoding)),e.emissive=new Color(0,0,0),e.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,e.specular=new Color(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){const t=i.specularGlossinessTexture;n.push(s.assignTexture(e,"glossinessMap",t)),n.push(s.assignTexture(e,"specularMap",t,sRGBEncoding))}return Promise.all(n)}createMaterial(e){const t=new F(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=TangentSpaceNormalMap,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t}}class N{constructor(){this.name=C.KHR_MESH_QUANTIZATION}}class q extends THREE.Interpolant{constructor(e,t,s,i){super(e,t,s,i)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,i=this.valueSize,n=e*i*3+i;for(let e=0;e!==i;e++)t[e]=s[n+e];return t}}q.prototype.beforeStart_=q.prototype.copySampleValue_,q.prototype.afterEnd_=q.prototype.copySampleValue_,q.prototype.interpolate_=function(e,t,s,i){const n=this.resultBuffer,l=this.sampleValues,r=this.valueSize,o=2*r,a=3*r,d=i-t,c=(s-t)/d,h=c*c,p=h*c,m=e*a,u=m-a,g=-2*p+3*h,f=p-h,b=1-g,C=f-h+c;for(let e=0;e!==r;e++){const t=l[u+e+r],s=l[u+e+o]*d,i=l[m+e+r],a=l[m+e]*d;n[e]=b*t+C*s+g*i+f*a}return n};const U=new THREE.Quaternion;class j extends q{interpolate_(e,t,s,i){const n=super.interpolate_(e,t,s,i);return U.fromArray(n).normalize().toArray(n),n}}const B=0,z=1,G=2,V=3,W=4,Y=5,X=6,K={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},J={9728:THREE.NearestFilter,9729:THREE.LinearFilter,9984:THREE.NearestMipmapNearestFilter,9985:THREE.LinearMipmapNearestFilter,9986:THREE.NearestMipmapLinearFilter,9987:THREE.LinearMipmapLinearFilter},Q={33071:THREE.ClampToEdgeWrapping,33648:THREE.MirroredRepeatWrapping,10497:THREE.RepeatWrapping},Z={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ee={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},te={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},se={CUBICSPLINE:void 0,LINEAR:THREE.InterpolateLinear,STEP:THREE.InterpolateDiscrete},ie="OPAQUE",ne="MASK",le="BLEND";function re(e,t,s){for(const i in s.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=s.extensions[i])}function oe(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function ae(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let s=0,i=t.weights.length;s{const s=this.associations.get(e);null!=s&&this.associations.set(t,s);for(const[s,i]of e.children.entries())n(i,t.children[s])};return n(s,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s=2&&m.setY(t,c[e*l+1]),l>=3&&m.setZ(t,c[e*l+2]),l>=4&&m.setW(t,c[e*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m}))}loadTexture(e){const t=this.json,s=this.options,i=t.textures[e].source,n=t.images[i];let l=this.textureLoader;if(n.uri){const e=s.manager.getHandler(n.uri);null!==e&&(l=e)}return this.loadTextureImage(e,i,l)}loadTextureImage(e,t,s){const i=this,n=this.json,l=n.textures[e],r=n.images[t],o=(r.uri||r.bufferView)+":"+l.sampler;if(this.textureCache[o])return this.textureCache[o];const a=this.loadImageSource(t,s).then((function(t){t.flipY=!1,l.name&&(t.name=l.name);const s=(n.samplers||{})[l.sampler]||{};return t.magFilter=J[s.magFilter]||LinearFilter,t.minFilter=J[s.minFilter]||LinearMipmapLinearFilter,t.wrapS=Q[s.wrapS]||RepeatWrapping,t.wrapT=Q[s.wrapT]||RepeatWrapping,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=a,a}loadImageSource(e,t){const s=this,i=this.json,n=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const l=i.images[e],r=self.URL||self.webkitURL;let o=l.uri||"",a=!1;if(void 0!==l.bufferView)o=s.getDependency("bufferView",l.bufferView).then((function(e){a=!0;const t=new Blob([e],{type:l.mimeType});return o=r.createObjectURL(t),o}));else if(void 0===l.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(o).then((function(e){return new Promise((function(s,i){let l=s;!0===t.isImageBitmapLoader&&(l=function(e){const t=new Texture(e);t.needsUpdate=!0,s(t)}),t.load(THREE.LoaderUtils.resolveURL(e,n.path),l,void 0,i)}))})).then((function(e){var t;return!0===a&&r.revokeObjectURL(o),e.userData.mimeType=l.mimeType||((t=l.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),e}));return this.sourceCache[e]=d,d}assignTexture(e,t,s,i){const n=this;return this.getDependency("texture",s.index).then((function(l){if(void 0===s.texCoord||0==s.texCoord||"aoMap"===t&&1==s.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+s.texCoord+" for texture "+t+" not yet supported."),n.extensions[C.KHR_TEXTURE_TRANSFORM]){const e=void 0!==s.extensions?s.extensions[C.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=n.associations.get(l);l=n.extensions[C.KHR_TEXTURE_TRANSFORM].extendTexture(l,e),n.associations.set(l,t)}}return void 0!==i&&(l.encoding=i),e[t]=l,l}))}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const i=void 0===t.attributes.tangent,n=void 0!==t.attributes.color,l=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new PointsMaterial,Material.prototype.copy.call(t,s),t.color.copy(s.color),t.map=s.map,t.sizeAttenuation=!1,this.cache.add(e,t)),s=t}else if(e.isLine){const e="LineBasicMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new LineBasicMaterial,Material.prototype.copy.call(t,s),t.color.copy(s.color),this.cache.add(e,t)),s=t}if(i||n||l){let e="ClonedMaterial:"+s.uuid+":";s.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),i&&(e+="derivative-tangents:"),n&&(e+="vertex-colors:"),l&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=s.clone(),n&&(t.vertexColors=!0),l&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(s))),s=t}s.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=s}getMaterialType(){return MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,i=this.extensions,n=s.materials[e];let l;const r={},o=n.extensions||{},a=[];if(o[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=i[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];l=e.getMaterialType(),a.push(e.extendParams(r,n,t))}else if(o[C.KHR_MATERIALS_UNLIT]){const e=i[C.KHR_MATERIALS_UNLIT];l=e.getMaterialType(),a.push(e.extendParams(r,n,t))}else{const s=n.pbrMetallicRoughness||{};if(r.color=new Color(1,1,1),r.opacity=1,Array.isArray(s.baseColorFactor)){const e=s.baseColorFactor;r.color.fromArray(e),r.opacity=e[3]}void 0!==s.baseColorTexture&&a.push(t.assignTexture(r,"map",s.baseColorTexture,sRGBEncoding)),r.metalness=void 0!==s.metallicFactor?s.metallicFactor:1,r.roughness=void 0!==s.roughnessFactor?s.roughnessFactor:1,void 0!==s.metallicRoughnessTexture&&(a.push(t.assignTexture(r,"metalnessMap",s.metallicRoughnessTexture)),a.push(t.assignTexture(r,"roughnessMap",s.metallicRoughnessTexture))),l=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),a.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,r)}))))}!0===n.doubleSided&&(r.side=DoubleSide);const d=n.alphaMode||ie;if(d===le?(r.transparent=!0,r.depthWrite=!1):(r.transparent=!1,d===ne&&(r.alphaTest=void 0!==n.alphaCutoff?n.alphaCutoff:.5)),void 0!==n.normalTexture&&l!==MeshBasicMaterial&&(a.push(t.assignTexture(r,"normalMap",n.normalTexture)),r.normalScale=new Vector2(1,1),void 0!==n.normalTexture.scale)){const e=n.normalTexture.scale;r.normalScale.set(e,e)}return void 0!==n.occlusionTexture&&l!==MeshBasicMaterial&&(a.push(t.assignTexture(r,"aoMap",n.occlusionTexture)),void 0!==n.occlusionTexture.strength&&(r.aoMapIntensity=n.occlusionTexture.strength)),void 0!==n.emissiveFactor&&l!==MeshBasicMaterial&&(r.emissive=(new Color).fromArray(n.emissiveFactor)),void 0!==n.emissiveTexture&&l!==MeshBasicMaterial&&a.push(t.assignTexture(r,"emissiveMap",n.emissiveTexture,sRGBEncoding)),Promise.all(a).then((function(){let s;return s=l===F?i[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(r):new l(r),n.name&&(s.name=n.name),oe(s,n),t.associations.set(s,{materials:e}),n.extensions&&re(i,s,n),s}))}createUniqueName(e){const t=PropertyBinding.sanitizeNodeName(e||"");let s=t;for(let e=1;this.nodeNamesUsed[s];++e)s=t+"_"+e;return this.nodeNamesUsed[s]=!0,s}loadGeometries(e){const t=this,s=this.extensions,i=this.primitiveCache;function n(e){return s[C.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(s){return ue(s,e,t)}))}const l=[];for(let s=0,r=e.length;s0&&ae(h,n),h.name=t.createUniqueName(n.name||"mesh_"+e),oe(h,n),c.extensions&&re(i,h,c),t.assignFinalMaterial(h),a.push(h)}for(let s=0,i=a.length;s1?new Group:1===t.length?t[0]:new Object3D,r!==t[0])for(let e=0,s=t.length;e{const t=new Map;for(const[e,s]of n.associations)(e instanceof Material||e instanceof Texture)&&t.set(e,s);return e.traverse((e=>{const s=n.associations.get(e);null!=s&&t.set(e,s)})),t})(l),l}))}}function me(e,t,s,i){const n=s.nodes[e];return i.getDependency("node",e).then((function(e){if(void 0===n.skin)return e;let t;return i.getDependency("skin",n.skin).then((function(e){t=e;const s=[];for(let e=0,n=t.joints.length;e{const s=n[e];return s&&(l={profileId:e,profilePath:`${t}/${s.path}`,deprecated:!!s.deprecated}),!!l})),!l){if(!s)throw new Error("No matching profile name found");const e=n[s];if(!e)throw new Error(`No matching profile name found and default profile "${s}" missing.`);l={profileId:s,profilePath:`${t}/${e.path}`,deprecated:!!e.deprecated}}const r=await be(l.profilePath);let o;if(i){let t;if(t="any"===e.handedness?r.layouts[Object.keys(r.layouts)[0]]:r.layouts[e.handedness],!t)throw new Error(`No matching handedness, ${e.handedness}, in profile ${l.profileId}`);t.assetPath&&(o=l.profilePath.replace("profile.json",t.assetPath))}return{profile:r,assetPath:o}}const ye={xAxis:0,yAxis:0,button:0,state:fe.ComponentState.DEFAULT};class ve{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===fe.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(ye)}updateFromComponent({xAxis:e,yAxis:t,button:s,state:i}){const{normalizedXAxis:n,normalizedYAxis:l}=function(e=0,t=0){let s=e,i=t;if(Math.sqrt(e*e+t*t)>1){const n=Math.atan2(t,e);s=Math.cos(n),i=Math.sin(n)}return{normalizedXAxis:.5*s+.5,normalizedYAxis:.5*i+.5}}(e,t);switch(this.componentProperty){case fe.ComponentProperty.X_AXIS:this.value=this.states.includes(i)?n:.5;break;case fe.ComponentProperty.Y_AXIS:this.value=this.states.includes(i)?l:.5;break;case fe.ComponentProperty.BUTTON:this.value=this.states.includes(i)?s:0;break;case fe.ComponentProperty.STATE:this.valueNodeProperty===fe.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(i):this.value=this.states.includes(i)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class _e{constructor(e,t){if(!(e&&t&&t.visualResponses&&t.gamepadIndices&&0!==Object.keys(t.gamepadIndices).length))throw new Error("Invalid arguments supplied");this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach((e=>{const s=new ve(t.visualResponses[e]);this.visualResponses[e]=s})),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:fe.ComponentState.DEFAULT,button:void 0!==this.gamepadIndices.button?0:void 0,xAxis:void 0!==this.gamepadIndices.xAxis?0:void 0,yAxis:void 0!==this.gamepadIndices.yAxis?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(e){if(this.values.state=fe.ComponentState.DEFAULT,void 0!==this.gamepadIndices.button&&e.buttons.length>this.gamepadIndices.button){const t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||1===this.values.button?this.values.state=fe.ComponentState.PRESSED:(t.touched||this.values.button>fe.ButtonTouchThreshold)&&(this.values.state=fe.ComponentState.TOUCHED)}void 0!==this.gamepadIndices.xAxis&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===fe.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>fe.AxisTouchThreshold&&(this.values.state=fe.ComponentState.TOUCHED)),void 0!==this.gamepadIndices.yAxis&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===fe.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>fe.AxisTouchThreshold&&(this.values.state=fe.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach((e=>{e.updateFromComponent(this.values)}))}}class we{constructor(e,t,s){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No profile supplied");this.xrInputSource=e,this.assetUrl=s,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach((e=>{const t=this.layoutDescription.components[e];this.components[e]=new _e(e,t)})),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const e=[];return Object.values(this.components).forEach((t=>{e.push(t.data)})),e}updateFromGamepad(){Object.values(this.components).forEach((e=>{e.updateFromGamepad(this.xrInputSource.gamepad)}))}}class Se extends THREE.Object3D{constructor(){super(),this.motionController=null,this.envMap=null}setEnvironmentMap(e){return this.envMap==e||(this.envMap=e,this.traverse((e=>{e.isMesh&&(e.material.envMap=this.envMap,e.material.needsUpdate=!0)}))),this}updateMatrixWorld(e){super.updateMatrixWorld(e),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach((e=>{Object.values(e.visualResponses).forEach((e=>{const{valueNode:t,minNode:s,maxNode:i,value:n,valueNodeProperty:l}=e;t&&(l===fe.VisualResponseProperty.VISIBILITY?t.visible=n:l===fe.VisualResponseProperty.TRANSFORM&&(t.quaternion.slerpQuaternions(s.quaternion,i.quaternion,n),t.position.lerpVectors(s.position,i.position,n)))}))})))}}function Ae(e,t){!function(e,t){Object.values(e.components).forEach((e=>{const{type:s,touchPointNodeName:i,visualResponses:n}=e;if(s===fe.ComponentType.TOUCHPAD)if(e.touchPointNode=t.getObjectByName(i),e.touchPointNode){const t=new SphereGeometry(.001),s=new MeshBasicMaterial({color:255}),i=new Mesh(t,s);e.touchPointNode.add(i)}else console.warn(`Could not find touch dot, ${e.touchPointNodeName}, in touchpad component ${e.id}`);Object.values(n).forEach((e=>{const{valueNodeName:s,minNodeName:i,maxNodeName:n,valueNodeProperty:l}=e;if(l===fe.VisualResponseProperty.TRANSFORM){if(e.minNode=t.getObjectByName(i),e.maxNode=t.getObjectByName(n),!e.minNode)return void console.warn(`Could not find ${i} in the model`);if(!e.maxNode)return void console.warn(`Could not find ${n} in the model`)}e.valueNode=t.getObjectByName(s),e.valueNode||console.warn(`Could not find ${s} in the model`)}))}))}(e.motionController,t),e.envMap&&t.traverse((t=>{t.isMesh&&(t.material.envMap=e.envMap,t.material.needsUpdate=!0)})),e.add(t)}class xe{constructor(e=null){this.gltfLoader=e,this.path="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",this._assetCache={},this.gltfLoader||(this.gltfLoader=new f)}createControllerModel(e){const t=new Se;let s=null;return e.addEventListener("connected",(e=>{const i=e.data;"tracked-pointer"===i.targetRayMode&&i.gamepad&&Ce(i,this.path,"generic-trigger").then((({profile:e,assetPath:n})=>{t.motionController=new we(i,e,n);const l=this._assetCache[t.motionController.assetUrl];if(l)s=l.scene.clone(),Ae(t,s);else{if(!this.gltfLoader)throw new Error("GLTFLoader not set.");this.gltfLoader.setPath(""),this.gltfLoader.load(t.motionController.assetUrl,(e=>{this._assetCache[t.motionController.assetUrl]=e,s=e.scene.clone(),Ae(t,s)}),null,(()=>{throw new Error(`Asset ${t.motionController.assetUrl} missing or malformed.`)}))}})).catch((e=>{console.warn(e)}))})),e.addEventListener("disconnected",(()=>{t.motionController=null,t.remove(s),s=null})),t}}class ke extends THREE.EventDispatcher{constructor(e){if(super(),void 0===e)return void console.error("ControllerGestures must be passed a renderer");const t=new THREE.Clock;this.controller1=e.xr.getController(0),this.controller1.userData.gestures={index:0},this.controller1.userData.selectPressed=!1,this.controller1.addEventListener("selectstart",i),this.controller1.addEventListener("selectend",n),this.controller2=e.xr.getController(1),this.controller2.userData.gestures={index:1},this.controller2.userData.selectPressed=!1,this.controller2.addEventListener("selectstart",i),this.controller2.addEventListener("selectend",n),this.doubleClickLimit=.2,this.pressMinimum=.4,this.right=new THREE.Vector3(1,0,0),this.up=new THREE.Vector3(0,1,0),this.type="unknown",this.prevTap="none",this.clock=t;const s=this;function i(){const e=this.userData.gestures;e.startPosition=void 0,e.startTime=t.getElapsedTime(),-1==s.type.indexOf("tap")&&(e.taps=0),s.type="unknown",this.userData.selectPressed=!0}function n(){const e=this.userData.gestures;e.endTime=t.getElapsedTime();e.endTime-e.startTime.05&&(e.startPosition=this.controller1.position.clone())),this.controller2.userData.selectPressed&&void 0===t.startPosition&&(i=s-t.startTime,i>.05&&(t.startPosition=this.controller2.position.clone())),!this.controller1.userData.selectPressed&&"tap"===this.type&&(i=this.clock.getElapsedTime()-e.endTime,i>this.doubleClickLimit)){switch(e.taps){case 1:self.prevTap="tap";break;case 2:this.dispatchEvent({type:"doubletap",position:this.controller1.position,matrixWorld:this.controller1.matrixWorld}),self.prevTap="doubletap"}this.type="unknown",e.taps=0}if("unknown"===this.type&&this.touch)"doubletap"==self.prevTap?(this.type="pinch",this.startDistance=this.controller1.position.distanceTo(this.controller2.position),this.dispatchEvent({type:"pinch",delta:new THREE.Vector3(0,0,0),scale:1,initialise:!0})):(this.type="pan",this.startPosition=this.controller1.position.clone(),this.dispatchEvent({type:"pan",delta:new THREE.Vector3(0,0,0),initialise:!0}));else if(("pinch"===this.type||"pan"===this.type)&&"doubletap"==self.prevTap&&this.controller2.position){const e=this.controller1.position.distanceTo(this.controller2.position)/this.startDistance,t=this.controller1.position.clone().sub(this.startPosition);this.dispatchEvent({type:"pinch",delta:t,scale:e})}}}class Oe{constructor(e,t){this.config=void 0===t?{panelSize:{width:1,height:1},width:512,height:512,opacity:.7,body:{fontFamily:"Arial",fontSize:30,padding:2,backgroundColor:"#000",fontColor:"#fff",borderRadius:6}}:t,void 0===this.config.width&&(this.config.width=512),void 0===this.config.height&&(this.config.height=512),void 0===this.config.body&&(this.config.body={fontFamily:"Arial",size:30,padding:2,backgroundColor:"#000",fontColor:"#fff",borderRadius:6});const s=this.config.body;void 0===s.borderRadius&&(s.borderRadius=6),void 0===s.fontFamily&&(s.fontFamily="Arial"),void 0===s.padding&&(s.padding=2),void 0===s.fontSize&&(s.fontSize=30),void 0===s.backgroundColor&&(s.backgroundColor="#000"),void 0===s.fontColor&&(s.fontColor="#fff"),Object.entries(this.config).forEach((([e,t])=>{if(!("object"!=typeof t||"panelSize"===e||t instanceof THREE.WebGLRenderer||t instanceof THREE.Scene)){const e=void 0!==t.position?t.position:{x:0,y:0};void 0!==e.left&&void 0===e.x&&(e.x=e.left),void 0!==e.top&&void 0===e.y&&(e.y=e.top);const s=void 0!==t.width?t.width:this.config.width,i=void 0!==t.height?t.height:this.config.height;void 0!==e.right&&void 0===e.x&&(e.x=this.config.width-e.right-s),void 0!==e.bottom&&void 0===e.y&&(e.y=this.config.height-e.bottom-i),void 0===e.x&&(e.x=0),void 0===e.y&&(e.y=0),t.position=e,void 0===t.type&&(t.type="text")}}));const i=this.createOffscreenCanvas(this.config.width,this.config.height);this.context=i.getContext("2d"),this.context.save();const n=void 0!==this.config.opacity?this.config.opacity:.7,l=new THREE.MeshBasicMaterial({transparent:!0,opacity:n});this.panelSize=void 0!==this.config.panelSize?this.config.panelSize:{width:1,height:1};const r=new THREE.PlaneGeometry(this.panelSize.width,this.panelSize.height);this.mesh=new THREE.Mesh(r,l),this.texture=new THREE.CanvasTexture(i),this.mesh.material.map=this.texture,this.scene=this.config.scene;if(Object.values(this.config).filter((e=>"input-text"===e.type)).length>0){this.keyboard=new Re(this.panelSize.width,this.config.renderer);this.keyboard.mesh.position.set(0,-.3,.2),this.mesh.add(this.keyboard.mesh)}if(void 0===e)this.content={body:""},this.config.body.type="text";else{this.content=e;Object.values(t).filter((e=>"button"===e.type||"scroll"===e.overflow||"input-text"===e.type)).length>0&&(void 0===t||void 0===t.renderer?console.warn("CanvasUI: button, scroll or input-text in the config but no renderer"):(this.renderer=t.renderer,this.initControllers()))}this.selectedElements=[void 0,void 0],this.selectPressed=[!1,!1],this.scrollData=[void 0,void 0],this.intersects=[void 0,void 0],this.needsUpdate=!0,this.update()}getIntersectY(e){const t=this.config.height||512,s=this.intersects[e];return void 0===s||void 0===s.uv?0:(1-s.uv.y)*t}initControllers(){this.vec3=new THREE.Vector3,this.mat4=new THREE.Matrix4,this.raycaster=new THREE.Raycaster;const e=this;function t(t){const s=t.target===e.controller?0:1,i=e.selectedElements[s];if(void 0!==i)if("button"==i.type)e.select(s);else if("input-text"==i.type&&e.keyboard)if(e.keyboard.visible)e.keyboard.linkedUI=void 0,e.keyboard.linkedText=void 0,e.keyboard.linkedElement=void 0,e.keyboard.visible=!1;else{let t;e.keyboard.linkedUI=e,Object.entries(e.config).forEach((([e,s])=>{s==i&&(t=e)}));const s=(.5-(i.position.y+i.height+e.config.body.padding)/e.config.height)*e.panelSize.height,n=Math.max(e.panelSize.width,e.panelSize.height)/2;e.keyboard.position.set(0,-n/1.5-s,.1),e.keyboard.linkedText=e.content[t],e.keyboard.linkedName=t,e.keyboard.linkedElement=i,e.keyboard.visible=!0}}function s(t){const s=t.target===e.controller?0:1;if(e.selectPressed[s]=!0,void 0!==e.selectedElements[s]&&"scroll"==e.selectedElements[s].overflow){const t=e.selectedElements[s];e.scrollData[s]={scrollY:t.scrollY,rayY:e.getIntersectY(s)}}}function i(t){const s=t.target===e.controller?0:1;e.selectPressed[s]=!1,void 0!==e.selectedElements[s]&&"scroll"==e.selectedElements[s].overflow&&(e.scrollData[s]=void 0)}if(this.controller=this.renderer.xr.getController(0),this.controller.addEventListener("select",t),this.controller.addEventListener("selectstart",s),this.controller.addEventListener("selectend",i),this.controller1=this.renderer.xr.getController(1),this.controller1.addEventListener("select",t),this.controller1.addEventListener("selectstart",s),this.controller1.addEventListener("selectend",i),this.scene){const e=.015,t=new THREE.IcosahedronBufferGeometry(e),s=new THREE.MeshBasicMaterial({color:170}),i=new THREE.Mesh(t,s);i.visible=!1,this.scene.add(i);const n=new THREE.Mesh(t,s);n.visible=!1,this.scene.add(n),this.intersectMesh=[i,n]}}setClip(e){const t=this.context;if(t.restore(),t.save(),void 0!==e.clipPath){const s=new Path2D(e.clipPath);t.clip(s)}else{const s=void 0!==e.position?e.position:{x:0,y:0},i=e.borderRadius||0,n=e.width||this.config.width,l=e.height||this.config.height;if(t.beginPath(),0!==i){const e=Math.PI/2;t.moveTo(s.x+i,s.y),t.arc(s.x+i,s.y+i,i,e,2*e,!0),t.lineTo(s.x,s.y+l-i),t.arc(s.x+i,s.y+l-i,i,0,e,!0),t.lineTo(s.x+n-i,s.y+l),t.arc(s.x+n-i,s.y+l-i,i,3*e,4*e,!0),t.lineTo(s.x+n,s.y+i),t.arc(s.x+n-i,s.y+i,i,2*e,3*e,!0),t.closePath(),t.clip()}else t.rect(s.x,s.y,n,l),t.clip()}}setPosition(e,t,s){void 0!==this.mesh&&this.mesh.position.set(e,t,s)}setRotation(e,t,s){void 0!==this.mesh&&this.mesh.rotation.set(e,t,s)}updateElement(e,t){let s=this.content[e];void 0!==s?("object"==typeof s?s.content=t:s=t,this.content[e]=s,this.needsUpdate=!0):console.warn(`CanvasGUI.updateElement: No ${e} found`)}get panel(){return this.mesh}getElementAtLocation(e,t){const s=this,i=Object.entries(this.config).filter((([i,n])=>{if(!("object"!=typeof n||"panelSize"===i||"body"===i||n instanceof THREE.WebGLRenderer||n instanceof THREE.Scene)){const i=n.position,l=void 0!==n.width?n.width:s.config.width,r=void 0!==n.height?n.height:s.config.height;return e>=i.x&&e=i.y&&t0?(this.hover(t,s[0].uv),this.intersects[t]=s[0],this.scroll(t)):(this.hover(t),this.intersects[t]=void 0,this.scroll(t))}update(){if(void 0===this.mesh)return;if(this.controller&&this.handleController(this.controller,0),this.controller1&&this.handleController(this.controller1,1),this.keyboard&&this.keyboard.visible&&this.keyboard.update(),!this.needsUpdate)return;let e=this.context;e.clearRect(0,0,this.config.width,this.config.height);const t=this.config.body.backgroundColor?this.config.body.backgroundColor:"#000";!this.config.body.fontFamily||this.config.body.fontFamily;const s=this.config.body.fontColor?this.config.body.fontColor:"#fff";!this.config.body.fontSize||this.config.body.fontSize,this.setClip(this.config.body),e.fillStyle=t,e.fillRect(0,0,this.config.width,this.config.height);const i=this;Object.entries(this.content).forEach((([t,n])=>{const l=void 0!==i.config[t]?i.config[t]:i.config.body;if("none"!==(void 0!==l.display?l.display:"block")){const r=void 0!==l.position?l.position:{x:0,y:0},o=void 0!==l.width?l.width:i.config.width,a=void 0!==l.height?l.height:i.config.height;"button"!=l.type||n.toLowerCase().startsWith("")||(void 0===l.borderRadius&&(l.borderRadius=6),void 0===l.textAlign&&(l.textAlign="center")),i.setClip(l);const d=n.toLowerCase().startsWith(""),c=void 0!==i.selectedElements[0]&&this.selectedElements[0]===l||void 0!==i.selectedElements[1]&&this.selectedElements[1]===l;if(void 0!==l.backgroundColor&&(c&&"button"==l.type&&void 0!==l.hover?e.fillStyle=l.hover:e.fillStyle=l.backgroundColor,e.fillRect(r.x,r.y,o,a)),"text"==l.type||"button"==l.type||"input-text"==l.type){let h=!1;if(c?(d||"button"!=l.type?e.fillStyle=void 0!==l.hover?l.hover:void 0!==l.fontColor?l.fontColor:s:e.fillStyle=void 0!==l.fontColor?l.fontColor:s,h=void 0===l.hover):e.fillStyle=void 0!==l.fontColor?l.fontColor:s,d){const t=n.toUpperCase().substring(6,n.length-7);e.save(),e.translate(r.x,r.y);const s=new Path2D(t);e.fill(s),e.restore()}else i.wrapText(t,n);h&&(e.beginPath(),e.strokeStyle="#fff",e.lineWidth=2,e.rect(r.x,r.y,o,a),e.stroke())}else if("img"==l.type)if(void 0===l.img)this.loadImage(n).then((e=>{console.log(`w: ${e.width} | h: ${e.height}`),l.img=e,i.needsUpdate=!0,i.update()})).catch((e=>console.error(e)));else{const t=o/(l.img.width/l.img.height);e.drawImage(l.img,r.x,r.y,o,t)}}})),this.needsUpdate=!1,this.texture.needsUpdate=!0}loadImage(e){return new Promise(((t,s)=>{const i=new THREE.Image;i.addEventListener("load",(()=>t(i))),i.addEventListener("error",(e=>s(e))),i.src=e}))}createOffscreenCanvas(e,t){const s=document.createElement("canvas");return s.width=e,s.height=t,s}fillRoundedRect(e,t,s,i,n){const l=this.context;l.beginPath(),l.moveTo(e+n,t),l.lineTo(e+s-n,t),l.quadraticCurveTo(e+s,t,e+s,t+n),l.lineTo(e+s,t+i-n),l.quadraticCurveTo(e+s,t+i,e+s-n,t+i),l.lineTo(e+n,t+i),l.quadraticCurveTo(e,t+i,e,t+i-n),l.lineTo(e,t+n),l.quadraticCurveTo(e,t,e+n,t),l.closePath(),l.fill()}lookAt(e){void 0!==this.mesh&&(e instanceof Vector3?this.mesh.lookAt(e):console.error("CanvasUI lookAt called parameter not a THREE.Vector3"))}get visible(){return void 0!==this.mesh&&this.mesh.visible}set visible(e){this.mesh&&(this.mesh.visible=e)}get position(){if(void 0!==this.mesh)return this.mesh.position}set position(e){void 0!==this.mesh&&(e instanceof Vector3?this.mesh.position.copy(e):console.error("CanvasUI trying to set the mesh position using a parameter that is not a THREE.Vector3"))}get quaternion(){if(void 0!==this.mesh)return this.mesh.quaternion}set quaternion(e){void 0!==this.mesh&&(e instanceof QUaternion?this.mesh.quaternion.copy(e):console.error("CanvasUI trying to set the mesh quaternion using a parameter that is not a THREE.Quaternion"))}wrapText(e,t){const s=t.split(" ");let i="";const n=[],l=void 0!==this.config[e]?this.config[e]:this.config.body,r=void 0!==l.width?l.width:this.config.width,o=void 0!==l.height?l.height:this.config.height,a=void 0!==l.position?l.position:{x:0,y:0},d=void 0!==l.padding?l.padding:void 0!==this.config.body.padding?this.config.body.padding:10,c=void 0!==l.paddingTop?l.paddingTop:d,h=void 0!==l.paddingLeft?l.paddingLeft:d,p=void 0!==l.paddingBottom?l.paddingBottom:d,m=void 0!==l.paddingRight?l.paddingRight:d,u={x:a.x+h,y:a.y+c,width:r-h-m,height:o-c-p},g=void 0!==l.textAlign?l.textAlign:void 0!==this.config.body.textAlign?this.config.body.textAlign:"left",f=void 0!==l.fontSize?l.fontSize:void 0!==this.config.body.fontSize?this.config.body.fontSize:30,b=void 0!==l.fontFamily?l.fontFamily:void 0!==this.config.body.fontFamily?this.config.body.fontFamily:"Arial",C=f+(void 0!==l.leading?l.leading:void 0!==this.config.body.leading?this.config.body.leading:8),y=this.context;y.textAlign=g,y.font=`${f}px '${b}'`,s.forEach((function(e){let t=s.length>1?`${i}${e} `:e,l=y.measureText(t);if(l.width>u.width&&e.length>1)if(0==i.length&&l.width>u.width){for(;l.width>u.width;){let s=0;do{s++,t=e.substr(0,s),l=y.measureText(t)}while(l.widthu.height&&"scroll"===l.overflow){void 0===l.scrollY&&(l.scrollY=0);const e=void 0!==l.fontColor?l.fontColor:this.config.body.fontColor;y.fillStyle="#aaa",this.fillRoundedRect(a.x+r-12,a.y,12,o,6),y.fillStyle="#666";const t=u.height/v,s=t*o,i=-l.scrollY*t;this.fillRoundedRect(a.x+r-12,a.y+i,12,s,6),y.fillStyle=e,_=l.scrollY,l.minScrollY=u.height-v}let w,S=_+u.y+f/2;switch(g){case"center":w=u.x+u.width/2;break;case"right":w=u.x+u.width;break;default:w=u.x}n.forEach((e=>{S+C>0&&y.fillText(e,w,S),S+=C}))}}class Re{constructor(e,t,s="EN"){const i=this.getConfig(s);i.panelSize={width:e,height:.5*e},i.height=256,i.body={backgroundColor:"#555"},i.renderer=t;const n=this.getContent(s);this.keyboard=new Oe(n,i),this.keyboard.mesh.visible=!1,this.shift=!1}get mesh(){return this.keyboard.mesh}getConfig(e){const t={};let s=10;const i=39.2,n=49,l="#333",r="#000";let o=s,a=s;for(let e=0;e<10;e++){const d={type:"button",position:{x:a,y:o},width:i,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e)};t[`btn${e}`]=d,a+=49.2}o+=59,a=s;for(let e=0;e<10;e++){const d={type:"button",position:{x:a,y:o},width:i,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+10)};t[`btn${e+10}`]=d,a+=49.2}o+=59,a=s;for(let e=0;e<9;e++){const d=0==e||8==e?1.5*i+5:i,c={type:"button",position:{x:a,y:o},width:d,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+20)};t[`btn${e+20}`]=c,a+=d+s}o+=59,a=s;for(let e=0;e<5;e++){const d=0==e||4==e?88.4:2==e?186.8:i,c={type:"button",position:{x:a,y:o},width:d,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+30)};0==e&&(c.fontSize=20),t[`btn${e+30}`]=c,a+=d+s}return t}getContent(e,t=0){let s,i={};switch(this.language=e,this.keyboardIndex=t,t){case 0:s=["q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","@","⇧","z","x","c","v","b","n","m","⇦","","?123",","," ",".","↲"];for(let e=0;e","_","`","~",":",";","⇦","","abc",","," ",".","↲"];for(let e=0;e=0;e--){let s=t.scene.children[e];t.scene.remove(s)}else t.scene=new THREE.Scene;if(void 0!==t.scene_ghost)for(let e=t.scene_ghost.children.length-1;e>=0;e--){let s=t.scene_ghost.children[e];t.scene_ghost.remove(s)}else t.scene_ghost=new THREE.Scene;if(""!=s.htmlCls.setHtmlCls.getCookie("shininess")){let e=parseFloat(s.htmlCls.setHtmlCls.getCookie("shininess"));t.shininess!=e&&s.htmlCls.clickMenuCls.setLogCmd("set shininess "+e,!0),t.shininess=e}if(!s.bNode&&""!=s.htmlCls.setHtmlCls.getCookie("light1")){let e=parseFloat(s.htmlCls.setHtmlCls.getCookie("light1")),i=parseFloat(s.htmlCls.setHtmlCls.getCookie("light2")),n=parseFloat(s.htmlCls.setHtmlCls.getCookie("light3"));t.light1==e&&t.light2==i&&t.light3==n||s.htmlCls.clickMenuCls.setLogCmd("set light | light1 "+e+" | light2 "+i+" | light3 "+n,!0),t.light1=e,t.light2=i,t.light3=n}t.directionalLight=new THREE.DirectionalLight(16777215,t.light1),t.directionalLight2=new THREE.DirectionalLight(16777215,t.light2),t.directionalLight3=new THREE.DirectionalLight(16777215,t.light3),t.cam_z>0?(t.directionalLight.position.set(-1,1,1),t.directionalLight2.position.set(1,1,1),t.directionalLight3.position.set(1,1,-1),t.lightPos=new THREE.Vector3(-1,1,1),t.lightPos2=new THREE.Vector3(1,1,1),t.lightPos3=new THREE.Vector3(1,1,-1)):(t.directionalLight.position.set(-1,1,-1),t.directionalLight2.position.set(1,1,-1),t.directionalLight3.position.set(1,1,1),t.lightPos=new THREE.Vector3(-1,1,-1),t.lightPos2=new THREE.Vector3(1,1,-1),t.lightPos3=new THREE.Vector3(1,1,1));let i=new THREE.AmbientLight(4210752);if(t.scene.add(t.directionalLight),t.scene.add(i),void 0!==t.mdl)for(let e=t.mdl.children.length-1;e>=0;e--){let s=t.mdl.children[e];s.geometry&&s.geometry.dispose(),s.material&&s.material.dispose(),t.mdl.remove(s)}if(void 0!==t.mdlImpostor){for(let e=t.mdlImpostor.children.length-1;e>=0;e--){let s=t.mdlImpostor.children[e];s.geometry&&s.geometry.dispose(),s.material&&s.material.dispose(),t.mdlImpostor.remove(s)}t.mdlImpostor.children.length=0}s.bNode||t.renderer.renderLists.dispose(),t.mdl=new THREE.Object3D,t.mdlImpostor=new THREE.Object3D,t.scene.add(t.mdl),t.scene.add(t.mdlImpostor),t.mdl_ghost=new THREE.Object3D,t.scene_ghost.add(t.mdl_ghost),t.objects=[],t.objects_ghost=[],t.raycaster=new THREE.Raycaster,t.projector=new THREE.Projector,t.mouse=new THREE.Vector2;let n=s.parasCls.backgroundColors[t.opts.background.toLowerCase()];s.bNode||("transparent"===t.opts.background.toLowerCase()?t.renderer.setClearColor(n,0):t.renderer.setClearColor(n,1)),t.perspectiveCamera=new THREE.PerspectiveCamera(20,t.container.whratio,.1,1e4),t.perspectiveCamera.position.set(0,0,t.cam_z),t.perspectiveCamera.lookAt(new THREE.Vector3(0,0,0)),t.orthographicCamera=new THREE.OrthographicCamera,t.orthographicCamera.position.set(0,0,t.cam_z),t.orthographicCamera.lookAt(new THREE.Vector3(0,0,0)),t.cams={perspective:t.perspectiveCamera,orthographic:t.orthographicCamera}}setVrAr(){let e=this.icn3d;e.icn3dui;let t=this;e.bSetVrAr=!0,e.bVr?(e.canvasUI=this.createUI(),e.raycasterVR=new THREE.Raycaster,e.workingMatrix=new THREE.Matrix4,e.workingVector=new THREE.Vector3,e.origin=new THREE.Vector3,e.dolly=new THREE.Object3D,e.dolly.position.z=5,e.dolly.add(e.cam),e.scene.add(e.dolly),e.dollyId=e.dolly.id,e.dummyCam=new THREE.Object3D,e.cam.add(e.dummyCam),e.clock=new THREE.Clock,e.controllers=this.getControllers(),e.controllers.forEach((s=>{s.addEventListener("connected",(function(e){try{const s={},i="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",n="generic-trigger";Ce(e.data,i,n).then((({profile:i,assetPath:n})=>{s.name=i.profileId,s.targetRayMode=e.data.targetRayMode,Object.entries(i.layouts).forEach((([e,t])=>{const i={};Object.values(t.components).forEach((e=>{i[e.rootNodeName]=e.gamepadIndices})),s[e]=i})),t.updateControllers(s)}))}catch(e){}})),s.addEventListener("disconnected",(function(){this.remove(this.children[0]),e.controllers.forEach((e=>{}))}))}))):e.bAr&&(e.gestures=new ke(e.renderer),e.scene.add(e.gestures.controller1),e.scene.add(e.gestures.controller2),e.gestures.addEventListener("doubletap",(e=>{t.positionCenter()})),e.gestures.addEventListener("pinch",(s=>{if(void 0!==s.initialise)t.startPosition=e.mdl.position.clone(),t.startScale=e.mdl.scale.clone();else{let i=1;const n=t.startScale.clone().multiplyScalar(s.scale*i);e.mdl.scale.copy(n)}})))}positionCenter(){let e=this.icn3d;e.icn3dui;const t=e.gestures.controller1;e.mdl.position.set(-.06,0,-.6).applyMatrix4(t.matrixWorld),e.mdl.scale.copy(new THREE.Vector3(.005,.005,.005))}setVrArButtons(){let e=this.icn3d,t=e.icn3dui;e.bSetVrArButtons=!0,t.bNode||($("#"+t.pre+"VRButton").remove(),$("#"+t.pre+"viewer").get(0).appendChild(e.VRButtonCls.createButton(e.renderer)),$("#"+t.pre+"ARButton").remove(),$("#"+t.pre+"viewer").get(0).appendChild(e.ARButtonCls.createButton(e.renderer)))}updateControllers(e){this.icn3d.icn3dui,this.addEventForController(e,"right"),this.addEventForController(e,"left")}addEventForController(e,t){let s=this.icn3d;s.icn3dui;const i="right"==t?s.renderer.xr.getController(0):s.renderer.xr.getController(1),n="right"==t?e.right:e.left;if(i&&void 0!==n){let e=!1,t=!1;Object.keys(n).forEach((i=>{-1!=i.indexOf("trigger")&&(e=!0),-1!=i.indexOf("squeeze")&&(t=!0),-1==i.indexOf("thumbstick")&&-1==i.indexOf("touchpad")||(s.xAxisIndex=n[i].xAxis,s.yAxisIndex=n[i].yAxis)})),e&&(i.addEventListener("selectstart",(function(){this.userData.selectPressed=!0})),i.addEventListener("selectend",(function(){this.userData.selectPressed=!1,this.userData.selected=void 0}))),t&&(i.addEventListener("squeezestart",(function(){this.userData.squeezePressed=!0,s.cam.add(s.canvasUI.mesh)})),i.addEventListener("squeezeend",(function(){this.userData.squeezePressed=!1,s.cam.remove(s.canvasUI.mesh)})))}}createUI(){let e=this.icn3d,t=e.icn3dui,s=94,i=50,n=94,l=34,r=12,o="#1c94c4",a="#ccc",d="#fbcb09",c=20;const h={panelSize:{width:2,height:1.6},height:400,select:{type:"button",paddingTop:c,position:{top:6,left:6},width:s,height:i,fontColor:"#000",fontSize:14,backgroundColor:a},residue:{type:"button",paddingTop:c,position:{top:62,left:6},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.pk=2,e.pAtomNum||(e.pAtomNum=0),e.cam.remove(e.canvasUI.mesh)}},secondarySelect:{type:"button",paddingTop:12,position:{top:118,left:6},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.pk=3,e.pAtomNum||(e.pAtomNum=0),e.cam.remove(e.canvasUI.mesh)}},chainSelect:{type:"button",paddingTop:c,position:{top:174,left:6},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.pk=5,e.pAtomNum||(e.pAtomNum=0),e.cam.remove(e.canvasUI.mesh)}},atom:{type:"button",paddingTop:c,position:{top:230,left:6},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.pk=1,e.pAtomNum||(e.pAtomNum=0),e.cam.remove(e.canvasUI.mesh)}},reset:{type:"button",paddingTop:c,position:{top:286,left:6},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.viewInterPairsCls.resetInteractionPairs(),e.selectionCls.resetAll(),e.cam.remove(e.canvasUI.mesh)}},togglehl:{type:"button",paddingTop:12,position:{top:342,left:6},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.hlUpdateCls.toggleHighlight(),e.cam.remove(e.canvasUI.mesh)}},style:{type:"button",paddingTop:c,position:{top:6,left:106},width:s,height:i,fontColor:"#000",fontSize:14,backgroundColor:a},ribbon:{type:"button",paddingTop:c,position:{top:62,left:106},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.setOptionCls.setStyle("proteins","ribbon"),e.setOptionCls.setStyle("nucleotides","nucleotide cartoon"),e.cam.remove(e.canvasUI.mesh)}},schematic:{type:"button",paddingTop:c,position:{top:118,left:106},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.setOptionCls.setStyle("proteins","schematic"),e.setOptionCls.setStyle("nucleotides","schematic"),e.cam.remove(e.canvasUI.mesh)}},stick:{type:"button",paddingTop:c,position:{top:174,left:106},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.setOptionCls.setStyle("proteins","stick"),e.setOptionCls.setStyle("nucleotides","stick"),e.cam.remove(e.canvasUI.mesh)}},sphere:{type:"button",paddingTop:c,position:{top:230,left:106},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.setOptionCls.setStyle("proteins","sphere"),e.setOptionCls.setStyle("nucleotides","sphere"),e.cam.remove(e.canvasUI.mesh)}},surface:{type:"button",paddingTop:c,position:{top:286,left:106},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.opts.surface="molecular surface",e.applyMapCls.applySurfaceOptions(),e.cam.remove(e.canvasUI.mesh)}},surfaceTrn:{type:"button",paddingTop:12,position:{top:342,left:106},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.opts.surface="molecular surface",e.opts.opacity="0.2",e.applyMapCls.applySurfaceOptions(),e.cam.remove(e.canvasUI.mesh)}},color:{type:"button",paddingTop:c,position:{top:6,left:206},width:s,height:i,fontColor:"#000",fontSize:14,backgroundColor:a},rainbow:{type:"button",paddingTop:c,position:{top:62,left:206},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.setOptionCls.setOption("color","rainbow for chains"),e.cam.remove(e.canvasUI.mesh)}},atomColor:{type:"button",paddingTop:c,position:{top:118,left:206},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.setOptionCls.setOption("color","atom"),e.cam.remove(e.canvasUI.mesh)}},chainColor:{type:"button",paddingTop:c,position:{top:174,left:206},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.setOptionCls.setOption("color","chain"),e.cam.remove(e.canvasUI.mesh)}},secondaryColor:{type:"button",paddingTop:12,position:{top:230,left:206},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.setOptionCls.setOption("color","secondary structure green"),e.cam.remove(e.canvasUI.mesh)}},charge:{type:"button",paddingTop:c,position:{top:342,left:206},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.setOptionCls.setOption("color","charge"),e.cam.remove(e.canvasUI.mesh)}},AlphaFold:{type:"button",paddingTop:c,position:{top:286,left:206},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.setOptionCls.setOption("color","confidence"),e.cam.remove(e.canvasUI.mesh)}},unicolor:{type:"button",paddingTop:c,position:{top:6,left:306},width:s,height:i,fontColor:"#000",fontSize:14,backgroundColor:a},red:{type:"button",position:{top:i,left:300},width:n,height:l,fontColor:"red",hover:d,onSelect:function(){e.setOptionCls.setOption("color","red"),e.cam.remove(e.canvasUI.mesh)}},green:{type:"button",position:{top:78,left:300},width:n,height:l,fontColor:"green",hover:d,onSelect:function(){e.setOptionCls.setOption("color","green"),e.cam.remove(e.canvasUI.mesh)}},blue:{type:"button",position:{top:106,left:300},width:n,height:l,fontColor:"blue",hover:d,onSelect:function(){e.setOptionCls.setOption("color","blue"),e.cam.remove(e.canvasUI.mesh)}},blueviolet:{type:"button",position:{top:134,left:300},width:n,height:l,fontColor:"#8A2BE2",hover:d,onSelect:function(){e.setOptionCls.setOption("color","8A2BE2"),e.cam.remove(e.canvasUI.mesh)}},magenta:{type:"button",position:{top:162,left:300},width:n,height:l,fontColor:"magenta",hover:d,onSelect:function(){e.setOptionCls.setOption("color","magenta"),e.cam.remove(e.canvasUI.mesh)}},yellow:{type:"button",position:{top:190,left:300},width:n,height:l,fontColor:"yellow",hover:d,onSelect:function(){e.setOptionCls.setOption("color","yellow"),e.cam.remove(e.canvasUI.mesh)}},orange:{type:"button",position:{top:218,left:300},width:n,height:l,fontColor:"orange",hover:d,onSelect:function(){e.setOptionCls.setOption("color","FFA500"),e.cam.remove(e.canvasUI.mesh)}},cyan:{type:"button",position:{top:246,left:300},width:n,height:l,fontColor:"cyan",hover:d,onSelect:function(){e.setOptionCls.setOption("color","cyan"),e.cam.remove(e.canvasUI.mesh)}},gray:{type:"button",position:{top:274,left:300},width:n,height:l,fontColor:"gray",hover:d,onSelect:function(){e.setOptionCls.setOption("color","888888"),e.cam.remove(e.canvasUI.mesh)}},white:{type:"button",position:{top:302,left:300},width:n,height:l,fontColor:"white",hover:d,onSelect:function(){e.setOptionCls.setOption("color","white"),e.cam.remove(e.canvasUI.mesh)}},analysis:{type:"button",paddingTop:c,position:{top:6,left:406},width:s,height:i,fontColor:"#000",fontSize:14,backgroundColor:a},distance:{type:"button",paddingTop:c,position:{top:62,left:406},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){try{e.bMeasureDistance=!0;let s=e.pickingCls.getPickedAtomList(e.pk,e.pAtom),i=e.pickingCls.getPickedAtomList(e.pk,e.pAtom2),n=e.applyCenterCls.centerAtoms(t.hashUtilsCls.hash2Atoms(s,e.atoms)).center,l=e.applyCenterCls.centerAtoms(t.hashUtilsCls.hash2Atoms(i,e.atoms)).center,r=0,o=0,a="#FFFF00",d=(n.x+l.x)/2,c=(n.y+l.y)/2,h=(n.z+l.z)/2,p=!0;e.analysisCls.addLine(n.x,n.y,n.z,l.x,l.y,l.z,a,p,"distance");let m=(parseInt(10*n.distanceTo(l))/10).toString()+" A";e.analysisCls.addLabel(m,d,c,h,r,a,o,"distance"),e.drawCls.draw(),e.cam.remove(e.canvasUI.mesh)}catch(e){}}},interaction:{type:"button",paddingTop:c,position:{top:118,left:406},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){try{e.viewInterPairsCls.viewInteractionPairs(["selected"],["non-selected"],!1,"3d",1,1,1,1,1,1),e.cam.remove(e.canvasUI.mesh)}catch(e){}}},delphi:{type:"button",paddingTop:c,position:{top:174,left:406},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:async function(){e.phisurftype=22,e.phisurfop=1,e.phisurfwf="no",await e.delphiCls.CalcPhi(65,.15,2,!0),e.cam.remove(e.canvasUI.mesh)}},removeLabel:{type:"button",paddingTop:c,position:{top:230,left:406},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){for(let t in e.labels)e.labels[t]=[];e.drawCls.draw(),e.cam.remove(e.canvasUI.mesh)}},renderer:e.renderer},p=new Oe({select:"Select",residue:"Residue",secondarySelect:"Secondary Structure",chainSelect:"Chain",atom:"Atom",reset:"Reset",togglehl:"Toggle Highlight",style:"Style",ribbon:"Ribbon",schematic:"Schematic",stick:"Stick",sphere:"Sphere",surface:"Surface",surfaceTrn:"Transparent Surface",color:"Color",rainbow:"Rainbow",atomColor:"Atom",chainColor:"Chain",secondaryColor:"Secondary Structure",AlphaFold:"AlphaFold",charge:"Charge",unicolor:"UniColor",red:"M 100 15 L 15 15 L 15 100 L 100 100 Z",green:"M 100 15 L 15 15 L 15 100 L 100 100 Z",blue:"M 100 15 L 15 15 L 15 100 L 100 100 Z",blueviolet:"M 100 15 L 15 15 L 15 100 L 100 100 Z",magenta:"M 100 15 L 15 15 L 15 100 L 100 100 Z",yellow:"M 100 15 L 15 15 L 15 100 L 100 100 Z",orange:"M 100 15 L 15 15 L 15 100 L 100 100 Z",cyan:"M 100 15 L 15 15 L 15 100 L 100 100 Z",gray:"M 100 15 L 15 15 L 15 100 L 100 100 Z",white:"M 100 15 L 15 15 L 15 100 L 100 100 Z",analysis:"Analysis",distance:"Distance",interaction:"Interaction",delphi:"DelPhi Potential",removeLabel:"Remove Label"},h);return p.mesh.position.set(0,0,-3),p}createUILog(){let e=this.icn3d;e.icn3dui;const t={panelSize:{width:2,height:2},height:512,info:{type:"text",overflow:"scroll",position:{top:6,left:6},width:506,height:506,backgroundColor:"#aaa",fontColor:"#000"},renderer:e.renderer},s=new Oe({info:"Debug info"},t);return s.mesh.position.set(0,-1,-2),s}getControllers(){let e=this.icn3d;e.icn3dui;const t=new xe,s=(new THREE.BufferGeometry).setFromPoints([new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,-1)]),i=new THREE.Line(s);i.name="line",i.scale.z=50;const n=[];for(let s=0;s<=1;s++){const l=e.renderer.xr.getController(s);if(!l)continue;e.dolly.add(l),l.add(i.clone()),l.userData.selectPressed=!1,e.cam.add(l),n.push(l);const r=e.renderer.xr.getControllerGrip(s);r.add(t.createControllerModel(r)),e.scene.add(r)}return n}}class Te{constructor(e){this.icn3d=e}setCamera(){let e=this.icn3d,t=e.icn3dui;if(e.bControlGl&&!t.bNode){window.cam=e.cams[e.opts.camera.toLowerCase()];let s=e.maxD;if(window.cam===e.perspectiveCamera){let i=void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>e.maxatomcnt;i?window.camMaxDFactor=1:void 0!==window.camMaxDFactorFog?window.camMaxDFactor=window.camMaxDFactorFog:window.camMaxDFactor=3,window.cam_z>0?window.cam.position.z=s*window.camMaxDFactor:window.cam.position.z=-s*window.camMaxDFactor,"yes"===e.opts.slab?i?window.cam.near=.1:void 0!==window.camMaxDFactorFog?window.cam.near=s*window.camMaxDFactorFog-10:window.cam.near=s*window.camMaxDFactor:window.cam.near=.1,window.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.TrackballControls(window.cam,void 0,e):t.bNode?e.controls=new THREE.TrackballControls(e.cam,document,e):e.controls=new THREE.TrackballControls(e.cam,document.getElementById(e.id),e)}else window.cam===e.orthographicCamera&&(void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>10*e.maxatomcnt?window.cam.right=e.maxD/2*1.5:window.cam.right=e.maxD/2*2.5,window.cam.left=-window.cam.right,window.cam.top=window.cam.right/e.container.whratio,window.cam.bottom=-window.cam.right/e.container.whratio,"yes"===e.opts.slab?window.cam.near=2*e.maxD:window.cam.near=0,window.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.OrthographicTrackballControls(window.cam,void 0,e):t.bNode?e.controls=new THREE.OrthographicTrackballControls(e.cam,document,e):e.controls=new THREE.OrthographicTrackballControls(e.cam,document.getElementById(e.id),e));window.cam.updateProjectionMatrix()}e.cam=e.cams[e.opts.camera.toLowerCase()];let s=e.maxD;if(e.cam===e.perspectiveCamera){let i=void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>e.maxatomcnt;i?e.camMaxDFactor=1:void 0!==e.camMaxDFactorFog?e.camMaxDFactor=e.camMaxDFactorFog:e.camMaxDFactor=3,e.cam_z>0?e.cam.position.z=s*e.camMaxDFactor:e.cam.position.z=-s*e.camMaxDFactor,"yes"===e.opts.slab?i?e.cam.near=.1:void 0!==e.camMaxDFactorFog?e.cam.near=s*e.camMaxDFactorFog-10:e.cam.near=s*e.camMaxDFactor:e.cam.near=.1,e.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.TrackballControls(e.cam,void 0,e):t.bNode?e.controls=new THREE.TrackballControls(e.cam,document,e):e.controls=new THREE.TrackballControls(e.cam,document.getElementById(e.id),e)}else e.cam===e.orthographicCamera&&(void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>10*e.maxatomcnt?e.cam.right=e.maxD/2*1.5:e.cam.right=e.maxD/2*2.5,e.cam.left=-e.cam.right,e.cam.top=e.cam.right/e.container.whratio,e.cam.bottom=-e.cam.right/e.container.whratio,"yes"===e.opts.slab?e.cam.near=2*e.maxD:e.cam.near=0,e.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.OrthographicTrackballControls(e.cam,void 0,e):t.bNode?e.controls=new THREE.OrthographicTrackballControls(e.cam,document,e):e.controls=new THREE.OrthographicTrackballControls(e.cam,document.getElementById(e.id),e));e.cam.updateProjectionMatrix()}}class Ee{constructor(e){this.icn3d=e}setFog(e){let t=this.icn3d,s=t.icn3dui.parasCls.backgroundColors[t.opts.background.toLowerCase()];if(e){let e=t.applyCenterCls.centerAtoms(t.hAtoms);t.maxD=e.maxD,t.maxD<25&&(t.maxD=25)}let i=void 0!==t.biomtMatrices&&t.biomtMatrices.length*t.cnt>t.maxatomcnt;if("yes"===t.opts.fog)if("perspective"===t.opts.camera)if(i)t.scene.fog=void 0,t.bSetFog=!1;else{let e=t._zoomFactor>1?1*t._zoomFactor:t._zoomFactor;t.scene.fog=new THREE.Fog(s,2.5*t.maxD*e,4*t.maxD*e),t.bSetFog=!0,t.camMaxDFactorFog=3}else"orthographic"===t.opts.camera&&(t.scene.fog=void 0,t.bSetFog=!1);else t.scene.fog=void 0,t.bSetFog=!1}}class Pe{constructor(e){this.icn3d=e}createBox(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(o.bNode)return;void 0===t&&(t=.8),void 0===s&&(s=!1),void 0===i&&(i=.8),l?void 0===n&&(n=r.hColor):void 0===n&&(n=e.color);let a=s?t:(o.parasCls.vdwRadii[e.elem.toUpperCase()]||t)*(i||1);this.createBox_base(e.coord,a,n,l)}createBox_base(e,t,s,i,n,l,r){let o,a=this.icn3d;a.icn3dui.bNode||(void 0===r&&(r=l?.5:1),new THREE.BoxGeometry(1,1,1),o=new THREE.Mesh(a.boxGeometry,new THREE.MeshPhongMaterial({transparent:!0,opacity:r,specular:a.frac,shininess:a.shininess,emissive:a.emissive,color:s})),o.scale.x=o.scale.y=o.scale.z=t,o.position.copy(e),a.mdl.add(o),i?a.prevHighlightObjects.push(o):n?a.prevOtherMesh.push(o):a.objects.push(o))}createBoxRepresentation_P_CA(e,t,s){let i=this.icn3d;if(i.icn3dui.bNode)return;let n=this;i.reprSubCls.createRepresentationSub(e,(function(e){"CA"!==e.name&&"O3'"!==e.name&&"O3*"!==e.name||n.createBox(e,void 0,void 0,t,void 0,s)}))}}class Me{constructor(e){this.icn3d=e}createBrick(e,t,s,i){let n=this.icn3d;if(n.icn3dui.bNode)return;let l=new THREE.CylinderGeometry(1,1,1,4,1),r=new THREE.Mesh(l,new THREE.MeshPhongMaterial({specular:n.frac,shininess:n.shininess,emissive:n.emissive,color:i}));r.position.copy(e).add(t).multiplyScalar(.5),r.matrixAutoUpdate=!1,r.lookAt(t.clone().sub(e)),r.updateMatrix(),r.matrix.multiply((new THREE.Matrix4).makeScale(s,s,e.distanceTo(t))).multiply((new THREE.Matrix4).makeRotationX(.5*Math.PI)),n.mdl.add(r)}}class De{constructor(e){this.icn3d=e}createCurveSubArrow(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u){if(this.icn3d.icn3dui.bNode)return;let g=[],f=[];g.push(e),f.push(o),this.prepareStrand(g,f,t,s,i,void 0,n,l,r,a,d,!1,c,h,p,m,u),g=[],f=[]}createStripArrow(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g){if(this.icn3d.icn3dui.bNode)return;let f=[],b=[];f.push(e),f.push(t),b.push(o),b.push(a),this.prepareStrand(f,b,void 0,s,i,n,l,void 0,r,d,c,!0,h,p,m,u,g),f=[],b=[]}prepareStrand(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g,f){let b=this.icn3d,C=b.icn3dui;if(1===d.length)return;let y=i,v=!u,_=[];_.push(i[i.length-2]),_.push(i[i.length-1]),n=n||b.axisDIV;let w,S,A,x,k=2/(a-1),O={};for(let e=0,s=t.length;e1)if(void 0!==d){let i,n,l=[];for(let r=0,o=p.length;r0&&i.tubeCls.createTube(a,"CA",i.coilWidth,s),Object.keys(d).length>0&&i.strandCls.createStrand(d,void 0,void 0,!0,0,i.helixSheetWidth,!1,2*i.ribbonthickness,s)):(Object.keys(a).length>0&&i.tubeCls.createTube(a,"CA",i.coilWidth),Object.keys(d).length>0&&i.strandCls.createStrand(d,void 0,void 0,!0,0,i.helixSheetWidth,!1,2*i.ribbonthickness))}createCylinderCurve(e,t,s,i,n){let l=this.icn3d;if(l.icn3dui.bNode)return;let r,o,a,d,c,h,p=null;for(a in e)if(d=e[a],!d.het&&(c=d.structure+"_"+d.chain,h=d.structure+"_"+r,-1!=t.indexOf(d.name))){if(null!==p&&r===d.chain&&l.ParserUtilsCls.getResiNCBI(h,o)+1===l.ParserUtilsCls.getResiNCBI(c,d.resi)&&Math.abs(p.coord.x-d.coord.x)<8&&Math.abs(p.coord.y-d.coord.y)<8&&Math.abs(p.coord.z-d.coord.z)<8){let e=p.coord.clone().add(d.coord).multiplyScalar(.5);if(n)1===n&&(this.createCylinder(p.coord,e,s,p.color,n),this.createCylinder(e,d.coord,s,d.color,n),l.sphereCls.createSphere(d,s,!0,1,n));else if(i){let t=l.lineCls.createSingleLine(p.coord,e,p.color,!1);l.mdl.add(t),l.objects.push(t),t=l.lineCls.createSingleLine(e,d.coord,d.color,!1),l.mdl.add(t),l.objects.push(t)}else this.createCylinder(p.coord,e,s,p.color),this.createCylinder(e,d.coord,s,d.color),l.sphereCls.createSphere(d,s,!0,1,n)}p=d,r=d.chain,o=d.resi,l.sphereCls.createSphere(d,s,!0,1,n),2===n&&l.boxCls.createBox(d,void 0,void 0,void 0,void 0,n)}if(null!==p&&r===d.chain&&l.ParserUtilsCls.getResiNCBI(h,o)+1===l.ParserUtilsCls.getResiNCBI(c,d.resi)&&Math.abs(p.coord.x-d.coord.x)<8&&Math.abs(p.coord.y-d.coord.y)<8&&Math.abs(p.coord.z-d.coord.z)<8){let e=p.coord.add(d.coord).multiplyScalar(.5);if(n)1===n&&(this.createCylinder(p.coord,e,s,p.color,n),this.createCylinder(e,d.coord,s,d.color,n),l.sphereCls.createSphere(d,s,!0,1,n));else if(i){let t=l.lineCls.createSingleLine(p.coord,e,p.color,!1);l.mdl.add(t),l.objects.push(t),t=l.lineCls.createSingleLine(e,d.coord,d.color,!1),l.mdl.add(t),l.objects.push(t)}else this.createCylinder(p.coord,e,s,p.color),this.createCylinder(e,d.coord,s,d.color)}}}class Le{constructor(e){this.icn3d=e}createLineRepresentation(e,t){let s=this.icn3d;if(s.icn3dui.bNode)return;let i=new THREE.BufferGeometry,n=[],l=[],r=0,o=0;s.reprSubCls.createRepresentationSub(e,void 0,(function(e,t){if(e.color===t.color)n[r++]=e.coord.x,n[r++]=e.coord.y,n[r++]=e.coord.z,n[r++]=t.coord.x,n[r++]=t.coord.y,n[r++]=t.coord.z,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b;else{let s=e.coord.clone().add(t.coord).multiplyScalar(.5);n[r++]=e.coord.x,n[r++]=e.coord.y,n[r++]=e.coord.z,n[r++]=s.x,n[r++]=s.y,n[r++]=s.z,n[r++]=t.coord.x,n[r++]=t.coord.y,n[r++]=t.coord.z,n[r++]=s.x,n[r++]=s.y,n[r++]=s.z,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b}}));if(i.setAttribute("position",new THREE.BufferAttribute(new Float32Array(n),3)),i.setAttribute("color",new THREE.BufferAttribute(new Float32Array(l),3)),2!==t){let e;1===t||(e=new THREE.LineSegments(i,new THREE.LineBasicMaterial({linewidth:s.linewidth,vertexColors:!0})),s.mdl.add(e)),1===t?s.prevHighlightObjects.push(e):s.objects.push(e)}else 2===t&&s.boxCls.createBoxRepresentation_P_CA(e,.8,t)}createConnCalphSidechain(e,t){let s=this.icn3d;if(s.icn3dui.bNode)return;let i={};for(let s in e){let n=e[s];if(!n.het&&n.style2===t){i[n.structure+"_"+n.chain+"_"+n.resi]=1}}let n=[],l=[];for(let e in i){let t=s.firstAtomObjCls.getFirstAtomObjByName(s.residues[e],"CA");if(void 0!==t)for(let e=0,i=t.bonds.length;e=t.bonds.length&&e.bonds.length>1)s=e.serial,l=e.bonds[0],d=e.bonds[1];else{if(!(t.bonds.length>=e.bonds.length&&t.bonds.length>1))return void console.log("Double bond was not drawn due to the undefined cross plane");s=t.serial,l=t.bonds[0],d=t.bonds[1]}let i=r.atoms[s].coord.clone();i.sub(r.atoms[l].coord);let n=r.atoms[s].coord.clone();n.sub(r.atoms[d].coord),i.cross(n),0==parseInt(1e4*i.length())&&(i=new THREE.Vector3(.2,.3,.5)),c=t.coord.clone(),c.sub(e.coord),c.cross(i).normalize().multiplyScalar(.2*o),0==parseInt(1e4*c.length())&&(i=new THREE.Vector3(.5,.3,.2),c.cross(i).normalize().multiplyScalar(.2*o))}e.color===t.color?r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),t.coord.clone().add(c),a,e.color,n),r.cylinderCls.createCylinder(e.coord.clone().sub(c),t.coord.clone().sub(c),a,e.color,n)):r.bImpo?r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),t.coord.clone().add(c),a,e.color,n,t.color),r.cylinderCls.createCylinder(e.coord.clone().sub(c),t.coord.clone().sub(c),a,e.color,n,t.color)):r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),i.clone().add(c),a,e.color,n),r.cylinderCls.createCylinder(t.coord.clone().add(c),i.clone().add(c),a,t.color,n),r.cylinderCls.createCylinder(e.coord.clone().sub(c),i.clone().sub(c),a,e.color,n),r.cylinderCls.createCylinder(t.coord.clone().sub(c),i.clone().sub(c),a,t.color,n))}else if(r.aromaticbonds.hasOwnProperty(l)){let s,l,d;if(e.bonds.length>t.bonds.length&&e.bonds.length>1)s=e.serial,l=e.bonds[0],d=e.bonds[1];else{if(!(t.bonds.length>1))return;s=t.serial,l=t.bonds[0],d=t.bonds[1]}let c=r.atoms[s].coord.clone();c.sub(r.atoms[l].coord);let h=r.atoms[s].coord.clone();h.sub(r.atoms[d].coord),c.cross(h);let p=t.coord.clone();p.sub(e.coord),p.cross(c).normalize().multiplyScalar(.2*o);let m=0;for(let s=0,i=e.bondOrder.length;so+1?(s=k.clone(),i=d.atoms[G[G.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random()))):d.bCalphaOnly&&"CA"===b.name&&(G.length>o+1?(s=k.clone(),i=d.atoms[G[G.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(f),null!==I&&s.dot(I)<0&&s.negate(),I=s;for(let e=0,s=2/(t-1);e6||c&&Math.abs(S.y-c.y)>6||c&&Math.abs(S.z-c.z)>6;if((u!==b.chain||b.ssbegin||b.ssend||B===j-1||p)&&m[0].length>0){let c="CA",u=[],g=[];if(isNaN(d.atoms[M].resi))u=[];else{let e=d.atoms[M].structure+"_"+d.atoms[M].chain+"_"+(parseInt(d.atoms[M].resi)-1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);u=void 0!==t?[t]:[]}if(!isNaN(d.atoms[M].resi)){let e=d.atoms[M].structure+"_"+d.atoms[M].chain+"_"+(parseInt(d.atoms[M].resi)+1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);void 0!==t&&g.push(t);let s=d.atoms[M].structure+"_"+d.atoms[M].chain+"_"+(parseInt(d.atoms[M].resi)+2).toString(),i=d.firstAtomObjCls.getAtomCoordFromResi(s,c);void 0!==i&&g.push(i)}if(!p){1===a||2===a?w.push(d.hColor):w.push(R),f=b.ssend&&"sheet"===b.ss?0:"coil"===T&&b.ssbegin||E&&b.ssbegin||"coil"===b.ss?n:l;let s,i,o=4;"O"===b.name?(s=A.clone(),s.sub(S)):d.bCalphaOnly&&"CA"===b.name&&(G.length>o?(s=S.clone(),i=d.atoms[G[G.length-1-o]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(f),null!==I&&s.dot(I)<0&&s.negate(),I=s;for(let e=0,s=2/(t-1);e0){let e="CA",n=[],l=[];if(isNaN(d.atoms[M].resi))n=[];else{let t=d.atoms[M].structure+"_"+d.atoms[M].chain+"_"+(parseInt(d.atoms[M].resi)-1).toString();d.firstAtomObjCls.getAtomCoordFromResi(t,e)}for(let e=0;!i&&e0;--e){let t=a.structure+"_"+a.chain+"_"+e;if(!c.residues.hasOwnProperty(t))break;let s=c.firstAtomObjCls.getFirstCalphaAtomObj(c.residues[t]);if(s.ss===a.ss&&s.ssbegin){g=s.resi;break}}for(let e=g;e0&&(o!==c.chain||Math.abs(c.coord.x-h.coord.x)>6||Math.abs(c.coord.y-h.coord.y)>6||Math.abs(c.coord.z-h.coord.z)>6||r.ParserUtilsCls.getResiNCBI(c.structure+"_"+o,a)+13||Math.abs(c.coord.y-h.coord.y)>3||Math.abs(c.coord.z-h.coord.z)>3))){if(2!==i){if(!isNaN(d.resi)&&!isNaN(h.resi)){let e=d.structure+"_"+d.chain+"_"+(parseInt(d.resi)-1).toString(),i=r.firstAtomObjCls.getAtomCoordFromResi(e,t);g=void 0!==i?[i]:[];let l=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+1).toString(),o=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+2).toString(),a=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+3).toString();if(r.residues.hasOwnProperty(l)){let e=r.firstAtomObjCls.getAtomFromResi(l,t);void 0!==e&&e.ssbegin&&(l=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+2).toString(),o=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+3).toString(),p.push(e.coord),n?u.push(this.getCustomtubesize(l)):u.push(this.getRadius(s,e)),m.push(e.color))}if(1==p.length&&r.residues.hasOwnProperty(l)){let e=r.firstAtomObjCls.getAtomFromResi(l,t);if(e){p.push(e.coord),m.push(e.color);let t=this.getRadius(s,c);u.push(t),l=o,o=a}}let b=r.firstAtomObjCls.getAtomCoordFromResi(l,t);void 0!==b&&f.push(b);let C=r.firstAtomObjCls.getAtomCoordFromResi(o,t);void 0!==C&&f.push(C)}C.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}p=[],m=[],u=[],g=[],f=[],d=c,b=0}if(0==p.length&&!isNaN(c.resi)){let e=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)-1).toString();r.residues.hasOwnProperty(e)&&(h=r.firstAtomObjCls.getAtomFromResi(e,t),void 0!==h&&h.ssend&&(p.push(h.coord),n?u.push(this.getCustomtubesize(e)):u.push(this.getRadius(s,h)),m.push(h.color)))}let e;p.push(c.coord),e=n?this.getCustomtubesize(c.structure+"_"+c.chain+"_"+c.resi):this.getRadius(s,c),u.push(e),m.push(c.color),1===b&&(m[m.length-2]=c.color),o=c.chain,a=c.resi;let l=1.2;2!==i||c.ssbegin||r.boxCls.createBox(c,void 0,void 0,l,void 0,i),++b,h=c}if(2!==i){if(g=[],void 0!==d&&!isNaN(d.resi)){let e=d.structure+"_"+d.chain+"_"+(parseInt(d.resi)-1).toString(),s=r.firstAtomObjCls.getAtomCoordFromResi(e,t);g=void 0!==s?[s]:[]}if(f=[],void 0!==c&&!isNaN(c.resi)){let e=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+1).toString(),i=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+2).toString(),n=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+3).toString();if(1==p.length&&r.residues.hasOwnProperty(e)){let l=r.firstAtomObjCls.getAtomFromResi(e,t);if(l){p.push(l.coord),m.push(l.color);let t=this.getRadius(s,c);u.push(t),e=i,i=n}}let l=r.firstAtomObjCls.getAtomCoordFromResi(e,t);void 0!==l&&f.push(l);let o=r.firstAtomObjCls.getAtomCoordFromResi(i,t);void 0!==o&&f.push(o)}C.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}for(let e=0,t=C.length;e1?a.parasCls.thr(t[t.length-2]):a.parasCls.thr(t[e]),f[y++]=d.r,f[y++]=d.g,f[y++]=d.b}}let x,k=0;for(let e=0,t=w.length-1;er&&(l=r,e=1);for(let t=0;t0&&t.b<=100?.01*t.b:t.b>100?1:s.coilWidth),i}}class ze{constructor(e){this.icn3d=e}drawCartoonNucleicAcid(e,t,s,i){this.drawStrandNucleicAcid(e,2,t,!0,void 0,s,i)}drawStrandNucleicAcid(e,t,s,i,n,l,r){let o,a,d,c=this.icn3d;if(c.icn3dui.bNode)return;2===r&&(t=void 0,l=void 0),n=n||c.nucleicAcidWidth,s=s||c.axisDIV,t=t||c.nucleicAcidStrandDIV;let h=[];for(d=0;dy?y=C:C=y);let v=.8*b/y;if(g.width=C,g.height=y,f.clearRect(0,0,C,y),h)if(f.fillStyle="rgba("+n.r+","+n.g+","+n.b+","+n.a+")",f.strokeStyle="rgba("+l.r+","+l.g+","+l.b+","+l.a+")",f.lineWidth=r,p){let e=.4*C;this.circle(f,0,0,C,y,e)}else{let e=0;this.roundRect(f,0,0,C,y,e)}f.font="Bold "+a+"px "+o,f.textAlign="center",f.textBaseline="middle",f.fillStyle="rgba("+u.r+", "+u.g+", "+u.b+", 1.0)",f.strokeStyle="rgba("+u.r+", "+u.g+", "+u.b+", 1.0)",f.fillText(e,.5*C,.5*y);let _=new THREE.Texture(g);_.needsUpdate=!0;let w=new THREE.SpriteMaterial({map:_,depthTest:!1,depthWrite:!1});w.map.minFilter=THREE.LinearFilter;let S=new THREE.Sprite(w);return p?S.scale.set(.3*d,.3*d,1):S.scale.set(v*d,d,1),S.renderOrder=1,S}roundRect(e,t,s,i,n,l){e.beginPath(),e.moveTo(t+l,s),e.lineTo(t+i-l,s),e.quadraticCurveTo(t+i,s,t+i,s+l),e.lineTo(t+i,s+n-l),e.quadraticCurveTo(t+i,s+n,t+i-l,s+n),e.lineTo(t+l,s+n),e.quadraticCurveTo(t,s+n,t,s+n-l),e.lineTo(t,s+l),e.quadraticCurveTo(t,s,t+l,s),e.closePath(),e.fill(),e.stroke()}circle(e,t,s,i,n,l){e.beginPath(),e.arc(t+i/2,.9*(s+n/2),l,0,2*Math.PI,!0),e.closePath(),e.fill(),e.stroke()}}class Ve{constructor(e){this.icn3d=e,this.textSpriteCls=new Ge(e)}createLabelRepresentation(e){let t=this.icn3d;t.icn3dui;let s=t.oriMaxD/100;s<.4&&(s=.4);let i=3*s*t.labelScale;for(let s in e){let n=void 0!==e[s]?e[s]:[],l="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd;for(let e=0,r=n.length;e.99999)h.set(0,0,0,1);else if(e.y<-.99999)h.set(1,0,0,0);else{let t=new THREE.Vector3;t.set(e.z,0,-e.x).normalize();let s=Math.acos(e.y);h.setFromAxisAngle(t,s)}return c.applyQuaternion(h),c.scale.set(l,n,l),c.position.copy(t),c}setPc1Axes(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s=t.hashUtilsCls.intHash(e.hAtoms,e.dAtoms),i=[],n=Object.keys(s).length<100;for(let t in s){let s=e.atoms[t],l=s.structure+"_"+s.chain+"_"+s.resi;(n||""!=l)&&i.push(s.coord.clone())}let l=t.rmsdSuprCls.getEigenForSelection(i,i.length),r=new THREE.Vector3(l.h1[0],l.h1[1],l.h1[2]);if(0==l.k&&e.bRender)return void alert("Can't determine the first principal component. Please select a subset and try it again.");let o=e.applyCenterCls.centerAtoms(s),a=o.maxD,d=o.center,c=d.clone().add(r.normalize().multiplyScalar(.4*a)),h=new THREE.Vector3(l.h2[0],l.h2[1],l.h2[2]),p=d.clone().add(h.normalize().multiplyScalar(.3*a)),m=new THREE.Vector3(l.h3[0],l.h3[1],l.h3[2]),u=d.clone().add(m.normalize().multiplyScalar(.3*a));this.buildAxes(void 0,d,c,p,u,!0);let g=[d,c,p,u];return e.axes.push(g),e.drawCls.draw(),g}}class Ye{constructor(e){this.icn3d=e}showGlycans(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s={},i=e.dAtoms;for(let n in i){let i=e.atoms[n];i.het&&-1!=t.parasCls.glycanHash.hasOwnProperty(i.resn)&&(void 0===s[i.resn]&&(s[i.resn]={}),"Misc"!=i.chain&&(s[i.resn][i.structure+"_"+i.chain+"_"+i.resi]=1))}let n=Object.keys(s);for(let i=0,l=n.length;i>2))+i+((2&t)>>1))*c+n+(1&t)]&this.ISDONE)<=3&&(t.push(t[i]),i=t.length-1,t.push(t[n]),n=t.length-1,t.push(t[l]),l=t.length-1),s.push(i),s.push(n),s.push(l)}}},Xe.prototype.laplacianSmooth=function(e,t,s){let i,n,l,r,o,a=new Array(t.length);for(i=0,n=t.length;ithis.origextent[1][0])&&(!(tthis.origextent[1][1])&&!(sthis.origextent[1][2]))},Ke.prototype.getFacesAndVertices=function(){let e,t,s=this.verts;for(e=0,t=s.length;eh&&(h=this.pmaxy-this.pminy),this.pmaxz-this.pminz>h&&(h=this.pmaxz-this.pminz),this.scaleFactor=(c-1)/h,this.scaleFactor=this.defaultScaleFactor,this.defaultScaleFactor*h>this.threshbox&&(c=Math.floor(this.threshbox),this.scaleFactor=(this.threshbox-1)/h),this.bCalcArea&&(this.scaleFactor=this.defaultScaleFactor),this.pLength=Math.ceil(this.scaleFactor*(this.pmaxx-this.pminx))+1,this.pWidth=Math.ceil(this.scaleFactor*(this.pmaxy-this.pminy))+1,this.pHeight=Math.ceil(this.scaleFactor*(this.pmaxz-this.pminz))+1,this.boundingatom(t),this.cutRadius=this.probeRadius*this.scaleFactor,this.vpBits=new Uint8Array(this.pLength*this.pWidth*this.pHeight),this.vpDistance=new Float64Array(this.pLength*this.pWidth*this.pHeight),this.vpAtomID=new Int32Array(this.pLength*this.pWidth*this.pHeight),this.vpColor=[],this.vpPot=[]},Ke.prototype.boundingatom=function(e){let t,s,i,n,l=[];for(let r in this.vdwRadii){if(!this.vdwRadii.hasOwnProperty(r))continue;let o=this.vdwRadii[r];l[r]=e?(o+this.probeRadius)*this.scaleFactor+.5:o*this.scaleFactor+.5,i=l[r]*l[r],this.widxz[r]=Math.floor(l[r])+1,this.depty[r]=new Int32Array(this.widxz[r]*this.widxz[r]),n=0;for(let e=0;ei?this.depty[r][n]=-1:(s=Math.sqrt(i-t),this.depty[r][n]=Math.floor(s)),n++}},Ke.prototype.fillvoxels=function(e,t){let s,i,n,l;for(s=0,l=this.vpBits.length;sc&&(a=c),C>h&&(C=h),v>p&&(v=p);let _,w=g[o*m+d*u+y],S=g[a*m+d*u+y],A=g[o*m+C*u+y],x=g[o*m+d*u+v],k=g[a*m+C*u+y],O=g[o*m+C*u+v],R=g[a*m+d*u+v],I=g[a*m+C*u+v],T=r.x-o,E=r.y-d,P=r.z-y,M=((w*(1-T)+S*T)*(1-E)+(A*(1-T)+k*T)*E)*(1-P)+((x*(1-T)+R*T)*(1-E)+(O*(1-T)+I*T)*E)*P,D=s*f+i*b+n;this.vpPot[D]=M,M>this.isovalue&&(M=this.isovalue),M<-this.isovalue&&(M=-this.isovalue),M>0?(M/=1*this.isovalue,_=new THREE.Color(1-M,1-M,1)):(M/=-1*this.isovalue,_=new THREE.Color(1,1-M,1-M)),this.vpColor[D]=_}}for(s=0,l=this.vpBits.length;s=this.pLength||g>=this.pWidth||f>=this.pHeight)continue;let h=u*S+g*this.pHeight+f;if(this.vpBits[h]&this.INOUT){let p=t[this.vpAtomID[h]];p.serial!=e.serial&&(l=s+a-Math.floor(.5+this.scaleFactor*(p.x+this.ptranx)),r=i+d-Math.floor(.5+this.scaleFactor*(p.y+this.ptrany)),o=n+c-Math.floor(.5+this.scaleFactor*(p.z+this.ptranz)),a*a+d*d+c*c=this.pLength||p>=this.pWidth||m>=this.pHeight)continue;let u=h*S+p*this.pHeight+m;if(this.vpBits[u]&this.ISDONE){let h=t[this.vpAtomID[u]];h.serial!=e.serial&&(l=s+a-Math.floor(.5+this.scaleFactor*(h.x+this.ptranx)),r=i+d-Math.floor(.5+this.scaleFactor*(h.y+this.ptrany)),o=n+c-Math.floor(.5+this.scaleFactor*(h.z+this.ptranz)),a*a+d*d+c*c-1&&r-1&&a-1&&o=h)||(this.vpBits[n]|=this.ISBOUND))},Ke.prototype.fastoneshell=function(e,t){let s,i,n,l,r,o,a,d,c,h,p,m,u=[];if(0===e.length)return u;let g={ix:-1,iy:-1,iz:-1},f=this.pWidth*this.pHeight;for(a=0,c=e.length;a-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,h-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,h-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,hm&&(m=this.pmaxy-this.pminy),this.pmaxz-this.pminz>m&&(m=this.pmaxz-this.pminz),this.scaleFactor=1,this.pLength=Math.floor(.5+this.scaleFactor*(this.pmaxx-this.pminx))+1,this.pWidth=Math.floor(.5+this.scaleFactor*(this.pmaxy-this.pminy))+1,this.pHeight=Math.floor(.5+this.scaleFactor*(this.pmaxz-this.pminz))+1,this.cutRadius=this.probeRadius*this.scaleFactor,this.vpBits=new Uint8Array(this.pLength*this.pWidth*this.pHeight),this.vpAtomID=new Uint8Array(this.pLength*this.pWidth*this.pHeight)},Je.prototype.transformMemPro=function(e,t,s,i){let n=e.clone();n.sub(s);let l=n.x*t[0]+n.y*t[1]+n.z*t[2]+i.x,r=n.x*t[3]+n.y*t[4]+n.z*t[5]+i.y,o=n.x*t[6]+n.y*t[7]+n.z*t[8]+i.z;return n.x=l,n.y=r,n.z=o,n},Je.prototype.fillvoxels=function(e,t){let s,i,n,l,r,o;for(s=0,l=this.vpBits.length;sthis.pLength&&(o=this.pLength),p>this.pWidth&&(p=this.pWidth),b>this.pHeight&&(b=this.pHeight);let C,y=l[r*a+h*d+f],v=l[o*a+h*d+f],_=l[r*a+p*d+f],w=l[r*a+h*d+b],S=l[o*a+p*d+f],A=l[r*a+p*d+b],x=l[o*a+h*d+b],k=l[o*a+p*d+b],O=n.x-r,R=n.y-h,I=n.z-f,T=((y*(1-O)+v*O)*(1-R)+(_*(1-O)+S*O)*R)*(1-I)+((w*(1-O)+x*O)*(1-R)+(A*(1-O)+k*O)*R)*I;T>this.isovalue&&(T=this.isovalue),T<-this.isovalue&&(T=-this.isovalue),T>0?(T/=1*this.isovalue,C=new THREE.Color(1-T,1-T,1)):(T/=-1*this.isovalue,C=new THREE.Color(1,1-T,1-T)),this.icn3d.atoms[t[s]].color=C,this.icn3d.atomPrevColors[t[s]]=C}}else{for(let p in t){let f,b=e[t[p]];if("DUM"!==b.resn){if(void 0!==this.rmsd_supr&&void 0!==this.rmsd_supr.rot){f=this.transformMemPro(b.coord,g,u,m).applyMatrix4(c)}else f=b.coord.clone().applyMatrix4(c);for(s=Math.floor(f.x)-this.maxdist,l=Math.ceil(f.x)+this.maxdist;s<=l;++s)if(!(s<0||s>this.header.xExtent*this.scaleFactor-1))for(i=Math.floor(f.y)-this.maxdist,r=Math.ceil(f.y)+this.maxdist;i<=r;++i)if(!(i<0||i>this.header.yExtent*this.scaleFactor-1))for(n=Math.floor(f.z)-this.maxdist,o=Math.ceil(f.z)+this.maxdist;n<=o;++n){if(n<0||n>this.header.zExtent*this.scaleFactor-1)continue;let e=s*a+i*d+n;h.push(e)}}}for(s=0,l=h.length;s=this.isovalue?1:0:"fofc"==this.type?(this.vpBits[e]=this.dataArray[e]>=this.isovalue||this.dataArray[e]<=-this.isovalue?1:0,this.vpAtomID[e]=this.dataArray[e]>=0?1:0):"em"==this.type&&(this.vpBits[e]=this.dataArray[e]>=this.isovalue?1:0)}}}else for(s=0;s=this.isovalue||this.dataArray[e]<=-this.isovalue?1:0,this.vpAtomID[t]=this.dataArray[e]>=0?1:0)}for(s=0,l=this.vpBits.length;s-1&&r-1&&a-1&&o1?"Structure":"",a=Object.keys(i).length>1?"Chain":"";n+=""+o+a+"ResidueNumberSASA (Å2)Percent OutIn/Out";for(let e in l.resid2area){let d=e.lastIndexOf("_"),c=e.substr(d+1),h=r.utilsCls.getIdArray(e.substr(0,d));o=Object.keys(s).length>1?""+h[0]+"":"",a=Object.keys(i).length>1?""+h[1]+"":"";let p="",m="";l.resid2area[e]=(l.resid2area[e]/t).toFixed(2),r.parasCls.residueArea.hasOwnProperty(c)&&(m=parseInt(l.resid2area[e]/r.parasCls.residueArea[c]*100),m>100&&(m=100),m>=50&&(p="out"),m<20&&(p="in")),n+=''+o+a+""+c+''+h[2]+''+l.resid2area[e]+''+m+"%"+p+""}return n+="",void(l.areahtml=n)}let p,m,u,g=c.vertices,f=c.faces,b=r.parasCls.thr("#00FFFF"),C=r.parasCls.thr("#00FF00"),y=r.parasCls.thr("#ff0000"),v=r.parasCls.thr("#00FFFF"),_=r.parasCls.thr("#0000FF"),w=r.parasCls.thr("#FF0000");11!=t&&12!=t&&13!=t&&14!=t||void 0===l.rmsd_supr||void 0===l.rmsd_supr.rot||(p=l.rmsd_supr.rot,m=l.rmsd_supr.trans1,u=l.rmsd_supr.trans2);let S=(11==t||12==t||13==t||14==t&&"delphi"!=l.loadPhiFrom)&&void 0!==l.rmsd_supr&&void 0!==l.rmsd_supr.rot;n=new THREE.BufferGeometry;let A,x=[],k=[],O=[],R=0;for(let e=0,s=g.length;e0?-parseInt(C.z):parseInt(C.z),y.onBeforeRender=function(e,t,s,i,n,o){let a,d=new THREE.Vector3(0,0,0),c=i.getAttribute("position").array;for(let e=0,t=c.length;e0?-parseInt(a.z):parseInt(a.z)},l.mdl.add(y),11==t||12==t?l.prevMaps.push(y):13==t?l.prevEmmaps.push(y):14==t?l.prevPhimaps.push(y):l.prevSurfaces.push(y)}}else{let e=new THREE.Mesh(n,new THREE.MeshPhongMaterial({specular:l.frac,shininess:20,emissive:l.emissive,vertexColors:!0,wireframe:s,opacity:i,transparent:!0,depthWrite:10==parseInt(10*i),side:THREE.DoubleSide}));e.renderOrder=-2,l.mdl.add(e),11==t||12==t?l.prevMaps.push(e):13==t?l.prevEmmaps.push(e):14==t?l.prevPhimaps.push(e):l.prevSurfaces.push(e)}c=null,g=null,f=null,n=null}transformMemPro(e,t,s,i,n){this.icn3d.icn3dui;let l=e.clone();l.sub(s),n&&console.log("sub coord: "+JSON.stringify(l));let r=l.x*t[0]+l.y*t[1]+l.z*t[2]+i.x,o=l.x*t[3]+l.y*t[4]+l.z*t[5]+i.y,a=l.x*t[6]+l.y*t[7]+l.z*t[8]+i.z;return l.x=r,l.y=o,l.z=a,n&&console.log("out coord: "+JSON.stringify(l)),l}SetupSurface(e){let t=this.icn3d;t.icn3dui;let s=e.threshbox,i=new Ke(t,s);i.initparm(e.extent,1!==e.type,e.bCalcArea,e.atomsToShow,e.header,e.data,e.matrix,e.isovalue,e.loadPhiFrom),i.fillvoxels(e.allatoms,e.extendedAtoms),i.buildboundary(),2===e.type&&(i.fastdistancemap(),i.boundingatom(!1),i.fillvoxelswaals(e.allatoms,e.extendedAtoms));let n=i.marchingcube();i.vpBits=null,i.vpDistance=null,i.vpAtomID=null;let l=i.getFacesAndVertices(e.atomsToShow);return l.area=n.area,l.serial2area=n.serial2area,l.scaleFactor=n.scaleFactor,i.faces=null,i.verts=null,l}SetupMap(e){let t=this.icn3d;t.icn3dui;let s,i=new Je(t);return i.initparm(e.header,e.data,e.matrix,e.isovalue,e.center,e.maxdist,e.pmin,e.pmax,e.water,e.type,e.rmsd_supr,e.loadPhiFrom,e.icn3d),i.fillvoxels(e.allatoms,e.extendedAtoms),e.header.bSurface||i.buildboundary(),e.header.bSurface||i.marchingcube(),i.vpBits=null,i.vpAtomID=null,e.header.bSurface||(s=i.getFacesAndVertices(e.allatoms,e.atomsToShow)),i.faces=null,i.verts=null,s}}class Ze{constructor(e){this.icn3d=e}applyCenterOptions(e){let t,s=this.icn3d;switch(s.icn3dui,void 0===e&&(e=s.opts),e.rotationcenter.toLowerCase()){case"molecule center":void 0!==s.center&&this.setRotationCenter(s.center);break;case"pick center":void 0!==s.pAtom&&this.setRotationCenter(s.pAtom.coord);break;case"display center":t=this.centerAtoms(s.dAtoms).center,this.setRotationCenter(t);break;case"highlight center":t=this.centerAtoms(s.hAtoms).center,this.setRotationCenter(t)}}setRotationCenter(e){this.icn3d.icn3dui,this.setCenter(e)}setCenter(e){let t=this.icn3d;t.icn3dui,t.mdl.position.set(0,0,0),t.mdlImpostor.position.set(0,0,0),t.mdl_ghost.position.set(0,0,0),t.mdl.position.sub(e),t.mdlImpostor.position.sub(e),t.mdl_ghost.position.sub(e)}centerSelection(e,t){let s=this.icn3d,i=s.icn3dui;if(s.opts.rotationcenter="highlight center",void 0===e&&(e=i.hashUtilsCls.hash2Atoms(s.hAtoms,s.atoms)),t||(s._zoomFactor=1,s.mouseChange=new THREE.Vector2(0,0),s.quaternion=new THREE.Quaternion(0,0,0,1)),Object.keys(e).length>1){let t=this.centerAtoms(e);s.center=t.center,this.setCenter(s.center),s.cameraCls.setCamera()}}centerAtoms(e){let t=this.icn3d;t.icn3dui;let s=new THREE.Vector3(9999,9999,9999),i=new THREE.Vector3(-9999,-9999,-9999),n=new THREE.Vector3;for(let l in e){let e=t.atoms[l].coord;n.add(e),s.min(e),i.max(e)}let l=t.ParserUtilsCls.getGeoCenter(s,i);return{center:l,maxD:t.ParserUtilsCls.getStructureSize(e,s,i,l),pmin:s,pmax:i}}setWidthHeight(e,t){let s=this.icn3d;s.icn3dui,void 0===s.scaleFactor&&(s.scaleFactor=1),s.renderer.setSize(e*s.scaleFactor,t*s.scaleFactor),s.renderer.domElement.style.width=e*s.scaleFactor+"px",s.renderer.domElement.style.height=t*s.scaleFactor+"px",s.renderer.domElement.width=e*s.scaleFactor,s.renderer.domElement.height=t*s.scaleFactor,s.container.whratio=e/t}}class et{constructor(e){this.icn3d=e}applyClbondsOptions(e){let t=this.icn3d,s=t.icn3dui;if(void 0===e&&(e=t.opts),t.bCalcCrossLink||(t.clbondpnts={},t.clbondResid2serial={},this.applyClbondsOptions_base("chemical"),this.applyClbondsOptions_base("all"),t.bCalcCrossLink=!0),"yes"===e.clbonds.toLowerCase()&&"nothing"!==e.chemicals){let e="#006400";if(s.parasCls.thr(25600),t.lines.clbond=[],t.residuesHashClbonds={},t.structures){let i=Object.keys(t.structures);for(let n=0,l=i.length;n1&&"sphere"!==a[Object.keys(a)[0]].style&&"dot"!==a[Object.keys(a)[0]].style){if(void 0===i.bCid||!i.bCid)for(let e in a){let t=a[e],n=1;i.boxCls.createBox(t,void 0,void 0,n,void 0,s)}}else for(let e in o){let l=i.firstAtomObjCls.getFirstCalphaAtomObj(i.residues[e]),r=l,o=r.structure+"_"+r.chain+"_"+(parseInt(r.resi)-1).toString(),a=r.structure+"_"+r.chain+"_"+(parseInt(r.resi)+1).toString();if("cylinder and plate"===r.style&&"helix"===r.ss)for(let t in i.residues[e]){let e=i.atoms[t],n=1;i.boxCls.createBox(e,void 0,void 0,n,void 0,s)}else if("ribbon"===r.style&&"coil"===r.ss||"strand"===r.style&&"coil"===r.ss||"o3 trace"===r.style||"schematic"===r.style||"c alpha trace"===r.style||"b factor tube"===r.style||"cylinder and plate"===r.style&&"helix"!==r.ss){if(void 0!==l&&void 0!==l.style2&&"nothing"!==l.style2)continue;let e=!1;if(!isNaN(r.resi)&&!e&&i.residues.hasOwnProperty(a)){let s=Object.keys(i.residues[a])[0],l=n.hashUtilsCls.hash2Atoms(i.residues[a],i.atoms)[s];if(r.style===l.style&&!l.ssbegin||l.ssbegin){let s=i.residues[a];if(t=n.hashUtilsCls.unionHash(t,s),e=!0,l.ssbegin)for(let e in s)i.atoms[e].notshow=!0}}if(!isNaN(r.resi)&&!e&&i.residues.hasOwnProperty(o)){let s=Object.keys(i.residues[o])[0],l=n.hashUtilsCls.hash2Atoms(i.residues[o],i.atoms)[s];r.style===l.style&&(t=n.hashUtilsCls.unionHash(t,i.residues[o]),e=!0)}}else if("ribbon"===r.style&&"coil"!==r.ss&&r.ssend||"strand"===r.style&&"coil"!==r.ss&&r.ssend){if(void 0!==l&&void 0!==l.style2&&"nothing"!==l.style2)continue;let e=!1;if(!isNaN(r.resi)&&!e&&i.residues.hasOwnProperty(a)){let s=Object.keys(i.residues[a])[0];n.hashUtilsCls.hash2Atoms(i.residues[a],i.atoms)[s],t=n.hashUtilsCls.unionHash(t,i.residues[a]),e=!0}}}a={}}if(i.bInitial){if(""!=n.htmlCls.setHtmlCls.getCookie("membrane")){let e=parseInt(n.htmlCls.setHtmlCls.getCookie("membrane"));i.bMembrane!=e&&n.htmlCls.clickMenuCls.setLogCmd("set membrane "+e,!0),i.bMembrane=isNaN(e)?0:parseInt(e)}i.bMembrane?i.selectionCls.toggleMembrane(!0):i.selectionCls.toggleMembrane(!1)}i.setStyleCls.setStyle2Atoms(t);let d=.5*i.cylinderRadius;void 0!==i.labels&&delete i.labels.schematic;for(let e in i.style2atoms){let t=i.style2atoms[e],l=n.hashUtilsCls.intHash(t,i.nucleotides),r=n.utilsCls.isCalphaPhosOnly(n.hashUtilsCls.hash2Atoms(l,i.atoms));if("ribbon"===e)i.strandCls.createStrand(n.hashUtilsCls.hash2Atoms(t,i.atoms),2,void 0,!0,void 0,void 0,!1,i.ribbonthickness,s);else if("strand"===e)i.strandCls.createStrand(n.hashUtilsCls.hash2Atoms(t,i.atoms),null,null,null,null,null,!1,void 0,s);else if("cylinder and plate"===e)i.cylinderCls.createCylinderHelix(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderHelixRadius,s);else if("nucleotide cartoon"===e)r?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["P"],i.traceRadius,!1,s):(i.cartoonNuclCls.drawCartoonNucleicAcid(n.hashUtilsCls.hash2Atoms(t,i.atoms),null,i.ribbonthickness,s),2!==s&&i.cartoonNuclCls.drawNucleicAcidStick(n.hashUtilsCls.hash2Atoms(t,i.atoms),s));else if("o3 trace"===e)r?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["P"],i.traceRadius,!1,s):i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["O3'","O3*"],i.traceRadius,!1,s);else if("schematic"===e){let e=i.firstAtomObjCls.getFirstAtomObj(t);if(i.chemicals.hasOwnProperty(e.serial)){i.residueLabelsCls.addNonCarbonAtomLabels(n.hashUtilsCls.hash2Atoms(t,i.atoms));let e=!0;i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),d,d,void 0,s,e)}else i.residueLabelsCls.addResidueLabels(n.hashUtilsCls.hash2Atoms(t,i.atoms),!0),r?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["P"],i.traceRadius,!1,s):i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["O3'","O3*"],i.traceRadius,!1,s),i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["CA"],i.traceRadius,!1,s)}else"c alpha trace"===e?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["CA"],i.traceRadius,!1,s):"b factor tube"===e?i.tubeCls.createTube(n.hashUtilsCls.hash2Atoms(t,i.atoms),"CA",null,s,!1,!0):"custom tube"===e?i.tubeCls.createTube(n.hashUtilsCls.hash2Atoms(t,i.atoms),"CA",null,s,!0,!0):"lines"===e||"lines2"===e?(1===s?i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.hlLineRadius,i.hlLineRadius,void 0,s):i.lineCls.createLineRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),s),i.lineCls.createConnCalphSidechain(n.hashUtilsCls.hash2Atoms(t,i.atoms),e)):"stick"===e||"stick2"===e?(i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderRadius,i.cylinderRadius,void 0,s,void 0),i.lineCls.createConnCalphSidechain(n.hashUtilsCls.hash2Atoms(t,i.atoms),e)):"backbone"===e?(t=this.selectMainChainSubset(t),i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderRadius,i.cylinderRadius,void 0,s,void 0)):"ball and stick"===e||"ball and stick2"===e?(i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderRadius,.5*i.cylinderRadius,i.dotSphereScale,s,void 0),i.lineCls.createConnCalphSidechain(n.hashUtilsCls.hash2Atoms(t,i.atoms),e)):"sphere"===e||"sphere2"===e?i.sphereCls.createSphereRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.sphereRadius,void 0,void 0,s):"dot"===e&&i.sphereCls.createSphereRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.sphereRadius,!1,i.dotSphereScale,s)}if(i.cnt>i.maxmaxatomcnt&&i.init_base(),void 0!==i.labels&&Object.keys(i.labels).length>0){i.labelCls.hideLabels();for(let e in i.labels)"schematic"!=e&&this.changeLabelColor(i.labels[e]);i.labelCls.createLabelRepresentation(i.labels)}}changeLabelColor(e){let t=this.icn3d;if(t.icn3dui,e)for(let s=0,i=e.length;s0){this.updateStabilizer();let e="#FFFFFF",s=t.stabilizerpnts;t.lines.stabilizer=[];for(let i=0,n=Math.floor(s.length/2);i0)for(let e=0,s=t.distPnts.length;e0&&t.applySymdCls.applySymd(),void 0!==t.prevOtherMesh)for(let e=0,s=t.prevOtherMesh.length;e0&&(e=s.hashUtilsCls.hash2Atoms(t.chemicals,t.atoms));let i=4;if(void 0!==e){let n=t.contactCls.getAtomsWithinAtom(t.atoms,e,i),l=3.5;t.opts.hbonds="yes",Object.keys(n).length>0&&t.hBondCls.calculateChemicalHbonds(e,n,parseFloat(l)),t.bSetFog||t.transformCls.zoominSelection(s.hashUtilsCls.unionHash(e,n))}}else"hide"===e.chemicalbinding&&(t.hBondCls.hideHbonds(),t.showInterCls.hideExtraBonds(),t.bSetFog||t.transformCls.zoominSelection(t.atoms))}updateStabilizer(){let e=this.icn3d;if(e.icn3dui,e.stabilizerpnts=[],void 0!==e.pairArray)for(let t=0,s=e.pairArray.length;t=0;i--){let r=t.ssbondpnts[e][2*i],o=t.ssbondpnts[e][2*i+1],a={};a.color=n,a.dashed=!1;let d=[],c=[],h=[],p=[],m=!1,u=!1;for(let e in t.residues[r])"SG"===t.atoms[e].name&&(h.push(t.atoms[e].coord),d.push(t.atoms[e].serial),m=!0);if(!m)for(let e in t.residues[r])if("CA"===t.atoms[e].name){h.push(t.atoms[e].coord),d.push(t.atoms[e].serial),m=!0,u=!0;break}m=!1;for(let e in t.residues[o])"SG"===t.atoms[e].name&&(p.push(t.atoms[e].coord),c.push(t.atoms[e].serial),m=!0);if(!m)for(let e in t.residues[o])if("CA"===t.atoms[e].name){p.push(t.atoms[e].coord),c.push(t.atoms[e].serial),m=!0,u=!0;break}let g=u?7:3,f=!1;for(let e=0,t=h.length;e1&&(l=!0)}if(t)if(l){let t=Object.keys(r)[0];e=i.chains[t]}else{0==Object.keys(i.hAtoms).length&&(i.hAtoms=n.hashUtilsCls.cloneHash(i.dAtoms));let t,s=parseInt(Object.keys(i.hAtoms).length/u),l=0;for(let n in i.hAtoms)if(e[n]=1,t=n,++l,l>s)break;let r=i.atoms[t].structure+"_"+i.atoms[t].chain+"_"+i.atoms[t].resi;e=n.hashUtilsCls.unionHash(e,i.residues[r])}else{let t=Object.keys(i.structures)[0]+"_"+g;if(i.chains.hasOwnProperty(t)||(t=Object.keys(i.structures)[0]+"_"+g.toLowerCase()),!i.chains.hasOwnProperty(t)){t=Object.keys(i.chains)[0];for(let e in i.chains){let s=Object.keys(i.chains[e])[0];if(i.proteins.hasOwnProperty(s)){t=e;break}}}e=i.chains[t]}let a=s.clone().add(h).multiplyScalar(.5),c=new THREE.Vector3,p=0,f=h.clone().sub(s).normalize(),b=new THREE.Vector3(0,0,1),C=new THREE.Quaternion;C.setFromUnitVectors(f,b);let y=-9999;for(let t in e){let e=i.atoms[t].coord.clone();c.add(e),e.sub(a).applyQuaternion(C);let s=e.x*e.x+e.y*e.y;s>y&&(y=s),++p}let v=i.ParserUtilsCls.getMassCenter(c,p),_=new THREE.Line3(s,h),w=new THREE.Vector3;_.closestPointToPoint(v,!0,w);let S,A,x,k,O=Math.sqrt(y),R=v.clone().sub(w).normalize().multiplyScalar(O),I=a.clone().add(s.clone().sub(a).multiplyScalar(.83)).add(R),T=a.clone().add(h.clone().sub(a).multiplyScalar(.83)).add(R),E=2*Math.PI/o;for(let e=0;et&&(i.sphereCls.createSphereBase(r,colorPolygon,d,1,0),i.cylinderCls.createCylinder(e,r,d,colorPolygon,0),i.cylinderCls.createCylinder(s,r,d,colorPolygon,0),void 0!==n&&i.cylinderCls.createCylinder(c[n],r,d,colorPolygon,0),n=l)}}else if("O"==r)for(let e=0,t=c.length;e0&&(e.mdl.remove(e.prevSurfaces[e.prevSurfaces.length-1]),e.prevSurfaces.slice(e.prevSurfaces.length-1,1))}removeMaps(){let e=this.icn3d;e.icn3dui;for(let t=0,s=e.prevMaps.length;t0&&(e.mdl.remove(e.prevMaps[e.prevMaps.length-1]),e.prevMaps.slice(e.prevMaps.length-1,1))}removeLastEmmap(){let e=this.icn3d;e.icn3dui,e.prevEmmaps.length>0&&(e.mdl.remove(e.prevEmmaps[e.prevEmmaps.length-1]),e.prevEmmaps.slice(e.prevEmmaps.length-1,1))}removeLastPhimap(){let e=this.icn3d;e.icn3dui,e.prevPhimaps.length>0&&(e.mdl.remove(e.prevPhimaps[e.prevPhimaps.length-1]),e.prevPhimaps.slice(e.prevPhimaps.length-1,1))}}class ot{constructor(e){this.icn3d=e}addResidueLabels(e,t,s,i,n){let l=this.icn3d,r=l.icn3dui;if(r.bNode)return;let o=r.hashUtilsCls.intHash(l.hAtoms,e);t?void 0===l.labels.schematic&&(l.labels.schematic=[]):void 0===l.labels.residue&&(l.labels.residue=[]);let a="";for(let e in o){let s=l.atoms[e],o={},d=s.structure+"_"+s.chain+"_"+s.resi;if(!s.het&&("CA"===s.name||"O3'"===s.name||"O3*"===s.name)||l.water.hasOwnProperty(s.serial)||l.ions.hasOwnProperty(s.serial)||l.chemicals.hasOwnProperty(s.serial)&&d!==a){if(o.position=s.coord,o.bSchematic=0,t&&(o.bSchematic=1),o.text=r.utilsCls.residueName2Abbr(s.resn),i)o.text+=s.resi;else if(n){let e=s.structure+"_"+s.chain+"_"+s.resi,t="";l.resid2refnum[e]&&(t=" "==l.resid2refnum[e].substr(0,1)?"":l.resid2refnum[e]),o.text=t}o.size=18,o.factor=.3;let e=s.color.getHexString().toUpperCase();o.color=i?"black"!=l.opts.background?l.colorWhitebkgd:l.colorBlackbkgd:n?"#00FFFF":"CCCCCC"===e||"C8C8C8"===e?"#888888":"#"+e,o.background="#FFFFFF",t?l.labels.schematic.push(o):l.labels.residue.push(o)}a=d}l.hlObjectsCls.removeHlObjects()}addNonCarbonAtomLabels(e){let t=this.icn3d,s=t.icn3dui;if(s.bNode)return;let i=s.hashUtilsCls.intHash(t.hAtoms,e);void 0===t.labels.schematic&&(t.labels.schematic=[]);for(let e in i){let s=t.atoms[e];if(!t.residues.hasOwnProperty(s.structure+"_"+s.chain+"_"+s.resi))continue;if("C"===s.elem)continue;let i={};i.position=s.coord,i.bSchematic=1,i.text=s.elem,i.size=18,i.color="black"!=t.opts.background?t.colorWhitebkgd:s.color.getHexString(),i.background="#FFFFFF",t.labels.schematic.push(i)}t.hlObjectsCls.removeHlObjects()}addAtomLabels(e,t){let s=this.icn3d,i=s.icn3dui;if(i.bNode)return;let n=i.hashUtilsCls.intHash(s.hAtoms,e);n=i.hashUtilsCls.intHash(s.dAtoms,n),void 0===s.labels.residue&&(s.labels.residue=[]);for(let e in n){let i=s.atoms[e],n={};n.position=i.coord,n.bSchematic=0,n.text=t?i.elem:i.name.padEnd(2," "),n.size=18,t&&(n.bSchematic=!0);let l=i.color.getHexString().toUpperCase();n.color="black"!=s.opts.background?s.colorWhitebkgd:s.colorBlackbkgd,t&&(n.color="CCCCCC"===l||"C8C8C8"===l?"#888888":"#"+l),n.background="#FFFFFF",s.labels.residue.push(n)}s.hlObjectsCls.removeHlObjects()}}class at{constructor(e){this.icn3d=e}onBeforeRender(e,t,s,i,n,l){let r=n.uniforms,o=[];if(r.objectId&&(r.objectId.value=SupportsReadPixelsFloat?this.id:this.id/255,o.push("objectId")),(r.modelViewMatrixInverse||r.modelViewMatrixInverseTranspose||r.modelViewProjectionMatrix||r.modelViewProjectionMatrixInverse)&&this.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,this.matrixWorld),r.modelViewMatrixInverse&&(r.modelViewMatrixInverse.value.copy(this.modelViewMatrix).invert(),o.push("modelViewMatrixInverse")),r.modelViewMatrixInverseTranspose&&(r.modelViewMatrixInverse?r.modelViewMatrixInverseTranspose.value.copy(r.modelViewMatrixInverse.value).transpose():r.modelViewMatrixInverseTranspose.value.copy(this.modelViewMatrix).invert().transpose(),o.push("modelViewMatrixInverseTranspose")),r.modelViewProjectionMatrix&&(s.updateProjectionMatrix(),r.modelViewProjectionMatrix.value.multiplyMatrices(s.projectionMatrix,this.modelViewMatrix),o.push("modelViewProjectionMatrix")),r.modelViewProjectionMatrixInverse){let e=new THREE.Matrix4;r.modelViewProjectionMatrix?(e.copy(r.modelViewProjectionMatrix.value),r.modelViewProjectionMatrixInverse.value.copy(e).invert()):(s.updateProjectionMatrix(),e.multiplyMatrices(s.projectionMatrix,this.modelViewMatrix),r.modelViewProjectionMatrixInverse.value.copy(e).invert()),o.push("modelViewProjectionMatrixInverse")}if(r.projectionMatrix&&(s.updateProjectionMatrix(),r.projectionMatrix.value.copy(s.projectionMatrix),o.push("projectionMatrix")),r.projectionMatrixInverse&&(s.updateProjectionMatrix(),r.projectionMatrixInverse.value.copy(s.projectionMatrix).invert(),o.push("projectionMatrixInverse")),o.length){let t=e.properties.get(n);if(t.program){let s=e.getContext(),i=t.program;s.useProgram(i.program);let n=i.getUniforms();o.forEach((function(e){n.setValue(s,e,r[e].value)}))}}}setParametersForShader(e){let t,s=this.icn3d,i=s.icn3dui.parasCls.backgroundColors[s.opts.background.toLowerCase()],n=2.5*s.maxD,l=4*s.maxD,r=void 0!==s.biomtMatrices&&s.biomtMatrices.length*s.cnt>s.maxatomcnt;"yes"===s.opts.slab?r?t=.1:void 0!==s.camMaxDFactorFog?(t=s.maxD*s.camMaxDFactorFog-10,n=2.5*s.maxD-t<0?0:2.5*s.maxD-t,l=4*s.maxD-t):t=s.maxD*s.camMaxDFactor:t=.1;let o=void 0!==e?e:1,a=s.shininess/100*.5;s.uniforms=THREE.UniformsUtils.merge([THREE.UniformsLib.common,{modelViewMatrix:{value:new THREE.Matrix4},modelViewMatrixInverse:{value:new THREE.Matrix4},modelViewMatrixInverseTranspose:{value:new THREE.Matrix4},modelViewProjectionMatrix:{value:new THREE.Matrix4},modelViewProjectionMatrixInverse:{value:new THREE.Matrix4},projectionMatrix:{value:new THREE.Matrix4},projectionMatrixInverse:{value:new THREE.Matrix4},diffuse:{type:"v3",value:[1,1,1]},emissive:{type:"v3",value:[.06,.06,.06]},roughness:{type:"f",value:.5},metalness:{type:"f",value:a},opacity:{type:"f",value:o},nearClip:{type:"f",value:t},ortho:{type:"f",value:0},shrink:{type:"f",value:.13},fogColor:{type:"v3",value:[i.r,i.g,i.b]},fogNear:{type:"f",value:n},fogFar:{type:"f",value:l},fogDensity:{type:"f",value:2}},THREE.UniformsLib.ambient,THREE.UniformsLib.lights]),s.defines={USE_COLOR:1,NEAR_CLIP:1,CAP:1},"yes"!==s.opts.fog||r||(s.defines.USE_FOG=1,"orthographic"===s.opts.camera&&(s.defines.FOG_EXP2=1)),s.bExtFragDepth&&(s.defines.USE_LOGDEPTHBUF_EXT=1)}drawImpostorShader(){this.icn3d.icn3dui.bNode||(this.setParametersForShader(),this.createImpostorShaderSphere("SphereImpostor"),this.createImpostorShaderCylinder("CylinderImpostor"))}getShader(e){this.icn3d.icn3dui;let t=$NGL_shaderTextHash[e];return t=t.replace(/#include\s+(\S+)/gim,(function(e,t){let s;return THREE.ShaderChunk.hasOwnProperty(t)&&(s=THREE.ShaderChunk[t]),s||""})),t}createImpostorShaderBase(e,t,s,i,n,l,r,o,a){let d=this.icn3d;d.icn3dui;let c=new THREE.ShaderMaterial({defines:d.defines,uniforms:d.uniforms,vertexShader:this.getShader(e+".vert"),fragmentShader:this.getShader(e+".frag"),depthTest:!0,depthWrite:!0,lights:!0});c.extensions.fragDepth=!0,"CylinderImpostor"==e?d.CylinderImpostorMaterial=c:"SphereImpostor"==e&&(d.SphereImpostorMaterial=c);let h,p,m=l*r,u=l*o,g=new(m>65535?Uint32Array:Uint16Array)(u);for(let e=0;e=0;t--){let s=a.children[t];s.onBeforeRender=e.impostorCls.onBeforeRender,s.frustumCulled=!1}l.add(a)}void 0!==e.mdl_ghost&&(a=e.mdl_ghost.clone(),this.applyMat(a,d),r.add(a));let c=e.center.clone();this.applyMat(c,d,!0),s.add(c),++t}e.mdl.add(n),e.mdlImpostor.add(l),e.mdl_ghost.add(r),void 0!==e.bSetInstancing&&e.bSetInstancing?(e.maxD=e.maxDAssembly,e.center=e.centerAssembly.clone(),e.applyCenterCls.setCenter(e.center),e.cameraCls.setCamera()):(e.maxD*=Math.sqrt(t),e.center=e.ParserUtilsCls.getMassCenter(s,t),e.maxDAssembly=e.maxD,e.centerAssembly=e.center.clone(),e.applyCenterCls.setCenter(e.center),e.cameraCls.setCamera()),e.bSetInstancing=!0}createInstancedGeometry(e){let t=this.icn3d,s=t.icn3dui,i=e.geometry,n=new THREE.InstancedBufferGeometry,l=[],r=[],o=[],a=[],d=[],c=[],h=[],p=[];if(t.bImpo&&"Cylinder"==e.type){t.instancedMaterial=this.getInstancedMaterial("CylinderInstancing");let e=s.hashUtilsCls.hashvalue2array(i.attributes.position1.array),r=s.hashUtilsCls.hashvalue2array(i.attributes.color.array),m=s.hashUtilsCls.hashvalue2array(i.attributes.position2.array),u=s.hashUtilsCls.hashvalue2array(i.attributes.color2.array),g=s.hashUtilsCls.hashvalue2array(i.index.array),f=s.hashUtilsCls.hashvalue2array(i.attributes.radius.array),b=s.hashUtilsCls.hashvalue2array(i.attributes.mapping.array);l=l.concat(e),o=o.concat(r),h=h.concat(m),p=p.concat(u),a=a.concat(g),d=d.concat(f),c=c.concat(b),n.setAttribute("position1",new THREE.BufferAttribute(new Float32Array(l),3)),n.setAttribute("color",new THREE.BufferAttribute(new Float32Array(o),3)),n.setAttribute("position2",new THREE.BufferAttribute(new Float32Array(h),3)),n.setAttribute("color2",new THREE.BufferAttribute(new Float32Array(p),3)),n.setAttribute("radius",new THREE.BufferAttribute(new Float32Array(d),1)),n.setAttribute("mapping",new THREE.BufferAttribute(new Float32Array(c),3)),n.setIndex(new THREE.BufferAttribute(new Uint32Array(a),1)),e=null,r=null,m=null,u=null,g=null,f=null,b=null}else if(t.bImpo&&"Sphere"==e.type){t.instancedMaterial=this.getInstancedMaterial("SphereInstancing");let e=s.hashUtilsCls.hashvalue2array(i.attributes.position.array),r=s.hashUtilsCls.hashvalue2array(i.attributes.color.array),h=s.hashUtilsCls.hashvalue2array(i.index.array),p=s.hashUtilsCls.hashvalue2array(i.attributes.radius.array),m=s.hashUtilsCls.hashvalue2array(i.attributes.mapping.array);l=l.concat(e),o=o.concat(r),a=a.concat(h),d=d.concat(p),c=c.concat(m),n.setAttribute("position",new THREE.BufferAttribute(new Float32Array(l),3)),n.setAttribute("color",new THREE.BufferAttribute(new Float32Array(o),3)),n.setAttribute("radius",new THREE.BufferAttribute(new Float32Array(d),1)),n.setAttribute("mapping",new THREE.BufferAttribute(new Float32Array(c),2)),n.setIndex(new THREE.BufferAttribute(new Uint32Array(a),1)),e=null,r=null,h=null,p=null,m=null}else{t.instancedMaterial=this.getInstancedMaterial("Instancing");let e=i.attributes.position?s.hashUtilsCls.hashvalue2array(i.attributes.position.array):[],d=i.attributes.normal?s.hashUtilsCls.hashvalue2array(i.attributes.normal.array):[],c=i.attributes.color?s.hashUtilsCls.hashvalue2array(i.attributes.color.array):[],h=i.index?s.hashUtilsCls.hashvalue2array(i.index.array):[];l=l.concat(e),r=r.concat(d),o=o.concat(c),a=a.concat(h);let p=[],m="CylinderGeometry"==i.type?1:0;for(let e=0,t=l.length/3;e0&&(e.dAtoms=t.hashUtilsCls.cloneHash(s)),e.bShowHighlight=!1}e.applyMapCls.removeSurfaces(),e.applyMapCls.applySurfaceOptions(),e.applyMapCls.removeMaps(),e.applyMapCls.applyMapOptions(),e.applyMapCls.removeEmmaps(),e.applyMapCls.applyEmmapOptions(),e.applyMapCls.removePhimaps(),e.applyMapCls.applyPhimapOptions(),e.applyMapCls.removeSurfaces(),e.applyMapCls.applyphisurfaceOptions(),e.axes=[],e.pc1&&e.axesCls.setPc1Axes(),e.opts.rotationcenter="highlight center",e.drawCls.draw(),e.bShowHighlight=!0}async alternateWrapper(){let e=this.icn3d;e.icn3dui,e.bAlternate=!0,await this.alternateStructures(),e.bAlternate=!1}}class ht{constructor(e){this.icn3d=e}draw(e){let t=this.icn3d,s=t.icn3dui;if(t.impostorCls.clearImpostors(),!t.bRender||t.hAtoms&&0!=Object.keys(t.hAtoms)||(t.hAtoms=s.hashUtilsCls.cloneHash(t.atoms)),t.sceneCls.rebuildScene(),t.bImpo&&t.impostorCls.drawImpostorShader(),t.setColorCls.applyPrevColor(),void 0!==t.biomtMatrices&&t.biomtMatrices.length>1)if(t.bAssembly&&1==Object.keys(t.structures).length&&(void 0===s.cfg.mmdbid&&1==s.cfg.bu||void 0!==s.cfg.mmdbid&&1==s.cfg.bu&&Object.keys(t.atoms).length*t.biomtMatrices.length>t.maxatomcnt))t.instancingCls.drawSymmetryMates();else{let e=!0;t.applyCenterCls.centerSelection(void 0,e)}let i=void 0!==t.hAtoms?Object.keys(t.hAtoms).length:0;if(i>0&&i0){e.children[0].scale.z=t[0].distance,t[0].point.sub(r.mdl.position);let s=r.rayThreshold,i=r.rayCls.getAtomsFromPosition(t[0].point,s);for(;!i&&s<10;)s+=.5,i=r.rayCls.getAtomsFromPosition(t[0].point,s);i&&(r.pAtomNum%2==0?r.pAtom=i:r.pAtom2=i,++r.pAtomNum,this.showPickingVr(r.pk,i))}}}}catch(e){}}showPickingVr(e,t){let s=this.icn3d;s.icn3dui,e||(e=2),s.hAtoms=s.pickingCls.getPickedAtomList(e,t),2===e?s.residueLabelsCls.addResidueLabels(s.hAtoms,void 0,void 0,!0):1===e&&s.residueLabelsCls.addAtomLabels(s.hAtoms),s.setOptionCls.setStyle("proteins",t.style)}render_base(){let e=this.icn3d,t=e.icn3dui,s=this;if(t.bNode)return;let i=e.bControlGl&&!t.bNode?window.cam:e.cam;if(e.directionalLight){let t=new THREE.Quaternion;t.setFromUnitVectors(new THREE.Vector3(0,0,e.cam_z).normalize(),i.position.clone().normalize()),e.directionalLight.position.copy(e.lightPos.clone().applyQuaternion(t).normalize()),e.directionalLight2.position.copy(e.lightPos2.clone().applyQuaternion(t).normalize()),e.directionalLight3.position.copy(e.lightPos3.clone().applyQuaternion(t).normalize())}if(e.bVr||e.renderer.setPixelRatio(window.devicePixelRatio),e.bVr){let t=.04;if(e.controllers){let i=this.updateGamepadState();for(let n=0,l=e.controllers.length;n{const i=e.gamepad.axes;let r=parseInt(1e3*i[t]),o=parseInt(-1e3*i[s]);n.push(r),l.push(o)})),{xArray:n,yArray:l}}return{xArray:[0,0],yArray:[0,0]}}}class pt{constructor(e){this.icn3d=e}getAtomsWithinAtom(e,t,s,i,n,l,r){let o=this.icn3d;o.icn3dui;let a=this.getNeighboringAtoms(e,t,s,r);i&&(o.resid2Residhash={});let d={};for(let e in t){let c,h,p=o.atoms[e],m=p.structure+"_"+p.chain+"_"+p.resi;for(let e in o.residues[m])if(o.atoms[e]&&("CA"===o.atoms[e].name&&"C"===o.atoms[e].elem||"O3'"===o.atoms[e].name||"O3*"===o.atoms[e].name)){c=o.atoms[e];break}void 0===c&&(c=p),i&&(h=p.resn+" $"+p.structure+"."+p.chain+":"+p.resi,void 0===o.resid2Residhash[h]&&(o.resid2Residhash[h]={}));let u=p.structure+"_"+p.chain+"_"+p.resi;for(let e in a){let m=a[e];if(!o.crossstrucinter&&p.structure!=m.structure)continue;if(!r&&m.serial in t)continue;if(o.bOpm&&"DUM"===m.resn)continue;let g=m.coord.distanceTo(p.coord);if(go?r:o,d=Math.sqrt(a),c=(d+s)*(d+s),h={};for(let r in e){let e=n.atoms[r];!i&&t.hasOwnProperty(e.serial)||(this.bOpm&&"DUM"===e.resn||e.coord.xl[1][0]+s||e.coord.yl[1][1]+s||e.coord.zl[1][2]+s||(e.coord.x-l[2][0])*(e.coord.x-l[2][0])+(e.coord.y-l[2][1])*(e.coord.y-l[2][1])+(e.coord.z-l[2][2])*(e.coord.z-l[2][2])e.coord.x?n:e.coord.x,l=l>e.coord.y?l:e.coord.y,r=r>e.coord.z?r:e.coord.z}return[[t,s,i],[n,l,r],[o/c,a/c,d/c]]}hideContact(){let e=this.icn3d;e.icn3dui,e.opts.contact="no",void 0===e.lines&&(e.lines={}),e.lines.contact=[],e.contactpnts=[]}}class mt{constructor(e){this.icn3d=e}isHbondDonorAcceptor(e){let t=this.icn3d;if(t.icn3dui,"N"==e.name&&!e.het||"N"==e.elem&&"Arg"==e.resn||"N"==e.elem&&"Asn"==e.resn||"N"==e.elem&&"Gln"==e.resn||"N"==e.elem&&"Lys"==e.resn||"N"==e.elem&&"Trp"==e.resn)return"donor";if("O"==e.name&&!e.het||"S"==e.elem&&"Met"==e.resn||"O"==e.elem&&"Asn"==e.resn||"O"==e.elem&&"Asp"==e.resn||"O"==e.elem&&"Gln"==e.resn||"O"==e.elem&&"Glu"==e.resn)return"acceptor";if("S"==e.elem&&"Cys"==e.resn||"N"==e.elem&&"His"==e.resn||"O"==e.elem&&"Ser"==e.resn||"O"==e.elem&&"Thr"==e.resn||"O"==e.elem&&"Tyr"==e.resn)return"both";if("Pro"==e.resn)return"none";if("N"==e.elem){if("Asn"==e.resn||"Gln"==e.resn)return"both";let s=0,i=0;for(let i=0,n=e.bonds.length;i1?"ring":"donor":"none"}if("O"==e.elem&&1==e.bonds.length){if("Asn"==e.resn||"Gln"==e.resn)return"both";for(let s=0,i=e.bonds.length;s=2?"acceptor":"both"}if("O"==e.elem&&2==e.bonds.length){for(let s=0,i=e.bonds.length;s1);++t)"H"!=s.atoms[e.bonds[t]].elem&&(i=s.atoms[e.bonds[t]],l[r++].subVectors(s.atoms[e.bonds[t]].coord,e.coord));if(1===r)for(let t=0,n=i.bonds.length;t1);++t)"H"!=s.atoms[i.bonds[t]].elem&&s.atoms[i.bonds[t]].serial!=e.serial&&l[r++].subVectors(s.atoms[i.bonds[t]].coord,e.coord);if(2!==r)return;let o=l[0].cross(l[1]);return Math.abs(Math.PI/2-o.angleTo(n))}isValidHbond(e,t,s){let i=this.icn3d;i.icn3dui;let n,l,r=this.isHbondDonorAcceptor(e),o=this.isHbondDonorAcceptor(t),a=50*Math.PI/180,d=50*Math.PI/180,c=90*Math.PI/180,h=30*Math.PI/180;if("donor"==r&&("acceptor"==o||"both"==o||"ring"==o)||"acceptor"==o&&("donor"==r||"both"==r||"ring"==r))n=e,l=t;else if("acceptor"==r&&("donor"==o||"both"==o||"ring"==o)||"donor"==o&&("acceptor"==r||"both"==r||"ring"==r))l=e,n=t;else{if("both"!=r&&"ring"!=r||"both"!=o&&"ring"!=o)return!1;n=e,l=t,i.nucleotides.hasOwnProperty(e.serial)&&i.nucleotides.hasOwnProperty(t.serial)&&("ring"==r||"ring"==o)||(e.het||t.het)&&"ring"==r&&"ring"==o||(h=90*Math.PI/180)}let p=this.calcAngles(n,l),m=90*Math.PI/180;for(let e=0,t=p.length;ed)return!1;let u=this.calcPlaneAngle(n,l);if(void 0!==u&&u>h)return!1;let g=this.calcAngles(l,n),f=90*Math.PI/180;for(let e=0,t=g.length;ea)return!1;let b=this.calcPlaneAngle(l,n);return!(void 0!==b&&b>c)}calculateChemicalHbonds(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(0===Object.keys(e).length||0===Object.keys(t).length)return;r.resid2Residhash={};let a,d,c={},h=s*s;for(let t in e){let s=e[t],n=i?"LYS"===s.resn&&"N"===s.elem&&"N"!==s.name||"ARG"===s.resn&&("NH1"===s.name||"NH2"===s.name)||("GLU"===s.resn||"ASP"===s.resn)&&"O"===s.elem&&"O"!==s.name||s.het&&("N"===s.elem||"O"===s.elem||"S"===s.elem):"N"===s.elem||"O"===s.elem||"S"===s.elem&&(s.het||"Cys"===s.resn||"Met"===s.resn);n=r.bOpm?n&&"DUM"!==s.resn:n,n&&(a=s.structure+"_"+s.chain+"_"+s.resi,d=a+"_"+s.name,c[d]=s)}let p={},m={},u=.5,g=-27.888,f={};for(let e in t){let b=t[e],C=i?"LYS"===b.resn&&"N"===b.elem&&"N"!==b.name||"ARG"===b.resn&&("NH1"===b.name||"NH2"===b.name)||("GLU"===b.resn||"ASP"===b.resn)&&"O"===b.elem&&"O"!==b.name||b.het&&("N"===b.elem||"O"===b.elem||"S"===b.elem):"N"===b.elem||"O"===b.elem||"S"===b.elem&&(b.het||"Cys"===b.resn||"Met"===b.resn);if(C=r.bOpm?C&&"DUM"!==b.resn:C,C){a=b.structure+"_"+b.chain+"_"+b.resi,d=a+"_"+b.name;let e=b.resn+" $"+b.structure+"."+b.chain+":"+b.resi+"@"+b.name;void 0===r.resid2Residhash[e]&&(r.resid2Residhash[e]={});for(let t in c){if(i&&!(("LYS"!==b.resn&&"ARG"!==b.resn||"LYS"!==c[t].resn&&"ARG"!==c[t].resn)&&("GLU"!==b.resn&&"ASP"!==b.resn||"GLU"!==c[t].resn&&"ASP"!==c[t].resn)))continue;if(!r.crossstrucinter&&b.structure!=c[t].structure)continue;if(a==t.substr(0,t.lastIndexOf("_")))continue;let d=Math.abs(b.coord.x-c[t].coord.x);if(d>s)continue;let C=Math.abs(b.coord.y-c[t].coord.y);if(C>s)continue;let y=Math.abs(b.coord.z-c[t].coord.z);if(y>s)continue;let v=d*d+C*C+y*y;if(v>h)continue;if(!r.proteins.hasOwnProperty(b.serial)||!r.proteins.hasOwnProperty(c[t].serial)||"N"!==b.name&&"O"!==b.name||"O"!==c[t].name&&"N"!==c[t].name){if(!this.isValidHbond(b,c[t],s))continue}else{if(b.name===c[t].name)continue;if(b.structure==c[t].structure&&b.chain==c[t].chain&&Math.abs(b.resi-c[t].resi)<=1)continue;let e,i="N"===b.name?b:c[t],n="O"===b.name?b:c[t];if("Pro"===i.resn)continue;if(void 0===i.hcoord){if(!this.isValidHbond(b,c[t],s))continue}else{let s,l=i.hcoord,o=i.coord,a=n.structure+"_"+n.chain+"_"+n.resi;for(let e in r.residues[a])if("C"===r.atoms[e].name){s=r.atoms[e];break}if(!s)continue;let d=s.coord,h=n.coord,p=l.distanceTo(h),m=l.distanceTo(d),f=o.distanceTo(d),C=o.distanceTo(h);e=p2||f[c[t].serial]>2)continue;void 0===f[b.serial]?f[b.serial]=1:++f[b.serial],void 0===f[c[t].serial]?f[c[t].serial]=1:++f[c[t].serial],"graph"!==n&&(i?(r.saltbridgepnts.push({serial:b.serial,coord:b.coord}),r.saltbridgepnts.push({serial:c[t].serial,coord:c[t].coord})):(r.hbondpnts.push({serial:b.serial,coord:b.coord}),r.hbondpnts.push({serial:c[t].serial,coord:c[t].coord})));let _=c[t].structure+"_"+c[t].chain+"_"+c[t].resi;p=o.hashUtilsCls.unionHash(p,r.residues[a]),p=o.hashUtilsCls.unionHash(p,r.residues[_]),m[a]=1,m[_]=1;let w=c[t].resn+" $"+c[t].structure+"."+c[t].chain+":"+c[t].resi+"@"+c[t].name,S=a+"_"+b.resn+","+_+"_"+c[t].resn;void 0!==r.resids2interAll[S]&&void 0!==r.resids2interAll[S].ionic&&r.resids2interAll[S].ionic.hasOwnProperty(e+","+w)||(r.resid2Residhash[e][w]=v.toFixed(1),l||(void 0===r.resids2inter[S]&&(r.resids2inter[S]={}),void 0===r.resids2inter[S].hbond&&(r.resids2inter[S].hbond={}),r.resids2inter[S].hbond[e+","+w]=v.toFixed(1)),void 0===r.resids2interAll[S]&&(r.resids2interAll[S]={}),void 0===r.resids2interAll[S].hbond&&(r.resids2interAll[S].hbond={}),r.resids2interAll[S].hbond[e+","+w]=v.toFixed(1))}}}let b=Object.keys(m);if("graph"!==n)for(let e=0,t=b.length;en)return!1;let c=Math.abs(e.coord.y-t.coord.y);if(c>n)return!1;let h=Math.abs(e.coord.z-t.coord.z);if(h>n)return!1;let p=d*d+c*c+h*h;if(p>l)return!1;"graph"!==s&&("halogen"==i?(a.halogenpnts.push({serial:e.serial,coord:e.coord}),a.halogenpnts.push({serial:t.serial,coord:t.coord})):"pi-cation"==i?(a.picationpnts.push({serial:e.serial,coord:e.coord}),a.picationpnts.push({serial:t.serial,coord:t.coord})):"pi-stacking"==i&&(a.pistackingpnts.push({serial:e.serial,coord:e.coord}),a.pistackingpnts.push({serial:t.serial,coord:t.coord})));let m=t.resn+" $"+t.structure+"."+t.chain+":"+t.resi+"@"+t.name;a.resid2Residhash[r][m]=p.toFixed(1);let u=e.structure+"_"+e.chain+"_"+e.resi+"_"+e.resn+","+t.structure+"_"+t.chain+"_"+t.resi+"_"+t.resn;return o||(void 0===a.resids2inter[u]&&(a.resids2inter[u]={}),void 0===a.resids2inter[u][i]&&(a.resids2inter[u][i]={}),a.resids2inter[u][i][r+","+m]=p.toFixed(1)),void 0===a.resids2interAll[u]&&(a.resids2interAll[u]={}),void 0===a.resids2interAll[u][i]&&(a.resids2interAll[u][i]={}),a.resids2interAll[u][i][r+","+m]=p.toFixed(1),!0}getRingNormal(e){if(this.icn3d.icn3dui,e.length<3)return;let t=e[0].clone().sub(e[1]),s=e[1].clone().sub(e[2]);return t.cross(s).normalize()}getAromaticRings(e,t,s){let i=this.icn3d;i.icn3dui;let n=[],l=[],r=[],o=[];if("nucleotide"==s){let s=new THREE.Vector3,a=new THREE.Vector3;if("A"==e.trim().toUpperCase()||"DA"==e.trim().toUpperCase()||"G"==e.trim().toUpperCase()||"DG"==e.trim().toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"N1"==t.name||"C2"==t.name||"N3"==t.name||"C6"==t.name?(s.add(t.coord),r.push(t.coord)):"C4"==t.name||"C5"==t.name?(s.add(t.coord),a.add(t.coord),r.push(t.coord),o.push(t.coord)):"N7"!=t.name&&"C8"!=t.name&&"N9"!=t.name||(a.add(t.coord),o.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r))),5==o.length&&(a.multiplyScalar(.2),n.push(a),l.push(this.getRingNormal(o)))}else if("C"==e.trim().toUpperCase()||"DC"==e.trim().toUpperCase()||"T"==e.trim().toUpperCase()||"DT"==e.trim().toUpperCase()||"U"==e.trim().toUpperCase()||"DU"==e.trim().toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"N1"==t.name||"C2"==t.name||"N3"==t.name||"C6"==t.name?(s.add(t.coord),r.push(t.coord)):"C4"!=t.name&&"C5"!=t.name||(s.add(t.coord),r.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r)))}}else if("protein"==s){let s=new THREE.Vector3,a=new THREE.Vector3;if("PHE"==e.toUpperCase()||"TYR"==e.toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"CG"!=t.name&&"CD1"!=t.name&&"CE1"!=t.name&&"CZ"!=t.name&&"CE2"!=t.name&&"CD2"!=t.name||(s.add(t.coord),r.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r)))}else if("HIS"==e.toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"CG"!=t.name&&"ND1"!=t.name&&"CE1"!=t.name&&"NE2"!=t.name&&"CD2"!=t.name||(s.add(t.coord),r.push(t.coord))}5==r.length&&(s.multiplyScalar(.2),n.push(s),l.push(this.getRingNormal(r)))}else if("TRP"==e.toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"CZ2"==t.name||"CH2"==t.name||"CZ3"==t.name||"CE3"==t.name?(s.add(t.coord),r.push(t.coord)):"CD2"==t.name||"CE2"==t.name?(s.add(t.coord),a.add(t.coord),r.push(t.coord),o.push(t.coord)):"CG"!=t.name&&"CD1"!=t.name&&"NE1"!=t.name||(a.add(t.coord),o.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r))),5==o.length&&(a.multiplyScalar(.2),n.push(a),l.push(this.getRingNormal(o)))}}return{piPosArray:n,normalArray:l}}dfs_cycle(e,t,s){let i=this.icn3d;if(i.icn3dui,2==i.ring_color[e])return s;if(1==i.ring_color[e]){s++;let n=t;for(i.ring_mark[n]=s;n!=e;)n=i.ring_par[n],i.ring_mark[n]=s;return s}if(i.ring_par[e]=t,i.ring_color[e]=1,void 0!==i.atoms[e])for(let t=0,n=i.atoms[e].bonds.length;t=3&&o<=6&&a[0]&&a[1]&&a[2]&&a[3]){let i=a[0].clone().sub(a[1]).normalize(),r=a[1].clone().sub(a[2]).normalize(),d=a[2].clone().sub(a[3]).normalize(),c=i.cross(r).normalize(),h=c.dot(d);if(Math.abs(h)<.052){l.multiplyScalar(1/o);let i=t.atoms[n];s[e+"_pi"+n]={resn:i.resn,name:"pi"+n,coord:l,serial:i.serial,structure:i.structure,chain:i.chain,resi:i.resi,normal:c}}}}return s}hideHalogenPi(){let e=this.icn3d;e.icn3dui,e.opts.halogen="no",e.opts["pi-cation"]="no",e.opts["pi-stacking"]="no",void 0===e.lines&&(e.lines={}),e.lines.halogen=[],e.lines["pi-cation"]=[],e.lines["pi-stacking"]=[],e.halogenpnts=[],e.picationpnts=[],e.pistackingpnts=[]}}class gt{constructor(e){this.icn3d=e}calculateIonicInteractions(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(0===Object.keys(e).length||0===Object.keys(t).length)return;r.resid2Residhash={};let a,d,c={},h={},p=s*s;for(let t in e){let s=e[t];if("ARG"===s.resn&&"NH2"===s.name||"GLU"===s.resn&&"OE2"===s.name||"ASP"===s.resn&&"OD2"===s.name)continue;let i=("LYS"===s.resn||"HIS"===s.resn)&&"N"===s.elem&&"N"!==s.name||"ARG"===s.resn&&("NH1"===s.name||"NH2"===s.name)||s.het&&-1!==o.parasCls.cationsTrimArray.indexOf(s.elem)||s.het&&"N"===s.elem&&1==s.bonds.length,n=this.isAnion(s);i=r.bOpm?i&&"DUM"!==s.resn:i,n=r.bOpm?n&&"DUM"!==s.resn:n,(i||n)&&(a=s.structure+"_"+s.chain+"_"+s.resi,d=a+"_"+s.name,i&&(c[d]=s),n&&(h[d]=s))}let m={},u={};for(let e in t){let i=t[e];if("ARG"===i.resn&&"NH2"===i.name||"GLU"===i.resn&&"OE2"===i.name||"ASP"===i.resn&&"OD2"===i.name)continue;let g=("LYS"===i.resn||"HIS"===i.resn)&&"N"===i.elem&&"N"!==i.name||"ARG"===i.resn&&("NH1"===i.name||"NH2"===i.name)||i.het&&-1!==o.parasCls.cationsTrimArray.indexOf(i.elem),f=this.isAnion(i);if(g=r.bOpm?g&&"DUM"!==i.resn:g,f=r.bOpm?f&&"DUM"!==i.resn:f,g||f){a=i.structure+"_"+i.chain+"_"+i.resi,d=a+"_"+i.name;let e=i.resn+" $"+i.structure+"."+i.chain+":"+i.resi+"@"+i.name;void 0===r.resid2Residhash[e]&&(r.resid2Residhash[e]={});let t={};g?t=h:f&&(t=c);let b,C=i.structure+"_"+i.chain+"_"+i.resi;g&&"ARG"===i.resn&&"NH1"===i.name?b=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[C],"NH2"):f&&"GLU"===i.resn&&"OE1"===i.name?b=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[C],"OE2"):f&&"ASP"===i.resn&&"OD1"===i.name&&(b=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[C],"OD2"));let y=void 0===b?i.coord:i.coord.clone().add(b.coord).multiplyScalar(.5);for(let d in t){if(a==d.substr(0,d.lastIndexOf("_")))continue;if(!r.crossstrucinter&&i.structure!=t[d].structure)continue;let c,h=t[d].structure+"_"+t[d].chain+"_"+t[d].resi;f&&"ARG"===t[d].resn&&"NH1"===t[d].name?c=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[h],"NH2"):g&&"GLU"===t[d].resn&&"OE1"===t[d].name?c=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[h],"OE2"):g&&"ASP"===t[d].resn&&"OD1"===t[d].name&&(c=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[h],"OD2"));let b=void 0===c?t[d].coord:t[d].coord.clone().add(c.coord).multiplyScalar(.5),C=Math.abs(y.x-b.x);if(C>s)continue;let v=Math.abs(y.y-b.y);if(v>s)continue;let _=Math.abs(y.z-b.z);if(_>s)continue;let w=C*C+v*v+_*_;if(w>p)continue;"graph"!==n&&(r.saltbridgepnts.push({serial:i.serial,coord:y}),r.saltbridgepnts.push({serial:t[d].serial,coord:b}));let S=t[d].structure+"_"+t[d].chain+"_"+t[d].resi;m=o.hashUtilsCls.unionHash(m,r.residues[a]),m=o.hashUtilsCls.unionHash(m,r.residues[S]),u[a]=1,u[S]=1;let A=t[d].resn+" $"+t[d].structure+"."+t[d].chain+":"+t[d].resi+"@"+t[d].name;r.resid2Residhash[e][A]=w.toFixed(1);let x=a+"_"+i.resn+","+S+"_"+t[d].resn;l||(void 0===r.resids2inter[x]&&(r.resids2inter[x]={}),void 0===r.resids2inter[x].ionic&&(r.resids2inter[x].ionic={}),r.resids2inter[x].ionic[e+","+A]=w.toFixed(1)),void 0===r.resids2interAll[x]&&(r.resids2interAll[x]={}),void 0===r.resids2interAll[x].ionic&&(r.resids2interAll[x].ionic={}),r.resids2interAll[x].ionic[e+","+A]=w.toFixed(1)}}}let g=Object.keys(u);if("graph"!==n)for(let e=0,t=g.length;e1?1/(n-1):1;for(let n in e){let e=t.atoms[n];e.color=e.het?s.parasCls.atomColors[e.elem]||s.parasCls.defaultAtomColor:s.parasCls.thr().setHSL(3/4*(1-i++*l),1,.45),t.atomPrevColors[n]=e.color}}colorRainbow(e){let t=this.icn3d,s=t.icn3dui,i=0,n=0;e=s.hashUtilsCls.intHash(e,t.hAtoms);for(let s in e){t.atoms[s].het||++n}let l=n>1?1/(n-1):1;for(let n in e){let e=t.atoms[n];e.color=e.het?s.parasCls.atomColors[e.elem]||s.parasCls.defaultAtomColor:s.parasCls.thr().setHSL(3/4*i++*l,1,.45),t.atomPrevColors[n]=e.color}}setColorAcrossSets(e,t){let s=this.icn3d,i=s.icn3dui,n=0,l=e.length,r=l>1?1/(l-1):1;for(let l=0,o=e.length;l0)this.setMmdbChainColor();else{let e=-1,s="",l=n.parasCls.stdChainColors.length;for(let r in t){let t=i.atoms[r];t.chain!=s&&(++e,e%=l),t.het?(t.color=n.parasCls.atomColors[t.elem],i.atomPrevColors[r]=t.color):(t.color=n.parasCls.stdChainColors[e],Object.keys(i.chainsColor).length>0&&this.updateChainsColor(t),i.atomPrevColors[r]=t.color),s=t.chain}}break;case"domain":s=0,l=0;let m=Object.keys(i.tddomains);l=m.length,r=l>1?1/(l-1):1;for(let e=0,t=m.length;e1?1/(l-1):1;for(let e=0;e Defined Sets", and try it again.');break;case"secondary structure green":i.sheetcolor="green";for(let e in t){let t=i.atoms[e];t.color=t.het?n.parasCls.atomColors[t.elem]||n.parasCls.defaultAtomColor:n.parasCls.ssColors[t.ss]||n.parasCls.thr(16711935),i.atomPrevColors[e]=t.color}break;case"secondary structure yellow":case"secondary structure":i.sheetcolor="yellow";for(let e in t){let t=i.atoms[e];t.color=t.het?n.parasCls.atomColors[t.elem]||n.parasCls.defaultAtomColor:n.parasCls.ssColors2[t.ss]||n.parasCls.thr(16711935),i.atomPrevColors[e]=t.color}break;case"secondary structure spectrum":s=0,l=0;let u,g,f=[],b=-9999;for(let e in t){if(!i.proteins.hasOwnProperty(e))continue;let t=i.atoms[e];-9999==b&&(u=parseInt(e)),-9999!=b&&(t.ss!=g.ss||Math.abs(t.resi-g.resi)>1||t.ssbegin&&g.ssend)&&("coil"==g.ss||f.push([u,b]),u=e),b=parseInt(e),g=t}"coil"==g.ss||f.push([u,b]),l=f.length,r=l>1?1/(l-1):1;for(let e=0,t=f.length;e100&&(e=100);let r=(i.middB-e)*i.spanBinv1,o=(e-i.middB)*i.spanBinv2;e=90?t.color=n.parasCls.thr().setRGB(0,.325,.839):e>=70&&e<90?t.color=n.parasCls.thr().setRGB(.396,.572,.953):e>=50&&e<70?t.color=n.parasCls.thr().setRGB(1,.859,.075):e<50&&(t.color=n.parasCls.thr().setRGB(1,.49,.271))}i.atomPrevColors[e]=t.color}break;case"b factor":i.middB=50,i.spanBinv1=.02,i.spanBinv2=.02;for(let e in t){let t=i.atoms[e];if(void 0===t.b||isNaN(t.b)||0==parseInt(1e3*t.b))t.color=n.parasCls.thr().setRGB(0,1,0);else{let e=t.b;e>100&&(e=100),e=t.structure.substr(0,4)!=i.defaultPdbId&&t.structure.length>5?100-e:e;let s=(i.middB-e)*i.spanBinv1,l=(e-i.middB)*i.spanBinv2;t.color=et.b&&(o=t.b),a5?100-t.b:t.b,s=i.bfactorArray.indexOf(e)/C;t.color=s<.5?n.parasCls.thr().setRGB(2*s,2*s,1):n.parasCls.thr().setRGB(1,2*(1-s),2*(1-s))}i.atomPrevColors[e]=t.color}break;case"area":if(void 0===i.resid2area){let e=n.hashUtilsCls.cloneHash(i.hAtoms);i.hAtoms=n.hashUtilsCls.cloneHash(i.atoms),i.bCalcArea=!0,i.opts.surface="solvent accessible surface",i.applyMapCls.applySurfaceOptions(),i.bCalcArea=!1,i.hAtoms=n.hashUtilsCls.cloneHash(e)}let y=void 0!==i.midpercent?i.midpercent:35;i.spanBinv1=.02,i.spanBinv2=.02;for(let e in t){let t=i.atoms[e],s=t.structure+"_"+t.chain+"_"+t.resi+"_"+t.resn,l=n.parasCls.residueArea.hasOwnProperty(t.resn)?i.resid2area[s]/n.parasCls.residueArea[t.resn]*100:y;l>100&&(l=100);let r=(y-l)*i.spanBinv1,o=(l-y)*i.spanBinv2;t.color=l

    ";if("atom"==e){let e=["proteins","nucleotides","chemicals","ions","water"];for(let i=0,l=e.length;i[e,s.parasCls.hydrophobicValues[e]]));l.sort(((e,t)=>parseFloat(e[1])-parseFloat(t[1])));var r=l.map((e=>[e[0],Object.keys(o[e[0]])[0]]));n+="
    ","normalized hydrophobic"==e?(n+="Dark green (W, F, L, I, Y, M, V, C): Hydrophobic
    ",n+="Light green (P, T, S, A, Q, N, G): Polar
    ",n+="Grey: Charged, not hydrophobic

    "):(n+="Green (W, F, L, I, Y, M, V, C): Hydrophobic
    ",n+="Yellow (P, T, S, A, Q, N, G): Polar
    ",n+="Red: Negatively Charged
    ",n+="Blue: Positively Charged

    ");let a=0;for(let e of r)s.parasCls.residueAbbrev[e[0]]&&(n+="
    ",n+="
    ",n+=s.parasCls.residueAbbrev[e[0]]+"
    ",a%4==3&&(n+="
    "),++a);n+="
    "}else"b factor"==e?(n+="
    B factor quantitates the uncertainty for each atom. A high B factor reflects that the position is less certain.

    ",n+=s.htmlCls.clickMenuCls.setLegendHtml()):"confidence"==e?n+=s.htmlCls.clickMenuCls.setLegendHtml(!0):"exon"==e?(t.startColor="red",t.midColor="white",t.endColor="blue",t.startValue="Start",t.midValue="Middle",t.endValue="End",n+=s.htmlCls.clickMenuCls.setLegendHtml()):n="";n?($("#"+s.pre+"dl_legend_html").html(n),s.htmlCls.dialogCls.openDlg("dl_legend","Color Legend")):$("#"+s.pre+"dl_legend").hasClass("ui-dialog-content")&&$("#"+s.pre+"dl_legend").dialog("isOpen")&&$("#"+s.pre+"dl_legend").dialog("close")}getColorLegendForElem(e,t){let s=this.icn3d,i=s.icn3dui,n="",l={};for(let e in t){let t=s.atoms[e],i=void 0===t||void 0===t.color||"FFFFFF"===t.color.getHexString().toUpperCase()?"DDDDDD":t.color.getHexString();void 0===l[t.elem]&&(l[t.elem]={}),l[t.elem][i]=1}if(Object.keys(l).length>0){n+=""+e+"
    ";let t=Object.keys(l).sort();for(let e=0,s=t.length;e";for(let e in l[s])n+="
    ";n+=i.parasCls.atomnames[s.toUpperCase()]+"

    "}n+="
    "}return n}getRes2color(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=s.firstAtomObjCls.getResiduesFromAtoms(e);for(let e in l){let l=s.residues[e],r=s.firstAtomObjCls.getFirstAtomObj(l),o=t?r.resn:i.parasCls.residueAbbrev[r.resn],a=void 0===r||void 0===r.color||"FFFFFF"===r.color.getHexString().toUpperCase()?"DDDDDD":r.color.getHexString();null!=o&&(void 0===n[o]&&(n[o]={}),n[o][a]=1)}return n}getColorLegendForResidue(e){this.icn3d.icn3dui;let t="",s=this.getRes2color(e);if(Object.keys(s).length>0){t+="
    ";let e=Object.keys(s).sort(),i="",n=0;for(let l=0,r=e.length;l";for(let e in s[o])r+="
    ";r+=o+"
    ",n%4==3&&(r+="
    "),-1!=o.indexOf("(")?(t+=r,++n):i+=r}i&&(t+="
    "+i),t+="
    "}return t}getColorLegendForCharge(e){let t=this.icn3d;t.icn3dui;let s="",i=t.firstAtomObjCls.getResiduesFromAtoms(e),n={};for(let e in i){let s=t.residues[e],i=t.firstAtomObjCls.getFirstAtomObj(s);"ARG"==i.resn||"LYS"==i.resn?n.Positive=1:"HIS"==i.resn?n["Partial-Positive"]=1:"ASP"==i.resn||"GLU"==i.resn||t.nucleotides[i.serial]?n.Negative=1:n.Neutral=1}const l={Positive:"0000ff","Partial-Positive":"8080ff",Negative:"ff0000",Neutral:"888888"};let r=["Positive","Partial-Positive","Negative","Neutral"];s+="
    ";for(let e=0,t=r.length;e",s+="
    ",s+=t,s+="
    ")}return s+="
    (Charges are at pH 7)",s+="
    ",s}getColorLegendForIgstrand(e){this.icn3d.icn3dui;let t="";const s={"A Strand":"9400D3","B Strand":"ba55d3","C Strand":"0000FF","C' Strand":"6495ED","C'' Strand":"006400","D Strand":"00FF00","E Strand":"FFD700","F Strand":"FF8C00","G Strand":"FF0000",Loop:"CCCCCC"};t+="
    ";for(let e in s){t+="",t+="
    ",t+=e,t+="

    "}return t+="
    ",t}getColorLegendForIgproto(e){this.icn3d.icn3dui;let t="";const s={"Protodomain 1":"","A Strand":"0000FF","B Strand":"006400","C Strand":"FFD700","C' Strand":"FF8C00","
    Linker":"","C'' Strand":"FF0000","
    Protodomain 2":"","D Strand":"0000FF","E Strand":"006400","F Strand":"FFD700","G Strand":"FF8C00","":"",Loop:"CCCCCC"};t+="
    A protodomain is a supersecondary structure
    that by its duplication, symmetry operations
    can generate a structural domain.

    ";for(let e in s){let i=s[e];t+="",i&&(t+="
    "),t+=e,t+="

    "}return t+="
    ",t}}class vt{constructor(e){this.icn3d=e}async showCddSiteAll(){let e=this.icn3d,t=e.icn3dui,s=this;e.chainid2pssmid={};let i=$.map(e.protein_chainid,(function(e){return e})),n=Object.keys(e.protein_chainid),l="https://www.ncbi.nlm.nih.gov/Structure/cdannots/cdannots.fcgi?fmt&frclive&live=lcl&queries="+i;if(1==Object.keys(e.structures).length&&!t.cfg.afid&&(t.cfg.mmtfid||t.cfg.pdbid||t.cfg.opmid||t.cfg.mmdbid||t.cfg.gi||t.cfg.uniprotid||t.cfg.blast_rep_id||t.cfg.cid||t.cfg.mmcifid)||2==Object.keys(e.structures).length&&t.cfg.align){let e={};try{t.bNode?e=await t.getAjaxPromise(l,"jsonp"):e.value=await t.getAjaxPromise(l,"jsonp"),s.parseCddData([e],n)}catch(e){return void s.getNoCdd(i)}}else{let i=[];for(let s=0,r=n.length;s',p=h,m=h,u=d.doms;n.bNode&&!i.resid2cdd[c]&&(i.resid2cdd[c]=[]);let g=l.setDomainFeature(u,c,!0,h,p,m);i.chainid2pssmid[c]={pssmid2name:g.pssmid2name,pssmid2fromArray:g.pssmid2fromArray,pssmid2toArray:g.pssmid2toArray};let f=g.acc2domain;h=g.html+"",p=g.html2+"",m=g.html3+"",$("#"+i.pre+"dt_cdd_"+c).html(h),$("#"+i.pre+"ov_cdd_"+c).html(p),$("#"+i.pre+"tt_cdd_"+c).html(m),h='
    ',p=h,m=h;let b=d.motifs;n.bNode&&!i.resid2site[c]&&(i.resid2site[c]=[]),g=l.setDomainFeature(b,c,!1,h,p,m,f),h=g.html,p=g.html2,m=g.html3;let C=a.data[e].sites,y=void 0!==C?C.length:0;for(let e=0;e17&&(s=s.substr(0,17)+"...");let l,r=C[e].title,o=[];for(let t=0,s=C[e].locs.length;t'+s+"
    ",u=''+t.toString()+" Res",g='';m+=d+u+"
    ",h+=d+u+g,p+=d+u+g;let f="site"+e.toString(),b=0,y=0,v=1;i.seqStartLen&&i.seqStartLen[c]&&(p+=i.showSeqCls.insertMulGapOverview(c,i.seqStartLen[c])),i.seqStartLen&&i.seqStartLen[c]&&(h+=i.showSeqCls.insertMulGap(i.seqStartLen[c],"-"));for(let t=0,s=i.giSeq[c].length;t1&&(l=s[0]+"..");let r=i.ParserUtilsCls.getResi(c,t);if(h+=''+s+"",n.bNode){let t={};t[c+"_"+r]="site: "+C[e].title,i.resid2site[c].push(t)}p+=i.showSeqCls.insertGapOverview(c,t);let o=n.cfg.blast_rep_id==c?Math.round(i.seqAnnWidth*t/(i.maxAnnoLength+i.nTotalGap)-b-y):Math.round(i.seqAnnWidth*t/i.maxAnnoLength-b-y);o>=0&&(p+='
     
    ',p+='
     
    ',b+=o,y+=v)}else h+="-";i.seqStartLen&&i.seqStartLen[c]&&(h+=i.showSeqCls.insertMulGap(i.seqEndLen[c],"-")),g=' '+t.toString()+" Residues",g+="
    ",g+="
    ",h+=g,p+=g}h+="",p+="",m+="",$("#"+i.pre+"dt_site_"+c).html(h),$("#"+i.pre+"ov_site_"+c).html(p),$("#"+i.pre+"tt_site_"+c).html(m)}}for(let e in i.protein_chainid)r.hasOwnProperty(e)||($("#"+i.pre+"dt_cdd_"+e).html(""),$("#"+i.pre+"ov_cdd_"+e).html(""),$("#"+i.pre+"tt_cdd_"+e).html(""),$("#"+i.pre+"dt_site_"+e).html(""),$("#"+i.pre+"ov_site_"+e).html(""),$("#"+i.pre+"tt_site_"+e).html(""));i.showAnnoCls.enableHlSeq(),i.bAjaxCddSite=!0}getNoCdd(e){let t=this.icn3d;t.icn3dui,console.log("No CDD data were found for the protein "+e+"...");for(let e in t.protein_chainid)$("#"+t.pre+"dt_cdd_"+e).html(""),$("#"+t.pre+"ov_cdd_"+e).html(""),$("#"+t.pre+"tt_cdd_"+e).html(""),$("#"+t.pre+"dt_site_"+e).html(""),$("#"+t.pre+"ov_site_"+e).html(""),$("#"+t.pre+"tt_site_"+e).html("");t.showAnnoCls.enableHlSeq(),t.bAjaxCddSite=!0}setDomainFeature(e,t,s,i,n,l,r){let o,a,d,c=this.icn3d,h=c.icn3dui;s&&(r={},o={},a={},d={});let p=void 0!==e?e.length:0,m=s?14:19,u=s?100:120;for(let g=0;gm&&(v=v.substr(0,m)+"...");let _=b+": "+C;s&&(o[p]=C);let w=e[g].locs;if(w)for(let e=0,r=w.length;e'+v+" ",I=''+S.toString()+" Res";l+=R+I+"
    ";let T='';i+=R+I+T,s&&(n+='
    '),n+='
    '+v+"
    ",n+=I+T;let E=b+g.toString();c.seqStartLen&&c.seqStartLen[t]&&(i+=c.showSeqCls.insertMulGap(c.seqStartLen[t],"-"));for(let e=0,n=c.giSeq[t].length;e1&&(l=n[0]+"..");let r=c.ParserUtilsCls.getResi(t,e);if(i+=''+n+"",h.bNode){let e={};e[t+"_"+r]=_,s?c.resid2cdd[t].push(e):c.resid2site[t].push(e)}}else i+="-";c.seqStartLen&&c.seqStartLen[t]&&(i+=c.showSeqCls.insertMulGap(c.seqEndLen[t],"-"));let P=c.firstAtomObjCls.getFirstCalphaAtomObj(c.chains[t]),M=void 0===P.color||"FFFFFF"===P.color.getHexString()?"DDDDDD":P.color.getHexString(),D=void 0!==P.color?M:"CCCCCC";if(c.seqStartLen&&c.seqStartLen[t]&&(n+=c.showSeqCls.insertMulGapOverview(t,c.seqStartLen[t])),h.cfg.blast_rep_id!=t)for(let s=0,i=r.length;s ',n+='
    '+C+"
    "}else{let s=[],i=[];for(let e=0,t=r.length;e ',n+='
    '+C+"
    "}}T=' '+S.toString()+" Residues",T+="
    ",T+="
    ",i+=T,n+=T,s&&(n+='')}}return{html:i,html2:n,html3:l,acc2domain:r,pssmid2name:o,pssmid2fromArray:a,pssmid2toArray:d}}showAnnoType(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui,a='
    ',d=a,c=a;if(0==n.length)return $("#"+r.pre+"dt_"+s+"_"+e).html(""),$("#"+r.pre+"ov_"+s+"_"+e).html(""),void $("#"+r.pre+"tt_"+s+"_"+e).html("");let h=i;i.length>17&&(i=i.substr(0,17)+"...");let p=[];for(let e=0,t=n.length;e'+i+"
    ",f=''+m.toString()+" Res";c+=g+f+"
    ";let b='';a+=g+f+b,d+=g+f+b;let C=s,y=0,v=0;r.seqStartLen&&r.seqStartLen[e]&&(d+=r.showSeqCls.insertMulGapOverview(e,r.seqStartLen[e])),r.seqStartLen&&r.seqStartLen[e]&&(a+=r.showSeqCls.insertMulGap(r.seqStartLen[e],"-"));for(let t=0,i=r.giSeq[e].length;t1&&(c=n[0]+"..");let h=i,p=e+"_"+i,m=n+i;if("ssbond"==s){m="Residue "+p+" has disulfide bond with";let t="";if(void 0!==l[p])for(let e=0,s=l[p].length;e'+c+"",d+=r.showSeqCls.insertGapOverview(e,t);let u=o.cfg.blast_rep_id==e?Math.round(r.seqAnnWidth*t/(r.maxAnnoLength+r.nTotalGap)-y-v):Math.round(r.seqAnnWidth*t/r.maxAnnoLength-y-v);u>=0&&(d+='
     
    ',d+='
     
    ',y+=u,v+=1)}else a+="-"}r.seqStartLen&&r.seqStartLen[e]&&(a+=r.showSeqCls.insertMulGap(r.seqEndLen[e],"-")),b=' '+m.toString()+" Residues",b+="",b+="
    ",a+=b,d+=b,a+="",d+="",c+="",$("#"+r.pre+"dt_"+s+"_"+e).html(a),$("#"+r.pre+"ov_"+s+"_"+e).html(d),$("#"+r.pre+"tt_"+s+"_"+e).html(c)}setToolTip(){let e=this.icn3d;e.icn3dui,$("[id^="+e.pre+"snp]").add("[id^="+e.pre+"clinvar]").add("[id^="+e.pre+"ssbond]").add("[id^="+e.pre+"crosslink]").tooltip({content:function(){return $(this).prop("title")},show:null,close:function(e,t){t.tooltip.hover((function(){$(this).stop(!0).fadeTo(400,1)}),(function(){$(this).fadeOut("400",(function(){$(this).remove()}))}))}})}}class _t{constructor(e){this.icn3d=e}showInteraction(e,t){this.icn3d.icn3dui,this.showInteraction_base(e,t)}showInteraction_base(e,t){let s=this.icn3d,i=s.icn3dui;i.bNode&&(s.resid2contact||(s.resid2contact={}),s.resid2contact[e]||(s.resid2contact[e]=[])),void 0===s.chainname2residues&&(s.chainname2residues={});let n=Object.keys(s.chains),l=e,r=Math.round(l.indexOf("_"));if(s.firstAtomObjCls.getFirstCalphaAtomObj(s.chains[l]),void 0===s.chainname2residues[l]){s.chainname2residues[l]={};let t=n.length;if(t>100&&void 0===i.cfg.mmdbid&&void 0===i.cfg.gi&&void 0===i.cfg.blast_rep_id&&void 0===i.cfg.align&&void 0===i.cfg.chainalign)return $("#"+s.pre+"dt_interaction_"+e).html(""),void $("#"+s.pre+"ov_interaction_"+e).html("");for(let e=0;e4)continue;let o,a=s.firstAtomObjCls.getFirstCalphaAtomObj(s.chains[t]);s.chemicals.hasOwnProperty(a.serial)?o="chemical":s.nucleotides.hasOwnProperty(a.serial)?o="nucleotide":s.ions.hasOwnProperty(a.serial)?o="ion":s.proteins.hasOwnProperty(a.serial)?o="protein":s.water.hasOwnProperty(a.serial)&&(o="water");let d=s.contactCls.getAtomsWithinAtom(i.hashUtilsCls.hash2Atoms(s.chains[l],s.atoms),i.hashUtilsCls.hash2Atoms(s.chains[t],s.atoms),4);if(0==Object.keys(d).length)continue;let c={};for(let e in d){let t=s.atoms[e];c[t.structure+"_"+t.chain+"_"+t.resi]=1}let h=t.substr(t.indexOf("_")+1)+"("+o+")";s.chainname2residues[l][h]=Object.keys(c)}}let o='
    ',a=o,d=o,c=0;for(let t in s.chainname2residues[e]){let n=s.chainname2residues[e][t];if(!n)continue;let l="Interact ."+t;l.length>17&&(l=l.substr(0,17)+"...");let r="Interact ."+t,h=[];for(let e=0,t=n.length;e'+l+"
    ",g=''+p.toString()+" Res";d+=u+g+"
    ";let f='';o+=u+g+f,a+=u+g+f;let b="inter"+c.toString(),C=0,y=0,v=1;s.seqStartLen&&s.seqStartLen[e]&&(a+=s.showSeqCls.insertMulGapOverview(e,s.seqStartLen[e])),s.seqStartLen&&s.seqStartLen[e]&&(o+=s.showSeqCls.insertMulGap(s.seqStartLen[e],"-"));for(let t=0,n=s.giSeq[e].length;t1&&(d=l[0]+"..");let c=n;if(o+=''+d+"",i.bNode){let t={};t[e+"_"+c]=r,s.resid2contact[e].push(t)}a+=s.showSeqCls.insertGapOverview(e,t);let h=i.cfg.blast_rep_id==e?Math.round(s.seqAnnWidth*t/(s.maxAnnoLength+s.nTotalGap)-C-y):Math.round(s.seqAnnWidth*t/s.maxAnnoLength-C-y);h>=0&&(a+='
     
    ',a+='
     
    ',C+=h,y+=v)}else o+="-"}s.seqStartLen&&s.seqStartLen[e]&&(o+=s.showSeqCls.insertMulGap(s.seqEndLen[e],"-")),f=' '+p.toString()+" Residues",f+="
    ",f+="
    ",o+=f,a+=f,++c}o+="",a+="",d+="",$("#"+s.pre+"dt_interaction_"+e).html(o),$("#"+s.pre+"ov_interaction_"+e).html(a),$("#"+s.pre+"tt_interaction_"+e).html(d),i.utilsCls.isMobile()?(s.hlSeqCls.selectSequenceMobile(),s.hlSeqCls.selectChainMobile()):s.hlSeqCls.selectSequenceNonMobile()}}class wt{constructor(e){this.icn3d=e}async showPTM(e,t,s,i,n){let l=this.icn3d,r=l.icn3dui,o=this,a=e.substr(0,e.indexOf("_")),d=e.substr(e.indexOf("_")+1);if("afmem"==s){let t={Transmembrane:[{begin:i,end:n}]};this.setAnnoPtmTransmem("transmem",t,e)}else if(a.length>5){let t,i="https://www.ebi.ac.uk/proteins/api/features/"+a;try{t=await r.getAjaxPromise(i,"json"),o.parsePTM(t,e,s)}catch{return void o.getNoPTM(e,s)}}else{let t,i=a.substr(0,4).toLowerCase(),n="https://www.ebi.ac.uk/pdbe/api/mappings/uniprot/"+i;try{t=await r.getAjaxPromise(n,"json");let a="";l.UPResi2ResiPosPerChain||(l.UPResi2ResiPosPerChain={}),l.UPResi2ResiPosPerChain[e]={};let c=t[i].UniProt,h=!1;for(let t in c){let s=c[t].mappings;for(let i=0,n=s.length;i',o+=r,a+=r;let d=s.substr(0,s.indexOf("_"));for(let c in t){let h=t[c],p=[],m=!1;for(let e=0,t=h.length;e5?p.push(e-1):i.UPResi2ResiPosPerChain&&i.UPResi2ResiPosPerChain[s][e]&&p.push(i.UPResi2ResiPosPerChain[s][e]),!m&&i.residues.hasOwnProperty(s+"_"+e)&&(m=!0)}if(0==p.length)continue;let u=p.length,g="ptm"==e?"PTM: "+c:"Transmembrane";g.length>17&&(g=g.substr(0,17)+"...");let f=c,b='
    '+g+"
    ",C=''+u.toString()+" Res",y='';a+=b+C+"
    ",r+=b+C+y,o+=b+C+y;let v=e+l.toString(),_=0,w=0,S=1;i.seqStartLen&&i.seqStartLen[s]&&(o+=i.showSeqCls.insertMulGapOverview(s,i.seqStartLen[s])),i.seqStartLen&&i.seqStartLen[s]&&(r+=i.showSeqCls.insertMulGap(i.seqStartLen[s],"-"));for(let e=0,t=i.giSeq[s].length;e1&&(l=t[0]+"..");let a=i.ParserUtilsCls.getResi(s,e);if(r+=''+t+"",n.bNode){let e={};e[s+"_"+a]=g,i.resid2ptm[s].push(e)}o+=i.showSeqCls.insertGapOverview(s,e);let d=n.cfg.blast_rep_id==s?Math.round(i.seqAnnWidth*e/(i.maxAnnoLength+i.nTotalGap)-_-w):Math.round(i.seqAnnWidth*e/i.maxAnnoLength-_-w);d>=0&&(o+='
     
    ',o+='
     
    ',_+=d,w+=S)}else r+="-";i.seqStartLen&&i.seqStartLen[s]&&(r+=i.showSeqCls.insertMulGap(i.seqEndLen[s],"-")),y=' '+u.toString()+" Residues",y+="
    ",y+="
    ",r+=y,o+=y,++l}r+="",o+="",a+="",$("#"+i.pre+"dt_"+e+"_"+s).html(r),$("#"+i.pre+"ov_"+e+"_"+s).html(o),$("#"+i.pre+"tt_"+e+"_"+s).html(a)}getNoPTM(e,t){let s=this.icn3d;s.icn3dui,console.log("No PTM data were found for the chain "+e+"...");let i="ptm"==t?"ptm":"transmem";$("#"+s.pre+"dt_"+i+"_"+e).html(""),$("#"+s.pre+"ov_"+i+"_"+e).html(""),$("#"+s.pre+"tt_"+i+"_"+e).html(""),s.showAnnoCls.enableHlSeq(),s.bAjaxPTM=!0}}class St{constructor(e){this.icn3d=e}showCrosslink(e,t){let s=this.icn3d;s.icn3dui;let i=this;void 0===s.clbondpnts?setTimeout((function(){i.showCrosslink_base(e,t)}),1e3):this.showCrosslink_base(e,t)}showCrosslink_base(e,t){let s=this.icn3d;s.icn3dui.bNode&&(s.resid2crosslink||(s.resid2crosslink={}),s.resid2crosslink[e]||(s.resid2crosslink[e]=[]));let i=t,n={},l=i.substr(0,i.indexOf("_")),r=s.clbondpnts[l];if(void 0===r)return $("#"+s.pre+"dt_crosslink_"+e).html(""),$("#"+s.pre+"ov_crosslink_"+e).html(""),void $("#"+s.pre+"tt_crosslink_"+e).html("");for(let e=0,t=r.length;e',a=o,d=o,c=e.indexOf("_"),h=e.substr(c+1);if(h.length>1&&"1"==h.substr(h.length-1)&&(h=h.substr(0,h.length-1)),s)n=e,i=t.domains[e]?t.domains[e].domains:[];else{let e,s=t.moleculeInfor;for(let t in s)if(s[t].chain===h){e=t,n=s[t].name;break}void 0!==e&&void 0!==t.domains[e]&&(i=t.domains[e].domains),void 0===i&&(i=[])}for(let t=0,s=i.length;t17?s.substr(0,17)+"...":s,h=i[t].intervals,p={},m={},u=[],g=[],f={},b=0;for(let e=0,t=h.length;e'+c+" ",y=''+b.toString()+" Res";d+=C+y+"
    ";let v='';o+=C+y+v,a+=C+y+v;let _="domain3d"+t.toString();l.seqStartLen&&l.seqStartLen[e]&&(o+=l.showSeqCls.insertMulGap(l.seqStartLen[e],"-"));for(let t=0,s=l.giSeq[e].length;t1&&(n=i[0]+"..");let r=s;o+=''+i+""}else o+="-"}l.seqStartLen&&l.seqStartLen[e]&&(o+=l.showSeqCls.insertMulGap(l.seqEndLen[e],"-"));let w=l.firstAtomObjCls.getFirstCalphaAtomObj(l.chains[e]),S=void 0===w.color||"FFFFFF"===w.color.getHexString()?"DDDDDD":w.color.getHexString(),A=void 0!==w.color?S:"CCCCCC";if(l.seqStartLen&&l.seqStartLen[e]&&(a+=l.showSeqCls.insertMulGapOverview(e,l.seqStartLen[e])),r.cfg.blast_rep_id!=e)for(let i=0,n=u.length;i ',a+='"}else{let i=[],n=[];for(let e=0,t=u.length;e ',a+='"}}v=' '+b.toString()+" Residues",v+="",v+="
    ",o+=v,a+=v}o+="",a+="",d+="",$("#"+l.pre+"dt_domain_"+e).html(o),$("#"+l.pre+"ov_domain_"+e).html(a),$("#"+l.pre+"tt_domain_"+e).html(d)}}class xt{constructor(e){this.icn3d=e}async showSnp(e,t){this.icn3d.icn3dui,await this.showSnpClinvar(e,t,!0)}async showClinvar(e,t){this.icn3d.icn3dui,await this.showSnpClinvar(e,t,!1)}async showSnpClinvar(e,t,s){let i=this.icn3d.icn3dui,n=this,l=i.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainid="+t;try{let r=await i.getAjaxPromise(l,"jsonp"),o=r.snpgi,a=r.gi;if(s)await n.showSnpPart2(e,t,o);else{let s=o;[6137708,1942289,224510717,2624886,253723219,2554905,75765331,3660278,312207882,319443632,342350956,1827805,109157826,1065265,40889086,6730307,163931185,494469,163931091,60594093,55669745,18655489,17942684,6980537,166235465,6435586,4139398,4389047,364506122,78101667,262118402,20664221,2624640,158430173,494395,28948777,34810587,13399647,3660342,261278854,342350965,384482350,378792570,15988303,213424334,4558333,2098365,10835631,3318817,374074330,332639529,122919696,4389286,319443573,2781341,67464020,194709238,210061039,364506106,28949044,40889076,161172338,17943181,4557976,62738484,365813173,6137343,350610552,17942703,576308,223674070,15826518,1310997,93279697,4139395,255311799,157837067,361132363,357380836,146387678,383280379,1127268,299856826,13786789,1311054,46015217,3402130,381353319,30750059,218766885,340707375,27065817,355333104,2624634,62738384,241913553,304446010].includes(a)&&(s=a),await n.showClinvarPart2(e,t,s)}}catch(t){return void(s?n.processNoSnp(e):n.processNoClinvar(e))}}navClinVar(e){let t=this.icn3d;t.icn3dui;let s=this;t.currClin[e]=-1,$(document).on("click","#"+t.pre+e+"_prevclin",(function(t){let i=s.icn3d;t.stopImmediatePropagation();let n=void 0!==i.resi2disease_nonempty[e]?Object.keys(i.resi2disease_nonempty[e]).length:0;--i.currClin[e],i.currClin[e]<0&&(i.currClin[e]=n-1),s.showClinVarLabelOn3D(e)})),$(document).on("click","#"+t.pre+e+"_nextclin",(function(t){let i=s.icn3d;t.stopImmediatePropagation();let n=void 0!==i.resi2disease_nonempty[e]?Object.keys(i.resi2disease_nonempty[e]).length:0;++i.currClin[e],i.currClin[e]>n-1&&(i.currClin[e]=0),s.showClinVarLabelOn3D(e)}))}showClinVarLabelOn3D(e){let t,s,i=this.icn3d,n=i.icn3dui,l=Object.keys(i.resi2disease_nonempty[e]);t=e,s=t+"_"+(parseInt(l[i.currClin[e]])+i.baseResi[e]).toString();let r="",o=i.resi2disease_nonempty[e][l[i.currClin[e]]];for(let e=0,t=o.length;e0?o[0]:"N/A");let a=i.applyCenterCls.centerAtoms(n.hashUtilsCls.hash2Atoms(i.residues[s],i.atoms));r.length>30&&(r=r.substr(0,30)+"..."),i.selectionCls.removeSelection(),null==i.labels&&(i.labels={}),i.labels.clinvar=[];let d=i.LABELSIZE,c="black"!=i.opts.background?i.colorWhitebkgd:i.colorBlackbkgd;i.analysisCls.addLabel(r,a.center.x+1,a.center.y+1,a.center.z+1,d,c,void 0,"clinvar"),i.hAtoms={};for(let e in i.residues[s])i.hAtoms[e]=1;$("#clinvar_"+i.pre+s).addClass("icn3d-highlightSeq"),void 0===$("#"+i.pre+"modeswitch")[0]||$("#"+i.pre+"modeswitch")[0].checked||i.definedSetsCls.setMode("selection"),i.drawCls.draw()}getSnpLine(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g){let f=this.icn3d,b=f.icn3dui,C="",y=m?"clinvar":"snp",v=!1;for(let e in i){for(let t=0,s=i[e].length;t(from human)",i=" (based on human sequences and mapped to this structure by sequence similarity)"),C+=m?'":'"}else if(2==e&&m){let e=b.utilsCls.isMobile()?"none":"button";C+='
    ',C+='
    '}else C+='
    ';let _=y,w=0,S=0,A={},x={};for(let t=1,i=f.giSeq[h].length;t<=i;++t)if(void 0!==r[t]){++w;let i="";for(let n=0,r=s[t].length;n'+k+" Res":'',u)return C+"
    ";C+='';let O="",R=0,I=0;p?f.seqStartLen&&f.seqStartLen[h]&&(C+=f.showSeqCls.insertMulGapOverview(h,f.seqStartLen[h])):f.seqStartLen&&f.seqStartLen[h]&&(C+=f.showSeqCls.insertMulGap(f.seqStartLen[h],"-"));for(let t=1,a=f.giSeq[h].length;t<=a;++t)if(p){if(void 0!==r[t]){let e=f.giSeq[h][t-1],i=e;e.length>1&&(i=e[0]+"..");let n=f.ParserUtilsCls.getResi(h,t-1)+i+">";for(let e=0,i=s[t].length;e=0&&(C+='
     
    ',C+='
     
    ',R+=r,I+=1):r>0&&(C+='
     
    ',C+='
     
    ',R+=r,I+=1)}}else if(C+=f.showSeqCls.insertGap(h,t-1,"-"),void 0!==r[t])if(m||1!=e){let r=f.giSeq[h][t-1],a=r;r.length>1&&(a=r[0]+"..");let d,c=f.ParserUtilsCls.getResi(h,t-1),p="",u="
    ",y=s[t].length,v=0,w=0;if(2==e&&(v=0,w=y),m){d=1;let r=0;for(let e=v;e0?w+="; ":0!==e&&1!==e||(O='disease="'+v[t]+'"'),w+=v[t]+"("+_[t]+")",++S;""!=w&&(r"+s[t][e],u+=": "+w,C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(m,"snpin3d","3D with scap","SNP in 3D with scap",70,g)+"  ",u+=f.showAnnoCls.addSnpButton(m,"snpinter","Interactions","SNP Interactions in 3D",70,g)+"  ",u+=f.showAnnoCls.addSnpButton(m,"snppdb","PDB","Download SNP PDB",35,g)),u+="
    Links: ClinVar, dbSNP(rs"+i[t][e]+")",e
    "),++r)}r>d&&2==e&&(p+="..")}else{d=1;for(let e=v;e"+s[t][e],g)C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),0!=i[t][e]&&(u+="
    Link: dbSNP(rs"+i[t][e]+")"),e
    ");else{let s=l[t][e].split("; "),a=o[t][e].split("; "),d="",c=0;for(let t=0,i=s.length;t0?d+="; ":0!==e&&1!==e||(O='disease="'+s[t]+'"'),d+=s[t]+"("+a[t]+")",++c;""!=d?(u+=": "+d,C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),u+="
    Links: ClinVar, dbSNP(rs"+i[t][e]+")"):(C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),u+="
    Link: dbSNP(rs"+i[t][e]+")"),e
    ")}}y>d&&2==e&&(p+="..")}u+="
    ",m?"icn3d-clinvar"==A[t]||"icn3d-clinvar-path"==A[t]?C+=1==e?"":""==p||" "==p?"-":''+p+"":C+="-":C+=""==p||" "==p?"-":g?''+p+"":''+p+""}else C+="";else C+="-";return p||f.seqStartLen&&f.seqStartLen[h]&&(C+=f.showSeqCls.insertMulGap(f.seqEndLen[h],"-")),C+=1==e?' '+k+" Residues":'',C+="
    ",C+="
    ",C}processSnpClinvar(e,t,s,i,n){let l=this.icn3d,r=l.icn3dui,o='
    ',a=o,d=o,c='
    ',h=c,p=c,m=!i||n?e.data:e.split("\n"),u={},g={},f={};void 0===l.resi2disease_nonempty[t]&&(l.resi2disease_nonempty[t]={});let b={},C={},y={},v={},_={},w="";r.bNode&&(i?(l.resid2snp||(l.resid2snp={}),l.resid2snp[t]||(l.resid2snp[t]=[])):(l.resid2clinvar||(l.resid2clinvar={}),l.resid2clinvar[t]||(l.resid2clinvar[t]=[])));for(let e=0,s=m.length;e")+1),h=s[4],p=i?"":s[5],S=i?"":s[6],A=i?"":s[7],x=l.ParserUtilsCls.getResi(t,d-1);v[x]=1,""!=S&&(_[x]=1),g[d]=e+1,void 0===u[d]&&(u[d]=[]),u[d].push(c),void 0===C[d]&&(C[d]=[]),C[d].push(h),void 0===y[d]&&(y[d]=[]),y[d].push(p),void 0===f[d]&&(f[d]=[]),f[d].push(S),""!=S&&(void 0===l.resi2disease_nonempty[t][d]&&(l.resi2disease_nonempty[t][d]=[]),l.resi2disease_nonempty[t][d].push(S)),void 0===b[d]&&(b[d]=[]),b[d].push(A)}let S=Object.keys(v),A=Object.keys(_);if(i){let e=!1;o+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,void 0,i),o+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,void 0,i),d+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,!0,i),d+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,!0,i),a+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!0,e,void 0,i),o+="
    ",a+="
    ",d+="",$("#"+l.pre+"dt_snp_"+t).html(o),$("#"+l.pre+"ov_snp_"+t).html(a),$("#"+l.pre+"tt_snp_"+t).html(d)}else{let e=!0;c+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,void 0,i),c+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,void 0,i),p+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,!0,i),p+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,!0,i),h+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!0,e,void 0,i),c+="",h+="",p+="",$("#"+l.pre+"dt_clinvar_"+t).html(c),$("#"+l.pre+"ov_clinvar_"+t).html(h),$("#"+l.pre+"tt_clinvar_"+t).html(p),this.navClinVar(t,s)}l.showAnnoCls.enableHlSeq(),i?l.bAjaxSnp=!0:l.bAjaxClinvar=!0}async showClinvarPart2(e,t,s){let i=this.icn3d,n=i.icn3dui,l=this,r=n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainid_clinvar="+t;i.chainsGene[e]&&i.chainsGene[e].geneSymbol&&(r+="&gene="+i.chainsGene[e].geneSymbol);try{let s=await n.getAjaxPromise(r,"jsonp");if(s&&s.data&&s.data.length>0){let i=!1,n=s;l.processSnpClinvar(n,e,t,i)}else l.processNoClinvar(e)}catch(t){return void l.processNoClinvar(e)}}async showSnpPart2(e,t,s){let i=this.icn3d,n=i.icn3dui,l=this;if(void 0!==s){let s=n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainid_snp="+t;i.chainsGene[e]&&i.chainsGene[e].geneSymbol&&(s+="&gene="+i.chainsGene[e].geneSymbol);try{let i=await n.getAjaxPromise(s,"jsonp");if(i&&i.data&&i.data.length>0){let s=!0,n=!0;l.processSnpClinvar(i,e,t,s,n)}else l.processNoSnp(e)}catch(t){return void l.processNoSnp(e)}}else this.processNoSnp(e),console.log("No gi was found for the chain "+t+"...")}processNoClinvar(e){let t=this.icn3d;t.icn3dui,console.log("No ClinVar data were found for the protein "+e+"..."),$("#"+t.pre+"dt_clinvar_"+e).html(""),$("#"+t.pre+"ov_clinvar_"+e).html(""),t.showAnnoCls.enableHlSeq(),t.bAjaxClinvar=!0}processNoSnp(e){let t=this.icn3d;t.icn3dui,console.log("No SNP data were found for the protein "+e+"..."),$("#"+t.pre+"dt_snp_"+e).html(""),$("#"+t.pre+"ov_snp_"+e).html(""),t.showAnnoCls.enableHlSeq(),t.bAjaxSnp=!0}}class kt{constructor(e){this.icn3d=e}showSsbond(e,t){let s=this.icn3d;s.icn3dui;let i=this;void 0===s.ssbondpnts?setTimeout((function(){i.showSsbond_base(e,t)}),1e3):this.showSsbond_base(e,t)}showSsbond_base(e,t){let s=this.icn3d;s.icn3dui.bNode&&(s.resid2ssbond||(s.resid2ssbond={}),s.resid2ssbond[e]||(s.resid2ssbond[e]=[]));let i=t,n={},l=i.substr(0,i.indexOf("_")),r=s.ssbondpnts[l];if(void 0===r)return $("#"+s.pre+"dt_ssbond_"+e).html(""),$("#"+s.pre+"ov_ssbond_"+e).html(""),void $("#"+s.pre+"tt_ssbond_"+e).html("");for(let e=0,t=r.length;e-s.halfBilayerSize){i[t.structure+"_"+t.chain+"_"+t.resi]=1}}let n=Object.keys(i);s.annoCddSiteCls.showAnnoType(e,t,"transmem","Transmembrane",n)}}class Rt{constructor(e){this.icn3d=e,this.dcut=8,this.MAX_SSE=512,this.ctc_cnt=[];for(let e=0;e=this.curr_ratio+.01||f>this.split_ratio)return e;if(f>this.curr_ratio-.01&&Math.min(m,u)=0&&l[i]==t-e+i;i--);if(i<0)break;for(l[i]++,s=i+1;s-1;i++);for(l=Math.min(i-1,this.max_csz),this.curr_ne0=this.curr_ne1=0,this.curr_ratio=100,s=1;s<=l;s++)this.cut_size(s,i);if(this.top--,0==this.curr_ne0){for(n=this.stack[this.top],e=n;e-1;e++)this.parts[this.np++]=this.elements[e];this.parts[this.np++]=-1,this.n_doms++}else{if(this.save_ratios[this.saved++]=this.curr_ratio,this.curr_ne0>this.min_sse){for(n=this.stack[this.top],e=0;ethis.min_sse){for(n=this.stack[this.top],e=0;e0;)this.process_set()}output(e){let t,s;this.icn3d.icn3dui;let i=[];for(t=0;t<2*e;t++)i.push(0);for(t=s=0;st+n)break;let p=(t-a)*(t-a);p+=(s-c)*(s-c),p+=(i-h)*(i-h);let m=Math.sqrt(p);if(m>n)continue;let u={},g={};parseInt(e.rnum)this.MAX_SSE)return{subdomains:a,substruct:o,pos2resi:u};let f=h.length,b=f,C=this.c2b_AlphaContacts(f,i,n,l,t,r),y=[];for(let e=0;e=this.min_contacts&&(k[s]||(k[s]={}),k[i]||(k[i]={}),k[s][i]=1,k[i][s]=1)}let O=0,R={};this.groupnum2sheet={},this.visited={};for(let e in k)this.visited[e]=!1;for(let e in k)0==this.visited[e]&&(O++,this.countUtil(e,k,O));for(let e in this.groupnum2sheet){let t=this.groupnum2sheet[e].sort();for(let e=0,s=t.length;e0&&this.elt_size[s.sse-1]>=6&&0!=s.adj_strand2&&e++}for(let e=0;e0)for(let e=0;e0){let e=0;for(let t=0;t<=T;t++){let t=[];for(;e<2*g;){let s=this.parts[e++];if(0==s){E.push(t);break}t.push(s)}}}E.sort((function(e,t){return e[0]-t[0]}));for(let e=0,t=E.length;e=o.length)return{subdomains:a,substruct:o,pos2resi:u};let n=o[i],l=n.From,r=n.To;for(let e=l;e<=r;e++)s[e]=1;if(0==i&&l>1)for(let e=1;e0){let e=o[i-1].To,t=parseInt(.5*(l-e-1));if(t>0)for(let e=l-t;e<=l-1;e++)s[e]=1}if(i0)for(let e=r+1;e<=r+t;e++)s[e]=1}}let i,n=!1,l=[];for(let e=0;e0&&(h+=", "),h+='{"ss": [';let t=0;for(let i=0,n=l[e].length;i=n&&m<=a&&(t>0&&(h+=", "),h+="["+i+","+p+","+m+","+r[e].x1.toFixed(2)+","+r[e].y1.toFixed(2)+","+r[e].z1.toFixed(2)+","+r[e].x2.toFixed(2)+","+r[e].y2.toFixed(2)+","+r[e].z2.toFixed(2)+"]",++t))}}h+="]",h+=', "domain": [';let n=0;for(let t=0,r=l[e].length;t=r&&l<=o&&(n>0&&(h+=", "),h+="["+l+","+c+","+a.coord.x.toFixed(2)+","+a.coord.y.toFixed(2)+","+a.coord.z.toFixed(2)+"]",++n)}}h+="]}"}return h+="]}",h}}class It{constructor(e){this.icn3d=e}clickAddTrackButton(){let e=this.icn3d,t=e.icn3dui,s=this;t.myEventCls.onIds("#"+e.pre+"addtrack_button1","click",(async function(e){let i=s.icn3d;e.stopImmediatePropagation(),dialog.dialog("close");let n=$("#"+i.pre+"track_chainid").val(),l=$("#"+i.pre+"track_gi").val(),r=isNaN(l)?"Acc "+l:"gi "+l,o=t.htmlCls.baseUrl+"pwaln/pwaln.fcgi?from=track",a={targets:n,queries:l},d=await t.getAjaxPostPromise(o,a);s.alignSequenceToStructure(n,d,r)})),t.myEventCls.onIds("#"+e.pre+"addtrack_button2","click",(async function(e){let i=s.icn3d;e.stopImmediatePropagation(),dialog.dialog("close");let n=$("#"+i.pre+"track_chainid").val(),l=$("#"+i.pre+"track_fasta").val(),r=$("#"+i.pre+"fasta_title").val(),o=n.substr(0,n.indexOf("_")),a=n;if(5==o.length)a=a.substr(0,4);else if(o.length>5){a="";for(let e=0,t=i.chainsSeq[n].length;e8||d.length<6)&&(a=!1),d.length<9&&(o=!1),d[0];let c,h,p=d[1],m=d[2],u=d[3];d.length,d.length>5&&(c=d[5]),d.length,d.length,d.length>8&&(h=d[8]),d.length,d.length,d.length;let g=u,f="51,51,51";o?f=h:a&&("+"==c&&l.length>0?f=l[0]:"-"==c&&l.length>1?f=l[1]:"."==c&&l.length>2&&(f=l[2]));let b="",C=[];for(let e=0,t=m;e1&&(s=t[0]);let l=i.ParserUtilsCls.getResi(n,e);if(a.hasOwnProperty(n+"_"+l)){let e=i.firstAtomObjCls.getFirstCalphaAtomObj(i.residues[n+"_"+l]),t=void 0===e.color||"FFFFFF"===e.color.getHexString().toUpperCase()?"DDDDDD":e.color.getHexString(),o=void 0!==e.color?t:"CCCCCC";r+=s,d.push("#"+o)}else r+="-",d.push("")}s.showNewTrack(n,l,r,d,void 0,"selection",void 0),t.htmlCls.clickMenuCls.setLogCmd("add track | chainid "+n+" | title "+l+" | text "+s.simplifyText(r)+" | type selection",!0)}))}showNewTrack(e,t,s,i,n,l,r,o,a,d,c,h){let p=this.icn3d,m=p.icn3dui,u=!1;"cannot be aligned"==s&&(u=!0);let g=s.replace(/-/g,"").length;if(!o)if(s.length>p.giSeq[e].length)s=s.substr(0,p.giSeq[e].length);else if(s.length20&&(f=f.substr(0,20));let b=m.htmlCls.RESIDUE_WIDTH*s.length+200;$("#"+p.pre+"dt_custom_"+e).append("
    "),$("#"+p.pre+"dt_custom_"+e+"_"+f).width(b),$("#"+p.pre+"ov_custom_"+e).append("
    "),$("#"+p.pre+"ov_custom_"+e+"_"+f).width(b),$("#"+p.pre+"tt_custom_"+e).append("
    "),$("#"+p.pre+"tt_custom_"+e+"_"+f).width(b);let C='
    ',y=C,v=C,_=C,w=C,S=parseInt(10*Math.random()),A='",x='
    Exons
    ',k=''+g.toString()+" Pos";_+=A+k+"
    ",w+=x+k+"
    ";let O='';C+=A+k+O,y+=x+k+O,v+=A+k+O;let R=e.indexOf("_"),I="cst"+e.substr(R+1),T=0,E=0,P=(void 0===l||"seq"===l||"custom"===l)&&-1==s.indexOf("cannot-be-aligned")&&-1==s.indexOf("cannot be aligned"),M="identity"===l&&-1==s.indexOf("cannot-be-aligned")&&-1==s.indexOf("cannot be aligned"),D={},H=0;A="";let F={},L={},N={},q=0;if(h)for(let e=0,t=h.length;e"+d+"";let g='style="background-color:'+F[q]+'"';y+=' ";for(let t in p.residues[e+"_"+u]){let e=p.atoms[t];e.color=m.parasCls.thr(F[q]),p.atomPrevColors[t]=e.color}A+=p.showSeqCls.insertGapOverview(e,t);let f=Math.round(p.seqAnnWidth*t/(p.maxAnnoLength+p.nTotalGap)-T-E);f<0&&(f=0),A+='
     
    ',s=void 0!==i&&""!=i[t]?i[t]:r?"rgb("+r+")":P?"#"+c:"#333",A+='
     
    ',T+=f,E+=1,++q}else u?C+=""+d+"":(C+="-",y+="")}if(void 0!==a){A="";let s=[],i=[];for(let e=0,t=a.length;e 
    ',h){let t,s;n=d[l]-a[l]+1;let i,r,o,c=m,p=m+n-1;m+=n;for(let e=0,i=h.length;e=i&&c<=n&&(t={exonIndex:e,rangeStart:i,rangeEnd:n,from:c,genomeRange:h[e].genomeRange}),p>=i&&p<=n&&(s={exonIndex:e,rangeStart:i,rangeEnd:n,to:p,genomeRange:h[e].genomeRange})}if(t&&s&&t.exonIndex==s.exonIndex)i=this.getExonColor(t.rangeStart,t.rangeEnd,c),r=this.getExonColor(t.rangeStart,t.rangeEnd,p),o=i+" 0%, #FFF 50%, "+r+" 100%",A+=this.getExonHtml(t.exonIndex,o,t.from,s.to,t.genomeRange,e,f);else if(t&&(i=this.getExonColor(t.rangeStart,t.rangeEnd,c),o=i+" 0%, #FFF 50%, #00F 100%",A+=this.getExonHtml(t.exonIndex,o,t.from,t.rangeEnd,t.genomeRange,e,f)),t&&s){for(let i=t.exonIndex+1;i'+t+""}}O=''+g.toString()+" Pos",O+="",O+="
    ",O+="",C+=O,v+=A+O,y+=O,_+="",w+="",h?($("#"+p.pre+"dt_custom_"+e+"_"+f).html(y+C),$("#"+p.pre+"ov_custom_"+e+"_"+f).html(v),$("#"+p.pre+"tt_custom_"+e+"_"+f).html(w+_)):($("#"+p.pre+"dt_custom_"+e+"_"+f).html(C),$("#"+p.pre+"ov_custom_"+e+"_"+f).html(v),$("#"+p.pre+"tt_custom_"+e+"_"+f).html(_))}getExonHtml(e,t,s,i,n,l,r){let o=this.icn3d;return o.icn3dui,''}getExonColor(e,t,s){this.icn3d.icn3dui;let i=.5*(e+t);if(s1e-200&&(h=parseFloat(h).toExponential()),n.scores.bit_score;let p=t.targets[l].seqdata,m=i.seqdata,u=n.segs;for(let e=0,t=u.length;e0&&(l=n+"H"+d.toString().padStart(2,"0")+")","coil"==t&&(s.selectionCls.selectResidueList(r,l,l,o,a),o||(o=!0)),r={})),n=e+"_H"+d.toString().padStart(2,"0"),r[p]=1,i.ssend&&(h=e+"_C(H"+d.toString().padStart(2,"0"),"helix"==t&&(s.selectionCls.selectResidueList(r,n,n,o,a),o||(o=!0)),r={})):"E"==m?(i.ssbegin&&(++c,Object.keys(r).length>0&&(l=n+"S"+c.toString().padStart(2,"0")+")","coil"==t&&(s.selectionCls.selectResidueList(r,l,l,o,a),o||(o=!0)),r={})),n=e+"_S"+c.toString().padStart(2,"0"),r[p]=1,i.ssend&&(h=e+"_C(S"+c.toString().padStart(2,"0"),"sheet"==t&&(s.selectionCls.selectResidueList(r,n,n,o,a),o||(o=!0)),r={})):(n=h+"-",r[p]=1)}}Object.keys(r).length>0&&(l=n+"Cterm)","coil"==t&&s.selectionCls.selectResidueList(r,l,l,o,a))}defineIgstrand(e,t){let s=this.icn3d,i=s.icn3dui;$("#"+s.pre+"dl_definedsets").hasClass("ui-dialog-content")&&$("#"+s.pre+"dl_definedsets").dialog("isOpen")||(i.htmlCls.dialogCls.openDlg("dl_definedsets","Select sets"),$("#"+s.pre+"atomsCustom").resizable());let n,l,r,o,a,d={},c=!1,h=!0,p=0,m=0,u="NT";s.hAtoms={};let g=!1;for(let i=0,f=s.chainsSeq[e].length;i0&&("igstrand"==a?(++p,n="Strand-"+r+"-"+e+"-"+p.toString().padStart(3,"0"),n=n.replace(/'/g,"`"),"igstrand"==t&&(s.selectionCls.selectResidueList(d,n,n,c,h),c||(c=!0)),u=r):"igloop"==a&&(++m,n="Loop-"+u+"_"+l+"-"+e+"-"+m.toString().padStart(3,"0"),n=n.replace(/'/g,"`"),"igloop"==t&&(s.selectionCls.selectResidueList(d,n,n,c,h),c||(c=!0))),d={}),d[C]=1,r=l,a=o,g=!0))}"igstrand"==a?(++p,n="Strand-"+r+"-"+e+"-"+p.toString().padStart(3,"0"),n=n.replace(/'/g,"`"),"igstrand"==t&&s.selectionCls.selectResidueList(d,n,n,c,h)):"igloop"==a&&(++m,l="CT",n="Loop-"+u+"_"+l+"-"+e+"-"+m.toString().padStart(3,"0"),n=n.replace(/'/g,"`"),"igloop"==t&&s.selectionCls.selectResidueList(d,n,n,c,h))}simplifyText(e){this.icn3d.icn3dui;let t,s,i="",n=!1,l=-1;for(t=0,s=(e=e.replace(/undefined/g," ")).length;t20)return!1;if(void 0!==o.giSeq&&void 0!==o.giSeq[e]){let r=this.getFullText(s);return s=r.text,this.showNewTrack(e,t,s,void 0,void 0,i,n,l),!1}setTimeout((function(){a.checkGiSeq(e,t,s,i,n,l,r+1)}),100)}getFullText(e){this.icn3d.icn3dui;let t="",s=[],i=[],n=e.split(","),l=-1;for(let e=0,r=n.length;ep?t+=c.substr(0,p):t+=c;for(let e=0;ed&&(d=t.length,c=h),++h}o=n.htmlCls.baseUrl+"pwaln/pwaln.fcgi?from=msa";let p=e.split(","),m={};m[t]=0;for(let e=0,t=p.length;e0&&(g+=","+p.join(","));let f={targets:u,queries:g},b=await n.getAjaxPostPromise(o,f);if(!b.data)return void console.log("The protein accessions "+u+","+g+" can not be aligned...");let C=[];i.qt_start_end={};let y=[],v=[],_=Object.keys(b.targets)[0],w=b.targets[_].seqdata;p.splice(0,0,t);for(let e=0,s=p.length;eA&&(A=e)}let x=S,k=w.length-(A+1),O=[],R=[];for(let e=0,t=p.length;ea&&(a=t.length,d=c),++c}s.qt_start_end={};let m="genomeRes",u={};for(let e=0,i=h.length;ef&&(f=e)}for(let e=0,t=h.length;e0&&(d=h,o.targetGapHash[a+o.startposGiSeq]={from:a+o.startposGiSeq,to:d+m-1+o.startposGiSeq}),c=t[s],h=p,"-"!=t[s]?(++p,f=s,o.seqEndLen[e]=b-1-f,u||(g=s,o.seqStartLen[e]=g,u=!0)):++m;o.maxAnnoLength0&&(C+=" "),C+=e+"_"+o.targetGapHash[e].from+"_"+o.targetGapHash[e].to,++y;let v={};for(let a=0,d=i.length;a5?(l.uniprot2acc&&l.uniprot2acc[y]&&(y=l.uniprot2acc[y]),f=y):f=e,y.length>5){let e="";for(let t=0,s=l.chainsSeq.length;t"),d=a[1].indexOf("\n");n=a[1].substr(d+1).replace(/\n/g,"");for(let e=2,t=a.length;e0&&($("#"+e.pre+"anno_cdd")[0].checked?(this.setAnnoTabCdd(),t.htmlCls.clickMenuCls.setLogCmd("set annotation cdd",!0)):(this.hideAnnoTabCdd(),t.htmlCls.clickMenuCls.setLogCmd("hide annotation cdd",!0)))}showAnnoSelectedChains(){let e=this.icn3d,t=e.icn3dui,s={};for(let t in e.hAtoms){let i=e.atoms[t];s[i.structure+"_"+i.chain]=1}$("#"+e.pre+"dl_annotations > .icn3d-annotation").hide();for(let i in s){$("#"+e.pre+"anno_"+i).length&&$("#"+e.pre+"anno_"+i).show();let s=e.firstAtomObjCls.getFirstCalphaAtomObj(e.chains[i]);if(void 0!==s.resn){let i=t.utilsCls.residueName2Abbr(s.resn.substr(0,3));$("#"+e.pre+"anno_"+i).show()}}}showAnnoAllChains(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"dl_annotations > .icn3d-annotation").show()}setAnnoView(e){let t=this.icn3d;t.icn3dui.bNode||("detailed view"===e?(t.view="detailed view",$("#"+t.pre+"dl_anno_view_tabs").tabs("option","active",1)):(t.view="overview",$("#"+t.pre+"dl_anno_view_tabs").tabs("option","active",0)))}setAnnoDisplay(e,t){let s=this.icn3d;s.icn3dui;let i=["giseq","custom","site","ptm","snp","clinvar","cdd","domain","interaction","ssbond","crosslink","transmem"];for(let n in i){let l=i[n];$("[id^="+s.pre+t+"_"+l+"]").attr("style",e)}}showFixedTitle(){this.icn3d.icn3dui;this.setAnnoDisplay("display:block;","tt")}hideFixedTitle(){this.icn3d.icn3dui;this.setAnnoDisplay("display:none!important;","tt")}setAnnoViewAndDisplay(e){let t=this.icn3d;if(t.icn3dui,"detailed view"===e){this.setAnnoView("detailed view");let e="display:block;";this.setAnnoDisplay(e,"dt"),$("#"+t.pre+"seqguide_wrapper").attr("style",e),e="display:none;",this.setAnnoDisplay(e,"ov")}else{this.setAnnoView("overview"),this.hideFixedTitle();let e="display:none;";this.setAnnoDisplay(e,"dt"),$("#"+t.pre+"seqguide_wrapper").attr("style",e),e="display:block;",this.setAnnoDisplay(e,"ov")}}async updateClinvar(){let e=this.icn3d;if(e.icn3dui,void 0===e.bClinvarShown||!e.bClinvarShown)for(let t in e.protein_chainid){let s=e.protein_chainid[t];await e.annoSnpClinVarCls.showClinvar(t,s)}e.bClinvarShown=!0}async updateSnp(){let e=this.icn3d;if(e.icn3dui,void 0===e.bSnpShown||!e.bSnpShown)for(let t in e.protein_chainid){let s=e.protein_chainid[t];await e.annoSnpClinVarCls.showSnp(t,s)}e.bSnpShown=!0}updateDomain(){let e=this.icn3d;e.icn3dui,void 0!==e.bDomainShown&&e.bDomainShown||e.annoDomainCls.showDomainAll(),e.bDomainShown=!0}updateInteraction(){let e=this.icn3d;if(e.icn3dui,void 0===e.bInteractionShown||!e.bInteractionShown)for(let t in e.interactChainbase){let s=e.interactChainbase[t];e.annoContactCls.showInteraction(t,s)}e.bInteractionShown=!0}async updatePTM(){let e=this.icn3d;if(e.icn3dui,void 0===e.bPTMShown||!e.bPTMShown)for(let t in e.PTMChainbase){let s=e.PTMChainbase[t];await e.annoPTMCls.showPTM(t,s,"ptm")}e.bPTMShown=!0}updateSsbond(){let e=this.icn3d;if(e.icn3dui,void 0===e.bSSbondShown||!e.bSSbondShown)for(let t in e.ssbondChainbase){let s=e.ssbondChainbase[t];e.annoSsbondCls.showSsbond(t,s)}e.bSSbondShown=!0}updateCrosslink(){let e=this.icn3d;if(e.icn3dui,void 0===e.bCrosslinkShown||!e.bCrosslinkShown)for(let t in e.crosslinkChainbase){let s=e.crosslinkChainbase[t];e.annoCrossLinkCls.showCrosslink(t,s)}e.bCrosslinkShown=!0}async updateTransmem(){let e=this.icn3d,t=e.icn3dui;if(void 0===e.bTranememShown||!e.bTranememShown)for(let s in e.protein_chainid){let i=e.protein_chainid[s];if(void 0!==t.cfg.opmid)e.annoTransMemCls.showTransmem(s,i);else if(e.bAfMem&&e.afmem_start_end){let t=e.afmem_start_end[0],n=e.afmem_start_end[1];await e.annoPTMCls.showPTM(s,i,"afmem",t,n)}else await e.annoPTMCls.showPTM(s,i,"transmem")}e.bTranememShown=!0}}class Et{constructor(e){this.icn3d=e}showAnnotations_part1(){let e=this.icn3d,t=e.icn3dui;if(t.htmlCls.dialogCls.openDlg("dl_selectannotations","Sequences and Annotations"),(void 0===e.bAssemblyNote||!e.bAssemblyNote)&&void 0!==e.asuCnt){let t="
    Assembly Tips: Only the asymmetric unit is shown in the sequence window.
    Click \"Assembly\" in the menu \"View\" to switch between asymmetric unit and biological assembly("+e.asuCnt+" asymmetric unit).
    ";$("#"+e.pre+"dl_annotations_tabs").append(t),e.bAssemblyNote=!0}e.bResetAnno&&(e.giSeq={},e.currClin={},e.resi2disease_nonempty={},e.baseResi={},e.matchedPos={},$("#"+t.pre+"dl_annotations").empty(),e.annotationCls.setAnnoView("overview"));let s={},i={},n={};if(void 0===e.bAnnoShown||!e.bAnnoShown||e.bResetAnno){e.protein_chainid={};let l,r=Object.keys(e.chains);void 0===e.giSeq&&(e.giSeq={}),void 0===e.currClin&&(e.currClin={}),void 0===e.resi2disease_nonempty&&(e.resi2disease_nonempty={}),void 0===e.baseResi&&(e.baseResi={}),void 0===e.matchedPos&&(e.matchedPos={}),l=t.bNode?500:t.cfg.notebook?t.htmlCls.WIDTH/2:$("#"+e.pre+"dl_selectannotations").dialog("option","width"),e.seqAnnWidth=l-120-60-50;for(let l=0,o=r.length;l1&&"1"==d.substr(d.length-1)?(d=d.substr(0,d.length-1),a=r[l].substr(0,r[l].indexOf("_"))+"_"+d):a=r[l],e.proteins.hasOwnProperty(o.serial)&&e.chainsSeq[r[l]].length>1)e.protein_chainid[r[l]]=a;else if(e.nucleotides.hasOwnProperty(o.serial)&&e.chainsSeq[r[l]].length>1)s[r[l]]=a;else if(e.chainsSeq[r[l]].length>1)i[r[l]]=a;else{let t=e.chainsSeq[r[l]][0].name,s=r[l]+"_"+e.chainsSeq[r[l]][0].resi;void 0===n[t]&&(n[t]=[]),n[t].push(s)}if((void 0!==t.cfg.pdbid||void 0!==t.cfg.opmid||void 0!==t.cfg.mmcifid||void 0!==t.cfg.mmtfid)&&(e.proteins.hasOwnProperty(o.serial)||e.nucleotides.hasOwnProperty(o.serial)))for(let t=0,s=e.chainsSeq[r[l]].length;te.maxAnnoLengthOri&&(e.protein_chainid.hasOwnProperty(t)||s.hasOwnProperty(t))&&(e.maxAnnoLengthOri=e.chainsSeq[t].length);e.maxAnnoLength=e.maxAnnoLengthOri}return{nucleotide_chainid:s,chemical_chainid:i,chemical_set:n}}async showAnnotations(){let e=this.icn3d,t=e.icn3dui,s=this,i=this.showAnnotations_part1(),n=i.nucleotide_chainid,l=i.chemical_chainid,r=i.chemical_set;if(!e.bAnnoShown||e.bResetAnno)if(e.bAnnoShown=!0,void 0===t.cfg.blast_rep_id){if(e.bFullUi){if(void 0!==t.cfg.mmtfid){let t=Object.keys(e.structures)[0];await e.mmcifParserCls.downloadMmcifSymmetry(t,"mmtfid")}await this.showAnnoSeqData(n,l,r)}}else if(void 0===t.cfg.blast_rep_id||e.bSmithwm||e.bLocalSmithwm){if(void 0!==t.cfg.blast_rep_id&&(e.bSmithwm||e.bLocalSmithwm)){let i,o,a=[t.cfg.blast_rep_id];if(-1!=t.cfg.query_id.indexOf(">")?o=t.cfg.query_id.substr(t.cfg.query_id.indexOf("\n")+1):!/\d/.test(t.cfg.query_id)||t.cfg.query_id.length>50?o=t.cfg.query_id:a.push(t.cfg.query_id),e.blastAcxn){let s=t.cfg.afid+"_A",n="";for(let t=0,i=e.chainsSeq[s].length;t5){let n;e.uniprot2acc&&e.uniprot2acc[i]?e.uniprot2acc[i]:e.uniprot2acc={},n="https://rest.uniprot.org/uniprotkb/search?format=json&fields=xref_geneid,gene_names&query="+i;let l=await t.getAjaxPromise(n,"json"),r=l.results[0]&&l.results[0].uniProtKBCrossReferences&&l.results[0].uniProtKBCrossReferences[0]?l.results[0].uniProtKBCrossReferences[0].id:void 0,o=l.results[0]&&l.results[0].genes&&l.results[0].genes[0]&&l.results[0].genes[0].geneName?l.results[0].genes[0].geneName.value:"ID "+r;e.chainsGene[s]={geneId:r,geneSymbol:o}}}for(let s in e.protein_chainid){let i=t.utilsCls.isMobile()?"none":"button",l=e.showSeqCls.getProteinName(s),r=l,o=0==n?"Proteins:

    ":"",a=e.chainsGene[s]&&e.chainsGene[s].geneId&&e.chainsGene[s].geneDesc?"(Gene: "+e.chainsGene[s].geneSymbol+")":"",d=s.substr(0,s.indexOf("_")),c=d.length>5?''+s+"":s,h="
    "+o+"Annotations of "+c+": "+r+""+a+"   "+this.addButton(s,"icn3d-addtrack","Add Track","Add a custom track",60,i)+"   ";h+=this.addButton(s,"icn3d-customcolor","Custom Color/Tube","Use a custom file to define the colors or tubes in 3D structure",110,i)+"   ",h+=this.addButton(s,"icn3d-helixsets","Helix Sets",'Define sets for each helix in this chain and add them to the menu of "Defined Sets"',60,i)+" "+this.addButton(s,"icn3d-sheetsets","Sheet Sets",'Define sets for each sheet in this chain and add them to the menu of "Defined Sets"',60,i)+" "+this.addButton(s,"icn3d-coilsets","Coil Sets",'Define sets for each coil in this chain and add them to the menu of "Defined Sets"',60,i),e.bShowRefnum&&e.chainid2refpdbname.hasOwnProperty(s)&&e.chainid2refpdbname[s].length>0&&(h+=" "+this.addButton(s,"icn3d-igstrandsets","Ig Strand Sets",'Define sets for each Ig strand in this chain and add them to the menu of "Defined Sets"',80,i)+" "+this.addButton(s,"icn3d-igloopsets","Ig Loop Sets",'Define sets for each Ig loop in this chain and add them to the menu of "Defined Sets"',80,i)),$("#"+e.pre+"dl_annotations").append(h);let p=["giseq","cdd","clinvar","snp","site","ptm","ssbond","crosslink","transmem","domain","custom","interaction"];for(let t in p){let i=p[t];$("#"+e.pre+"anno_"+s).append(this.getAnDiv(s,i))}$("#"+e.pre+"anno_"+s).append("


    "),++n}if(t.bNode||e.annoCddSiteCls.setToolTip(),void 0!==e.chainid_seq)await this.processSeqData(e.chainid_seq);else try{let n=[],l=[];for(let e=0,t=i.length;e=6?l.push(i[e]):n.push(i[e])}if(n.length>0){let s=t.htmlCls.baseUrl+"/vastdyn/vastdyn.cgi?chainlist="+n;e.chainid_seq=await t.getAjaxPromise(s,"jsonp")}else e.chainid_seq={};for(let t=0,s=l.length;t40&&(r=r.substr(0,40)+"...");let o="";0==i&&("protein"==s?o="Proteins:

    ":"nucleotide"==s?o="Nucleotides:

    ":"chemical"==s&&(o="Chemicals/Ions/Water:

    ")),$("#"+n.pre+"dl_annotations").append("
    "+o+""+e+": "+r+"
    "),$("#"+n.pre+"anno_"+e).append(this.getAnDiv(e,"giseq")),$("#"+n.pre+"anno_"+e).append(this.getAnDiv(e,"interaction")),$("#"+n.pre+"anno_"+e).append("


    "),n.giSeq[e]=[];for(let t=0;tChemicals/Ions/Water:

    ":"",o=t[0].lastIndexOf("_"),a=t[0].substr(0,o),d=void 0!==l.cfg.mmdbid&&void 0!==n.chainid2sid?n.chainid2sid[a]:void 0;i=void 0!==d?""+e+" ":""+e+"",$("#"+n.pre+"dl_annotations").append("
    "+r+i+"
    "),$("#"+n.pre+"anno_"+e).append("
    "),$("#"+n.pre+"anno_"+e).append("


    ");let c='
    ';c+='",c+='Count: '+t.length+"",c+='';let h=c,p=c;for(let s=0,i=t.length;s3&&(l=i.substr(0,3)),s'+l+""}let m=l.htmlCls.GREY8,u=Math.round(n.seqAnnWidth*t.length/n.maxAnnoLength);u<1&&(u=1),p+='
     
    ',c="",c+="
    ",c+="
    ",h+=c,p+=c,$("#"+n.pre+"dt_giseq_"+e).html(h),$("#"+n.pre+"ov_giseq_"+e).html(p)}async processSeqData(e){let t=this.icn3d,s=t.icn3dui;for(let i in t.protein_chainid){let n=t.protein_chainid[i];if(e.hasOwnProperty(n)){let s=e[n];t.giSeq[i]=s;let l="";for(let e=0;e<10&&e14?"Query: "+o.substr(0,6)+"...":isNaN(s.cfg.query_id)?"Query: "+o:"Query: gi "+o;let a="cannot be aligned";t.queryStart="",t.queryEnd="",t.bRender&&alert("The sequence can NOT be aligned to the structure"),t.showSeqCls.showSeq(i,n,void 0,e,l,a,r)}else if(s.cfg.blast_rep_id==i&&(void 0!==t.seqStructAlignData||void 0!==t.seqStructAlignDataSmithwm)){let e,l,r,o,a,d=s.cfg.oriQuery_id?s.cfg.oriQuery_id:s.cfg.query_id;if(e=d.length>14?"Query: "+d.substr(0,6)+"...":isNaN(s.cfg.query_id)?"Query: "+d:"Query: gi "+d,void 0!==t.seqStructAlignData){let e,s,i=t.seqStructAlignData;if(void 0!==i.data){e=i.data[0].query;let t=Object.keys(i.data[0].targets);s=i.data[0].targets[t[0]],s=void 0!==s&&s.hsps.length>0?s.hsps[0]:void 0}if(void 0!==e&&void 0!==s){l=s.scores.e_value.toPrecision(2),l>1e-200&&(l=parseFloat(l).toExponential()),s.scores.bit_score;let t=Object.keys(i.targets);r=i.targets[t[0]].seqdata,o=e.seqdata,a=s.segs}}else{let e=t.seqStructAlignDataSmithwm;l=e.score,r=e.target.replace(/-/g,""),o=e.query.replace(/-/g,""),a=[];let s=-1,i=-1,n=!1,d={};for(let t=0,l=e.target.length;t0)if(i.orifrom-ni.from-l)for(let t=n+1;t
    "+i+"
    "}addButton(e,t,s,i,n,l){return this.icn3d.icn3dui,"
    "}addSnpButton(e,t,s,i,n,l){let r=this.icn3d;return r.icn3dui,"
    "}conservativeReplacement(e,t){let s=this.icn3d.icn3dui,i=-1!==s.parasCls.b62ResArray.indexOf(e)?s.parasCls.b62ResArray.indexOf(e):s.parasCls.b62ResArray.length-1,n=-1!==s.parasCls.b62ResArray.indexOf(t)?s.parasCls.b62ResArray.indexOf(t):s.parasCls.b62ResArray.length-1;return s.parasCls.b62Matrix[i][n]>0}getColorhexFromBlosum62(e,t){let s=this.icn3d.icn3dui,i="333333";if(!e||!t)return i;e=e.toUpperCase(),t=t.toUpperCase();let n=-1!==s.parasCls.b62ResArray.indexOf(e)?s.parasCls.b62ResArray.indexOf(e):s.parasCls.b62ResArray.length-1,l=-1!==s.parasCls.b62ResArray.indexOf(t)?s.parasCls.b62ResArray.indexOf(t):s.parasCls.b62ResArray.length-1,r=s.parasCls.b62Matrix[n][l];if(void 0===r)return"333333";if(r>0){let e=221-parseInt(r/11*221),t=e<10?"0"+e.toString(16):e.toString(16);i="DD"+t+t}else{let e=221-parseInt(-1*r/4*221),t=e<10?"0"+e.toString(16):e.toString(16);i=t+t+"DD"}return i}}class Pt{constructor(e){this.icn3d=e}showSeq(e,t,s,i,n,l,r){let o,a=this.icn3d,d=a.icn3dui,c=!1;if(void 0===d.cfg.mmdbid&&void 0===d.cfg.gi&&void 0===d.cfg.blast_rep_id&&void 0===d.cfg.align&&void 0===d.cfg.chainalign&&void 0===d.cfg.mmdbafid){c=!0,o=[];for(let t=0;t10){u='
    ';let t=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]);void 0===d.cfg.mmdbid&&void 0===d.cfg.gi&&void 0===d.cfg.blast_rep_id&&void 0===d.cfg.align&&void 0===d.cfg.chainalign&&void 0===d.cfg.mmdbafid||void 0===t.resi_ori||t.resi_ori==t.resi||-1!=e.indexOf("Misc")?u+='
    ':u+='
    NCBI Residue Numbers
    ',u+='',b+=u+"
    ",g+=u+'';let s=0,i=0,n="";a.seqStartLen&&a.seqStartLen[e]&&(g+=this.insertMulGap(a.seqStartLen[e]," "));for(let t=0,l=o.length;t",l%10==0&&(g+=l);let r=e+"_"+l,o=l%10!=0&&l%10!=1&&l%10!=9;if(a.residues.hasOwnProperty(r)){let e=a.firstAtomObjCls.getFirstCalphaAtomObj(a.residues[r]);"H"==a.secondaries[r]&&e.ssbegin?(++s,n='H'+s+"",o&&(g+=n,n="")):"E"==a.secondaries[r]&&e.ssbegin?(++i,"green"==a.sheetcolor?n='S'+i+"":"yellow"==a.sheetcolor&&(n='S'+i+""),o&&(g+=n,n="")):e.ssend&&(n=""),""!=n&&o&&(g+=n,n="")}g+=""}a.seqStartLen&&a.seqStartLen[e]&&(g+=this.insertMulGap(a.seqEndLen[e]," ")),g+='',g+="",g+="
    ",g+="
    ",b+=""}u='
    ',u+='
    ',u+='',b+=u+"
    ",g+=u+'',a.seqStartLen&&a.seqStartLen[e]&&(g+=this.insertMulGap(a.seqStartLen[e],"-"));for(let t=0,s=o.length;t':'',g+=" ";else if("E"==a.secondaries[s]){a.firstAtomObjCls.getFirstCalphaAtomObj(a.residues[s]).ssend?"green"==a.sheetcolor?g+='':"yellow"==a.sheetcolor&&(g+=''):"green"==a.sheetcolor?g+='':"yellow"==a.sheetcolor&&(g+=''),g+=" "}else"c"==a.secondaries[s]?g+=' ':"o"==a.secondaries[s]&&(g+=' ');else g+="-"}a.seqStartLen&&a.seqStartLen[e]&&(g+=this.insertMulGap(a.seqEndLen[e],"-")),g+='',g+="",g+="
    ",g+="
    ",g+="",b+="",u=d.cfg.blast_rep_id===e?'
    ':'
    ';let C="Protein",y="Protein";void 0!==s&&("nucleotide"==s?(C="Nucl.",y="Nucleotide"):"chemical"==s&&(C="Chem.",y="Chemical")),u+='",u+=''+(a.baseResi[e]+1).toString()+"",b+=u+"
    ";let v='';g+=u+v,f+=u+v;let _,w=0;a.seqStartLen&&a.seqStartLen[e]&&(g+=this.insertMulGap(a.seqStartLen[e],"-"));for(let t=0,s=o.length;t1&&(i=s[0]+".."),_=a.ParserUtilsCls.getResi(e,t),a.residues.hasOwnProperty(e+"_"+_)){let n="333333";if(d.cfg.blast_rep_id==e&&void 0!==a.fullpos2ConsTargetpos&&void 0!==a.fullpos2ConsTargetpos[t+w])n=a.fullpos2ConsTargetpos[t+w].color;else{let t=a.firstAtomObjCls.getFirstCalphaAtomObj(a.residues[e+"_"+_]),s=void 0===t.color||"FFFFFF"===t.color.getHexString().toUpperCase()||"FFF"===t.color.getHexString().toUpperCase()?"DDDDDD":t.color.getHexString();n=void 0!==t.color?s:"CCCCCC"}g+=''+i+""}else i=i.toLowerCase(),g+=''+i+""}a.seqStartLen&&a.seqStartLen[e]&&(g+=this.insertMulGap(a.seqEndLen[e],"-")),d.cfg.blast_rep_id==e&&(a.opts.color=a.blastAcxn?"confidence":"conservation",a.setColorCls.setColorByOptions(a.opts,a.atoms));let S=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]),A=S.color?S.color.getHexString():"CCCCCC",x=Math.round(a.seqAnnWidth*o.length/(a.maxAnnoLength+a.nTotalGap));if(x<1&&(x=1),a.seqStartLen&&a.seqStartLen[e]&&(f+=this.insertMulGapOverview(e,a.seqStartLen[e])),d.cfg.blast_rep_id!=e)f+='";else{let t=[],s=[];t.push(0);for(let e=0,i=o.length;e';for(let i=0,n=t.length;i'+e+"
    ";f+="
    "}if(u=''+_+"",u+="",u+="
    ",g+=u,f+=u,d.cfg.blast_rep_id==e){if(void 0!==r&&""!==r){u='",u+='',b+=u+"
    ";let t='';g+=u+t,f+=u+t;let s=0,i=0,l=1;a.queryStart;for(let t=0,n=r.length;t-";else if(" "==n)g+=" ";else{let r=a.fullpos2ConsTargetpos[t].pos;if(a.residues.hasOwnProperty(e+"_"+r)){let s=a.fullpos2ConsTargetpos[t].color;g+=''+n+""}else n=n.toLowerCase(),g+=''+n+"";f+=this.insertGapOverview(e,t);let o=Math.round(a.seqAnnWidth*t/(a.maxAnnoLength+a.nTotalGap)-s-i);o>=0&&(f+='
     
    ',f+='
     
    ',s+=o,i+=l)}}u='',u+="",u+="
    ",g+=u,f+=u}u='
    '+i+"
    ",u+=''+a.queryStart+"",b+=u+"
    ";let t='';g+=u+t,f+=u+t;let s=a.queryStart;for(let t=0,i=l.length;t-":(void 0===a.fullpos2ConsTargetpos||void 0===a.fullpos2ConsTargetpos[t]||a.residues.hasOwnProperty(e+"_"+a.fullpos2ConsTargetpos[t].pos)||(i=i.toLowerCase()),g+=''+i+"",++s)}let o=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]),d=void 0===o.color||"FFFFFF"===o.color.getHexString()?"DDDDDD":o.color.getHexString(),c=void 0!==o.color?d:"CCCCCC",h=[],p=[],m="-";for(let e=0,t=l.length;e ',f+='
    '+i+"
    "}u=''+a.queryEnd+"",u+="",u+="
    ",g+=u,f+=u}if(g+="",f+="",b+="",a.giSeq[e].length>10){let t=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]);if((void 0!==d.cfg.mmdbid||void 0!==d.cfg.gi||void 0!==d.cfg.blast_rep_id||void 0!==d.cfg.align||void 0!==d.cfg.chainalign||void 0!==d.cfg.mmdbafid)&&void 0!==t.resi_ori&&t.resi_ori!=t.resi&&-1==e.indexOf("Misc")){u='
    ',u+='
    ',u+='
    PDB Residue Numbers
    ',u+='',b+=u+"
    ",g+=u+'',a.seqStartLen&&a.seqStartLen[e]&&(g+=this.insertMulGap(a.seqStartLen[e],"-"));for(let t=0,s=o.length;t",e%10==0&&(g+=e+" "),g+=""}else g+=""}a.seqStartLen&&a.seqStartLen[e]&&(g+=this.insertMulGap(a.seqEndLen[e],"-")),g+='',g+="",g+="
    ",g+="
    ",g+="
    ",b+=""}if(a.bShowRefnum&&a.chainid2refpdbname.hasOwnProperty(e)&&a.chainid2refpdbname[e].length>0){let t=this.showAllRefNum(o,e);g+=t.html,b+=t.html3}if(a.bShowCustomRefnum&&a.chainsMapping.hasOwnProperty(e)){let t=!0,s=this.showRefNum(o,e,void 0,t);g+=s.html,b+=s.html3}}a.bShowRefnum&&a.hlUpdateCls.updateHlAll(),$("#"+a.pre+"dt_giseq_"+e).html(g),$("#"+a.pre+"ov_giseq_"+e).html(f),$("#"+a.pre+"tt_giseq_"+e).html(b)}showAllRefNum(e,t){let s=this.icn3d;s.icn3dui;let i="",n="",l=this.showRefNum(e,t);i+=l.html,n+=l.html3;let r=1;return l=this.showRefNum(e,t,r),i+=l.html,n+=l.html3,r=2,l=this.showRefNum(e,t,r),i+=l.html,n+=l.html3,s.bShowRefnum&&(s.opts.color="ig strand",s.setColorCls.setColorByOptions(s.opts,s.dAtoms),s.hlUpdateCls.updateHlAll(),s.drawCls.draw()),{html:i,html3:n}}showRefNum(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r="",o="";if(!n.chainid2refpdbname[t])return{html:r,html3:o};let a=n.refnumCls.getTemplateList(t),d=a.refpdbnameList,c=a.scoreList,h=d?"based on "+d+". The TM-scores are "+c+".":"",p='
    ';p+='
    ',p+=i?'
    Custom Ref. No.
    ':1==s?'
    Kabat Ref. No.
    ':2==s?'
    IMGT Ref. No.
    ':'
    IgStRAnD Ref. No.
    ',p+='',o+=p+"
    ",r+=p+'';let m=!1;for(let s=0,l=e.length;s0){m=!0;break}}if(1==s&&!m)return{html:"",html3:""};let u=!1;for(let s=0,l=e.length;s0){u=!0;break}}if(2==s&&!u)return{html:"",html3:""};let g,f,b,C,y,v,_,w,S=!1,A="",x="",k=!1,O=!1,R=1,I=!1;if(!i&&!s&&!l.bNode){let e=l.hashUtilsCls.intHash(n.chains[t],n.hAtoms),s=n.firstAtomObjCls.getResiduesFromAtoms(e);for(let e in s)delete n.residIgLoop[e]}let T,E=[],P={},M=0,D=0,H=0,F=0;if(!i&&!s){for(let s=0,i=e.length;s=0;--t)"G"!=E[t].strand.substr(0,1)&&E[t].endRefnum-E[t].startRefnum+1<3&&(t!=e-1&&(E[t+1].loopResCnt+=E[t].loopResCnt+parseInt(E[t].endResi)-parseInt(E[t].startResi)+1),E.splice(t,1));M=0;let s,i,l=0,r=!0,o=!0,a=0;I=!1;let d=0;if(E.length>0)for(let c=0,h=e.length;cE[M].endResi:parseInt(e)>parseInt(E[M].endResi),c=!t&&!p,t)if(n.residIgLoop[h]=1,r)I?(i=E[M].startRefnum-E[M].loopResCnt+l,s=E[M].strand+i,g=s+E[M].strandPostfix):(s=void 0,g=void 0);else if(a>=0&&"G"==E[a].strand.substr(0,1))o?I&&n.resid2refnum[h]?(o=!0,i=E[a].endRefnum+l,s=E[a].strand+i,g=s+E[a].strandPostfix):(I=!1,r=!0,o=!1,s=void 0,g=void 0):(s=void 0,g=void 0);else{o=!0;let e=E[M].loopResCnt;l<=parseInt(e/2+.5)?(i=E[a].endRefnum+l,s=E[a].strand+i,g=s+E[a].strandPostfix):(i=E[M].startRefnum-e+l-1,s=E[M].strand+i,g=s+E[M].strandPostfix)}else c?(r=!1,E[M].anchorRefnum&&(e==E[M].startResi?(d=E[M].anchorRefnum-E[M].resCntBfAnchor,E[M].startRefnum=d):e==E[M].endResi&&(E[M].endRefnum=d),s=E[M].strand+d,g=s+E[M].strandPostfix),e==E[M].endResi&&(++M,l=0,E[M]||--M)):p&&(n.residIgLoop[h]=1,o?n.resid2refnum[h]?(o=!0,i=E[M].endRefnum+l,s=E[M].strand+i,g=s+E[M].strandPostfix):(o=!1,s=void 0,g=void 0):(s=void 0,g=void 0))}else g=void 0;x=A,a=M-1,n.resid2refnum[h]=g,b=n.refnumCls.rmStrandFromRefnumlabel(g),n.refnum2residArray.hasOwnProperty(b)?n.refnum2residArray[b].push(h):n.refnum2residArray[b]=[h],n.chainsMapping.hasOwnProperty(t)||(n.chainsMapping[t]={}),n.chainsMapping[t][h]=s}}for(let l=0,o=e.length;l'+b+"":' '}else r+="";else if(1==s||2==s)if(b){let e=parseInt(b).toString(),t='style="color:'+this.getRefnumColor(A,!0)+'"';r+=parseInt(e.substr(e.length-2,2))%2==0?"'+b+"":" '}else r+="";else" "!=A?(S=n.residIgLoop[e],r+=this.getRefnumHtml(e,b,f,g,A,S,a)):r+="";else r+="";x=T}return r+='',r+="",r+="
    ",r+="
    ",r+="
    ",o+="",{html:r,html3:o}}getRefnumHtml(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui,d=parseInt(t).toString(),c=(d-1e3*parseInt(d/1e3)).toString(),h=parseInt(d.toString().substr(0,2)),p="5"!=c.substr(0,1)&&"18"!=h,m=this.getRefnumColor(n,!0),u=l?'style="color:'+m+'"':'style="color:'+m+'; text-decoration: underline overline;"',g=d.substr(d.length-2,2),f=parseInt(g);parseInt(d.substr(d.length-3,3));let b="";return!i||50!=f||p||l?i&&f%2==0&&52!=f&&!r?(g=isNaN(t)?g+t.substr(t.length-1,1):g,b+="'+g+""):b+=" ':(o.hAtomsRefnum=a.hashUtilsCls.unionHash(o.hAtomsRefnum,o.residues[e]),b+="'+i.substr(0,1)+""+i.substr(1)+""),b}getRefnumColor(e,t){let s=this.icn3d.icn3dui,i=e?e.substr(0,1):"";return"C"==e?"#0000FF":"C'"==e?"#6495ED":"C''"==e?"#006400":"A"==i?"#9400D3":"B"==i?"#ba55d3":"D"==i?"#00FF00":"E"==i?"#FFD700":"F"==i?"#FF8C00":"G"==i?"#FF0000":s.htmlCls.GREYB}getProtodomainColor(e){let t=this.icn3d.icn3dui,s=e?e.substr(0,1):"";return"A"==s||"D"==s?"#0000FF":"B"==s||"E"==s?"#006400":"C"==e||"F"==s?"#FFD700":"C'"==e||"G"==s?"#FF8C00":"C''"==e?"#FF0000":t.htmlCls.GREYB}insertGap(e,t,s,i){let n=this.icn3d;n.icn3dui;let l="";return void 0!==n.targetGapHash&&n.targetGapHash.hasOwnProperty(t)&&(l+=this.insertMulGap(n.targetGapHash[t].to-n.targetGapHash[t].from+1,s,i)),l}insertMulGap(e,t,s){this.icn3d.icn3dui;let i="";for(let n=0;n"+t+"";return i}insertGapOverview(e,t){let s=this.icn3d;s.icn3dui;let i="";return void 0!==s.targetGapHash&&s.targetGapHash.hasOwnProperty(t)&&(i+=this.insertMulGapOverview(e,s.targetGapHash[t].to-s.targetGapHash[t].from+1)),i}insertMulGapOverview(e,t){let s=this.icn3d;s.icn3dui;let i="",n=s.seqAnnWidth*t/(s.maxAnnoLength+s.nTotalGap);return n=parseInt(n),i+='
     
    ',i}setAlternativeSeq(e,t){let s=this.icn3d;s.icn3dui;let i=s.chainsSeq[e];s.giSeq[e]=[];for(let t=0,n=i.length;t1&&s.htmlCls.clickMenuCls.setLogCmd("select sets "+e,!0)}else{let o={};if(void 0!==$(e).attr("domain")||void 0!==$(e).attr("feat")||void 0!==$(e).attr("3ddomain")||void 0!==$(e).attr("custom")){t.hlUpdateCls.hlSummaryDomain3ddomain(e);let a,d,c,h=$(e).attr("from").split(","),p=$(e).attr("to").split(",");r.substr(0,r.indexOf("_"));for(let s=0,i=h.length;s1&&s.htmlCls.clickMenuCls.setLogCmd("select sets "+c,!0)}}else{t.bCtrl||t.bShift?(t.currSelectedSets.push(i),t.selectionCls.selectAChain(r,i,!0,!0)):(t.currSelectedSets=[i],t.selectionCls.selectAChain(r,i,t.bAlignSeq)),t.bAlignSeq?s.htmlCls.clickMenuCls.setLogCmd("select alignChain "+r,!0):s.htmlCls.clickMenuCls.setLogCmd("select chain "+r,!0);let e=t.currSelectedSets.join(" or ");t.currSelectedSets.length>1&&s.htmlCls.clickMenuCls.setLogCmd("select sets "+e,!0)}else t.hlObjectsCls.removeHlObjects(),t.hlUpdateCls.removeHl2D(),$("#"+t.pre+"atomsCustom").val("")}}selectResidues(e,t){let s=this.icn3d,i=s.icn3dui;if(!i.bNode&&(!1!==s.bSelectResidue||s.bShift||s.bCtrl||s.selectionCls.removeSelection(),void 0!==e&&""!==e)){e=e.substr(e.indexOf("_")+1),s.bSelectResidue=!0,$(t).toggleClass("icn3d-highlightSeq");let n=e.substr(e.indexOf("_")+1);if(s.residues.hasOwnProperty(n))if($(t).hasClass("icn3d-highlightSeq")){for(let e in s.residues[n])s.hAtoms[e]=1;if(s.selectedResidues[n]=1,s.bAnnotations&&void 0!==$(t).attr("disease")){let e=$(t).attr("disease"),l=s.applyCenterCls.centerAtoms(i.hashUtilsCls.hash2Atoms(s.residues[n],s.atoms)),r=15;e.length>r&&(e=e.substr(0,r)+"...");let o=s.LABELSIZE,a=i.htmlCls.GREYD;s.analysisCls.addLabel(e,l.center.x,l.center.y,l.center.z,o,a,void 0,"custom")}}else{for(let e in s.residues[n])delete s.hAtoms[e];delete s.selectedResidues[n],s.hlObjectsCls.removeHlObjects()}}}}class Dt{constructor(e){this.icn3d=e}update2DdgmContent(){let e=this.icn3d,t=e.icn3dui,s="";void 0!==t.cfg.mmdbid||void 0!==t.cfg.gi?(s+=e.diagram2dCls.draw2Ddgm(e.interactionData,e.inputid,void 0,!0),s+=e.diagram2dCls.set2DdgmNote(),$("#"+e.pre+"dl_2ddgm_html").html(s)):e.mmdbidArray&&(void 0!==t.cfg.align||void 0!==t.cfg.chainalign||e.bRealign)&&(s+=e.diagram2dCls.draw2Ddgm(e.interactionData1,e.mmdbidArray[0].toUpperCase(),0,!0),void 0!==e.mmdbid_q&&e.mmdbid_q===e.mmdbid_t?s+=e.diagram2dCls.draw2Ddgm(e.interactionData2,e.mmdbidArray[0].toUpperCase(),1,!0):s+=e.diagram2dCls.draw2Ddgm(e.interactionData2,e.mmdbidArray[1].toUpperCase(),1,!0),s+=e.diagram2dCls.set2DdgmNote(!0),$("#"+e.pre+"dl_2ddgm_html").html(s))}changeSeqColor(e){let t=this.icn3d,s=t.icn3dui;for(let i=0,n=e.length;i0&&($("#"+e.pre+"dl_2ddgm svg line").attr("stroke","#000000"),$("#"+e.pre+"dl_2ddgm line").attr("stroke-width",1))}removeHlMenus(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"atomsCustom").val(""),$("#"+e.pre+"atomsCustom")[0].blur()}updateHlAll(e,t,s,i){let n=this.icn3d,l=n.icn3dui;n.prevHighlightAtoms=l.hashUtilsCls.cloneHash(n.hAtoms),this.updateHlObjects(i),void 0!==e?this.updateHlSeqInChain(e,s):this.updateHlSeq(void 0,void 0,s),this.updateHl2D(),(void 0===t||t)&&this.updateHlMenus(e)}updateHlObjects(e){let t=this.icn3d;t.icn3dui,t.hlObjectsCls.removeHlObjects(),(t.hAtoms&&t.atoms&&Object.keys(t.hAtoms).length0&&(e=s.defNames2Residues[i]);let t={};if(void 0!==s.defNames2Atoms[i]&&s.defNames2Atoms[i].length>0){for(let e=0,n=s.defNames2Atoms[i].length;e0&&(r=t.firstAtomObjCls.getFirstCalphaAtomObj(l))}let o=void 0!==r&&void 0!==r.color?"#"+r.color.getHexString():"#FFFFFF",a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] rect[class='icn3d-hlnode']"),d=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] rect[class='icn3d-basenode']");void 0!==a&&(t.diagram2dCls.highlightNode("rect",a,d,l),$(a).attr("fill",o)),a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] circle[class='icn3d-hlnode']"),d=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] circle[class='icn3d-basenode']"),void 0!==a&&(t.diagram2dCls.highlightNode("circle",a,d,l),$(a).attr("fill",o)),a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] ellipse[class='icn3d-hlnode']"),void 0!==a&&t.diagram2dCls.highlightNode("ellipse",a,void 0,l),a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] polygon[class='icn3d-hlnode']"),d=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] polygon[class='icn3d-basenode']"),void 0!==a&&(t.diagram2dCls.highlightNode("polygon",a,d,l),$(a).attr("fill",o))}if(void 0!==t.lineArray2d)for(let e=0,i=t.lineArray2d.length;e1){let e={},l=[],o=[],a=[],c=[],h=[],m=[],u=[],g=[],f=[],b=[],C=[],y=[],v={},_={};for(let t=0,s=p.length;t0&&(T=1,t=i.getGraphCls.getNodeTopBottom(c[e],d,void 0,T,g[e]),h[e]=t.nodeArray1,m[e]=t.nodeArray2,d=n.hashUtilsCls.unionHash(d,t.name2node),T=2,t=i.getGraphCls.getNodeTopBottom(c[e],d,void 0,T,y[e]),f[e]=t.nodeArray1,b[e]=t.nodeArray2,d=n.hashUtilsCls.unionHash(d,t.name2node)),k[e]=l[e].length,O[e]=o[e].length,R=Math.max(R,O[e]),I.push(p[e])}let E,P,M,D,H,F=1,L=3*F,N=7*F,q=10,U=10,$=30,j=20;t?(M=(n.utilsCls.sumArray(k)+2*I.length)*(L+N)+4*U+2*$+j*I.length,P=(R+2)*(L+N)+2*q+$):(E=110+j,M=E*I.length,P=(R+2)*(L+N)+2*q,P+=20),Object.keys(i.chainsMapping).length>0&&(M*=3),t?(i.scatterplotWidth=2*P,H=i.scatterplotWidth,D=n.scatterplotid):(i.linegraphWidth=2*P,H=i.linegraphWidth,D=n.linegraphid),s=0==I.length?"No interactions found for each structure

    ":"2D integration graph for "+I.length+" structure(s) "+I+'. There are three sections: "Interactions", "Common interactions", and "Different interactions". Each section has '+I.length+" graphs.

    ",s+="";let B,z=0;T=0,B=this.drawGraphPerType(T,p,t,l,o,a,d,z,E,j,k,L,N,U),z=B.heightFinal,s+=B.html,Object.keys(i.chainsMapping).length>0&&(T=1,B=this.drawGraphPerType(T,p,t,h,m,u,d,z,E,j,k,L,N,U),z=B.heightFinal,s+=B.html,T=2,B=this.drawGraphPerType(T,p,t,f,b,C,d,z,E,j,k,L,N,U),z=B.heightFinal,s+=B.html),s+=""}else if(t){let e,t,l,c,h=p[0],m=o.length,u=a.length,g=1,f=3*g,b=7*g,C=30;t=(m+2)*(f+b)+2*10+C,e=(u+2)*(f+b)+2*10+C,i.scatterplotWidth=2*e,c=i.scatterplotWidth,l=n.scatterplotid,s=r.length>0?"":"No interactions found for these two sets

    ",s+="",s+=this.drawScatterplot_base(o,a,r,d,0),i.lineGraphStr+=i.getGraphCls.updateGraphJson(h,1,o,a,r),s+=""}else{let e=p[0],t=o.length,l=a.length,c=1,h=3*c,m=7*c,u=110,g=10,f=t>l?t*(h+m)+2*g:l*(h+m)+2*g;i.linegraphWidth=2*f,s=r.length>0?"":"No interactions found for these two sets

    ",s+="",s+=this.drawLineGraph_base(o,a,r,d,0),i.lineGraphStr+=i.getGraphCls.updateGraphJson(e,1,o,a,r),s+=""}return i.lineGraphStr+="}\n",i.scatterplotStr=i.lineGraphStr,t?$("#"+i.pre+"scatterplotDiv").html(s):$("#"+i.pre+"linegraphDiv").html(s),s}drawGraphPerType(e,t,s,i,n,l,r,o,a,d,c,h,p,m){let u=this.icn3d;u.icn3dui;let g,f,b="",C=2==t.length&&"2"==t[1].replace(t[0],"");0==e?(g="Interactions in ",f=""):1==e?(g="Common interactions in ",f="_common"):2==e&&(g="Different interactions in ",f="_diff");for(let y=0,v=t.length;y0&&(u.lineGraphStr+=", \n"):u.lineGraphStr+=", \n",u.lineGraphStr+=u.getGraphCls.updateGraphJson(t[y],y+f,i[y],n[y],l[y])}return{heightFinal:o,html:b}}getIdArrayFromNode(e){let t=this.icn3d.icn3dui,s=[];s.push(""),s.push("");let i=e.r.substr(4);return s=s.concat(t.utilsCls.getIdArray(i)),s}drawLineGraph_base(e,t,s,i,n,l,r){let o,a,d=this.icn3d,c=d.icn3dui,h="",p=e.length,m=t.length;p>m?(o=10,a=10*Math.abs(p-m)*.5+10):(a=10,o=10*Math.abs(p-m)*.5+10),l&&(h+=""+l+"");let u=30+n,g=80+n,f="",b={},C={};for(let t=0;t";let u=1==t.n?"Interaction":t.n+" interactions";t.n>1&&(h+=""+u+" of residue "+n.id+" with residue "+l.id+""),h+=""}return h+=f,h}drawScatterplot_base(e,t,s,i,n,l,r,o,a){let d=this.icn3d;d.icn3dui;let c="",h=e.length,p=t.length,m=l?3:7,u=(h+1)*(3+m)+30+40;r&&(c+=""+r+"");let g=n+u-(50+(3+m)),f=40+(3+m),b="",C={},y={};for(let t=0;t";else{h+="";let i=1==e.n?"Interaction":e.n+" interactions";e.n>1&&(h+=""+i+" of residue "+t.id+" with residue "+s.id+""),h+=l?"":"",h+=""}return h}copyStylesInline(e,t){this.icn3d.icn3dui;let s=["svg","g"];for(let i=0;ii.domainid2score[a])&&(i.domainid2score[a]=e,i.domainid2refpdbname[a]=d,r[a]=o[0].segs,i.domainid2ig2kabat[a]=o[0].ig2kabat,i.domainid2ig2imgt[a]=o[0].ig2imgt)}else console.log("domainid: "+a),(!i.domainid2score.hasOwnProperty(a)||o[0].score>=i.domainid2score[a])&&(i.domainid2score[a]=o[0].score,i.domainid2refpdbname[a]=d,r[a]=o[0].segs,i.domainid2ig2kabat[a]=o[0].ig2kabat,i.domainid2ig2imgt[a]=o[0].ig2imgt)}if(s){n.bNode||console.log("Start round 2 alignment with the reference culsters "+JSON.stringify(i.domainid2refpdbname));let e=[],t=[],s=n.htmlCls.baseUrl+"tmalign/tmalign.cgi";for(let l in i.domainid2refpdbname){let r=[],o=i.domainid2refpdbname[l],a=l.substr(0,l.indexOf(","));if(i.refpdbHash.hasOwnProperty(a)&&(o=a,n.bNode||console.log("Adjusted refpdbname for domainid "+l+": "+o)),!i.refpdbHash[o])continue;for(let e=0,t=i.refpdbHash[o].length;e0){if(i.bShowRefnum=!0,i.hAtomsRefnum={},i.bAnnoShown)for(let e in i.protein_chainid){let t=i.protein_chainid[e];i.showSeqCls.showSeq(e,t,"protein")}else await i.showAnnoCls.showAnnotations();i.annotationCls.setAnnoViewAndDisplay("detailed view")}else alert("No Ig reference numbers are assigned based on the reference structures in iCn3D...")}getLabelFromRefnum(e,t,s){this.icn3d.icn3dui;let i=parseInt(e);return i<1e3?void 0:i>=1200&&i<1290?"A---"+e:i>=1320&&i<1390?"A--"+e:i>=1420&&i<1490?"A-"+e:i>=1520&&i<1590?"A"+e:i>=1620&&i<1690?"A+"+e:i>=1820&&i<1890?"A'"+e:i>=2e3&&i<2900?"B"+e:i>=3300&&i<3390?"C--"+e:i>=3420&&i<3490?"C-"+e:i>=3520&&i<3590?"C"+e:i>=4e3&&i<4900?"C'"+e:i>=5e3&&i<5900?"C''"+e:i>=6e3&&i<6900?"D"+e:i>=7500&&i<7590?"E"+e:i>=7620&&i<7900?"E+"+e:i>=8e3&&i<8900?"F"+e:i>=9500&&i<9590?"G"+e:i>=9620&&i<9690?"G+"+e:i>=9720&&i<9790?"G++"+e:i>9900?void 0:" "+e}async parseCustomRefFile(e){let t=this.icn3d;t.icn3dui,t.bShowCustomRefnum=!0;let s=e.split("\n");t.resid2refnum||(t.resid2refnum={}),t.refnum2residArray||(t.refnum2residArray={}),t.chainsMapping||(t.chainsMapping={});let i=[];for(let e=0,t=s.length;e",C=e.id;return c.resid2refnum[p]&&(C+="=>"+c.resid2refnum[p]),b+=""+C+"",o?(b+="",b+=""+g+""):(b+="",b+=""+g+""),b+="",b}getNodeTopBottom(e,t,s,i,n){let l=this.icn3d.icn3dui,r=this,o=[],a=[],d={};for(let s in e){let e=t[s];if(e){if(1==i||2==i){if(e=l.hashUtilsCls.cloneHash(e),1==i){let t=n[s]?n[s]:"-";e.id+="=>"+t}else{let t=n[s]?n[s]:"--";e.id+="==>"+t}d[e.id]=e}"a"==e.s?o.push(e):"b"==e.s?a.push(e):"ab"==e.s&&(o.push(e),a.push(e))}}return o.sort((function(e,t){return r.compNode(e,t)})),a.sort((function(e,t){return r.compNode(e,t,s)})),{nodeArray1:o,nodeArray2:a,name2node:d}}updateGraphJson(e,t,s,i,n){let l=this.icn3d.icn3dui,r="";return r+='"structure'+t+'": {"id": "'+e+'", "nodes1":[',r+=l.utilsCls.getJSONFromArray(s),r+='], \n"nodes2":[',r+=l.utilsCls.getJSONFromArray(i),r+='], \n"links":[',r+=l.utilsCls.getJSONFromArray(n),r+="]}",r}updateGraphColor(){let e=this.icn3d,t=e.icn3dui;if(void 0!==e.graphStr){let s=JSON.parse(e.graphStr),i={};for(let t in e.residues){let s=e.firstAtomObjCls.getFirstAtomObj(e.residues[t]);i[t]=s.color.getHexString().toUpperCase()}let n={};for(let e=0,l=s.nodes.length;e0&&c==e.chain&&(n.resid2ncbi[e.resi]==n.resid2ncbi[p]+1||n.resid2ncbi[e.resi]==n.resid2ncbi[p])&&(o.push('{"source": "'+h+'", "target": "'+u+'", "v": '+d+', "c": "'+f+'"}'),e.ssbegin&&(d=l.htmlCls.ssValue),e.ssend&&(d=l.htmlCls.coilValue)),c=e.chain,h=u,p=e.resi,++a}}return{node:r,link:o}}getHbondLinksForSet(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=parseFloat($("#"+s.pre+"hbondthreshold").val()),r=e,o=r;if(Object.keys(o).length>0&&Object.keys(r).length>0){let e=!1;s.hBondCls.calculateChemicalHbonds(i.hashUtilsCls.hash2Atoms(o,s.atoms),i.hashUtilsCls.hash2Atoms(r,s.atoms),parseFloat(l),e,"graph",!0),n=i.hashUtilsCls.cloneHash(s.resid2Residhash)}return this.getGraphLinks(n,n,i.htmlCls.hbondInsideColor,t,i.htmlCls.hbondInsideValue)}getIonicLinksForSet(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=parseFloat($("#"+s.pre+"saltbridgethreshold").val()),r=e,o=r;if(Object.keys(o).length>0&&Object.keys(r).length>0){let e=!1;s.saltbridgeCls.calculateIonicInteractions(i.hashUtilsCls.hash2Atoms(o,s.atoms),i.hashUtilsCls.hash2Atoms(r,s.atoms),parseFloat(l),e,"graph",!0),n=i.hashUtilsCls.cloneHash(s.resid2Residhash)}return this.getGraphLinks(n,n,i.htmlCls.ionicInsideColor,t,i.htmlCls.ionicInsideValue)}getHalogenPiLinksForSet(e,t){let s,i=this.icn3d,n=i.icn3dui,l={},r=e,o=r,a="";return s=parseFloat($("#"+i.pre+"halogenthreshold").val()),Object.keys(o).length>0&&Object.keys(r).length>0&&(i.piHalogenCls.calculateHalogenPiInteractions(n.hashUtilsCls.hash2Atoms(r,i.atoms),n.hashUtilsCls.hash2Atoms(o,i.atoms),parseFloat(s),"graph","halogen",!0),l=n.hashUtilsCls.cloneHash(i.resid2Residhash)),a+=this.getGraphLinks(l,l,n.htmlCls.halogenInsideColor,t,n.htmlCls.halogenInsideValue),s=parseFloat($("#"+i.pre+"picationthreshold").val()),Object.keys(o).length>0&&Object.keys(r).length>0&&(i.piHalogenCls.calculateHalogenPiInteractions(n.hashUtilsCls.hash2Atoms(r,i.atoms),n.hashUtilsCls.hash2Atoms(o,i.atoms),parseFloat(s),"graph","pi-cation",!0),l=n.hashUtilsCls.cloneHash(i.resid2Residhash)),a+=this.getGraphLinks(l,l,n.htmlCls.picationInsideColor,t,n.htmlCls.picationInsideValue),s=parseFloat($("#"+i.pre+"pistackingthreshold").val()),Object.keys(o).length>0&&Object.keys(r).length>0&&(i.piHalogenCls.calculateHalogenPiInteractions(n.hashUtilsCls.hash2Atoms(r,i.atoms),n.hashUtilsCls.hash2Atoms(o,i.atoms),parseFloat(s),"graph","pi-stacking",!0),l=n.hashUtilsCls.cloneHash(i.resid2Residhash)),a+=this.getGraphLinks(l,l,n.htmlCls.pistackingInsideColor,t,n.htmlCls.pistackingInsideValue),a}getContactLinksForSet(e,t,s){let i=this.icn3d;i.icn3dui;let n=[],l="",r="",o={};for(let t in e){let e=i.atoms[t];e.ss==l&&e.chain==r||(Object.keys(o).length>0&&n.push(o),o={}),o[e.serial]=1,l=e.ss,r=e.chain}Object.keys(o).length>0&&n.push(o);let a=n.length,d="";for(let e=0;ed?s?-1:1:ah?1:c0&&Object.keys(a).length>0)){let t,s=c.hBondCls.calculateChemicalHbonds(h.hashUtilsCls.hash2Atoms(d,c.atoms),h.hashUtilsCls.hash2Atoms(a,c.atoms),parseFloat(e),n);n?(c.resid2ResidhashSaltbridge=h.hashUtilsCls.cloneHash(c.resid2Residhash),t="all atoms that have salt bridges with the selected atoms"):(c.resid2ResidhashHbond=h.hashUtilsCls.cloneHash(c.resid2Residhash),t="all atoms that are hydrogen-bonded with the selected atoms");let i={};for(let e in s){i[c.atoms[e].structure+"_"+c.atoms[e].chain+"_"+c.atoms[e].resi]=1}c.hAtoms={};for(let e in i)for(let t in c.residues[e])c.hAtoms[t]=1,c.atoms[t].style2="stick";let l=r+"_auto";c.selectionCls.addCustomSelection(Object.keys(i),l,t,o,!0),c.selectionCls.saveSelectionIfSelected(),c.drawCls.draw()}}showHydrogens(){let e=this.icn3d;if(void 0!==e.icn3dui.cfg.cid)for(let t in e.hAtoms){let s=e.atoms[t];if("H"!==s.elem.substr(0,1)){e.atoms[s.serial].bonds=e.atoms[s.serial].bonds2.concat(),e.atoms[s.serial].bondOrder=e.atoms[s.serial].bondOrder2.concat();for(let t=0,i=e.atoms[s.serial].bonds.length;t0){let i=e.atoms[t].bonds[0];e.atoms[i].bonds.push(s.serial),e.atoms[i].bondOrder&&e.atoms[i].bondOrder.push(1)}e.dAtoms[t]=1}}e.bShowHighlight=!1}hideHydrogens(){let e=this.icn3d;e.icn3dui;for(let t in e.hAtoms){let s=e.atoms[t];if("H"===s.elem.substr(0,1)){if(e.atoms[s.serial].bonds.length>0){let t=e.atoms[s.serial].bonds[0],i=e.atoms[t].bonds?e.atoms[t].bonds.indexOf(s.serial):-1;-1!==i&&(e.atoms[t].bonds.splice(i,1),e.atoms[t].bondOrder&&e.atoms[t].bondOrder.splice(i,1))}delete e.dAtoms[s.serial],delete e.hAtoms[s.serial]}}}hideExtraBonds(){let e=this.icn3d;e.icn3dui;for(let t in e.atoms)e.atoms[t].style2="nothing";for(let t in e.sidec)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style2=e.opts.sidec);for(let t in e.water)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style=e.opts.water)}hideHbondsContacts(){let e=this.icn3d,t=e.icn3dui,s="set hbonds off";t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.hBondCls.hideHbonds(),s="set salt bridge off",t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.saltbridgeCls.hideSaltbridge(),s="set contact off",t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.contactCls.hideContact(),s="set halogen pi off",t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.piHalogenCls.hideHalogenPi(),this.hideExtraBonds()}showIonicInteractions(e,t,s,i,n,l){let r,o,a,d,c=this.icn3d,h=c.icn3dui;if(!i&&(r="saltbridge",o="salt bridge "+e+" | sets "+t+" "+s+" | "+i,c.opts.saltbridge="yes",a=c.definedSetsCls.getAtomsFromNameArray(t),d=c.definedSetsCls.getAtomsFromNameArray(s),c.firstAtomObjCls.getFirstAtomObj(a),Object.keys(d).length>0&&Object.keys(a).length>0)){let t,s=c.saltbridgeCls.calculateIonicInteractions(h.hashUtilsCls.hash2Atoms(d,c.atoms),h.hashUtilsCls.hash2Atoms(a,c.atoms),parseFloat(e),n);c.resid2ResidhashSaltbridge=h.hashUtilsCls.cloneHash(c.resid2Residhash),t="all atoms that have ionic interactions with the selected atoms";let i={};for(let e in s){i[c.atoms[e].structure+"_"+c.atoms[e].chain+"_"+c.atoms[e].resi]=1}c.hAtoms={};for(let e in i)for(let t in c.residues[e])c.hAtoms[t]=1,c.atoms[t].style2="stick",c.ions.hasOwnProperty(t)&&(c.atoms[t].style2="sphere");let l="saltbridge_auto";c.selectionCls.addCustomSelection(Object.keys(i),l,t,o,!0),c.selectionCls.saveSelectionIfSelected(),c.drawCls.draw()}}showHalogenPi(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(i)return;let a,d,c=l+" "+e+" | sets "+t+" "+s+" | "+i;if(r.opts[l]="yes",a=r.definedSetsCls.getAtomsFromNameArray(t),d=r.definedSetsCls.getAtomsFromNameArray(s),r.firstAtomObjCls.getFirstAtomObj(a),Object.keys(d).length>0&&Object.keys(a).length>0){let t,s=r.piHalogenCls.calculateHalogenPiInteractions(o.hashUtilsCls.hash2Atoms(a,r.atoms),o.hashUtilsCls.hash2Atoms(d,r.atoms),parseFloat(e),n,l);"halogen"==l?(r.resid2ResidhashHalogen=o.hashUtilsCls.cloneHash(r.resid2Residhash),t="all atoms that have halogen bonds with the selected atoms"):"pi-cation"==l?(r.resid2ResidhashPication=o.hashUtilsCls.cloneHash(r.resid2Residhash),t="all atoms that have pi-cation interactions with the selected atoms"):"pi-stacking"==l&&(r.resid2ResidhashPistacking=o.hashUtilsCls.cloneHash(r.resid2Residhash),t="all atoms that have pi-stacking with the selected atoms");let i={};for(let e in s){i[r.atoms[e].structure+"_"+r.atoms[e].chain+"_"+r.atoms[e].resi]=1}r.hAtoms={};for(let e in i)for(let t in r.residues[e])r.hAtoms[t]=1,r.atoms[t].style2="stick",r.ions.hasOwnProperty(t)&&(r.atoms[t].style2="sphere");let h=l+"_auto";r.selectionCls.addCustomSelection(Object.keys(i),h,t,c,!0),r.selectionCls.saveSelectionIfSelected(),r.drawCls.draw()}}showClbonds(){let e=this.icn3d,t=e.icn3dui;e.opts.clbonds="yes";let s=e.applyClbondsCls.applyClbondsOptions();for(let i in s)e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.residues[i]);if(Object.keys(s).length>0){let t="clbonds",i="all atoms that have cross-linkages";e.selectionCls.addCustomSelection(Object.keys(s),t,i,"cross linkage",!0),e.selectionCls.saveSelectionIfSelected(),e.drawCls.draw()}}showSsbonds(){let e=this.icn3d,t=e.icn3dui;e.opts.ssbonds="yes";let s={},i=Object.keys(e.structures);for(let n=0,l=i.length;n0){let t="ssbonds",i="all atoms that have disulfide bonds";e.selectionCls.addCustomSelection(Object.keys(s),t,i,"disulfide bonds",!0),e.selectionCls.saveSelectionIfSelected(),e.drawCls.draw()}}pickCustomSphere(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(i)return;let a,d,c="select zone cutoff "+e+" | sets "+t+" "+s+" | "+i;n&&(c="interactions "+e+" | sets "+t+" "+s+" | "+i,r.opts.contact="yes"),a=r.definedSetsCls.getAtomsFromNameArray(t),d=r.definedSetsCls.getAtomsFromNameArray(s);let h,p,m=this.pickCustomSphere_base(e,a,d,i,n,l,c,!0),u=Object.keys(m.residues);r.hAtoms={};for(let e=0,t=u.length;e1?"structure":v>1?"chain":"residue";let w=[];if(n&&w.push("hbonds"),l&&w.push("salt bridge"),r&&w.push("interactions"),o&&w.push("halogen"),a&&w.push("pi-cation"),d&&w.push("pi-stacking"),s||(p.resids2inter={},p.resids2interAll={}),l){let n=parseFloat($("#"+p.pre+"saltbridgethreshold").val());n&&!isNaN(n)||(n=p.tsIonic),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showIonicInteractions(n,e,t,s,!0,i)),g=m.hashUtilsCls.unionHash(g,p.hAtoms)}if(n){let n=parseFloat($("#"+p.pre+"hbondthreshold").val());n&&!isNaN(n)||(n=p.tsHbond),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHbonds(n,e,t,s,void 0,i)),g=m.hashUtilsCls.unionHash(g,p.hAtoms)}let S,A,x,k,O="";if(n&&(O+=this.exportHbondPairs(i,u)),l&&(O+=this.exportSaltbridgePairs(i,u)),o){let n=parseFloat($("#"+p.pre+"halogenthreshold").val());n&&!isNaN(n)||(n=p.tsHalogen),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHalogenPi(n,e,t,s,i,"halogen")),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportHalogenPiPairs(i,u,"halogen")}if(a){let n=parseFloat($("#"+p.pre+"picationthreshold").val());n&&!isNaN(n)||(n=p.tsPication),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHalogenPi(n,e,t,s,i,"pi-cation")),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportHalogenPiPairs(i,u,"pi-cation")}if(d){let n=parseFloat($("#"+p.pre+"pistackingthreshold").val());n&&!isNaN(n)||(n=p.tsPistacking),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHalogenPi(n,e,t,s,i,"pi-stacking")),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportHalogenPiPairs(i,u,"pi-stacking")}if(r){let n=b?c:parseFloat($("#"+p.pre+"contactthreshold").val());if(n&&!isNaN(n)||(n=p.tsContact),1!=e.length||1!=t.length||e[0]!=t[0])s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.pickCustomSphere(n,e,t,s,!0,i)),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportSpherePairs(!0,i,u);else{if(!s){let l={},o={};if(b){let e=!0,t=p.showInterCls.pickCustomSphere_base(n,C,y,s,!0,void 0,void 0,!0,e);l=m.hashUtilsCls.unionHash(l,t.residues);for(let e in t.resid2Residhash)o[e]=m.hashUtilsCls.unionHash(o[e],t.resid2Residhash[e])}else{let r=[],a="",d="",c={};for(let e in C){let t=p.atoms[e];t.ss==a&&t.chain==d||(Object.keys(c).length>0&&r.push(c),c={}),c[t.serial]=1,a=t.ss,d=t.chain}Object.keys(c).length>0&&r.push(c);let h=r.length;A="interactions "+n+" | sets "+e+" "+t+" | true",p.opts.contact="yes";for(let e=0;e
    ",E=p.resid2specCls.atoms2residues(Object.keys(C)),P=p.resid2specCls.atoms2residues(Object.keys(y)),M="select "+p.resid2specCls.residueids2spec(E),D="select "+p.resid2specCls.residueids2spec(P);T+="Set 1: "+e+'
    ',T+="Set 2: "+t+'

    ',T+='
    The interfaces are:
    ';let H=p.resid2specCls.atoms2residues(Object.keys(R)),F=p.resid2specCls.atoms2residues(Object.keys(I)),L="select "+p.resid2specCls.residueids2spec(H),N="select "+p.resid2specCls.residueids2spec(F);T+='interface_1
    ',T+='interface_2

    ',T+='
    Note: Each checkbox below selects the corresponding residue. You can click "Save Selection" in the "Select" menu to save the selection and click on "Highlight" button to clear the checkboxes.

    ';let q=T;if(("graph"==i||"linegraph"==i||"scatterplot"==i||b)&&(T=""),T+=O,"save1"==i||"save2"==i){T=q;let e="";"save1"==i?e="Set 1":"save2"==i&&(e="Set 2"),T+='

    Interactions Sorted on '+e+':
    ';let t=this.getAllInteractionTable(i);T+=t.html,h=t.bondCnt,$("#"+p.pre+"dl_interactionsorted_html").html(T),m.htmlCls.dialogCls.openDlg("dl_interactionsorted","Show sorted interactions")}else if("view"==i)$("#"+p.pre+"dl_allinteraction_html").html(T),m.htmlCls.dialogCls.openDlg("dl_allinteraction","Show interactions");else if("linegraph"==i){m.htmlCls.dialogCls.openDlg("dl_linegraph","Show interactions between two lines of residue nodes"),p.graphStr=p.getGraphCls.getGraphData(C,y,e,t,T,u),p.bLinegraph=!0;let s=p.lineGraphCls.drawLineGraph(p.graphStr);$("#"+p.pre+"linegraphDiv").html(s)}else if("scatterplot"==i){m.htmlCls.dialogCls.openDlg("dl_scatterplot","Show interactions as scatterplot"),p.graphStr=p.getGraphCls.getGraphData(C,y,e,t,T,u),p.bScatterplot=!0;let s=p.lineGraphCls.drawLineGraph(p.graphStr,!0);$("#"+p.pre+"scatterplotDiv").html(s)}else if(b){m.htmlCls.dialogCls.openDlg("dl_contactmap","Show contact map");let s=!0,i=p.getGraphCls.getGraphData(C,y,e,t,T,u,s);p.bContactMap=!0;let n=p.contactMapCls.drawContactMap(i);$("#"+p.pre+"contactmapDiv").html(n)}else if("graph"==i){if(p.graphStr=p.getGraphCls.getGraphData(C,y,e,t,T,u),p.bGraph=!0,Object.keys(y).length+Object.keys(C).length>Object.keys(p.dAtoms).length&&(p.graphStr=p.selectionCls.getGraphDataForDisplayed()),void 0===p.bD3){let e="https://www.ncbi.nlm.nih.gov/Structure/icn3d/script/d3v4-force-all.min.js";await m.getAjaxPromise(e,"script"),p.bD3=!0}$("#"+m.svgid).empty(),m.htmlCls.dialogCls.openDlg("dl_graph","Force-directed graph"),p.drawGraphCls.drawGraph(p.graphStr,p.pre+"dl_graph")}return{interactionTypes:w.toString(),bondCnt:h}}clearInteractions(){let e=this.icn3d;e.icn3dui,e.lines.hbond=[],e.hbondpnts=[],e.lines.saltbridge=[],e.saltbridgepnts=[],e.lines.contact=[],e.contactpnts=[],e.lines.halogen=[],e.lines["pi-cation"]=[],e.lines["pi-stacking"]=[],e.halogenpnts=[],e.picationpnts=[],e.pistackingpnts=[]}resetInteractionPairs(){let e=this.icn3d;e.icn3dui,e.bHbondCalc=!1,e.showInterCls.hideHbondsContacts(),e.hlUpdateCls.clearHighlight(),e.resids2inter={},e.resids2interAll={}}async retrieveInteractionData(){let e=this.icn3d,t=e.icn3dui;if(!e.b2DShown)if(void 0!==t.cfg.align){let s=Object.keys(e.structures);if(2==t.cfg.atype){let t=!0;await e.alignParserCls.downloadAlignment(s[0]+","+s[1],t)}await e.ParserUtilsCls.set2DDiagramsForAlign(s[0].toUpperCase(),s[1].toUpperCase())}else void 0!==t.cfg.chainalign?(Object.keys(e.structures),await e.ParserUtilsCls.set2DDiagramsForChainalign(e.chainidArray)):e.ParserUtilsCls.download2Ddgm(e.inputid.toUpperCase())}getAllInteractionTable(e){let t=this.icn3d,s=t.icn3dui,i=[],n=Object.keys(t.resids2inter);("save1"==e||"save2"==e)&&n.sort((function(t,i){return s.utilsCls.compResid(t,i,e)}));let l,r,o="",a="",d="",c="",h="",p="",m="",u="",g="",f=0,b=0,C=0,y=0,v=0,_=0,w="";for(let s=0,S=n.length;s0&&l!=a&&(i.push({res1:a,res2:w,cntHbond:f,cntIonic:b,cntContact:C,cntHalegen:y,cntPication:v,cntPistacking:_}),o+=this.getInteractionPerResidue(d,c,h,p,m,u,g,f,b,C,y,v,_),c="",h="",p="",m="",u="",g="",f=0,b=0,C=0,y=0,v=0,_=0,w=""),x=t.resids2inter[S].hbond,k=this.getInteractionPairDetails(x,e,"hbond"),c+=k.html,f+=k.cnt,k.cnt>0&&(w+=r+":hbond_"+k.cnt+" "),x=t.resids2inter[S].ionic,k=this.getInteractionPairDetails(x,e,"ionic"),h+=k.html,b+=k.cnt,k.cnt>0&&(w+=r+":ionic_"+k.cnt+" "),x=t.resids2inter[S].contact,k=this.getContactPairDetails(x,e,"contact"),p+=k.html,C+=k.cnt,k.cnt>0&&(w+=r+":contact_"+k.cnt+" "),x=t.resids2inter[S].halogen,k=this.getInteractionPairDetails(x,e,"halogen"),m+=k.html,y+=k.cnt,k.cnt>0&&(w+=r+":halogen_"+k.cnt+" "),x=t.resids2inter[S]["pi-cation"],k=this.getInteractionPairDetails(x,e,"pi-cation"),u+=k.html,v+=k.cnt,k.cnt>0&&(w+=r+":pi-cation_"+k.cnt+" "),x=t.resids2inter[S]["pi-stacking"],k=this.getInteractionPairDetails(x,e,"pi-stacking"),g+=k.html,_+=k.cnt,k.cnt>0&&(w+=r+":pi-stacking_"+k.cnt+" "),a=l,d=O}i.push({res1:a,res2:w,cntHbond:f,cntIonic:b,cntContact:C,cntHalegen:y,cntPication:v,cntPistacking:_}),o+=this.getInteractionPerResidue(d,c,h,p,m,u,g,f,b,C,y,v,_);let S="";if(n.length>0){S+='
    ',S+="",S+="",S+="",S+="",S+="";let e='';S+=e,S+=e,S+='',S+=e,S+=e,S+=e,S+="",S+="",S+=o,S+="
    Residue# Hydrogen
    Bond
    # Salt Bridge
    /Ionic Interaction
    # Contact# Halogen
    Bond
    # π-Cation# π-StackingHydrogen Bond (backbone atoms: @CA, @N, @C, @O)Salt Bridge/Ionic InteractionContactHalogen Bondπ-Cationπ-Stacking
    Atom1Atom2Distance(Å)Highlight in 3D
    Atom1Atom2# ContactsMin Distance(Å)C-alpha Distance(Å)Highlight in 3D

    "}return{html:S,bondCnt:i}}getInteractionPerResidue(e,t,s,i,n,l,r,o,a,d,c,h,p){this.icn3d.icn3dui;let m="";m+=''+e[3]+e[2]+""+o+""+a+""+d+""+c+""+h+""+p+"";let u=[t,s,i,n,l,r];for(let e in u){m+=''+u[e]+"
    "}return m+="",m}getInteractionPairDetails(e,t,s){let i=this.icn3d;i.icn3dui;let n="",l=0,r='    ';if(void 0!==e)for(let a in e){let d=a.split(","),c="save1"==t?d[0]:d[1],h="save1"==t?d[1]:d[0],p=i.getGraphCls.convertLabel2Resid(c),m=i.firstAtomObjCls.getFirstAtomObj(i.residues[p]),u=m.color?m.color.getHexString():"",g=i.getGraphCls.convertLabel2Resid(h),f=i.firstAtomObjCls.getFirstAtomObj(i.residues[g]),b=f.color?f.color.getHexString():"",C=Math.sqrt(e[a]).toFixed(1);n+=' '+c+r+u+o+' '+h+r+b+o+''+C+"",n+='',n+="",++l}return{html:n,cnt:l}}getContactPairDetails(e,t){let s=this.icn3d;s.icn3dui;let i="",n=0,l='    ';if(void 0!==e)for(let o in e){let a=o.split(","),d="save1"==t?a[0]:a[1],c="save1"==t?a[1]:a[0],h=s.getGraphCls.convertLabel2Resid(d),p=s.firstAtomObjCls.getFirstAtomObj(s.residues[h]),m=p.color?p.color.getHexString():"",u=s.getGraphCls.convertLabel2Resid(c),g=s.firstAtomObjCls.getFirstAtomObj(s.residues[u]),f=g.color?g.color.getHexString():"",b=e[o].split("_"),C=b[0],y=b[1],v=b[2],_=b[3],w=b[4];i+=' '+d+"@"+v+l+m+r+' '+c+"@"+_+l+f+r+''+w+''+C+''+y+"",i+='',i+="",n+=parseInt(w)}return{html:i,cnt:n}}exportInteractions(){var e=this.icn3d,t=e.icn3dui;let s='

    Interacting residues:
    ';for(let t in e.chainname2residues)for(let i in e.chainname2residues[t]){let n=t.substr(0,t.indexOf("_"))+"_"+i.substr(0,i.indexOf(" "));s+=""}s+="
    Base Chain: ResiduesInteracting Chain
    "+t+": ",s+=e.resid2specCls.residueids2spec(e.chainname2residues[t][i]),s+=""+n+"

    ";let i=Object.keys(t.utilsCls.getHlStructures()).join(",");e.saveFileCls.saveFile(i+"_interactions.html","html",s)}exportSsbondPairs(){var e=this.icn3d,t=e.icn3dui;let s="",i=0;for(let t in e.structures){let n=e.ssbondpnts[t];if(void 0===n)break;for(let e=0,t=n.length;e"+n[e]+" Cys"+n[e+1]+" Cys",++i}}let n='

    '+i+" disulfide pairs:

    ";n+=s,n+="
    Residue ID 1Residue ID 2

    ";let l=Object.keys(t.utilsCls.getHlStructures()).join(",");e.saveFileCls.saveFile(l+"_disulfide_pairs.html","html",n)}exportClbondPairs(){var e=this.icn3d,t=e.icn3dui;let s="",i=0,n={};for(let t in e.structures){let l=e.clbondpnts[t];if(void 0===l)break;for(let t=0,r=l.length;t"+r+" "+t.resn+""+o+" "+n.resn+"",++i}n[r+"_"+o]=1,n[o+"_"+r]=1}}let l='

    '+i+" cross-linkage pairs:

    ";l+=s,l+="
    Residue ID 1Residue ID 2

    ";let r=Object.keys(t.utilsCls.getHlStructures()).join(",");e.saveFileCls.saveFile(r+"_crosslinkage_pairs.html","html",l)}exportHbondPairs(e,t){var s=this.icn3d,i=s.icn3dui;let n="",l=0,r='    ';for(let t in s.resid2ResidhashHbond){let i=s.getGraphCls.convertLabel2Resid(t),a=s.firstAtomObjCls.getFirstAtomObj(s.residues[i]),d=a.color?a.color.getHexString():"";for(let i in s.resid2ResidhashHbond[t]){let a=s.getGraphCls.convertLabel2Resid(i),c=s.firstAtomObjCls.getFirstAtomObj(s.residues[a]),h=c.color?c.color.getHexString():"",p=Math.sqrt(s.resid2ResidhashHbond[t][i]).toFixed(1);n+=' '+t+r+d+o+' '+i+r+h+o+''+p+"","view"==e&&(n+=''),n+="",++l}}let a='

    '+l+" hydrogen bond pairs (backbone atoms: @CA, @N, @C, @O):

    ";if(l>0&&(a+="
    ","view"==e&&(a+=''),a+="",a+=n,a+="
    Atom 1Atom 2Distance(Å)Highlight in 3D

    "),"graph"==e||"linegraph"==e||"scatterplot"==e){return s.getGraphCls.getGraphLinks(s.resid2ResidhashHbond,s.resid2ResidhashHbond,i.htmlCls.hbondColor,t,i.htmlCls.hbondValue)}return a}exportSaltbridgePairs(e,t){var s=this.icn3d,i=s.icn3dui;let n="",l=0,r='    ';for(let t in s.resid2ResidhashSaltbridge){let i=s.getGraphCls.convertLabel2Resid(t),a=s.firstAtomObjCls.getFirstAtomObj(s.residues[i]),d=a.color?a.color.getHexString():"";for(let i in s.resid2ResidhashSaltbridge[t]){let a=s.getGraphCls.convertLabel2Resid(i),c=s.firstAtomObjCls.getFirstAtomObj(s.residues[a]),h=c.color?c.color.getHexString():"",p=Math.sqrt(s.resid2ResidhashSaltbridge[t][i]).toFixed(1);n+=' '+t+r+d+o+' '+i+r+h+o+''+p+"","view"==e&&(n+=''),n+="",++l}}let a='

    '+l+" salt bridge/ionic interaction pairs:

    ";if(l>0&&(a+="
    ","view"==e&&(a+=''),a+="",a+=n,a+="
    Atom 1Atom 2Distance(Å)Highlight in 3D

    "),"graph"==e||"linegraph"==e||"scatterplot"==e){return s.getGraphCls.getGraphLinks(s.resid2ResidhashSaltbridge,s.resid2ResidhashSaltbridge,i.htmlCls.ionicColor,t,i.htmlCls.ionicValue)}return a}exportHalogenPiPairs(e,t,s){var i=this.icn3d,n=i.icn3dui;let l,r,o,a="",d=0,c='    ';"halogen"==s?(l=i.resid2ResidhashHalogen,r=n.htmlCls.halogenColor,o=n.htmlCls.halogenValue):"pi-cation"==s?(l=i.resid2ResidhashPication,r=n.htmlCls.picationColor,o=n.htmlCls.picationValue):"pi-stacking"==s&&(l=i.resid2ResidhashPistacking,r=n.htmlCls.pistackingColor,o=n.htmlCls.pistackingValue);for(let t in l){let n=i.getGraphCls.convertLabel2Resid(t),r=i.firstAtomObjCls.getFirstAtomObj(i.residues[n]),o=r.color?r.color.getHexString():"";for(let n in l[t]){let r=i.getGraphCls.convertLabel2Resid(n),p=i.firstAtomObjCls.getFirstAtomObj(i.residues[r]),m=p.color?p.color.getHexString():"",u=Math.sqrt(l[t][n]).toFixed(1);a+=' '+t+c+o+h+' '+n+c+m+h+''+u+"","view"==e&&(a+=''),a+="",++d}}let p='

    '+d+" "+s+" pairs:

    ";if(d>0&&(p+="
    ","view"==e&&(p+=''),p+="",p+=a,p+="
    Atom 1Atom 2Distance(Å)Highlight in 3D

    "),"graph"==e||"linegraph"==e||"scatterplot"==e){return i.getGraphCls.getGraphLinks(l,l,r,t,o)}return p}exportSpherePairs(e,t,s){var i=this.icn3d,n=i.icn3dui;let l="",r=0,o=e?i.resid2ResidhashInteractions:i.resid2ResidhashSphere,a='    ';for(let s in o){let n=i.getGraphCls.convertLabel2Resid(s),c=i.firstAtomObjCls.getFirstAtomObj(i.residues[n]),h=c.color?c.color.getHexString():"";for(let n in o[s]){let p=i.getGraphCls.convertLabel2Resid(n),m=i.firstAtomObjCls.getFirstAtomObj(i.residues[p]),u=m.color?m.color.getHexString():"",g=o[s][n].split("_"),f=g[0],b=g[1];c=g[2],m=g[3];let C=g[4];e?(l+=' '+s+"@"+c+a+h+d+' '+n+"@"+m+a+u+d+''+C+''+f+''+b+"","view"==t&&(l+=''),l+=""):l+=""+s+""+n+''+C+''+f+''+b+"",++r}}let c='

    '+r+" residue pairs in "+(e?"the contacts":"sphere")+":

    ";if(r>0&&(e?(c+='
    ',"view"==t&&(c+=''),c+=""):c+='
    Residue 1Residue 2Num ContactsMin Distance(Å)C-alpha Distance(Å)Highlight in 3D
    ',c+=l,c+="
    Residue 1Residue 2Num ContactsMin Distance(Å)C-alpha Distance(Å)

    "),"graph"==t||"linegraph"==t||"scatterplot"==t||"calpha"==t||"cbeta"==t||"heavyatoms"==t){return i.getGraphCls.getGraphLinks(o,o,n.htmlCls.contactColor,s,n.htmlCls.contactValue)}return c}}class $t{constructor(e){this.icn3d=e}drawGraph(e,t){var s=this.icn3d,i=s.icn3dui;if(void 0===n)var n=d3;var l=JSON.parse(e),r=$("#"+t).width(),o=$("#"+t).height(),a=isNaN(r)?300:1*r,d=isNaN(o)?300:1*o,c=r,h=o,p=d3.select("#"+i.svgid).attr("width",r).attr("height",o).attr("viewBox","0,0,"+a+","+d);p.selectAll(".g-main").remove();var m=p.append("g").classed("g-main",!0),u=m.append("rect").attr("width",c).attr("height",h).style("fill","#FFF"),g=m.append("g"),f=n.zoom().on("zoom",(function(){g.attr("transform",n.event.transform)}));if(m.call(f),l.links){for(var b=[],C={},y=0,v=l.nodes.length;y0?n.structures[0]:n.defaultPdbId;p=10*(a.length+2)+20+30,h=10*(d.length+2)+20+30,t?(n.alignerrormapWidth=2*h,u=n.alignerrormapWidth,m=l.alignerrormapid):(n.contactmapWidth=2*h,u=n.contactmapWidth,m=l.contactmapid),i=o.length>0?"":"No interactions found for these two sets

    ",i+="";if(t){n.hex2id={};let e=29/s;n.hex2skip={};let t=1e3;for(let s=0;se&&(n.hex2skip[d]=c)}}if(i+=n.lineGraphCls.drawScatterplot_base(a,d,o,c,0,!0,void 0,void 0,t),g+=n.getGraphCls.updateGraphJson(f,1,a,d,o),i+="",g+="}\n",t){n.alignerrormapStr=g,$("#"+n.pre+"alignerrormapDiv").html(i);let e=$("#"+l.alignerrormapid+"_scale").val();$("#"+l.alignerrormapid).attr("width",(n.alignerrormapWidth*parseFloat(e)).toString()+"px")}else n.contactmapStr=g,$("#"+n.pre+"contactmapDiv").html(i);return i}}class Bt{constructor(e){this.icn3d=e}async downloadAlignment(e,t){let s=this.icn3d,i=s.icn3dui,n=this;s.opts.proteins="c alpha trace";let l=e.split(","),r="ids="+e,o=i.htmlCls.baseUrl+"vastplus/vastplus.cgi?v=3&cmd=c&b=1&s=1&w3d&"+r;void 0!==i.cfg.inpara&&(o+=i.cfg.inpara),s.pdbid_chain2title={},void 0===s.chainids2resids&&(s.chainids2resids={});let a={},d="These two MMDB IDs "+l+' do not have 3D alignment data in the VAST+ database. You can try the VAST alignment by visiting the VAST+ page https://www.ncbi.nlm.nih.gov/Structure/vastplus/vastplus.cgi?uid=[PDB ID] (e.g., uid=1KQ2), and clicking "Original VAST"',c=await i.getAjaxPromise(o,"jsonp",!0,d);if(a=c.seqalign,void 0===a)return alert(d),!1;s.pdbid_molid2chain={},s.chainsColor={};for(let e=0,t=2;e5){let t=!1,s=!0;d=await r.pdbParserCls.loadPdbData(e,n,!1,t,"target",h,s)}else{let t=!0;d=await r.mmdbParserCls.parseMmdbData(e,"target",i[0],0,h,t)}for(let e=0,s=t.length;e5){let s=!0,i=!0;c=await r.pdbParserCls.loadPdbData(t[e],l,!1,s,"query",h,i)}else{let s=!0;c=await r.mmdbParserCls.parseMmdbData(t[e],"query",i[e+1],e,h,s)}d=o.hashUtilsCls.unionHash(d,c)}if(o.cfg.resnum)await r.realignParserCls.realignChainOnSeqAlign(s,i);else if(o.cfg.resdef)await r.realignParserCls.realignChainOnSeqAlign(s,i,void 0,!0);else{await r.pdbParserCls.applyCommandDssp(!0);for(let e in r.pdbChainIndexHash){let t=r.pdbChainIndexHash[e].split("_");l=t[0],t[1],n=t[2],t[3],a.transformStructure(l,e-1,"query")}let e=[],t=[],c=[],h=o.htmlCls.baseUrl+"vastdyn/vastdyn.cgi",p=o.htmlCls.baseUrl+"tmalign/tmalign.cgi";for(let s in r.afChainIndexHash){let i=r.afChainIndexHash[s].split("_");l=i[0];let a=i[1];n=i[2];let d,m=i[3];if("tmalign"!=o.cfg.aligntool){let e={domains1:r.domain3dCls.getDomainJsonForAlign(r.chains[l+"_"+a]),domains2:r.domain3dCls.getDomainJsonForAlign(r.chains[n+"_"+m])};d=o.getAjaxPostPromise(h,e)}else{let e={pdb_query:r.saveFileCls.getAtomPDB(r.chains[l+"_"+a]),pdb_target:r.saveFileCls.getAtomPDB(r.chains[n+"_"+m])};d=o.getAjaxPostPromise(p,e)}e.push(d),t.push(s-1),c.push(l)}let m=Promise.allSettled(e),u=await m;await a.downloadChainalignmentPart2b(s,i,d,u,t,n,c)}}async downloadChainalignmentPart2b(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui;for(let e=0,t=i.length;ec&&(c=l[t[0]],a=t[0]),l[t[1]]>c&&(c=l[t[1]],a=t[1])}let h={},p={},m={},u={};for(let e in r){let t,s,i=e.split("_"),n=r[e].split(","),l=n[2];a==i[0]?(t=i[0],s=i[1]):a==i[1]?(t=i[1],s=i[0]):(t=i[0],s=i[1]),m[t]=1,m.hasOwnProperty(s)||(m[s]=1,u[e]=r[e],d="target",this.transformStructure(t,l,d),d="query",this.transformStructure(s,l,d),h[n[0]]=1,h[n[1]]=1)}for(let e in u)if(void 0!==i.q_rotation){let t=u[e].split(","),s=[t[1],t[0],t[2]],l=i.setSeqAlignCls.setSeqAlignChain(void 0,void 0,s);p=n.hashUtilsCls.unionHash(p,l);let r=!1,o=n.htmlCls.alignSeqCls.getAlignSequencesAnnotations(Object.keys(i.alnChains),void 0,void 0,!1,void 0,r),a=$("#"+i.pre+"dl_sequence2").html();$("#"+i.pre+"dl_sequence2").html(a+o.sequencesHtml),$("#"+i.pre+"dl_sequence2").width(n.htmlCls.RESIDUE_WIDTH*o.maxSeqCnt+200)}i.dAtoms=n.hashUtilsCls.cloneHash(p),i.hAtoms=n.hashUtilsCls.cloneHash(p);let g="protein_aligned";i.selectionCls.saveSelection(g,g),i.opts.color="identity",i.setColorCls.setColorByOptions(i.opts,i.hAtoms),n.htmlCls.dialogCls.openDlg("dl_alignment","Select residues in aligned sequences"),i.drawCls.draw(),i.transformCls.zoominSelection(),i.hlUpdateCls.updateHlAll()}transformStructure(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=n.structures[e];for(let e=0,o=r.length;e2){let e=i.firstAtomObjCls.getResiduesFromAtoms(s),t="protein_aligned",n="protein aligned",l="select "+i.resid2specCls.residueids2spec(Object.keys(e));i.selectionCls.addCustomSelection(Object.keys(e),t,n,l,!0)}i.hlUpdateCls.updateHlAll(),n.htmlCls.dialogCls.openDlg("dl_alignment","Select residues in aligned sequences"),void 0!==n.cfg.rotate&&i.resizeCanvasCls.rotStruc(n.cfg.rotate,!0),i.html2ddgm="",n.cfg.show2d&&i.bFullUi&&(n.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions"),i.bFullUi&&(i.bChainAlign?await i.ParserUtilsCls.set2DDiagramsForChainalign(t):i.ParserUtilsCls.download2Ddgm(i.inputid.toUpperCase())))}addPostfixForChainids(e){this.icn3d.icn3dui;let t={};for(let s=0,i=e.length;s5?(d="https://alphafold.ebi.ac.uk/files/AF-"+i.mmdbid_t+"-F1-model_"+i.AFUniprotVersion+".pdb",a=n.getAjaxPromise(d,"text")):(d=n.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+n.cfg.bu+"&uid="+i.mmdbid_t,void 0!==n.cfg.inpara&&(d+=n.cfg.inpara),a=n.getAjaxPromise(d,"jsonp")),c.push(a),i.ParserUtilsCls.setYourNote(e.toUpperCase()+" in iCn3D"),i.pdbid_chain2title={},void 0===i.chainids2resids&&(i.chainids2resids={}),i.afChainIndexHash={},i.pdbChainIndexHash={};for(let e=1,t=l.length;e5?(t="https://alphafold.ebi.ac.uk/files/AF-"+i.mmdbid_q+"-F1-model_"+i.AFUniprotVersion+".pdb",s=n.getAjaxPromise(t,"text")):(t=n.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+n.cfg.bu+"&uid="+i.mmdbid_q,void 0!==n.cfg.inpara&&(t+=n.cfg.inpara),s=n.getAjaxPromise(t,"jsonp")),c.push(s)}for(let e=1,t=l.length;e0?r[e]+","+r[0]:void 0;if("tmalign"!=n.cfg.aligntool&&4==i.mmdbid_t.length&&4==i.mmdbid_q.length){let o;o=r.length>0?n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?domainpairs="+l:n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainpairs="+t;let a=n.getAjaxPromise(o,"jsonp");c.push(a),i.pdbChainIndexHash[e]=s+"_"+i.chain_q+"_"+i.mmdbid_t+"_"+i.chain_t}else i.afChainIndexHash[e]=i.mmdbid_q+"_"+i.chain_q+"_"+i.mmdbid_t+"_"+i.chain_t}}let h=Promise.allSettled(c),p=await h;await this.parseChainAlignData(p,l,i.mmdbid_t,i.chain_t)}async parseChainAlignData(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=e[0].value,o="HEADER "+s+"\n";isNaN(s)&&s.length>5&&(r=o+r),n.t_trans_add=[],n.q_trans_sub=[],"tmalign"==l.cfg.aligntool&&(n.q_trans_add=[]),n.q_rotation=[],n.qt_start_end=[],n.mmdbidArray=[],n.mmdbidArray.push(s);let a=[];for(let s=1,i=t.length;s5&&(i=o+i),void 0===i||-1!==JSON.stringify(i).indexOf("Oops there was a problem"))return void alert("The coordinate data can NOT be retrieved for the structure "+r+"...");n.mmdbidArray.push(r),a.push(i)}let d=0;for(let r=1,o=t.length;r";"tmalign"==o.cfg.aligntool&&(n+="TM-score: "+e[0].score.toPrecision(4)+"

    ",r.tmscore=e[0].score.toPrecision(4)),$("#"+r.pre+"dl_rmsd_html").html(n),o.cfg.bSidebyside||o.htmlCls.dialogCls.openDlg("dl_rmsd","RMSD of alignment"),a=!0}return a}async loadOpmDataForChainalign(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=this;if(l.cfg.resnum||l.cfg.resdef)n.bCommandLoad||n.init(),await this.downloadChainalignmentPart2(e,t,void 0,s);else{let o=l.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?mmdbids2opm="+i.join("','"),a=await l.getAjaxPromise(o,"jsonp");if(a&&a.mmdbid){let i=a.mmdbid;n.selectedPdbid=i;let o="https://opm-assets.storage.googleapis.com/pdb/"+i.toLowerCase()+".pdb",d=await l.getAjaxPromise(o,"text");n.bOpm=!0;let c=!0,h=n.loadPDBCls.loadPDB(d,i,n.bOpm,c);$("#"+n.pre+"selectplane_z1").val(n.halfBilayerSize),$("#"+n.pre+"selectplane_z2").val(-n.halfBilayerSize),$("#"+n.pre+"extra_mem_z").val(n.halfBilayerSize),$("#"+n.pre+"intra_mem_z").val(-n.halfBilayerSize),n.bCommandLoad||n.init(),await r.downloadChainalignmentPart2(e,t,h,s)}else n.bCommandLoad||n.init(),await r.downloadChainalignmentPart2(e,t,void 0,s)}}async downloadMmdbAf(e,t,s){let i=this.icn3d,n=i.icn3dui;i.structArray=i.structures?Object.keys(i.structures):[],0==i.structArray.length?i.init():(i.resetConfig(),i.bResetAnno=!0,i.bResetSets=!0);let l=e.split(","),r=[];for(let e=0,t=l.length;e5)t="https://alphafold.ebi.ac.uk/files/AF-"+l+"-F1-model_"+i.AFUniprotVersion+".pdb",s=n.getAjaxPromise(t,"text");else{let e=l;5==l.length&&(e=l.substr(0,4)),t=n.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+n.cfg.bu+"&uid="+e,void 0!==n.cfg.inpara&&(t+=n.cfg.inpara),s=n.getAjaxPromise(t,"jsonp")}o.push(s)}i.ParserUtilsCls.setYourNote(i.structArray+" in iCn3D"),i.ParserUtilsCls.showLoading();let a=Promise.allSettled(o),d=await a;await this.parseMMdbAfData(d,r,t,s),void 0===s&&i.ParserUtilsCls.hideLoading()}async parseMMdbAfData(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=[];for(let s=0,i=t.length;s5&&(i=n+i),void 0===i||-1!==JSON.stringify(i).indexOf("Oops there was a problem"))return void alert("The coordinate data can NOT be retrieved for the structure "+t[s]+"...");r.push(i)}let o={},a={},d=!1;n.opts.color=n.structArray.length>1?"structure":t[0].length>5?"confidence":"chain";for(let e=0,i=t.length;e5){let s=!1;a=await n.pdbParserCls.loadPdbData(r[e],t[e],!1,c,i,d,s)}else{let s=!0,l=t[e];a=await n.mmdbParserCls.parseMmdbData(r[e],i,void 0,void 0,d,s,l)}o=l.hashUtilsCls.unionHash(o,a)}if(n.structArray.length>1&&(n.opts.color="structure"),n.setColorCls.setColorByOptions(n.opts,n.atoms),await n.ParserUtilsCls.renderStructure(),void 0!==l.cfg.rotate&&n.resizeCanvasCls.rotStruc(l.cfg.rotate,!0),s&&l.cfg.matchedchains){let e=!0,t=!0;await n.realignParserCls.realignChainOnSeqAlign(void 0,n.chainidArray,e,t),$("#"+n.pre+"dl_annotations").html(""),n.bAnnoShown=!1,$("#"+l.pre+"dl_selectannotations").hasClass("ui-dialog-content")&&$("#"+n.pre+"dl_selectannotations").dialog("isOpen")&&$("#"+n.pre+"dl_selectannotations").dialog("close")}else if(void 0!==i){let e=Object.keys(n.structures);await n.vastplusCls.vastplusAlign(e,i)}}}class Gt{constructor(e){this.icn3d=e}async dsn6Parser(e,t,s){this.icn3d.icn3dui;let i="https://edmaps.rcsb.org/maps/"+e.toLowerCase()+"_"+t+".dsn6";await this.dsn6ParserBase(i,t,s)}async dsn6ParserBase(e,t,s){let i=this.icn3d,n=i.icn3dui,l=this;if("2fofc"==t&&i.bAjax2fofc)i.mapData.sigma2=s,i.setOptionCls.setOption("map",t);else if("fofc"==t&&i.bAjaxfofc)i.mapData.sigma=s,i.setOptionCls.setOption("map",t);else{let r=await n.getXMLHttpRqstPromise(e,"GET","arraybuffer","rcsbEdmaps");l.loadDsn6Data(r,t,s),"2fofc"==t?i.bAjax2fofc=!0:"fofc"==t&&(i.bAjaxfofc=!0),i.setOptionCls.setOption("map",t)}}loadDsn6Data(e,t,s){let i=this.icn3d;i.icn3dui;let n,l,r={},o=e.buffer&&e.buffer instanceof ArrayBuffer?e.buffer:e,a=new Int16Array(o),d=new Uint8Array(o),c=String.fromCharCode.apply(null,d.subarray(0,512));if(0==c.indexOf(":-)"))r.xStart=parseInt(c.substr(10,5)),r.yStart=parseInt(c.substr(15,5)),r.zStart=parseInt(c.substr(20,5)),r.xExtent=parseInt(c.substr(32,5)),r.yExtent=parseInt(c.substr(38,5)),r.zExtent=parseInt(c.substr(42,5)),r.xRate=parseInt(c.substr(52,5)),r.yRate=parseInt(c.substr(58,5)),r.zRate=parseInt(c.substr(62,5)),r.xlen=1*parseFloat(c.substr(73,10)),r.ylen=1*parseFloat(c.substr(83,10)),r.zlen=1*parseFloat(c.substr(93,10)),r.alpha=parseFloat(c.substr(103,10)),r.beta=parseFloat(c.substr(113,10)),r.gamma=parseFloat(c.substr(123,10)),n=parseFloat(c.substr(138,12))/100,l=parseInt(c.substr(155,8)),r.sigma=100*parseFloat(c.substr(170,12));else{if(100!==a[18])for(let e=0,t=a.length;e>8&255}r.zStart=a[2],r.xStart=a[0],r.yStart=a[1],r.xExtent=a[3],r.yExtent=a[4],r.zExtent=a[5],r.xRate=a[6],r.yRate=a[7],r.zRate=a[8];let e=1/a[17],t=1*e;r.xlen=a[9]*t,r.ylen=a[10]*t,r.zlen=a[11]*t,r.alpha=a[12]*e,r.beta=a[13]*e,r.gamma=a[14]*e,n=a[15]/a[18],l=a[16]}let h=new Float32Array(r.xExtent*r.yExtent*r.zExtent),p=512,m=Math.ceil(r.xExtent/8),u=Math.ceil(r.yExtent/8),g=Math.ceil(r.zExtent/8);for(let e=0;es.maxatomcnt&&(s.bAssembly=!0)}if("mmtfid"===t&&void 0!==o.missingseq){let t=0,n="";for(let l=0,r=o.missingseq.length;lt)&&(s.chainMissingResidueArray[c].push(h),t=d,n=a)}s.loadPDBCls.adjustSeq(s.chainMissingResidueArray)}}async loadMmcifData(e,t){let s=this.icn3d;if(s.icn3dui,t||(t=e.mmcif),t||(t=s.defaultPdbId),void 0===e.atoms)return!1;s.init(),void 0!==e.emd&&(s.emd=e.emd),void 0!==e.organism&&(s.organism=e.organism),void 0!==s.emd?($("#"+s.pre+"mapWrapper1").hide(),$("#"+s.pre+"mapWrapper2").hide(),$("#"+s.pre+"mapWrapper3").hide()):($("#"+s.pre+"emmapWrapper1").hide(),$("#"+s.pre+"emmapWrapper2").hide(),$("#"+s.pre+"emmapWrapper3").hide()),await s.opmParserCls.loadOpmData(e,t,void 0,"mmcif")}}class Wt{constructor(e){this.icn3d=e}async downloadMmdb(e,t){let s,i=this.icn3d,n=i.icn3dui;try{if(s=await this.loadMmdbPrms(e,t),!s||s.error)return void this.getNoData(e,t)}catch(s){return void this.getNoData(e,t)}if(0!=Object.keys(s.atoms).length)if(n.utilsCls.isCalphaPhosOnly(s.atoms)||s.atomCount<=i.maxatomcnt)await this.parseMmdbData(s);else{let s;try{s=await this.loadMmdbPrms(e,t,!0)}catch(s){return void this.getNoData(e,t)}await this.parseMmdbData(s)}else{let e=s.pdbId;await i.mmtfParserCls.downloadMmtf(e)}}async downloadGi(e){let t=this.icn3d;t.icn3dui,t.bCid=void 0;await this.downloadMmdb(e,!0)}async downloadBlast_rep_id(e){let t=this.icn3d,s=t.icn3dui,i=e.split(",");s.cfg.query_id=i[0],s.cfg.blast_rep_id=i[1];let n=s.cfg.blast_rep_id.split("_")[0];4==n.length?await this.downloadMmdb(n):(t.blastAcxn=s.cfg.blast_rep_id.split(".")[0],await this.downloadRefseq(t.blastAcxn,!0))}async downloadRefseq(e,t){let s=this.icn3d,i=s.icn3dui,n=i.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?refseq2uniprot="+e;i.cfg.refseqid=e;let l=await i.getAjaxPromise(n,"jsonp",!1,"The protein accession "+e+" can not be mapped to AlphaFold UniProt ID...");if(!l||!l.uniprot)return void alert("The accession "+e+" can not be mapped to AlphaFold UniProt ID. It will be treated as a UniProt ID instead.");i.cfg.afid=l.uniprot,s.uniprot2acc||(s.uniprot2acc={}),s.uniprot2acc[l.uniprot]=e,t&&(i.cfg.blast_rep_id=i.cfg.afid+"_A");await s.pdbParserCls.downloadPdb(i.cfg.afid,!0)}async downloadProteinname(e){let t=this.icn3d,s=t.icn3dui;s.icn3d.bCid=void 0;let i=s.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?protein2acc="+e,n=(await s.getAjaxPromise(i,"jsonp")).acc;if(0==n.length)return void(s.bNode||alert("The protein/gene name "+e+" can not be mapped to RefSeq proteins..."));let l=[];for(let e=0,t=n.length;e=20231001||!i.cfg.date&&parseInt(i.utilsCls.getDateDigitStr())>=20231001)&&(h=h.replace(/_/g,"")),void 0===d[h]?d[h]=1:++d[h];let p=n+"_"+(1===d[h]?h:h+d[h].toString());r[e]=c,o[p]=e,a[e]=p,s.chainsColor[p]=void 0===t||i.cfg.mmdbafid?i.parasCls.thr(c):i.parasCls.thr(i.htmlCls.GREY8);let m=void 0===l[e].geneId?"":l[e].geneId,u=void 0===l[e].geneSymbol?"":l[e].geneSymbol,g=void 0===l[e].geneDesc?"":l[e].geneDesc;s.chainsGene[p]={geneId:m,geneSymbol:u,geneDesc:g}}s.molid2chain=a,$("#"+s.pre+"accordion5").show()}loadMmdbPrms(e,t,s){let i,n=this.icn3d,l=n.icn3dui;return i=t?l.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+l.cfg.bu+"&simple=1&gi="+e:l.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+l.cfg.bu+"&simple=1&uid="+e,void 0!==l.cfg.blast_rep_id&&(i+="&bu=0"),void 0!==l.cfg.inpara&&(i+=l.cfg.inpara),s&&(i+="&complexity=2"),void 0===n.chainids2resids&&(n.chainids2resids={}),l.getAjaxPromise(i,"jsonp",!0)}}class Yt{constructor(e){this.icn3d=e}async downloadMmtf(e){let t=this.icn3d,s=t.icn3dui;t.ParserUtilsCls.setYourNote(e.toUpperCase()+"(MMTF) in iCn3D");let i=await s.getMmtfReducedPromise(e);if(10*i.numAtoms>t.maxatomcnt){let s=!1;if(0==Object.keys(i).length)return void alert("This PDB structure is not found at RCSB...");await t.opmParserCls.loadOpmData(i,e,s,"mmtf")}else{let i=await s.getMmtfPromise(e),n=!0;if(0==Object.keys(i).length)return void alert("This PDB structure is not found at RCSB...");await t.opmParserCls.loadOpmData(i,e,n,"mmtf")}}async parseMmtfData(e,t,s){let i=this.icn3d,n=i.icn3dui;e.numAtoms,i.init();let l=new THREE.Vector3(9999,9999,9999),r=new THREE.Vector3(-9999,-9999,-9999),o=new THREE.Vector3,a=e.structureId;if(i.molTitle=e.title,void 0!==e.bioAssemblyList&&void 0!==e.bioAssemblyList[0]&&e.bioAssemblyList[0].transformList.length>1){i.biomtMatrices=[];for(let t=0,s=e.bioAssemblyList[0].transformList.length;t1&&($("#"+i.pre+"assemblyWrapper").show(),i.asuCnt=i.biomtMatrices.length);let d,c,h,p,m,u,g,f,b,C,y,v,_,w,S,A,x,k,O,R={},I=[],T="coil",E="",P=0,M=0,D={onModel:function(e){d=0===e.modelIndex?a:a+(e.modelIndex+1).toString()},onChain:function(e){c=e.chainName;let t=d+"_"+c;void 0===i.structures[d]&&(i.structures[d]=[]),i.structures[d].push(t)},onGroup:function(e){h=e.groupName,p=e.groupId;let t=d+"_"+c+"_"+p;m=0===e.secStruct||2===e.secStruct||4===e.secStruct?"helix":3===e.secStruct?"sheet":-1===e.secStruct?"other":"coil";let s=!1;if(c!==E){if(x=void 0,O=void 0,"coil"!==m&&"other"!==m?(u=!0,g=!1):(u=!1,g=!1),"coil"!==T&&"other"!==T){let e=d+"_"+E+"_"+P.toString();for(let t in i.residues[e])i.atoms[t].ssbegin=!1,i.atoms[t].ssend=!0}}else x=A,O=k,m!==T?"coil"===T||"other"===T?(u=!0,g=!1):"coil"===m||"other"===m?(s=!0,u=!1,g=!1):("sheet"===T&&"helix"===m||"helix"===T&&"sheet"===m)&&(s=!0,u=!0,g=!1):(u=!1,g=!1);if(s&&!isNaN(p)){let e=d+"_"+c+"_"+(p-1).toString();for(let t in i.residues[e])i.atoms[t].ssbegin=!1,i.atoms[t].ssend=!0}T=m,E=c,P=p,f=!1,b=!1,C=!1,"non-polymer"===e.chemCompType.toLowerCase()||"other"===e.chemCompType.toLowerCase()||-1!==e.chemCompType.toLowerCase().indexOf("saccharide")?f=!0:-1!==e.chemCompType.toLowerCase().indexOf("peptide")?b=!0:-1!==e.chemCompType.toLowerCase().indexOf("dna")||-1!==e.chemCompType.toLowerCase().indexOf("rna")?C=!0:b=!0;let l=d+"_"+c,r={};r.resi=p,r.name=n.utilsCls.residueName2Abbr(h),i.residueId2Name[t]=r.name,r.resi%10==0&&r.resi.toString();let o="-";"helix"===m?o="H":"sheet"===m?o="E":"coil"===m?o="c":"other"===m&&(o="o"),void 0===i.chainsSeq[l]&&(i.chainsSeq[l]=[]),i.bFullUi&&i.chainsSeq[l].push(r),i.secondaries[t]=o},onAtom:function(e){if(y=e.element,v=e.atomName,_=new THREE.Vector3(e.xCoord,e.yCoord,e.zCoord),w=e.bFactor,S=e.altLoc,"\0"===e.altLoc&&(S=""),""===S||"A"===S){++M,"SG"===v&&I.push(M),R[e.atomIndex]=M;let t={het:f,serial:M,name:v,alt:S,resn:h,structure:d,chain:c,resi:p,coord:_,b:w,elem:y,bonds:[],bondOrder:[],ss:m,ssbegin:u,ssend:g};if(t.het||"C"!==t.name||(A=M),t.het||"O"!==t.name||(k=M),!t.het&&"N"===t.name&&void 0!==x&&void 0!==O){let e=i.atoms[x].coord.distanceTo(i.atoms[O].coord),s=t.coord.x+(i.atoms[x].coord.x-i.atoms[O].coord.x)/e,n=t.coord.y+(i.atoms[x].coord.y-i.atoms[O].coord.y)/e,l=t.coord.z+(i.atoms[x].coord.z-i.atoms[O].coord.z)/e;t.hcoord=new THREE.Vector3(s,n,l)}i.atoms[M]=t,l.min(_),r.max(_),o.add(_);let a=d+"_"+c,T=a+"_"+p;void 0===i.chains[a]&&(i.chains[a]={}),i.chains[a][M]=1,void 0===i.residues[T]&&(i.residues[T]={}),i.residues[T][M]=1,b?(i.proteins[M]=1,"CA"===v&&(i.calphas[M]=1),"N"!==v&&"H"!==v&&"CA"!==v&&"HA"!==v&&"C"!==v&&"O"!==v&&(i.sidec[M]=1)):C?(i.nucleotides[M]=1,(!s||"O3'"!=v&&"O3*"!=v)&&(s||"P"!=v)||(i.nucleotidesO3[M]=1),-1===n.parasCls.nuclMainArray.indexOf(v)&&(i.ntbase[M]=1)):y.toLowerCase()===h.toLowerCase()?i.ions[M]=1:"HOH"===h||"WAT"===h||"SQL"===h||"H2O"===h||"W"===h||"DOD"===h||"D3O"===h?i.water[M]=1:i.chemicals[M]=1,i.dAtoms[M]=1,i.hAtoms[M]=1}},onBond:function(e){let t=R[e.atomIndex1],s=R[e.atomIndex2];if(R.hasOwnProperty(e.atomIndex1)&&R.hasOwnProperty(e.atomIndex2)&&(i.atoms[t].bonds.push(s),i.atoms[s].bonds.push(t),f)){let n=e.bondOrder;i.atoms[t].bondOrder.push(n),i.atoms[s].bondOrder.push(n),2===n?(i.doublebonds[t+"_"+s]=1,i.doublebonds[s+"_"+t]=1):3===n&&(i.triplebonds[t+"_"+s]=1,i.triplebonds[s+"_"+t]=1)}}};MMTF.traverse(e,D),i.loadPDBCls.setResidMapping();for(let e=0,t=I.length;ei.maxatomcnt||void 0!==i.biomtMatrices&&i.biomtMatrices.length*i.cnt>10*i.maxatomcnt)&&(i.opts.proteins="c alpha trace",i.opts.nucleotides="o3 trace"),i.pmin=l,i.pmax=r,i.center=i.ParserUtilsCls.getGeoCenter(i.pmin,i.pmax),i.maxD=i.ParserUtilsCls.getStructureSize(i.atoms,i.pmin,i.pmax,i.center),i.maxD<5&&(i.maxD=5),i.oriMaxD=i.maxD,i.oriCenter=i.center.clone(),i.ParserUtilsCls.transformToOpmOri(t),void 0===n.cfg.align&&1==Object.keys(i.structures).length&&$("#"+i.pre+"alternateWrapper").hide(),i.setStyleCls.setAtomStyleByOptions(i.opts),i.setColorCls.setColorByOptions(i.opts,i.atoms),await i.ParserUtilsCls.renderStructure(),i.saveFileCls.showTitle(),void 0!==n.cfg.rotate&&i.resizeCanvasCls.rotStruc(n.cfg.rotate,!0)}}class Xt{constructor(e){this.icn3d=e}async loadMol2Data(e){let t=this.icn3d,s=t.icn3dui,i=this.loadMol2AtomData(e);void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),i?(t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.atoms),await t.ParserUtilsCls.renderStructure(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0)):alert("The Mol2 file has the wrong format...")}loadMol2AtomData(e){let t=this.icn3d;t.icn3dui;let s=e.split(/\r?\n|\r/);if(s.length<4)return!1;t.init();let i,n,l="LIG",r={},o="1_A",a=0,d=0,c=1,h=!1,p=!1,m={},u={};for(let e=0,o=s.length;eMOLECULE"==o){t.molTitle=s[e+1].trim();let l=s[e+2].trim().replace(/\s+/g," ").split(" ");i=l[0],n=l[1],e+=4}else"@ATOM"==o?(c=1,h=!0,++e):"@BOND"==o?(p=!0,h=!1,++e):"@SUBSTRUCTURE"==o&&(p=!1,++e);if(o=s[e].trim(),""!==o&&"#"!==o.substr(0,1)){if(h&&a1&&($("#"+l.pre+"assemblyWrapper").show(),l.asuCnt=l.biomtMatrices.length),l.setStyleCls.setAtomStyleByOptions(l.opts),l.setColorCls.setColorByOptions(l.opts,l.atoms),await l.ParserUtilsCls.renderStructure(),void 0!==r.cfg.rotate&&l.resizeCanvasCls.rotStruc(r.cfg.rotate,!0)}else"pdb"===i?await l.pdbParserCls.loadPdbData(e,t):"align"===i&&(l.bOpm?await l.alignParserCls.downloadAlignmentPart2(t):void 0!==n?await this.loadOpmData(e,n,s,i):await l.alignParserCls.downloadAlignmentPart2(t))}}class Jt{constructor(e){this.icn3d=e}async downloadPdb(e,t){let s,i=this.icn3d,n=i.icn3dui;t?(s="https://alphafold.ebi.ac.uk/files/AF-"+e+"-F1-model_"+i.AFUniprotVersion+".pdb",n.cfg.refseqid?i.ParserUtilsCls.setYourNote(n.cfg.refseqid.toUpperCase()+"(NCBI Protein Acc.) in iCn3D"):n.cfg.protein?i.ParserUtilsCls.setYourNote(n.cfg.protein+"(NCBI Protein/Gene) in iCn3D"):i.ParserUtilsCls.setYourNote(e.toUpperCase()+"(AlphaFold) in iCn3D")):(s="https://files.rcsb.org/view/"+e+".pdb",e=e.toUpperCase(),i.ParserUtilsCls.setYourNote(e+"(PDB) in iCn3D"));let l=await n.getAjaxPromise(s,"text",!0,"The ID "+e+" can not be found in the server "+s+"...");if(t){l="HEADER "+e+"\n"+l,await i.opmParserCls.parseAtomData(l,e,void 0,"pdb",void 0)}else await i.opmParserCls.loadOpmData(l,e,void 0,"pdb")}async downloadUrl(e,t,s){let i=this.icn3d,n=i.icn3dui,l=e.lastIndexOf("/");if(-1!=l){let t=e.lastIndexOf(".");i.filename=e.substr(l+1,t-l-1)}else{let t=e.lastIndexOf(".");i.filename=e.substr(0,t)}let r=await n.getAjaxPromise(e,"text",!0);if(i.InputfileData=i.InputfileData?i.InputfileData+"\nENDMDL\n"+r:r,i.InputfileType=t,"pdb"===t)await this.loadPdbData(r);else if("mmcif"===t){let e=n.htmlCls.baseUrl+"mmcifparser/mmcifparser.cgi",t={mmciffile:r},s=await n.getAjaxPostPromise(e,t,!0);await i.mmcifParserCls.loadMmcifData(s,void 0)}else if("mol2"===t)await i.mol2ParserCls.loadMol2Data(r);else if("sdf"===t)await i.sdfParserCls.loadSdfData(r);else if("xyz"===t)await i.xyzParserCls.loadXyzData(r);else if("mmcif"===t)await i.mmcifParserCls.loadMmcifData(r);else if("icn3dpng"===t)await n.htmlCls.setHtmlCls.loadPng(r,s);else if("pae"===t){n.htmlCls.dialogCls.openDlg("dl_alignerrormap","Show Predicted Aligned Error (PAE) map");let e=!0;i.contactMapCls.processAfErrorMap(JSON.parse(r),e)}}async loadPdbData(e,t,s,i,n,l,r,o){let a=this.icn3d,d=a.icn3dui;if(!i&&(void 0===n||"target"===n)){let e=!!a.bCommandLoad;a.bStatefile||a.init(e)}let c=a.loadPDBCls.loadPDB(e,t,s,void 0,void 0,i,n,o);void 0===d.cfg.opmid&&a.ParserUtilsCls.transformToOpmOri(t),void 0!==a.biomtMatrices&&a.biomtMatrices.length>1&&(d.bNode||$("#"+a.pre+"assemblyWrapper").show(),a.asuCnt=a.biomtMatrices.length),d.bNode||(void 0!==a.emd?($("#"+a.pre+"mapWrapper1").hide(),$("#"+a.pre+"mapWrapper2").hide(),$("#"+a.pre+"mapWrapper3").hide()):($("#"+a.pre+"emmapWrapper1").hide(),$("#"+a.pre+"emmapWrapper2").hide(),$("#"+a.pre+"emmapWrapper3").hide()));let h=!1;return a.bSecondaryStructure&&1==Object.keys(a.structures).length?h=!1:d.cfg.mmtfid||d.cfg.pdbid||d.cfg.opmid||d.cfg.mmdbid||d.cfg.gi||d.cfg.uniprotid||d.cfg.blast_rep_id||d.cfg.cid||d.cfg.mmcifid||d.cfg.align||d.cfg.chainalign||(h=!0),(!a.bSecondaryStructure||h)&&Object.keys(a.proteins).length>0&&!r?await this.applyCommandDssp(i):(await this.loadPdbDataRender(i),d.bNode||await a.ParserUtilsCls.checkMemProteinAndRotate()),c}async applyCommandDssp(e){let t=this.icn3d,s=t.icn3dui,i=s.utilsCls.isCalphaPhosOnly(s.hashUtilsCls.hash2Atoms(t.proteins,t.atoms));await t.dsspCls.applyDssp(i,e)}async loadPdbDataRender(e){let t=this.icn3d,s=t.icn3dui;void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),(s.cfg.afid&&!t.bAfMem||t.bEsmfold)&&(t.opts.color="confidence"),t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.hAtoms),await t.ParserUtilsCls.renderStructure(),t.saveFileCls.showTitle(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0),e&&!s.bNode&&t.definedSetsCls.setModeAndDisplay("all")}}class Qt{constructor(e){this.icn3d=e}async downloadCid(e){let t=this.icn3d,s=t.icn3dui;t.ParserUtilsCls.setYourNote("PubChem CID "+e+" in iCn3D"),t.bCid=!0;let i="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+t.inputid+"/cids/JSONP?cids_type=parent",n="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+(await s.getAjaxPromise(i,"jsonp",!0,"Can not retrieve the parant CID...")).IdentifierList.CID[0]+"/record/SDF/?record_type=3d&response_type=display",l=await s.getAjaxPromise(n,"text",!0,"This CID may not have 3D structure..."),r=this.loadSdfAtomData(l,e);void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),r?(t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.atoms),await t.ParserUtilsCls.renderStructure(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0)):alert("The SDF of CID "+e+" has the wrong format...")}async loadSdfData(e){let t=this.icn3d,s=t.icn3dui,i=this.loadSdfAtomData(e);void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),i?(t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.atoms),await t.ParserUtilsCls.renderStructure(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0)):alert("The SDF file has the wrong format...")}loadSdfAtomData(e,t){let s=this.icn3d;s.icn3dui;let i=e.split(/\r?\n|\r/);if(i.length<4)return!1;s.init();let n=t||1,l="LIG",r=n,o=n+"_A",a=o+"_1",d=parseInt(i[3].substr(0,3));if(isNaN(d)||d<=0)return!1;let c=parseInt(i[3].substr(3,3)),h=4;if(i.lengthr||(Math.abs(t.coord.y-i.coord.y)>r||Math.abs(t.coord.z-i.coord.z)>r||l.utilsCls.hasCovalentBond(t,i)&&(n.atoms[o[e]].bonds.push(o[s]),n.atoms[o[s]].bonds.push(o[e])))}}}loadXyzAtomData(e){let t=this.icn3d;t.icn3dui;let s=e.split(/\r?\n|\r/);if(s.length<3)return!1;t.init();let i,n,l,r={},o=0,a=1;t.molTitle="";for(let e=0,d=s.length;e1&&(t.molTitle+="; "),t.molTitle+=s[e+1].trim(),e+=2),d=s[e].trim(),""===d)continue;let c=d.replace(/,/," ").replace(/\s+/g," ").split(" "),h=c[0],p=parseFloat(c[1]),m=parseFloat(c[2]),u=parseFloat(c[3]),g={het:!0,serial:a,name:h,resn:"LIG",structure:l,chain:"A",resi:1,coord:new THREE.Vector3(p,m,u),b:0,elem:h,bonds:[],ss:"coil",ssbegin:!1,ssend:!1,bondOrder:[]};t.atoms[a]=g,r[a]=1,++a}return this.setXyzAtomSeq(r,o,i,n),t.ParserUtilsCls.setMaxD(),t.saveFileCls.showTitle(),!0}}class es{constructor(e){this.icn3d=e}realign(){let e=this.icn3d,t=e.icn3dui;e.selectionCls.saveSelectionPrep();let s="alseq_"+Object.keys(e.defNames2Atoms).length;e.selectionCls.saveSelection(s,s),t.htmlCls.clickMenuCls.setLogCmd("realign",!0);let i={},n={};e.realignResid={};let l="";for(let s in e.hAtoms){let r=e.atoms[s],o=r.structure+"_"+r.chain;if(e.proteins.hasOwnProperty(s)&&"CA"==r.name||e.nucleotides.hasOwnProperty(s)&&("O3'"==r.name||"O3*"==r.name)){if(r.structure+"_"+r.resi==l)continue;i.hasOwnProperty(r.structure)||(i[r.structure]=[]),i[r.structure].push(r.coord.clone()),e.realignResid.hasOwnProperty(o)||(e.realignResid[o]=[]),e.realignResid[o].push({resid:o+"_"+r.resi,resn:t.utilsCls.residueName2Abbr(r.resn.substr(0,3)).substr(0,1)}),n[r.structure]=r.structure+"_"+r.chain,l=r.structure+"_"+r.resi}}let r=Object.keys(i),o=r[0],a=[];e.qt_start_end=[],a.push(n[o]);for(let t=1,s=r.length;t5){let e=r.cfg.chainalign.split(",");e.length>0&&(l.hAtoms=l.definedSetsCls.getAtomsFromNameArray(e)),r.cfg.aligntool="tmalign",await l.realignParserCls.realignOnStructAlign()}else l.hAtoms=l.chainalignParserCls.setMsa(e),l.transformCls.zoominSelection(),await l.chainalignParserCls.downloadChainalignmentPart3(void 0,e,l.hAtoms)}async parseChainRealignData(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui,d=s[0].substr(0,s[0].indexOf("_"));r||(d=d.toUpperCase());let c={};o.realignResid={},o.opts.color="grey",o.setColorCls.setColorByOptions(o.opts,o.dAtoms),o.qt_start_end=[];for(let t=0,h=e.length;t=6&&C.length>=6&&!a.cfg.command&&o.bRender&&alert("These sequences can not be aligned to each other")):o.bRender&&alert("Please do not align residues in the same structure")}if(r){o.hAtoms=o.chainalignParserCls.setMsa(s);let e="protein_aligned";if(o.selectionCls.saveSelection(e,e),o.bAfMem?(o.selectionCls.selectAll_base(),o.opts.chemicals="stick",o.opts.color="confidence",o.setColorCls.setColorByOptions(o.opts,o.atoms)):(o.transformCls.zoominSelection(),o.dAtoms=a.hashUtilsCls.cloneHash(o.hAtoms),o.opts.color="identity",o.setColorCls.setColorByOptions(o.opts,o.hAtoms)),o.drawCls.draw(),o.hlUpdateCls.updateHlAll(),o.bAfMem){let e=new THREE.Vector3(1,0,0),t=-.5*Math.PI;o.transformCls.setRotation(e,t)}}else o.hAtoms=o.chainalignParserCls.setMsa(s),o.transformCls.zoominSelection(),await o.chainalignParserCls.downloadChainalignmentPart3(t,s,o.hAtoms)}async realignOnSeqAlign(e){let t=this.icn3d;t.icn3dui;let s=t.firstAtomObjCls.getChainsFromAtoms(t.hAtoms),i=Object.keys(s),n=[],l="";for(let e=0,t=i.length;ei){n[e][o]=a;break}}}let l=[],r=[],o=s.htmlCls.baseUrl+"vastdyn/vastdyn.cgi",a=s.htmlCls.baseUrl+"tmalign/tmalign.cgi",d=Object.keys(n);e&&(d=d.reverse());for(let e=0,i=d.length;ei){n[r]=o;break}}let l=[],r=[],o=[],a=s.htmlCls.baseUrl+"vastdyn/vastdyn.cgi",d=s.htmlCls.baseUrl+"tmalign/tmalign.cgi",c=e[0],h=c.substr(0,c.indexOf("_")),p=t.domain3dCls.getDomainJsonForAlign(n[c]);for(let i=1,m=e.length;if&&(f=s)}}}return{data:n,min:g,max:f}}(e.getCategory("_volume_data_3d").getColumn("values"),o,n.sampleCount,l);return{name:n.name,spacegroup:function(e,t,s){let i=Math.PI/180*s[0],n=Math.PI/180*s[1],l=Math.PI/180*s[2],r=t[0],o=t[1],a=t[2],d=Math.cos(n),c=(Math.cos(i)-Math.cos(n)*Math.cos(l))/Math.sin(l),h=Math.sqrt(1-d*d-c*c);return{number:e,size:t,angles:s,basis:{x:[r,0,0],y:[Math.cos(l)*o,Math.sin(l)*o,0],z:[d*a,c*a,h*a]}}}(n.spacegroupNumber,n.cellSize,n.cellAngles),box:{origin:r(n.origin),dimensions:r(n.dimensions),sampleCount:o},data:a.data,valuesInfo:{min:a.min,max:a.max,mean:n.mean,sigma:n.sigma}}}BinaryParse(e){this.icn3d.icn3dui;let t=new Uint8Array(e),s=this.MessagePackParse({buffer:t,offset:0,dataView:new DataView(t.buffer)}),i=function(){function e(e){this.additionalData={},this.header=e.header,this.categoryList=e.categories.map((function(e){return new n(e)})),this.categoryMap=new Map;for(let e=0,t=this.categoryList;e=0;s--)t=c(t,e.encoding[s]);return t}function p(e){if(!e.data.data)return _UndefinedColumn;let t,s=h(e.data);return e.mask&&(t=h(e.mask)),s.buffer&&s.byteLength&&s.BYTES_PER_ELEMENT?t?new f(s,t):new g(s):t?new C(s,t):new b(s)}function m(e,t,s){let i=0,n=1;for(45===e.charCodeAt(t)&&(n=-1,t++);t9||s<0)return n*i|0;i=10*i+s|0}return n*i}function u(e,t,s){let i=1,n=0,l=0,r=1;for(45===e.charCodeAt(t)&&(i=-1,++t);t=0&&o<10)){if(-2===o){for(++t;t=0&&o<10))return 53===o||21===o?parseScientific(i*(n+l/r),e,t+1,s):i*(n+l/r);l=10*l+o,r*=10,++t}return i*(n+l/r)}if(53===o||21===o)return parseScientific(i*n,e,t+1,s);break}n=10*n+o,++t}return i*n}let g=function(){function e(e){this.data=e,this.isDefined=!0}return e.prototype.getString=function(e){return""+this.data[e]},e.prototype.getInteger=function(e){return 0|this.data[e]},e.prototype.getFloat=function(e){return 1*this.data[e]},e.prototype.stringEquals=function(e,t){return this.data[e]===u(t,0,t.length)},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return 0},e}(),f=function(){function e(e,t){this.data=e,this.mask=t,this.isDefined=!0}return e.prototype.getString=function(e){return 0===this.mask[e]?""+this.data[e]:null},e.prototype.getInteger=function(e){return 0===this.mask[e]?this.data[e]:0},e.prototype.getFloat=function(e){return 0===this.mask[e]?this.data[e]:0},e.prototype.stringEquals=function(e,t){return 0===this.mask[e]?this.data[e]===u(t,0,t.length):null==t},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return this.mask[e]},e}(),b=function(){function e(e){this.data=e,this.isDefined=!0}return e.prototype.getString=function(e){return this.data[e]},e.prototype.getInteger=function(e){let t=this.data[e];return m(t,0,t.length)},e.prototype.getFloat=function(e){let t=this.data[e];return u(t,0,t.length)},e.prototype.stringEquals=function(e,t){return this.data[e]===t},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return 0},e}(),C=function(){function e(e,t){this.data=e,this.mask=t,this.isDefined=!0}return e.prototype.getString=function(e){return 0===this.mask[e]?this.data[e]:null},e.prototype.getInteger=function(e){if(0!==this.mask[e])return 0;let t=this.data[e];return m(t||"",0,(t||"").length)},e.prototype.getFloat=function(e){if(0!==this.mask[e])return 0;let t=this.data[e];return u(t||"",0,(t||"").length)},e.prototype.stringEquals=function(e,t){return this.data[e]===t},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return this.mask[e]},e}(),y=function(){function e(e){this.dataBlocks=e.dataBlocks.map((function(e){return new i(e)}))}return e.prototype.toJSON=function(){return this.dataBlocks.map((function(e){return e.toJSON()}))},e}();return new y(s)}MessagePackParse(e){this.icn3d.icn3dui;let t=this;function s(e,s){let i={};for(let n=0;n0&&(i[i.length]=l.slice(0,a).join(""));return i.join("")}(e.buffer,e.offset,t);return e.offset+=t,s}let r=function(){let e=[];for(let t=0;t<1024;t++)e[t]=String.fromCharCode(t);return e}();let o,a,d=e.buffer[e.offset];if(0==(128&d))return e.offset++,d;if(128==(240&d))return a=15&d,e.offset++,s(e,a);if(144==(240&d))return a=15&d,e.offset++,n(e,a);if(160==(224&d))return a=31&d,e.offset++,l(e,a);if(224==(224&d))return o=e.dataView.getInt8(e.offset),e.offset++,o;switch(d){case 192:return e.offset++,null;case 194:return e.offset++,!1;case 195:return e.offset++,!0;case 196:return a=e.dataView.getUint8(e.offset+1),e.offset+=2,i(e,a);case 197:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,i(e,a);case 198:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,i(e,a);case 202:return o=e.dataView.getFloat32(e.offset+1),e.offset+=5,o;case 203:return o=e.dataView.getFloat64(e.offset+1),e.offset+=9,o;case 204:return o=e.buffer[e.offset+1],e.offset+=2,o;case 205:return o=e.dataView.getUint16(e.offset+1),e.offset+=3,o;case 206:return o=e.dataView.getUint32(e.offset+1),e.offset+=5,o;case 208:return o=e.dataView.getInt8(e.offset+1),e.offset+=2,o;case 209:return o=e.dataView.getInt16(e.offset+1),e.offset+=3,o;case 210:return o=e.dataView.getInt32(e.offset+1),e.offset+=5,o;case 217:return a=e.dataView.getUint8(e.offset+1),e.offset+=2,l(e,a);case 218:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,l(e,a);case 219:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,l(e,a);case 220:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,n(e,a);case 221:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,n(e,a);case 222:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,s(e,a);case 223:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,s(e,a)}}}class ss{constructor(e){this.icn3d=e}alignCoords(e,t,s,i,n,l,r,o){let a,d=this.icn3d,c=d.icn3dui,h=e.length=4&&(d.bAfMem?d.rmsd_suprTmp=c.rmsdSuprCls.getRmsdSuprCls(t,e,h):d.rmsd_suprTmp=c.rmsdSuprCls.getRmsdSuprCls(e,t,h),void 0!==d.rmsd_suprTmp.rot)){let e=d.rmsd_suprTmp.rot;null===e[0]&&alert("Please select more residues in each structure...");let t=d.rmsd_suprTmp.trans1,i=d.rmsd_suprTmp.trans2;if(a=d.rmsd_suprTmp.rmsd,a){c.htmlCls.clickMenuCls.setLogCmd("realignment RMSD: "+a.toPrecision(4),!1);let e="
    Realignment RMSD: "+a.toPrecision(4)+" Å

    ";d.bAfMem&&!c.cfg.chainalign&&(e+=c.utilsCls.getMemDesc()),$("#"+d.pre+"dl_rmsd_html").html(e),c.cfg.bSidebyside||c.htmlCls.dialogCls.openDlg("dl_rmsd","Realignment RMSD")}let r={};for(let n=0,l=d.structures[s].length;n"+s.diagram2dCls.set2DdgmNote(!0),$("#"+s.pre+"dl_2ddgm_html").html(s.html2ddgm),s.b2DShown=!0}async set2DDiagramsForChainalign(e){let t=this.icn3d.icn3dui,s=this;t.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions");let i=[];for(let s=0,n=e.length;s"+s.diagram2dCls.set2DdgmNote(!0),s.b2DShown=!0,$("#"+s.pre+"dl_2ddgm_html").html(s.html2ddgm),i.cfg.show2d&&i.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions")}download2Ddgm(e,t){this.set2DDiagrams(e)}set2DDiagrams(e){let t=this.icn3d;t.icn3dui.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions"),void 0!==t.b2DShown&&t.b2DShown||(t.html2ddgm="",t.diagram2dCls.draw2Ddgm(t.interactionData,e),t.html2ddgm+="
    "+t.diagram2dCls.set2DdgmNote(),$("#"+t.pre+"dl_2ddgm_html").html(t.html2ddgm)),t.b2DShown=!0}showLoading(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"wait")&&$("#"+e.pre+"wait").show(),$("#"+e.pre+"canvas")&&$("#"+e.pre+"canvas").hide(),$("#"+e.pre+"cmdlog")&&$("#"+e.pre+"cmdlog").hide()}hideLoading(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"wait")&&$("#"+e.pre+"wait").hide(),$("#"+e.pre+"canvas")&&$("#"+e.pre+"canvas").show(),$("#"+e.pre+"cmdlog")&&$("#"+e.pre+"cmdlog").show()}setYourNote(e){let t=this.icn3d,s=t.icn3dui;t.yournote=e,$("#"+t.pre+"yournote").val(t.yournote),s.cfg.shownote&&(document.title=t.yournote)}transformToOpmOri(e){let t=this.icn3d;if(t.icn3dui,void 0!==t.rmsd_supr&&void 0!==t.rmsd_supr.rot){let s=t.rmsd_supr.rot,i=t.rmsd_supr.trans1,n=t.rmsd_supr.trans2;t.rmsd_supr.rmsd;let l=0;for(let e in t.atoms){let r=t.atoms[e];r.coord=t.surfaceCls.transformMemPro(r.coord,s,i,n);let o=r.coord.x*r.coord.x+r.coord.y*r.coord.y;Math.abs(r.coord.z)<=25&&o>l&&(l=o)}this.addMemAtoms(t.halfBilayerSize,e,Math.sqrt(l)),t.bStopRotate=!0,t.bOpm=!0,$("#"+t.pre+"togglememli").show(),$("#"+t.pre+"adjustmemli").show(),$("#"+t.pre+"selectplaneli").show()}else t.bOpm=!1}transformToOpmOriForAlign(e,t,s){let i=this.icn3d,n=i.icn3dui;if(void 0!==t){let l=i.loadPDBCls.getChainCalpha(i.chains,i.atoms,s,e),r=1==Object.keys(l.chainresiCalphaHash).length||1==Object.keys(t.chainresiCalphaHash).length,o=[],a=[];for(let e in l.chainresiCalphaHash)if(t.chainresiCalphaHash.hasOwnProperty(e)){let s=l.chainresiCalphaHash[e],i=t.chainresiCalphaHash[e];if((s.length==i.length||r)&&(o=o.concat(s),a=a.concat(i)),o.length>500)break}let d=o.length=4)if(i.rmsd_supr=n.rmsdSuprCls.getRmsdSuprCls(o,a,d),void 0!==i.rmsd_supr.rot&&i.rmsd_supr.rmsd<.1){let s=i.rmsd_supr.rot,l=i.rmsd_supr.trans1,r=i.rmsd_supr.trans2,o=i.rmsd_supr.rmsd;n.htmlCls.clickMenuCls.setLogCmd("RMSD of alignment to OPM: "+o.toPrecision(4),!1);let a=0;for(let e in i.atoms){let t=i.atoms[e];t.coord=i.surfaceCls.transformMemPro(t.coord,s,l,r);let n=t.coord.x*t.coord.x+t.coord.y*t.coord.y;Math.abs(t.coord.z)<=25&&n>a&&(a=n)}i.center=t.center,i.oriCenter=i.center.clone(),this.addMemAtoms(i.halfBilayerSize,e,Math.sqrt(a)),i.bStopRotate=!0,i.bOpm=!0,$("#"+i.pre+"togglememli").show(),$("#"+i.pre+"adjustmemli").show(),$("#"+i.pre+"selectplaneli").show()}else i.bOpm=!1;else i.bOpm=!1}}addOneDumAtom(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui,a={het:!0,serial:++l,name:t,alt:void 0,resn:"DUM",structure:e,chain:"MEM",resi:1,coord:new THREE.Vector3(s,i,n),b:void 0,elem:t,bonds:[],ss:"",ssbegin:!1,ssend:!1,color:o.parasCls.atomColors[t]};return r.atoms[l]=a,r.chains[e+"_MEM"][l]=1,r.residues[e+"_MEM_1"][l]=1,r.chemicals[l]=1,r.dAtoms[l]=1,r.hAtoms[l]=1,l}addMemAtoms(e,t,s){let i=this.icn3d;if(i.icn3dui,!t)return;t=t?t.toUpperCase():i.defaultPdbId,i.structures[t].push(t+"_MEM"),i.chains[t+"_MEM"]={},i.residues[t+"_MEM_1"]={},i.chainsSeq[t+"_MEM"]=[{name:"DUM",resi:1}];let n=Object.keys(i.atoms).length;for(let e=0;e<1e3;++e)if(!i.atoms.hasOwnProperty(n+e)){n=n+e-1;break}for(let i=0;i<81;++i)for(let l=0;l<81;++l){let r=2*i-80,o=2*l-80;if(Math.sqrt(r*r+o*o)=2?$("#"+e.pre+"mn2_alternateWrap").show():$("#"+e.pre+"mn2_alternateWrap").hide(),setTimeout((async function(){if(e.bInitial){if(void 0!==t.cfg.align||void 0!==t.cfg.chainalign){let s=e.pre+"selection";if($("#"+s).show(),$("#"+s+"_expand").hide(),$("#"+s+"_shrink").show(),void 0!==t.cfg.align&&2!=t.cfg.atype){let s=!1,i=t.htmlCls.alignSeqCls.getAlignSequencesAnnotations(Object.keys(e.alnChains),void 0,void 0,s);$("#"+e.pre+"dl_sequence2").html(i.sequencesHtml),$("#"+e.pre+"dl_sequence2").width(t.htmlCls.RESIDUE_WIDTH*i.maxSeqCnt+200)}}if(t.cfg.showanno){let s="view annotations";t.htmlCls.clickMenuCls.setLogCmd(s,!0),await e.showAnnoCls.showAnnotations()}(t.cfg.closepopup||t.cfg.imageonly)&&e.resizeCanvasCls.closeDialogs()}else e.hlUpdateCls.updateHlAll();$("#"+e.pre+"atomsCustom").length>0&&$("#"+e.pre+"atomsCustom")[0].blur(),e.bInitial=!1,t.cfg.imageonly&&e.saveFileCls.saveFile(void 0,"png",void 0,!0)}),0)}processCommand(){let e=this.icn3d,t=e.icn3dui;if(1==Object.keys(e.structures).length){let s=Object.keys(e.structures)[0];t.cfg.command=t.cfg.command.replace(new RegExp("!","g"),s+"_")}}getMassCenter(e,t){return this.icn3d.icn3dui,e.multiplyScalar(1/t)}getGeoCenter(e,t){return this.icn3d.icn3dui,e.clone().add(t).multiplyScalar(.5)}getStructureSize(e,t,s,i){let n=this.icn3d;n.icn3dui;let l=0;for(let r in e){let e=n.atoms[r].coord;if(Math.round(t.x)==Math.round(e.x)||Math.round(t.y)==Math.round(e.y)||Math.round(t.z)==Math.round(e.z)||Math.round(s.x)==Math.round(e.x)||Math.round(s.y)==Math.round(e.y)||Math.round(s.z)==Math.round(e.z)){let t=2*e.distanceTo(i);t>l&&(l=t)}}return l}async checkMemProteinAndRotate(){let e=this.icn3d,t=e.icn3dui;if(!e.bCheckMemProtein){e.bCheckMemProtein=!0;let s=t.cfg.afid?t.cfg.afid:t.cfg.mmdbafid;if(await e.ParserUtilsCls.checkMemProtein(s),t.cfg.url&&-1!=t.cfg.url.indexOf("membranome")){let t=new THREE.Vector3(1,0,0),s=-.5*Math.PI;e.transformCls.setRotation(t,s)}}}async checkMemProtein(e){let t=this.icn3d,s=t.icn3dui;try{let i=s.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?afid2mem="+e,n=await s.getAjaxPromise(i,"jsonp");if(n&&n.pdbid){let e='This is a single-spanning (bitopic) transmembrane protein according to the Membranome database. Do you want to align the protein with the model from Membranome? If you click "OK", you can press the letter "a" to alternate the structures.';if("off"==s.cfg.afmem);else if("on"==s.cfg.afmem||confirm(e))try{let e="https://storage.googleapis.com/membranome-assets/pdb_files/proteins/"+n.pdbid+".pdb",i=await s.getAjaxPromise(e,"text");t.bAfMem=!0,s.bNode||$("#"+s.pre+"togglememli").show();let l=n.pdbid.substr(0,n.pdbid.indexOf("_")),r=!0,o=!0;await t.pdbParserCls.loadPdbData(i,l,r,o),o&&(t.bSetChainsAdvancedMenu&&t.definedSetsCls.showSets(),t.bAnnoShown&&await t.showAnnoCls.showAnnotations());let a=n.segment.replace(/ /gi,"").split("(")[0];t.afmem_start_end=a.split("-"),t.hAtoms={},t.dAtoms={};for(let e in t.atoms)t.atoms[e].structure!=l&&(t.hAtoms[e]=1),t.dAtoms[e]=1;for(let e=parseInt(t.afmem_start_end[0]);e<=parseInt(t.afmem_start_end[1]);++e)t.hAtoms=s.hashUtilsCls.unionHash(t.hAtoms,t.residues[l+"_A_"+e]);await t.realignParserCls.realignOnSeqAlign(l)}catch(e){return void console.log("Error in retrieving matched PDB from Membranome...")}}}catch(e){return void console.log("Error in finding matched PDB in Membranome...")}}getResi(e,t){let s=this.icn3d;s.icn3dui;let i=s.ncbi2resid[e+"_"+(t+1).toString()];return i?i.substr(i.lastIndexOf("_")+1):""}getResiNCBI(e,t){let s=this.icn3d;s.icn3dui;let i=s.resid2ncbi[e+"_"+t];return i?parseInt(i.substr(i.lastIndexOf("_")+1)):0}}class is{constructor(e){this.icn3d=e}loadAtomDataIn(e,t,s,i,n,l,r,o,a){let d=this.icn3d,c=d.icn3dui;d.pmin=new THREE.Vector3(9999,9999,9999),d.pmax=new THREE.Vector3(-9999,-9999,-9999),d.psum=new THREE.Vector3;let h=e.atoms,p=d.atoms?Object.keys(d.atoms).length:0,m={},u={};d.pmid=e.pubmedId,void 0===d.chainid2title&&(d.chainid2title={}),void 0===d.chainid2sid&&(d.chainid2sid={});let g={},f={};if("align"===s){d.pmid="",d.molTitle="",c.cfg.inpara&&-1!==c.cfg.inpara.indexOf("atype=1")?d.molTitle="Invariant Core Structure Alignment (VAST) of ":c.cfg.inpara&&-1!==c.cfg.inpara.indexOf("atype=2")?d.molTitle="Structure Alignment (TM-align) of ":d.molTitle="Structure Alignment (VAST) of ";let t=!1;for(let s=0,i=e.alignedStructures[0].length;s'+i.pdbId.toUpperCase()+"",void 0!==i.descr&&(d.pmid+=i.descr.pubmedid),0===s&&(d.molTitle+=" and ",void 0!==i.descr&&(d.pmid+="_")),t=!0}d.molTitle+=" from VAST+",t||(d.molTitle="")}else if(void 0!==e.descr&&(d.molTitle+=e.descr.name),"mmdbid"===s){let s=isNaN(t)?t:e.pdbId,i={};void 0===d.alignmolid2color&&(d.alignmolid2color=[]);let n=1;for(let t in e.moleculeInfor){if(0===Object.keys(e.moleculeInfor[t]).length)continue;let l=e.moleculeInfor[t].chain.trim();(parseInt(c.cfg.date)>=20231001||!c.cfg.date&&parseInt(c.utilsCls.getDateDigitStr())>=20231001)&&(l=l.replace(/_/g,""));let r=s+"_"+l;i.hasOwnProperty(l)?(++i[l],r+=i[l]):i[l]=1,void 0!==d.mmdbid_q&&(d.mmdbid_q,d.mmdbid_t);let o=e.moleculeInfor[t].kind,a=e.moleculeInfor[t].color,h=e.moleculeInfor[t].sid;if(g[r]=o,f[r]=a,"protein"==o&&(d.organism=e.moleculeInfor[t].taxonomyName.toLowerCase()),void 0!==h&&(d.chainid2sid[r]=h),void 0===d.pdbid_chain2title&&(d.pdbid_chain2title={}),d.pdbid_chain2title[r]=e.moleculeInfor[t].name,l==r.substr(r.lastIndexOf("_"))){let e={};e[t]=n.toString(),d.alignmolid2color.push(e)}++n}}"mmdbid"===s&&(d.molTitleHash||(d.molTitleHash={}),d.molTitleHash[t]=d.molTitle);let b,C,y,v,_,w={},S="",A="",x="",k="",O="",R="",I=0,T=0,E="",P=!0,M=!1,D="",H=c.utilsCls.isCalphaPhosOnly(h),F=0,L={};for(let e in h){++p,w[e]=p;let i,n=h[e];n.serial=p,"mmdbid"===s||"mmcifid"===s?i=t:"align"===s&&(i=m[p]);let l=!1;if(void 0!==n.chain||"mmdbid"!==s&&"align"!==s)n.chain=""===n.chain?"Misc":n.chain;else if("mmdbid"===s)if(b=n.ids.m,void 0!==d.molid2chain[b]){let e=d.molid2chain[b].indexOf("_");n.chain=d.molid2chain[b].substr(e+1)}else{let e="Misc";("protein"===g[O]&&"nucleotide"===g[O]&&n.resi!=T||"protein"!==g[O]&&"nucleotide"!==g[O]&&(n.resn.substr(0,3)!=E.substr(0,3)||n.resi!=T||"solvent"===g[O]||"HOH"===n.resn))&&++F,n.resi_ori=n.resi,n.resi=F,l=!0,n.chain=e}else if("align"===s)if(b=n.ids.m,void 0!==d.pdbid_molid2chain[i+"_"+b])n.chain=d.pdbid_molid2chain[i+"_"+b];else{let e="Misc";("protein"===g[O]&&"nucleotide"===g[O]&&n.resi!=T||"protein"!==g[O]&&"nucleotide"!==g[O]&&(n.resn.substr(0,3)!=E.substr(0,3)||n.resi!=T||"solvent"===g[O]||"HOH"===n.resn))&&(++F,n.resi_ori=n.resi,n.resi=F,l=!0),n.chain=e}if(n.chain=n.chain.trim(),(parseInt(c.cfg.date)>=20231001||!c.cfg.date&&parseInt(c.utilsCls.getDateDigitStr())>=20231001)&&(n.chain=n.chain.replace(/_/g,"")),"mmdbid"!==s&&"align"!==s||(n.structure=i,"mmdbid"===s&&void 0!==d.mmdbid_q&&(d.mmdbid_q,d.mmdbid_t)),k=n.structure,O=k+"_"+n.chain,"mmdbid"===s||"align"===s){l||(n.resi_ori=n.resi,d.bUsePdbNum?n.resi=n.resi_ori:n.resi=n.ids.r);let e=n.resn.indexOf(" ");-1!==e&&0!=e&&(n.resn=n.resn.substr(0,e))}O!==A&&(I=0),n.resi!==I&&(O!==A?(y=void 0,_=void 0):(y=C,_=v)),n.coord="mmdbid"===s?new THREE.Vector3(n.coord[0],n.coord[1],n.coord[2]):new THREE.Vector3(n.coord.x,n.coord.y,n.coord.z);let r=c.utilsCls.residueName2Abbr(n.resn.substr(0,3));"mmdbid"!==s&&"align"!==s||!d.bFullUi||(void 0===d.mmdbMolidResid2mmdbChainResi&&(d.mmdbMolidResid2mmdbChainResi={}),d.mmdbMolidResid2mmdbChainResi[i+"_"+n.ids.m+"_"+n.ids.r]=i+"_"+n.chain+"_"+n.resi),d.pmin.min(n.coord),d.pmax.max(n.coord),d.psum.add(n.coord);let o=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"protein"===g[O]:"p"===n.mt,a=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"nucleotide"===g[O]:"n"===n.mt,u=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"solvent"===g[O]:"s"===n.mt,N=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"ligand"===g[O]||void 0!==g[O]&&-1!==g[O].indexOf("other")||void 0===g[O]:"l"===n.mt;if("Misc"!==n.chain&&"other"!==g[O]||"protein"===L[O]||"nucleotide"===L[O]||("CA"===n.name&&"C"===n.elem?L[O]="protein":"P"===n.name&&"P"===n.elem?L[O]="nucleotide":L[O]="chemical"),o||a?(o?(d.proteins[p]=1,"CA"===n.name&&(d.calphas[p]=1),"N"!==n.name&&"H"!==n.name&&"CA"!==n.name&&"HA"!==n.name&&"C"!==n.name&&"O"!==n.name&&(d.sidec[p]=1)):a&&(d.nucleotides[p]=1,("O3'"==n.name||"O3*"==n.name||H&&"P"==n.name)&&(d.nucleotidesO3[p]=1),-1===c.parasCls.nuclMainArray.indexOf(n.name)&&(d.ntbase[p]=1)),n.het=!1):u?(d.water[p]=1,n.het=!0):N&&("HOH"===n.resn||"O"===n.resn?d.water[p]=1:n.elem===n.resn?d.ions[p]=1:d.chemicals[p]=1,n.het=!0),"mmdbid"===s?n.het?n.color=c.parasCls.atomColors[n.elem]||c.parasCls.defaultAtomColor:n.color=void 0!==f[O]?c.parasCls.thr(f[O]):c.parasCls.chargeColors[n.resn]:void 0!==n.color&&(n.color=c.parasCls.thr(n.color))," "!==n.resn.charAt(0)&&" "===n.resn.charAt(1)&&(n.resn=n.resn.charAt(0)),n.het||"C"!==n.name||(C=p),n.het||"O"!==n.name||(v=p),!n.het&&"N"===n.name&&void 0!==y&&void 0!==_){let e=d.atoms[y].coord.distanceTo(d.atoms[_].coord),t=n.coord.x+(d.atoms[y].coord.x-d.atoms[_].coord.x)/e,s=n.coord.y+(d.atoms[y].coord.y-d.atoms[_].coord.y)/e,i=n.coord.z+(d.atoms[y].coord.z-d.atoms[_].coord.z)/e;n.hcoord=new THREE.Vector3(t,s,i)}"HOH"==n.resn&&(d.water[p]=1),d.atoms[p]=n,d.dAtoms[p]=1,d.hAtoms[p]=1;let q=n.structure+"_"+n.chain;void 0===d.chains[q]&&(d.chains[q]={}),d.chains[q][p]=1;let U=q+"_"+n.resi;void 0===d.residues[U]&&(d.residues[U]={}),d.residues[U][p]=1,R=O+"_"+n.resi,R!==x&&O!==A&&(P=!0,""!==S&&(void 0===d.structures[S]&&(d.structures[S]=[]),d.structures[S].push(A))),d.residueId2Name[U]=r;let $="-";if("helix"===n.ss?$="H":"sheet"===n.ss?$="E":n.het||a?$="o":(!n.het&&c.parasCls.residueColors.hasOwnProperty(n.resn.toUpperCase())||"coil"===n.ss)&&($="c"),d.secondaries[n.structure+"_"+n.chain+"_"+n.resi]=$,(n.resi!=I||b!=D)&&d.bFullUi&&(void 0===d.chainsSeq[q]&&(d.chainsSeq[q]=[],P=!1),!isNaN(n.resi)))if(P&&!M&&void 0!==d.chainsSeq[q][n.resi-1])d.chainsSeq[q][n.resi-1].name=r;else if(!P||!d.chainsSeq[q].hasOwnProperty(n.resi-1)){let e={};e.resi=n.resi,e.name=r,n.resi%10==0&&n.resi.toString(),d.chainsSeq[q].push(e),M=!0}I=n.resi,T=n.resi_ori,E=n.resn,S=k,A=O,x=R,D=b}for(let e in d.chemicals){let t=d.atoms[e];if("P"==t.elem&&t.bonds.length>=4)for(let e=t.bonds.length-1;e>=0;--e){"P"==d.atoms[t.bonds[e]].elem&&t.bonds.splice(e,1)}}for(let e in L)if(!(Object.keys(d.chains[e]).length<10)&&"chemical"!==L[e])for(let t in d.chains[e]){let s=d.atoms[t];delete d.chemicals[t],s.het=!1,"protein"===L[e]?(d.proteins[t]=1,"CA"===s.name&&(d.calphas[t]=1),"N"!==s.name&&"H"!==s.name&&"CA"!==s.name&&"HA"!==s.name&&"C"!==s.name&&"O"!==s.name&&(d.sidec[t]=1)):"nucleotide"===L[e]&&(d.nucleotides[t]=1,("O3'"==s.name||"O3*"==s.name||H&&"P"==s.name)&&(d.nucleotidesO3[t]=1),-1===c.parasCls.nuclMainArray.indexOf(s.name)&&(d.ntbase[t]=1))}if(void 0===d.structures[k]&&(d.structures[k]=[]),d.structures[k].push(O),d.bFullUi)if("mmdbid"===s||"mmcifid"===s)for(let i in e.sequences){let n=e.sequences[i],l=t+"_"+i;void 0!==d.mmdbid_q&&(d.mmdbid_q,d.mmdbid_t),d.ParserUtilsCls.getMissingResidues(n,s,l)}else if("align"===s)for(let e in d.chainid2seq){let t=d.chainid2seq[e];d.ParserUtilsCls.getMissingResidues(t,s,e)}if(d.loadPDBCls.setResidMapping(),"mmcifid"!==s)for(let e in h){let t=w[e],s=void 0===d.atoms[t].bonds?0:d.atoms[t].bonds.length;for(let e=0;ed.maxatomcnt||void 0!==d.biomtMatrices&&d.biomtMatrices.length*d.cnt>10*d.maxatomcnt)&&(d.opts.proteins="c alpha trace",d.opts.nucleotides="o3 trace"),d.center=d.ParserUtilsCls.getGeoCenter(d.pmin,d.pmax),d.maxD=d.ParserUtilsCls.getStructureSize(d.atoms,d.pmin,d.pmax,d.center),d.maxD<5&&(d.maxD=5),d.oriMaxD=d.maxD,("align"===s||o)&&(d.ssbondpnts={},d.loadPDBCls.setSsbond()),"mmdbid"===s&&1==Object.keys(d.structures).length){let t=e.disulfides;if(void 0!==t)for(let e=0,s=t.length;ep&&(p=e)),c[e]={resi:t,resn:i,aligned:n}}r=e[t][1];let u=r.moleculeId,g=s.pdbid_molid2chain[l+"_"+u],f=l+"_"+g;void 0===s.alnChainsAnTtl[d]&&(s.alnChainsAnTtl[d]=[]),void 0===s.alnChainsAnTtl[d][0]&&(s.alnChainsAnTtl[d][0]=[]),void 0===s.alnChainsAnTtl[d][1]&&(s.alnChainsAnTtl[d][1]=[]),void 0===s.alnChainsAnTtl[d][2]&&(s.alnChainsAnTtl[d][2]=[]),void 0===s.alnChainsAnTtl[d][3]&&(s.alnChainsAnTtl[d][3]=[]),void 0===s.alnChainsAnTtl[d][4]&&(s.alnChainsAnTtl[d][4]=[]),void 0===s.alnChainsAnTtl[d][5]&&(s.alnChainsAnTtl[d][5]=[]),void 0===s.alnChainsAnTtl[d][6]&&(s.alnChainsAnTtl[d][6]=[]),s.alnChainsAnTtl[d][0].push(f),s.alnChainsAnTtl[d][1].push(d),s.alnChainsAnTtl[d][2].push(""),s.alnChainsAnTtl[d][3].push(""),s.alnChainsAnTtl[d][4].push(f),s.alnChainsAnTtl[d][5].push(d),s.alnChainsAnTtl[d][6].push("");let b=1;s.chainsMapping[d]||(s.chainsMapping[d]={}),s.chainsMapping[f]||(s.chainsMapping[f]={});for(let e=h;e<=p;++e){let t,o,p,m=s.bUsePdbNum?s.ParserUtilsCls.getResi(f,r.sequence[e][0]-1):r.sequence[e][0],u="~"===r.sequence[e][2]?"-":r.sequence[e][2],C=r.sequence[e][3]?1:0,y=c[e].aligned+C;2===y?(c[e].resn===u?(t="#FF0000",p="icn3d-cons",s.consHash1[d+"_"+c[e].resi]=1,s.consHash2[f+"_"+m]=1):(t="#0000FF",p="icn3d-ncons",s.nconsHash1[d+"_"+c[e].resi]=1,s.nconsHash2[f+"_"+m]=1),s.chainsMapping[d][d+"_"+c[e].resi]=c[e].resn+c[e].resi,s.chainsMapping[f][f+"_"+m]=c[e].resn+c[e].resi,o="#"+s.showAnnoCls.getColorhexFromBlosum62(c[e].resn,u)):(t=i.htmlCls.GREY8,p="icn3d-nalign",s.nalignHash1[d+"_"+c[e].resi]=1,s.nalignHash2[f+"_"+m]=1),void 0===s.alnChainsSeq[d]&&(s.alnChainsSeq[d]=[]);let v={};v.mmdbid=n,v.chain=a,v.resi=c[e].resi,v.resn=""===v.resi||"icn3d-nalign"===p?c[e].resn.toLowerCase():c[e].resn,v.aligned=y,v.color=""===v.resi?i.htmlCls.GREYC:t,v.color2=""===v.resi?i.htmlCls.GREYC:o,v.class=p,s.alnChainsSeq[d].push(v),""!==c[e].resi&&(void 0===s.alnChains[d]&&(s.alnChains[d]={}),$.extend(s.alnChains[d],s.residues[d+"_"+c[e].resi])),void 0===s.alnChainsSeq[f]&&(s.alnChainsSeq[f]=[]),v={},v.mmdbid=l,v.chain=g,v.resi=m,v.resn=""===v.resi||"icn3d-nalign"===p?u.toLowerCase():u,v.aligned=y,v.color=""===v.resi?i.htmlCls.GREYC:t,v.color2=""===v.resi?i.htmlCls.GREYC:o,v.class=p,s.alnChainsSeq[f].push(v),""!==v.resi&&(void 0===s.alnChains[f]&&(s.alnChains[f]={}),$.extend(s.alnChains[f],s.residues[f+"_"+m])),void 0===s.alnChainsAnno[d]&&(s.alnChainsAnno[d]=[]),void 0===s.alnChainsAnno[d][0]&&(s.alnChainsAnno[d][0]=[]),void 0===s.alnChainsAnno[d][1]&&(s.alnChainsAnno[d][1]=[]),void 0===s.alnChainsAnno[d][2]&&(s.alnChainsAnno[d][2]=[]),void 0===s.alnChainsAnno[d][3]&&(s.alnChainsAnno[d][3]=[]),e===h&&(void 0===s.alnChainsAnno[d][4]&&(s.alnChainsAnno[d][4]=[]),void 0===s.alnChainsAnno[d][5]&&(s.alnChainsAnno[d][5]=[]),void 0===s.alnChainsAnno[d][6]&&(s.alnChainsAnno[d][6]=[]),s.alnChainsAnno[d][4].push(s.pdbid_chain2title[f]),s.alnChainsAnno[d][5].push(s.pdbid_chain2title[d]),s.alnChainsAnno[d][6].push(""));let _=d+"_"+c[e].resi,w=f+"_"+m,S=s.secondaries[_],A=s.secondaries[w];A?s.alnChainsAnno[d][0].push(A):s.alnChainsAnno[d][0].push("-"),S?s.alnChainsAnno[d][1].push(S):s.alnChainsAnno[d][1].push("-");let x=".";b%5==0&&(x="*"),b%10==0&&(x="|"),s.alnChainsAnno[d][2].push(x);let k="";b%10==0&&(k=b.toString()),s.alnChainsAnno[d][3].push(k),++b}}e={}}getPosFromResi(e,t){let s=this.icn3d;s.icn3dui;let i,n=s.resid2ncbi[e+"_"+t];if(n){i=n.substr(n.lastIndexOf("_")+1)-1}return i}getResnFromResi(e,t){let s=this.icn3d;s.icn3dui;let i=e+"_"+t,n=s.residueId2Name[i];return n||(n="?"),n}getResiAferAlign(e,t,s){let i,n=this.icn3d,l=n.icn3dui;if(t&&"tmalign"==l.cfg.aligntool)i=s;else if(n.posid2resid){let t=n.posid2resid[e+"_"+s];i=t.substr(t.lastIndexOf("_")+1)}else i=n.chainsSeq[e][s].resi;return i}setSeqAlignChain(e,t,s){let i,n,l,r,o,a,d,c,h,p,m,u=this.icn3d,g=u.icn3dui,f={},b=!!s;if(b){if(o=s[1],a=s[0],t=s[2],d=o.indexOf("_"),c=a.indexOf("_"),i=o.substr(0,d).toUpperCase(),n=a.substr(0,c).toUpperCase(),l=o.substr(d+1),r=a.substr(d+1),i==n&&l==r){let e=u.chainsSeq[n+"_"+r].length;u.qt_start_end[t]={q_start:1,q_end:e,t_start:1,t_end:e}}}else{let d=s[0].indexOf("_"),c=e.indexOf("_");if(i=u.mmdbid_t,n=e.substr(0,c).toUpperCase(),l=s[0].substr(d+1),r=e.substr(c+1),i==n&&l==r){let e=u.chainsSeq[u.mmdbid_q+"_"+u.chain_q].length;u.qt_start_end[t]={q_start:1,q_end:e,t_start:1,t_end:e}}o=i+"_"+l,a=n+"_"+r,void 0!==n&&u.mmdbid_t}u.conservedName1=o+"_cons",u.nonConservedName1=o+"_ncons",u.notAlignedName1=o+"_nalign",u.conservedName2=a+"_cons",u.nonConservedName2=a+"_ncons",u.notAlignedName2=a+"_nalign",u.consHash1={},u.nconsHash1={},u.nalignHash1={},u.consHash2={},u.nconsHash2={},u.nalignHash2={},u.alnChains={},u.alnChainsSeq[o]=[],u.alnChains[o]={},u.alnChainsSeq[a]=[],u.alnChains[a]={},u.alnChainsAnno[o]=[],u.alnChainsAnTtl[o]=[],void 0===u.alnChainsAnTtl[o]&&(u.alnChainsAnTtl[o]=[]);for(let e=0;e<7;++e)void 0===u.alnChainsAnTtl[o][e]&&(u.alnChainsAnTtl[o][e]=[]);u.alnChainsAnTtl[o][0].push(a),u.alnChainsAnTtl[o][1].push(o),u.alnChainsAnTtl[o][2].push(""),u.alnChainsAnTtl[o][3].push(""),u.alnChainsAnTtl[o][4].push(a),u.alnChainsAnTtl[o][5].push(o),u.alnChainsAnTtl[o][6].push("");let C=0,y=0;if(void 0===u.qt_start_end[t])return;let v=1;u.chainsMapping[o]||(u.chainsMapping[o]={}),u.chainsMapping[a]||(u.chainsMapping[a]={});let _={},w={};for(let e=0,s=u.qt_start_end[t].length;e0){let e=v;for(let t=C+1,i=s;tc&&(c=t)}}}"tmalign"==n.cfg.aligntool&&(s=!0);let p=Object.keys(a);p.sort((function(e,t){return parseInt(e)-parseInt(t)}));let m=-999,u=0,g=0,f=[],b=0;for(let e=0,t=p.length;e0&&i.resid2ncbi[t]!=i.resid2ncbi[m]+1&&i.resid2ncbi[t]!=i.resid2ncbi[m]){g=m;for(let e=0,t=f.length;ec)continue;let o={},p=r.indexOf("_");o.mmdbid=r.substr(0,p),o.chain=r.substr(p+1),o.resi=t,o.resn=a[t]?i.chainsSeq[r][e].name.toUpperCase():i.chainsSeq[r][e].name.toLowerCase(),o.aligned=!!a[t],o.color=a[t]?"#FF0000":n.htmlCls.GREYC,o.color2=a[t]?"#FF0000":n.htmlCls.GREYC,o.class=a[t]?"icn3d-align":"icn3d-nalign",i.alnChainsSeq[r].push(o),a[t]&&($.extend(i.alnChains[r],i.residues[r+"_"+o.resi]),l=n.hashUtilsCls.unionHash(l,i.residues[r+"_"+o.resi]))}let C=[0];for(let i=0,r=t.length;in)for(let e=0,t=u-m;e=n)for(let e=0,s=t-n;en)for(let e=0,t=d-a;e=n)for(let t=0,s=e-n;t0?void 0!==n?p.alnChainsAnno[t][0].push(n):p.alnChainsAnno[t][0].push("-"):console.log("Error: ic.alnChainsAnno[chainid1] is undefined")}}}class ls{constructor(e){this.icn3d=e}getStructureId(e,t,s){let i=this.icn3d;i.icn3dui;let n=e;return(e==i.defaultPdbId||s||i.structures.hasOwnProperty(e))&&(n=1===t?e:e+t.toString()),n}loadPDB(e,t,s,i,n,l,r,o){let a,d,c=this.icn3d,h=c.icn3dui,p={},m=!1,u=e.split("\n"),g={},f={};c.atoms||(l=!1),n||l?(c.oriNStru=c.structures?Object.keys(c.structures).length:0,d=c.oriNStru+1,a=c.atoms?Object.keys(c.atoms).length:0):(c.init(),d=1,a=0);let b,C,y,v,_,w,S,A=[],x=[],k=[],O=[],R=[],I=[],T="",E="",P="",M={},D=t||c.defaultPdbId,H=D,F="",L=!1,N=!0;for(let e in u){let r=u[e],q=r.substr(0,6);if("HEADER"!==q||L||t)if("TITLE "===q){let e=r.substr(10).replace(/ALPHAFOLD MONOMER V2.0 PREDICTION FOR /gi,"");c.molTitle+=e.trim()+" ",o&&c.esmTitle&&(c.molTitle=c.esmTitle),c.molTitleHash||(c.molTitleHash={}),c.molTitleHash[H]=c.molTitle}else if("HELIX "===q){c.bSecondaryStructure=!0;let e=""==r.substr(18,2).trim()?"A":r.substr(18,2).trim(),t=parseInt(r.substr(21,4)),s=parseInt(r.substr(33,4));for(let i=t;i<=s;++i){let n=H+"_"+e+"_"+i;O.push(n),i===t&&R.push(n),i===s&&I.push(n)}}else if("SHEET "===q){void 0!==s&&s||(c.bSecondaryStructure=!0);let e=""==r.substr(20,2).trim()?"A":r.substr(20,2).trim(),t=parseInt(r.substr(22,4)),i=parseInt(r.substr(33,4));for(let s=t;s<=i;++s){let n=H+"_"+e+"_"+s;A.push(n),s===t&&x.push(n),s===i&&k.push(n)}}else if("HBOND "===q)void 0!==s&&s||(c.bSecondaryStructure=!0);else if("SSBOND"===q){c.bSsbondProvided=!0;let e=D+"_"+(" "==r.substr(15,1)?"A":r.substr(15,1))+"_"+r.substr(17,4).trim(),t=D+"_"+(" "==r.substr(29,1)?"A":r.substr(29,1))+"_"+r.substr(31,4).trim();void 0===c.ssbondpnts[D]&&(c.ssbondpnts[D]=[]),c.ssbondpnts[D].push(e),c.ssbondpnts[D].push(t)}else if("REMARK"===q){let e=parseInt(r.substr(7,3));if(-1!==r.indexOf("1/2 of bilayer thickness:"))c.halfBilayerSize=parseFloat(r.substr(r.indexOf(":")+1).trim());else if(210==e)"EXPERIMENT TYPE"==r.substr(11,32).trim()&&"NMR"==r.substr(45).trim()&&(m=!0);else if(350==e&&"BIOMT"==r.substr(13,5)){let e=parseInt(r[18])-1,t=parseInt(r.substr(21,2))-1;null==c.biomtMatrices[t]&&(c.biomtMatrices[t]=(new THREE.Matrix4).identity()),c.biomtMatrices[t].elements[e]=parseFloat(r.substr(24,9)),c.biomtMatrices[t].elements[e+4]=parseFloat(r.substr(34,9)),c.biomtMatrices[t].elements[e+8]=parseFloat(r.substr(44,9)),c.biomtMatrices[t].elements[e+12]=parseFloat(r.substr(54,14))}else if(465==e&&" "==r.substr(18,1)&&" "==r.substr(20,1)&&"S"!=r.substr(21,1)){let e=r.substr(15,3),t=r.substr(18,2).trim(),s=r.substr(21,5).trim(),i=D+"_"+t;void 0===c.chainMissingResidueArray[i]&&(c.chainMissingResidueArray[i]=[]);let n={};n.resi=s,n.name=h.utilsCls.residueName2Abbr(e).toLowerCase(),""!=F&&t==F&&t!=F||(c.chainMissingResidueArray[i].push(n),F=t)}else 900==e&&void 0===c.emd&&"RELATED DB: EMDB"==r.substr(34).trim()&&(c.emd=r.substr(23,11).trim())}else if("SOURCE"===q&&void 0===c.organism&&"ORGANISM_COMMON"==r.substr(11,15).trim())c.organism=r.substr(28).toLowerCase().trim(),c.organism=c.organism.substr(0,c.organism.length-1);else if("ENDMDL"===q)++d,D=c.defaultPdbId,H=this.getStructureId(D,d,n),m||(A=[],x=[],k=[],O=[],R=[],I=[]),L=!1;else if("JRNL "===q)"PMID"===r.substr(12,4)&&(c.pmid=r.substr(19).trim());else if("ATOM "===q||"HETATM"===q){N&&(H=this.getStructureId(D,d,n),N=!1);let e=r.substr(16,1);++a,M[parseInt(r.substr(6,5))]=a;let t=r.substr(76,2).trim();""===t&&(t=r.substr(12,2).trim());let l=r.substr(12,4).trim(),u=r.substr(17,3),F=r.substr(20,2).trim();""===F&&(F="A");let L=r.substr(22,5).trim(),U=L;if(s&&"DUM"===u&&(t=l,F="MEM",U=1,L=1),i&&"DUM"===u)break;b=H+"_"+F,y=b+"_"+L,C=b+"_"+U;let $=parseFloat(r.substr(30,8)),j=parseFloat(r.substr(38,8)),B=parseFloat(r.substr(46,8)),z=new THREE.Vector3($,j,B),G=parseFloat(r.substr(60,8));o&&(G*=100);let V={het:"H"===q[0],serial:a,name:l,alt:e,resn:u,structure:H,chain:F,resi:U,coord:z,b:G,elem:t,bonds:[],ss:"coil",ssbegin:!1,ssend:!1};if(V.het||"C"!==V.name||(v=a),V.het||"O"!==V.name||(w=a),!V.het&&"N"===V.name&&void 0!==_&&void 0!==S){let e=c.atoms[_].coord.distanceTo(c.atoms[S].coord),t=V.coord.x+(c.atoms[_].coord.x-c.atoms[S].coord.x)/e,s=V.coord.y+(c.atoms[_].coord.y-c.atoms[S].coord.y)/e,i=V.coord.z+(c.atoms[_].coord.z-c.atoms[S].coord.z)/e;V.hcoord=new THREE.Vector3(t,s,i)}c.atoms[a]=V,c.dAtoms[a]=1,c.hAtoms[a]=1,p[a]=1,this.isSecondary(C,A,m)?(c.atoms[a].ss="sheet",this.isSecondary(C,x,m)&&(c.atoms[a].ssbegin=!0),this.isSecondary(C,k,m)&&(c.atoms[a].ssend=!0)):this.isSecondary(C,O,m)&&(c.atoms[a].ss="helix",this.isSecondary(C,R,m)&&(c.atoms[a].ssbegin=!0),this.isSecondary(C,I,m)&&(c.atoms[a].ssend=!0));let W="-";if(W="helix"===c.atoms[a].ss?"H":"sheet"===c.atoms[a].ss?"E":!c.atoms[a].het&&h.parasCls.residueColors.hasOwnProperty(c.atoms[a].resn.toUpperCase())?"c":"o",c.secondaries[C]=W,y!==P){let e=h.utilsCls.residueName2Abbr(u);if(c.residueId2Name[C]=e,1!==a&&""!==E&&(c.residues[E]=f),C!==E&&(f={}),b!==T){_=void 0,S=void 0,1!==a&&""!==T&&(void 0===c.chains[T]&&(c.chains[T]={}),c.chains[T]=h.hashUtilsCls.unionHash(c.chains[T],g)),g={},void 0===c.structures[H.toString()]&&(c.structures[H.toString()]=[]),c.structures[H.toString()].includes(b)||c.structures[H.toString()].push(b),void 0===c.chainsSeq[b]&&(c.chainsSeq[b]=[]);let t={};t.resi=U,t.name=e,c.chainsSeq[b].push(t)}else{_=v,S=w;let t={};t.resi=U,t.name=e,c.chainsSeq[b].push(t)}}g[a]=1,f[a]=1,T=b,E=C,P=y}else if("CONECT"===q){let e=parseInt(r.substr(6,5));for(let t=0;t<4;++t){let s=parseInt(r.substr([11,16,21,26][t],5));isNaN(s)||void 0!==c.atoms[M[e]]&&c.atoms[M[e]].bonds.push(M[s])}}else q.substr(0,3);else D=r.substr(62).trim(),""==D&&(D=l?c.defaultPdbId:c.inputid&&-1==c.inputid.indexOf("/")?c.inputid.substr(0,10):c.defaultPdbId),H=this.getStructureId(D,d,n),c.molTitle="",c.molTitleHash={},L=!0}c.residues[C]=f,void 0===c.chains[b]&&(c.chains[b]={}),c.chains[b]=h.hashUtilsCls.unionHash2Atoms(c.chains[b],g,c.atoms),this.adjustSeq(c.chainMissingResidueArray);let q=Object.keys(c.structures);for(let e=0,t=q.length;e=l?n:l,o=new Array(s+i),a=0,d=0,c=0,h=!1;for(;ar&&i>r&&(h=!0),s<=r&&i>r?s>i||h?(o[c]=t[d],d++):(o[c]=e[a],a++):s>r&&i<=r?s<=i||h?(o[c]=e[a],a++):(o[c]=t[d],d++):s<=i?(o[c]=e[a],a++):(o[c]=t[d],d++),c++}if(a4||Math.abs(l.y-r.y)>4||Math.abs(l.z-r.z)>4||(l.x-r.x)*(l.x-r.x)+(l.y-r.y)*(l.y-r.y)+(l.z-r.z)*(l.z-r.z)<16&&(void 0===t.ssbondpnts[e]&&(t.ssbondpnts[e]=[]),t.ssbondpnts[e].push(o),t.ssbondpnts[e].push(a)))}}}getChainCalpha(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r={};for(let o in e){if(void 0!==i){if(o.split("_")[0]!==i)continue}let a=Object.keys(e[o]),d=[],c=0,h=0;for(let e=0,i=a.length;e3?i.resn.trim().substr(0,3):i.resn.trim();if(!l.parasCls.chargeColors.hasOwnProperty(e))continue;s?i.resi_ori:i.resi,d.push(i.coord.clone()),++c,h=i.resi}}if(c>0){r[t[a[0]].chain]=d}}return{chainresiCalphaHash:r,center:n.center.clone()}}isSecondary(e,t,s){if(this.icn3d.icn3dui,s){let s=e.substr(e.indexOf("_")+1),i=!1;for(let e=0,n=t.length;e0&&(d=!0);for(let n=0,l=t.length;na&&(a=l),s.push(l)}o.push(s)}if(!d)return void(n.bRender&&alert("These structures can not be aligned..."));a<1e-6&&(a=1);for(let e=0,s=t.length;ep[e]=4&&(n.rmsd_suprTmp=l.rmsdSuprCls.getRmsdSuprCls(c,a,p),void 0!==n.rmsd_suprTmp.rot))){let e=n.rmsd_suprTmp.rot;if(null===e[0])continue;let i=n.rmsd_suprTmp.trans1,r=n.rmsd_suprTmp.trans2,a=n.rmsd_suprTmp.rmsd;if(aRealignment RMSD: "+a.toPrecision(4)+" Å

    "),l.cfg.bSidebyside||l.htmlCls.dialogCls.openDlg("dl_rmsd","Realignment RMSD"),n.q_rotation=[],n.q_trans_sub=[],n.t_trans_add=[],n.q_rotation.push({x1:e[0],y1:e[1],z1:e[2],x2:e[3],y2:e[4],z2:e[5],x3:e[6],y3:e[7],z3:e[8]}),n.q_trans_sub.push(i),n.t_trans_add.push({x:-r.x,y:-r.y,z:-r.z}),l.cfg.aligntool="vast";//!= 'tmalign'; -let c=0,h="query",p=o.substr(0,o.indexOf("_")),m=!0;n.chainalignParserCls.transformStructure(p,c,h,m);let u="";for(let e=0,i=s.length;e8)return s;let g=[];g[0]=n[0]*r[0]+n[1]*r[1]+n[2]*r[2],g[1]=n[3]*r[0]+n[4]*r[1]+n[5]*r[2],g[2]=n[6]*r[0]+n[7]*r[1]+n[8]*r[2],g[0]-=n[0]*a[0]+n[1]*a[1]+n[2]*a[2],g[1]-=n[3]*a[0]+n[4]*a[1]+n[5]*a[2],g[2]-=n[6]*a[0]+n[7]*a[1]+n[8]*a[2];let f=0;return f=c[0]*g[0],f+=c[1]*g[1],f+=c[2]*g[2],f/=p*m,f<.866?s:(g[0]=l[0]*r[0]+l[1]*r[1]+l[2]*r[2],g[1]=l[3]*r[0]+l[4]*r[1]+l[5]*r[2],g[2]=l[6]*r[0]+l[7]*r[1]+l[8]*r[2],g[0]-=l[0]*a[0]+l[1]*a[1]+l[2]*a[2],g[1]-=l[3]*a[0]+l[4]*a[1]+l[5]*a[2],g[2]-=l[6]*a[0]+l[7]*a[1]+l[8]*a[2],f=c[0]*g[0],f+=c[1]*g[1],f+=c[2]*g[2],f/=p*m,f<.866?s:(u=0,u+=Math.pow(e.q_rotation.x1-t.q_rotation.x1,2),u+=Math.pow(e.q_rotation.y1-t.q_rotation.y1,2),u+=Math.pow(e.q_rotation.z1-t.q_rotation.z1,2),u+=Math.pow(e.q_rotation.x2-t.q_rotation.x2,2),u+=Math.pow(e.q_rotation.y2-t.q_rotation.y2,2),u+=Math.pow(e.q_rotation.z2-t.q_rotation.z2,2),u+=Math.pow(e.q_rotation.x3-t.q_rotation.x3,2),u+=Math.pow(e.q_rotation.y3-t.q_rotation.y3,2),u+=Math.pow(e.q_rotation.z3-t.q_rotation.z3,2),Math.sqrt(u)))}GetRotMatrix(e,t,s){this.icn3d.icn3dui;let i=[];return i&&(i[0]=e.q_rotation.x1/t,i[1]=e.q_rotation.y1/t,i[2]=e.q_rotation.z1/t,i[3]=e.q_rotation.x2/t,i[4]=e.q_rotation.y2/t,i[5]=e.q_rotation.z2/t,i[6]=e.q_rotation.x3/t,i[7]=e.q_rotation.y3/t,i[8]=e.q_rotation.z3/t,2!=s?(i[9]=e.t_trans_add.x/t,i[10]=e.t_trans_add.y/t,i[11]=e.t_trans_add.z/t,i[12]=-e.q_trans_sub.x/t,i[13]=-e.q_trans_sub.y/t,i[14]=-e.q_trans_sub.z/t):(i[9]=-e.q_trans_add.x/t,i[10]=-e.q_trans_add.y/t,i[11]=-e.q_trans_add.z/t,i[12]=0,i[13]=0,i[14]=0)),i}cbu_dist(e,t,s){return er&&(s.push(e[n].leaves),i.push(e[n].dist));return{clusters:s,scores:i}}}class os{constructor(e){this.icn3d=e}async applyCommand(e){let t=this.icn3d,s=t.icn3dui;t.bAddCommands=!1;let i=e.split("|||")[0].split("%7C%7C%7C")[0].replace(/\s+/g," ").trim(),n=i.toLowerCase();if("share link"==n)await t.shareLinkCls.shareLink();else if("export state file"==n);else if(0==n.indexOf("export canvas"))setTimeout((async function(){let e=n.substr(13).trim();t.scaleFactor=""===e?1:parseInt(e);let s=""!==e;await t.shareLinkCls.shareLink(!0,s)}),500);else if("export interactions"==n)t.viewInterPairsCls.exportInteractions();else if("export stl file"==n)setTimeout((function(){t.export3DCls.exportStlFile("")}),500);else if("export vrml file"==n)setTimeout((function(){t.export3DCls.exportVrmlFile("")}),500);else if("export stl stabilizer file"==n)setTimeout((function(){t.threeDPrintCls.hideStabilizer(),t.threeDPrintCls.resetAfter3Dprint(),t.threeDPrintCls.addStabilizer(),t.export3DCls.exportStlFile("_stab")}),500);else if("export vrml stabilizer file"==n)setTimeout((function(){t.threeDPrintCls.hideStabilizer(),t.threeDPrintCls.resetAfter3Dprint(),t.threeDPrintCls.addStabilizer(),t.export3DCls.exportVrmlFile("_stab")}),500);else if("export pdb"==n)s.htmlCls.setHtmlCls.exportPdb();else if("export pdb missing atoms"==n)await t.scapCls.exportPdbProfix(!1);else if("export pdb hydrogen"==n)await t.scapCls.exportPdbProfix(!0);else if(-1!=n.indexOf("export refnum ")){let e=n.substr(14);t.refnumCls.exportRefnum(e)}else if("export secondary structure"==n)s.htmlCls.setHtmlCls.exportSecondary();else if("select all"==n)t.selectionCls.selectAll();else if("show all"==n)t.selectionCls.showAll();else if("select complement"==n)t.resid2specCls.selectComplement();else if("set pk atom"==n)t.pk=1,t.opts.pk="atom";else if("set pk off"==n)t.pk=0,t.opts.pk="no",t.drawCls.draw(),t.hlObjectsCls.removeHlObjects();else if("set pk residue"==n)t.pk=2,t.opts.pk="residue";else if("set pk strand"==n)t.pk=3,t.opts.pk="strand";else if("set pk domain"==n)t.pk=4,t.opts.pk="domain";else if("set pk chain"==n)t.pk=5,t.opts.pk="chain";else if("set surface wireframe on"==n)t.opts.wireframe="yes",t.applyMapCls.applySurfaceOptions();else if("set surface wireframe off"==n)t.opts.wireframe="no",t.applyMapCls.applySurfaceOptions();else if("set map wireframe on"==n)t.opts.mapwireframe="yes",t.applyMapCls.applyMapOptions();else if("set map wireframe off"==n)t.opts.mapwireframe="no",t.applyMapCls.applyMapOptions();else if("set emmap wireframe on"==n)t.opts.emmapwireframe="yes",t.applyMapCls.applyEmmapOptions();else if("set emmap wireframe off"==n)t.opts.emmapwireframe="no",t.applyMapCls.applyEmmapOptions();else if("set surface neighbors on"==n)t.bConsiderNeighbors=!0,t.applyMapCls.applySurfaceOptions();else if("set surface neighbors off"==n)t.bConsiderNeighbors=!1,t.applyMapCls.applySurfaceOptions();else if("set axis on"==n)t.opts.axis="yes";else if("set pc1 axis"==n)t.pc1=!0,t.axesCls.setPc1Axes();else if("set axis off"==n)t.opts.axis="no",t.pc1=!1;else if("set fog on"==n)t.opts.fog="yes",t.fogCls.setFog(!0);else if("set fog off"==n)t.opts.fog="no",t.fogCls.setFog(!0);else if("set slab on"==n)t.opts.slab="yes";else if("set slab off"==n)t.opts.slab="no";else if("set assembly on"==n)t.bAssembly=!0;else if("set assembly off"==n)t.bAssembly=!1;else if("set chemicalbinding show"==n)t.setOptionCls.setOption("chemicalbinding","show");else if("set chemicalbinding hide"==n)t.setOptionCls.setOption("chemicalbinding","hide");else if("set hbonds off"==n)t.hBondCls.hideHbonds(),t.showInterCls.hideExtraBonds(),t.drawCls.draw();else if("set salt bridge off"==n)t.saltbridgeCls.hideSaltbridge(),t.showInterCls.hideExtraBonds(),t.drawCls.draw();else if("set contact off"==n)t.contactCls.hideContact(),t.showInterCls.hideExtraBonds(),t.drawCls.draw();else if("set halogen pi off"==n)t.piHalogenCls.hideHalogenPi(),t.showInterCls.hideExtraBonds(),t.drawCls.draw();else if("hydrogens"==n)t.showInterCls.showHydrogens(),t.drawCls.draw();else if("set hydrogens off"==n)t.showInterCls.hideHydrogens(),t.drawCls.draw();else if("close popup"==n)t.resizeCanvasCls.closeDialogs();else if("set stabilizer off"==n)t.threeDPrintCls.hideStabilizer(),t.drawCls.draw();else if("set disulfide bonds off"==n)t.opts.ssbonds="no",t.drawCls.draw();else if("set cross linkage off"==n)t.opts.clbonds="no",t.drawCls.draw();else if("set lines off"==n)t.labels.distance=[],t.lines.distance=[],t.drawCls.draw();else if("set labels off"==n){for(let e in t.labels)t.labels[e]=[];t.drawCls.draw()}else if("set mode all"==n)t.definedSetsCls.setModeAndDisplay("all");else if("set mode selection"==n)t.definedSetsCls.setModeAndDisplay("selection");else if("set view detailed view"==n)t.annotationCls.setAnnoViewAndDisplay("detailed view");else if("set view overview"==n)t.annotationCls.setAnnoViewAndDisplay("overview");else if("set annotation custom"==n)t.annotationCls.setAnnoTabCustom();else if("set annotation interaction"==n)t.annotationCls.setAnnoTabInteraction();else if("set annotation ptm"==n)await t.annotationCls.setAnnoTabPTM();else if("set annotation cdd"==n)t.annotationCls.setAnnoTabCdd();else if("set annotation site"==n)t.annotationCls.setAnnoTabSite();else if("set annotation ssbond"==n)t.annotationCls.setAnnoTabSsbond();else if("set annotation crosslink"==n)t.annotationCls.setAnnoTabCrosslink();else if("set annotation transmembrane"==n)await t.annotationCls.setAnnoTabTransmem();else if("highlight level up"==n)t.resid2specCls.switchHighlightLevelUp();else if("highlight level down"==n)t.resid2specCls.switchHighlightLevelDown();else if(0==n.indexOf("hide annotation")){let e=n.lastIndexOf(" "),s=n.substr(e+1);"all"==s?t.annotationCls.hideAnnoTabAll():"custom"==s?t.annotationCls.hideAnnoTabCustom():"clinvar"==s?t.annotationCls.hideAnnoTabClinvar():"snp"==s?t.annotationCls.hideAnnoTabSnp():"cdd"==s?t.annotationCls.hideAnnoTabCdd():"3ddomain"==s?t.annotationCls.hideAnnoTab3ddomain():"site"==s?t.annotationCls.hideAnnoTabSite():"ptm"==s?t.annotationCls.hideAnnoTabPTM():"interaction"==s?t.annotationCls.hideAnnoTabInteraction():"ssbond"==s?t.annotationCls.hideAnnoTabSsbond():"crosslink"==s?t.annotationCls.hideAnnoTabCrosslink():"transmembrane"==s&&t.annotationCls.hideAnnoTabTransmem()}else if("add residue labels"==n)t.residueLabelsCls.addResidueLabels(t.hAtoms),t.drawCls.draw();else if("add residue number labels"==n)t.residueLabelsCls.addResidueLabels(t.hAtoms,void 0,void 0,!0),t.drawCls.draw();else if("add reference number labels"==n)t.residueLabelsCls.addResidueLabels(t.hAtoms,void 0,void 0,void 0,!0),t.drawCls.draw();else if("add atom labels"==n)t.residueLabelsCls.addAtomLabels(t.hAtoms),t.drawCls.draw();else if("add element labels"==n)t.residueLabelsCls.addAtomLabels(t.hAtoms,!0),t.drawCls.draw();else if("add chain labels"==n)t.analysisCls.addChainLabels(t.hAtoms),t.drawCls.draw();else if("add terminal labels"==n)t.analysisCls.addTerminiLabels(t.hAtoms),t.drawCls.draw();else if("rotate left"==n)t.bStopRotate=!1,t.ROT_DIR="left",t.transformCls.rotateCountMax=6e3,t.resizeCanvasCls.rotStruc("left");else if("rotate right"==n)t.bStopRotate=!1,t.ROT_DIR="right",t.transformCls.rotateCountMax=6e3,t.resizeCanvasCls.rotStruc("right");else if("rotate up"==n)t.bStopRotate=!1,t.ROT_DIR="up",t.transformCls.rotateCountMax=6e3,t.resizeCanvasCls.rotStruc("up");else if("rotate down"==n)t.bStopRotate=!1,t.ROT_DIR="down",t.transformCls.rotateCountMax=6e3,t.resizeCanvasCls.rotStruc("down");else if("rotate x"==n){let e=new THREE.Vector3(1,0,0),s=.5*Math.PI;t.transformCls.setRotation(e,s)}else if("rotate y"==n){let e=new THREE.Vector3(0,1,0),s=.5*Math.PI;t.transformCls.setRotation(e,s)}else if("rotate z"==n){let e=new THREE.Vector3(0,0,1),s=.5*Math.PI;t.transformCls.setRotation(e,s)}else if("reset"===n)t.selectionCls.resetAll();else if("reset orientation"===n)t.transformCls.resetOrientation(),t.drawCls.draw();else if("reset thickness"==n)t.threeDPrintCls.resetAfter3Dprint(),t.drawCls.draw();else if("clear selection"==n)t.hlObjectsCls.removeHlObjects(),t.hlUpdateCls.removeHl2D(),t.bShowHighlight=!1,t.bSelectResidue=!1;else if("zoom selection"==n)t.transformCls.zoominSelection(),t.drawCls.draw();else if("center selection"==n)t.applyCenterCls.centerSelection(),t.drawCls.draw();else if("show selection"==n)t.selectionCls.showSelection();else if("hide selection"==n)t.selectionCls.hideSelection();else if("output selection"==n)t.threeDPrintCls.outputSelection();else if("toggle selection"==n)t.selectionCls.toggleSelection();else if("toggle highlight"==n)t.hlUpdateCls.toggleHighlight();else if("stabilizer"==n)t.threeDPrintCls.addStabilizer(),t.threeDPrintCls.prepareFor3Dprint();else if("disulfide bonds"==n)t.showInterCls.showSsbonds();else if("cross linkage"==n)t.showInterCls.showClbonds();else if("back"==n)await t.resizeCanvasCls.back();else if("forward"==n)await t.resizeCanvasCls.forward();else if("clear all"==n)t.selectionCls.selectAll();else if("defined sets"==n)t.definedSetsCls.showSets();else if("delete selected sets"==n)t.definedSetsCls.deleteSelectedSets();else if("view interactions"==n)void 0===s.cfg.mmdbid&&void 0===s.cfg.gi||t.ParserUtilsCls.set2DDiagrams(t.inputid);else if("show annotations all chains"==n)t.annotationCls.showAnnoAllChains();else if("save color"==n)t.setOptionCls.saveColor();else if("apply saved color"==n)t.setOptionCls.applySavedColor();else if("save style"==n)t.setOptionCls.saveStyle();else if("apply saved style"==n)t.setOptionCls.applySavedStyle();else if("select main chains"==n)t.selectionCls.selectMainChains();else if("select side chains"==n)t.selectionCls.selectSideChains();else if("select main side chains"==n)t.selectionCls.selectMainSideChains();else if("realign"==n)t.realignParserCls.realign();else if(-1!=n.indexOf("realign predefined ")){let e="realign predefined ",n=i.substr(e.length),l=n.indexOf(" "),r=n.substr(0,l).split(",");s.cfg.resdef=n.substr(l+1).replace(/:/gi,";"),await t.realignParserCls.realignChainOnSeqAlign(void 0,r,!0,!0)}else if("area"==n)t.analysisCls.calculateArea();else if("table inter count only"==n)$(".icn3d-border").hide();else if("table inter details"==n)$(".icn3d-border").show();else if("setoption map nothing"==n)t.setOptionCls.setOption("map","nothing");else if("setoption emmap nothing"==n)t.setOptionCls.setOption("emmap","nothing");else if("setoption phimap nothing"==n)t.setOptionCls.setOption("phimap","nothing");else if("setoption phisurface nothing"==n)t.setOptionCls.setOption("phisurface","nothing");else if("clear symd symmetry"==n)t.symdArray=[];else if("show axis"==n)t.bAxisOnly=!0;else if(0==i.indexOf("define helix sets")){let e=i.split(" | ")[1].split(" ")[1];t.addTrackCls.defineSecondary(e,"helix")}else if(0==i.indexOf("define sheet sets")){let e=i.split(" | ")[1].split(" ")[1];t.addTrackCls.defineSecondary(e,"sheet")}else if(0==i.indexOf("define coil sets")){let e=i.split(" | ")[1].split(" ")[1];t.addTrackCls.defineSecondary(e,"coil")}else if(0==i.indexOf("define igstrand sets")){let e=i.split(" | ")[1].split(" ")[1];t.addTrackCls.defineIgstrand(e,"igstrand")}else if(0==i.indexOf("define igloop sets")){let e=i.split(" | ")[1].split(" ")[1];t.addTrackCls.defineIgstrand(e,"igloop")}else if(0==i.indexOf("select interaction")){let e=i.substr(i.lastIndexOf(" ")+1).split(",");if(null!==e){let s=e[0].split("_")[0];t.b2DShown||t.ParserUtilsCls.download2Ddgm(s.toUpperCase()),t.diagram2dCls.selectInteraction(e[0],e[1])}}else if(0==i.indexOf("select saved atoms")||0==i.indexOf("select sets")){i=i.replace(/aligned_protein/g,"protein_aligned");let e=i.split(" | "),s=e[0].replace(/,/g," or "),n=19;0==i.indexOf("select sets")&&(n=12);let l=s.substr(n),r=l;2==e.length&&(r=e[1].substr(5)),t.definedSetsCls.selectCombinedSets(l,r)}else if(-1!==i.indexOf("select chain")){let e=i.substr(i.lastIndexOf(" ")+1).split(",");for(let s=0,i=e.length;s6?e[6].substr(e[6].lastIndexOf(" ")+1):0,d=e.length>7?e[7].substr(e[7].lastIndexOf(" ")+1):1;t.analysisCls.addLine(parseFloat(s[1]),parseFloat(s[3]),parseFloat(s[5]),parseFloat(i[1]),parseFloat(i[3]),parseFloat(i[5]),l,r,o,parseFloat(a),parseFloat(d)),t.drawCls.draw()}else if(0==n.indexOf("add sphere"))this.addShape(n,"sphere");else if(0==n.indexOf("add cube"))this.addShape(n,"cube");else if(0==n.indexOf("clear shape"))t.shapeCmdHash={};else if(0==n.indexOf("clear line between sets"))t.lines.cylinder=[];else if(0==i.indexOf("add label")){let e,n,l,r,o,a,d,c=i.split(" | "),h=c[0].substr("add label".length+1),p=!1;for(let t=1,s=c.length;t=5&&(e=l[4].substr(5)),l.length>=6&&(s=l[5].substr(6)),l.length>=7&&(n=l[6].substr(4)),$("#"+t.pre+"anno_custom")[0]&&($("#"+t.pre+"anno_custom")[0].checked=!0),$("[id^="+t.pre+"custom]").show(),"0"==s&&(s=void 0),t.addTrackCls.checkGiSeq(r,o,a,e,s,n,0)}else if(0==n.indexOf("remove one stabilizer")){let e=n.split(" | ")[1].split(" "),s=[];s.push(parseInt(e[0])),s.push(parseInt(e[1])),t.threeDPrintCls.removeOneStabilizer(s),t.drawCls.draw()}else if(0==n.indexOf("add one stabilizer")){let e=n.split(" | ")[1].split(" ");void 0===t.pairArray&&(t.pairArray=[]),t.pairArray.push(parseInt(e[0])),t.pairArray.push(parseInt(e[1])),t.drawCls.draw()}else if(0==n.indexOf("select planes z-axis")){let e=n.split(" ");if(5==e.length){let s=parseFloat(e[3]),i=parseFloat(e[4]);t.selectionCls.selectBtwPlanes(s,i)}}else if(0==n.indexOf("adjust membrane z-axis")){let e=n.split(" ");if(5==e.length){let s=parseFloat(e[3]),i=parseFloat(e[4]);t.selectionCls.adjustMembrane(s,i)}}else if(0==n.indexOf("toggle membrane"))t.selectionCls.toggleMembrane();else if(0==i.indexOf("calc buried surface")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(" ");if(2==s.length){let e=s[0].split(","),i=s[1].split(",");t.analysisCls.calcBuriedSurface(e,i)}}}else if(0==i.indexOf("dist ")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(" ");if(2==s.length){let e=s[0].split(","),i=s[1].split(",");t.analysisCls.measureDistTwoSets(e,i)}}}else if(0==i.indexOf("disttable")){let e=i.split(" | ");if(2==e.length){let i=e[1].split(" ");if(2==i.length){let e=i[0].split(","),n=i[1].split(",");t.analysisCls.measureDistManySets(e,n),s.htmlCls.dialogCls.openDlg("dl_disttable","Distance among the sets")}}}else if(0==i.indexOf("display interaction 3d")||0==i.indexOf("view interaction pairs")||0==i.indexOf("save1 interaction pairs")||0==i.indexOf("save2 interaction pairs")||0==i.indexOf("line graph interaction pairs")||0==i.indexOf("scatterplot interaction pairs")){let e=i.split(" | ");if(e.length>=3){let s=e[1].split(" ");if(2==s.length){let n,l,r=s[0].split(","),o=s[1].split(","),a=-1!==e[2].indexOf("hbonds"),d=-1!==e[2].indexOf("salt bridge"),c=-1!==e[2].indexOf("interactions"),h=-1!==e[2].indexOf("halogen"),p=-1!==e[2].indexOf("pi-cation"),m=-1!==e[2].indexOf("pi-stacking");if(e.length>=4&&(n="true"==e[3]),e.length>=5){let s=e[4].split(" ");s.length>=4&&($("#"+t.pre+"hbondthreshold").val(s[1]),$("#"+t.pre+"saltbridgethreshold").val(s[2]),$("#"+t.pre+"contactthreshold").val(s[3]),7==s.length&&($("#"+t.pre+"halogenthreshold").val(s[4]),$("#"+t.pre+"picationthreshold").val(s[5]),$("#"+t.pre+"pistackingthreshold").val(s[6])))}0==i.indexOf("display interaction 3d")?l="3d":0==i.indexOf("view interaction pairs")?l="view":0==i.indexOf("save1 interaction pairs")?l="save1":0==i.indexOf("save2 interaction pairs")?l="save2":0==i.indexOf("line graph interaction pairs")?l="linegraph":0==i.indexOf("scatterplot interaction pairs")&&(l="scatterplot"),await t.viewInterPairsCls.viewInteractionPairs(r,o,n,l,a,d,c,h,p,m)}}}else if(0==i.indexOf("export pairs")){let e=i.split(" | ");if(3==e.length){let i=e[1].split(" ");if(2==i.length){let n=i[0].split(","),l=i[1].split(","),r=e[2].split(" ")[1];t.showInterCls.pickCustomSphere(r,n,l,t.bSphereCalc),t.bSphereCalc=!0;let o=t.viewInterPairsCls.exportSpherePairs(),a=Object.keys(s.utilsCls.getHlStructures()).join(",");t.saveFileCls.saveFile(a+"_sphere_pairs.html","html",o)}}}else if(0==n.indexOf("graph label")){let e=n.lastIndexOf(" "),t=n.substr(e+1);$("#"+s.svgid+"_label").val(t),$("#"+s.svgid+" text").removeClass(),$("#"+s.svgid+" text").addClass(t)}else if(0==n.indexOf("cartoon label")){let e=n.lastIndexOf(" "),t=n.substr(e+1);$("#"+s.svgid_ct+"_label").val(t),$("#"+s.svgid_ct+" text").removeClass(),$("#"+s.svgid_ct+" text").addClass(t)}else if(0==n.indexOf("line graph scale")){let e=n.lastIndexOf(" "),i=n.substr(e+1);$("#"+s.linegraphid+"_scale").val(i),$("#"+s.linegraphid).attr("width",(t.linegraphWidth*parseFloat(i)).toString()+"px")}else if(0==n.indexOf("scatterplot scale")){let e=n.lastIndexOf(" "),i=n.substr(e+1);$("#"+s.scatterplotid+"_scale").val(i),$("#"+s.scatterplotid).attr("width",(t.scatterplotWidth*parseFloat(i)).toString()+"px")}else if(0==n.indexOf("contactmap scale")){let e=n.lastIndexOf(" "),i=n.substr(e+1);$("#"+s.contactmapid+"_scale").val(i),$("#"+s.contactmapid).attr("width",(t.contactmapWidth*parseFloat(i)).toString()+"px")}else if(0==n.indexOf("alignerrormap scale")){let e=n.lastIndexOf(" "),i=n.substr(e+1);$("#"+s.alignerrormapid+"_scale").val(i),$("#"+s.alignerrormapid).attr("width",(t.alignerrormapWidth*parseFloat(i)).toString()+"px")}else if(0==n.indexOf("graph force")){let e=n.lastIndexOf(" ");s.htmlCls.force=parseInt(n.substr(e+1)),$("#"+s.svgid+"_force").val(s.htmlCls.force),t.getGraphCls.handleForce()}else if(0==n.indexOf("hide edges")){let e=n.lastIndexOf(" ");s.htmlCls.hideedges=parseInt(n.substr(e+1)),$("#"+s.svgid+"_hideedges").val(s.htmlCls.hideedges),s.htmlCls.hideedges?(s.htmlCls.contactInsideColor="FFF",s.htmlCls.hbondInsideColor="FFF",s.htmlCls.ionicInsideColor="FFF"):(s.htmlCls.contactInsideColor="DDD",s.htmlCls.hbondInsideColor="AFA",s.htmlCls.ionicInsideColor="8FF"),void 0!==t.graphStr&&t.bRender&&s.htmlCls.force&&t.drawGraphCls.drawGraph(t.graphStr,t.pre+"dl_graph")}else if(0==n.indexOf("reset interaction pairs"))t.viewInterPairsCls.resetInteractionPairs();else if(0==n.indexOf("side by side")){let e=n.split(" | ")[1],t="_blank";window.open(e,t)}else if(0==i.indexOf("your note")){let e=i.split(" | ");t.yournote=e[1],$("#"+t.pre+"yournote").val(t.yournote),s.cfg.shownote&&(document.title=t.yournote)}else if(0==n.indexOf("cross structure interaction"))t.crossstrucinter=parseInt(n.substr(n.lastIndexOf(" ")+1)),$("#"+t.pre+"crossstrucinter").val(t.crossstrucinter);else if("replay on"==n)await t.resizeCanvasCls.replayon();else if("replay off"==n)await t.resizeCanvasCls.replayoff();else if(0==n.indexOf("contact map")){let e=n.split(" | ");if(3===e.length){let s=parseFloat(e[1].split(" ")[1]),i=e[2].split(" ")[1];await t.contactMapCls.contactMap(s,i)}}else if(0==n.indexOf("pickatom")){let e=parseInt(n.substr(n.lastIndexOf(" ")+1));t.pAtom=t.atoms[e],t.pickingCls.showPicking(t.pAtom)}else if(0==i.indexOf("set color spectrum")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(","),i=!0;t.setColorCls.setColorAcrossSets(s,i)}}else if(0==i.indexOf("set residues color spectrum")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(","),i=!0;t.setColorCls.setColorBySets(s,i)}}else if(0==i.indexOf("set color rainbow")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(","),i=!1;t.setColorCls.setColorAcrossSets(s,i)}}else if(0==i.indexOf("set residues color rainbow")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(","),i=!1;t.setColorCls.setColorBySets(s,i)}}else if(0==i.indexOf("color")){let e=i.split(" | "),n=e[0].substr(e[0].indexOf(" ")+1);if(t.opts.color=n,"residue custom"==n&&2==e.length){t.customResidueColors=JSON.parse(e[1]);for(let e in t.customResidueColors)t.customResidueColors[e.toUpperCase()]=s.parasCls.thr("#"+t.customResidueColors[e])}else if("align custom"==n&&3==e.length){let s=e[1],i=e[2].split(", ");t.queryresi2score={},t.queryresi2score[s]={};for(let e=0,n=i.length;e=4?this.setQueryresi2score(e):"area"==n&&2==e.length&&(t.midpercent=e[1],$("#"+t.pre+"midpercent").val(t.midpercent));t.setColorCls.setColorByOptions(t.opts,t.hAtoms),t.hlUpdateCls.updateHlAll(),t.getGraphCls.updateGraphColor()}else if(0==i.indexOf("remove legend"))$("#"+s.pre+"legend").hide();else if(0==i.indexOf("custom tube")){let e=i.split(" | ");this.setQueryresi2score(e),t.setOptionCls.setStyle("proteins","custom tube")}else if(0==n.indexOf("style")){let e=n.substr(n.indexOf(" ")+1),s=e.substr(0,e.indexOf(" ")),i=e.substr(e.indexOf(" ")+1);t.setOptionCls.setStyle(s,i)}else if(0==n.indexOf("window")){let e=n.substr(n.indexOf(" ")+1);setTimeout((function(){"aligned sequences"==e?s.htmlCls.dialogCls.openDlg("dl_alignment","Select residues in aligned sequences"):"interaction table"==e?s.htmlCls.dialogCls.openDlg("dl_allinteraction","Show interactions"):"interaction graph"==e?s.htmlCls.dialogCls.openDlg("dl_linegraph","Show interactions between two lines of residue nodes"):"interaction scatterplot"==e?s.htmlCls.dialogCls.openDlg("dl_scatterplot","Show interactions as scatterplot"):"force-directed graph"==e&&s.htmlCls.dialogCls.openDlg("dl_graph","Force-directed graph")}),1e3)}else if(0==n.indexOf("set theme")){let e=n.substr(n.lastIndexOf(" ")+1);s.htmlCls.setMenuCls.setTheme(e)}else if(0==n.indexOf("set double color")){let e=n.substr(n.lastIndexOf(" ")+1);"on"==e?(t.bDoublecolor=!0,t.setOptionCls.setStyle("proteins","ribbon")):"off"==e&&(t.bDoublecolor=!1)}else if(0==n.indexOf("adjust dialog")){let e=n.substr(n.lastIndexOf(" ")+1);t.scapCls.adjust2DWidth(e)}else if(0==n.indexOf("glycans cartoon")){let e=n.substr(n.lastIndexOf(" ")+1);t.bGlycansCartoon="yes"==e}else if(0==n.indexOf("save html")){let e=n.substr(n.lastIndexOf(" ")+1);s.htmlCls.eventsCls.saveHtml(e)}else if(0==n.indexOf("resdef"))s.cfg.resdef=n.substr(n.indexOf(" ")+1);else if(0==n.indexOf("vast_search_chainid")){t.chainidArray=i.substr(i.indexOf(" ")+1).split(",");let e=!0,s=!0;await t.realignParserCls.realignChainOnSeqAlign(void 0,t.chainidArray,e,s)}else if(0==n.indexOf("ig refnum off"))await t.refnumCls.hideIgRefNum();else if(0==n.indexOf("custom refnum")){let e=i.split(" | ")[1].replace(/\\n/g,"\n");await t.refnumCls.parseCustomRefFile(e)}else if(0==n.indexOf("show ref number"))t.bShownRefnum=!0;else if(0==n.indexOf("hide ref number"))t.bShownRefnum=!1;else if(-1!==n.indexOf("select displayed set"))t.hAtoms=s.hashUtilsCls.cloneHash(t.viewSelectionAtoms),t.hlUpdateCls.updateHlAll();else if(-1!==n.indexOf("select prop")){let e,s,n=i.split(" | "),l=n[0].substr("select prop".length+1);if(2==n.length){let t=n[1].split("_");e=t[0],s=t[1]}t.resid2specCls.selectProperty(l,e,s)}else if(-1!==n.indexOf("select each residue"))t.selectionCls.saveEachResiInSel();else if(0==n.indexOf("select")&&-1!==n.indexOf("name")){let e=i.split(" | "),s="",n="",l="";for(let t=0,i=e.length;t1&&(n=e[1].substr(e[1].indexOf(" ")+1)),e.length>2&&(l=e[2].substr(e[2].indexOf(" ")+1)),-1!==s.indexOf(" or ")?await t.selByCommCls.selectByCommand(s,n,l):await t.selByCommCls.selectBySpec(s,n,l)}s.htmlCls.clickMenuCls.setLogCmd(i,!1),t.bAddCommands=!0}setStrengthPara(e){let t=this.icn3d;if(t.icn3dui,e.length>=5){let s=e[4].split(" ");s.length>=4&&($("#"+t.pre+"hbondthreshold").val(s[1]),$("#"+t.pre+"saltbridgethreshold").val(s[2]),$("#"+t.pre+"contactthreshold").val(s[3]),s.length>=7&&($("#"+t.pre+"halogenthreshold").val(s[4]),$("#"+t.pre+"picationthreshold").val(s[5]),$("#"+t.pre+"pistackingthreshold").val(s[6])))}if(6==e.length){let s=e[5].split(" ");s.length>=6&&($("#"+t.pre+"dist_ss").val(s[0]),$("#"+t.pre+"dist_coil").val(s[1]),$("#"+t.pre+"dist_hbond").val(s[2]),$("#"+t.pre+"dist_inter").val(s[3]),$("#"+t.pre+"dist_ssbond").val(s[4]),$("#"+t.pre+"dist_ionic").val(s[5]),9==s.length&&($("#"+t.pre+"dist_halogen").val(s[6]),$("#"+t.pre+"dist_pication").val(s[7]),$("#"+t.pre+"dist_pistacking").val(s[8])))}}getThresholdNameArrays(e){this.icn3d.icn3dui.htmlCls.clickMenuCls.SetChainsAdvancedMenu();let t,s=e.split(" | "),i=parseFloat(s[0].substr(s[0].lastIndexOf(" ")+1)),n=[],l=[];if(s.length>=2&&s[1].length>4){let e=s[1].split(" ");e.length>1&&(l=e[1].split(",")),e.length>2&&(n=e[2].split(","))}else l=["selected"],n=["non-selected"];return 3==s.length&&(t="true"==s[2]),{threshold:i,nameArray2:l,nameArray:n,bHbondCalc:t}}setQueryresi2score(e){let t=this.icn3d,s=t.icn3dui,i=e[1],n=e[2].split(" ")[1].split("_"),l=e[3];void 0===t.queryresi2score&&(t.queryresi2score={}),t.queryresi2score[i]={};for(let e=parseInt(n[0]),s=0;e<=parseInt(n[1]);++e,++s)"_"!=l[s]&&(t.queryresi2score[i][e]=11.11111111111111*parseInt(l[s]));if(e.length>4){let i=e[4].split(" ");t.startColor=i[1],t.midColor=i[2],t.endColor=i[3];let n=s.htmlCls.clickMenuCls.setLegendHtml();$("#"+s.pre+"dl_legend_html").html(n),s.htmlCls.dialogCls.openDlg("dl_legend","Color Range")}}addShape(e,t){let s=this.icn3d,i=s.icn3dui;s.shapeCmdHash[e]=1;let n=e.split(" | "),l=n[1].split(" "),r=n[2].substr(n[2].lastIndexOf(" ")+1),o=n[3].substr(n[3].lastIndexOf(" ")+1),a=n[4].substr(n[4].lastIndexOf(" ")+1);r="#"+r.replace(/\#/g,"");let d=i.parasCls.thr(r),c=new THREE.Vector3(parseFloat(l[1]),parseFloat(l[3]),parseFloat(l[5]));"sphere"==t?s.sphereCls.createSphereBase(c,d,parseFloat(a),void 0,void 0,void 0,parseFloat(o)):s.boxCls.createBox_base(c,parseFloat(a),d,void 0,void 0,void 0,parseFloat(o))}getMenuFromCmd(e){this.icn3d.icn3dui;let t="Windows > View Sequences & Annotations",s="Analysis > Interactions",i=s+" > 2D Graph(Force-Directed)",n="View > Rotate > Auto Rotation > Rotate ",l="View > Rotate > Rotate 90 deg > ",r="Select > Select on 3D > ",o="Analysis > Label > ",a="File > 3D Printing > ";return 0==(e=e.trim()).indexOf("load")?"File > Retrieve by ID, Align":0==e.indexOf("set map")&&-1==e.indexOf("set map wireframe")?"Style > Electron Density":0==e.indexOf("set emmap")&&-1==e.indexOf("set emmap wireframe")?"Style > EM Density Map":0==e.indexOf("set phi")?"Analysis > Load Potential > URL(CORS) Phi/Cube":0==e.indexOf("set delphi")?"Analysis > DelPhi Potential":0==e.indexOf("setoption map")?"Style > Remove Map":0==e.indexOf("setoption emmap")?"Style > Remove EM Map":0==e.indexOf("view annotations")?t:0==e.indexOf("set annotation all")?t+': "All" checkbox':0==e.indexOf("set annotation clinvar")?t+': "ClinVar" checkbox':0==e.indexOf("set annotation snp")?t+': "SNP" checkbox':0==e.indexOf("set annotation 3ddomain")?t+': "3D Domains" checkbox':0==e.indexOf("view interactions")?"Windows > View 2D Diagram":0==e.indexOf("symmetry")?"Analysis > Symmetry":0==e.indexOf("realign on seq align")?"File > Realign Selection > on Sequence Alignment":0==e.indexOf("realign")?"File > Realign Selection > Residue by Residue":0==e.indexOf("graph interaction pairs")?s+" > 2D Graph(Force-Directed)":0==e.indexOf("export canvas")?"File > Save File > iCn3D PNG Image":"export stl file"==e?a+"STL":"export vrml file"==e?a+"VRML(Color)":"export stl stabilizer file"==e?a+"STL W/ Stabilizers":"export vrml stabilizer file"==e?a+"VRML(Color, W/ Stabilizers)":"select all"==e?'Select > All; or Toggle to "All"(next to "Help")':"show all"==e?"View > View Full Structure":"select complement"==e?"Select > Inverse":"set pk atom"==e?r+"Atom":"set pk residue"==e?r+"Residue":"set pk strand"==e?r+"Strand/Helix":"set pk domain"==e?r+"3D Domain":"set pk chain"==e?r+"Chain":"set surface wireframe on"==e?"Style > Surface Wireframe > Yes":"set surface wireframe off"==e?"Style > Surface Wireframe > No":"set map wireframe on"==e?"Style > Map Wireframe > Yes":"set map wireframe off"==e?"Style > Map Wireframe > No":"set emmap wireframe on"==e?"Style > EM Map Wireframe > Yes":"set emmap wireframe off"==e?"Style > EM Map Wireframe > No":"set surface neighbors on"==e?"Style > Surface Type > ... with Context":"set axis on"==e?"View > XYZ-axes > Show":"set axis off"==e?"View > XYZ-axes > Hide":"set fog on"==e?"View > Fog for Selection > On":"set fog off"==e?"View > Fog for Selection > Off":"set slab on"==e?"View > Slab for Selection > On":"set slab off"==e?"View > Slab for Selection > Off":"set assembly on"==e?"Analysis > Assembly > Biological Assembly":"set assembly off"==e?"Analysis > Assembly > Asymmetric Unit":"set chemicalbinding show"==e?"Analysis > Chem. Binding > Show":"set chemicalbinding hide"==e?"Analysis > Chem. Binding > Hide":"set hbonds off"==e||"set salt bridge off"==e||"set contact off"==e||"set halogen pi off"==e?s+" > Reset":"hydrogens"==e?"Style > Hydrogens > Show":"set hydrogens off"==e?"Style > Hydrogens > Hide":"set stabilizer off"==e?"File > 3D Printing > Remove All Stabilizers":"set disulfide bonds off"==e?"Analysis > Disulfide Bonds > Hide":"set cross linkage off"==e?"Analysis > Cross-Linkages > Hide":"set lines off"==e?"Analysis > Distance > Hide":"set labels off"==e?"Analysis > Label > Remove":"set mode all"==e?'Toggle to "All"(next to "Help")':"set mode selection"==e?'Toggle to "Selection"(next to "Help")':"set view detailed view"==e?t+': "Details" tab':"set view overview"==e?t+': "Summary" tab':"set annotation custom"==e?t+': "Custom" checkbox':"set annotation interaction"==e?t+': "Interactions" checkbox':"set annotation ptm"==e?t+': "PTM" checkbox':"set annotation cdd"==e?t+': "Conserved Domains" checkbox':"set annotation site"==e?t+': "Functional Sites" checkbox':"set annotation ssbond"==e?t+': "Disulfide Bonds" checkbox':"set annotation crosslink"==e?t+': "Cross-Linkages" checkbox':"set annotation transmembrane"==e?t+': "Transmembrane" checkbox':"highlight level up"==e?"Keyboard Arrow Up":"highlight level down"==e?"Keyboard Arrow Down":0==e.indexOf("hide annotation")?t+": checkboxes off":"add residue labels"==e?o+"per Residue":"add residue number labels"==e?o+"per Residue & Number":"add atom labels"==e?o+"per Atom":"add chain labels"==e?o+"per Chain":"add terminal labels"==e?o+"N- & C- Termini":"rotate left"==e?n+"Left; or Key l":"rotate right"==e?n+"Right; or Key j":"rotate up"==e?n+"Up; or Key i":"rotate down"==e?n+"Down; or Key m":"rotate x"==e?l+"X-axis":"rotate y"==e?l+"Y-axis":"rotate z"==e?l+"Z-axis":"reset"==e?"View > Reset > All":"reset orientation"==e?"View > Reset > Orientation":"clear selection"==e?"Select > Clear Selection":"zoom selection"==e?"Select > Zoom in Selection":"center selection"==e?"Select > Center Selection":"show selection"==e?"Select > View Only Selection":"hide selection"==e?"Select > Hide Selection":"output selection"==e?"Select > Clear Selection":"toggle highlight"==e?"Select > Toggle Highlight":"stabilizer"==e?"File > 3D Printing > Add all Stabilizers":"disulfide bonds"==e?"Analysis > Disulfide Bonds > Show":"cross linkage"==e?"Analysis > Cross-Linkages > Show":"back"==e?"View > Undo":"forward"==e?"View > Redo":"clear all"==e?"Select > Clear Selection":"defined sets"==e?"Windows > Defined Sets":"delete selected sets"==e?'Windows > Defined Sets: "Delete Selected Sets" button':"view interactions"==e?"Windows > View Interactions":"show annotations all chains"==e?t+': "Show All Chains" button':"save color"==e?"Color > Save Color":"apply saved color"==e?"Color > Apply Saved Color":"save style"==e?"Style > Save Style":"apply saved style"==e?"Style > Apply Saved Style":"select main chains"==e?"Select > Main Chains":"select side chains"==e?"Select > Side Chains":"select main side chains"==e?"Select > Main & Side Chains":"area"==e?"View > Surface Area":"table inter count only"==e?s+': "Set 1" button: "Show Count Only" button':"table inter details"==e?s+': "Set 1" button: "Show Details" button':0==e.indexOf("define helix sets")?t+': "Helix Sets" button':0==e.indexOf("define sheet sets")?t+': "Sheet Sets" button':0==e.indexOf("define coil sets")?t+': "Coil Sets" button':0==e.indexOf("select interaction")?"Windows > View 2D Diagram: click on edges":0==e.indexOf("select saved atoms")||0==e.indexOf("select sets")?"Windows > Defined Sets: select in menu":-1!==e.indexOf("select chain")?t+": click on chain names":-1!==e.indexOf("select alignChain")?"Windows > View Aligned Sequences: click on chain names":0==e.indexOf("select zone cutoff")?"Select > by Distance":0==e.indexOf("set surface opacity")?"Style > Surface Opacity":0==e.indexOf("set label scale")?"View > Label Scale":0==e.indexOf("set surface")?"Style > Surface Type":0==e.indexOf("set camera")?"View > Camera":0==e.indexOf("set background")?"Style > Background":0==e.indexOf("set thickness")?"File > 3D Printing > Set Thickness":0==e.indexOf("set highlight color")?"Select > Highlight Color":0==e.indexOf("set highlight style")?"Select > Highlight Style":0==e.indexOf("add line")||0==e.indexOf("add label")?"Analysis > Distance > between Two Atoms":0==e.indexOf("dist")?"Analysis > Distance > between Two Sets":0==e.indexOf("msa")?t+': "Add Track" button: "FASTA Alignment" button':0==e.indexOf("add track")?t+': "Add Track" button':0==e.indexOf("remove one stabilizer")?"File > 3D Printing > Remove One Stablizer":0==e.indexOf("add one stabilizer")?"File > 3D Printing > Add One Stablizer":0==e.indexOf("select planes z-axis")?"View > Select between Two X-Y Planes":0==e.indexOf("adjust membrane z-axis")?"View > Adjust Membrane":0==e.indexOf("toggle membrane")?"View > Toggle Membrane":0==e.indexOf("calc buried surface")?s+': "Buried Surface Area" button':0==e.indexOf("display interaction 3d")?s+': "3D Display Interactions" button':0==e.indexOf("view interaction pairs")?s+': "Highlight Interactions in Table" button':0==e.indexOf("save1 interaction pairs")?s+': "Set 1" button':0==e.indexOf("save2 interaction pairs")?s+': "Set 2" button':0==e.indexOf("line graph interaction pairs")?s+': "2D Interaction Network" button':0==e.indexOf("scatterplot interaction pairs")?s+': "2D Interaction Map" button':0==e.indexOf("graph label")?i+': "Label Size" menu':0==e.indexOf("graph force")?i+': "Force on Nodes" menu':0==e.indexOf("hide edges")?i+': "Internal Edges" menu':0==e.indexOf("reset interaction pairs")?s+" > Reset":0==e.indexOf("side by side")?"View > Side by Side":0==e.indexOf("your note")?"Windows > Your Notes / Window Title":0==e.indexOf("pickatom")?"Hold Alt key and click on 3D structure":0==e.indexOf("color")?"Color menu":0==e.indexOf("custom tube")?t+': "Custom Color/Tube" button: "Custom Tube" button':0==e.indexOf("style")?"Style menu":-1!==e.indexOf("select displayed set")?"Select > Displayed Set":-1!==e.indexOf("select prop")?"Select > by Property":0==e.indexOf("select")&&-1!==e.indexOf("name")?t+": drag on residues to select":-1!==e.indexOf("select $")||-1!==e.indexOf("select .")||-1!==e.indexOf("select :")||-1!==e.indexOf("select @")?"Select > Advanced; or other selection":-1!==e.indexOf("replay on")?"File > Replay Each Step > On":-1!==e.indexOf("replay off")?"File > Replay Each Step > Off":-1!==e.indexOf("set theme")?"Style > Theme Color":-1!==e.indexOf("set double color")?"Style > Two-color Helix":""}}class as{constructor(e){this.icn3d=e}setProtNuclLigInMenu(){let e=this.icn3d;if(e.icn3dui,Object.keys(e.proteins).length>0&&(e.defNames2Residues.proteins=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.proteins)),e.defNames2Descr.proteins="proteins",e.defNames2Command.proteins="select :proteins"),Object.keys(e.nucleotides).length>0&&(e.defNames2Residues.nucleotides=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.nucleotides)),e.defNames2Descr.nucleotides="nucleotides",e.defNames2Command.nucleotides="select :nucleotides"),Object.keys(e.chemicals).length>0)if(e.bOpm){let t={},s={};for(let i in e.chemicals){let n=e.atoms[i],l=n.structure+"_"+n.chain+"_"+n.resi;"DUM"===n.resn?s[l]=1:t[l]=1}Object.keys(t).length>0&&(e.defNames2Residues.chemicals=Object.keys(t),e.defNames2Descr.chemicals="chemicals",e.defNames2Command.chemicals="select :chemicals"),Object.keys(s).length>0&&(e.defNames2Residues.membrane=Object.keys(s),e.defNames2Descr.membrane="membrane",e.defNames2Command.membrane="select :membrane")}else e.defNames2Residues.chemicals=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.chemicals)),e.defNames2Descr.chemicals="chemicals",e.defNames2Command.chemicals="select :chemicals";Object.keys(e.ions).length>0&&(e.defNames2Residues.ions=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.ions)),e.defNames2Descr.ions="ions",e.defNames2Command.ions="select :ions"),Object.keys(e.water).length>0&&(e.defNames2Residues.water=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.water)),e.defNames2Descr.water="water",e.defNames2Command.water="select :water"),this.setTransmemInMenu(e.halfBilayerSize,-e.halfBilayerSize)}setPredefinedInMenu(){let e=this.icn3d,t=e.icn3dui;if(this.setChainsInMenu(),this.setProtNuclLigInMenu(),void 0!==t.cfg.mmdbid||void 0!==t.cfg.gi||void 0!==t.cfg.chainalign||void 0!==t.cfg.mmdbafid)for(let t in e.tddomains)e.selectionCls.selectResidueList(e.tddomains[t],t,t,!1,!1);if((void 0!==t.cfg.align||void 0!==t.cfg.chainalign&&2==e.chainidArray.length)&&e.bFullUi){e.selectionCls.selectResidueList(e.consHash1,e.conservedName1,e.conservedName1,!1,!1),e.selectionCls.selectResidueList(e.consHash2,e.conservedName2,e.conservedName2,!1,!1),e.selectionCls.selectResidueList(e.nconsHash1,e.nonConservedName1,e.nonConservedName1,!1,!1),e.selectionCls.selectResidueList(e.nconsHash2,e.nonConservedName2,e.nonConservedName2,!1,!1),e.selectionCls.selectResidueList(e.nalignHash1,e.notAlignedName1,e.notAlignedName1,!1,!1),e.selectionCls.selectResidueList(e.nalignHash2,e.notAlignedName2,e.notAlignedName2,!1,!1);let s={};for(let i in e.alnChains)s=t.hashUtilsCls.unionHash(s,e.alnChains[i]);let i=e.firstAtomObjCls.getResiduesFromAtoms(s),n="protein_aligned",l="aligned protein and nucleotides",r="select "+e.resid2specCls.residueids2spec(Object.keys(i));e.selectionCls.addCustomSelection(Object.keys(i),n,l,r,!0)}}setAtomMenu(e){let t=this.icn3d;t.icn3dui;let s="",i=void 0!==t.defNames2Residues?Object.keys(t.defNames2Residues):[],n=void 0!==t.defNames2Atoms?Object.keys(t.defNames2Atoms):[],l=i.concat(n).sort(),r=[];l.forEach((e=>{-1===$.inArray(e,r)&&r.push(e)}));for(let i=0,n=r.length;i0&&(n=t.atoms[e[0]])}else if(void 0!==t.defNames2Residues&&t.defNames2Residues.hasOwnProperty(o)){let e=t.defNames2Residues[o];e.length>0&&(l=t.residues[e[0]],l&&(n=t.atoms[Object.keys(l)[0]]))}let a=void 0===n||void 0===n.color||"FFFFFF"===n.color.getHexString().toUpperCase()?"DDDDDD":n.color.getHexString(),d=void 0!==n&&void 0!==n.color?a:"000000";-1!=e.indexOf(o)?s+="":s+=""}return s}setChainsInMenu(){let e=this.icn3d;e.icn3dui;for(let t in e.chains)if(e.chainsSeq[t]&&e.chainsSeq[t].length>1){e.defNames2Residues[t]=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.chains[t])),e.defNames2Descr[t]=t;let s=t.indexOf("_"),i=t.substr(0,s),n=t.substr(s+1);e.defNames2Command[t]="select $"+i+"."+n}if(1==Object.keys(e.structures)){let t=Object.keys(e.structures)[0];e.defNames2Residues[t]=Object.keys(e.residues),e.defNames2Descr[t]=t,e.defNames2Command[t]="select $"+t}else{let t=Object.keys(e.residues),s={};for(let e=0,i=t.length;ee?l[a]=1:o.coord.z0&&(i.defNames2Residues["transmembrane"+o]=Object.keys(n),i.defNames2Descr["transmembrane"+o]="transmembrane"+o,i.defNames2Command["transmembrane"+o]="select :transmembrane"+o),Object.keys(l).length>0&&(i.defNames2Residues["extracellular"+o]=Object.keys(l),i.defNames2Descr["extracellular"+o]="extracellular"+o,i.defNames2Command["extracellular"+o]="select :extracellular"+o),Object.keys(r).length>0&&(i.defNames2Residues["intracellular"+o]=Object.keys(r),i.defNames2Descr["intracellular"+o]="intracellular"+o,i.defNames2Command["intracellular"+o]="select :intracellular"+o)}}showSets(){let e=this.icn3d,t=e.icn3dui;t.bNode||(t.htmlCls.dialogCls.openDlg("dl_definedsets","Select sets"),$("#"+e.pre+"dl_setsmenu").show(),$("#"+e.pre+"dl_setoperations").show(),$("#"+e.pre+"dl_command").hide(),$("#"+e.pre+"atomsCustom").resizable());let s=t.hashUtilsCls.cloneHash(e.hAtoms),i=t.hashUtilsCls.cloneHash(e.dAtoms);void 0!==e.bSetChainsAdvancedMenu&&e.bSetChainsAdvancedMenu&&!e.bResetSets||(this.setPredefinedInMenu(),e.bSetChainsAdvancedMenu=!0),e.hAtoms=t.hashUtilsCls.cloneHash(s),e.dAtoms=t.hashUtilsCls.cloneHash(i),e.hlUpdateCls.updateHlMenus()}clickCustomAtoms(){let e=this.icn3d,t=e.icn3dui,s=this;$("#"+e.pre+"atomsCustom").change((function(e){let i=s.icn3d,n=$(this).val();if(i.nameArray=n,null!==n){let e=!1;s.changeCustomAtoms(n,e),t.htmlCls.clickMenuCls.setLogCmd("select sets "+n.join(" "+i.setOperation+" "),!0),i.bSelectResidue=!1}})),t.myEventCls.onIds("#"+e.pre+"atomsCustom","focus",(function(e){let i=s.icn3d;t.utilsCls.isMobile()&&$("#"+i.pre+"atomsCustom").val("")}))}deleteSelectedSets(){let e=this.icn3d;e.icn3dui;let t=$("#"+e.pre+"atomsCustom").val();for(let s=0;s0)for(let n=0,l=t.defNames2Residues[e].length;n0)for(let s=0,n=t.defNames2Atoms[e].length;s0&&(n[0]=i.commands[0]);let l=e.trim().split("\n");i.commands=l;let r=l[0].indexOf("command=");if(t&&-1!=r){let e=l[0].substr(0,r-1);i.commands.splice(0,1,e)}i.STATENUMBER=i.commands.length,i.commands=n.concat(i.commands),i.STATENUMBER=i.commands.length,i.CURRENTNUMBER=0,i.bReplay?await this.replayFirstStep(i.CURRENTNUMBER):await this.execCommands(i.CURRENTNUMBER,i.STATENUMBER-1,i.STATENUMBER,s)}async execCommands(e,t,s,i){let n=this.icn3d;n.icn3dui,n.bRender=!1,i||n.reinitAfterLoad(),await this.execCommandsBase(e,t,s)}getNameArray(e){let t=this.icn3d;t.icn3dui;let s=e.split(" | "),i=[];return 2==s.length&&(i=s[1].split(","),t.hAtoms=t.definedSetsCls.getAtomsFromNameArray(i)),i}async execCommandsBase(e,t,s,i){let n,l=this.icn3d,r=l.icn3dui,o=this;for(n=e;n<=t;++n){let i=n===s-1;if(!l.commands[n].trim())continue;if(0==(l.atoms?Object.keys(l.atoms).length:0)&&-1==l.commands[n].indexOf("load"))continue;let a=l.commands[n].split("|||"),d=a[0].trim();if(l.inputid&&(l.bNotLoadStructure=!0),-1!==d.indexOf("load")){if(0===t&&e===t)return void(l.bNotLoadStructure?(l.hAtoms=r.hashUtilsCls.cloneHash(l.atoms),1===l.commands.length&&(l.bAddCommands=!0),i&&this.renderFinalStep(s)):(await o.applyCommandLoad(l.commands[n]),1===l.commands.length&&(l.bAddCommands=!0),i&&o.renderFinalStep(s)));l.bNotLoadStructure?(l.hAtoms=r.hashUtilsCls.cloneHash(l.atoms),l.backForward&&this.renderFinalStep(1)):(await o.applyCommandLoad(l.commands[n]),l.backForward&&o.renderFinalStep(1))}else if(0==d.indexOf("set map")&&-1==d.indexOf("set map wireframe")){let e=a[0].trim().split(" | ")[0].substr(8).split(" ");3==e.length&&"sigma"==e[1]&&(e[2],e[0],await o.applyCommandMap(a[0].trim()))}else if(0==d.indexOf("set emmap")&&-1==d.indexOf("set emmap wireframe")){let e=a[0].trim().substr(10).split(" ");2==e.length&&"percentage"==e[0]&&(e[1],await o.applyCommandEmmap(a[0].trim()))}else if(0==d.indexOf("set phi"))await l.delphiCls.applyCommandPhi(a[0].trim());else if(0==d.indexOf("set delphi"))await l.delphiCls.applyCommandDelphi(a[0].trim());else if(0==d.indexOf("view annotations"))Object.keys(l.proteins).length>0&&await o.applyCommandAnnotationsAndCddSite(a[0].trim());else if(0==d.indexOf("set annotation clinvar"))Object.keys(l.proteins).length>0&&await o.applyCommandClinvar(a[0].trim());else if(0==d.indexOf("set annotation snp"))Object.keys(l.proteins).length>0&&await o.applyCommandSnp(a[0].trim());else if(0==d.indexOf("set annotation ptm"))Object.keys(l.proteins).length>0&&await o.applyCommandPTM(a[0].trim());else if(0==d.indexOf("ig refnum on"))await l.refnumCls.showIgRefNum();else if(0==d.indexOf("ig template")){let e=d.substr(d.lastIndexOf(" ")+1);await l.refnumCls.showIgRefNum(e)}else if(0==d.indexOf("set annotation 3ddomain"))Object.keys(l.proteins).length>0&&o.applyCommand3ddomain(a[0].trim());else if(0==d.indexOf("set annotation all"))Object.keys(l.proteins).length>0&&(await o.applyCommandClinvar(a[0].trim()),await o.applyCommandSnp(a[0].trim()),o.applyCommand3ddomain(a[0].trim())),await l.annotationCls.setAnnoTabAll();else if(0==d.indexOf("view interactions")&&void 0!==r.cfg.align)await o.applyCommandViewinteraction(a[0].trim());else if(0==d.indexOf("symmetry")){l.bAxisOnly=!1;let e=d.substr(d.indexOf(" ")+1);l.symmetrytitle="none"===e?void 0:e,"none"!==e&&await l.symdCls.retrieveSymmetry(Object.keys(l.structures)[0]),l.drawCls.draw()}else if(0==d.indexOf("symd symmetry"))l.bAxisOnly=!1,await l.symdCls.applyCommandSymd(d),l.drawCls.draw();else if(0==d.indexOf("scap"))await l.scapCls.applyCommandScap(d);else if(0==d.indexOf("realign on seq align"))this.getNameArray(d),await o.applyCommandRealign(d);else if(0==d.indexOf("realign on structure align msa")){let e=this.getNameArray(d);r.cfg.aligntool="vast",await l.realignParserCls.realignOnStructAlignMsa(e)}else if(0==d.indexOf("realign on structure align"))this.getNameArray(d),r.cfg.aligntool="vast",await l.realignParserCls.realignOnStructAlign();else if(0==d.indexOf("realign on tmalign msa")){let e=this.getNameArray(d);r.cfg.aligntool="tmalign",await l.realignParserCls.realignOnStructAlignMsa(e)}else if(0==d.indexOf("realign on tmalign"))this.getNameArray(d),r.cfg.aligntool="tmalign",await l.realignParserCls.realignOnStructAlign();else if(0==d.indexOf("realign on vastplus"))o.getHAtoms(l.commands[n]),await l.vastplusCls.realignOnVastplus();else if(0==d.indexOf("graph interaction pairs"))await o.applyCommandGraphinteraction(d);else if(0==d.indexOf("cartoon 2d domain"))await o.applyCommandCartoon2d(d);else if(0==d.indexOf("set half pae map"))await o.applyCommandAfmap(d);else if(0==d.indexOf("set full pae map"))await o.applyCommandAfmap(d,!0);else if(0==d.indexOf("export pqr"))await r.htmlCls.setHtmlCls.exportPqr();else if(0==d.indexOf("cartoon 2d chain")||0==d.indexOf("cartoon 2d secondary")){let e=d.lastIndexOf(" "),t=d.substr(e+1);await l.cartoon2dCls.draw2Dcartoon(t)}else if(0==d.indexOf("add msa track")){let e=d.split(" | "),t=e[1].substr(8),s=e[2].substr(9),i=e[3].substr(5),n=e[4].substr(10);$("#"+l.pre+"anno_custom")[0]&&($("#"+l.pre+"anno_custom")[0].checked=!0),$("[id^="+l.pre+"custom]").show(),await l.addTrackCls.addMsaTracks(t,s,i,n)}else if(0==d.indexOf("add exon track")){let e=d.split(" | "),t=e[1].substr(8),s=e[2].substr(7),i=e[3].substr(9),n=e[4].substr(5);$("#"+l.pre+"anno_custom")[0]&&($("#"+l.pre+"anno_custom")[0].checked=!0),$("[id^="+l.pre+"custom]").show(),await l.addTrackCls.addExonTracks(t,s,i,n)}else await l.applyCommandCls.applyCommand(l.commands[n])}(n===s||i)&&this.renderFinalStep(n)}pressCommandtext(){let e=this.icn3d,t=e.icn3dui,s=this;$("#"+e.pre+"logtext").keypress((async function(e){let i=s.icn3d;if(i.bAddLogs=!1,13==(e.keyCode?e.keyCode:e.which)){e.preventDefault();let n=$(this).val();i.bRender=!0;let l=n.split("\n"),r=i.logs.length;for(let e=r,n=l.length;e "+i.logs.join("\n> ")+"\n> ").scrollTop($("#"+i.pre+"logtext")[0].scrollHeight)}i.bAddLogs=!0}))}async applyCommandLoad(e){let t=this.icn3d,s=t.icn3dui;t.bAddCommands=!1;let i=e.split("|||")[0].replace(/\s\s/g," ").trim();if(-1!==i.indexOf("load")){let e=i.split(" | "),n=e[0];if(e.length>1){let t=e[e.length-1].indexOf(" ");s.cfg.inpara=e[e.length-1].substr(t+1),"undefined"===s.cfg.inpara&&(s.cfg.inpara="")}let l=n.substr(n.lastIndexOf(" ")+1);if(4==l.length&&(l=l.toUpperCase()),t.bInputPNGWithData||t.structures&&t.structures.hasOwnProperty(l))return;if(t.inputid=l,-1!==i.indexOf("load mmtf"))s.cfg.mmtfid=l,await t.mmtfParserCls.downloadMmtf(l);else if(-1!==i.indexOf("load pdb"))s.cfg.pdbid=l,await t.pdbParserCls.downloadPdb(l);else if(-1!==i.indexOf("load af"))s.cfg.afid=l,await t.pdbParserCls.downloadPdb(l,!0);else if(-1!==i.indexOf("load opm"))s.cfg.opmid=l,await t.opmParserCls.downloadOpm(l);else if(-1!==i.indexOf("load mmcif"))s.cfg.mmcifid=l,await t.mmcifParserCls.downloadMmcif(l);else if(-1!==i.indexOf("load mmdb ")||-1!==i.indexOf("load mmdb1 "))s.cfg.mmdbid=l,s.cfg.bu=1,await t.mmdbParserCls.downloadMmdb(l);else if(-1!==i.indexOf("load mmdb0"))s.cfg.mmdbid=l,s.cfg.bu=0,await t.mmdbParserCls.downloadMmdb(l);else if(-1!==i.indexOf("load mmdbaf1"))s.cfg.mmdbafid=l,s.cfg.bu=1,await t.chainalignParserCls.downloadMmdbAf(l);else if(-1!==i.indexOf("load mmdbaf0"))s.cfg.mmdbafid=l,s.cfg.bu=0,await t.chainalignParserCls.downloadMmdbAf(l);else if(-1!==i.indexOf("load gi"))s.cfg.gi=l,await t.mmdbParserCls.downloadGi(l);else if(-1!==i.indexOf("load refseq"))s.cfg.refseqid=l,await t.mmdbParserCls.downloadRefseq(l);else if(-1!==i.indexOf("load protein"))s.cfg.protein=l,await t.mmdbParserCls.downloadProteinname(l);else if(-1!==i.indexOf("load seq_struct_ids "))t.bSmithwm=!1,t.bLocalSmithwm=!1,await t.mmdbParserCls.downloadBlast_rep_id(l);else if(-1!==i.indexOf("load seq_struct_ids_smithwm "))t.bSmithwm=!0,await t.mmdbParserCls.downloadBlast_rep_id(l);else if(-1!==i.indexOf("load seq_struct_ids_local_smithwm "))t.bLocalSmithwm=!0,await t.mmdbParserCls.downloadBlast_rep_id(l);else if(-1!==i.indexOf("load cid"))s.cfg.cid=l,await t.sdfParserCls.downloadCid(l);else if(-1!==i.indexOf("load alignment"))if(s.cfg.align=l,s.cfg.inpara||-1==s.cfg.inpara.indexOf("atype=2"))await t.alignParserCls.downloadAlignment(s.cfg.align);else{let e=2;await t.chainalignParserCls.downloadMmdbAf(s.cfg.align,void 0,e)}else if(-1!==i.indexOf("load chainalignment")){let e=i.split(" | ");e.length>1&&-1!=e[1].indexOf("resnum")&&(s.cfg.resnum=e[1].substr(e[1].indexOf("resnum")+7)),e.length>2&&-1!=e[2].indexOf("resdef")&&(s.cfg.resdef=e[2].substr(e[1].indexOf("resdef")+7)),e.length>3&&-1!=e[3].indexOf("aligntool")&&(s.cfg.aligntool=e[3].substr(e[1].indexOf("aligntool")+10)),s.cfg.chainalign=l,await t.chainalignParserCls.downloadChainalignment(l,s.cfg.resnum,s.cfg.resdef)}else if(-1!==i.indexOf("load url")){let i=e[1],n=void 0!==i?i.indexOf("type "):-1,r="pdb";-1!==n&&(r=i.substr(n+5)),s.cfg.url=l,await t.pdbParserCls.downloadUrl(l,r)}}t.bAddCommands=!0}async applyCommandMap(e){let t=this.icn3d;t.icn3dui;let s=e.split(" | "),i=s[0].substr(8).split(" ");if(3==i.length&&"sigma"==i[1]){let e=i[2],n=i[0];2==s.length?await t.dsn6ParserCls.dsn6ParserBase(s[1],n,e):await t.dsn6ParserCls.dsn6Parser(t.inputid,n,e)}}async applyCommandEmmap(e){let t=this.icn3d;t.icn3dui;let s=e.substr(10).split(" ");if(2==s.length&&"percentage"==s[0]){let e=s[1],i="em";await t.densityCifParserCls.densityCifParser(t.inputid,i,e,t.emd)}}async applyCommandRealign(e){let t=this.icn3d;t.icn3dui,await t.realignParserCls.realignOnSeqAlign()}async applyCommandRealignByStruct(e){let t=this.icn3d;t.icn3dui,t.drawCls.draw(),await t.realignParserCls.realignOnStructAlign()}async applyCommandAfmap(e,t){let s=this.icn3d;s.icn3dui;let i=e.substr(e.lastIndexOf(" ")+1);await s.contactMapCls.afErrorMap(i,t)}async applyCommandGraphinteraction(e){let t=this.icn3d;t.icn3dui;let s=e.split(" | ");if(s.length>=3){let e,i=s[1].split(" "),n=i[0].split(","),l=i[1].split(","),r=-1!==s[2].indexOf("hbonds"),o=-1!==s[2].indexOf("salt bridge"),a=-1!==s[2].indexOf("interactions"),d=-1!==s[2].indexOf("halogen"),c=-1!==s[2].indexOf("pi-cation"),h=-1!==s[2].indexOf("pi-stacking");s.length>=4&&(e="true"==s[3]),t.applyCommandCls.setStrengthPara(s),await t.viewInterPairsCls.viewInteractionPairs(n,l,e,"graph",r,o,a,d,c,h)}}async applyCommandCartoon2d(e){let t=this.icn3d;t.icn3dui;let s=e.substr(e.lastIndexOf(" ")+1);await t.cartoon2dCls.draw2Dcartoon(s)}async applyCommandAnnotationsAndCddSite(e){let t=this.icn3d;t.icn3dui,"view annotations"==e&&await t.showAnnoCls.showAnnotations()}async applyCommandClinvar(e){let t=this.icn3d;t.icn3dui;let s=e.lastIndexOf(" ");e.substr(s+1),await t.annotationCls.setAnnoTabClinvar()}async applyCommandSnp(e){let t=this.icn3d;t.icn3dui;let s=e.lastIndexOf(" ");e.substr(s+1),await t.annotationCls.setAnnoTabSnp()}async applyCommandPTM(e){let t=this.icn3d;t.icn3dui;let s=e.lastIndexOf(" ");e.substr(s+1),await t.annotationCls.setAnnoTabPTM()}applyCommand3ddomain(e){let t=this.icn3d;t.icn3dui;let s=e.lastIndexOf(" "),i=e.substr(s+1);"3ddomain"!=i&&"all"!=i||t.annotationCls.setAnnoTab3ddomain()}async applyCommandViewinteraction(e){let t=this.icn3d,s=t.icn3dui;if(void 0!==s.cfg.align||void 0!==s.cfg.chainalign){let e=Object.keys(t.structures);await t.ParserUtilsCls.set2DDiagramsForAlign(e[0].toUpperCase(),e[1].toUpperCase())}}async renderFinalStep(e){let t=this.icn3d,s=t.icn3dui;t.bCommandLoad=!1,t.ParserUtilsCls.hideLoading(),e+1===t.commands.length&&(t.bAddCommands=!0),t.bRender=!0;let i=t.commands[e-1]?t.commands[e-1].split("|||"):[];if(2==i.length){let e=JSON.parse(i[1]);t._zoomFactor=e.factor,t.mouseChange.x=e.mouseChange.x,t.mouseChange.y=e.mouseChange.y,t.quaternion._x=e.quaternion._x,t.quaternion._y=e.quaternion._y,t.quaternion._z=e.quaternion._z,t.quaternion._w=e.quaternion._w}if(t.selectionCls.oneStructurePerWindow(),1===e||t.hAtoms&&t.atoms&&Object.keys(t.hAtoms).length===Object.keys(t.atoms).length||void 0!==t.optsHistory[e-1]&&t.optsHistory[e-1].hasOwnProperty("hlatomcount")&&t.optsHistory[e-1].hlatomcount===Object.keys(t.atoms).length)if(t.optsHistory.length>=e){let s=t.optsHistory[e-1].pk;"no"===s?t.pk=0:"atom"===s?t.pk=1:"residue"===s?t.pk=2:"strand"===s&&(t.pk=3),t.hlUpdateCls.updateHlAll(),t.drawCls.draw()}else t.hlUpdateCls.updateHlAll(),t.drawCls.draw();else t.hlUpdateCls.updateHlAll(),t.drawCls.draw();(s.cfg.closepopup||s.cfg.imageonly)&&(setTimeout((function(){t.resizeCanvasCls.closeDialogs()}),100),t.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,s.htmlCls.HEIGHT,!0)),t.bTransparentSurface&&t.bRender&&t.drawCls.render(),s.cfg.imageonly&&t.saveFileCls.saveFile(void 0,"png",void 0,!0)}async replayFirstStep(e){let t=this.icn3d,s=t.icn3dui;t.reinitAfterLoad(),await this.execCommandsBase(e,e,t.STATENUMBER);let i=t.commands[e],n=t.commands[e].indexOf("|");-1!=n&&(i=t.commands[e].substr(0,n));let l=i.length>20?i.substr(0,20)+"...":i,r=t.applyCommandCls.getMenuFromCmd(i);$("#"+t.pre+"replay_cmd").html("Cmd: "+l),$("#"+t.pre+"replay_menu").html("Menu: "+r),s.htmlCls.clickMenuCls.setLogCmd(i,!0),t.bCommandLoad=!1,t.ParserUtilsCls.hideLoading(),t.bRender=!0,t.drawCls.draw()}getHAtoms(e){let t=this.icn3d;t.icn3dui;let s=e.split("|||")[0].trim().split(" | ");if(2==s.length){let e=s[1].split(",");t.hAtoms=t.definedSetsCls.getAtomsFromNameArray(e)}}}class cs{constructor(e){this.icn3d=e}async selectByCommand(e,t,s){let i=this.icn3d,n=i.icn3dui;if(0===e.indexOf("saved atoms")){let s=12,n=e.substr(s);i.definedSetsCls.selectCombinedSets(n,t)}else{let l=e.replace(/ AND /g," and ").replace(/ OR /g," or ").replace(/ or and /g," and ").replace(/ and /g," or and ").replace(/ or not /g," not ").replace(/ not /g," or not "),r=("select"===l.trim().substr(0,6)?l.trim().substr(7):l.trim()).split(" or "),o={};for(let e=0,t=r.length;e1||1==o.length&&"*"!==o[0])&&(h=!1);let C,y,v,_,w=[],S=[];if(w="*"===t?Object.keys(l.structures):t.split(","),"*"===s){let e=Object.keys(l.chains);for(let t=0,s=e.length;t1&&"3"===x[t][0]&&isNaN(x[t][1])&&"-"!==x[t][0]){i=x[t].toUpperCase().substr(1),m=!0}else if(""===x[t]||isNaN(parseInt(x[t]))){if("*"===x[t])h=!0;else if("proteins"!==x[t]&&"nucleotides"!==x[t]&&"chemicals"!==x[t]&&"ions"!==x[t]&&"water"!==x[t]&&"anchors"!==x[t]&&"strands"!==x[t]&&"loops"!==x[t]){s=x[t].toUpperCase(),p=!0}}else v=x[t],_=v,n=!0;for(let a=0,u=S.length;a1?e.substr(0,l-1)===n.atoms[i].name.substr(0,l-1)&&(0===s?t[i]=1:t.hasOwnProperty(i)||delete t[i]):"*"!==e&&e!==n.atoms[i].name||(0===s?t[i]=1:t.hasOwnProperty(i)||delete t[i]),t}}class hs{constructor(e){this.icn3d=e}selectAll(){let e=this.icn3d;e.icn3dui,this.selectAll_base(),e.hlObjectsCls.removeHlObjects(),e.hlUpdateCls.removeHl2D(),e.hlUpdateCls.removeHlMenus(),e.bSelectResidue=!1,e.bSelectAlignResidue=!1,e.hlUpdateCls.removeSeqResidueBkgd(),e.hlUpdateCls.update2DdgmContent(),$("#"+e.pre+"dl_annotations > .icn3d-annotation").show(),e.definedSetsCls.setMode("all"),e.saveFileCls.showTitle()}selectAll_base(){let e=this.icn3d,t=e.icn3dui;e.hAtoms={},e.dAtoms={};for(let s in e.chains)e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.chains[s]);e.dAtoms=t.hashUtilsCls.cloneHash(e.hAtoms),e.viewSelectionAtoms=t.hashUtilsCls.cloneHash(e.hAtoms),e.ALTERNATE_STRUCTURE=-1}selectAChain(e,t,s,i){let n=this.icn3d,l=n.icn3dui;t=t.replace(/\s/g,"");let r=void 0!==s||s?"select alignChain "+e:"select chain "+e;void 0!==i&&i?(n.hAtoms=l.hashUtilsCls.unionHash(n.hAtoms,n.chains[e]),void 0===n.nameArray&&(n.nameArray=[])):(n.hAtoms={},n.nameArray=[]),n.nameArray.push(e);let o,a=s?n.alnChainsSeq[e]:n.chainsSeq[e];o=void 0===a?0:a.length;let d={};for(let t=0,s=o;t0){if(void 0!==i&&i?void 0===r.nameArray&&(r.nameArray=[]):(r.hAtoms={},r.nameArray=[]),l)for(let t in e)r.hAtoms[t]=1;else for(let t in e)for(let e in r.residues[t])r.hAtoms[e]=1;let o,a;t=t.replace(/\s/g,""),r.nameArray.push(t),l?(o="select "+r.resid2specCls.atoms2spec(r.hAtoms),a=!1):(o="select "+r.resid2specCls.residueids2spec(Object.keys(e)),a=!0);let d=Object.keys(e);this.addCustomSelection(d,t,s,o,a),(void 0===n||n)&&r.hlUpdateCls.updateHlAll(r.nameArray,void 0,i)}}selectMainChains(){let e=this.icn3d,t=e.icn3dui.hashUtilsCls.cloneHash(e.hAtoms);e.hAtoms=e.applyDisplayCls.selectMainChainSubset(t),e.hlUpdateCls.showHighlight()}selectSideChains(){let e=this.icn3d,t=e.icn3dui,s=t.hashUtilsCls.cloneHash(e.hAtoms);e.hAtoms={};for(let i in s)(e.proteins.hasOwnProperty(i)&&"N"!==e.atoms[i].name&&"H"!==e.atoms[i].name&&"C"!==e.atoms[i].name&&"O"!==e.atoms[i].name&&("CA"!==e.atoms[i].name||"C"!==e.atoms[i].elem)&&"HA"!==e.atoms[i].name||e.nucleotides.hasOwnProperty(i)&&-1===t.parasCls.nuclMainArray.indexOf(e.atoms[i].name))&&(e.hAtoms[i]=1);e.hlUpdateCls.showHighlight()}selectMainSideChains(){let e=this.icn3d,t=e.icn3dui,s=e.firstAtomObjCls.getResiduesFromAtoms(e.hAtoms);e.hAtoms={};for(let i in s)e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.residues[i]),e.dAtoms=t.hashUtilsCls.unionHash(e.dAtoms,e.residues[i]);e.drawCls.draw(),e.hlUpdateCls.showHighlight()}clickShow_selected(){let e=this.icn3d,t=e.icn3dui,s=this;t.myEventCls.onIds(["#"+e.pre+"show_selected","#"+e.pre+"mn2_show_selected"],"click",(function(e){s.icn3d,s.showSelection(),t.htmlCls.clickMenuCls.setLogCmd("show selection",!0)}))}clickHide_selected(){let e=this.icn3d,t=e.icn3dui,s=this;t.myEventCls.onIds("#"+e.pre+"mn2_hide_selected","click",(function(e){s.icn3d,s.hideSelection(),t.htmlCls.clickMenuCls.setLogCmd("hide selection",!0)}))}getGraphDataForDisplayed(){let e=this.icn3d;e.icn3dui;let t=JSON.parse(e.graphStr),s=e.firstAtomObjCls.getResiduesFromAtoms(e.dAtoms),i=[],n=[],l={};for(let e=0,n=t.nodes.length;e0)if(1==s.pk){let n=!0;this.selectResidueList(s.hAtoms,e,t,void 0,void 0,n),this.updateSelectionNameDesc(),i.htmlCls.clickMenuCls.setLogCmd("select "+s.resid2specCls.atoms2spec(s.hAtoms)+" | name "+e,!0)}else this.selectResidueList(s.selectedResidues,e,t),this.updateSelectionNameDesc(),i.htmlCls.clickMenuCls.setLogCmd("select "+s.resid2specCls.residueids2spec(Object.keys(s.selectedResidues))+" | name "+e,!0)}saveSelInCommand(){let e=this.icn3d,t=e.icn3dui;e.selectedResidues=e.firstAtomObjCls.getResiduesFromCalphaAtoms(e.hAtoms),t.htmlCls.clickMenuCls.setLogCmd("select "+e.resid2specCls.residueids2spec(Object.keys(e.selectedResidues)),!0)}saveEachResiInSel(){let e=this.icn3d;e.icn3dui,e.selectionCls.saveSelectionPrep(),e.selectedResidues={},e.selectedResidues=e.firstAtomObjCls.getResiduesFromCalphaAtoms(e.hAtoms);for(let t in e.selectedResidues){let s={};s[t]=1;let i=t+"_"+e.selectedResidues[t];this.selectResidueList(s,i,i)}}removeSelection(){let e=this.icn3d;e.icn3dui,e.bAnnotations||e.hlUpdateCls.removeSeqChainBkgd(),e.bCtrl||e.bShift||(e.hlUpdateCls.removeSeqResidueBkgd(),e.hlUpdateCls.removeSeqChainBkgd()),e.selectedResidues={},e.bSelectResidue=!1,e.hAtoms={},e.hlObjectsCls.removeHlObjects(),e.hlUpdateCls.removeHl2D()}resetAll(){let e=this.icn3d,t=e.icn3dui;e.maxD=e.oriMaxD,e.center=e.oriCenter.clone(),e.opts=t.hashUtilsCls.cloneHash(e.optsOri),e.setOptionCls.setStyle("sidec","nothing"),e.reinitAfterLoad(),e.definedSetsCls.setMode("all"),e.selectionCls.selectAll(),t.htmlCls.clickMenuCls.setLogCmd("reset",!0),e.hlUpdateCls.removeSeqChainBkgd(),e.hlUpdateCls.removeSeqResidueBkgd(),e.hlUpdateCls.removeHl2D(),e.hlUpdateCls.removeHlMenus(),e.loadScriptCls.renderFinalStep(1)}async loadSelection(e){let t=this.icn3d,s=t.icn3dui,i=e.trim().split("\n");for(let e=0,n=i.length;e=t&&l.coord.z<=e)){i[l.structure+"_"+l.chain+"_"+l.resi]=1}}let n="z_planes_"+e+"_"+t,l=n;this.selectResidueList(i,n,l,!1)}}class ps{constructor(e){this.icn3d=e}residueids2spec(e){var t=this.icn3d;t.icn3dui;let s="";if(void 0!==e){let i,n,l,r,o,a,d,c=e.sort((function(e,t){if(""!==e&&!isNaN(e))return parseInt(e)-parseInt(t);{let s=e.lastIndexOf("_"),i=t.lastIndexOf("_");if(e.substr(0,s)t.substr(0,i))return 1;if(e.substr(0,s)==t.substr(0,i)){if(parseInt(e.substr(s+1))parseInt(t.substr(i+1)))return 1;if(parseInt(e.substr(s+1))==parseInt(t.substr(i+1)))return 0}}})),h="",p=0,m=1!=Object.keys(t.structures).length;for(let e=0,u=c.length;e0&&(s+=p===d?m?"$"+o+"."+a+":"+d+" or ":"."+a+":"+d+" or ":m?"$"+o+"."+a+":"+d+"-"+p+" or ":"."+a+":"+d+"-"+p+" or "),d=n;else if(h===i){let e=t.ParserUtilsCls.getResiNCBI(h,p);t.ParserUtilsCls.getResiNCBI(i,n)!=e+1&&(s+=p===d?m?"$"+o+"."+a+":"+d+" or ":"."+a+":"+d+" or ":m?"$"+o+"."+a+":"+d+"-"+p+" or ":"."+a+":"+d+"-"+p+" or ",d=n)}h=i,p=n}}r=h.indexOf("_"),o=h.substr(0,r),a=h.substr(r+1),s+=p===d?m?"$"+o+"."+a+":"+d:"."+a+":"+d:m?"$"+o+"."+a+":"+d+"-"+p:"."+a+":"+d+"-"+p}return s}atoms2spec(e){var t=this.icn3d;t.icn3dui;let s,i="",n=0,l={},r={},o={};for(let a in e)s=t.atoms[a],n>0&&(i+=" or "),i+="$"+s.structure+"."+s.chain+":"+s.resi+"@"+s.name,l[s.structure]=1,r[s.structure+"_"+s.chain]=1,o[s.structure+"_"+s.chain+"_"+s.resi]=1,++n;if(1==Object.keys(o).length){let e="\\$"+s.structure+"\\."+s.chain+":"+s.resi;i=i.replace(new RegExp(e,"g"),"")}else if(1==Object.keys(r).length){let e="\\$"+s.structure+"\\."+s.chain;i=i.replace(new RegExp(e,"g"),"")}else if(1==Object.keys(l).length){let e="\\$"+s.structure;i=i.replace(new RegExp(e,"g"),"")}return i}atoms2residues(e){var t=this.icn3d;t.icn3dui;let s={};for(let t=0,i=e.length;t=parseInt(t)&&e.b<=parseInt(s)&&(i.hAtoms=n.hashUtilsCls.unionHash(i.hAtoms,i.residues[e.structure+"_"+e.chain+"_"+e.resi]))}}else if("percent out"==e){i.bCalcArea=!0,i.opts.surface="solvent accessible surface",i.applyMapCls.applySurfaceOptions(),i.bCalcArea=!1,i.hAtoms={};for(let e in i.resid2area){let l=e.lastIndexOf("_"),r=e.substr(l+1);if(n.parasCls.residueArea.hasOwnProperty(r)){let o=parseInt(i.resid2area[e]/n.parasCls.residueArea[r]*100);if(o>=t&&o<=s){let t=e.substr(0,l);i.hAtoms=n.hashUtilsCls.unionHash(i.hAtoms,i.residues[t])}}}}i.hAtoms=n.hashUtilsCls.intHash(i.hAtoms,l),i.drawCls.draw(),i.hlUpdateCls.updateHlAll()}selectComplement(){let e=this.icn3d,t=e.icn3dui,s={};for(let t in e.atoms)e.hAtoms.hasOwnProperty(t)||(s[t]=1);e.hAtoms=t.hashUtilsCls.cloneHash(s),e.hlUpdateCls.updateHlAll()}switchHighlightLevel(){var e=this.icn3d.icn3dui;if(e.bNode)return;let t=this;document.addEventListener("keydown",(function(s){let i=t.icn3d;38===s.keyCode?(s.preventDefault(),0!=Object.keys(i.pickedAtomList).length&&i.hAtoms.hasOwnProperty(i.firstAtomObjCls.getFirstAtomObj(i.pickedAtomList).serial)||(i.pickedAtomList=e.hashUtilsCls.cloneHash(i.hAtoms)),t.switchHighlightLevelUp(),e.htmlCls.clickMenuCls.setLogCmd("highlight level up",!0)):40===s.keyCode&&(s.preventDefault(),0!=Object.keys(i.pickedAtomList).length&&i.hAtoms.hasOwnProperty(i.firstAtomObjCls.getFirstAtomObj(i.pickedAtomList).serial)||(i.pickedAtomList=e.hashUtilsCls.cloneHash(i.hAtoms)),t.switchHighlightLevelDown(),e.htmlCls.clickMenuCls.setLogCmd("highlight level down",!0))}))}switchHighlightLevelUp(){var e=this.icn3d,t=e.icn3dui;if(!t.bNode){if(e.bShift||e.bCtrl||e.hlObjectsCls.removeHlObjects(),void 0!==e.pickedAtomList&&0!==Object.keys(e.pickedAtomList).length||(e.pickedAtomList=t.hashUtilsCls.cloneHash(e.hAtoms)),0===Object.keys(e.pickedAtomList).length&&(e.pickedAtomList=e.dAtoms),1===e.highlightlevel){e.highlightlevel=2;let s=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);e.bShift||e.bCtrl?e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.residues[s.structure+"_"+s.chain+"_"+s.resi]):e.hAtoms=t.hashUtilsCls.cloneHash(e.residues[s.structure+"_"+s.chain+"_"+s.resi])}else if(2===e.highlightlevel){e.highlightlevel=3;let s=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);e.bShift||e.bCtrl?e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.pickingCls.selectStrandHelixFromAtom(s)):e.hAtoms=t.hashUtilsCls.cloneHash(e.pickingCls.selectStrandHelixFromAtom(s))}else if(3===e.highlightlevel){let s;if(void 0!==t.cfg.mmdbid||void 0!==t.cfg.gi){e.highlightlevel=4;let i=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);s=e.pickingCls.select3ddomainFromAtom(i),e.bShift||e.bCtrl?e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,s):e.hAtoms=t.hashUtilsCls.cloneHash(s)}if(void 0===t.cfg.mmdbid&&void 0===t.cfg.gi||0==Object.keys(s).length){e.highlightlevel=5;let s=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);e.bShift||e.bCtrl?e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.chains[s.structure+"_"+s.chain]):e.hAtoms=t.hashUtilsCls.cloneHash(e.chains[s.structure+"_"+s.chain])}}else if(4===e.highlightlevel){e.highlightlevel=5;let s=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);e.bShift||e.bCtrl?e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.chains[s.structure+"_"+s.chain]):e.hAtoms=t.hashUtilsCls.cloneHash(e.chains[s.structure+"_"+s.chain])}else if(5===e.highlightlevel||6===e.highlightlevel){e.highlightlevel=6;let s=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);e.bShift||e.bCtrl||(e.hAtoms={});let i=e.structures[s.structure];for(let s=0,n=i.length;s3e4)return void(e?console.log("The maximum number of allowed atoms is 30,000. Please try it again with selected chains..."):alert("The maximum number of allowed atoms is 30,000. Please try it again with selected chains..."));let o="";return o+=s.cfg.cid?t.saveFileCls.getAtomPDB(n,!0,void 0,void 0,void 0,void 0,true):t.saveFileCls.getAtomPDB(n,void 0,void 0,void 0,void 0,void 0,true),o+=t.saveFileCls.getAtomPDB(i,!0,void 0,!0),o}async CalcPhi(e,t,s,i,n){let l=this.icn3d;l.icn3dui;let r=await this.CalcPhiPrms(e,t,s,i,n);this.loadPhiData(r,s,i),l.bAjaxPhi=!0,i?l.setOptionCls.setOption("phisurface","phi"):l.setOptionCls.setOption("phimap","phi")}CalcPhiPrms(e,t,s,i,n){let l=this.icn3d,r=l.icn3dui;l.loadPhiFrom="delphi";let o=r.htmlCls.baseUrl+"delphi/delphi.cgi",a=r.cfg.cid?r.cfg.cid:Object.keys(l.structures).toString(),d={};if(n)d={pqr2phi:n,gsize:e,salt:t,pdbid:a};else{let s=this.getPdbStr();d={pdb2phi:s,gsize:e,salt:t,pdbid:a}}return new Promise((function(e,t){$.ajax({url:o,type:"POST",data:d,dataType:"binary",responseType:"arraybuffer",cache:!0,beforeSend:function(){l.ParserUtilsCls.showLoading()},complete:function(){l.ParserUtilsCls.hideLoading()},success:function(t){e(t)},error:function(e,t,s){}})}))}async PhiParser(e,t,s,i){let n,l=this.icn3d,r=l.icn3dui,o=this;n="phiurl"==t||"phiurl2"==t?"arraybuffer":"text";let a=await r.getXMLHttpRqstPromise(e,"GET",n,"potential");"phiurl"==t||"phiurl2"==t?o.loadPhiData(a,s,i):o.loadCubeData(a,s,i),l.bAjaxPhi=!0,i?l.setOptionCls.setOption("phisurface","phi"):l.setOptionCls.setOption("phimap","phi")}loadPhiData(e,t,s){let i=this.icn3d;i.icn3dui;let n={filetype:"phi"},l=e.buffer&&e.buffer instanceof ArrayBuffer?e.buffer:e,r=new Float32Array(l.slice(l.byteLength-24,l.byteLength-8));n.scale=r[0];let o=r[1],a=r[2],d=r[3];n.n=new Int32Array(l.slice(l.byteLength-8,l.byteLength-4)),n.xExtent=n.yExtent=n.zExtent=n.n;let c=1/n.scale*((n.n-1)/2);n.ori=new THREE.Vector3(o-c,a-c,d-c);let h=new Float32Array(l.slice(110,l.byteLength-56));n.bSurface=s,i.mapData.headerPhi=n,i.mapData.dataPhi=h,i.mapData.contourPhi=t;let p=new THREE.Matrix4;p.identity(),p.multiply((new THREE.Matrix4).makeTranslation(n.ori.x,n.ori.y,n.ori.z)),i.mapData.matrixPhi=p}loadCubeData(e,t,s){let i=this.icn3d;i.icn3dui;let n={filetype:"cube"},l=e.split("\n"),r=[];r.push(parseFloat(l[0].substr(0,10))),r.push(parseFloat(l[0].substr(10,6))),r.push(parseFloat(l[0].substr(16,10))),r.push(parseFloat(l[0].substr(26,10))),r.push(parseFloat(l[0].substr(36,10))),n.scale=r[0];let o=r[2],a=r[3],d=r[4];n.n=r[1],n.xExtent=n.yExtent=n.zExtent=n.n;let c=1/n.scale*((n.n-1)/2);n.ori=new THREE.Vector3(o-c,a-c,d-c);let h=[];for(let e=7,t=l.length;e1e4)return void alert("The maximum number of allowed atoms is 10,000. Please try it again with smaller sets...");let o="";o+=e.saveFileCls.getAtomPDB(n);let a,d={pdb:o,pdbid:Object.keys(e.structures).toString()};try{a=await t.getAjaxPostPromise(i,d,!0);let n,l,o,c=a.rcsb_struct_symmetry,h="none";if(void 0!==c){let i;void 0!==e.rmsd_supr&&void 0!==e.rmsd_supr.rot&&(n=e.rmsd_supr.rot,l=e.rmsd_supr.trans1,o=e.rmsd_supr.trans2),void 0===e.symdArray&&(e.symdArray=[]);for(let t=0,n=c.length;tThe selected residues have no detected symmetry with a Z score of "+a.zscore+" from the program SymD."),t.htmlCls.dialogCls.openDlg("dl_symd","Dynamically Calculated Symmetry Using SymD");else{let n=a.seqalign.replace(/ /g,"").split(","),l=a.nres,o=a.shift,d=a.rmsd,h=Object.keys(r),p={},m={},u=[],g=[],f=0,b=0,C={};for(let e=0,s=n[0].length;et&&(t=C[s].length,e=s);let s=Object.keys(p),i=Object.keys(m);for(let t=0,n=C[e].length;tSymD. The Z score "+a.zscore+" is greater than the threshold Z score 8. The RMSD is "+d+' angstrom.

    The following sequence alignment shows the residue mapping of the best aligned sets: "symOri" and "symPerm", which are also available in the menu "Analysis > Defined Sets".
    ',$("#"+e.pre+"symd_info").html(A),s.setSeqAlignForSymmetry(_,w,S);let x=!1,k=t.htmlCls.alignSeqCls.getAlignSequencesAnnotations(Object.keys(e.alnChains),void 0,void 0,x,S);A=$("#"+e.pre+"dl_sequence2").html()+k.sequencesHtml,$("#"+e.pre+"dl_sequence2").html(A),$("#"+e.pre+"dl_sequence2").width(t.htmlCls.RESIDUE_WIDTH*k.maxSeqCnt+200),t.htmlCls.dialogCls.openDlg("dl_alignment","Select residues in aligned sequences from SymD");let O=Object.keys(e.defNames2Residues).length+Object.keys(e.defNames2Atoms).length,R="symOri"+O;e.selectionCls.selectResidueList(y,R,R),e.selectionCls.updateSelectionNameDesc(),t.htmlCls.clickMenuCls.setLogCmd("select "+e.resid2specCls.residueids2spec(Object.keys(y))+" | name "+R,!1),R="symPerm"+O,e.selectionCls.selectResidueList(v,R,R),e.selectionCls.updateSelectionNameDesc(),t.htmlCls.clickMenuCls.setLogCmd("select "+e.resid2specCls.residueids2spec(Object.keys(v))+" | name "+R,!1),R="symBoth"+O,y=t.hashUtilsCls.unionHash(y,v),e.selectionCls.selectResidueList(y,R,R),e.selectionCls.updateSelectionNameDesc(),t.htmlCls.clickMenuCls.setLogCmd("select "+e.resid2specCls.residueids2spec(Object.keys(y))+" | name "+R,!1)}}else $("#"+e.pre+"dl_symd").html("
    The selected residues have no detected symmetry with a Z score of "+a.zscore+" from the program SymD."),t.htmlCls.dialogCls.openDlg("dl_symd","Dynamically Calculated Symmetry Using SymD");e.symdtitle="none"===h?void 0:h,e.drawCls.draw()}catch(s){return $("#"+e.pre+"dl_symd").html("
    The web service can not determine the symmetry of the input set."),t.htmlCls.dialogCls.openDlg("dl_symd","Dynamically Calculated Symmetry Using SymD"),void e.ParserUtilsCls.hideLoading()}}getResObj(e){this.icn3d.icn3dui;let t=e.substr(0,e.indexOf(" ")),s=e.indexOf("$"),i=e.indexOf("."),n=e.indexOf(":"),l=e.substr(s+1,i-s-1),r=e.substr(i+1,n-i-1),o=e.substr(n+1);return{resn:t,resid:l+"_"+r+"_"+o,resi:o,aligned:!0}}setSeqAlignForSymmetry(e,t,s){let i=this.icn3d,n=i.icn3dui;i.conservedName1="symOri_cons",i.conservedName2="symPerm_cons",i.consHash1={},i.consHash2={},i.alnChainsAnTtl={},i.alnChainsAnno={},i.alnChainsSeq={},i.alnChains={},i.alnChainsSeq={};let l={};for(let r=0,o=e.length;rThis structure has no symmetry."),void i.htmlCls.dialogCls.openDlg("dl_symmetry","Symmetry")}let r,o,a,d=t.rcsb_struct_symmetry;if(void 0!==d){void 0!==s.rmsd_supr&&void 0!==s.rmsd_supr.rot&&(r=s.rmsd_supr.rot,o=s.rmsd_supr.trans1,a=s.rmsd_supr.trans2),s.symmetryHash={};for(let e=0,t=d.length;eThis structure has no symmetry.");else{let e="",t=0;for(let i in s.symmetryHash){e+="",++t}$("#"+s.pre+"selectSymmetry").html(e)}}else $("#"+s.pre+"dl_symmetry").html("
    This structure has no symmetry.");i.htmlCls.dialogCls.openDlg("dl_symmetry","Symmetry")}getPolygonColor(e){let t=this.icn3d.icn3dui,s=e.substr(0,1);return"C"==s?t.parasCls.thr(16747520):"D"==s?t.parasCls.thr(65535):"T"==s?t.parasCls.thr(15631086):"O"==s?t.parasCls.thr(16753920):"I"==s?t.parasCls.thr(65280):t.parasCls.thr(11119017)}getAxisColor(e,t){let s=this.icn3d.icn3dui,i=e.substr(0,1);return"C"==i?s.parasCls.thr(16711680):"D"==i?2==t?s.parasCls.thr(65535):s.parasCls.thr(16711680):"T"==i?2==t?s.parasCls.thr(65535):s.parasCls.thr(65280):"O"==i||"I"==i?2==t?s.parasCls.thr(65535):3==t?s.parasCls.thr(65280):s.parasCls.thr(16711680):s.parasCls.thr(16711680)}}class Cs{constructor(e){this.icn3d=e}alignSW(e,t,s,i,n,l,r){this.icn3d.icn3dui;let o=this.bsa_align(r,e,t,[s,i],[n,l]),a="score: "+o[0]+"\n";a+="start: "+o[1]+"\n",a+="cigar: "+this.bsa_cigar2str(o[2])+"\n\n",a+="alignment:\n\n";let d=this.bsa_cigar2gaps(e,t,o[1],o[2]),c={};return c.score=o[0],c.start=o[1],c.cigar=this.bsa_cigar2str(o[2]),c.target=d[0],c.query=d[1],c}bsg_enc_seq(e,t){if(this.icn3d.icn3dui,null==t)return null;let s=[];s.length=e.length;for(let i=0;i0&&(s=-s),i=0;i=2&&"number"==typeof t[0]&&"number"==typeof t[1]){if(null==s)return null;let e="number"==typeof s?s:s[s.length-1]+1;i=this.bsa_gen_score_matrix(e,t[0],t[1])}else i=t;for(let e=0;eo.length?d:o.length;l=null==l||l<0?c:l;let h,p,m=o.target>d?o.target-d:d-o.target;l=l>m?l:m,"number"==typeof n?(h=0,p=n>0?n:-n):(h=n[0]>0?n[0]:-n[0],p=n[1]>0?n[1]:-n[1]);let u,g=h+p,f=-1073741824,b=[],C=[],y=[],v=0,_=-1,w=-1;if(e)for(let e=0;e<=d;++e)b[e]=C[e]=0;else{b[0]=0,C[0]=-g-g;for(let e=1;e<=d;++e)e>=l?b[e]=C[e]=f:(b[e]=-(g+p*(e-1)),C[e]=-(g+g+p*e))}for(let t=0;tl?t-l:0,u=t+l+10?f:-(g+p*t),n=m>0?f:-(g+g+p*t));for(let t=m;t=o?0:1,a=a>=o?a:o,l=a>=n?l:2,a=a>=n?a:n,l=!e||a>0?l:64,i=a,c=r>a?c:t,r=r>a?r:a,a-=g,a=!e||a>0?a:0,o-=p,l|=o>a?4:0,o=o>a?o:a,C[t]=o,n-=p,l|=n>a?32:0,n=n>a?n:a,s[t]=l}b[u]=i,C[u]=e?0:f,r>v&&(v=r,_=t,w=c)}if(e&&0==v)return null;u=e?v:b[d];let S,A,x,k=[],O=0,R=0;for(e?(A=_,x=w,w!=d-1&&this.push_cigar(k,4,d-1-w)):(A=o.length-1,x=(A+l+1=0&&x>=0&&(S=y[A][x-(A>l?A-l:0)],O=S>>(O<<1)&3,!(0==O&&S>>6));)0==O&&(O=3&S),0==O?(this.push_cigar(k,0,1),--A,--x):1==O?(this.push_cigar(k,2,1),--A):(this.push_cigar(k,1,1),--x);e?(x>=0&&this.push_cigar(k,4,x+1),R=A+1):(A>=0&&this.push_cigar(k,2,A+1),x>=0&&this.push_cigar(k,1,x+1));for(let e=0;e>1;++e)S=k[e],k[e]=k[k.length-1-e],k[k.length-1-e]=S;return[u,R,k]}push_cigar(e,t,s){this.icn3d.icn3dui,0==e.length||t!=(15&e[e.length-1])?e.push(s<<4|t):e[e.length-1]+=s<<4}bsa_cigar2gaps(e,t,s,i){this.icn3d.icn3dui;let n="",l="",r="",o=0,a=s;for(let s=0;s>4;0==r?(n+=t.substr(o,d),l+=e.substr(a,d),o+=d,a+=d):1==r?(n+=t.substr(o,d),l+=Array(d+1).join("-"),o+=d):2==r?(n+=Array(d+1).join("-"),l+=e.substr(a,d),a+=d):4==r&&(o+=d)}let d=l.toUpperCase(),c=n.toUpperCase();for(let e=0;e>4).toString()+"MIDNSHP=XB".charAt(15&e[s]));return t.join("")}}class ys{constructor(e){this.icn3d=e}calculateArea(){var e=this.icn3d,t=e.icn3dui;e.bCalcArea=!0,e.opts.surface="solvent accessible surface",e.applyMapCls.applySurfaceOptions(),$("#"+e.pre+"areavalue").val(e.areavalue),$("#"+e.pre+"areatable").html(e.areahtml),t.htmlCls.dialogCls.openDlg("dl_area","Surface area calculation"),e.bCalcArea=!1}calcBuriedSurface(e,t){var s=this.icn3d,i=s.icn3dui;if(0==e.length)alert("Please select the first set");else{let n=i.hashUtilsCls.cloneHash(s.hAtoms),l=s.definedSetsCls.getAtomsFromNameArray(e),r=s.definedSetsCls.getAtomsFromNameArray(t);s.bCalcArea=!0,s.opts.surface="solvent accessible surface",s.hAtoms=i.hashUtilsCls.cloneHash(l),s.applyMapCls.applySurfaceOptions();let o=s.areavalue,a=i.hashUtilsCls.cloneHash(s.resid2area);s.hAtoms=i.hashUtilsCls.cloneHash(r),s.applyMapCls.applySurfaceOptions();let d=s.areavalue,c=i.hashUtilsCls.cloneHash(s.resid2area);s.hAtoms=i.hashUtilsCls.unionHash(s.hAtoms,l),s.applyMapCls.applySurfaceOptions();let h=s.areavalue,p=i.hashUtilsCls.cloneHash(s.resid2area),m=0,u=0,g=0,f=0;for(let e in a)p.hasOwnProperty(e)&&(f+=parseFloat(p[e]));u=(o-f).toFixed(2);for(let e in c)p.hasOwnProperty(e)&&(g+=parseFloat(p[e]));m=(d-g).toFixed(2),s.bCalcArea=!1,s.hAtoms=i.hashUtilsCls.cloneHash(n);let b=(parseFloat(d)+parseFloat(o)-parseFloat(h)).toFixed(2),C="
    Calculate solvent accessible surface area in the interface:

    ";C+="Set 1: "+e+", Surface: "+o+" Å2
    ",C+="Set 2: "+t+", Surface: "+d+" Å2
    ",C+="Total Surface: "+h+" Å2
    ",C+="Buried Surface for Set 1: "+u+" Å2
    ",C+="Buried Surface for Set 2: "+m+" Å2

    ",$("#"+s.pre+"dl_buriedarea_html").html(C),i.htmlCls.dialogCls.openDlg("dl_buriedarea","Buried solvent accessible surface area in the interface"),i.htmlCls.clickMenuCls.setLogCmd("buried surface "+b,!1)}}measureDistTwoSets(e,t){var s=this.icn3d,i=s.icn3dui;if(0==e.length||0==t.length)alert("Please select two sets");else{let n=i.hashUtilsCls.cloneHash(s.hAtoms),l=s.definedSetsCls.getAtomsFromNameArray(e),r=s.definedSetsCls.getAtomsFromNameArray(t),o=s.contactCls.getExtent(l),a=s.contactCls.getExtent(r),d=new THREE.Vector3(o[2][0],o[2][1],o[2][2]),c=new THREE.Vector3(a[2][0],a[2][1],a[2][2]);s.hAtoms=i.hashUtilsCls.cloneHash(n),void 0===s.distPnts&&(s.distPnts=[]),s.distPnts.push(d),s.distPnts.push(c);let h=$("#"+s.pre+"distancecolor2").val();this.addLine(d.x,d.y,d.z,c.x,c.y,c.z,h,!0,"distance");let p=0,m=0,u=d.clone().add(c).multiplyScalar(.5),g=(parseInt(10*d.distanceTo(c))/10).toString()+" A";this.addLabel(g,u.x,u.y,u.z,p,h,m,"distance"),s.drawCls.draw()}}measureDistManySets(e,t){var s=this.icn3d,i=s.icn3dui;if(0==e.length||0==t.length)alert("Please select sets for distance calculation...");else{let n=i.hashUtilsCls.cloneHash(s.hAtoms),l={};for(let i=0,n=e.length;i"+t[e]+" (Å)"}r+="";for(let s=0,i=e.length;s"+i+" (Å)";for(let e=0,s=t.length;e'+l[i][s]+"":r+="0"}r+=""}r+="

    ",$("#"+i.pre+"dl_disttable_html").html(r)}}addLine(e,t,s,i,n,l,r,o,a,d,c){var h=this.icn3d;h.icn3dui;let p={};p.position1=new THREE.Vector3(e,t,s),p.position2=new THREE.Vector3(i,n,l),p.color=r,p.dashed=o,p.radius=d,p.opacity=c,void 0===h.lines[a]&&(h.lines[a]=[]),void 0!==a?h.lines[a].push(p):(void 0===h.lines.custom&&(h.lines.custom=[]),h.lines.custom.push(p)),h.hlObjectsCls.removeHlObjects()}addLineFromPicking(e){var t=this.icn3d,s=t.icn3dui;let i=$("#"+t.pre+e+"color").val();t.pAtom.coord.x,t.pAtom2.coord.x,t.pAtom.coord.y,t.pAtom2.coord.y,t.pAtom.coord.z,t.pAtom2.coord.z;let n="stabilizer"!=e;s.htmlCls.clickMenuCls.setLogCmd("add line | x1 "+t.pAtom.coord.x.toPrecision(4)+" y1 "+t.pAtom.coord.y.toPrecision(4)+" z1 "+t.pAtom.coord.z.toPrecision(4)+" | x2 "+t.pAtom2.coord.x.toPrecision(4)+" y2 "+t.pAtom2.coord.y.toPrecision(4)+" z2 "+t.pAtom2.coord.z.toPrecision(4)+" | color "+i+" | dashed "+n+" | type "+e,!0),this.addLine(t.pAtom.coord.x,t.pAtom.coord.y,t.pAtom.coord.z,t.pAtom2.coord.x,t.pAtom2.coord.y,t.pAtom2.coord.z,i,n,e),t.pickpair=!1}addLabel(e,t,s,i,n,l,r,o){var a=this.icn3d;a.icn3dui;let d={};"0"!==n&&""!==n&&"undefined"!==n||(n=void 0),"0"!==l&&""!==l&&"undefined"!==l||(l=void 0),"0"!==r&&""!==r&&"undefined"!==r||(r=void 0);let c=new THREE.Vector3;c.x=t,c.y=s,c.z=i,d.position=c,d.text=e,d.size=n,d.color=l,d.background=r,void 0===a.labels[o]&&(a.labels[o]=[]),void 0!==o?a.labels[o].push(d):(void 0===a.labels.custom&&(a.labels.custom=[]),a.labels.custom.push(d)),a.hlObjectsCls.removeHlObjects()}addChainLabels(e){var t=this.icn3d;let s=t.icn3dui.hashUtilsCls.intHash(t.hAtoms,e);void 0===t.labels.chain&&(t.labels.chain=[]);let i=t.firstAtomObjCls.getChainsFromAtoms(s);for(let e in i){let s={};s.position=t.applyCenterCls.centerAtoms(t.chains[e]).center;let i=e.indexOf("_"),n=e.substr(i+1),l=t.showSeqCls.getProteinName(e);l.length>20&&(l=l.substr(0,20)+"..."),s.text="Chain "+n+": "+l,s.size=18,t.firstAtomObjCls.getFirstCalphaAtomObj(t.chains[e]).color.getHexString().toUpperCase(),s.color="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd,s.background="#FFFFFF",t.labels.chain.push(s)}t.hlObjectsCls.removeHlObjects()}addTerminiLabels(e){var t=this.icn3d,s=t.icn3dui;let i,n="#FFFFFF";i=s.hashUtilsCls.unionHash(i,t.proteins),i=s.hashUtilsCls.unionHash(i,t.nucleotides);let l=s.hashUtilsCls.intHash(t.dAtoms,i),r=s.hashUtilsCls.intHash(l,e);void 0===t.labels.chain&&(t.labels.chain=[]);let o=t.firstAtomObjCls.getChainsFromAtoms(r);for(let e in o){let i=s.hashUtilsCls.intHash(l,t.chains[e]),r=Object.keys(i),o=t.atoms[r[0]],a=t.atoms[r[r.length-1]],d={},c={};d.position=o.coord,c.position=a.coord,d.text="N-",c.text="C-",t.nucleotides.hasOwnProperty(o.serial)&&(d.text="5'",c.text="3'"),d.size=18,c.size=18,o.color.getHexString().toUpperCase(),a.color.getHexString().toUpperCase(),d.color="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd,c.color="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd,d.background=n,c.background=n,t.labels.chain.push(d),t.labels.chain.push(c)}t.hlObjectsCls.removeHlObjects()}}class vs{constructor(e){this.icn3d=e}draw2Ddgm(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=.667,o={},a={},d={},c={},h={};if(void 0===e)return"";for(let s in e.moleculeInfor){let i="#"+("000000"+e.moleculeInfor[s].color.toString(16)).slice(-6),l=e.moleculeInfor[s].chain.trim();void 0===h[l]?h[l]=1:++h[l];let r=t+"_"+(1===h[l]?l:l+h[l].toString());void 0!==n.mmdbid_q&&(n.mmdbid_q,n.mmdbid_t),o[s]=r,a[s]=i,d[s]=e.moleculeInfor[s].name,c[r]=s}if(void 0===i||!i)for(let s=0,i=e.intracResidues.length;s";p+=""+t.toUpperCase()+"
    ",p+="";let m={},u=[],g="",f="",b={};if(i)for(let e in n.dAtoms){let t=n.atoms[e];b[c[t.structure+"_"+t.chain]]=1}let C=Object.keys(e.moleculeInfor),y=Object.keys(e.intrac),v=[];for(let e=0,t=C.length;e0)for(let t in e.intrac){let s=e.intrac[t];for(let e=0,i=s.intrac.length;e0&&(y="#"+n.atoms[e[0]].color.getHexString().toUpperCase())}let S="";n.bInitial&&void 0!==s&&(void 0!==n.alignmolid2color&&n.alignmolid2color[s].hasOwnProperty(l)?(S=n.alignmolid2color[s][l],y="#FF0000"):y="#FFFFFF");let A=d[l],x=" ",k=" ";if(void 0!==c){let e=c.indexOf("_");k=c.substr(e+1),x=k.length>1?k.substr(0,1)+"..":k}else c="Misc";void 0===y&&(y="#FFFFFF");let O=1;if(n.bInitial&&void 0!==n.alnChains[c]){let e=0;for(let t in n.alnChains[c]){let s=n.atoms[t].color.getHexString().toUpperCase();"FF0000"!==s&&"00FF00"!==s||++e}O=1*e/Object.keys(n.chains[c]).length}if(O<.2&&(O=.2),-1===v.indexOf(l)){for(let e=0,t=h.intrac.length;e1){let s=0,i=0;for(let e=0,t=_[l].length;e",p+="Interaction of chain "+c+" with chain "+h+"",p+="",p+="",p+="Interaction of chain "+h+" with chain "+c+"",p+=""}return p+=f+g,p+="",p+="",n.html2ddgm+=p,$("#"+n.pre+"dl_2ddgm_html").html(n.html2ddgm),p}set2DdgmNote(e){let t="
    Nodes:
    ";return this.icn3d.icn3dui.utilsCls.isMac()?(t+="Protein
    ",t+="Nucleotide
    ",t+="Chemical
    ",t+="Biopolymer
    "):(t+="OProtein
    ",t+="Nucleotide
    ",t+="Chemical
    ",t+="Biopolymer
    "),t+="
    Lines:
    Interactions at 4 Å
    ",e&&(t+="Numbers in red:
    Aligned chains"),t+="

    ",t}highlightNode(e,t,s,i){let n=this.icn3d.icn3dui;i<.2&&(i=.2);if("rect"===e){$(t).attr("stroke",n.htmlCls.ORANGE),$(t).attr("stroke-width",3);let e=Number($(s).attr("x")),l=Number($(s).attr("y")),r=Number($(s).attr("width")),o=Number($(s).attr("height"));$(t).attr("x",e+r/2*(1-i)),$(t).attr("y",l+o/2*(1-i)),$(t).attr("width",r*i),$(t).attr("height",o*i)}else if("circle"===e)$(t).attr("stroke",n.htmlCls.ORANGE),$(t).attr("stroke-width",3),$(t).attr("r",Number($(s).attr("r"))*i);else if("polygon"===e){$(t).attr("stroke",n.htmlCls.ORANGE),$(t).attr("stroke-width",3);let e=Number($(s).attr("x")),l=Number($(s).attr("y")),r=Number($(s).attr("x0d")),o=Number($(s).attr("y0d")),a=Number($(s).attr("x1d")),d=Number($(s).attr("y1d")),c=Number($(s).attr("x2d")),h=Number($(s).attr("y2d")),p=Number($(s).attr("x3d")),m=Number($(s).attr("y3d"));$(t).attr("points",(e+r*i).toString()+", "+(l+o*i).toString()+", "+(e+a*i).toString()+", "+(l+d*i).toString()+", "+(e+c*i).toString()+", "+(l+h*i).toString()+", "+(e+p*i).toString()+", "+(l+m*i).toString())}}removeLineGraphSelection(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"dl_linegraph circle").attr("stroke","#000000"),$("#"+e.pre+"dl_linegraph circle").attr("stroke-width",1),$("#"+e.pre+"dl_linegraph svg line.icn3d-hlline").attr("stroke","#FFF")}removeScatterplotSelection(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"dl_scatterplot circle").attr("stroke","#000000"),$("#"+e.pre+"dl_scatterplot circle").attr("stroke-width",1),$("#"+e.pre+"dl_scatterplot rect").attr("stroke","#000000"),$("#"+e.pre+"dl_scatterplot rect").attr("stroke-width",1)}click2Ddgm(){let e=this.icn3d,t=e.icn3dui,s=this;$(document).on("click","#"+e.pre+"dl_2ddgm .icn3d-node",(function(e){let i=s.icn3d;e.stopImmediatePropagation(),Object.keys(i.hAtoms).length1)s="inter_"+e+"_"+t;else{let i=e.indexOf("_"),n=t.indexOf("_");s="inter_"+e.substr(i+1)+"_"+t.substr(n+1)}i="select the atoms in chain "+e+" interacting with chain "+t+" in a distance of 4 angstrom";let o="select interaction "+e+","+t;n.selectionCls.addCustomSelection(r,s,i,o,!0)}draw2DProtein(e,t,s,i,n,l,r,o,a,d,c){this.icn3d.icn3dui;let h=20*d,p="";return p+="Chain "+i+": "+l+"",p+="",p+="",p+=""+n+"",""!==r&&(p+=""+r+""),p+="",p}draw2DNucleotide(e,t,s,i,n,l,r,o,a,d,c){this.icn3d.icn3dui;let h=30*d,p=30*d,m="";return m+="Chain "+i+": "+l+"",m+="",m+="",m+=""+n+"",""!==r&&(m+=""+r+""),m+="",m}draw2DChemical(e,t,s,i,n,l,r,o,a,d,c,h){this.icn3d.icn3dui;let p,m,u,g,f,b,C,y,v=30*d;if(h){let s=.5*v/Math.sqrt(3),i=.5*v;p=e-s,m=t-i,u=e+3*s,g=t-i,f=e+s,b=t+i,C=e-3*s,y=t+i}else{let s=.5*v,i=.5*v;p=e-s,m=t,u=e,g=t+i,f=e+s,b=t,C=e,y=t-i}let _=p-e,w=m-t,S=u-e,A=g-t,x=f-e,k=b-t,O=C-e,R=y-t,I="";return I+="Chain "+i+": "+l+"",I+="",I+="",I+=""+n+"",""!==r&&(I+=""+r+""),I+="",I}}class _s{constructor(e){this.icn3d=e}async draw2Dcartoon(e,t){let s=this.icn3d,i=s.icn3dui,n=this;if(i.htmlCls.clickMenuCls.setLogCmd("cartoon 2d "+e,!0),s.cartoon2dType=e,t){let t=n.getCartoonSvg(e,s.graphStr);$("#"+i.svgid_ct).html(t)}else{await this.getNodesLinksForSetCartoon(e),s.graphStr=n.getCartoonData(e,s.node_link);let t=n.getCartoonSvg(e,s.graphStr);$("#"+i.svgid_ct).html(t),n.setEventsForCartoon2d(),i.htmlCls.dialogCls.openDlg("dl_2dctn","2D Cartoon")}}getCartoonSvg(e,t){let s=this.icn3d,i=s.icn3dui,n="",l="",r=JSON.parse(t);s.ctnNodeHash={};for(let t=0,i=r.nodes.length;t":"domain"==e?n+="":"secondary"==e&&(a=s.ctnNodeHash[l].x2,d=i.htmlCls.width2d-s.ctnNodeHash[l].y2,c=s.ctnNodeHash[o].x1,h=i.htmlCls.width2d-s.ctnNodeHash[o].y1,n+="");let p=l+"--"+o;n+="Interaction of "+e+" "+this.getLabelFromId(l,e)+" with "+e+" "+this.getLabelFromId(o,e)+"",n+="",s.nodeid2lineid.hasOwnProperty(l)||(s.nodeid2lineid[l]=[]),s.nodeid2lineid.hasOwnProperty(o)||(s.nodeid2lineid[o]=[]),s.nodeid2lineid[l].push(p),s.nodeid2lineid[o].push(p)}return n+=l,n}setEventsForCartoon2d(){let e=this.icn3d,t=e.icn3dui;$("#"+t.svgid_ct+" .icn3d-ctnode").draggable({start:function(e,t){let s=parseFloat(e.target.getAttribute("cx")),i=parseFloat(e.target.getAttribute("cy"));e.target.setAttribute("cx",s),e.target.setAttribute("cy",i);let n=e.target.getAttribute("ang");if(n)e.target.setAttribute("transform","rotate("+n+","+s+","+i+")");else{let t=parseFloat(e.target.getAttribute("x1")),s=parseFloat(e.target.getAttribute("y1")),i=parseFloat(e.target.getAttribute("x2")),n=parseFloat(e.target.getAttribute("y2"));e.target.setAttribute("x1",t),e.target.setAttribute("y1",s),e.target.setAttribute("x2",i),e.target.setAttribute("y2",n)}},drag:function(s,i){let n=$("#"+t.svgid_ct).offset().left,l=$("#"+t.svgid_ct).offset().top,r=s.target.getAttribute("id"),o=s.target.getAttribute("ang"),a=s.clientX-n,d=s.clientY-l,c=parseFloat(s.target.getAttribute("cx")),h=parseFloat(s.target.getAttribute("cy")),p=(a-c)/e.resizeRatioX,m=(d-h)/e.resizeRatioY,u=parseFloat($("#"+r+"_text").attr("x")),g=parseFloat($("#"+r+"_text").attr("y"));if($("#"+r+"_text").attr("x",u+p),$("#"+r+"_text").attr("y",g+m),s.target.setAttribute("cx",a),s.target.setAttribute("cy",d),o)s.target.setAttribute("transform","rotate("+o+","+a+","+d+")");else{let e=parseFloat(s.target.getAttribute("x1")),t=parseFloat(s.target.getAttribute("y1")),i=parseFloat(s.target.getAttribute("x2")),n=parseFloat(s.target.getAttribute("y2"));if(s.target.setAttribute("x1",e+p),s.target.setAttribute("y1",t+m),s.target.setAttribute("x2",i+p),s.target.setAttribute("y2",n+m),"S"==r.substr(0,1)){let e=parseFloat($("#"+r+"_box").attr("x1")),t=parseFloat($("#"+r+"_box").attr("y1")),s=parseFloat($("#"+r+"_box").attr("x2")),i=parseFloat($("#"+r+"_box").attr("y2"));$("#"+r+"_box").attr("x1",e+p),$("#"+r+"_box").attr("y1",t+m),$("#"+r+"_box").attr("x2",s+p),$("#"+r+"_box").attr("y2",i+m)}}if(e.nodeid2lineid[r])for(let t=0,s=e.nodeid2lineid[r].length;t";return u+=""+e+" "+m+"","H"==t.substr(0,1)?u+="":(u+="",u+=""),u+=""+m+"",u+="",u}drawOval(e,t,s,i,n,l,r,o,a,d){let c=this.icn3d.icn3dui,h=this.getLabelFromId(t,e);i=c.htmlCls.width2d-i,r=180-r;let p="chain"==e?"":"";return p+=""+e+" "+h+"",p+="",p+="",p+=" ",p+=" ",p+="",p+="",p+="":" from='"+a+"' to='"+d+"' />",p+=""+h+"",p+="",p}getCartoonData(e,t){let s=this.icn3d;s.icn3dui;let i,n,l=[],r=[];l=t.node;let o=[],a={},d=0;for(let e=0,t=l.length;e0?n.y=s.htmlCls.width2d-n.y:n.y=-n.y,n}async getNodesLinksForSetCartoon(e){let t,s,i,n,l,r=this.icn3d,o=r.icn3dui,a=this,d=[],c=[],h=0,p=o.htmlCls.defaultValue,m="",u="",g="",f=!1,b=!0;if("chain"==e){let e={};for(let t in r.hAtoms){let s=r.atoms[t];if("DUM"==s.chain)continue;let i=s.structure+"_"+s.chain;(r.proteins.hasOwnProperty(t)||r.nucleotides.hasOwnProperty(t))&&(e.hasOwnProperty(i)||(e[i]={}),e[i][s.serial]=s)}let t=r.contactCls.getExtent(r.atoms),s=9999,i=9999,n=-9999,a=-9999,h=-9999,p=[];for(let d in e){r.hAtom={},r.hAtoms=o.hashUtilsCls.cloneHash(r.chains[d]);let e=r.axesCls.setPc1Axes(),c=e[0],m=e[1].distanceTo(e[0]),u=e[2].distanceTo(e[0]),g=180*new THREE.Vector2(e[1].x-e[0].x,e[1].y-e[0].y).angle()/Math.PI;g>180&&(g-=180);let f=Object.keys(r.hAtoms)[0],b=r.atoms[f];l=d,c=this.projectTo2d(c);let C=c.x,y=c.y;Cn&&(n=C),ya&&(a=y);let v=.5;m=v*o.htmlCls.width2d*m/(t[1][0]-t[0][0]),u=v*o.htmlCls.width2d*u/(t[1][1]-t[0][1]),m>h&&(h=m),u>h&&(h=u),p.push({id:d,r:l,x:C,y:y,rx:m,ry:u,ang:g,c:b.color.getHexString()})}let m=h+2,u=n-s,g=a-i;for(let e=0,t=p.length;e1&&(e+="__"+S.structure),a.push(e)),g==S.chain&&f&&S.ssend){let o=this.projectTo2d(t.coord.clone()),d=o.x,g=o.y,x=this.projectTo2d(S.coord.clone()),k=x.x,O=x.y;s=.5*(d+k),i=.5*(g+O),d=.5*(s+d),g=.5*(i+g),k=.5*(s+k),O=.5*(i+O),d_&&(_=d),gw&&(w=g),k_&&(_=k),Ow&&(w=O),f=!1,b=!0,n+="-"+S.resi,l+="-"+S.resi,n+="__"+S.chain,Object.keys(r.structures).length>1&&(n+="__"+S.structure);for(let t=0,s=a.length;t0&&m==S.chain&&c.push('{"source": "'+u+'", "target": "'+n+'", "v": '+p+', "c": "'+t.color.getHexString().toUpperCase()+'"}'),A.push({id:n,r:l,ss:C,x:s,y:i,x1:d,y1:g,x2:k,y2:O,c:S.color.getHexString()}),m=S.chain,u=n,++h}}}let x=S+2,k=_-y,O=w-v;for(let e=0,t=A.length;e1&&(v+="__"+i.substr(0,i.indexOf("_")));let _=g[b],w=f[b];t.hAtoms={};for(let e=0,n=_.length;e180&&(O-=180);let R=Object.keys(t.hAtoms)[0],I=t.atoms[R];A=this.projectTo2d(A);let T=A.x,E=A.y;Tc&&(c=T),Eh&&(h=E);let P=.5;x=P*s.htmlCls.width2d*x/(o[1][0]-o[0][0]),k=P*s.htmlCls.width2d*k/(o[1][1]-o[0][1]),x>p&&(p=x),k>p&&(p=k),void 0!==C&&n.push('{"source": "'+C+'", "target": "'+v+'", "v": '+l+', "c": "'+y.color.getHexString().toUpperCase()+'"}'),m.push({id:v,from:_+"",to:w+"",x:T,y:E,rx:x,ry:k,ang:O,c:I.color.getHexString()}),C=v,y=I}}let g=p+2,f=c-a,b=h-d;for(let e=0,t=m.length;e=2?d+"_"+e[1]:Object.keys(i.chains)[0];for(let e=0,t=o.length;e0&&(void 0===i||i)&&n.drawCls.draw()}}windowResize(){let e=this.icn3d.icn3dui,t=this;e.cfg.resize&&!e.utilsCls.isMobile()&&$(window).resize((function(){let s=t.icn3d;e.utilsCls.setViewerWidthHeight(s.icn3dui);let i=e.htmlCls.WIDTH,n=e.htmlCls.HEIGHT;void 0===s||s.bFullscreen||t.resizeCanvas(i,n)}))}openFullscreen(e){this.icn3d.icn3dui.bNode||document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement||(e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen())}rotStruc(e,t){var s=this.icn3d;s.icn3dui;let i=this;if(s.bStopRotate)return!1;if(s.transformCls.rotateCount>s.transformCls.rotateCountMax)return s.transformCls.resetOrientation(),!1;if(++s.transformCls.rotateCount,t)if("left"===e)s.ROT_DIR="left";else if("right"===e)s.ROT_DIR="right";else if("up"===e)s.ROT_DIR="up";else{if("down"!==e)return!1;s.ROT_DIR="down"}if("left"===e&&"left"===s.ROT_DIR)s.transformCls.rotateLeft(1);else if("right"===e&&"right"===s.ROT_DIR)s.transformCls.rotateRight(1);else if("up"===e&&"up"===s.ROT_DIR)s.transformCls.rotateUp(1);else{if("down"!==e||"down"!==s.ROT_DIR)return!1;s.transformCls.rotateDown(1)}setTimeout((function(){i.rotStruc(e)}),100)}async back(){var e=this.icn3d;e.icn3dui,e.backForward=!0,e.STATENUMBER--,e.bAddCommands=!1,e.bAddLogs=!1,e.bNotLoadStructure=!0,e.STATENUMBER<1?e.STATENUMBER=1:await e.loadScriptCls.execCommands(0,e.STATENUMBER-1,e.STATENUMBER,!0),e.setStyleCls.adjustIcon(),e.bAddCommands=!0,e.bAddLogs=!0}async forward(){var e=this.icn3d;e.icn3dui,e.backForward=!0,e.STATENUMBER++,e.bAddCommands=!1,e.bAddLogs=!1,e.bNotLoadStructure=!0,e.STATENUMBER>e.commands.length?e.STATENUMBER=e.commands.length:await e.loadScriptCls.execCommands(0,e.STATENUMBER-1,e.STATENUMBER,!0),e.setStyleCls.adjustIcon(),e.bAddCommands=!0,e.bAddLogs=!0}async replayon(){var e=this.icn3d;e.icn3dui,e.CURRENTNUMBER=0,e.bReplay=1,$("#"+e.pre+"replay").show(),e.commands.length>0&&await e.loadScriptCls.replayFirstStep(e.CURRENTNUMBER)}async replayoff(){var e=this.icn3d;e.icn3dui,e.bReplay=0,$("#"+e.pre+"replay").hide(),++e.CURRENTNUMBER,await e.loadScriptCls.execCommands(e.CURRENTNUMBER,e.STATENUMBER-1,e.STATENUMBER)}closeDialogs(){var e=this.icn3d,t=e.icn3dui;let s=["dl_2ddgm","dl_2dctn","dl_alignment","dl_sequence2","dl_definedsets","dl_setsmenu","dl_command","dl_setoperations","dl_vast","dl_foldseek","dl_mmtfid","dl_pdbid","dl_afid","dl_opmid","dl_pdbfile","dl_pdbfile_app","dl_rescolorfile","dl_customcolor","dl_align","dl_alignaf","dl_chainalign","dl_chainalign2","dl_chainalign3","dl_mutation","dl_mol2file","dl_sdffile","dl_xyzfile","dl_afmapfile","dl_urlfile","dl_mmciffile","dl_mmcifid","dl_mmdbid","dl_mmdbafid","dl_blast_rep_id","dl_yournote","dl_proteinname","dl_refseqid","dl_cid","dl_pngimage","dl_state","dl_fixedversion","dl_selection","dl_dsn6","dl_dsn6url","dl_clr","dl_symmetry","dl_symd","dl_contact","dl_hbonds","dl_realign","dl_realignbystruct","dl_allinteracton","dl_interactionsorted","dl_linegraph","dl_linegraphcolor","dl_scatterplot","dl_scatterploitcolor","dl_contactmap","dl_alignerrormap","dl_elecmap2fofc","dl_elecmapfofc","dl_emmap","dl_aroundsphere","dl_adjustmem","dl_selectplane","dl_addlabel","dl_addlabelselection","dl_labelColor","dl_distance","dl_stabilizer","dl_disttwosets","dl_distmanysets","dl_stabilizer_rm","dl_thickness","dl_thickness2","dl_addtrack","dl_addtrack_tabs","dl_saveselection","dl_copyurl","dl_selectannotations","dl_annotations_tabs","dl_anno_view_tabs","dl_annotations","dl_graph","dl_svgcolor","dl_area","dl_colorbyarea","dl_rmsd","dl_buriedarea","dl_propbypercentout","dl_propbybfactor","dl_legend","dl_disttable"];for(let i in s){let n=s[i];t.cfg.notebook?$("#"+e.pre+n).hide():$("#"+e.pre+n).hasClass("ui-dialog-content")&&$("#"+e.pre+n).dialog("isOpen")&&$("#"+e.pre+n).dialog("close").remove()}t.cfg.notebook||this.resizeCanvas(t.htmlCls.WIDTH,t.htmlCls.HEIGHT,!0)}}class Ss{constructor(e){this.icn3d=e}resetOrientation(){let e=this.icn3d;e.icn3dui;let t=!1;if(e.commands.length>0){let s=e.commands[0].split("|||");if(2==s.length){let i=JSON.parse(s[1]);e._zoomFactor=i.factor,e.mouseChange.x=i.mouseChange.x,e.mouseChange.y=i.mouseChange.y,e.quaternion._x=i.quaternion._x,e.quaternion._y=i.quaternion._y,e.quaternion._z=i.quaternion._z,e.quaternion._w=i.quaternion._w,t=!0}}t||(e._zoomFactor=1,e.mouseChange=new THREE.Vector2(0,0),e.quaternion=new THREE.Quaternion(0,0,0,1)),e.maxD=e.oriMaxD,e.center=e.oriCenter.clone(),"show"==e.ori_chemicalbinding?e.bSkipChemicalbinding=!1:"hide"==e.ori_chemicalbinding&&(e.bSkipChemicalbinding=!0)}rotateLeft(e){let t=this.icn3d,s=t.icn3dui,i=new THREE.Vector3(0,1,0),n=-e/180*Math.PI;t.bControlGl&&!s.bNode?i.applyQuaternion(window.cam.quaternion).normalize():i.applyQuaternion(t.cam.quaternion).normalize();let l=new THREE.Quaternion;l.setFromAxisAngle(i,-n);let r={};r.quaternion=l,r.update=!0,t.bControlGl&&!s.bNode?window.controls.update(r):t.controls.update(r),t.bRender&&t.drawCls.render()}rotateRight(e){let t=this.icn3d,s=t.icn3dui,i=new THREE.Vector3(0,1,0),n=e/180*Math.PI;t.bControlGl&&!s.bNode?i.applyQuaternion(window.cam.quaternion).normalize():i.applyQuaternion(t.cam.quaternion).normalize();let l=new THREE.Quaternion;l.setFromAxisAngle(i,-n);let r={};r.quaternion=l,r.update=!0,t.bControlGl&&!s.bNode?window.controls.update(r):t.controls.update(r),t.bRender&&t.drawCls.render()}rotateUp(e){this.icn3d.icn3dui,this.rotate_base(-e)}rotateDown(e){this.icn3d.icn3dui,this.rotate_base(e)}rotate_base(e){let t=this.icn3d,s=t.icn3dui,i=new THREE.Vector3(1,0,0),n=e/180*Math.PI;t.bControlGl&&!s.bNode?i.applyQuaternion(window.cam.quaternion).normalize():i.applyQuaternion(t.cam.quaternion).normalize();let l=new THREE.Quaternion;l.setFromAxisAngle(i,-n);let r={};r.quaternion=l,r.update=!0,t.bControlGl&&!s.bNode?window.controls.update(r):t.controls.update(r),t.bRender&&t.drawCls.render()}setRotation(e,t){let s=this.icn3d,i=s.icn3dui;s.bControlGl&&!i.bNode&&window.cam?e.applyQuaternion(window.cam.quaternion).normalize():s.cam&&e.applyQuaternion(s.cam.quaternion).normalize();let n=new THREE.Quaternion;n.setFromAxisAngle(e,-t);let l={};l.quaternion=n,l.update=!0,s.bControlGl&&!i.bNode&&window.controls?window.controls.update(l):s.controls&&s.controls.update(l),s.bRender&&s.drawCls.render()}translateLeft(e){this.icn3d.icn3dui,this.translate_base(-e,0)}translateRight(e){this.icn3d.icn3dui,this.translate_base(e,0)}translateUp(e){this.icn3d.icn3dui,this.translate_base(0,-e)}translateDown(e){this.icn3d.icn3dui,this.translate_base(0,e)}translate_base(e,t){let s=this.icn3d,i=s.icn3dui,n=new THREE.Vector2(0,0);n.x+=e/100,n.y+=t/100;let l={};l.mouseChange=n,l.update=!0,s.bControlGl&&!i.bNode?window.controls.update(l):s.controls.update(l),s.bRender&&s.drawCls.render()}zoominSelection(e){let t=this.icn3d,s=t.icn3dui,i={};if(i._zoomFactor=1/t._zoomFactor,i.update=!0,t.bControlGl&&!s.bNode?window.controls&&window.controls.update(i):t.controls&&t.controls.update(i),void 0===e&&(e=s.hashUtilsCls.hash2Atoms(t.hAtoms,t.atoms)),Object.keys(e).length>1){let s=t.applyCenterCls.centerAtoms(e);t.maxD=s.maxD,t.maxD<5&&(t.maxD=5),t.center=s.center,t.applyCenterCls.setCenter(t.center),t.cameraCls.setCamera()}}getTransformationStr(e){this.icn3d.icn3dui;let t={factor:1,mouseChange:{x:0,y:0},quaternion:{_x:0,_y:0,_z:0,_w:1}};return t.factor=parseFloat(e.factor).toPrecision(4),t.mouseChange.x=parseFloat(e.mouseChange.x).toPrecision(4),t.mouseChange.y=parseFloat(e.mouseChange.y).toPrecision(4),t.quaternion._x=parseFloat(e.quaternion._x).toPrecision(4),t.quaternion._y=parseFloat(e.quaternion._y).toPrecision(4),t.quaternion._z=parseFloat(e.quaternion._z).toPrecision(4),t.quaternion._w=parseFloat(e.quaternion._w).toPrecision(4),"1.0000"==t.factor&&(t.factor=1),"0.0000"==t.mouseChange.x&&(t.mouseChange.x=0),"0.0000"==t.mouseChange.y&&(t.mouseChange.y=0),"0.0000"==t.quaternion._x&&(t.quaternion._x=0),"0.0000"==t.quaternion._y&&(t.quaternion._y=0),"0.0000"==t.quaternion._z&&(t.quaternion._z=0),"1.0000"==t.quaternion._w&&(t.quaternion._w=1),JSON.stringify(t)}}class As{constructor(e){this.icn3d=e}saveFile(e,t,s,i){let n,l=this.icn3d,r=l.icn3dui,o=this;if("command"===t){let e=l.loadCmd?l.loadCmd+"\n":"";for(let t=0,s=l.commands.length;t4e3||0!==s.indexOf("http")||l.bInputfile&&!l.bInputUrlfile?$("#"+l.pre+"viewer").html(""):$("#"+l.pre+"viewer").html(""),$("#"+l.pre+"viewer").width(i),$("#"+l.pre+"viewer").height(n),$("#"+l.pre+"cmdlog").hide(),$("#"+l.pre+"title").hide(),$("#"+l.pre+"mnlist").hide(),$("#"+l.pre+"fullscreen").length>0&&$("#"+l.pre+"fullscreen").hide(),l={}}else saveAs(e,t)}saveSvg(e,t,s){if(this.icn3d.icn3dui.bNode)return"";let i=$("#"+e).width(),n=$("#"+e).height();s&&(n=i);let l=this.getSvgXml(e,i,n,s),r=new Blob([l],{type:"image/svg+xml"});saveAs(r,t)}getSvgXml(e,t,s,i){if(this.icn3d.icn3dui.bNode)return"";return(t&&s?''+""+document.getElementById(e).innerHTML+""}savePng(e,t,s){let i=this.icn3d,n=i.icn3dui;if(n.bNode)return"";let l=$("#"+e).width(),r=$("#"+e).height();s&&(r=l);let o=document.getElementById(e),a=o.getBBox(),d=o.cloneNode(!0);i.lineGraphCls.copyStylesInline(d,o);let c=document.createElement("CANVAS");c.width=l,c.height=r;let h=c.getContext("2d");h.clearRect(0,0,a.width,a.height);let p=this.getSvgXml(e,l,r,s),m=window.URL||window.webkitURL||window,u=new Blob([p],{type:"image/svg+xml;charset=utf-8"}),g=new Image;g.src=m.createObjectURL(u),g.onload=function(){if(h.drawImage(g,0,0),m.revokeObjectURL(this.src),n.utilsCls.isIE()){let e=c.msToBlob();e&&(saveAs(e,t),c.remove())}else c.toBlob((function(e){e&&(saveAs(e,t),c.remove())}))}}exportCustomAtoms(e){var t=this.icn3d;t.icn3dui;let s="",i=void 0!==t.defNames2Residues?Object.keys(t.defNames2Residues).sort():[];for(let n=0,l=i.length;n0)if(s){let s={};for(let e=0,l=t.length;eparseInt(p)+1&&(s.ss=" ",f.push(s)),"helix"==t.ss?(s.ss="H",f.push(s)):"sheet"==t.ss&&(s.ss="S",f.push(s)),t.ssend){let e=a.hashUtilsCls.cloneHash(s);e.ss=" ",f.push(e)}p=t.resi}let b,C,y=0,v=!1,_=!1;for(let e=0,t=f.length;e1,A=1,x="",k="",O=0,R="",I={};for(let l in e){let e=o.atoms[l];if(s&&e.het)continue;if(e.structure!=x){r&&S||(d+=w,w="",A>1&&(d+="\nENDMDL\n"),S&&(d+="MODEL "+A+"\n"));let t=n?"Mutated chain_residue "+Object.keys(n)+"; ":"";i||r&&S||(d+=this.getPDBHeader(A-1,g,t,e.structure)),++A}e.chain!=k&&e.structure==x&&k&&(d+="TER\n");let p=e.chain+"_"+e.resi;if(n&&n.hasOwnProperty(p)){I.hasOwnProperty(p)||(d+=n[p],I[p]=1);continue}let m="";m+=e.het?"HETATM":"ATOM ",m+=l.toString().padStart(5," "),m+=" ";let u=e.name.trim();isNaN(u.substr(0,1))||(u=u.substr(1)+u.substr(0,1)),4==u.length?m+=u:(m+=" ",u=u.replace(/\*/g,"'"),"O1P"==u?u="OP1":"O2P"==u?u="OP2":"C5M"==u&&(u="C7 "),m+=u.padEnd(3," ")),m+=" ";let f=e.resn;if(m+=f.length<=3?f.padStart(3," "):f.substr(0,3),r&&A>2&&(o.proteins.hasOwnProperty(e.serial)||o.nucleotides.hasOwnProperty(e.serial)))e.structure==x&&e.chain==k||(R=O<36?"abcdefghijklmnopqrstuvwxyz0123456789"[O]:"?",++O),m+=" "+R;else if(e.chain.length>=2){m+=e.chain.replace(/_/gi,"").substr(0,2)}else 1==e.chain.length?m+=" "+e.chain.substr(0,1):0==e.chain.length&&(m+=" A");let b=e.resi;!isNaN(b)&&e.chain.length>3&&!isNaN(e.chain.substr(3))&&(b=b-1+parseInt(e.chain.substr(3)));let C=parseInt(b);m+=C.toString().length<=4?C.toString().padStart(4," "):C.toString().substr(0,4);let y=e.resi.toString().substr(e.resi.toString().length-1,1);if(isNaN(y)?m+=y:m+=" ",m+=" ".padStart(3," "),m+=e.coord.x.toFixed(3).toString().padStart(8," "),m+=e.coord.y.toFixed(3).toString().padStart(8," "),m+=e.coord.z.toFixed(3).toString().padStart(8," "),t&&e.het){let t=1.5,s=0;"C"==e.elem?t=1.908:"N"==e.elem?t=1.824:"O"==e.elem?t=1.6612:"H"==e.elem?t=1.25:"S"==e.elem?t=2:"P"==e.elem?t=2.1:a.parasCls.vdwRadii.hasOwnProperty(e.elem)&&(t=a.parasCls.vdwRadii[e.elem]),void 0!==a.cfg.cid&&void 0!==e.crg?s=e.crg:c.hasOwnProperty(l)?s=1.38:h.hasOwnProperty(l)?s=-.595:a.parasCls.ionCharges.hasOwnProperty(e.elem)&&(s=a.parasCls.ionCharges[e.elem]),m+=s.toFixed(4).toString().padStart(8," "),m+=t.toFixed(4).toString().padStart(7," ")}else m+="1.00".padStart(6," "),m+=e.b?parseFloat(e.b).toFixed(2).toString().padStart(6," "):" ".padStart(6," "),m+=" ".padStart(10," "),m+=e.elem.padStart(2," "),m+=" ".padStart(2," ");if(e.het&&e.bonds.length>0){w+="CONECT"+l.toString().padStart(5," ");let t={};for(let s=0,i=e.bonds.length;s50?n.molTitle.substr(0,47)+"...":n.molTitle;-1!=e.indexOf('"')&&(e=""),s&&(e=s+e),l+="TITLE "+e+"\n"}return t&&t[r]&&(l+=t[r]),l}showTitle(){var e=this.icn3d,t=e.icn3dui;let s=e.molTitle?e.molTitle:"",i="black"==e.opts.background?t.htmlCls.GREYD:"black";if(void 0===e.inputid)s.length>40&&(s=s.substr(0,40)+"..."),$("#"+e.pre+"title").html(s);else if(void 0!==t.cfg.cid){let t=this.getLinkToStructureSummary();$("#"+e.pre+"title").html("PubChem CID "+e.inputid.toUpperCase()+": "+s)}else if(void 0!==t.cfg.align)s="VAST+ alignment of "+Object.keys(e.structures),$("#"+e.pre+"title").html(s);else if(void 0!==t.cfg.chainalign){s="Dynamic Structure Alignment of Chains: "+t.cfg.chainalign.split(","),$("#"+e.pre+"title").html(s)}else{let n=Object.keys(t.utilsCls.getStructures(e.dAtoms));if(n.length>1){s="Multiple structures: ";for(let e=0,t=n.length;e'+n[e]+"",e5?"https://alphafold.ebi.ac.uk/entry/"+n[0]:"https://www.ncbi.nlm.nih.gov/structure/?term="+n[0];this.setStructureTitle(e,s,i)}}}setStructureTitle(e,t,s){var i=this.icn3d,n=i.icn3dui;t.length>40&&(t=t.substr(0,40)+"...");let l,r,o=i.inputid;if(-1!=o.indexOf("http"))r="Data from",e=o,l=o;else{let e=n.utilsCls.getHlStructures(),s=!1,a=!1;for(let t in e)t.length>5?a=!0:s=!0;let d=Object.keys(e);if(o=d.join(","),l=n.cfg.refseqid||n.cfg.protein?i.inputid:o.toUpperCase(),s&&a?r="AlphaFold/PDB ID":s?r="PDB ID":a&&(r="AlphaFold ID"),d.length>1&&(r+="s"),i.molTitleHash){t="";for(let e=0,s=d.length;e20&&(e=e.substr(0,17)+"..."),l="Query: "+e+"; target: "+s,$("#"+i.pre+"title").html(l+", "+t)}else $("#"+i.pre+"title").html(r+" "+l+": "+t);else $("#"+i.pre+"title").html(t)}getLinkToStructureSummary(e){var t=this.icn3d,s=t.icn3dui;let i="https://www.ncbi.nlm.nih.gov/structure/?term=";if(i=void 0!==s.cfg.cid?"https://www.ncbi.nlm.nih.gov/pccompound/?term=":void 0!==s.cfg.refseqid?"https://www.ncbi.nlm.nih.gov/protein/":void 0!==s.cfg.afid?"https://alphafold.ebi.ac.uk/search/text/":Object.keys(t.structures).length>1?"https://www.ncbi.nlm.nih.gov/structure/?term=":s.htmlCls.baseUrl+"pdb/",void 0===t.inputid)i="https://www.ncbi.nlm.nih.gov/pccompound/?term="+t.molTitle;else{let n=t.inputid.split("_");1===n.length?(i+=t.inputid,e&&s.htmlCls.clickMenuCls.setLogCmd("link to "+t.inputid+": "+i,!1)):2===n.length&&(s.cfg.afid?i+=n[0]+" "+n[1]:i+=n[0]+" OR "+n[1],e&&s.htmlCls.clickMenuCls.setLogCmd("link to structures "+n[0]+" and "+n[1]+": "+i,!1))}return i}setEntrezLinks(e){var t=this.icn3d,s=t.icn3dui;let i,n=Object.keys(t.structures);if(1===n.length){i="https://www.ncbi.nlm.nih.gov/"+e+"/?term="+n[0],s.htmlCls.clickMenuCls.setLogCmd("Entrez "+e+" about PDB "+n[0]+": "+i,!1);let l=t.structures&&Object.keys(t.structures).length>0?"_blank":"_self";window.open(i,l)}else if(2===n.length){i="https://www.ncbi.nlm.nih.gov/"+e+"/?term="+n[0]+" OR "+n[1],s.htmlCls.clickMenuCls.setLogCmd("Entrez "+e+" about PDB "+n[0]+" OR "+n[1]+": "+i,!1);let l=t.structures&&Object.keys(t.structures).length>0?"_blank":"_self";window.open(i,l)}}}class xs{constructor(e){this.icn3d=e}async shareLink(e,t){let s=this.icn3d,i=s.icn3dui,n=this.shareLinkUrl(),l=n.length>4e3||0!==n.indexOf("http"),r=Object.keys(s.structures).join("_");if(r==s.defaultPdbId&&(s.filename?r=s.filename:s.inputid&&(r=s.inputid)),e){if(t||s.bInputfile||l)return void s.saveFileCls.saveFile(r+"_icn3d_loadable.png","png")}else{if(s.bInputfile&&!s.bInputUrlfile)return void alert("Share Link does NOT work when the data are from custom files. Please save 'iCn3D PNG Image' in the File menu and open it in iCn3D.");if(l)return void alert("The url is more than 4000 characters and may not work. Please save 'iCn3D PNG Image' or 'State File' and open them in iCn3D.");i.htmlCls.clickMenuCls.setLogCmd("share link: "+n,!1)}let o="Problem in getting shortened URL";if(!i.cfg.notebook){let t=await this.getShareLinkPrms(n,e);if(void 0!==t.shortLink&&(o=t.shortLink,e)){let e=o.split("/"),t=e[e.length-1];s.saveFileCls.saveFile(r+"-"+t+".png","png");let i='\n\n",s.saveFileCls.saveFile(r+"-"+t+".html","html",i)}e&&void 0===t.shortLink&&s.saveFileCls.saveFile(r+"_icn3d_loadable.png","png");let i=o.split("page.link/");2==i.length&&(o="https://structure.ncbi.nlm.nih.gov/icn3d/share.html?"+i[1]),$("#"+s.pre+"short_url").val(o),$("#"+s.pre+"short_url_title").val(o+"&t="+s.yournote)}let a=this.shareLinkUrl(void 0,!0),d="view = icn3dpy.view(q='"+(i.cfg.url?"url="+i.cfg.url:i.cfg.idname+"="+i.cfg.idvalue)+"',command='"+a+"')\nview";(i.cfg.url||i.cfg.idname)&&$("#"+s.pre+"jn_commands").val(d),$("#"+s.pre+"ori_url").val(n),e||i.htmlCls.dialogCls.openDlg("dl_copyurl","Copy a Share Link URL or Jupyter Notebook Commands")}getShareLinkPrms(e,t){let s=this.icn3d,i=s.icn3dui;return new Promise((function(n,l){$.ajax({url:"https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=AIzaSyBxl9CgM0dY5lagHL4UOhEpLWE1fuwdnvc",type:"POST",data:{longDynamicLink:"https://icn3d.page.link/?link="+encodeURIComponent(e)},dataType:"json",success:function(e){n(e)},error:function(n,l,r){let o="Problem in getting shortened URL";$("#"+s.pre+"ori_url").val(e),$("#"+s.pre+"short_url").val(o),$("#"+s.pre+"short_url_title").val(o+"&t="+s.yournote),t||i.htmlCls.dialogCls.openDlg("dl_copyurl","Copy a Share Link URL")}})}))}shareLinkUrl(e,t){let s=this.icn3d,i=s.icn3dui,n=i.htmlCls.baseUrl+"icn3d/?",l="";if(i.cfg.bSidebyside&&(n=i.htmlCls.baseUrl+"icn3d/full2.html?"),s.bInputUrlfile){n=window.location.href.split("?")[0]+"?"+s.inputurl+"&"}let r,o={};for(let e in s.cfg){let t=s.cfg[e];"inpara"!==e&&"command"!==e&&"usepdbnum"!==e&&"date"!==e&&"v"!==e&&void 0!==t&&("width"===e&&"100%"===t||"height"===e&&"100%"===t||"resize"===e&&!0===t||"showmenu"===e&&!0===t||"showtitle"===e&&!0===t||"showcommand"===e&&!0===t||"mobilemenu"===e&&!1===t||"showanno"===e&&!1===t||"showseq"===e&&!1===t||"showalignseq"===e&&!1===t||"show2d"===e&&!1===t||"showsets"===e&&!1===t||"rotate"===e&&"right"===t||"command"!==e&&("options"===e?Object.keys(t).length>0&&(o[e]=JSON.stringify(t)):!0===t?o[e]=1:!1===t?o[e]=0:""!==t&&(o[e]=t)))}s.bAfMem?o.afmem="on":(i.cfg.afid||1==Object.keys(s.structures).length&&Object.keys(s.structures)[0].length>5)&&(o.afmem="off");let a=-1;void 0!==i.cfg.inpara&&(a=i.cfg.inpara.indexOf("&command=")),r=-1!==a?i.cfg.inpara.substr(0,a):i.cfg.inpara;let d=!1;if(!s.bInputUrlfile){let e=r&&r.substr(1)?r.substr(1).split("&"):[];for(let t=0,s=e.length;tc){u=s.commands[c].split("|||")[0].split("&command=")[0].trim(),-1!==u.indexOf(g)&&++f}let b,C=c+1,y="";for(let e=s.commands.length;C0&&f%2==0&&u!==g&&(y+=g+"; "),y+=u+"|||"+s.transformCls.getTransformationStr(p),m+=u+"|||"+s.transformCls.getTransformationStr(p)+"\n"),n+=y,l=y,m=m.replace(/!/g,Object.keys(s.structures)[0]+"_"),(s.bEsmfold||s.bInputfile&&!s.bInputUrlfile||s.bInputUrlfile&&s.bAppend||n.length>4e3)&&(n=m),void 0!==s.structures&&1==Object.keys(s.structures).length&&void 0!==s.inputid&&(b=Object.keys(s.structures)[0],n=n.replace(new RegExp(b+"_","g"),"!"),l=l.replace(new RegExp(b+"_","g"),"!")),void 0!==i.cfg.blast_rep_id&&(n=n.replace(new RegExp("blast_rep_id=!","g"),"blast_rep_id="+b+"_")),t?l:n}getPngText(){let e,t=this.icn3d;t.icn3dui;let s="";if(t.bInputfile)e=this.shareLinkUrl(true),"http"==e.substr(0,4)?s+="\nShare Link: "+e:(s+="\nStart of type file======\n",s+=t.InputfileType+"\n",s+="End of type file======\n",s+="Start of data file======\n",s+=t.saveFileCls.getAtomPDB(t.atoms),s+="End of data file======\n",s+="Start of state file======\n",s+=e+"\n",s+="End of state file======\n");else{e=this.shareLinkUrl(),e.length>4e3||0!==e.indexOf("http")?(e=this.shareLinkUrl(true),s+="\nStart of state file======\n",s+=e+"\n",s+="End of state file======\n"):s+="\nShare Link: "+e}return s=s.replace(/!/g,Object.keys(t.structures)[0]+"_"),s}}class ks{constructor(e){this.icn3d=e}setThichknessFor3Dprint(){let e=this.icn3d,t=e.icn3dui;e.lineRadius=1,e.coilWidth=1.2,e.cylinderRadius=.8,e.crosslinkRadius=.8,e.traceRadius=1,e.dotSphereScale=.6,e.sphereRadius=1.5,e.ribbonthickness=1,e.helixSheetWidth=2,e.nucleicAcidWidth=1.4,t.htmlCls.setHtmlCls.setCookieForThickness()}prepareFor3Dprint(){let e=this.icn3d,t=e.icn3dui;if(e.bShowHighlight=!1,e.hlObjectsCls.removeHlObjects(),e.bDashedLines=!1,e.bSetThickness||void 0!==t.cfg.cid||this.setThichknessFor3Dprint(),void 0!==e.lines.hbond)for(let t=0,s=e.lines.hbond.length;tt.substr(0,s))return 1;if(e.substr(0,s)==t.substr(0,s)){if(parseInt(e.substr(s+1))parseInt(t.substr(i+1)))return 1;if(parseInt(e.substr(s+1))==parseInt(t.substr(i+1)))return 0}}})),n="";for(let e=0,t=i.length;e"}let l=Object.keys(t.utilsCls.getHlStructures()).join(",");e.saveFileCls.saveFile(l+"_residues.txt","html",n)}addStabilizer(){let e=this.icn3d,t=e.icn3dui,s=3.5;if(Object.keys(e.dAtoms).length>0){let i,n={},l=12.25,r=3.2*3.2;for(let t in e.dAtoms){let s=e.atoms[t];!e.nucleotides.hasOwnProperty(s.serial)||"N1"!==s.name&&"N2"!==s.name&&"N3"!==s.name&&"N4"!==s.name&&"N6"!==s.name&&"O2"!==s.name&&"O6"!==s.name||(i=s.structure+"_"+s.chain+"_"+s.resi+"_"+s.name,n[i]=s)}let o=Object.keys(n),a=o.length;void 0===e.pairArray&&(e.pairArray=[]);for(let t=0;ts)continue;let h=Math.abs(n[a].coord.y-n[d].coord.y);if(h>s)continue;let p=Math.abs(n[a].coord.z-n[d].coord.z);if(p>s)continue;let m=c*c+h*h+p*p;m>l||ms+1||rs+2||rs+4||r0&&o.length>0)if(a){let t=parseInt((r.length+.5)/2);e.pairArray.push(o[0]),e.pairArray.push(r[t])}else{let t=10,s=parseInt(r.length/(t+1));for(let i=0,n=o.length;i1&&t.bAssembly&&(t.threshbox=180/Math.pow(t.biomtMatrices.length,.33),t.applyMapCls.removeSurfaces(),t.applyMapCls.applySurfaceOptions(),t.applyMapCls.removeMaps(),t.applyMapCls.applyMapOptions(),t.applyMapCls.removeEmmaps(),t.applyMapCls.applyEmmapOptions());let i=this.saveStlFile(),n=Object.keys(s.utilsCls.getHlStructures()).join(",");if(t.saveFileCls.saveFile(n+e+".stl","binary",i),void 0!==t.biomtMatrices&&t.biomtMatrices.length>1&&t.bAssembly&&Object.keys(t.dAtoms).length*t.biomtMatrices.length>t.maxAtoms3DMultiFile){alert(t.biomtMatrices.length+" files will be generated for this assembly. Please merge these files using some software and 3D print the merged file.");let s=new THREE.Matrix4;s.identity();let l=1;for(let r=0;r1&&t.bAssembly&&(t.threshbox=180/Math.pow(t.biomtMatrices.length,.33),t.applyMapCls.removeSurfaces(),t.applyMapCls.applySurfaceOptions(),t.applyMapCls.removeMaps(),t.applyMapCls.applyMapOptions(),t.applyMapCls.removeEmmaps(),t.applyMapCls.applyEmmapOptions());let i=this.saveVrmlFile(),n=Object.keys(s.utilsCls.getHlStructures()).join(",");if(t.saveFileCls.saveFile(n+e+".wrl","text",i),void 0!==t.biomtMatrices&&t.biomtMatrices.length>1&&t.bAssembly&&Object.keys(t.dAtoms).length*t.biomtMatrices.length>t.maxAtoms3DMultiFile){alert(t.biomtMatrices.length+" files will be generated for this assembly. Please merge these files using some software and 3D print the merged file.");let s=new THREE.Matrix4;s.identity();let n=1;for(let l=0;l7e4)return alert("Please display a subset of the structure to export 3D files. Then merge the files for 3D printing..."),[""];t.threeDPrintCls.prepareFor3Dprint();let i=0;i+=this.getFaceCnt(t.mdl),i+=this.getFaceCnt(t.mdl_ghost);let n=[],l=new Uint8Array(84),r="STL file for the structure(s) ",o=Object.keys(t.structures);for(let e=0,t=o.length;e80&&(r=r.substr(0,80));for(let e=0;e<80;++e)e1&&t.bAssembly&&Object.keys(t.dAtoms).length*t.biomtMatrices.length<=t.maxAtoms3DMultiFile?this.updateArray(l,s.convertTypeCls.passInt32([i*t.biomtMatrices.length]),80):this.updateArray(l,s.convertTypeCls.passInt32([i]),80),n.push(new Blob([l],{type:"application/octet-stream"})),n=this.processStlMeshGroup(t.mdl,n,e),n=this.processStlMeshGroup(t.mdl_ghost,n,e),void 0!==t.biomtMatrices&&t.biomtMatrices.length>1&&t.bAssembly&&Object.keys(t.dAtoms).length*t.biomtMatrices.length<=t.maxAtoms3DMultiFile){let e=new THREE.Matrix4;e.identity();for(let s=0;s5e4)return alert("Please display a subset of the structure to export 3D files. Then merge the files for 3D printing..."),[""];t.threeDPrintCls.prepareFor3Dprint();let s=[];s.push("#VRML V2.0 utf8\n");let i=0,n=this.processVrmlMeshGroup(t.mdl,s,i,e);if(s=n.vrmlStrArray,i=n.vertexCnt,n=this.processVrmlMeshGroup(t.mdl_ghost,s,i,e),s=n.vrmlStrArray,i=n.vertexCnt,void 0!==t.biomtMatrices&&t.biomtMatrices.length>1&&t.bAssembly&&Object.keys(t.dAtoms).length*t.biomtMatrices.length<=t.maxAtoms3DMultiFile){let e=new THREE.Matrix4;e.identity();for(let l=0;l0?h.z=-1:h.z=1,s.cam===s.perspectiveCamera?(s.cam_z>0?h.z=-1:h.z=1,h.unproject(s.cam),s.raycaster.set(s.cam.position,h.sub(s.cam.position).normalize())):s.cam===s.orthographicCamera&&(s.cam_z>0?h.z=1:h.z=-1,h.unproject(s.cam),s.raycaster.set(h,new THREE.Vector3(0,0,-1).transformDirection(s.cam.matrixWorld)));let p=this.isIntersect(s.objects,s.mdl,t,d,c);p||(p=this.isIntersect(s.objects_ghost,s.mdl_ghost,t,d,c))}isIntersect(e,t,s,i,n){let l=this.icn3d;l.icn3dui;let r=l.raycaster.intersectObjects(e),o=!1,a=t.position;if(r.length>0){r[0].point.sub(a);let e=l.rayThreshold,t=this.getAtomsFromPosition(r[0].point,e);for(;!t&&e<10;)e+=.5,t=this.getAtomsFromPosition(r[0].point,e);t?(o=!0,l.pickpair?s&&(l.pAtomNum%2==0?l.pAtom=t:l.pAtom2=t,++l.pAtomNum):l.pAtom=t,s?l.pickingCls.showPicking(t):l.pickingCls.showPicking(t,i,n)):console.log("No atoms were found in 10 andstrom range")}return o}getAtomsFromPosition(e,t){let s,i=this.icn3d,n=i.icn3dui;for(s in null==t&&(t=1),i.dAtoms){let l=i.atoms[s];if(i.ions.hasOwnProperty(s)&&"sphere"===i.opts.ions){let s=n.parasCls.vdwRadii[l.elem.toUpperCase()];if(Math.abs(l.coord.x-e.x)-s>t)continue;if(Math.abs(l.coord.y-e.y)-s>t)continue;if(Math.abs(l.coord.z-e.z)-s>t)continue}else{if(l.coord.xe.x+t)continue;if(l.coord.ye.y+t)continue;if(l.coord.ze.z+t)continue}return l}return null}}class Is{constructor(e){this.icn3d=e}setControl(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s=this;e.WIDTH=e.container.width(),e.HEIGHT=e.container.height(),e.applyCenterCls.setWidthHeight(e.WIDTH,e.HEIGHT),e._zoomFactor=1,e.mouseChange=new THREE.Vector2(0,0),e.quaternion=new THREE.Quaternion(0,0,0,1),e.container.bind("contextmenu",(function(e){e.preventDefault()})),e.typetext=!1,$(document).bind("keyup",(function(t){16===t.keyCode&&(e.bShift=!1),17!==t.keyCode&&224!==t.keyCode&&91!==t.keyCode||(e.bCtrl=!1)})),$("input[type=text], textarea").focus((function(){e.typetext=!0})),$("input[type=text], textarea").blur((function(){e.typetext=!1})),$(document).bind("keydown",(async function(s){if((s.shiftKey||16===s.keyCode)&&(e.bShift=!0),(s.ctrlKey||17===s.keyCode||224===s.keyCode||91===s.keyCode)&&(e.bCtrl=!0),!e.bControlGl&&!e.controls||e.bControlGl&&!window.controls)return;e.bStopRotate=!0;let i=e.bShift?90:5;if(!e.typetext)if(90===s.keyCode){let s={};e.bControlGl&&!t.bNode?window.cam===e.perspectiveCamera?s._zoomFactor=.9:window.cam===e.orthographicCamera&&(e._zoomFactor<.1?e._zoomFactor=.1:e._zoomFactor>1&&(e._zoomFactor=1),s._zoomFactor=.8*e._zoomFactor,s._zoomFactor<.1&&(s._zoomFactor=.1)):e.cam===e.perspectiveCamera?s._zoomFactor=.9:e.cam===e.orthographicCamera&&(e._zoomFactor<.1?e._zoomFactor=.1:e._zoomFactor>1&&(e._zoomFactor=1),s._zoomFactor=.8*e._zoomFactor,s._zoomFactor<.1&&(s._zoomFactor=.1)),s.update=!0,e.bControlGl&&!t.bNode?window.controls.update(s):e.controls.update(s),e.bRender&&e.drawCls.render()}else if(88===s.keyCode){let s={};e.bControlGl&&!t.bNode?window.cam===e.perspectiveCamera?s._zoomFactor=1.03:window.cam===e.orthographicCamera&&(e._zoomFactor>10?e._zoomFactor=10:e._zoomFactor<1&&(e._zoomFactor=1),s._zoomFactor=1.01*e._zoomFactor,s._zoomFactor>10&&(s._zoomFactor=10)):e.cam===e.perspectiveCamera?s._zoomFactor=1.03:e.cam===e.orthographicCamera&&(e._zoomFactor>10?e._zoomFactor=10:e._zoomFactor<1&&(e._zoomFactor=1),s._zoomFactor=1.01*e._zoomFactor,s._zoomFactor>10&&(s._zoomFactor=10)),s.update=!0,e.bControlGl&&!t.bNode?window.controls.update(s):e.controls.update(s),e.bRender&&e.drawCls.render()}else if(76===s.keyCode){let t=new THREE.Vector3(0,1,0),s=-i/180*Math.PI;e.transformCls.setRotation(t,s)}else if(74===s.keyCode){let t=new THREE.Vector3(0,1,0),s=i/180*Math.PI;e.transformCls.setRotation(t,s)}else if(73===s.keyCode){let t=new THREE.Vector3(1,0,0),s=-i/180*Math.PI;e.transformCls.setRotation(t,s)}else if(77===s.keyCode){let t=new THREE.Vector3(1,0,0),s=i/180*Math.PI;e.transformCls.setRotation(t,s)}else 65===s.keyCode&&Object.keys(e.structures).length>1&&await e.alternateCls.alternateWrapper()})),e.container.bind("mouseup",(function(t){e.isDragging=!1})),e.container.bind("touchend",(function(t){e.isDragging=!1})),e.container.bind("mousedown",(function(s){if(e.isDragging=!0,e.scene){if(e.bStopRotate=!0,e.pk&&(s.altKey||s.ctrlKey||s.shiftKey||18===s.keyCode||16===s.keyCode||17===s.keyCode||224===s.keyCode||91===s.keyCode)){e.highlightlevel=e.pk;let t=!0;e.rayCls.rayCaster(s,t)}e.bControlGl&&!t.bNode?(window.controls.handleResize(),window.controls.update()):(e.controls.handleResize(),e.controls.update()),e.bRender&&e.drawCls.render()}})),e.container.bind("touchstart",(function(s){if(s.preventDefault(),e.isDragging=!0,!e.scene)return;e.bStopRotate=!0,$("#"+e.pre+"popup").hide();e.rayCls.rayCaster(s,!0),e.bControlGl&&!t.bNode?(window.controls.handleResize(),window.controls.update()):(e.controls.handleResize(),e.controls.update()),e.bRender&&e.drawCls.render()})),e.container.bind("mousemove touchmove",(function(e){s.mouseMove(e)})),e.container.bind("mousewheel",(function(s){s.preventDefault(),e.scene&&(e.bStopRotate=!0,e.bControlGl&&!t.bNode?(window.controls.handleResize(),window.controls.update()):(e.controls.handleResize(),e.controls.update()),e.bRender&&e.drawCls.render())})),e.container.bind("DOMMouseScroll",(function(s){s.preventDefault(),e.scene&&(e.bStopRotate=!0,e.bControlGl&&!t.bNode?(window.controls.handleResize(),window.controls.update()):(e.controls.handleResize(),e.controls.update()),e.bRender&&e.drawCls.render())}))}mouseMove(e){let t=this.icn3d,s=t.icn3dui;if(s.bNode)return;if(e.preventDefault(),!t.scene)return;$("#"+t.pre+"popup").hide();if(t.rayCls.rayCaster(e,!1),t.bControlGl&&!s.bNode){window.controls.handleResize(),window.controls.update();for(let e in window.icn3duiHash){let t=window.icn3duiHash[e].icn3d;t.bRender&&t.drawCls.render()}}else t.controls.handleResize(),t.controls.update(),t.bRender&&t.drawCls.render()}}class Ts{constructor(e){this.icn3d=e}showPicking(e,t,s){let i=this.icn3d,n=i.icn3dui;if(void 0!==n.cfg.cid&&0!=i.pk&&(i.pk=1),i.highlightlevel=i.pk,this.showPickingBase(e,t,s),0!=i.pk)if(void 0!==t&&void 0!==s){null!=n.cfg.showmenu&&1==n.cfg.showmenu&&(s+=n.htmlCls.MENU_HEIGHT);let l,r=1==i.pk?e.resn+e.resi+"@"+e.name:e.resn+e.resi,o=e.structure+"_"+e.chain;if(void 0!==i.structures&&Object.keys(i.structures).length>1?(r=o+" "+r,l=i.chainid2refpdbname&&i.chainid2refpdbname[o]?240:160,$("#"+i.pre+"popup").css("width",l+"px")):(l=i.chainid2refpdbname&&i.chainid2refpdbname[o]?160:80,$("#"+i.pre+"popup").css("width",l+"px")),i.chainid2refpdbname&&i.chainid2refpdbname[o]){let t=i.resid2refnum[o+"_"+e.resi];t&&(r+=", Ig: "+t)}$("#"+i.pre+"popup").html(r),$("#"+i.pre+"popup").css("top",s).css("left",t+20).show()}else{i.hlUpdateCls.updateHlAll();let t={};t.factor=i._zoomFactor,t.mouseChange=i.mouseChange,t.quaternion={},t.quaternion._x=parseFloat(i.quaternion._x).toPrecision(5),t.quaternion._y=parseFloat(i.quaternion._y).toPrecision(5),t.quaternion._z=parseFloat(i.quaternion._z).toPrecision(5),t.quaternion._w=parseFloat(i.quaternion._w).toPrecision(5),n.htmlCls.clickMenuCls.setLogCmd("pickatom "+e.serial,!0),i.selectionCls.saveSelInCommand(),i.bSphereCalc=!1,i.bHbondCalc=!1}}showPickingBase(e,t,s){this.icn3d.icn3dui,void 0===t&&void 0===s&&this.showPickingHilight(e)}getPickedAtomList(e,t){let s=this.icn3d;s.icn3dui;let i={};if(1===e)i[t.serial]=1;else if(2===e){let e=t.structure+"_"+t.chain+"_"+t.resi;i=s.residues[e]}else if(3===e)i=this.selectStrandHelixFromAtom(t);else if(4===e)i=this.select3ddomainFromAtom(t);else if(5===e){let e=t.structure+"_"+t.chain;i=s.chains[e]}return i}showPickingHilight(e){let t=this.icn3d,s=t.icn3dui;t.bShift||t.bCtrl||t.hlObjectsCls.removeHlObjects(),t.pickedAtomList=this.getPickedAtomList(t.pk,e),0===t.pk?t.bShowHighlight=!1:t.bShowHighlight=!0;let i=Object.keys(t.hAtoms).length==Object.keys(t.atoms).length?{}:s.hashUtilsCls.intHash(t.hAtoms,t.pickedAtomList),n=Object.keys(i).length;if(t.bShift||t.bCtrl)if(t.bShift){if(void 0===t.prevPickedAtomList)t.hAtoms=s.hashUtilsCls.unionHash(t.hAtoms,t.pickedAtomList);else{let e=t.firstAtomObjCls.getFirstAtomObj(t.prevPickedAtomList),i=t.firstAtomObjCls.getFirstAtomObj(t.pickedAtomList);if(e.structure+"_"+e.chain!=i.structure+"_"+i.chain)t.hAtoms=s.hashUtilsCls.unionHash(t.hAtoms,t.pickedAtomList);else{let e;e=s.hashUtilsCls.unionHash(e,t.prevPickedAtomList),e=s.hashUtilsCls.unionHash(e,t.pickedAtomList);let i=t.firstAtomObjCls.getFirstAtomObj(e),n=t.firstAtomObjCls.getLastAtomObj(e);for(let e=i.serial;e<=n.serial;++e)t.hAtoms[e]=1}}t.prevPickedAtomList=s.hashUtilsCls.cloneHash(t.pickedAtomList)}else t.bCtrl&&(t.hAtoms=n>0?s.hashUtilsCls.exclHash(t.hAtoms,t.pickedAtomList):s.hashUtilsCls.unionHash(t.hAtoms,t.pickedAtomList));else t.hAtoms=s.hashUtilsCls.cloneHash(t.pickedAtomList);t.hlObjectsCls.removeHlObjects(),t.hlObjectsCls.addHlObjects()}select3ddomainFromAtom(e){let t,s=this.icn3d,i=s.icn3dui,n=e.structure+"_"+e.chain,l=n+"_"+e.resi;for(let e in s.tddomains){let i=e.indexOf("_3d_domain");if(e.substr(0,i)==n&&-1!==Object.keys(s.tddomains[e]).indexOf(l)){t=e;break}}let r={};for(let e in s.tddomains[t])r=i.hashUtilsCls.unionHash(r,s.residues[e]);return r}selectStrandHelixFromAtom(e){let t=this.icn3d,s=t.icn3dui,i=e,n=e,l={},r=i.resi;if(!i.ssbegin&&!isNaN(i.resi)){for(let e=i.resi-1;e>0;--e){let s=i.structure+"_"+i.chain+"_"+e;if(!t.residues.hasOwnProperty(s))break;let n=t.firstAtomObjCls.getFirstCalphaAtomObj(t.residues[s]);if(r=n.resi,"coil"!==i.ss&&n.ss===i.ss&&n.ssbegin||"coil"===i.ss&&n.ss!==i.ss){"coil"===i.ss&&n.ss!==i.ss&&(r=parseInt(n.resi)+1);break}}for(let e=r;e<=i.resi;++e){let n=i.structure+"_"+i.chain+"_"+e;l=s.hashUtilsCls.unionHash(l,s.hashUtilsCls.hash2Atoms(t.residues[n],t.atoms))}}let o=n.resi,a=t.firstAtomObjCls.getLastAtomObj(t.chains[n.structure+"_"+n.chain]).resi;for(let e=parseInt(n.resi)+1;e<=parseInt(a);++e){let s=n.structure+"_"+n.chain+"_"+e;if(!t.residues.hasOwnProperty(s))break;let i=t.firstAtomObjCls.getFirstCalphaAtomObj(t.residues[s]);if(o=i.resi,"coil"!==n.ss&&i.ss===n.ss&&i.ssend||"coil"===n.ss&&i.ss!==n.ss){"coil"!==n.ss||i.ss===n.ss||isNaN(i.resi)||(o=i.resi-1);break}}for(let e=parseInt(n.resi)+1;e<=parseInt(o);++e){let i=n.structure+"_"+n.chain+"_"+e;l=s.hashUtilsCls.unionHash(l,s.hashUtilsCls.hash2Atoms(t.residues[i],t.atoms))}return l}}class Es{constructor(e){this.icn3d=e,this.xrSessionIsGranted=!1}createButton(e,t){let s=this.icn3d,i=s.icn3dui;t&&console.error('THREE.VRButton: The "options" parameter has been removed. Please set the reference space type via renderer.xr.setReferenceSpaceType() instead.');const n=document.createElement("button");function l(){n.style.display="",n.style.cursor="auto",n.style.left="calc(33% - 75px)",n.style.width="150px",n.onmouseenter=null,n.onmouseleave=null,n.onclick=null}let r=this;if("xr"in navigator)return n.id=i.pre+"VRButton",n.style.display="none",(o=n).style.position="absolute",o.style.bottom="20px",o.style.padding="12px 6px",o.style.border="1px solid #fff",o.style.borderRadius="4px",o.style.background="#000",o.style.color="#f8b84e",o.style.font="bold 13px sans-serif",o.style.textAlign="center",o.style.opacity="0.8",o.style.outline="none",o.style.zIndex="999",navigator.xr.isSessionSupported("immersive-vr").then((function(t){t?function(){let t=null;async function i(s){s.addEventListener("end",l),await e.xr.setSession(s),n.textContent="EXIT VR",t=s}function l(){s.transformCls.resetOrientation(),s.bVr=!1,s.drawCls.draw(),t.removeEventListener("end",l),n.textContent="ENTER VR",t=null}n.style.display="",n.style.cursor="pointer",n.style.left="calc(33% - 50px)",n.style.width="100px",n.textContent="ENTER VR",n.onmouseenter=function(){n.style.opacity="1.0"},n.onmouseleave=function(){n.style.opacity="0.8"},n.onclick=function(){if(s.bImpo=!1,s.bVr=!0,s.drawCls.draw(s.bVr),null===t){const e={optionalFeatures:["local-floor","bounded-floor","hand-tracking","layers"]};navigator.xr.requestSession("immersive-vr",e).then(i)}else t.end()}}():(l(),n.style.display="none"),t&&r.xrSessionIsGranted&&n.click()})).catch((function(e){l(),console.warn("Exception when trying to call xr.isSessionSupported",e),n.style.display="none"})),n;return document.createElement("span");var o}registerSessionGrantedListener(){"xr"in navigator&&navigator.xr.addEventListener("sessiongranted",(()=>{this.xrSessionIsGranted=!0}))}}class Ps{constructor(e){this.icn3d=e,this.xrSessionIsGranted=!1}createButton(e,t={}){let s=this.icn3d,i=s.icn3dui;const n=document.createElement("button");function l(){n.style.display="",n.style.cursor="auto",n.style.left="calc(66% - 50px)",n.style.width="150px",n.onmouseenter=null,n.onmouseleave=null,n.onclick=null}function r(e){e.style.position="absolute",e.style.bottom="20px",e.style.padding="12px 6px",e.style.border="1px solid #fff",e.style.borderRadius="4px",e.style.background="#000",e.style.color="#f8b84e",e.style.font="bold 13px sans-serif",e.style.textAlign="center",e.style.opacity="0.8",e.style.outline="none",e.style.zIndex="999"}if(i.utilsCls.isAndroid()&&i.utilsCls.isChrome()){if("xr"in navigator)return n.id=i.pre+"ARButton",n.style.display="none",r(n),navigator.xr.isSessionSupported("immersive-ar").then((function(i){i?function(){if(void 0===t.domOverlay){const e=document.createElement("div");e.style.display="none",document.body.appendChild(e);const s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("width",38),s.setAttribute("height",38),s.style.position="absolute",s.style.right="20px",s.style.top="20px",s.addEventListener("click",(function(){i.end()})),e.appendChild(s);const n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d","M 12,12 L 28,28 M 28,12 12,28"),n.setAttribute("stroke","#fff"),n.setAttribute("stroke-width",2),s.appendChild(n),void 0===t.optionalFeatures&&(t.optionalFeatures=[]),t.optionalFeatures.push("dom-overlay"),t.domOverlay={root:e}}let i=null;async function l(s){s.addEventListener("end",r),e.xr.setReferenceSpaceType("local"),await e.xr.setSession(s),n.textContent="STOP AR",t.domOverlay.root.style.display="",i=s}function r(){s.transformCls.resetOrientation(),s.bAr=!1,s.drawCls.draw(),i.removeEventListener("end",r),n.textContent="START AR",t.domOverlay.root.style.display="none",i=null}n.style.display="",n.style.cursor="pointer",n.style.left="calc(66% - 50px)",n.style.width="100px",n.textContent="START AR",n.onmouseenter=function(){n.style.opacity="1.0"},n.onmouseleave=function(){n.style.opacity="0.8"},n.onclick=function(){s.bImpo=!1,s.opts.background="transparent",s.bAr=!0,s.drawCls.draw(s.bAr),null===i?navigator.xr.requestSession("immersive-ar",t).then(l):i.end()}}():(l(),n.style.display="none")})).catch((function(e){l(),console.warn("Exception when trying to call xr.isSessionSupported",e),n.style.display="none"})),n;return document.createElement("span")}return n.id=i.pre+"ARButton",n.style.display="none",r(n),l(),n.style.display="none",n}}class Ms{constructor(e){let t,s,i,n=e;if(this.icn3dui=e,this.id=this.icn3dui.pre+"canvas",this.pre=this.icn3dui.pre,this.container=$("#"+this.id),this.oriContainer=$("#"+this.id),this.bControlGl=!1,this.maxatomcnt=1e5,this.overdraw=0,this.bDrawn=!1,this.bOpm=!1,this.crossstrucinter=0,this.bSecondaryStructure=!1,this.bHighlight=1,this.renderOrderPicking=-1,this.bInitial=!0,this.bDoublecolor=!1,this.originSize=1,this.ALTERNATE_STRUCTURE=-1,this.bUsePdbNum=!0,!this.icn3dui.bNode){let e=document.createElement("canvas");t=!(!window.WebGLRenderingContext||!e.getContext("webgl")&&!e.getContext("experimental-webgl")),e.remove(),e=document.createElement("canvas"),s=!(!window.WebGLRenderingContext||!e.getContext("webgl2")),e.remove(),i="xr"in navigator,t?(s&&i?(this.renderer=new THREE.WebGLRenderer({canvas:this.oriContainer.get(0),antialias:!0,preserveDrawingBuffer:!0,sortObjects:!1,alpha:!0}),this.renderer.xr.enabled=!0):this.renderer=new THREE.WebGL1Renderer({canvas:this.oriContainer.get(0),antialias:!0,preserveDrawingBuffer:!0,sortObjects:!1,alpha:!0}),this.overdraw=0):alert("Currently your web browser has a problem on WebGL. If you are using Chrome, open a new tab for the same URL and WebGL may work again.")}this.frac=new THREE.Color(.1,.1,.1),this.shininess=40,this.emissive=1118481,this.light1=.8,this.light2=.4,this.light3=.2,this.lineRadius=.1,this.coilWidth=.3,this.cylinderRadius=.4,this.crosslinkRadius=.4,this.traceRadius=.4,this.dotSphereScale=.3,this.sphereRadius=1.5,this.cylinderHelixRadius=1.6,this.ribbonthickness=.2,this.helixSheetWidth=1.3,this.nucleicAcidWidth=.8,this.scaleFactor=1,this.labelScale=1,this.resizeRatioX=1,this.resizeRatioY=1,this.bImpo=!0,this.bInstanced=!0,this.chainMissingResidueArray={},this._zoomFactor=1,this.transparentRenderOrder=!1,this.AFUniprotVersion="v4",this.defaultPdbId="stru",this.icn3dui.bNode||(s&&i?(this.bExtFragDepth=!0,this.bImpo=!0,this.bInstanced=!0):(this.bExtFragDepth=this.renderer.extensions.get("EXT_frag_depth"),this.bExtFragDepth?console.log("EXT_frag_depth is supported. All spheres and cylinders are drawn using shaders."):(this.bImpo=!1,console.log("EXT_frag_depth is NOT supported. All spheres and cylinders are drawn using geometry.")),this.bInstanced=this.renderer.extensions.get("ANGLE_instanced_arrays"),this.bInstanced?console.log("ANGLE_instanced_arrays is supported. Assembly is drawn with one copy of the asymmetric unit using hardware instancing."):console.log("ANGLE_instanced_arrays is NOT supported. Assembly is drawn by making copies of the asymmetric unit."))),this.posArray=new Array,this.colorArray=new Array,this.pos2Array=new Array,this.color2Array=new Array,this.radiusArray=new Array,this.posArraySphere=new Array,this.colorArraySphere=new Array,this.radiusArraySphere=new Array,this.axis=!1,this.pk=1,this.highlightlevel=1,this.pickpair=!1,this.pAtomNum=0,this.pAtom=void 0,this.pAtom2=void 0,this.bCtrl=!1,this.bShift=!1,this.bStopRotate=!1,this.bCalphaOnly=!1,this.bConsiderNeighbors=!1,this.bShowCrossResidueBond=!0,this.bExtrude=!0,this.effects={none:this.renderer},this.maxD=500,this.oriMaxD=this.maxD,this.cam_z=2*this.maxD,this.commands=[],this.optsHistory=[],this.logs=[],this.bRender=!0,this.hColor=new THREE.Color(16777011),this.sphereGeometry=new THREE.SphereGeometry(1,32,32),this.boxGeometry=new THREE.BoxGeometry(1,1,1),this.cylinderGeometry=new THREE.CylinderGeometry(1,1,1,32,1),this.cylinderGeometryOutline=new THREE.CylinderGeometry(1,1,1,32,1,!0),this.axisDIV=15,this.strandDIV=6,this.tubeDIV=8,this.nucleicAcidStrandDIV=6,this.linewidth=1,this.hlLineRadius=.1,this.threshbox=180,this.maxAtoms3DMultiFile=4e4,this.tsHbond=3.8,this.tsIonic=6,this.tsContact=4,this.tsHalogen=3.8,this.tsPication=6,this.tsPistacking=5.5,this.LABELSIZE=30,this.rayThreshold=.5,this.colorBlackbkgd="#ffff00",this.colorWhitebkgd="#000000",this.optsOri={},this.optsOri.camera="perspective",this.optsOri.background="black",this.optsOri.color="chain",this.optsOri.proteins="ribbon",this.optsOri.sidec="nothing",this.optsOri.nucleotides="nucleotide cartoon",this.optsOri.ntbase="nothing",this.optsOri.surface="nothing",this.optsOri.opacity="1.0",this.optsOri.wireframe="no",this.optsOri.map="nothing",this.optsOri.mapwireframe="yes",this.optsOri.emmap="nothing",this.optsOri.emmapwireframe="yes",this.optsOri.phimap="nothing",this.optsOri.phimapwireframe="yes",this.optsOri.phisurface="nothing",this.optsOri.phisurftype="nothing",this.optsOri.phisurfop="1.0",this.optsOri.phisurfwf="yes",this.optsOri.chemicals="stick",this.optsOri.water="nothing",this.optsOri.ions="sphere",this.optsOri.hbonds="no",this.optsOri.saltbridge="no",this.optsOri.contact="no",this.optsOri.halogen="no",this.optsOri["pi-cation"]="no",this.optsOri["pi-stacking"]="no",this.optsOri.ssbonds="yes",this.optsOri.clbonds="yes",this.optsOri.rotationcenter="molecule center",this.optsOri.axis="no",this.optsOri.fog="no",this.optsOri.slab="no",this.optsOri.pk="residue",this.optsOri.chemicalbinding="hide",this.opts=n.hashUtilsCls.cloneHash(this.optsOri),this.sheetcolor="green",this.bShowHighlight=!0,this.mapData={},this.bFullUi=!0,this.divid=this.icn3dui.cfg.divid,this.inputid="",this.setOperation="or",this.ROT_DIR="right",this.currSelectedSets=[],this.selectedResidues={},this.ncbi2resid={},this.resid2ncbi={},this.shapeCmdHash={},this.bHideSelection=!0,this.bSelectResidue=!1,this.bSelectAlignResidue=!1,this.bAnnoShown=!1,this.bSetChainsAdvancedMenu=!1,this.b2DShown=!1,this.bCrashed=!1,this.bAddCommands=!0,this.bAddLogs=!0,this.bNotLoadStructure=!1,this.InputfileData="",this.bVr=!1,this.bAr=!1,this.startColor="blue",this.midColor="white",this.endColor="red",this.startValue=0,this.midValue=50,this.endValue=100,this.crosslinkRadius=.4,this.sceneCls=new Ie(this),this.cameraCls=new Te(this),this.fogCls=new Ee(this),this.boxCls=new Pe(this),this.brickCls=new Me(this),this.curveStripArrowCls=new De(this),this.curveCls=new He(this),this.cylinderCls=new Fe(this),this.lineCls=new Le(this),this.reprSubCls=new Ne(this),this.sphereCls=new qe(this),this.stickCls=new Ue(this),this.strandCls=new $e(this),this.stripCls=new je(this),this.tubeCls=new Be(this),this.cartoonNuclCls=new ze(this),this.surfaceCls=new Qe(this),this.labelCls=new Ve(this),this.axesCls=new We(this),this.glycanCls=new Ye(this),this.applyCenterCls=new Ze(this),this.applyClbondsCls=new et(this),this.applyMissingResCls=new tt(this),this.applyDisplayCls=new st(this),this.applyMapCls=new rt(this),this.applyOtherCls=new it(this),this.applySsbondsCls=new nt(this),this.applySymdCls=new lt(this),this.hlObjectsCls=new Ht(this),this.residueLabelsCls=new ot(this),this.alternateCls=new ct(this),this.drawCls=new ht(this),this.firstAtomObjCls=new ms(this),this.impostorCls=new at(this),this.instancingCls=new dt(this),this.contactCls=new pt(this),this.hBondCls=new mt(this),this.piHalogenCls=new ut(this),this.saltbridgeCls=new gt(this),this.loadPDBCls=new ls(this),this.vastplusCls=new rs(this),this.transformCls=new Ss(this),this.setStyleCls=new ft(this),this.setColorCls=new bt(this),this.threeDPrintCls=new ks(this),this.export3DCls=new Os(this),this.annoCddSiteCls=new vt(this),this.annoContactCls=new _t(this),this.annoPTMCls=new wt(this),this.annoCrossLinkCls=new St(this),this.annoDomainCls=new At(this),this.annoSnpClinVarCls=new xt(this),this.annoSsbondCls=new kt(this),this.annoTransMemCls=new Ot(this),this.domain3dCls=new Rt(this),this.addTrackCls=new It(this),this.annotationCls=new Tt(this),this.showAnnoCls=new Et(this),this.showSeqCls=new Pt(this),this.hlSeqCls=new Mt(this),this.hlUpdateCls=new Dt(this),this.lineGraphCls=new Ft(this),this.getGraphCls=new Nt(this),this.showInterCls=new qt(this),this.viewInterPairsCls=new Ut(this),this.drawGraphCls=new $t(this),this.contactMapCls=new jt(this),this.alignParserCls=new Bt(this),this.chainalignParserCls=new zt(this),this.dsn6ParserCls=new Gt(this),this.mmcifParserCls=new Vt(this),this.mmdbParserCls=new Wt(this),this.mmtfParserCls=new Yt(this),this.mol2ParserCls=new Xt(this),this.opmParserCls=new Kt(this),this.pdbParserCls=new Jt(this),this.sdfParserCls=new Qt(this),this.xyzParserCls=new Zt(this),this.realignParserCls=new es(this),this.densityCifParserCls=new ts(this),this.ParserUtilsCls=new ss(this),this.loadAtomDataCls=new is(this),this.setSeqAlignCls=new ns(this),this.applyCommandCls=new os(this),this.definedSetsCls=new as(this),this.legendTableCls=new yt(this),this.loadScriptCls=new ds(this),this.selByCommCls=new cs(this),this.selectionCls=new hs(this),this.resid2specCls=new ps(this),this.delphiCls=new us(this),this.dsspCls=new gs(this),this.refnumCls=new Lt(this),this.scapCls=new fs(this),this.symdCls=new bs(this),this.alignSWCls=new Cs(this),this.analysisCls=new ys(this),this.resizeCanvasCls=new ws(this),this.saveFileCls=new As(this),this.setOptionCls=new Ct(this),this.shareLinkCls=new xs(this),this.diagram2dCls=new vs(this),this.cartoon2dCls=new _s(this),this.rayCls=new Rs(this),this.controlCls=new Is(this),this.pickingCls=new Ts(this),this.VRButtonCls=new Es(this),this.ARButtonCls=new Ps(this),this.matShader=this.setColorCls.setOutlineColor("yellow")}}Ms.prototype.init=function(e){this.init_base(),this.molTitle="",this.ssbondpnts={},this.clbondpnts={},this.biomtMatrices=[],this.bAssembly=!0,this.bDrawn=!1,this.bSecondaryStructure=!1,this.bHighlight=1,this.axes=[]},Ms.prototype.init_base=function(e){this.resetConfig(),this.structures={},this.chains={},this.tddomains={},this.residues={},this.secondaries={},this.alnChains={},this.chainsSeq={},this.chainsColor={},this.chainsGene={},this.chainsAn={},this.chainsAnTitle={},this.chainsMapping={},this.resid2refnum={},this.residIgLoop={},this.refnum2residArray={},this.bShowRefnum=!1,this.alnChainsSeq={},this.alnChainsAnno={},this.alnChainsAnTtl={},this.pickedAtomList={},this.prevHighlightObjects=[],this.prevHighlightObjects_ghost=[],this.prevSurfaces=[],this.prevMaps=[],this.prevEmmaps=[],this.prevPhimaps=[],this.prevOtherMesh=[],this.defNames2Residues={},this.defNames2Atoms={},this.defNames2Descr={},this.defNames2Command={},this.residueId2Name={},this.atoms={},this.dAtoms={},this.hAtoms={},this.proteins={},this.sidec={},this.ntbase={},this.nucleotides={},this.nucleotidesO3={},this.chemicals={},this.ions={},this.water={},this.calphas={},this.hbondpnts=[],this.saltbridgepnts=[],this.contactpnts=[],this.stabilizerpnts=[],this.halogenpnts=[],this.picationpnts=[],this.pistackingpnts=[],this.distPnts=[],this.doublebonds={},this.triplebonds={},this.aromaticbonds={},this.atomPrevColors={},this.style2atoms={},this.labels={},this.lines={},this.resids2inter={},this.resids2interAll={},this.transformCls.rotateCount=0,this.transformCls.rotateCountMax=20,e&&(this.commands=[]),this.axes=[],this.bGlycansCartoon=0,this.bMembrane=1,this.bCmdWindow=0,this.chainMissingResidueArray={},this.nTotalGap=0},Ms.prototype.reinitAfterLoad=function(){let e=this,t=e.icn3dui;e.resetConfig(),e.setStyleCls.setAtomStyleByOptions(),e.setColorCls.setColorByOptions(e.opts,e.atoms),e.dAtoms=t.hashUtilsCls.cloneHash(e.atoms),e.hAtoms=t.hashUtilsCls.cloneHash(e.atoms),e.prevHighlightObjects=[],e.prevHighlightObjects_ghost=[],e.prevSurfaces=[],e.prevMaps=[],e.prevEmmaps=[],e.prevPhimaps=[],e.prevOtherMesh=[],e.labels={},e.lines={},e.shapeCmdHash={},e.bAssembly=!0},Ms.prototype.resetConfig=function(){let e=this,t=e.icn3dui;if(this.opts=t.hashUtilsCls.cloneHash(this.optsOri),void 0===t.cfg.align&&void 0===t.cfg.chainalign||(this.opts.color="identity",this.opts.proteins="c alpha trace",this.opts.nucleotides="o3 trace"),void 0!==t.cfg.cid&&(this.opts.color="atom",this.opts.pk="atom",this.opts.chemicals="ball and stick"),(void 0!==t.cfg.afid||e.bEsmfold)&&(this.opts.color="confidence"),void 0!==t.cfg.blast_rep_id&&(this.opts.color="conservation"),void 0!==t.cfg.mmdbafid){let s=t.cfg.mmdbafid.split(",");if(s.length>1)e.opts.color="structure";else if(1==s.length){let t=s[0];isNaN(t)&&t.length>5?this.opts.color="confidence":e.opts.color="chain"}}void 0!==t.cfg.options&&$.extend(this.opts,t.cfg.options)};class Ds{constructor(e){this.cfg=e,this.pre=this.cfg.divid+"_",this.REVISION="3.28.4",this.bNode=Object.keys(window).length<2,void 0===this.cfg.command&&(this.cfg.command=""),void 0===this.cfg.width&&(this.cfg.width="100%"),void 0===this.cfg.height&&(this.cfg.height="100%"),void 0===this.cfg.resize&&(this.cfg.resize=!0),void 0===this.cfg.showmenu&&(this.cfg.showmenu=!0),void 0===this.cfg.showtitle&&(this.cfg.showtitle=!0),void 0===this.cfg.showcommand&&(this.cfg.showcommand=!0),void 0===this.cfg.mobilemenu&&(this.cfg.mobilemenu=!1),void 0===this.cfg.imageonly&&(this.cfg.imageonly=!1),void 0===this.cfg.closepopup&&(this.cfg.closepopup=!1),void 0===this.cfg.showanno&&(this.cfg.showanno=!1),void 0===this.cfg.showseq&&(this.cfg.showseq=!1),void 0===this.cfg.showalignseq&&(this.cfg.showalignseq=!1),void 0===this.cfg.show2d&&(this.cfg.show2d=!1),void 0===this.cfg.showsets&&(this.cfg.showsets=!1),void 0===this.cfg.rotate&&(this.cfg.rotate="right"),void 0===this.cfg.hidelicense&&(this.cfg.hidelicense=!1),this.hashUtilsCls=new t(this),this.utilsCls=new s(this),this.parasCls=new i(this),this.myEventCls=new n(this),this.rmsdSuprCls=new l(this),this.subdivideCls=new r(this),this.convertTypeCls=new o(this),this.htmlCls=new g(this)}allCustomEvents(){}}Ds.prototype.show3DStructure=async function(e){let t=this;t.cfg.menuicon?(t.htmlCls.wifiStr=' ',t.htmlCls.licenseStr=' '):(t.htmlCls.wifiStr="",t.htmlCls.licenseStr=""),t.setIcn3d();let s=t.icn3d;t.utilsCls.isSessionStorageSupported()&&s.setStyleCls.getCommandsBeforeCrash();let i=t.htmlCls.WIDTH,n=t.htmlCls.HEIGHT;t.oriWidth=i,t.oriHeight=n,t.htmlCls.eventsCls.allEventFunctions(),this.allCustomEvents();let l=0;if((null==t.cfg.showmenu||t.cfg.showmenu)&&(l+=t.htmlCls.MENU_HEIGHT),(null==t.cfg.showcommand||t.cfg.showcommand)&&(l+=t.htmlCls.CMD_HEIGHT),null!=t.cfg.showmenu&&0==t.cfg.showmenu?t.htmlCls.setMenuCls.hideMenu():t.htmlCls.setMenuCls.showMenu(),null!=t.cfg.showtitle&&0==t.cfg.showtitle?$("#"+s.pre+"title").hide():$("#"+s.pre+"title").show(),$("#"+s.pre+"viewer").width(i).height(parseInt(n)+l),$("#"+s.pre+"canvas").width(i).height(parseInt(n)),$("#"+s.pre+"canvas").resizable({resize:function(e,i){t.htmlCls.WIDTH=i.size.width,t.htmlCls.HEIGHT=i.size.height,void 0===s||t.icn3d.bFullscreen||s.resizeCanvasCls.resizeCanvas(t.htmlCls.WIDTH,t.htmlCls.HEIGHT,!0)}}),void 0!==t.cfg.usepdbnum?t.icn3d.bUsePdbNum=t.cfg.usepdbnum:void 0!==t.cfg.date?t.icn3d.bUsePdbNum=parseInt(t.cfg.date)>=20201222:"1tup"==t.cfg.mmdbid&&1==t.cfg.showanno&&1==t.cfg.show2d&&1==t.cfg.showsets||"118496"==t.cfg.mmdbid&&0==t.cfg.showanno&&-1!=t.cfg.inpara.indexOf("bu=1")||"163605,1,91105,1,1,1"==t.cfg.align&&-1!=t.cfg.inpara.indexOf("atype=1")?t.icn3d.bUsePdbNum=!1:t.icn3d.bUsePdbNum=!0,t.cfg.replay?(s.bReplay=1,$("#"+s.pre+"replay").show()):(s.bReplay=0,$("#"+s.pre+"replay").hide()),t.utilsCls.isMobile()&&(s.threshbox=60),t.cfg.controlGl&&(s.bControlGl=!0,s.container=s.bControlGl&&!t.bNode?$(document):$("#"+s.id)),s.setStyleCls.handleContextLost(),s.applyCenterCls.setWidthHeight(i,n),s.ori_chemicalbinding=s.opts.chemicalbinding,void 0!==t.cfg.bCalphaOnly&&(s.bCalphaOnly=t.cfg.bCalphaOnly),s.opts=t.hashUtilsCls.cloneHash(s.opts),s.STATENUMBER=s.commands.length,t.utilsCls.isSessionStorageSupported()&&s.bCrashed){s.bCrashed=!1;let e=s.commandsBeforeCrash.split("|||")[0],i=e.substr(e.lastIndexOf(" ")+1);if(i===t.cfg.mmtfid||i===t.cfg.pdbid||i===t.cfg.opmid||i===t.cfg.mmdbid||i===t.cfg.gi||i===t.cfg.blast_rep_id||i===t.cfg.cid||i===t.cfg.mmcifid||i===t.cfg.align||i===t.cfg.chainalign||i===t.cfg.mmdbafid)return void await s.loadScriptCls.loadScript(s.commandsBeforeCrash,!0)}if(s.molTitle="",s.loadCmd,t.htmlCls.clickMenuCls.getHiddenMenusFromCache(),t.htmlCls.clickMenuCls.applyShownMenus(),e){if(s.init(),s.bInputfile=!0,s.InputfileType="pdb",s.InputfileData=s.InputfileData?s.InputfileData+"\nENDMDL\n"+e:e,await s.pdbParserCls.loadPdbData(e),void 0!==t.cfg.resdef&&void 0!==t.cfg.chains){let e=Object.keys(s.structures),i=t.cfg.chains.split(" | "),n=[];if(e.length==i.length){for(let t=0,s=e.length;t0&&(l+=","),l+=n[e].substr(0,n[e].indexOf("_"));s.chainidArray=[e].concat(n),s.chainidArray=s.chainalignParserCls.addPostfixForChainids(s.chainidArray),t.htmlCls.clickMenuCls.setLogCmd("resdef "+t.cfg.resdef,!0),s.loadCmd="vast_search_chainid "+s.chainidArray,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),s.bMmdbafid=!0;let r=!0;await s.chainalignParserCls.downloadMmdbAf(l,r)}}else if(void 0!==t.cfg.url){s.bInputUrlfile=!0;let e=t.cfg.url.split("|"),i=e[0],n=e[1];s.molTitle="",s.inputid=n,s.inputurl="type="+i+"&url="+encodeURIComponent(n),s.loadCmd="load url "+n+" | type "+i,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.pdbParserCls.downloadUrl(n,i,t.cfg.command)}else if(void 0!==t.cfg.mmtfid)s.inputid=t.cfg.mmtfid,s.loadCmd="load mmtf "+t.cfg.mmtfid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmtfParserCls.downloadMmtf(t.cfg.mmtfid);else if(void 0!==t.cfg.pdbid)s.inputid=t.cfg.pdbid,s.loadCmd="load pdb "+t.cfg.pdbid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.pdbParserCls.downloadPdb(t.cfg.pdbid);else if(void 0!==t.cfg.afid){s.inputid=t.cfg.afid,s.loadCmd="load af "+t.cfg.afid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0);let e=!0;await s.pdbParserCls.downloadPdb(t.cfg.afid,e)}else if(void 0!==t.cfg.opmid)s.inputid=t.cfg.opmid,s.loadCmd="load opm "+t.cfg.opmid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.opmParserCls.downloadOpm(t.cfg.opmid);else if(void 0!==t.cfg.mmdbid)s.inputid=t.cfg.mmdbid,s.loadCmd="load mmdb "+t.cfg.mmdbid+" | parameters "+t.cfg.inpara,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmdbParserCls.downloadMmdb(t.cfg.mmdbid);else if(void 0!==t.cfg.gi)s.loadCmd="load gi "+t.cfg.gi,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmdbParserCls.downloadGi(t.cfg.gi);else if(void 0!==t.cfg.refseqid)s.inputid=t.cfg.refseqid,s.loadCmd="load refseq "+t.cfg.refseqid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmdbParserCls.downloadRefseq(t.cfg.refseqid);else if(void 0!==t.cfg.protein)s.inputid=t.cfg.protein,s.loadCmd="load protein "+t.cfg.protein,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmdbParserCls.downloadProteinname(t.cfg.protein);else if(void 0!==t.cfg.blast_rep_id)if(s.inputid=t.cfg.query_id+","+t.cfg.blast_rep_id,t.cfg.oriQuery_id=t.cfg.query_id,t.cfg.oriBlast_rep_id=t.cfg.blast_rep_id,"Query"!==t.cfg.query_id.substr(0,5)&&void 0===t.cfg.rid)"icn3d"==t.cfg.from&&"1TSR_A"==t.cfg.blast_rep_id&&"NP_001108451.1"==t.cfg.query_id&&(t.cfg.command="view annotations; set annotation cdd; set annotation site; set view detailed view; select chain 1TSR_A; show selection"),"smithwm"==t.cfg.alg?(s.loadCmd="load seq_struct_ids_smithwm "+t.cfg.query_id+","+t.cfg.blast_rep_id,s.bSmithwm=!0):"local_smithwm"==t.cfg.alg?(s.loadCmd="load seq_struct_ids_local_smithwm "+t.cfg.query_id+","+t.cfg.blast_rep_id,s.bLocalSmithwm=!0):(s.loadCmd="load seq_struct_ids "+t.cfg.query_id+","+t.cfg.blast_rep_id,s.bSmithwm=!1,s.bLocalSmithwm=!1),t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmdbParserCls.downloadBlast_rep_id(t.cfg.query_id+","+t.cfg.blast_rep_id);else if(void 0!==t.cfg.rid){let e="https://blast.ncbi.nlm.nih.gov/Blast.cgi?RESULTS_FILE=on&FORMAT_TYPE=JSON2_S&FORMAT_OBJECT=Alignment&CMD=Get&RID="+t.cfg.rid,i=await t.getAjaxPromise(e,"json",!1,"The RID "+t.cfg.rid+" may have expired...");for(let e=0,n=i.BlastOutput2.length;e
    ",s="All atoms  ";e.utilsCls.setViewerWidthHeight(e),e.utilsCls.isMobile()||e.cfg.mobilemenu?e.htmlCls.setMenuCls.setTopMenusHtmlMobile(e.cfg.divid,t,s):e.htmlCls.setMenuCls.setTopMenusHtml(e.cfg.divid,t,s),e.icn3d=new Ms(e),e.icn3d.controlCls.setControl(),e.setDialogAjax()},Ds.prototype.getMmtfPromise=function(e){return new Promise((function(t,s){MMTF.fetch(e,(async function(e){t(e)}),(function(e){s("error")}))}))},Ds.prototype.getMmtfReducedPromise=function(e){return new Promise((function(t,s){MMTF.fetchReduced(e,(async function(e){t(e)}),(function(e){s("error")}))}))},Ds.prototype.getXMLHttpRqstPromise=function(e,t,s,i){let n=this;return new Promise((function(l,r){let o=new XMLHttpRequest;o.open(t,e,!0),o.responseType=s,o.onreadystatechange=function(){if(4==this.readyState)if(200==this.status){let e=o.response;l(e)}else"2fofc"==i||"fofc"==i?alert("Density server at EBI has no corresponding electron density map for this structure."):"em"==i?alert("Density server at EBI has no corresponding EM density map for this structure."):"rcsbEdmaps"==i?alert("RCSB server has no corresponding eletron density map for this structure."):alert("The "+i+" file is unavailable..."),r("error");else n.icn3d.ParserUtilsCls.showLoading()},o.send()}))},Ds.prototype.getAjaxPromise=function(e,t,s,i,n,l,r){let o=this;return new Promise((function(r,a){$.ajax({url:e,dataType:t,cache:!0,beforeSend:function(){s&&o.icn3d.ParserUtilsCls.showLoading()},complete:function(){l&&o.icn3d.ParserUtilsCls.hideLoading()},success:function(e){r(e)},error:function(){i&&alert(i),n&&console.log(n),a("error")}})}))},Ds.prototype.getAjaxPostPromise=async function(e,t,s,i,n,l,r,o){let a=this;return r=r||"json",new Promise((function(o,d){$.ajax({url:e,type:"POST",data:t,dataType:r,cache:!0,beforeSend:function(){s&&a.icn3d.ParserUtilsCls.showLoading()},complete:function(){l&&a.icn3d.ParserUtilsCls.hideLoading()},success:function(e){o(e)},error:function(){i&&alert(i),n&&console.log(n),d("error")}})}))},Ds.prototype.setDialogAjax=function(){this.bNode||$.ui.dialog.prototype._makeDraggableBase||($.ui.dialog.prototype._makeDraggableBase=$.ui.dialog.prototype._makeDraggable,$.ui.dialog.prototype._makeDraggable=function(){this._makeDraggableBase(),this.uiDialog.draggable("option","containment",!1)}),$.ajaxTransport("+binary",(function(e,t,s){if(window.FormData&&(e.dataType&&"binary"==e.dataType||e.data&&(window.ArrayBuffer&&e.data instanceof ArrayBuffer||window.Blob&&e.data instanceof Blob)))return{send:function(t,s){let i=new XMLHttpRequest,n=e.url,l=e.type,r=e.async||!0,o=e.responseType||"blob",a=e.data||null;i.addEventListener("load",(function(){let t={};t[e.dataType]=i.response,s(i.status,i.statusText,t,i.getAllResponseHeaders())})),i.open(l,n,r);for(let e in t)i.setRequestHeader(e,t[e]);i.responseType=o,i.send(a)},abort:function(){s.abort()}}}))};return e.ARButton=Ps,e.AddTrack=It,e.AlignParser=Bt,e.AlignSW=Cs,e.AlignSeq=m,e.Alternate=ct,e.Analysis=ys,e.AnnoCddSite=vt,e.AnnoContact=_t,e.AnnoCrossLink=St,e.AnnoDomain=At,e.AnnoSnpClinVar=xt,e.AnnoSsbond=kt,e.AnnoTransMem=Ot,e.Annotation=Tt,e.ApplyCenter=Ze,e.ApplyClbonds=et,e.ApplyCommand=os,e.ApplyDisplay=st,e.ApplyMap=rt,e.ApplyOther=it,e.ApplySsbonds=nt,e.ApplySymd=lt,e.Axes=We,e.Box=Pe,e.Brick=Me,e.Camera=Te,e.CartoonNucl=ze,e.ChainalignParser=zt,e.ClickMenu=a,e.Contact=pt,e.Control=Is,e.ConvertTypeCls=o,e.Curve=He,e.CurveStripArrow=De,e.Cylinder=Fe,e.DefinedSets=as,e.Delphi=us,e.DensityCifParser=ts,e.Diagram2d=vs,e.Dialog=c,e.Domain3d=Rt,e.Draw=ht,e.DrawGraph=$t,e.Dsn6Parser=Gt,e.Dssp=gs,e.ElectronMap=Je,e.Events=p,e.Export3D=Os,e.FirstAtomObj=ms,e.Fog=Ee,e.GetGraph=Nt,e.Glycan=Ye,e.HBond=mt,e.HashUtilsCls=t,e.HlObjects=Ht,e.HlSeq=Mt,e.HlUpdate=Dt,e.Html=g,e.Impostor=at,e.Instancing=dt,e.Label=Ve,e.Line=Le,e.LineGraph=Ft,e.LoadAtomData=is,e.LoadPDB=ls,e.LoadScript=ds,e.MarchingCube=Xe,e.MmcifParser=Vt,e.MmdbParser=Wt,e.MmtfParser=Yt,e.Mol2Parser=Xt,e.MyEventCls=n,e.OpmParser=Kt,e.ParasCls=i,e.ParserUtils=ss,e.PdbParser=Jt,e.PiHalogen=ut,e.Picking=Ts,e.ProteinSurface=Ke,e.Ray=Rs,e.RealignParser=es,e.Refnum=Lt,e.ReprSub=Ne,e.Resid2spec=ps,e.ResidueLabels=ot,e.ResizeCanvas=ws,e.RmsdSuprCls=l,e.Saltbridge=gt,e.SaveFile=As,e.Scap=fs,e.Scene=Ie,e.SdfParser=Qt,e.SelectByCommand=cs,e.Selection=hs,e.SetColor=bt,e.SetDialog=h,e.SetHtml=u,e.SetMenu=d,e.SetOption=Ct,e.SetSeqAlign=ns,e.SetStyle=ft,e.ShareLink=xs,e.ShowAnno=Et,e.ShowInter=qt,e.ShowSeq=Pt,e.Sphere=qe,e.Stick=Ue,e.Strand=$e,e.Strip=je,e.SubdivideCls=r,e.Surface=Qe,e.Symd=bs,e.ThreeDPrint=ks,e.Transform=Ss,e.Tube=Be,e.UtilsCls=s,e.VRButton=Es,e.Vastplus=rs,e.ViewInterPairs=Ut,e.XyzParser=Zt,e.iCn3D=Ms,e.iCn3DUI=Ds,e.printMsg=class{constructor(){console.log("This is a message from the icn3d package")}},Object.defineProperty(e,"__esModule",{value:!0}),e}({}); +t+=this.getLink("mn6_igrefYes","Show Ig Ref. Number",void 0,2),t+=this.getLink("mn6_igrefTpl","Ig w/ Specified Template",void 0,2),t+=this.getLink("mn6_igrefNo","Hide Ig Ref. Number",void 0,2),t+=this.getMenuSep(),t+=this.getLink("mn6_customref","Custom Ref. Number",void 0,2),t+="",t+="",t+=this.getMenuSep()}return t+=this.getLink("mn6_yournote","Window Title",void 0,1),void 0!==e.cfg.cid?(t+=this.getMenuText("mn1_linkwrap","Links",void 0,void 0,1),t+="
      ",t+=this.getLink("mn1_link_structure","Compound Summary "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_vast","Similar Compounds "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_bind","Structures Bound "+e.htmlCls.wifiStr,void 0,2),t+="
    ",t+=""):(t+=this.getMenuText("mn1_linkwrap","Links",void 0,void 0,1),t+="
      ",t+=this.getLink("mn1_link_structure","Structure Summary "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_vast","Similar Structures "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_pubmed","Literature "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_link_protein","Protein "+e.htmlCls.wifiStr,void 0,2),t+="
    ",t+=""),t+="

  • ",t+="",t}setMenu6(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
    ",t+="",t+="

    Help

    ",t+="
    ",t+=this.setMenu6_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu6_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
      ",t+=this.getMenuUrl("abouticn3d",e.htmlCls.baseUrl+"icn3d/icn3d.html#about","About iCn3D "+e.REVISION+"",1,1),t+=this.getMenuUrl("gallery",e.htmlCls.baseUrl+"icn3d/icn3d.html#gallery","Live Gallery "+e.htmlCls.wifiStr,1,1),t+=this.getMenuUrl("video",e.htmlCls.baseUrl+"icn3d/icn3d.html#videos","Videos & Tutorials",1,1),t+=this.getMenuText("mn6_faq","FAQ",void 0,1,1),t+="
        ",t+=this.getMenuUrl("faq_viewstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#viewstru","View structure",1,2),t+=this.getMenuUrl("faq_tfstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#tfstru","Transform Structure",1,2),t+=this.getMenuUrl("faq_selsubset",e.htmlCls.baseUrl+"icn3d/icn3d.html#selsubset","Select Subsets",1,2),t+=this.getMenuUrl("faq_stylecolor",e.htmlCls.baseUrl+"icn3d/icn3d.html#changestylecolor","Change Style/Color",1,2),t+=this.getMenuUrl("faq_savework",e.htmlCls.baseUrl+"icn3d/icn3d.html#saveview","Save Work",1,2),t+=this.getMenuUrl("faq_showanno",e.htmlCls.baseUrl+"icn3d/icn3d.html#showanno","Show Annotations",1,2),t+=this.getMenuUrl("faq_exportanno",e.htmlCls.baseUrl+"icn3d/icn3d.html#exportanno","Export Annotations",1,2),t+=this.getMenuUrl("faq_interanal",e.htmlCls.baseUrl+"icn3d/icn3d.html#interanalysis","Interaction Analysis",1,2),t+=this.getMenuUrl("faq_mutanal",e.htmlCls.baseUrl+"icn3d/icn3d.html#mutationanalysis","Mutation Analysis",1,2),t+=this.getMenuUrl("faq_elecpot",e.htmlCls.baseUrl+"icn3d/icn3d.html#elecpot","Electrostatic Pot.",1,2),t+=this.getMenuUrl("faq_simipdb",e.htmlCls.baseUrl+"icn3d/icn3d.html#simivast","Similar PDB",1,2),t+=this.getMenuUrl("faq_simialphapdb",e.htmlCls.baseUrl+"icn3d/icn3d.html#simifoldseek","Similar AlphaFold/PDB",1,2),t+=this.getMenuUrl("faq_alnstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#alignmul","Align Multiple Structures",1,2),t+=this.getMenuUrl("faq_batchanal",e.htmlCls.baseUrl+"icn3d/icn3d.html#batchanalysis","Batch Analysis",1,2),t+=this.getMenuUrl("faq_embedicn3d",e.htmlCls.baseUrl+"icn3d/icn3d.html#embedicn3d","Embed iCn3D",1,2),t+="
      ",t+="",t+=this.getMenuUrl("citing",e.htmlCls.baseUrl+"icn3d/icn3d.html#citing","Citing iCn3D",void 0,1),t+=this.getMenuText("mn6_source","Source Code",void 0,1,1),t+="
        ",t+=this.getMenuUrl("github","https://github.com/ncbi/icn3d","GitHub (browser) "+e.htmlCls.wifiStr,1,2),t+=this.getMenuUrl("npm","https://www.npmjs.com/package/icn3d","npm (Node.js) "+e.htmlCls.wifiStr,1,2),t+=this.getMenuUrl("notebook","https://pypi.org/project/icn3dpy","Jupyter Notebook "+e.htmlCls.wifiStr,1,2),t+="
      ",t+="",t+=this.getMenuText("mn6_develop","Develop",void 0,void 0,1),t+="
        ",t+=this.getMenuUrl("dev_embedicn3d2",e.htmlCls.baseUrl+"icn3d/icn3d.html#HowToUse","Embed iCn3D",void 0,2),t+=this.getMenuUrl("dev_urlpara",e.htmlCls.baseUrl+"icn3d/icn3d.html#parameters","URL Parameters",void 0,2),t+=this.getMenuUrl("dev_command",e.htmlCls.baseUrl+"icn3d/icn3d.html#commands","Commands",void 0,2),t+=this.getMenuUrl("dev_datastru",e.htmlCls.baseUrl+"icn3d/icn3d.html#datastructure","Data Structure",void 0,2),t+=this.getMenuUrl("dev_classstru",e.htmlCls.baseUrl+"icn3d/icn3d.html#classstructure","Class Structure",void 0,2),t+=this.getMenuUrl("dev_addclass",e.htmlCls.baseUrl+"icn3d/icn3d.html#addclass","Add New Classes",void 0,2),t+=this.getMenuUrl("dev_modfunc",e.htmlCls.baseUrl+"icn3d/icn3d.html#modifyfunction","Modify Functions",void 0,2),t+=this.getMenuUrl("dev_restful",e.htmlCls.baseUrl+"icn3d/icn3d.html#restfulapi","RESTful APIs",void 0,2),t+=this.getMenuUrl("dev_contributor",e.htmlCls.baseUrl+"icn3d/icn3d.html#contributors","iCn3D Contributors",void 0,2),t+="
      ",t+="",t+=this.getMenuUrl("helpdoc",e.htmlCls.baseUrl+"icn3d/docs/icn3d_help.html","Help Doc "+e.htmlCls.wifiStr,1,1),t+=this.getMenuSep(),t+=this.getMenuText("mn6_tfhint","Transform Hints",void 0,1,1),t+="
        ",t+=this.getMenuText("mn6_rotate","Rotate",void 0,1,2),t+="
          ",t+="
        • Left Mouse (Click & Drag)
        • ",t+="
        • Key l: Left
        • ",t+="
        • Key j: Right
        • ",t+="
        • Key i: Up
        • ",t+="
        • Key m: Down
        • ",t+="
        • Shift + Key l: Left 90°
        • ",t+="
        • Shift + Key j: Right 90°
        • ",t+="
        • Shift + Key i: Up 90°
        • ",t+="
        • Shift + Key m: Down 90°
        • ",t+="
        ",t+="",t+=this.getMenuText("mn6_zoom","Zoom",void 0,1,2),t+="
          ",t+="
        • Middle Mouse
          (Pinch & Spread)
        • ",t+="
        • Key z: Zoom in
        • ",t+="
        • Key x: Zoom out
        • ",t+="
        ",t+="",t+=this.getMenuText("mn6_translate","Translate",void 0,1,2),t+="
          ",t+="
        • Right Mouse
          (Two Finger Click & Drag)
        • ",t+="
        ",t+="",t+="
      ",t+="",t+=this.getMenuUrl("selhints",e.htmlCls.baseUrl+"icn3d/icn3d.html#selsubset","Selection Hints",void 0,1),t+=this.getMenuUrl("helpdesk","https://support.nlm.nih.gov/support/create-case/","Write to Help Desk",1,1),t+="

    • ",t+="
    ",t}hideMenu(){let e=this.icn3dui;e.bNode||(void 0!==$("#"+e.pre+"mnlist")[0]&&($("#"+e.pre+"mnlist")[0].style.display="none"),void 0!==$("#"+e.pre+"mnLogSection")[0]&&($("#"+e.pre+"mnLogSection")[0].style.display="none"),void 0!==$("#"+e.pre+"cmdlog")[0]&&($("#"+e.pre+"cmdlog")[0].style.display="none"),$("#"+e.pre+"title")[0].style.margin="10px 0 0 10px")}showMenu(){let e=this.icn3dui;e.bNode||(void 0!==$("#"+e.pre+"mnlist")[0]&&($("#"+e.pre+"mnlist")[0].style.display="block"),void 0!==$("#"+e.pre+"mnLogSection")[0]&&($("#"+e.pre+"mnLogSection")[0].style.display="block"),void 0!==$("#"+e.pre+"cmdlog")[0]&&($("#"+e.pre+"cmdlog")[0].style.display="block"))}}class c{constructor(e){this.icn3dui=e}openDlg(e,t){let s=this.icn3dui;s.icn3d,s.bNode||(e=s.pre+e,s.cfg.notebook?this.openDlgNotebook(e,t):this.openDlgRegular(e,t),s.htmlCls.themecolor||(s.htmlCls.themecolor="blue"),s.htmlCls.setMenuCls.setTheme(s.htmlCls.themecolor))}addSaveButton(e){let t=this.icn3dui;t.icn3d,t.bNode||void 0!==this.dialogHashSave&&this.dialogHashSave.hasOwnProperty(e)||($("#"+e).parent().children(".ui-dialog-titlebar").append("
    "),void 0===this.dialogHashSave&&(this.dialogHashSave={}),this.dialogHashSave[e]=1)}addHideButton(e){let t=this.icn3dui;t.icn3d,t.bNode||void 0!==this.dialogHashHide&&this.dialogHashHide.hasOwnProperty(e)||($("#"+e).parent().children(".ui-dialog-titlebar").append("
    "),void 0===this.dialogHashHide&&(this.dialogHashHide={}),this.dialogHashHide[e]=1)}getDialogStatus(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t={},s={},i=$("#"+e.pre+"dl_selectannotations").hasClass("ui-dialog-content"),n=$("#"+e.pre+"dl_graph").hasClass("ui-dialog-content"),l=$("#"+e.pre+"dl_linegraph").hasClass("ui-dialog-content"),r=$("#"+e.pre+"dl_scatterplot").hasClass("ui-dialog-content"),o=$("#"+e.pre+"dl_contactmap").hasClass("ui-dialog-content"),a=$("#"+e.pre+"dl_alignerrormap").hasClass("ui-dialog-content"),d=$("#"+e.pre+"dl_interactionsorted").hasClass("ui-dialog-content"),c=$("#"+e.pre+"dl_alignment").hasClass("ui-dialog-content"),h=$("#"+e.pre+"dl_2ddgm").hasClass("ui-dialog-content"),p=$("#"+e.pre+"dl_2dctn").hasClass("ui-dialog-content"),m=$("#"+e.pre+"dl_definedsets").hasClass("ui-dialog-content");return t.bSelectannotationsInit2=!1,t.bGraph2=!1,t.bLineGraph2=!1,t.bScatterplot2=!1,t.bTable2=!1,t.bAlignmentInit2=!1,t.bTwoddgmInit2=!1,t.bTwodctnInit2=!1,t.bSetsInit2=!1,s.dl_selectannotations="bSelectannotationsInit2",s.dl_graph="bGraph2",s.dl_linegraph="bLineGraph2",s.dl_scatterplot="bScatterplot2",s.dl_contactmap="bContactmap2",s.dl_alignerrormap="bAlignerrormap2",s.dl_interactionsorted="bTable2",s.dl_alignment="bAlignmentInit2",s.dl_2ddgm="bTwoddgmInit2",s.dl_2dctn="bTwodctnInit2",s.dl_definedsets="bSetsInit2",i&&(t.bSelectannotationsInit2=$("#"+e.pre+"dl_selectannotations").dialog("isOpen")),n&&(t.bGraph2=$("#"+e.pre+"dl_graph").dialog("isOpen")),l&&(t.bLineGraph2=$("#"+e.pre+"dl_linegraph").dialog("isOpen")),r&&(t.bScatterplot2=$("#"+e.pre+"dl_scatterplot").dialog("isOpen")),o&&(t.bContactmap2=$("#"+e.pre+"dl_contactmap").dialog("isOpen")),a&&(t.bAlignerror2=$("#"+e.pre+"dl_alignerrormap").dialog("isOpen")),d&&(t.bTable2=$("#"+e.pre+"dl_interactionsorted").dialog("isOpen")),c&&(t.bAlignmentInit2=$("#"+e.pre+"dl_alignment").dialog("isOpen")),h&&(t.bTwoddgmInit2=$("#"+e.pre+"dl_2ddgm").dialog("isOpen")),p&&(t.bTwodctnInit2=$("#"+e.pre+"dl_2dctn").dialog("isOpen")),m&&(t.bSetsInit2=$("#"+e.pre+"dl_definedsets").dialog("isOpen")),{status:t,id2flag:s}}openDlgHalfWindow(e,t,s,i){let n=this.icn3dui,l=n.icn3d;if(n.bNode)return;let r=this,o=n.htmlCls.width2d+20;l.resizeCanvasCls.resizeCanvas(n.htmlCls.WIDTH-s,n.htmlCls.HEIGHT,i);let a,d=n.htmlCls.HEIGHT,c=s;a=!n.cfg.showmenu||n.utilsCls.isMobile()||n.cfg.mobilemenu?{my:"left top",at:"right top",of:"#"+n.pre+"viewer",collision:"none"}:{my:"left top",at:"right top+40",of:"#"+n.pre+"viewer",collision:"none"},n.cfg.resize=!1,window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:d,width:c,modal:!1,position:a,close:function(t){let s=r.getDialogStatus(),i=s.status,a=s.id2flag,d=!1;for(let t in a){let s=e===n.pre+t;for(let e in i)i.hasOwnProperty(e)||(s=s&&!i[e]);d=d||s}if(d)if(i.bTwoddgmInit2||i.bTwodctnInit2||i.bSetsInit2){let e=n.utilsCls.isMobile()?n.htmlCls.WIDTH:n.htmlCls.WIDTH-o;l.resizeCanvasCls.resizeCanvas(e,n.htmlCls.HEIGHT,!0),i.bTwoddgmInit2&&r.openDlg2Ddgm(n.pre+"dl_2ddgm",void 0,i.bSetsInit2),i.bTwodctnInit2&&r.openDlg2Ddgm(n.pre+"dl_2dctn",void 0,i.bSetsInit2),i.bSetsInit2&&r.openDlg2Ddgm(n.pre+"dl_definedsets")}else l.resizeCanvasCls.resizeCanvas(n.htmlCls.WIDTH,n.htmlCls.HEIGHT,!0)},resize:function(t){if(e==n.pre+"dl_selectannotations")l.annotationCls.hideFixedTitle();else if(e==n.pre+"dl_graph"){let t=$("#"+e).width(),s=$("#"+e).height();d3.select("#"+n.svgid).attr("width",t).attr("height",s)}else if(e==n.pre+"dl_linegraph"||e==n.pre+"dl_scatterplot"||e==n.pre+"dl_contactmap"||e==n.pre+"dl_alignerrormap"){let t=status.bTwoddgmInit2||status.bSetsInit2?(n.htmlCls.WIDTH-o)/2:n.htmlCls.WIDTH/2,s=$("#"+e).width()/t;if(e==n.pre+"dl_linegraph"){let e=l.linegraphWidth*s;$("#"+n.linegraphid).attr("width",e)}else if(e==n.pre+"dl_scatterplot"){let e=l.scatterplotWidth*s;$("#"+n.scatterplotid).attr("width",e)}else if(e==n.pre+"dl_contactmap"){let e=l.contactmapWidth*s;$("#"+n.contactmapid).attr("width",e)}else if(e==n.pre+"dl_alignerrormap"){let e=l.alignerrormapWidth*s;$("#"+n.alignerrormapid).attr("width",e)}}}}),this.addSaveButton(e),this.addHideButton(e)}openDlg2Ddgm(e,t,s){let i=this.icn3dui,n=i.icn3d;if(i.bNode)return;let l,r,o=this,a=i.htmlCls.width2d+20;e===i.pre+"dl_definedsets"?(l="right top",r="Select sets"):e!==i.pre+"dl_2ddgm"&&e!==i.pre+"dl_2dctn"||(l=s?"right top+240":"right top",r=e===i.pre+"dl_2ddgm"?"2D Diagram":"2D Cartoon");let d={my:"left top+"+i.htmlCls.MENU_HEIGHT,at:l,of:"#"+i.pre+"viewer",collision:"none"};window.dialog=$("#"+e).dialog({autoOpen:!0,title:r,height:"auto",width:a,modal:!1,position:d,close:function(e){let t=o.getDialogStatus().status;t.bSelectannotationsInit2||t.bGraph2||t.bLineGraph2||t.bScatterplot2||t.bTable2||t.bAlignmentInit2||n.resizeCanvasCls.resizeCanvas(i.htmlCls.WIDTH,i.htmlCls.HEIGHT,!0)},resize:function(t,s){e==i.pre+"dl_2dctn"&&(n.resizeRatioX=s.size.width/i.htmlCls.width2d,n.resizeRatioY=s.size.height/(i.htmlCls.width2d+70))},resizeStop:function(e,t){n.resizeRatioX=t.size.width/i.htmlCls.width2d,n.resizeRatioY=t.size.height/(i.htmlCls.width2d+70)}}),this.addSaveButton(e),this.addHideButton(e)}openDlgRegular(e,t){let s=this.icn3dui,i=s.icn3d;if(s.bNode)return;let n=400,l=150,r=s.htmlCls.width2d+20,o=this.getDialogStatus().status;if(e===s.pre+"dl_selectannotations"||e===s.pre+"dl_graph"||e===s.pre+"dl_linegraph"||e===s.pre+"dl_scatterplot"||e===s.pre+"dl_contactmap"||e===s.pre+"dl_alignerrormap"||e===s.pre+"dl_interactionsorted"||e===s.pre+"dl_alignment"){let a=.5*s.htmlCls.WIDTH-.5*r;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)this.openDlgHalfWindow(e,t,a,!0),(o.bTwoddgmInit2||o.bTwodctnInit2||o.bSetsInit2)&&(i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-a-r,s.htmlCls.HEIGHT,!0),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,o.bSetsInit2),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,o.bSetsInit2),o.bSetsInit2&&this.openDlg2Ddgm(s.pre+"dl_definedsets"));else{i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,.5*s.htmlCls.HEIGHT,!0),l=.5*s.htmlCls.HEIGHT,n=s.htmlCls.WIDTH;let a={my:"left top",at:"left bottom+32",of:"#"+s.pre+"canvas",collision:"none"};window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:l,width:n,modal:!1,position:a,close:function(t){if(!((e!==s.pre+"dl_selectannotations"||o.bAlignmentInit2||o.bGraph2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_graph"||o.bSelectannotationsInit2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_alignment"||o.bSelectannotationsInit2||o.bGraph2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_interactionsorted"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_linegraph"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_scatterplot"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_contactmap"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bAlignerrormap2)&&(e!==s.pre+"dl_alignerrormap"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2)))if(o.bTwoddgmInit2||o.bTwodctnInit2||o.bSetsInit2){let e=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(e,s.htmlCls.HEIGHT,!0),o.bTwoddgmInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,o.bSetsInit2),o.bTwodctnInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,o.bSetsInit2),o.bSetsInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_definedsets")}else i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,s.htmlCls.HEIGHT,!0)},resize:function(t){if(e==s.pre+"dl_selectannotations")i.annotationCls.hideFixedTitle();else if(e==s.pre+"dl_graph"){let t=$("#"+e).width(),i=$("#"+e).height();d3.select("#"+s.svgid).attr("width",t).attr("height",i)}else if(e==s.pre+"dl_linegraph"||e==s.pre+"dl_scatterplot"||e==s.pre+"dl_contactmap"||e==s.pre+"dl_alignerrormap"){let t=o.bTwoddgmInit2||o.bSetsInit2?(s.htmlCls.WIDTH-r)/2:s.htmlCls.WIDTH/2,n=$("#"+e).width()/t;if(e==s.pre+"dl_linegraph"){let e=i.linegraphWidth*n;$("#"+s.linegraphid).attr("width",e)}else if(e==s.pre+"dl_scatterplot"){let e=i.scatterplotWidth*n;$("#"+s.scatterplotid).attr("width",e)}else if(e==s.pre+"dl_contactmap"){let e=i.contactmapWidth*n;$("#"+s.contactmapid).attr("width",e)}else if(e==s.pre+"dl_alignerrormap"){let e=i.alignerrormapWidth*n;$("#"+s.alignerrormapid).attr("width",e)}}}}),this.addSaveButton(e),this.addHideButton(e)}}else if(e===s.pre+"dl_2ddgm"||e===s.pre+"dl_2dctn"){let t=0;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)(o.bSelectannotationsInit2||o.bGraph2||o.bLineGraph2||o.bScatterplot2||o.bTable2||o.bAlignmentInit2)&&(t=.5*s.htmlCls.WIDTH-.5*r),i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-t-r,s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,void 0,o.bSetsInit2);else{let t=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(t,.5*s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT,o.bSetsInit2)}}else{let a;if(l="auto",n="auto",e===s.pre+"dl_addtrack"?n="50%":e===s.pre+"dl_menupref"&&(n=600,l=500),e===s.pre+"dl_definedsets"){let t=0;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)(o.bSelectannotationsInit2||o.bGraph2||o.bLineGraph2||o.bScatterplot2||o.bTable2||o.bAlignmentInit2)&&(t=.5*s.htmlCls.WIDTH-.5*r),i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-t-r,s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,!0),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,!0);else{let t=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(t,.5*s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",.5*s.htmlCls.HEIGHT,!0),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",.5*s.htmlCls.HEIGHT,!0)}}else s.utilsCls.isMobile()?a={my:"left top",at:"left bottom-50",of:"#"+s.pre+"canvas",collision:"none"}:e===s.pre+"dl_allinteraction"||e===s.pre+"dl_buriedarea"?(a={my:"right top",at:"right top+50",of:"#"+i.divid,collision:"none"},n=700,l=500):a=e===s.pre+"dl_rmsd"||e===s.pre+"dl_legend"?{my:"left bottom",at:"left+20 bottom-20",of:"#"+s.pre+"canvas",collision:"none"}:e===s.pre+"dl_symd"?{my:"left top",at:"right-200 bottom-200",of:"#"+s.pre+"canvas",collision:"none"}:s.cfg.align?{my:"left top",at:"left top+90",of:"#"+s.pre+"canvas",collision:"none"}:e===s.pre+"dl_mmdbafid"?{my:"left top",at:"left top+130",of:"#"+s.pre+"canvas",collision:"none"}:{my:"left top",at:"left top+50",of:"#"+s.pre+"canvas",collision:"none"},window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:l,width:n,modal:!1,position:a}),this.addSaveButton(e),this.addHideButton(e)}$(".ui-dialog .ui-button span").removeClass("ui-icon-closethick").addClass("ui-icon-close")}openDlgNotebook(e,t){let s=this.icn3dui,i=s.icn3d;if(s.bNode)return;let n=400,l=150,r=s.htmlCls.width2d+20;e===s.pre+"dl_selectannotations"||e===s.pre+"dl_graph"||e===s.pre+"dl_linegraph"||e===s.pre+"dl_scatterplot"||e===s.pre+"dl_contactmap"||e===s.pre+"dl_alignerrormap"||e===s.pre+"dl_interactionsorted"||e===s.pre+"dl_alignment"?($("#"+e).show(),$("#"+e+"_nb").show(),$("#"+e+"_title").html(t),l=.5*s.htmlCls.HEIGHT,n=s.htmlCls.WIDTH,$("#"+e).width(n),$("#"+e).height(l),$("#"+e).resize((function(t){let n=s.htmlCls.WIDTH/2,l=$("#"+e).width()/n;if(e==s.pre+"dl_selectannotations")i.annotationCls.hideFixedTitle();else if(e==s.pre+"dl_graph"){let t=$("#"+e).width(),i=$("#"+e).height();d3.select("#"+s.svgid).attr("width",t).attr("height",i)}else if(e==s.pre+"dl_linegraph"){let e=i.linegraphWidth*l;$("#"+s.linegraphid).attr("width",e)}else if(e==s.pre+"dl_scatterplot"){let e=i.scatterplotWidth*l;$("#"+s.scatterplotid).attr("width",e)}else if(e==s.pre+"dl_contactmap"){let e=i.contactmapWidth*l;$("#"+s.contactmapid).attr("width",e)}else if(e==s.pre+"dl_alignerrormap"){let e=i.alignerrormapWidth*l;$("#"+s.alignerrormapid).attr("width",e)}}))):(i.bRender&&($("#"+e).show(),$("#"+e+"_nb").show(),$("#"+e+"_title").html(t)),l="auto",n="auto",e===s.pre+"dl_addtrack"?n="50%":e===s.pre+"dl_2ddgm"||e===s.pre+"dl_2dctn"||e===s.pre+"dl_definedsets"?n=r:e!==s.pre+"dl_allinteraction"&&e!==s.pre+"dl_buriedarea"||(n=700,l=500),$("#"+e).width(n),$("#"+e).height(l))}}class h{constructor(e){this.icn3dui=e}setCustomDialogs(){let e=this.icn3dui;if(e.icn3d,e.bNode)return"";return""}getHtmlAlignResidueByResidue(e,t,s){let i=this.icn3dui;i.icn3d;let n="";return n+="All chains will be aligned to the first chain in the comma-separated chain IDs. Each chain ID has the form of PDBID_chain (e.g., 1HHO_A, case sensitive) or UniprotID (e.g., P69905 for AlphaFold structures).

    ",n+="Chain IDs: "+i.htmlCls.inputTextStr+"id='"+i.pre+e+"' value='P69905,P01942,1HHO_A' size=50>

    ",n+='Each alignment is defined as " | "-separated residue lists in one line. "10-50" means a range of residues from 10 to 50.

    ",n+=i.htmlCls.buttonStr+s+"'>Align Residue by Residue
    ",n}addNotebookTitle(e,t,s){let i=this.icn3dui;i.icn3d;let n='';return s&&(n+='
    '),n}setDialogs(){let e=this.icn3dui,t=e.icn3d;if(e.bNode)return"";let s="";e.htmlCls.optionStr="
    StructureChainResidue Number
    "+i[e].substr(0,t)+""+i[e].substr(t+1,s-t-1)+""+i[e].substr(s+1)+"
    ",s+="",s+="",s+="",s+="",s+="",s+="",s+="",s+="",s+="",s+="",s+="",s+="",s+="",s+="",s+="
    "+e.htmlCls.inputCheckStr+"id='"+e.pre+"analysis_hbond' checked>Hydrogen Bonds "+e.htmlCls.space3+"",s+=e.htmlCls.divNowrapStr+" Å"+e.htmlCls.space3+""+e.htmlCls.inputCheckStr+"id='"+e.pre+"analysis_saltbridge' checked>Salt Bridge/Ionic "+e.htmlCls.space3+"",s+=e.htmlCls.divNowrapStr+" Å"+e.htmlCls.space3+""+e.htmlCls.inputCheckStr+"id='"+e.pre+"analysis_contact' checked>Contacts/Interactions "+e.htmlCls.space3+"",s+=e.htmlCls.divNowrapStr+" Å"+e.htmlCls.space3+"
    "+e.htmlCls.inputCheckStr+"id='"+e.pre+"analysis_halogen' checked>Halogen Bonds "+e.htmlCls.space3+"",s+=e.htmlCls.divNowrapStr+" Å"+e.htmlCls.space3+""+e.htmlCls.inputCheckStr+"id='"+e.pre+"analysis_pication' checked>π-Cation "+e.htmlCls.space3+"",s+=e.htmlCls.divNowrapStr+" Å"+e.htmlCls.space3+""+e.htmlCls.inputCheckStr+"id='"+e.pre+"analysis_pistacking' checked>π-Stacking "+e.htmlCls.space3+"",s+=e.htmlCls.divNowrapStr+" Å"+e.htmlCls.space3+"
    ",s+="
    ",s+=e.htmlCls.divNowrapStr+"2. Select the first set:",s+="
    ",s+="
    ",s+=e.htmlCls.divNowrapStr+"3. Select the second set:",s+="
    ",s+="
    ",s+="
    4. "+e.htmlCls.buttonStr+"applyhbonds'>3D Display Interactions

    ",s+="
    "+e.htmlCls.buttonStr+"hbondWindow'>Highlight Interactions in TableSort Interactions on: "+e.htmlCls.buttonStr+"sortSet1'> Set 1"+e.htmlCls.buttonStr+"sortSet2' style='margin-left:12px'>Set 2

    ",s+="
    "+e.htmlCls.buttonStr+"hbondLineGraph'>2D Interaction Network "+e.htmlCls.buttonStr+"hbondLineGraph2' style='margin-left:12px'>2D Network with Reference Numbers to show two lines of residue nodes

    ",s+="
    "+e.htmlCls.buttonStr+"hbondScatterplot'>2D Interaction Map "+e.htmlCls.buttonStr+"hbondScatterplot2' style='margin-left:12px'>2D Map with Reference Numbers to show map

    ",r=': "+e.htmlCls.buttonStr+"hbondGraph'>2D Graph(Force-Directed) to show interactions with strength parameters in 0-200:",s+='
    ',s+="',s+="',s+="',s+="',s+="',s+="',s+="',s+="
    Helix or Sheet'+r+e.pre+'dist_ss" size="4" value="100">Coil or Nucleotide"+r+e.pre+'dist_coil" size="4" value="50">Disulfide Bonds"+r+e.pre+'dist_ssbond" size="4" value="50">
    Hydrogen Bonds"+r+e.pre+'dist_hbond" size="4" value="50">Salt Bridge/Ionic"+r+e.pre+'dist_ionic" size="4" value="50">Contacts"+r+e.pre+'dist_inter" size="4" value="25">
    Halogen Bonds"+r+e.pre+'dist_halogen" size="4" value="50">π-Cation"+r+e.pre+'dist_pication" size="4" value="50">π-Stacking"+r+e.pre+'dist_pistacking" size="4" value="50">
    ',s+='
    (Note: you can also adjust thresholds at #1 to add/remove interactions.)

    ',s+="
    "+e.htmlCls.buttonStr+"areaWindow'>Buried Surface Area

    ",s+="
    5. "+e.htmlCls.buttonStr+"hbondReset'>Reset and select new sets
    ",s+="",s+=e.htmlCls.divStr+"dl_realign' class='"+n+"'>",s+=this.addNotebookTitle("dl_realign","Realign by sequence"),s+=e.htmlCls.divNowrapStr+"1. Select sets below
    or use your current selection:
    ",s+="

    ",s+="
    2. "+e.htmlCls.buttonStr+"applyRealign'>Realign by Sequence

    ",s+="",s+=e.htmlCls.divStr+"dl_realignbystruct' class='"+n+"' style='max-width:500px'>",s+=this.addNotebookTitle("dl_realignbystruct","Realign by structure"),s+="
    1. Select sets below or use your current selection.

    ",s+="

    ",s+="
    2. "+e.htmlCls.buttonStr+"applyRealignByStruct_tmalign'>Realign with TM-align"+e.htmlCls.buttonStr+"applyRealignByStruct' style='margin-left:30px'>Realign with VAST

    ",s+="",s+=e.htmlCls.divStr+"dl_realigntwostru' class='"+n+"'>",s+=this.addNotebookTitle("dl_realigntwostru","Realign two structure complexes"),s+=e.htmlCls.divNowrapStr+"1. Select sets below or use your current selection:
    ",s+="

    ",s+="2. Overall maximum RMSD: "+e.htmlCls.inputTextStr+"id='"+e.pre+"maxrmsd' value='30' size='2'> Å

    ",s+="
    3. "+e.htmlCls.buttonStr+"applyRealignByStruct_vastplus'>VAST+ Alignment based on TM-align

    ",s+="",s+=e.htmlCls.divStr+"dl_colorspectrumacrosssets' class='"+n+"'>",s+=this.addNotebookTitle("dl_colorspectrumacrosssets","Set color spectrum across sets"),s+=e.htmlCls.divNowrapStr+"1. Select sets below:
    ",s+="
    ",s+="
    2. "+e.htmlCls.buttonStr+"applyColorSpectrumAcrossSets'>Spectrum Color for Sets

    ",s+="",s+=e.htmlCls.divStr+"dl_colorspectrumbysets' class='"+n+"'>",s+=this.addNotebookTitle("dl_colorspectrumbysets","Set color spectrum for residues in sets"),s+=e.htmlCls.divNowrapStr+"1. Select sets below:
    ",s+="
    ",s+="
    2. "+e.htmlCls.buttonStr+"applyColorSpectrumBySets'>Spectrum Color for Residues in Sets

    ",s+="",s+=e.htmlCls.divStr+"dl_colorrainbowacrosssets' class='"+n+"'>",s+=this.addNotebookTitle("dl_colorrainbowacrosssets","Set color rainbow across sets"),s+=e.htmlCls.divNowrapStr+"1. Select sets below:
    ",s+="
    ",s+="
    2. "+e.htmlCls.buttonStr+"applyColorRainbowAcrossSets'>Rainbow Color for Sets

    ",s+="",s+=e.htmlCls.divStr+"dl_colorrainbowbysets' class='"+n+"'>",s+=this.addNotebookTitle("dl_colorrainbowbysets","Set color rainbow for residues in sets"),s+=e.htmlCls.divNowrapStr+"1. Select sets below:
    ",s+="
    ",s+="
    2. "+e.htmlCls.buttonStr+"applyColorRainbowBySets'>Rainbow Color for Residues in Sets

    ",s+="",s+=e.htmlCls.divStr+"dl_allinteraction' style='background-color:white' class='"+n+"'>",s+=this.addNotebookTitle("dl_allinteraction","All interactions",!0),s+="",s+=e.htmlCls.divStr+"dl_interactionsorted' style='background-color:white' class='"+n+"'>",s+=this.addNotebookTitle("dl_interactionsorted","Sorted interactions",!0),s+="",s+=e.htmlCls.divStr+"dl_linegraph' style='background-color:white' class='"+n+"'>",s+=this.addNotebookTitle("dl_linegraph","2D Interaction Network"),s+=e.htmlCls.divNowrapStr+'
    ',s+=e.htmlCls.space2+"Hold Ctrl key to select multiple nodes/lines.",s+=e.htmlCls.divStr+"dl_linegraphcolor' style='display:block;'>",s+=e.htmlCls.setHtmlCls.setColorHints(),s+="
    ",e.linegraphid=e.pre+"linegraph",s+=e.htmlCls.divNowrapStr+l+e.linegraphid+'_svg">SVG'+e.htmlCls.space2,s+=l+e.linegraphid+'_png">PNG'+e.htmlCls.space2,s+=l+e.linegraphid+'_json">JSON'+e.htmlCls.space4,s+="Scale:
    ",s+='
    ',s+="",s+=e.htmlCls.divStr+"dl_scatterplot' style='background-color:white' class='"+n+"'>",s+=this.addNotebookTitle("dl_scatterplot","2D Interaction Map"),s+=e.htmlCls.divNowrapStr+"Hold Ctrl key to select multiple nodes."+e.htmlCls.space3,s+='
    ',s+=e.htmlCls.divStr+"dl_scatterplotcolor' style='display:none;'>",s+=e.htmlCls.setHtmlCls.setColorHints(),s+="",e.scatterplotid=e.pre+"scatterplot",s+=e.htmlCls.divNowrapStr+l+e.scatterplotid+'_svg">SVG'+e.htmlCls.space2,s+=l+e.scatterplotid+'_png">PNG'+e.htmlCls.space2,s+=l+e.scatterplotid+'_json">JSON'+e.htmlCls.space4,s+="Scale:
    ",s+='
    ',s+="",s+=e.htmlCls.divStr+"dl_contactmap' style='background-color:white' class='"+n+"'>",s+=this.addNotebookTitle("dl_contactmap","Contact Map"),s+=e.htmlCls.divNowrapStr+"Hold Ctrl key to select multiple nodes."+e.htmlCls.space3+"",e.contactmapid=e.pre+"contactmap",s+=e.htmlCls.divNowrapStr+l+e.contactmapid+'_svg">SVG'+e.htmlCls.space2,s+=l+e.contactmapid+'_png">PNG'+e.htmlCls.space2,s+=l+e.contactmapid+'_json">JSON'+e.htmlCls.space4,s+="Scale:
    ",s+='
    ',s+="",s+=e.htmlCls.divStr+"dl_alignerrormap' style='background-color:white' class='"+n+"'>",s+=this.addNotebookTitle("dl_alignerrormap","PAE Map"),s+=e.htmlCls.divNowrapStr+"Hold Ctrl key to select multiple nodes."+e.htmlCls.space3+"",e.alignerrormapid=e.pre+"alignerrormap",s+=e.htmlCls.divNowrapStr+l+e.alignerrormapid+'_svg">SVG'+e.htmlCls.space2,s+=l+e.alignerrormapid+'_png">PNG (slow)'+e.htmlCls.space2,s+=l+e.alignerrormapid+'_json">JSON'+e.htmlCls.space4,s+='Scale:
    ";s+="
    ",s+="
    051015202530
    Expected position error (Angstroms)

    ",s+='
    ',s+="",s+=e.htmlCls.divStr+"dl_elecmap2fofc' class='"+n+"'>",s+=this.addNotebookTitle("dl_elecmap2fofc","Electron Density 2F0-Fc Map"),s+="Contour at: σ "+e.htmlCls.buttonStr+"applymap2fofc'>Display "+e.htmlCls.buttonStr+"elecmapNo2'>Remove Map",s+="",s+=e.htmlCls.divStr+"dl_elecmapfofc' class='"+n+"'>",s+=this.addNotebookTitle("dl_elecmapfofc","Electron Density F0-Fc Map"),s+="Contour at: σ "+e.htmlCls.buttonStr+"applymapfofc'>Display "+e.htmlCls.buttonStr+"elecmapNo3'>Remove Map",s+="",s+=e.htmlCls.divStr+"dl_emmap' class='"+n+"'>",s+=this.addNotebookTitle("dl_emmap","EM Density Map"),s+="Contour at: % of maximum EM values
    "+e.htmlCls.buttonStr+"applyemmap'>Display "+e.htmlCls.buttonStr+"emmapNo2'>Remove EM Map",s+="",s+=e.htmlCls.divStr+"dl_aroundsphere' class='"+n+"'>",s+=this.addNotebookTitle("dl_aroundsphere","Select a sphere around a set of residues"),s+=e.htmlCls.divNowrapStr+"1. Select the first set:",s+="

    ",s+=e.htmlCls.divNowrapStr+"2. Sphere with a radius: "+e.htmlCls.inputTextStr+"id='"+e.pre+"radius_aroundsphere' value='4' size='2'> Å
    ",s+=e.htmlCls.divNowrapStr+"3. Select the second set to apply the sphere:",s+="

    ",s+=e.htmlCls.divNowrapStr+"4. "+e.htmlCls.buttonStr+"applypick_aroundsphere'>Display the sphere around the first set of atoms
    ",s+="
    "+e.htmlCls.buttonStr+"sphereExport'>Save interacting/contacting residue pairs in a file
    ",s+="",s+=e.htmlCls.divStr+"dl_adjustmem' class='"+n+"'>",s+=this.addNotebookTitle("dl_adjustmem","Adjust membranes"),s+="Note: The membranes are parallel to the X-Y plane. The center of the membranes is at Z = 0.

    ",s+=e.htmlCls.divNowrapStr+"1. Extracellular membrane Z-axis position: "+e.htmlCls.inputTextStr+"id='"+e.pre+"extra_mem_z' value='' size='3'> Å
    ",s+=e.htmlCls.divNowrapStr+"2. intracellular membrane Z-axis position: "+e.htmlCls.inputTextStr+"id='"+e.pre+"intra_mem_z' value='' size='3'> Å
    ",s+=e.htmlCls.divNowrapStr+"3. "+e.htmlCls.buttonStr+"apply_adjustmem'>Display the adjusted membranes
    ",s+="",s+=e.htmlCls.divStr+"dl_selectplane' class='"+n+"'>",s+=this.addNotebookTitle("dl_selectplane","Select a plane"),s+="Note: The membranes are parallel to the X-Y plane. The center of the membranes is at Z = 0.

    ",s+=e.htmlCls.divNowrapStr+"1. Z-axis position of the first X-Y plane: "+e.htmlCls.inputTextStr+"id='"+e.pre+"selectplane_z1' value='15' size='3'> Å
    ",s+=e.htmlCls.divNowrapStr+"2. Z-axis position of the second X-Y plane: "+e.htmlCls.inputTextStr+"id='"+e.pre+"selectplane_z2' value='-15' size='3'> Å
    ",s+=e.htmlCls.divNowrapStr+"3. "+e.htmlCls.buttonStr+"apply_selectplane'>Save the region between the planes to Defined Sets
    ",s+="",s+=e.htmlCls.divStr+"dl_addlabel' class='"+n+"'>",s+=this.addNotebookTitle("dl_addlabel","Add labels between two atoms"),s+="1. Text: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labeltext' value='Text' size=4>
    ",s+="2. Size: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labelsize' value='18' size=4 maxlength=2>
    ",s+="3. Color: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labelcolor' value='"+"#ffff00' size=4>
    ",e.utilsCls.isMobile()?s+=e.htmlCls.spanNowrapStr+"4. Touch TWO atoms
    ":s+=e.htmlCls.spanNowrapStr+'4. Pick TWO atoms while holding "Alt" key
    ',s+=e.htmlCls.spanNowrapStr+"5. "+e.htmlCls.buttonStr+"applypick_labels'>Display",s+="",s+=e.htmlCls.divStr+"dl_addlabelselection' class='"+n+"'>",s+=this.addNotebookTitle("dl_addlabelselection","Add labels for your selection"),s+="1. Text: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labeltext2' value='Text' size=4>
    ",s+="2. Size: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labelsize2' value='18' size=4 maxlength=2>
    ",s+="3. Color: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labelcolor2' value='"+"#ffff00' size=4>
    ",s+=e.htmlCls.spanNowrapStr+"4. "+e.htmlCls.buttonStr+"applyselection_labels'>Display",s+="",s+=e.htmlCls.divStr+"dl_labelColor' class='"+n+"'>",s+=this.addNotebookTitle("dl_labelColor","Change label color"),s+="Color for all labels: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labelcolorall' value='"+"#ffff00' size=4>

    ",s+=e.htmlCls.spanNowrapStr+e.htmlCls.buttonStr+"applylabelcolor'>Display",s+="",s+=e.htmlCls.divStr+"dl_distance' class='"+n+"'>",s+=this.addNotebookTitle("dl_distance","Measure distance"),e.utilsCls.isMobile()?s+=e.htmlCls.spanNowrapStr+"1. Touch TWO atoms
    ":s+=e.htmlCls.spanNowrapStr+'1. Pick TWO atoms while holding "Alt" key
    ',s+=e.htmlCls.spanNowrapStr+"2. Line Color: "+e.htmlCls.inputTextStr+"id='"+e.pre+"distancecolor' value='"+"#ffff00' size=4>
    ",s+=e.htmlCls.spanNowrapStr+"3. "+e.htmlCls.buttonStr+"applypick_measuredistance'>Display",s+="",s+=e.htmlCls.divStr+"dl_stabilizer' class='"+n+"'>",s+=this.addNotebookTitle("dl_stabilizer","Add a stabilizer"),e.utilsCls.isMobile()?s+=e.htmlCls.spanNowrapStr+"1. Touch TWO atoms
    ":s+=e.htmlCls.spanNowrapStr+'1. Pick TWO atoms while holding "Alt" key
    ',s+=e.htmlCls.spanNowrapStr+"2. Color: "+e.htmlCls.inputTextStr+"id='"+e.pre+"stabilizercolor' value='ffffff' size=4>
    ",s+=e.htmlCls.spanNowrapStr+"3. "+e.htmlCls.buttonStr+"applypick_stabilizer'>Add",s+="",s+=e.htmlCls.divStr+"dl_disttwosets' class='"+n+"'>",s+=this.addNotebookTitle("dl_disttwosets","Measure the distance between two sets"),s+=e.htmlCls.spanNowrapStr+"1. Select two sets
    ",s+="
    ",s+=e.htmlCls.divNowrapStr+"First set:",s+="
    ",s+="
    ",s+=e.htmlCls.divNowrapStr+"Second set:",s+="
    ",s+="
    ",s+=e.htmlCls.spanNowrapStr+"2. Color: "+e.htmlCls.inputTextStr+"id='"+e.pre+"distancecolor2' value='"+"#ffff00' size=4>

    ",s+=e.htmlCls.spanNowrapStr+"3. "+e.htmlCls.buttonStr+"applydist2'>Display",s+="",s+=e.htmlCls.divStr+"dl_linebtwsets' class='"+n+"'>",s+=this.addNotebookTitle("dl_linebtwsets","Add a line between two sets"),s+=e.htmlCls.spanNowrapStr+"1. Select two sets
    ",s+="
    ",s+=e.htmlCls.divNowrapStr+"First set:",s+="
    ",s+="
    ",s+=e.htmlCls.divNowrapStr+"Second set:",s+="
    ",s+="
    ",s+=e.htmlCls.divNowrapStr+"2. Line style:
    ",s+="3. Line radius: "+e.htmlCls.inputTextStr+"id='"+e.pre+"linebtwsets_radius' value='0.4' size=4>

    ",s+="4. Color: "+e.htmlCls.inputTextStr+"id='"+e.pre+"linebtwsets_customcolor' value='"+"#ffff00' size=4>

    ",s+=e.htmlCls.divNowrapStr+"5. Opacity:
    ",s+=e.htmlCls.spanNowrapStr+"6. "+e.htmlCls.buttonStr+"applylinebtwsets'>Display",s+=e.htmlCls.space3+e.htmlCls.spanNowrapStr+e.htmlCls.buttonStr+"clearlinebtwsets'>Clear",s+="",s+=e.htmlCls.divStr+"dl_cartoonshape' class='"+n+"'>",s+=this.addNotebookTitle("dl_cartoonshape","Cartoon Shape"),s+=e.htmlCls.spanNowrapStr+"1. Select a set:
    ",s+="

    ",s+=e.htmlCls.divNowrapStr+"2. Shape:
    ",s+="3. Radius: "+e.htmlCls.inputTextStr+"id='"+e.pre+"cartoonshape_radius' value='1.5' size=4>

    ",s+="4. Color: "+e.htmlCls.inputTextStr+"id='"+e.pre+"cartoonshape_customcolor' value='"+"#ffff00' size=4>

    ",s+=e.htmlCls.divNowrapStr+"5. Opacity:
    ",s+=e.htmlCls.spanNowrapStr+"6. "+e.htmlCls.buttonStr+"applycartoonshape'>Display",s+=e.htmlCls.space3+e.htmlCls.spanNowrapStr+e.htmlCls.buttonStr+"clearcartoonshape'>Clear",s+="",s+=e.htmlCls.divStr+"dl_distmanysets' class='"+n+"'>",s+=this.addNotebookTitle("dl_distmanysets","Measure distances among many sets"),s+=e.htmlCls.spanNowrapStr+"1. Select sets for pairwise distances
    ",s+="
    ",s+=e.htmlCls.divNowrapStr+"First sets:",s+="
    ",s+="
    ",s+=e.htmlCls.divNowrapStr+"Second sets:",s+="
    ",s+="
    ",s+=e.htmlCls.spanNowrapStr+"2. "+e.htmlCls.buttonStr+"applydisttable'>Distances in Table",s+="",s+=e.htmlCls.divStr+"dl_stabilizer_rm' class='"+n+"'>",s+=this.addNotebookTitle("dl_stabilizer_rm","Remove a stabilizer"),e.utilsCls.isMobile()?s+=e.htmlCls.spanNowrapStr+"1. Touch TWO atoms
    ":s+=e.htmlCls.spanNowrapStr+'1. Pick TWO atoms while holding "Alt" key
    ',s+=e.htmlCls.spanNowrapStr+"2. "+e.htmlCls.buttonStr+"applypick_stabilizer_rm'>Remove",s+="",s+=e.htmlCls.divStr+"dl_thickness' class='"+n+"'>",s+=this.addNotebookTitle("dl_thickness","Set thickness"),s+=e.htmlCls.setHtmlCls.setThicknessHtml("3dprint"),s+="",s+=e.htmlCls.divStr+"dl_thickness2' class='"+n+"'>",s+=this.addNotebookTitle("dl_thickness2","Set thickness"),s+=e.htmlCls.setHtmlCls.setThicknessHtml("style"),s+="",s+=e.htmlCls.divStr+"dl_menupref' class='"+n+"'>",s+=this.addNotebookTitle("dl_menupref","Preferences for menus"),s+="Note: The following parameters will be saved in cache. You just need to set them once.

    ",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"apply_menupref'>Apply",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"reset_menupref' style='margin-left:30px'>Reset to Simple Menus",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"reset_menupref_all' style='margin-left:30px'>Reset to All Menus",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"savepref' style='margin-left:30px'>Save Preferences

    ",s+="


    ",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"apply_menupref2'>Apply",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"reset_menupref2' style='margin-left:30px'>Reset to Simple Menus",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"reset_menupref_all2' style='margin-left:30px'>Reset to All Menus",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"savepref2' style='margin-left:30px'>Save Preferences",s+="",s+=e.htmlCls.divStr+"dl_addtrack' class='"+n+"'>",s+=this.addNotebookTitle("dl_addtrack","Add a track"),s+=" ",s+=e.htmlCls.divStr+"dl_addtrack_tabs' style='border:0px;'>",s+="",s+=e.htmlCls.divStr+"tracktab1'>",s+="NCBI gi/Accession: "+e.htmlCls.inputTextStr+"id='"+e.pre+"track_gi' placeholder='gi' size=16>

    ",s+=e.htmlCls.buttonStr+"addtrack_button1'>Add Track",s+="",s+=e.htmlCls.divStr+"tracktab2'>",s+="FASTA Title: "+e.htmlCls.inputTextStr+"id='"+e.pre+"fasta_title' placeholder='track title' size=16>

    ",s+="FASTA sequence:


    ",s+=e.htmlCls.buttonStr+"addtrack_button2'>Add Track",s+="",s+=e.htmlCls.divStr+"tracktab2b'>",s+="
    Note: The full protein sequences with gaps in MSA are listed one by one. The sequence of the structure is listed at the top. Each sequence has a title line starting with \">\".

    ",s+="Precalculated Multiple Sequence Alignment (MSA):
    ",s+="

    ",s+="Position of the first residue in Sequences & Annotations window: "+e.htmlCls.inputTextStr+"id='"+e.pre+"fasta_startpos' value='1' size=2>

    ",s+="Color Sequence by:

    ",s+=e.htmlCls.buttonStr+"addtrack_button2b'>Add Track(s)",s+="",s+=e.htmlCls.divStr+"tracktab2c'>",s+="
    Note: Show exons for all isoforms of the protein in the same gene as specified below.

    ",s+="NCBI Gene ID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"track_geneid' size=20>"+e.htmlCls.space3+e.htmlCls.buttonStr+"exons_table'>Exons & Introns in Gene Table

    ",s+="Position of the first residue in Sequences & Annotations window: "+e.htmlCls.inputTextStr+"id='"+e.pre+"fasta_startpos2' value='1' size=2>

    ",s+=e.htmlCls.buttonStr+"addtrack_button2c'>Show Isoforms & Exons",s+="",s+=e.htmlCls.divStr+"tracktab3'>",s+="BED file: "+e.htmlCls.inputFileStr+"id='"+e.pre+"track_bed' size=16>

    ",s+=e.htmlCls.buttonStr+"addtrack_button3'>Add Track",s+="",s+=e.htmlCls.divStr+"tracktab4'>",s+="Track Title: "+e.htmlCls.inputTextStr+"id='"+e.pre+"track_title' placeholder='track title' size=16>

    ",s+='Track Text (e.g., "2 G, 5-6 RR" defines a character "G" at the position 2 and two continuous characters "RR" at positions from 5 to 6. The starting position is 1):
    ',s+="

    ",s+=e.htmlCls.buttonStr+"addtrack_button4'>Add Track",s+="",s+=e.htmlCls.divStr+"tracktab5'>",s+="Track Title: "+e.htmlCls.inputTextStr+"id='"+e.pre+"track_selection' placeholder='track title' size=16>

    ",s+=e.htmlCls.buttonStr+"addtrack_button5'>Add Track",s+="",s+="",s+="",s+=e.htmlCls.divStr+"dl_saveselection' class='"+n+"'>",s+=this.addNotebookTitle("dl_saveselection","Save Selection");let m=t&&t.defNames2Atoms?Object.keys(t.defNames2Atoms).length:1;s+="Name: "+e.htmlCls.inputTextStr+"id='"+e.pre+"seq_command_name' value='seq_"+m+"' size='5'>
    ",s+="

    ",s+="",s+=e.htmlCls.divStr+"dl_copyurl' style='width:520px;' class='"+n+"'>",s+=this.addNotebookTitle("dl_copyurl","Share Link"),s+="
    ",s+="1. URLs Used in Browsers

    ",s+='Please copy one of the URLs below. They show the same result.
    (To add a title to share link, click "Windows > Your Note" and click "File > Share Link" again.)

    ',s+="Original URL with commands:


    ",e.cfg.notebook||(s+="Lifelong Short URL:(To replace this URL, send a pull request to update share.html at iCn3D GitHub)
    "+e.htmlCls.inputTextStr+"id='"+e.pre+"short_url' value='' style='width:100%'>

    ",s+='Lifelong Short URL + Window Title:(To update the window title, click "Analysis > Your Note/Window Title".)
    '+e.htmlCls.inputTextStr+"id='"+e.pre+"short_url_title' value='' style='width:100%'>

    "),s+="2. Commands Used in Jupyter Noteboook

    ",s+="Please copy the following commands into a cell in Jupyter Notebook to show the same result.
    More details are at https://github.com/ncbi/icn3d/tree/master/jupyternotebook.

    ",s+='
    ',s+=l+e.pre+'jn_copy">Copy Commands
    ',s+="",s+=e.htmlCls.divStr+"dl_selectannotations' class='"+n+" icn3d-annotation' style='background-color:white;'>",s+=this.addNotebookTitle("dl_selectannotations","Sequences & Annotations"),s+=e.htmlCls.divStr+"dl_annotations_tabs'>",s+=e.htmlCls.divStr+"dl_anno_view_tabs' style='border:0px; height:33px;'>",s+="",s+=e.htmlCls.divStr+"anno_tmp1'>",s+="",s+=e.htmlCls.divStr+"anno_tmp2'>",s+="",s+="",s+=this.getAnnoHeader(),s+="
    ",s+=e.htmlCls.divStr+"seqguide_wrapper' style='display:none'>
    "+e.htmlCls.setHtmlCls.setSequenceGuide("2")+"",s+="


    ",s+=e.htmlCls.divStr+"dl_annotations'>",s+="",s+="",s+=e.htmlCls.divStr+"dl_graph' style='background-color:white;' class='"+n+"'>",s+=this.addNotebookTitle("dl_graph","Interactions"),e.svgid=e.pre+"icn3d_viz",s+="",s+=e.htmlCls.divNowrapStr+"Zoom: mouse wheel; "+e.htmlCls.space3+" Move: left button; "+e.htmlCls.space3+" Select Multiple Nodes: Ctrl Key and drag an Area"+e.htmlCls.space3,s+='
    ',s+=e.htmlCls.divStr+"dl_svgcolor' style='display:none;'>",s+=e.htmlCls.divNowrapStr+'Click "View > H-Bonds & Interactions" to adjust parameters and relaunch the graph',s+=e.htmlCls.divNowrapStr+'Green: H-Bonds; ',s+='Cyan: Salt Bridge/Ionic; ',s+='Grey: contacts; ',s+='Orange: disulfide bonds',s+=e.htmlCls.divNowrapStr+'Magenta: Halogen Bonds; ',s+='Red: π-Cation; ',s+='Blue: π-Stacking',s+="",s+=e.htmlCls.divNowrapStr+l+e.svgid+'_svg">SVG'+e.htmlCls.space2,s+=l+e.svgid+'_png">PNG'+e.htmlCls.space2,s+=l+e.svgid+'_json">JSON',s+=e.htmlCls.space3+"
    Force on Nodes:
    ",s+=e.htmlCls.space3+"Label Size: ",s+=e.htmlCls.space3+"
    Internal Edges:
    ",s+="",s+='',s+="",s+=e.htmlCls.divStr+"dl_area' class='"+n+"'>",s+=this.addNotebookTitle("dl_area","Surface Area"),s+="Solvent Accessible Surface Area(SASA) calculated using the EDTSurf algorithm:
    ",s+='(0-20% out is considered "in". 50-100% out is considered "out".)

    ',s+="Toal: "+e.htmlCls.inputTextStr+"id='"+e.pre+"areavalue' value='' size='10'> Å2

    ",s+="
    ",s+="",s+=e.htmlCls.divStr+"dl_colorbyarea' class='"+n+"'>",s+=this.addNotebookTitle("dl_colorbyarea","Color by surface area"),s+="
    Color each residue based on the percentage of solvent accessilbe surface area. The color ranges from blue, to white, to red for a percentage of 0, 35(variable), and 100, respectively.

    ",s+="Middle Percentage(White): "+e.htmlCls.inputTextStr+"id='"+e.pre+"midpercent' value='35' size='10'>%

    ",s+="

    ",s+="",s+=e.htmlCls.divStr+"dl_rmsd' class='"+n+"' style='max-width:300px'>",s+=this.addNotebookTitle("dl_rmsd","RMSD",!0),s+="",s+=e.htmlCls.divStr+"dl_buriedarea' class='"+n+"'>",s+=this.addNotebookTitle("dl_buriedarea","Buried surface area",!0),s+="",s+=e.htmlCls.divStr+"dl_propbypercentout' class='"+n+"'>",s+=this.addNotebookTitle("dl_propbypercentout","Select residues basen on solvent accessilbe surface area"),s+="
    Select residue based on the percentage of solvent accessilbe surface area. The values are in the range of 0-100.

    ",s+="Min Percentage: "+e.htmlCls.inputTextStr+"id='"+e.pre+"minpercentout' value='0' size='10'>%
    ",s+="Max Percentage: "+e.htmlCls.inputTextStr+"id='"+e.pre+"maxpercentout' value='100' size='10'>%
    ",s+="

    ",s+="",s+=e.htmlCls.divStr+"dl_propbybfactor' class='"+n+"'>",s+=this.addNotebookTitle("dl_propbybfactor","Select residues basen on B-factor/pLDDT"),s+="
    Select residue based on B-factor/pLDDT. The values are in the range of 0-100.

    ",s+="Min B-factor/pLDDT: "+e.htmlCls.inputTextStr+"id='"+e.pre+"minbfactor' value='0' size='10'>%
    ",s+="Max B-factor/pLDDT: "+e.htmlCls.inputTextStr+"id='"+e.pre+"maxbfactor' value='100' size='10'>%
    ",s+="

    ",s+="",s+=e.htmlCls.divStr+"dl_legend' class='"+n+"' style='max-width:500px; background-color:white'>",s+=this.addNotebookTitle("dl_legend","Legend",!0),s+="",s+=e.htmlCls.divStr+"dl_disttable' class='"+n+"'>",s+=this.addNotebookTitle("dl_disttable","Distance Table",!0),s+="",s+=e.htmlCls.divStr+"dl_igrefTpl' class='"+n+"'>",s+=this.addNotebookTitle("dl_igrefTpl","Choose an Ig template"),s+="Choose an Ig template for selected residues:



    "+e.htmlCls.buttonStr+"mn6_igrefTpl_apply'>Show Ig Ref. Number",s+="",s+="",s+="\x3c!--/form--\x3e",s}getAnnoHeader(){let e=this.icn3dui;e.icn3d;let t="";t+="
    Annotations: 
    ",t+="
    ";let s="",t+=i+e.htmlCls.inputCheckStr+"id='"+e.pre+"anno_cdd' checked>Conserved Domains"+e.htmlCls.space2+"",t+=s+e.htmlCls.inputCheckStr+"id='"+e.pre+"anno_clinvar'>ClinVar"+e.htmlCls.space2+"",t+=s+e.htmlCls.inputCheckStr+"id='"+e.pre+"anno_binding'>Functional Sites"+e.htmlCls.space2+"",t+="",t+=s+e.htmlCls.inputCheckStr+"id='"+e.pre+"anno_custom'>Custom"+e.htmlCls.space2+"",t+=i+e.htmlCls.inputCheckStr+"id='"+e.pre+"anno_3dd'>3D Domains"+e.htmlCls.space2+"",t+=s+e.htmlCls.inputCheckStr+"id='"+e.pre+"anno_snp'>SNPs"+e.htmlCls.space2+"",t+=s+e.htmlCls.inputCheckStr+"id='"+e.pre+"anno_ptm'>PTM (UniProt)"+e.htmlCls.space2+"",t+="",t+="",t+=s+e.htmlCls.inputCheckStr+"id='"+e.pre+"anno_ssbond'>Disulfide Bonds"+e.htmlCls.space2+"",t+=s+e.htmlCls.inputCheckStr+"id='"+e.pre+"anno_interact'>Interactions"+e.htmlCls.space2+"",t+=s+e.htmlCls.inputCheckStr+"id='"+e.pre+"anno_crosslink'>Cross-Linkages"+e.htmlCls.space2+"",t+=s+e.htmlCls.inputCheckStr+"id='"+e.pre+"anno_transmem'>Transmembrane"+e.htmlCls.space2+"",t+="",t+="
    ",i="";return t+=s+e.htmlCls.inputCheckStr+"id='"+e.pre+"anno_all'>All"+e.htmlCls.space2+"
    ",t}}class p{constructor(e){this.icn3dui=e}setLogCmd(e,t,s){var i=this.icn3dui;i.icn3d,i.htmlCls.clickMenuCls.setLogCmd(e,t,s)}fullScreenChange(){let e=this.icn3dui,t=e.icn3d,s=this;e.bNode||document.fullscreenElement||document.webkitFullscreenElement||document.mozFullscreenElement||document.msFullscreenElement||(s.setLogCmd("exit full screen",!1),t.bFullscreen=!1,e.utilsCls.setViewerWidthHeight(e,!0),t.applyCenterCls.setWidthHeight(e.htmlCls.WIDTH,e.htmlCls.HEIGHT),t.drawCls.draw())}convertUniProtInChains(e){this.icn3dui.icn3d;let t=e.split(","),s="";for(let e=0,i=t.length;e0&&(i.hAtoms=i.definedSetsCls.getAtomsFromNameArray(l)),s.cfg.aligntool=e;let r="vast"==e?"structure align":"tmalign";if(r+=t?" msa":"",l.length>0?n.setLogCmd("realign on "+r+" | "+l,!0):n.setLogCmd("realign on "+r,!0),t){if(0==l.length){l=[];let e={};for(let t in i.chains){let s=i.firstAtomObjCls.getFirstAtomObj(i.chains[t]);e.hasOwnProperty(s.structure)||!i.proteins.hasOwnProperty(s.serial)&&!i.nucleotides.hasOwnProperty(s.serial)||(l.push(t),e[s.structure]=1)}}await i.realignParserCls.realignOnStructAlignMsa(l)}else await i.realignParserCls.realignOnStructAlign()}async readFile(e,t,s,i){let n=this.icn3dui.icn3d,l=this,r=t[s],o=e?"append":"load",a=new FileReader;a.onload=async function(a){let d=a.target.result;l.setLogCmd(o+" pdb file "+r.name,!1),e?(n.resetConfig(),n.bResetAnno=!0,n.bResetSets=!0):n.init(),n.bInputfile=!0,n.InputfileType="pdb",n.InputfileData=n.InputfileData?n.InputfileData+"\nENDMDL\n"+d:d,i=s>0?i+"\nENDMDL\n"+d:d,Object.keys(t).length==s+1?(e&&(n.hAtoms={},n.dAtoms={}),await n.pdbParserCls.loadPdbData(i,void 0,void 0,e)):await l.readFile(e,t,s+1,i),e&&(n.bSetChainsAdvancedMenu&&n.definedSetsCls.showSets(),n.bResetAnno=!0,n.bAnnoShown&&(await n.showAnnoCls.showAnnotations(),n.annotationCls.resetAnnoTabAll()))},"object"==typeof r&&a.readAsText(r)}async loadPdbFile(e){let t=this.icn3dui,s=t.icn3d,i=e?"pdbfile_app":"pdbfile";s.bInitial=!0,t.cfg.notebook||dialog.dialog("close"),t.cfg.notebook?s.resizeCanvasCls.closeDialogs():$(".ui-dialog-content").dialog("close");let n=$("#"+t.pre+i)[0].files;n[0]?(t.htmlCls.setHtmlCls.fileSupport(),s.molTitle="",s.dataStrAll="",await this.readFile(e,n,0,"")):alert("Please select a file before clicking 'Load'")}saveHtml(e){let t=this.icn3dui.icn3d,s="";s+='\n',s+='\n',s+=$("#"+e).html();let i=e.split("_"),n=i.length>2?i[2]:e,l=Object.keys(t.structures)[0];Object.keys(t.structures).length>1&&(l+="-"+Object.keys(t.structures)[1]),t.saveFileCls.saveFile(l+"-"+n+".html","html",encodeURIComponent(s))}setPredefinedMenu(e){let t=this.icn3dui,s=t.icn3d;if(Object.keys(s.chains).length<2)return void alert("At least two chains are required for alignment...");t.htmlCls.clickMenuCls.SetChainsAdvancedMenu();let i=s.definedSetsCls.setAtomMenu(["protein"]);$("#"+t.pre+e).length&&$("#"+t.pre+e).html(i),$("#"+t.pre+e).resizable()}async launchMmdb(e,t,s,i){let n=this.icn3dui,l=n.icn3d,r=this;n.cfg.notebook||dialog.dialog("close");let o=t?1:0;if(!(e=e.replace(/,/g," ").replace(/\s+/g,",").trim()))return void alert("Please enter a list of PDB IDs or AlphaFold UniProt IDs...");let a=e.split(",");if(i)if(l.structures||1!=a.length||4!=a[0].length&&isNaN(a[0])){n.cfg.mmdbafid=e,n.cfg.bu=o,l.bMmdbafid=!0,l.inputid=l.inputid?l.inputid+n.cfg.mmdbafid:n.cfg.mmdbafid,1==n.cfg.bu?l.loadCmd="load mmdbaf1 "+n.cfg.mmdbafid:l.loadCmd="load mmdbaf0 "+n.cfg.mmdbafid,n.htmlCls.clickMenuCls.setLogCmd(l.loadCmd,!0);let t=!!(l.structures&&Object.keys(l.structures).length>0);await l.chainalignParserCls.downloadMmdbAf(n.cfg.mmdbafid),t&&(l.bSetChainsAdvancedMenu&&l.definedSetsCls.showSets(),l.bAnnoShown&&(await l.showAnnoCls.showAnnotations(),l.annotationCls.resetAnnoTabAll()))}else{r.setLogCmd("load mmdb"+o+" "+e,!1);let t=l.structures&&Object.keys(l.structures).length>0?"_blank":"_self";window.open(s+"?mmdbid="+e+"&bu="+o,t)}else if(1!=a.length||4!=a[0].length&&isNaN(a[0])){r.setLogCmd("load mmdbaf"+o+" "+e,!1);let t=l.structures&&Object.keys(l.structures).length>0?"_blank":"_self";window.open(s+"?mmdbafid="+e+"&bu="+o,t)}else{r.setLogCmd("load mmdb"+o+" "+e,!1);let t=l.structures&&Object.keys(l.structures).length>0?"_blank":"_self";window.open(s+"?mmdbid="+e+"&bu="+o,t)}}allEventFunctions(){let e=this.icn3dui,t=e.icn3d,s=this;if(e.bNode)return;let i=document.URL,n=i.indexOf("?");i=-1==n?i:i.substr(0,n),"https://www.ncbi.nlm.nih.gov/Structure/vast/icn3d/"==i&&(i="https://www.ncbi.nlm.nih.gov/Structure/icn3d/"),t.definedSetsCls.clickCustomAtoms(),t.definedSetsCls.clickCommand_apply(),t.definedSetsCls.clickModeswitch(),t.selectionCls.clickShow_selected(),t.selectionCls.clickHide_selected(),t.diagram2dCls.click2Ddgm(),t.cartoon2dCls.click2Dcartoon(),t.addTrackCls.clickAddTrackButton(),t.resizeCanvasCls.windowResize(),t.annotationCls.setTabs(),t.resid2specCls.switchHighlightLevel(),e.utilsCls.isMobile()?(t.hlSeqCls.selectSequenceMobile(),t.hlSeqCls.selectChainMobile()):t.hlSeqCls.selectSequenceNonMobile(),e.htmlCls.clickMenuCls.clickMenu1(),e.htmlCls.clickMenuCls.clickMenu2(),e.htmlCls.clickMenuCls.clickMenu3(),e.htmlCls.clickMenuCls.clickMenu4(),e.htmlCls.clickMenuCls.clickMenu5(),e.htmlCls.clickMenuCls.clickMenu6(),e.myEventCls.onIds(["#"+e.pre+"back","#"+e.pre+"mn6_back"],"click",(async function(t){let i=e.icn3d;t.preventDefault(),s.setLogCmd("back",!1),await i.resizeCanvasCls.back()})),e.myEventCls.onIds(["#"+e.pre+"forward","#"+e.pre+"mn6_forward"],"click",(async function(t){let i=e.icn3d;t.preventDefault(),s.setLogCmd("forward",!1),await i.resizeCanvasCls.forward()})),e.myEventCls.onIds(["#"+e.pre+"fullscreen","#"+e.pre+"mn6_fullscreen"],"click",(function(t){let i=e.icn3d;t.preventDefault(),s.setLogCmd("enter full screen",!1),i.bFullscreen=!0,e.htmlCls.WIDTH=$(window).width(),e.htmlCls.HEIGHT=$(window).height(),i.applyCenterCls.setWidthHeight(e.htmlCls.WIDTH,e.htmlCls.HEIGHT),i.drawCls.draw(),i.resizeCanvasCls.openFullscreen($("#"+e.pre+"canvas")[0])})),document.addEventListener("fullscreenchange",this.fullScreenChange.bind(this)),document.addEventListener("webkitfullscreenchange",this.fullScreenChange.bind(this)),document.addEventListener("mozfullscreenchange",this.fullScreenChange.bind(this)),document.addEventListener("msfullscreenchange",this.fullScreenChange.bind(this)),e.myEventCls.onIds(["#"+e.pre+"toggle","#"+e.pre+"mn2_toggle"],"click",(function(t){e.icn3d.selectionCls.toggleSelection(),s.setLogCmd("toggle selection",!0)})),e.myEventCls.onIds("#"+e.pre+"mn2_hl_clrYellow","click",(function(t){let i=e.icn3d;s.setLogCmd("set highlight color yellow",!0),i.hColor=e.parasCls.thr(16776960),i.matShader=i.setColorCls.setOutlineColor("yellow"),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn2_hl_clrGreen","click",(function(t){let i=e.icn3d;s.setLogCmd("set highlight color green",!0),i.hColor=e.parasCls.thr(65280),i.matShader=i.setColorCls.setOutlineColor("green"),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn2_hl_clrRed","click",(function(t){let i=e.icn3d;s.setLogCmd("set highlight color red",!0),i.hColor=e.parasCls.thr(16711680),i.matShader=i.setColorCls.setOutlineColor("red"),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn2_hl_styleOutline","click",(function(t){let i=e.icn3d;s.setLogCmd("set highlight style outline",!0),i.bHighlight=1,i.hlUpdateCls.showHighlight()})),e.myEventCls.onIds("#"+e.pre+"mn2_hl_styleObject","click",(function(t){let i=e.icn3d;s.setLogCmd("set highlight style 3d",!0),i.bHighlight=2,i.hlUpdateCls.showHighlight()})),e.myEventCls.onIds("#"+e.pre+"mn2_hl_styleNone","click",(function(t){let i=e.icn3d;t.stopImmediatePropagation(),i.hlUpdateCls.clearHighlight(),s.setLogCmd("clear selection",!0)})),e.myEventCls.onIds(["#"+e.pre+"alternate","#"+e.pre+"mn2_alternate","#"+e.pre+"alternate2"],"click",(async function(t){let i=e.icn3d;i.bAlternate=!0,await i.alternateCls.alternateStructures(),i.bAlternate=!1,s.setLogCmd("alternate structures",!1)})),e.myEventCls.onIds("#"+e.pre+"mn2_realignresbyres","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_realignresbyres","Align multiple chains residue by residue")})),e.myEventCls.onIds("#"+e.pre+"realignSelection","click",(function(t){let i=e.icn3d;Object.keys(i.chains).length<2?alert("At least two chains are required for alignment..."):(i.realignParserCls.realign(),s.setLogCmd("realign",!0))})),e.myEventCls.onIds("#"+e.pre+"mn2_realignonseqalign","click",(function(t){e.icn3d.bRender&&e.htmlCls.dialogCls.openDlg("dl_realign","Please select chains to realign"),s.setPredefinedMenu("atomsCustomRealign")})),e.myEventCls.onIds("#"+e.pre+"mn2_realignonstruct","click",(function(t){e.icn3d.bRender&&e.htmlCls.dialogCls.openDlg("dl_realignbystruct","Please select chains to realign"),s.setPredefinedMenu("atomsCustomRealignByStruct")})),e.myEventCls.onIds("#"+e.pre+"mn2_realigntwostru","click",(function(t){e.icn3d.bRender&&e.htmlCls.dialogCls.openDlg("dl_realigntwostru","Please select structures to realign"),s.setPredefinedMenu("atomsCustomRealignByStruct2")})),e.myEventCls.onIds("#"+e.pre+"applyRealign","click",(async function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"atomsCustomRealign").val();n.length>0&&(i.hAtoms=i.definedSetsCls.getAtomsFromNameArray(n)),await i.realignParserCls.realignOnSeqAlign(),n.length>0?s.setLogCmd("realign on seq align | "+n,!0):s.setLogCmd("realign on seq align",!0)})),e.myEventCls.onIds("#"+e.pre+"applyRealignByStruct","click",(async function(t){e.icn3d,t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),await s.setRealign("vast",!1)})),e.myEventCls.onIds("#"+e.pre+"applyRealignByStruct_tmalign","click",(async function(t){e.icn3d,t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),await s.setRealign("tmalign",!1)})),e.myEventCls.onIds("#"+e.pre+"applyRealignByStructMsa","click",(async function(t){e.icn3d,t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),await s.setRealign("vast",!0)})),e.myEventCls.onIds("#"+e.pre+"applyRealignByStructMsa_tmalign","click",(async function(t){e.icn3d,t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),await s.setRealign("tmalign",!0)})),e.myEventCls.onIds("#"+e.pre+"applyRealignByStruct_vastplus","click",(async function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"atomsCustomRealignByStruct2").val();n.length>0&&(i.hAtoms=i.definedSetsCls.getAtomsFromNameArray(n)),await i.vastplusCls.realignOnVastplus(),n.length>0?s.setLogCmd("realign on vastplus | "+n,!0):s.setLogCmd("realign on vastplus",!0)})),e.myEventCls.onIds("#"+e.pre+"applyColorSpectrumAcrossSets","click",(function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"atomsCustomColorSpectrumAcross").val();if(0==n.length)return void alert("Please select some sets");i.setColorCls.setColorAcrossSets(n,!0),s.setLogCmd("set color spectrum | "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"applyColorSpectrumBySets","click",(function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"atomsCustomColorSpectrum").val();if(0==n.length)return void alert("Please select some sets");i.setColorCls.setColorBySets(n,!0),s.setLogCmd("set residues color spectrum | "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"applyColorRainbowAcrossSets","click",(function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"atomsCustomColorRainbowAcross").val();if(0==n.length)return void alert("Please select some sets");i.setColorCls.setColorAcrossSets(n,!1),s.setLogCmd("set color rainbow | "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"applyColorRainbowBySets","click",(function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"atomsCustomColorRainbow").val();if(0==n.length)return void alert("Please select some sets");i.setColorCls.setColorBySets(n,!1),s.setLogCmd("set residues color rainbow | "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"anno_summary","click",(function(t){let i=e.icn3d;t.preventDefault(),i.annotationCls.setAnnoViewAndDisplay("overview"),s.setLogCmd("set view overview",!0)})),e.myEventCls.onIds("#"+e.pre+"anno_details","click",(function(t){let i=e.icn3d;t.preventDefault(),i.annotationCls.setAnnoViewAndDisplay("detailed view"),s.setLogCmd("set view detailed view",!0)})),e.myEventCls.onIds("#"+e.pre+"show_annotations","click",(async function(t){let i=e.icn3d;await i.showAnnoCls.showAnnotations(),s.setLogCmd("view annotations",!0)})),e.myEventCls.onIds("#"+e.pre+"showallchains","click",(function(t){e.icn3d.annotationCls.showAnnoAllChains(),s.setLogCmd("show annotations all chains",!0)})),e.myEventCls.onIds("#"+e.pre+"show_alignsequences","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_alignment","Select residues in aligned sequences")})),e.myEventCls.onIds(["#"+e.pre+"show_2ddgm","#"+e.pre+"mn2_2ddgm"],"click",(async function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_2ddgm","2D Diagram"),await i.viewInterPairsCls.retrieveInteractionData(),s.setLogCmd("view interactions",!0)})),e.myEventCls.onIds("#"+e.pre+"search_seq_button","click",(async function(t){e.icn3d,t.stopImmediatePropagation(),await s.searchSeq()})),e.myEventCls.onIds("#"+e.pre+"search_seq","keyup",(async function(t){e.icn3d,13===t.keyCode&&(t.preventDefault(),await s.searchSeq())})),e.myEventCls.onIds("#"+e.pre+"reload_vastplus","click",(function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),s.setLogCmd("vast+ search "+$("#"+e.pre+"vastpluspdbid").val(),!1);let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open("https://www.ncbi.nlm.nih.gov/Structure/vastplus/vastplus.cgi?uid="+$("#"+e.pre+"vastpluspdbid").val(),n)})),e.myEventCls.onIds("#"+e.pre+"reload_vast","click",(function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),s.setLogCmd("vast search "+$("#"+e.pre+"vastpdbid").val()+"_"+$("#"+e.pre+"vastchainid").val(),!1);let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open("https://www.ncbi.nlm.nih.gov/Structure/vast/vastsrv.cgi?pdbid="+$("#"+e.pre+"vastpdbid").val()+"&chain="+$("#"+e.pre+"vastchainid").val(),n)})),e.myEventCls.onIds("#"+e.pre+"reload_foldseek","click",(function(t){e.icn3d,t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"foldseekchainids").val(),l=s.convertUniProtInChains(n);s.setLogCmd("load chainalignment "+l,!0),window.open(i+"?chainalign="+l+"&aligntool=tmalign&showalignseq=1&bu=0","_self")})),e.myEventCls.onIds("#"+e.pre+"reload_mmtf","click",(function(t){let n=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),s.setLogCmd("load mmtf "+$("#"+e.pre+"mmtfid").val(),!1);let l=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?mmtfid="+$("#"+e.pre+"mmtfid").val(),l)})),e.myEventCls.onIds("#"+e.pre+"mmtfid","keyup",(function(t){let n=e.icn3d;if(13===t.keyCode){t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),s.setLogCmd("load mmtf "+$("#"+e.pre+"mmtfid").val(),!1);let l=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?mmtfid="+$("#"+e.pre+"mmtfid").val(),l)}})),e.myEventCls.onIds("#"+e.pre+"reload_pdb","click",(function(t){let n=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),s.setLogCmd("load pdb "+$("#"+e.pre+"pdbid").val(),!1);let l=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?pdbid="+$("#"+e.pre+"pdbid").val(),l)})),e.myEventCls.onIds("#"+e.pre+"pdbid","keyup",(function(t){let n=e.icn3d;if(13===t.keyCode){t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),s.setLogCmd("load pdb "+$("#"+e.pre+"pdbid").val(),!1);let l=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?pdbid="+$("#"+e.pre+"pdbid").val(),l)}})),e.myEventCls.onIds("#"+e.pre+"reload_af","click",(function(t){let n=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),s.setLogCmd("load af "+$("#"+e.pre+"afid").val(),!1);let l=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?afid="+$("#"+e.pre+"afid").val(),l)})),e.myEventCls.onIds("#"+e.pre+"reload_afmap","click",(async function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let n=e.cfg.afid?e.cfg.afid:$("#"+e.pre+"afid").val();s.setLogCmd("set half pae map "+n,!0),await i.contactMapCls.afErrorMap(n)})),e.myEventCls.onIds("#"+e.pre+"reload_afmapfull","click",(async function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let n=e.cfg.afid?e.cfg.afid:$("#"+e.pre+"afid").val();s.setLogCmd("set full pae map "+n,!0),await i.contactMapCls.afErrorMap(n,!0)})),e.myEventCls.onIds("#"+e.pre+"afid","keyup",(function(t){let n=e.icn3d;if(13===t.keyCode){t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),s.setLogCmd("load af "+$("#"+e.pre+"afid").val(),!1);let l=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?afid="+$("#"+e.pre+"afid").val(),l)}})),e.myEventCls.onIds("#"+e.pre+"reload_opm","click",(function(t){let n=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),s.setLogCmd("load opm "+$("#"+e.pre+"opmid").val(),!1);let l=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?opmid="+$("#"+e.pre+"opmid").val(),l)})),e.myEventCls.onIds("#"+e.pre+"opmid","keyup",(function(t){let n=e.icn3d;if(13===t.keyCode){t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),s.setLogCmd("load opm "+$("#"+e.pre+"opmid").val(),!1);let l=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?opmid="+$("#"+e.pre+"opmid").val(),l)}})),e.myEventCls.onIds("#"+e.pre+"reload_align_refined","click",(function(t){let n=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let l=$("#"+e.pre+"alignid1").val()+","+$("#"+e.pre+"alignid2").val();s.setLogCmd("load alignment "+l+" | parameters &atype=1&bu=1",!1);let r=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?align="+l+"&showalignseq=1&atype=1&bu=1",r)})),e.myEventCls.onIds("#"+e.pre+"reload_align_ori","click",(function(t){let n=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let l=$("#"+e.pre+"alignid1").val()+","+$("#"+e.pre+"alignid2").val();s.setLogCmd("load alignment "+l+" | parameters &atype=0&bu=1",!1);let r=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?align="+l+"&showalignseq=1&atype=0&bu=1",r)})),e.myEventCls.onIds("#"+e.pre+"reload_align_tmalign","click",(function(t){let n=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let l=$("#"+e.pre+"alignid1").val()+","+$("#"+e.pre+"alignid2").val();s.setLogCmd("load alignment "+l+" | parameters &atype=2&bu=1",!1);let r=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?align="+l+"&showalignseq=1&atype=2&bu=1",r)})),e.myEventCls.onIds("#"+e.pre+"reload_alignaf","click",(function(t){let n=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let l=$("#"+e.pre+"alignafid1").val()+"_A,"+$("#"+e.pre+"alignafid2").val()+"_A";s.setLogCmd("load chains "+l+" | residues | resdef ",!1);let r=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?chainalign="+l+"&resnum=&resdef=&showalignseq=1",r)})),e.myEventCls.onIds("#"+e.pre+"reload_alignaf_tmalign","click",(function(t){let n=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let l=$("#"+e.pre+"alignafid1").val()+"_A,"+$("#"+e.pre+"alignafid2").val()+"_A";s.setLogCmd("load chains "+l+" | residues | resdef | align tmalign",!1);let r=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?chainalign="+l+"&aligntool=tmalign&resnum=&resdef=&showalignseq=1",r)})),e.myEventCls.onIds("#"+e.pre+"reload_chainalign_asym","click",(function(t){let n=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let l=$("#"+e.pre+"chainalignids").val(),r=s.convertUniProtInChains(l);s.setLogCmd("load chains "+r+" on asymmetric unit | residues | resdef ",!1);let o=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?chainalign="+r+"&resnum=&resdef=&showalignseq=1&bu=0",o)})),e.myEventCls.onIds("#"+e.pre+"reload_chainalign_asym2","click",(function(t){let n=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let l=$("#"+e.pre+"chainalignids2").val(),r=s.convertUniProtInChains(l),o=$("#"+e.pre+"resalignids").val();s.setLogCmd("load chains "+r+" on asymmetric unit | residues "+o+" | resdef ",!1);let a=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?chainalign="+r+"&resnum="+o+"&resdef=&showalignseq=1&bu=0",a)})),e.myEventCls.onIds("#"+e.pre+"reload_chainalign_asym3","click",(function(t){let n=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let l=$("#"+e.pre+"chainalignids3").val(),r=s.convertUniProtInChains(l),o=$("#"+e.pre+"predefinedres").val().trim().replace(/\n/g,": ");if(o&&r.split(",").length-1!=o.split(": ").length)return void alert("Please make sure the number of chains and the lines of predefined residues are the same...");s.setLogCmd("load chains "+r+" on asymmetric unit | residues | resdef "+o,!1);let a=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?chainalign="+r+"&resnum=&resdef="+o+"&showalignseq=1&bu=0",a)})),e.myEventCls.onIds("#"+e.pre+"reload_chainalign_asym4","click",(async function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"chainalignids4").val(),l=s.convertUniProtInChains(n),r=$("#"+e.pre+"predefinedres2").val().trim().replace(/\n/g,": ");if(r&&l.split(",").length-1!=r.split(": ").length)return void alert("Please make sure the number of chains and the lines of predefined residues are the same...");e.cfg.resdef=r.replace(/:/gi,";");let o=l.split(",");await i.realignParserCls.realignChainOnSeqAlign(void 0,o,!0,!0),s.setLogCmd("realign predefined "+l+" "+r,!0)})),e.myEventCls.onIds("#"+e.pre+"reload_chainalign_tmalign","click",(function(t){let n=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let l=$("#"+e.pre+"chainalignids").val(),r=s.convertUniProtInChains(l);s.setLogCmd("load chains "+r+" on asymmetric unit | residues | resdef | align tmalign",!1);let o=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?chainalign="+r+"&aligntool=tmalign&resnum=&resdef=&showalignseq=1&bu=0",o)})),e.myEventCls.onIds("#"+e.pre+"reload_mutation_3d","click",(async function(t){let n=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let l,r,o=$("#"+e.pre+"mutationids").val();if(l=$("#"+e.pre+"type_mmdbid").is(":checked")?"mmdbid":"afid",r=$("#"+e.pre+"showin_currentpage").is(":checked")?"currentpage":"newpage","currentpage"==r){let e=o;await n.scapCls.retrieveScap(e),s.setLogCmd("scap 3d "+e,!0),s.setLogCmd("select displayed set",!0)}else{let e=o.substr(0,o.indexOf("_"));s.setLogCmd("3d of mutation "+o,!1);let t=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?"+l+"="+e+"&command=scap 3d "+o+"; select displayed set",t)}})),e.myEventCls.onIds("#"+e.pre+"reload_mutation_pdb","click",(async function(t){let n=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let l,r,o=$("#"+e.pre+"mutationids").val();if(l=$("#"+e.pre+"type_mmdbid").is(":checked")?"mmdbid":"afid",r=$("#"+e.pre+"showin_currentpage").is(":checked")?"currentpage":"newpage","currentpage"==r){let e=o,t=!0;await n.scapCls.retrieveScap(e,void 0,t),s.setLogCmd("scap pdb "+e,!0)}else{let e=o.substr(0,o.indexOf("_"));s.setLogCmd("pdb of mutation "+o,!1);let t=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?"+l+"="+e+"&command=scap pdb "+o+"; select displayed set",t)}})),e.myEventCls.onIds("#"+e.pre+"reload_mutation_inter","click",(async function(t){let n=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let l,r,o=$("#"+e.pre+"mutationids").val();if(l=$("#"+e.pre+"type_mmdbid").is(":checked")?"mmdbid":"afid",r=$("#"+e.pre+"showin_currentpage").is(":checked")?"currentpage":"newpage","currentpage"==r){let e=o,t=!0;await n.scapCls.retrieveScap(e,t),s.setLogCmd("scap interaction "+e,!0);let i=e.split("_"),l="."+i[1]+":"+i[2],r="snp_"+i[1]+"_"+i[2];s.setLogCmd("select "+l+" | name "+r,!0),s.setLogCmd("line graph interaction pairs | selected non-selected | hbonds,salt bridge,interactions,halogen,pi-cation,pi-stacking | false | threshold 3.8 6 4 3.8 6 5.5",!0),s.setLogCmd("adjust dialog dl_linegraph",!0),s.setLogCmd("select displayed set",!0)}else{let e=o.split(","),t=[];for(let s=0,i=e.length;s0?"_blank":"_self";window.open(i+"?"+l+"="+r+"&command=scap interaction "+o,a)}})),e.myEventCls.onIds("#"+e.pre+"reload_mmcif","click",(function(t){let n=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),s.setLogCmd("load mmcif "+$("#"+e.pre+"mmcifid").val(),!1);let l=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?mmcifid="+$("#"+e.pre+"mmcifid").val(),l)})),e.myEventCls.onIds("#"+e.pre+"mmcifid","keyup",(function(t){let n=e.icn3d;if(13===t.keyCode){t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),s.setLogCmd("load mmcif "+$("#"+e.pre+"mmcifid").val(),!1);let l=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?mmcifid="+$("#"+e.pre+"mmcifid").val(),l)}})),e.myEventCls.onIds("#"+e.pre+"reload_mmdb","click",(function(t){let n=e.icn3d;t.preventDefault(),s.setLogCmd("load mmdb1 "+$("#"+e.pre+"mmdbid").val(),!1);let l=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?mmdbid="+$("#"+e.pre+"mmdbid").val()+"&bu=1",l)})),e.myEventCls.onIds("#"+e.pre+"reload_mmdb_asym","click",(function(t){let n=e.icn3d;t.preventDefault(),s.setLogCmd("load mmdb0 "+$("#"+e.pre+"mmdbid").val(),!1);let l=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?mmdbid="+$("#"+e.pre+"mmdbid").val()+"&bu=0",l)})),e.myEventCls.onIds("#"+e.pre+"reload_mmdbaf","click",(function(t){e.icn3d,t.preventDefault();let n=$("#"+e.pre+"mmdbafid").val();s.launchMmdb(n,1,i)})),e.myEventCls.onIds("#"+e.pre+"reload_mmdbaf_asym","click",(function(t){e.icn3d,t.preventDefault();let n=$("#"+e.pre+"mmdbafid").val();s.launchMmdb(n,0,i)})),e.myEventCls.onIds("#"+e.pre+"reload_mmdbaf_append","click",(function(t){e.icn3d,t.preventDefault();let n=$("#"+e.pre+"mmdbafid").val();s.launchMmdb(n,1,i,!0)})),e.myEventCls.onIds("#"+e.pre+"reload_mmdbaf_asym_append","click",(function(t){e.icn3d,t.preventDefault();let n=$("#"+e.pre+"mmdbafid").val();s.launchMmdb(n,0,i,!0)})),e.myEventCls.onIds("#"+e.pre+"mmdbid","keyup",(function(t){let n=e.icn3d;if(13===t.keyCode){t.preventDefault(),s.setLogCmd("load mmdb1 "+$("#"+e.pre+"mmdbid").val(),!1);let l=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?mmdbid="+$("#"+e.pre+"mmdbid").val()+"&bu=1",l)}})),e.myEventCls.onIds("#"+e.pre+"mmdbafid","keyup",(function(t){if(e.icn3d,13===t.keyCode){t.preventDefault();let n=$("#"+e.pre+"mmdbafid").val();s.launchMmdb(n,1,i)}})),e.myEventCls.onIds("#"+e.pre+"reload_blast_rep_id","click",(function(t){let n=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let l=$("#"+e.pre+"query_id").val(),r=encodeURIComponent($("#"+e.pre+"query_fasta").val()),o=$("#"+e.pre+"blast_rep_id").val();s.setLogCmd("load seq_struct_ids "+l+","+o,!1),l=""!==l&&void 0!==l?l:r;let a=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?from=icn3d&alg=blast&blast_rep_id="+o+"&query_id="+l+"&command=view annotations; set annotation cdd; set annotation site; set view detailed view; select chain "+o+"; show selection",a)})),e.myEventCls.onIds("#"+e.pre+"run_esmfold","click",(async function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),$("#"+e.pre+"dl_mmdbafid").hasClass("ui-dialog-content")&&$("#"+e.pre+"dl_mmdbafid").dialog("close");let n=$("#"+e.pre+"esmfold_fasta").val(),l="stru--";if(-1!=n.indexOf(">")){let e=n.indexOf("\n");if(i.esmTitle=n.substr(1,e-1).trim(),-1!=i.esmTitle.indexOf("|")){let e=i.esmTitle.split("|");l=e.length>2?e[1]:i.esmTitle}else l=-1!=i.esmTitle.indexOf(" ")?i.esmTitle.substr(0,i.esmTitle.indexOf(" ")):i.esmTitle;l.length<6&&(l=l.padEnd(6,"-")),n=n.substr(e+1)}if(n=n.replace(/\s/g,""),n.length>400)return void alert("Your sequence is larger than 400 characters. Please consider to split it as described at https://github.com/facebookresearch/esm/issues/21.");s.setLogCmd("Run ESMFold with the sequence "+n,!1);let r=await e.getAjaxPostPromise("https://api.esmatlas.com/foldSequence/v1/pdb/",n,!0,"Problem in returning PDB from ESMFold server...",void 0,!0,"text");i.bResetAnno=!0,i.bInputfile=!0,i.InputfileType="pdb",i.InputfileData=i.InputfileData?i.InputfileData+"\nENDMDL\n"+r:r,i.bEsmfold=!0;await i.pdbParserCls.loadPdbData(r,l,void 0,!0,void 0,void 0,void 0,i.bEsmfold)})),e.myEventCls.onIds("#"+e.pre+"reload_alignsw","click",(function(t){let n=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let l=$("#"+e.pre+"query_id").val(),r=encodeURIComponent($("#"+e.pre+"query_fasta").val()),o=$("#"+e.pre+"blast_rep_id").val();s.setLogCmd("load seq_struct_ids_smithwm "+l+","+o,!1),l=""!==l&&void 0!==l?l:r;let a=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?from=icn3d&alg=smithwm&blast_rep_id="+o+"&query_id="+l+"&command=view annotations; set annotation cdd; set annotation site; set view detailed view; select chain "+o+"; show selection",a)})),e.myEventCls.onIds("#"+e.pre+"reload_alignswlocal","click",(function(t){let n=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let l=$("#"+e.pre+"query_id").val(),r=encodeURIComponent($("#"+e.pre+"query_fasta").val()),o=$("#"+e.pre+"blast_rep_id").val();s.setLogCmd("load seq_struct_ids_local_smithwm "+l+","+o,!1),l=""!==l&&void 0!==l?l:r;let a=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?from=icn3d&alg=local_smithwm&blast_rep_id="+o+"&query_id="+l+"&command=view annotations; set annotation cdd; set annotation site; set view detailed view; select chain "+o+"; show selection",a)})),e.myEventCls.onIds("#"+e.pre+"reload_proteinname","click",(function(t){let n=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),s.setLogCmd("load protein "+$("#"+e.pre+"proteinname").val(),!1);let l=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?protein="+$("#"+e.pre+"proteinname").val(),l)})),e.myEventCls.onIds("#"+e.pre+"reload_refseq","click",(function(t){let n=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),s.setLogCmd("load refseq "+$("#"+e.pre+"refseqid").val(),!1);let l=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?refseqid="+$("#"+e.pre+"refseqid").val(),l)})),e.myEventCls.onIds("#"+e.pre+"gi","keyup",(function(t){let n=e.icn3d;if(13===t.keyCode){t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),s.setLogCmd("load gi "+$("#"+e.pre+"gi").val(),!1);let l=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?gi="+$("#"+e.pre+"gi").val(),l)}})),e.myEventCls.onIds("#"+e.pre+"reload_uniprotid","click",(function(t){let n=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),s.setLogCmd("load uniprotid "+$("#"+e.pre+"uniprotid").val(),!1);let l=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?uniprotid="+$("#"+e.pre+"uniprotid").val(),l)})),e.myEventCls.onIds("#"+e.pre+"uniprotid","keyup",(function(t){let n=e.icn3d;if(13===t.keyCode){t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),s.setLogCmd("load uniprotid "+$("#"+e.pre+"uniprotid").val(),!1);let l=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?uniprotid="+$("#"+e.pre+"uniprotid").val(),l)}})),e.myEventCls.onIds("#"+e.pre+"reload_cid","click",(function(t){let n=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),s.setLogCmd("load cid "+$("#"+e.pre+"cid").val(),!1);let l=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?cid="+$("#"+e.pre+"cid").val(),l)})),e.myEventCls.onIds("#"+e.pre+"cid","keyup",(function(t){let n=e.icn3d;if(13===t.keyCode){t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),s.setLogCmd("load cid "+$("#"+e.pre+"cid").val(),!1);let l=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?cid="+$("#"+e.pre+"cid").val(),l)}})),e.htmlCls.setHtmlCls.clickReload_pngimage(),e.myEventCls.onIds("#"+e.pre+"reload_state","click",(function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),e.cfg.notebook?i.resizeCanvasCls.closeDialogs():$(".ui-dialog-content").dialog("close"),i.bInputfile||i.init();let n=$("#"+e.pre+"state")[0].files[0];if(n){e.htmlCls.setHtmlCls.fileSupport();let t=new FileReader;t.onload=async function(t){i.bStatefile=!0;let n=t.target.result;s.setLogCmd("load state file "+$("#"+e.pre+"state").val(),!1),i.commands=[],i.optsHistory=[],await i.loadScriptCls.loadScript(n,!0)},t.readAsText(n)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"reload_selectionfile","click",(function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"selectionfile")[0].files[0];if(n){e.htmlCls.setHtmlCls.fileSupport();let t=new FileReader;t.onload=async function(t){let n=t.target.result;await i.selectionCls.loadSelection(n),s.setLogCmd("load selection file "+$("#"+e.pre+"selectionfile").val(),!1)},t.readAsText(n)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"reload_dsn6file2fofc","click",(function(t){let s=e.icn3d;t.preventDefault(),s.dsn6ParserCls.loadDsn6File("2fofc")})),e.myEventCls.onIds("#"+e.pre+"reload_dsn6filefofc","click",(function(t){let s=e.icn3d;t.preventDefault(),s.dsn6ParserCls.loadDsn6File("fofc")})),e.myEventCls.onIds("#"+e.pre+"reload_ccp4file2fofc","click",(function(t){let s=e.icn3d;t.preventDefault(),s.ccp4ParserCls.loadCcp4File("2fofc")})),e.myEventCls.onIds("#"+e.pre+"reload_ccp4filefofc","click",(function(t){let s=e.icn3d;t.preventDefault(),s.ccp4ParserCls.loadCcp4File("fofc")})),e.myEventCls.onIds("#"+e.pre+"reload_mtzfile2fofc","click",(function(t){let s=e.icn3d;t.preventDefault(),s.mtzParserCls.loadMtzFile("2fofc")})),e.myEventCls.onIds("#"+e.pre+"reload_mtzfilefofc","click",(function(t){let s=e.icn3d;t.preventDefault(),s.mtzParserCls.loadMtzFile("fofc")})),e.myEventCls.onIds("#"+e.pre+"reload_delphifile","click",(async function(t){let s=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),await s.delphiCls.loadDelphiFile("delphi")})),e.myEventCls.onIds("#"+e.pre+"reload_pqrfile","click",(function(t){let s=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),s.delphiCls.loadPhiFile("pqr")})),e.myEventCls.onIds("#"+e.pre+"reload_phifile","click",(function(t){let s=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),s.delphiCls.loadPhiFile("phi")})),e.myEventCls.onIds("#"+e.pre+"reload_cubefile","click",(function(t){let s=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),s.delphiCls.loadPhiFile("cube")})),e.myEventCls.onIds("#"+e.pre+"reload_pqrurlfile","click",(async function(t){let s=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),await s.delphiCls.loadPhiFileUrl("pqrurl")})),e.myEventCls.onIds("#"+e.pre+"reload_phiurlfile","click",(async function(t){let s=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),await s.delphiCls.loadPhiFileUrl("phiurl")})),e.myEventCls.onIds("#"+e.pre+"reload_cubeurlfile","click",(async function(t){let s=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),await s.delphiCls.loadPhiFileUrl("cubeurl")})),e.myEventCls.onIds("#"+e.pre+"reload_delphifile2","click",(async function(t){let s=e.icn3d;t.preventDefault(),e.htmlCls.setHtmlCls.updateSurfPara("delphi"),e.cfg.notebook||dialog.dialog("close"),await s.delphiCls.loadDelphiFile("delphi2")})),e.myEventCls.onIds("#"+e.pre+"reload_pqrfile2","click",(function(t){let s=e.icn3d;t.preventDefault(),e.htmlCls.setHtmlCls.updateSurfPara("phi"),e.cfg.notebook||dialog.dialog("close"),s.delphiCls.loadPhiFile("pqr2")})),e.myEventCls.onIds("#"+e.pre+"reload_phifile2","click",(function(t){let s=e.icn3d;t.preventDefault(),e.htmlCls.setHtmlCls.updateSurfPara("phi"),e.cfg.notebook||dialog.dialog("close"),s.delphiCls.loadPhiFile("phi2")})),e.myEventCls.onIds("#"+e.pre+"reload_cubefile2","click",(function(t){let s=e.icn3d;t.preventDefault(),e.htmlCls.setHtmlCls.updateSurfPara("phi"),e.cfg.notebook||dialog.dialog("close"),s.delphiCls.loadPhiFile("cube2")})),e.myEventCls.onIds("#"+e.pre+"reload_pqrurlfile2","click",(async function(t){let s=e.icn3d;t.preventDefault(),e.htmlCls.setHtmlCls.updateSurfPara("phiurl"),e.cfg.notebook||dialog.dialog("close"),await s.delphiCls.loadPhiFileUrl("pqrurl2")})),e.myEventCls.onIds("#"+e.pre+"reload_phiurlfile2","click",(async function(t){let s=e.icn3d;t.preventDefault(),e.htmlCls.setHtmlCls.updateSurfPara("phiurl"),e.cfg.notebook||dialog.dialog("close"),await s.delphiCls.loadPhiFileUrl("phiurl2")})),e.myEventCls.onIds("#"+e.pre+"reload_cubeurlfile2","click",(async function(t){let s=e.icn3d;t.preventDefault(),e.htmlCls.setHtmlCls.updateSurfPara("phiurl"),e.cfg.notebook||dialog.dialog("close"),await s.delphiCls.loadPhiFileUrl("cubeurl2")})),e.myEventCls.onIds("#"+e.pre+"reload_dsn6fileurl2fofc","click",(function(t){let s=e.icn3d;t.preventDefault(),s.dsn6ParserCls.loadDsn6FileUrl("2fofc")})),e.myEventCls.onIds("#"+e.pre+"reload_dsn6fileurlfofc","click",(function(t){let s=e.icn3d;t.preventDefault(),s.dsn6ParserCls.loadDsn6FileUrl("fofc")})),e.myEventCls.onIds("#"+e.pre+"reload_ccp4fileurl2fofc","click",(function(t){let s=e.icn3d;t.preventDefault(),s.ccp4ParserCls.loadCcp4FileUrl("2fofc")})),e.myEventCls.onIds("#"+e.pre+"reload_ccp4fileurlfofc","click",(function(t){let s=e.icn3d;t.preventDefault(),s.ccp4ParserCls.loadCcp4FileUrl("fofc")})),e.myEventCls.onIds("#"+e.pre+"reload_mtzfileurl2fofc","click",(function(t){let s=e.icn3d;t.preventDefault(),s.mtzParserCls.loadMtzFileUrl("2fofc")})),e.myEventCls.onIds("#"+e.pre+"reload_mtzfileurlfofc","click",(function(t){let s=e.icn3d;t.preventDefault(),s.mtzParserCls.loadMtzFileUrl("fofc")})),e.myEventCls.onIds("#"+e.pre+"reload_pdbfile","click",(async function(t){e.icn3d,t.preventDefault();await s.loadPdbFile(!1)})),e.myEventCls.onIds("#"+e.pre+"reload_pdbfile_app","click",(async function(t){let i=e.icn3d;t.preventDefault(),i.bAppend=!0,await s.loadPdbFile(i.bAppend)})),e.myEventCls.onIds("#"+e.pre+"reload_mol2file","click",(function(t){let i=e.icn3d;t.preventDefault(),i.bInitial=!0,e.cfg.notebook||dialog.dialog("close"),e.cfg.notebook?i.resizeCanvasCls.closeDialogs():$(".ui-dialog-content").dialog("close");let n=$("#"+e.pre+"mol2file")[0].files[0];if(n){e.htmlCls.setHtmlCls.fileSupport();let t=new FileReader;t.onload=async function(t){let n=t.target.result;s.setLogCmd("load mol2 file "+$("#"+e.pre+"mol2file").val(),!1),i.molTitle="",i.inputid=void 0,i.init(),i.bInputfile=!0,i.InputfileData=i.InputfileData?i.InputfileData+"\nENDMDL\n"+n:n,i.InputfileType="mol2",await i.mol2ParserCls.loadMol2Data(n)},t.readAsText(n)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"reload_sdffile","click",(function(t){let i=e.icn3d;t.preventDefault(),i.bInitial=!0,e.cfg.notebook||dialog.dialog("close"),e.cfg.notebook?i.resizeCanvasCls.closeDialogs():$(".ui-dialog-content").dialog("close");let n=$("#"+e.pre+"sdffile")[0].files[0];if(n){e.htmlCls.setHtmlCls.fileSupport();let t=new FileReader;t.onload=async function(t){let n=t.target.result;s.setLogCmd("load sdf file "+$("#"+e.pre+"sdffile").val(),!1),i.molTitle="",i.inputid=void 0,i.init(),i.bInputfile=!0,i.InputfileData=i.InputfileData?i.InputfileData+"\nENDMDL\n"+n:n,i.InputfileType="sdf",await i.sdfParserCls.loadSdfData(n)},t.readAsText(n)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"reload_xyzfile","click",(function(t){let i=e.icn3d;t.preventDefault(),i.bInitial=!0,e.cfg.notebook||dialog.dialog("close"),e.cfg.notebook?i.resizeCanvasCls.closeDialogs():$(".ui-dialog-content").dialog("close");let n=$("#"+e.pre+"xyzfile")[0].files[0];if(n){e.htmlCls.setHtmlCls.fileSupport();let t=new FileReader;t.onload=async function(t){let n=t.target.result;s.setLogCmd("load xyz file "+$("#"+e.pre+"xyzfile").val(),!1),i.molTitle="",i.inputid=void 0,i.init(),i.bInputfile=!0,i.InputfileData=i.InputfileData?i.InputfileData+"\nENDMDL\n"+n:n,i.InputfileType="xyz",await i.xyzParserCls.loadXyzData(n)},t.readAsText(n)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"reload_afmapfile","click",(function(t){let i=e.icn3d;t.preventDefault(),i.bInitial=!0,e.cfg.notebook||dialog.dialog("close"),e.cfg.notebook?i.resizeCanvasCls.closeDialogs():$(".ui-dialog-content").dialog("close");let n=$("#"+e.pre+"afmapfile")[0].files[0];if(n){e.htmlCls.setHtmlCls.fileSupport();let t=new FileReader;t.onload=function(t){let n=t.target.result;s.setLogCmd("load AlphaFold PAE file "+$("#"+e.pre+"afmapfile").val(),!1),e.htmlCls.dialogCls.openDlg("dl_alignerrormap","Show Predicted Aligned Error (PAE) map"),i.contactMapCls.processAfErrorMap(JSON.parse(n))},t.readAsText(n)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"reload_afmapfilefull","click",(function(t){let i=e.icn3d;t.preventDefault(),i.bInitial=!0,e.cfg.notebook||dialog.dialog("close"),e.cfg.notebook?i.resizeCanvasCls.closeDialogs():$(".ui-dialog-content").dialog("close");let n=$("#"+e.pre+"afmapfile")[0].files[0];if(n){e.htmlCls.setHtmlCls.fileSupport();let t=new FileReader;t.onload=function(t){let n=t.target.result;s.setLogCmd("load AlphaFold PAE file "+$("#"+e.pre+"afmapfile").val(),!1),e.htmlCls.dialogCls.openDlg("dl_alignerrormap","Show Predicted Aligned Error (PAE) map"),i.contactMapCls.processAfErrorMap(JSON.parse(n),!0)},t.readAsText(n)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"reload_urlfile","click",(async function(t){let s=e.icn3d;t.preventDefault(),s.bInitial=!0,e.cfg.notebook||dialog.dialog("close"),e.cfg.notebook?s.resizeCanvasCls.closeDialogs():$(".ui-dialog-content").dialog("close");let i=$("#"+e.pre+"filetype").val(),n=$("#"+e.pre+"urlfile").val();s.inputurl="type="+i+"&url="+encodeURIComponent(n),s.init(),s.bInputfile=!0,s.bInputUrlfile=!0,await s.pdbParserCls.downloadUrl(n,i)})),e.myEventCls.onIds("#"+e.pre+"reload_mmciffile","click",(function(t){let i=e.icn3d;t.preventDefault(),i.bInitial=!0,e.cfg.notebook||dialog.dialog("close"),e.cfg.notebook?i.resizeCanvasCls.closeDialogs():$(".ui-dialog-content").dialog("close");let n=$("#"+e.pre+"mmciffile")[0].files[0];if(n){e.htmlCls.setHtmlCls.fileSupport();let t=new FileReader;t.onload=async function(t){let n=t.target.result;s.setLogCmd("load mmcif file "+$("#"+e.pre+"mmciffile").val(),!1),i.molTitle="";let l=e.htmlCls.baseUrl+"mmcifparser/mmcifparser.cgi",r={mmciffile:n},o=await e.getAjaxPostPromise(l,r,!0);i.init(),i.bInputfile=!0,i.InputfileData=i.InputfileData?i.InputfileData+"\nENDMDL\n"+o:o,i.InputfileType="mmcif",await i.mmcifParserCls.loadMmcifData(o)},t.readAsText(n)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"applycustomcolor","click",(function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),i.setOptionCls.setOption("color",$("#"+e.pre+"colorcustom").val()),s.setLogCmd("color "+$("#"+e.pre+"colorcustom").val(),!0)})),e.myEventCls.onIds(["#"+e.pre+"atomsCustomSphere2","#"+e.pre+"atomsCustomSphere","#"+e.pre+"radius_aroundsphere"],"change",(function(t){e.icn3d.bSphereCalc=!1})),e.myEventCls.onIds("#"+e.pre+"applypick_aroundsphere","click",(function(t){let i=e.icn3d,n=parseFloat($("#"+e.pre+"radius_aroundsphere").val()),l=$("#"+e.pre+"atomsCustomSphere").val(),r=$("#"+e.pre+"atomsCustomSphere2").val();if(0==r.length)alert("Please select the first set at step #1");else{let e="select zone cutoff "+n+" | sets "+r+" "+l+" | "+i.bSphereCalc;i.bSphereCalc||i.showInterCls.pickCustomSphere(n,r,l,i.bSphereCalc),i.bSphereCalc=!0,i.hlUpdateCls.updateHlAll(),s.setLogCmd(e,!0)}})),e.myEventCls.onIds("#"+e.pre+"sphereExport","click",(function(t){let i=e.icn3d;t.preventDefault();let n=parseFloat($("#"+e.pre+"radius_aroundsphere").val()),l=$("#"+e.pre+"atomsCustomSphere").val(),r=$("#"+e.pre+"atomsCustomSphere2").val();if(0==r.length)alert("Please select the first set at step #1");else{i.showInterCls.pickCustomSphere(n,r,l,i.bSphereCalc),i.bSphereCalc=!0;let t=i.viewInterPairsCls.exportSpherePairs(),o=Object.keys(e.utilsCls.getHlStructures()).join(",");i.saveFileCls.saveFile(o+"_sphere_pairs.html","html",t),s.setLogCmd("export pairs | "+r+" "+l+" | dist "+n,!0)}})),e.myEventCls.onIds("#"+e.pre+"apply_adjustmem","click",(function(t){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close");let n=parseFloat($("#"+e.pre+"extra_mem_z").val()),l=parseFloat($("#"+e.pre+"intra_mem_z").val());i.selectionCls.adjustMembrane(n,l);let r="adjust membrane z-axis "+n+" "+l;s.setLogCmd(r,!0)})),e.myEventCls.onIds("#"+e.pre+"apply_selectplane","click",(function(t){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close");let n=parseFloat($("#"+e.pre+"selectplane_z1").val()),l=parseFloat($("#"+e.pre+"selectplane_z2").val());i.selectionCls.selectBtwPlanes(n,l);let r="select planes z-axis "+n+" "+l;s.setLogCmd(r,!0)})),e.myEventCls.onIds(["#"+e.pre+"atomsCustomHbond2","#"+e.pre+"atomsCustomHbond","#"+e.pre+"analysis_hbond","#"+e.pre+"analysis_saltbridge","#"+e.pre+"analysis_contact","#"+e.pre+"hbondthreshold","#"+e.pre+"saltbridgethreshold","#"+e.pre+"contactthreshold"],"change",(function(t){e.icn3d.bHbondCalc=!1})),e.myEventCls.onIds("#"+e.pre+"crossstrucinter","change",(function(t){let i=e.icn3d;t.preventDefault(),i.crossstrucinter=parseInt($("#"+e.pre+"crossstrucinter").val()),s.setLogCmd("cross structure interaction "+i.crossstrucinter,!0)})),e.myEventCls.onIds("#"+e.pre+"applyhbonds","click",(async function(t){let s=e.icn3d;t.preventDefault(),await s.showInterCls.showInteractions("3d")})),e.myEventCls.onIds("#"+e.pre+"applycontactmap","click",(async function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let n=parseFloat($("#"+i.pre+"contactdist").val()),l=$("#"+i.pre+"contacttype").val();await i.contactMapCls.contactMap(n,l),s.setLogCmd("contact map | dist "+n+" | type "+l,!0)})),e.myEventCls.onIds("#"+e.pre+"hbondWindow","click",(async function(t){let s=e.icn3d;t.preventDefault(),await s.showInterCls.showInteractions("view")})),e.myEventCls.onIds("#"+e.pre+"areaWindow","click",(function(t){let i=e.icn3d;t.preventDefault();let n=$("#"+e.pre+"atomsCustomHbond").val(),l=$("#"+e.pre+"atomsCustomHbond2").val();i.analysisCls.calcBuriedSurface(l,n),s.setLogCmd("calc buried surface | "+l+" "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"sortSet1","click",(async function(t){let s=e.icn3d;t.preventDefault(),await s.showInterCls.showInteractions("save1")})),$(document).on("click","."+e.pre+"showintercntonly",(function(t){e.icn3d,t.stopImmediatePropagation(),$(".icn3d-border").hide(),s.setLogCmd("table inter count only",!0)})),$(document).on("click","."+e.pre+"showinterdetails",(function(t){e.icn3d,t.stopImmediatePropagation(),$(".icn3d-border").show(),s.setLogCmd("table inter details",!0)})),e.myEventCls.onIds("#"+e.pre+"sortSet2","click",(async function(t){let s=e.icn3d;t.preventDefault(),await s.showInterCls.showInteractions("save2")})),e.myEventCls.onIds("#"+e.pre+"hbondGraph","click",(async function(t){let s=e.icn3d;t.preventDefault(),await s.showInterCls.showInteractions("graph")})),e.myEventCls.onIds("#"+e.pre+"hbondLineGraph","click",(async function(t){let i=e.icn3d;t.preventDefault(),i.bShownRefnum=!1,s.setLogCmd("hide ref number",!0),await i.showInterCls.showInteractions("linegraph")})),e.myEventCls.onIds("#"+e.pre+"hbondLineGraph2","click",(async function(t){let i=e.icn3d;t.preventDefault(),i.bShownRefnum=!0,s.setLogCmd("show ref number",!0),await i.showInterCls.showInteractions("linegraph")})),e.myEventCls.onIds("#"+e.pre+"hbondScatterplot","click",(async function(t){let i=e.icn3d;t.preventDefault(),i.bShownRefnum=!1,s.setLogCmd("hide ref number",!0),await i.showInterCls.showInteractions("scatterplot")})),e.myEventCls.onIds("#"+e.pre+"hbondScatterplot2","click",(async function(t){let i=e.icn3d;t.preventDefault(),i.bShownRefnum=!0,s.setLogCmd("show ref number",!0),await i.showInterCls.showInteractions("scatterplot")})),$(document).on("click","#"+e.svgid+" circle.selected",(function(t){let s=e.icn3d;t.stopImmediatePropagation();let i=$(this).attr("res");!1!==s.bSelectResidue||s.bShift||s.bCtrl||s.selectionCls.removeSelection(),void 0!==i&&(s.hlSeqCls.selectResidues(i,this),s.hlObjectsCls.addHlObjects())})),e.myEventCls.onIds("#"+e.svgid+"_svg","click",(function(t){let s=e.icn3d;t.preventDefault(),s.saveFileCls.saveSvg(e.svgid,s.inputid+"_force_directed_graph.svg")})),e.myEventCls.onIds("#"+e.svgid+"_png","click",(function(t){let s=e.icn3d;t.preventDefault(),s.saveFileCls.savePng(e.svgid,s.inputid+"_force_directed_graph.png")})),e.myEventCls.onIds("#"+e.svgid+"_json","click",(function(t){let s=e.icn3d;t.preventDefault();let i=s.graphStr.substr(0,s.graphStr.lastIndexOf("}"));i+=e.htmlCls.setHtmlCls.getLinkColor(),s.saveFileCls.saveFile(s.inputid+"_force_directed_graph.json","text",[i])})),$(document).on("click","#"+e.svgid_ct+"_svg",(function(t){let s=e.icn3d;t.preventDefault(),s.saveFileCls.saveSvg(e.svgid_ct,s.inputid+"_cartoon.svg")})),$(document).on("click","#"+e.svgid_ct+"_png",(function(t){let s=e.icn3d;t.preventDefault(),s.saveFileCls.savePng(e.svgid_ct,s.inputid+"_cartoon.png")})),$(document).on("click","#"+e.svgid_ct+"_json",(function(t){let s=e.icn3d;t.preventDefault(),s.saveFileCls.saveFile(s.inputid+"_cartoon.json","text",[s.graphStr])})),$(document).on("change","#"+e.svgid_ct+"_label",(function(t){e.icn3d,t.preventDefault();let i=$("#"+e.svgid_ct+"_label").val();$("#"+e.svgid_ct+" text").removeClass(),$("#"+e.svgid_ct+" text").addClass(i),s.setLogCmd("cartoon label "+i,!0)})),e.myEventCls.onIds("#"+e.linegraphid+"_svg","click",(function(t){let s=e.icn3d;t.preventDefault(),s.saveFileCls.saveSvg(e.linegraphid,s.inputid+"_line_graph.svg")})),e.myEventCls.onIds("#"+e.linegraphid+"_png","click",(function(t){let s=e.icn3d;t.preventDefault(),s.saveFileCls.savePng(e.linegraphid,s.inputid+"_line_graph.png")})),e.myEventCls.onIds("#"+e.linegraphid+"_json","click",(function(t){let s=e.icn3d;t.preventDefault();let i=s.lineGraphStr.substr(0,s.lineGraphStr.lastIndexOf("}"));i+=e.htmlCls.setHtmlCls.getLinkColor(),s.saveFileCls.saveFile(s.inputid+"_line_graph.json","text",[i])})),e.myEventCls.onIds("#"+e.linegraphid+"_scale","change",(function(t){let i=e.icn3d;t.preventDefault();let n=$("#"+e.linegraphid+"_scale").val();$("#"+e.linegraphid).attr("width",(i.linegraphWidth*parseFloat(n)).toString()+"px"),s.setLogCmd("line graph scale "+n,!0)})),e.myEventCls.onIds("#"+e.scatterplotid+"_svg","click",(function(t){let s=e.icn3d;t.preventDefault(),s.saveFileCls.saveSvg(e.scatterplotid,s.inputid+"_scatterplot.svg")})),e.myEventCls.onIds("#"+e.scatterplotid+"_png","click",(function(t){let s=e.icn3d;t.preventDefault(),s.saveFileCls.savePng(e.scatterplotid,s.inputid+"_scatterplot.png")})),e.myEventCls.onIds("#"+e.scatterplotid+"_json","click",(function(t){let s=e.icn3d;t.preventDefault();let i=s.scatterplotStr.substr(0,s.scatterplotStr.lastIndexOf("}"));i+=e.htmlCls.setHtmlCls.getLinkColor(),s.saveFileCls.saveFile(s.inputid+"_scatterplot.json","text",[i])})),e.myEventCls.onIds("#"+e.scatterplotid+"_scale","change",(function(t){let i=e.icn3d;t.preventDefault();let n=$("#"+e.scatterplotid+"_scale").val();$("#"+e.scatterplotid).attr("width",(i.scatterplotWidth*parseFloat(n)).toString()+"px"),s.setLogCmd("scatterplot scale "+n,!0)})),e.myEventCls.onIds("#"+e.contactmapid+"_svg","click",(function(t){let s=e.icn3d;t.preventDefault(),s.saveFileCls.saveSvg(e.contactmapid,s.inputid+"_contactmap.svg",!0)})),e.myEventCls.onIds("#"+e.contactmapid+"_png","click",(function(t){let s=e.icn3d;t.preventDefault(),s.saveFileCls.savePng(e.contactmapid,s.inputid+"_contactmap.png",!0)})),e.myEventCls.onIds("#"+e.contactmapid+"_json","click",(function(t){let s=e.icn3d;t.preventDefault();let i=s.contactmapStr.substr(0,s.contactmapStr.lastIndexOf("}"));i+=e.htmlCls.setHtmlCls.getLinkColor(),s.saveFileCls.saveFile(s.inputid+"_contactmap.json","text",[i])})),e.myEventCls.onIds("#"+e.contactmapid+"_scale","change",(function(t){let i=e.icn3d;t.preventDefault();let n=$("#"+e.contactmapid+"_scale").val();$("#"+e.contactmapid).attr("width",(i.contactmapWidth*parseFloat(n)).toString()+"px"),s.setLogCmd("contactmap scale "+n,!0)})),e.myEventCls.onIds("#"+e.alignerrormapid+"_svg","click",(function(t){let s=e.icn3d;t.preventDefault();$("#"+e.alignerrormapid+"_scale").val(1),$("#"+e.alignerrormapid).attr("width",(s.alignerrormapWidth*parseFloat(1)).toString()+"px"),s.saveFileCls.saveSvg(e.alignerrormapid,s.inputid+"_alignerrormap.svg",!0)})),e.myEventCls.onIds("#"+e.alignerrormapid+"_png","click",(function(t){let s=e.icn3d;t.preventDefault();$("#"+e.alignerrormapid+"_scale").val(1),$("#"+e.alignerrormapid).attr("width",(s.alignerrormapWidth*parseFloat(1)).toString()+"px"),s.saveFileCls.savePng(e.alignerrormapid,s.inputid+"_alignerrormap.png",!0)})),e.myEventCls.onIds("#"+e.alignerrormapid+"_full","click",(async function(t){let s=e.icn3d;t.preventDefault(),await s.contactMapCls.afErrorMap(afid,!0)})),e.myEventCls.onIds("#"+e.alignerrormapid+"_json","click",(function(t){let s=e.icn3d;t.preventDefault();let i=s.alignerrormapStr.substr(0,s.alignerrormapStr.lastIndexOf("}"));i+=e.htmlCls.setHtmlCls.getLinkColor(),s.saveFileCls.saveFile(s.inputid+"_alignerrormap.json","text",[i])})),e.myEventCls.onIds("#"+e.alignerrormapid+"_scale","change",(function(t){let i=e.icn3d;t.preventDefault();let n=$("#"+e.alignerrormapid+"_scale").val();$("#"+e.alignerrormapid).attr("width",(i.alignerrormapWidth*parseFloat(n)).toString()+"px"),s.setLogCmd("alignerrormap scale "+n,!0)})),e.myEventCls.onIds("#"+e.svgid+"_label","change",(function(t){e.icn3d,t.preventDefault();let i=$("#"+e.svgid+"_label").val();$("#"+e.svgid+" text").removeClass(),$("#"+e.svgid+" text").addClass(i),s.setLogCmd("graph label "+i,!0)})),e.myEventCls.onIds("#"+e.svgid+"_hideedges","change",(function(t){let i=e.icn3d;t.preventDefault(),e.htmlCls.hideedges=parseInt($("#"+e.svgid+"_hideedges").val()),e.htmlCls.hideedges?(e.htmlCls.contactInsideColor="FFF",e.htmlCls.hbondInsideColor="FFF",e.htmlCls.ionicInsideColor="FFF"):(e.htmlCls.contactInsideColor="DDD",e.htmlCls.hbondInsideColor="AFA",e.htmlCls.ionicInsideColor="8FF"),void 0!==i.graphStr&&(i.bRender&&e.htmlCls.force&&e.drawGraph(i.graphStr,e.pre+"dl_graph"),s.setLogCmd("hide edges "+e.htmlCls.hideedges,!0))})),e.myEventCls.onIds("#"+e.svgid+"_force","change",(function(t){let i=e.icn3d;t.preventDefault(),e.htmlCls.force=parseInt($("#"+e.svgid+"_force").val()),void 0!==i.graphStr&&(s.setLogCmd("graph force "+e.htmlCls.force,!0),i.getGraphCls.handleForce())})),e.myEventCls.onIds("#"+e.pre+"hbondReset","click",(function(t){let i=e.icn3d;t.preventDefault(),i.viewInterPairsCls.resetInteractionPairs(),s.setLogCmd("reset interaction pairs",!0)})),e.myEventCls.onIds("#"+e.pre+"applypick_labels","click",(function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"labeltext").val(),l=$("#"+e.pre+"labelsize").val(),r=$("#"+e.pre+"labelcolor").val(),o=$("#"+e.pre+"labelbkgd").val();if("0"!==l&&""!==l&&"undefined"!==l||(l=0),"0"!==r&&""!==r&&"undefined"!==r||(r=0),"0"!==o&&""!==o&&"undefined"!==o||(o=0),void 0===i.pAtom||void 0===i.pAtom2)alert("Please pick another atom");else{let e=(i.pAtom.coord.x+i.pAtom2.coord.x)/2,t=(i.pAtom.coord.y+i.pAtom2.coord.y)/2,a=(i.pAtom.coord.z+i.pAtom2.coord.z)/2;i.analysisCls.addLabel(n,e,t,a,l,r,o,"custom"),i.pickpair=!1;let d="",c="",h="";0!=l&&(d=" | size "+l),0!=r&&(c=" | color "+r),0!=o&&(h=" | background "+o),s.setLogCmd("add label "+n+" | x "+e.toPrecision(4)+" y "+t.toPrecision(4)+" z "+a.toPrecision(4)+d+c+h+" | type custom",!0),i.drawCls.draw()}})),e.myEventCls.onIds("#"+e.pre+"applyselection_labels","click",(function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"labeltext2").val(),l=$("#"+e.pre+"labelsize2").val(),r=$("#"+e.pre+"labelcolor2").val(),o=$("#"+e.pre+"labelbkgd2").val();"0"!==l&&""!==l&&"undefined"!==l||(l=0),"0"!==r&&""!==r&&"undefined"!==r||(r=0),"0"!==o&&""!==o&&"undefined"!==o||(o=0);let a=i.applyCenterCls.centerAtoms(e.hashUtilsCls.hash2Atoms(i.hAtoms,i.atoms)),d=a.center.x,c=a.center.y,h=a.center.z;i.analysisCls.addLabel(n,d,c,h,l,r,o,"custom");let p="",m="",u="";0!=l&&(p=" | size "+l),0!=r&&(m=" | color "+r),0!=o&&(u=" | background "+o),s.setLogCmd("add label "+n+" | x "+d.toPrecision(4)+" y "+c.toPrecision(4)+" z "+h.toPrecision(4)+p+m+u+" | type custom",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"applylabelcolor","click",(function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),i.labelcolor=$("#"+e.pre+"labelcolorall").val(),s.setLogCmd("set label color "+i.labelcolor,!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"applypick_stabilizer","click",(function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),void 0===i.pAtom||void 0===i.pAtom2?alert("Please pick another atom"):(i.pickpair=!1,s.setLogCmd("add one stabilizer | "+i.pAtom.serial+" "+i.pAtom2.serial,!0),void 0===i.pairArray&&(i.pairArray=[]),i.pairArray.push(i.pAtom.serial),i.pairArray.push(i.pAtom2.serial),i.threeDPrintCls.setThichknessFor3Dprint(),i.drawCls.draw())}));let l=new CP(document.querySelector("#"+e.pre+"colorcustom"));l.on("change",(function(e){this.target.value=e})),e.myEventCls.onIds("#"+e.pre+"colorcustom","input",(function(){let t=$("#"+e.pre+"colorcustom").val();l.set("#"+t).enter()})),e.myEventCls.onIds("#"+e.pre+"colorcustom","keyup",(function(){let t=$("#"+e.pre+"colorcustom").val();l.set("#"+t).enter()})),e.myEventCls.onIds("#"+e.pre+"colorcustom","paste",(function(){let t=$("#"+e.pre+"colorcustom").val();l.set("#"+t).enter()})),e.myEventCls.onIds("#"+e.pre+"colorcustom","cut",(function(){let t=$("#"+e.pre+"colorcustom").val();l.set("#"+t).enter()}));let r=new CP(document.querySelector("#"+e.pre+"labelcolorall"));r.on("change",(function(e){this.target.value=e})),e.myEventCls.onIds("#"+e.pre+"labelcolorall","input",(function(){let t=$("#"+e.pre+"labelcolorall").val();r.set("#"+t).enter()})),e.myEventCls.onIds("#"+e.pre+"labelcolorall","keyup",(function(){let t=$("#"+e.pre+"labelcolorall").val();r.set("#"+t).enter()})),e.myEventCls.onIds("#"+e.pre+"labelcolorall","paste",(function(){let t=$("#"+e.pre+"labelcolorall").val();r.set("#"+t).enter()})),e.myEventCls.onIds("#"+e.pre+"labelcolorall","cut",(function(){let t=$("#"+e.pre+"labelcolorall").val();r.set("#"+t).enter()})),e.myEventCls.onIds("#"+e.pre+"applypick_stabilizer_rm","click",(function(t){let i=e.icn3d;if(t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),void 0===i.pAtom||void 0===i.pAtom2)alert("Please pick another atom");else{i.pickpair=!1,s.setLogCmd("remove one stabilizer | "+i.pAtom.serial+" "+i.pAtom2.serial,!0);let e=[];e.push(i.pAtom.serial),e.push(i.pAtom2.serial),i.threeDPrintCls.removeOneStabilizer(e),i.drawCls.draw()}})),e.myEventCls.onIds("#"+e.pre+"applypick_measuredistance","click",(function(t){let i=e.icn3d;if(t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),i.bMeasureDistance=!1,void 0===i.pAtom||void 0===i.pAtom2)alert("Please pick another atom");else{let t=0,n=0,l=$("#"+e.pre+"linecolor").val(),r=(i.pAtom.coord.x+i.pAtom2.coord.x)/2,o=(i.pAtom.coord.y+i.pAtom2.coord.y)/2,a=(i.pAtom.coord.z+i.pAtom2.coord.z)/2;i.analysisCls.addLineFromPicking("distance");let d=(parseInt(10*i.pAtom.coord.distanceTo(i.pAtom2.coord))/10).toString()+" A";i.analysisCls.addLabel(d,r,o,a,t,l,n,"distance");let c="",h="",p="";0!=l&&(h=" | color "+l),s.setLogCmd("add label "+d+" | x "+r.toPrecision(4)+" y "+o.toPrecision(4)+" z "+a.toPrecision(4)+c+h+p+" | type distance",!0),i.drawCls.draw(),i.pk=2}})),e.myEventCls.onIds("#"+e.pre+"applydist2","click",(function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),i.bMeasureDistance=!1;let n=$("#"+e.pre+"atomsCustomDist").val(),l=$("#"+e.pre+"atomsCustomDist2").val();i.analysisCls.measureDistTwoSets(n,l),s.setLogCmd("dist | "+l+" "+n,!0)})),$(document).on("click",".icn3d-distance",(function(t){let i=e.icn3d;t.preventDefault(),i.bMeasureDistance=!1,i.distPnts=[],i.labels.distance=[],i.lines.distance=[];let n=$(this).attr("sets").split("|"),l=[n[0]],r=[n[1]];i.analysisCls.measureDistTwoSets(l,r),s.setLogCmd("dist | "+r+" "+l,!0)})),e.myEventCls.onIds("#"+e.pre+"applydisttable","click",(function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),i.bMeasureDistance=!1;let n=$("#"+e.pre+"atomsCustomDistTable").val(),l=$("#"+e.pre+"atomsCustomDistTable2").val();i.analysisCls.measureDistManySets(n,l),e.htmlCls.dialogCls.openDlg("dl_disttable","Distance among the sets"),s.setLogCmd("disttable | "+l+" "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"applylinebtwsets","click",(function(t){let i=e.icn3d;t.preventDefault(),i.bLinebtwsets=!1;let n=$("#"+e.pre+"linebtwsets").val(),l=$("#"+e.pre+"linebtwsets2").val(),r=i.definedSetsCls.getAtomsFromNameArray(n),o=i.definedSetsCls.getAtomsFromNameArray(l),a=i.contactCls.getExtent(r),d=i.contactCls.getExtent(o),c=new THREE.Vector3(a[2][0],a[2][1],a[2][2]),h=new THREE.Vector3(d[2][0],d[2][1],d[2][2]),p=$("#"+e.pre+"linebtwsets_radius").val(),m=$("#"+e.pre+"linebtwsets_customcolor").val(),u=$("#"+e.pre+"linebtwsets_opacity").val(),g="Solid"!=$("#"+e.pre+"linebtwsets_style").val(),f="cylinder",b="add line | x1 "+c.x.toPrecision(4)+" y1 "+c.y.toPrecision(4)+" z1 "+c.z.toPrecision(4)+" | x2 "+h.x.toPrecision(4)+" y2 "+h.y.toPrecision(4)+" z2 "+h.z.toPrecision(4)+" | color "+m+" | dashed "+g+" | type "+f+" | radius "+p+" | opacity "+u;s.setLogCmd(b,!0),i.analysisCls.addLine(c.x,c.y,c.z,h.x,h.y,h.z,m,g,f,p,u),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"applycartoonshape","click",(function(t){let i=e.icn3d;t.preventDefault(),i.bCartoonshape=!1;let n=$("#"+e.pre+"cartoonshape").val(),l=i.definedSetsCls.getAtomsFromNameArray(n),r=i.contactCls.getExtent(l),o=new THREE.Vector3(r[2][0],r[2][1],r[2][2]),a=$("#"+e.pre+"cartoonshape_shape").val(),d=$("#"+e.pre+"cartoonshape_radius").val(),c=$("#"+e.pre+"cartoonshape_customcolor").val(),h=$("#"+e.pre+"cartoonshape_opacity").val();c="#"+c.replace(/\#/g,"");let p,m=e.parasCls.thr(c);"Sphere"==a?(i.sphereCls.createSphereBase(o,m,d,void 0,void 0,void 0,h),p="add sphere | x1 "+o.x.toPrecision(4)+" y1 "+o.y.toPrecision(4)+" z1 "+o.z.toPrecision(4)+" | color "+c+" | opacity "+h+" | radius "+d):(i.boxCls.createBox_base(o,d,m,void 0,void 0,void 0,h),p="add cube | x1 "+o.x.toPrecision(4)+" y1 "+o.y.toPrecision(4)+" z1 "+o.z.toPrecision(4)+" | color "+c+" | opacity "+h+" | radius "+d),s.setLogCmd(p,!0),i.shapeCmdHash[p]=1,i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"clearlinebtwsets","click",(function(t){let i=e.icn3d;t.preventDefault(),i.lines.cylinder=[],s.setLogCmd("clear line between sets",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"clearcartoonshape","click",(function(t){let i=e.icn3d;t.preventDefault(),i.shapeCmdHash={},s.setLogCmd("clear shape",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"apply_thickness_3dprint","click",(function(t){e.icn3d,t.preventDefault(),e.htmlCls.setHtmlCls.setLineThickness("3dprint")})),e.myEventCls.onIds("#"+e.pre+"apply_thickness_style","click",(function(t){e.icn3d,t.preventDefault(),e.htmlCls.setHtmlCls.setLineThickness("style"),e.htmlCls.setMenuCls.setLogWindow(!0)})),e.myEventCls.onIds("#"+e.pre+"reset_thickness_3dprint","click",(function(t){e.icn3d,t.preventDefault(),e.htmlCls.setHtmlCls.setLineThickness("3dprint",!0)})),e.myEventCls.onIds("#"+e.pre+"reset_thickness_style","click",(function(t){e.icn3d,t.preventDefault(),e.htmlCls.setHtmlCls.setLineThickness("style",!0),e.htmlCls.setMenuCls.setLogWindow(!0)})),e.myEventCls.onIds("#"+e.pre+"reset","click",(function(t){let s=e.icn3d;s.selectionCls.resetAll(),s.bRender&&s.drawCls.draw()})),e.myEventCls.onIds(["#"+e.pre+"toggleHighlight","#"+e.pre+"toggleHighlight2"],"click",(function(t){let i=e.icn3d;t.stopImmediatePropagation(),i.hlUpdateCls.toggleHighlight(),s.setLogCmd("toggle highlight",!0)})),e.myEventCls.onIds("#"+e.pre+"seq_clearselection","click",(function(t){let i=e.icn3d;t.stopImmediatePropagation(),e.cfg.notebook||dialog.dialog("close"),i.hlUpdateCls.clearHighlight(),s.setLogCmd("clear selection",!0)})),e.myEventCls.onIds("#"+e.pre+"seq_clearselection2","click",(function(t){let i=e.icn3d;t.stopImmediatePropagation(),t.preventDefault(),i.hlUpdateCls.clearHighlight(),s.setLogCmd("clear selection",!0)})),e.myEventCls.onIds("#"+e.pre+"alignseq_clearselection","click",(function(t){let i=e.icn3d;t.stopImmediatePropagation(),i.hlUpdateCls.clearHighlight(),s.setLogCmd("clear selection",!0)})),e.myEventCls.onIds("#"+e.pre+"replay","click",(async function(t){let i=e.icn3d;t.stopImmediatePropagation(),i.CURRENTNUMBER++;let n=e.cfg.replay?i.STATENUMBER:i.STATENUMBER-1;if(i.CURRENTNUMBER==n)i.bReplay=0,$("#"+e.pre+"replay").hide();else if(i.commands.length>0&&i.commands[i.CURRENTNUMBER]){await i.loadScriptCls.execCommandsBase(i.CURRENTNUMBER,i.CURRENTNUMBER,i.STATENUMBER);let t=i.commands[i.CURRENTNUMBER].indexOf("|||"),n=-1!=t?i.commands[i.CURRENTNUMBER].substr(0,t):i.commands[i.CURRENTNUMBER],l=30,r=n.length>l?n.substr(0,l)+"...":n,o=i.applyCommandCls.getMenuFromCmd(r);$("#"+e.pre+"replay_cmd").html("Cmd: "+r),$("#"+e.pre+"replay_menu").html("Menu: "+o),s.setLogCmd(n,!0),i.drawCls.draw()}})),t.loadScriptCls.pressCommandtext(),e.myEventCls.onIds("#"+e.pre+"seq_saveselection","click",(function(t){let s=e.icn3d;t.stopImmediatePropagation(),e.cfg.notebook||dialog.dialog("close"),s.selectionCls.saveSelectionPrep();let i=$("#"+e.pre+"seq_command_name").val().replace(/\s+/g,"_");s.selectionCls.saveSelection(i,i)})),e.myEventCls.onIds("#"+e.pre+"seq_saveselection2","click",(function(t){let s=e.icn3d;t.stopImmediatePropagation(),s.selectionCls.saveSelectionPrep();let i=$("#"+e.pre+"seq_command_name2").val().replace(/\s+/g,"_");s.selectionCls.saveSelection(i,i)})),e.myEventCls.onIds("#"+e.pre+"mn2_saveresidue","click",(function(t){let i=e.icn3d;t.stopImmediatePropagation(),e.cfg.notebook||dialog.dialog("close"),i.selectionCls.saveEachResiInSel(),s.setLogCmd("select each residue",!0)})),e.myEventCls.onIds("#"+e.pre+"alignseq_saveselection","click",(function(t){let s=e.icn3d;t.stopImmediatePropagation(),s.selectionCls.saveSelectionPrep();let i=$("#"+e.pre+"alignseq_command_name").val().replace(/\s+/g,"_");s.selectionCls.saveSelection(i,i)})),$(document).on("click","."+e.pre+"outputselection",(function(t){let i=e.icn3d;t.stopImmediatePropagation(),i.bSelectResidue=!1,i.bSelectAlignResidue=!1,s.setLogCmd("output selection",!0),i.threeDPrintCls.outputSelection()})),$(document).on("click",".icn3d-saveicon",(function(t){e.icn3d,t.stopImmediatePropagation();let i=$(this).attr("pid");s.saveHtml(i),s.setLogCmd("save html "+i,!0)})),$(document).on("click",".icn3d-hideicon",(function(t){let s=e.icn3d;t.stopImmediatePropagation();let i=$(this).attr("pid");if(!e.cfg.notebook)if(void 0===s.dialogHashHideDone&&(s.dialogHashHideDone={}),void 0===s.dialogHashPosToRight&&(s.dialogHashPosToRight={}),s.dialogHashHideDone.hasOwnProperty(i)){let e=s.dialogHashHideDone[i].width,t=s.dialogHashHideDone[i].height,n=s.dialogHashHideDone[i].position;$("#"+i).dialog("option","width",e),$("#"+i).dialog("option","height",t),$("#"+i).dialog("option","position",n),delete s.dialogHashHideDone[i]}else{s.dialogHashHideDone[i]={width:$("#"+i).dialog("option","width"),height:$("#"+i).dialog("option","height"),position:$("#"+i).dialog("option","position")};let e,t=160,n=80;$("#"+i).dialog("option","width",t),$("#"+i).dialog("option","height",n),s.dialogHashPosToRight.hasOwnProperty(i)?e=s.dialogHashPosToRight[i]:(e=Object.keys(s.dialogHashPosToRight).length*(t+10),s.dialogHashPosToRight[i]=e);let l={my:"right bottom",at:"right-"+e+" bottom+60",of:"#"+s.divid,collision:"none"};$("#"+i).dialog("option","position",l)}})),$(document).on("click","."+e.pre+"selres",(function(t){let i=e.icn3d;t.stopImmediatePropagation(),i.bSelOneRes=!1;let n=$("."+e.pre+"seloneres");for(let e=0,t=n.length;e0&&(r+=" or "),r+=i.selectionCls.selectOneResid(t)}i.hlUpdateCls.updateHlAll(),s.setLogCmd(r,!0)})),$(document).on("click","."+e.pre+"seloneres",(function(t){let s=e.icn3d;t.stopImmediatePropagation(),s.bSelOneRes||(s.hAtoms={},s.selectedResidues={},s.bSelOneRes=!0);let i=$(this).attr("resid"),n=$(this).attr("id");$("#"+n).length&&$("#"+n)[0].checked?s.selectionCls.selectOneResid(i):$("#"+n).length&&!$("#"+n)[0].checked&&s.selectionCls.selectOneResid(i,!0),s.hlUpdateCls.updateHlAll()})),$(document).on("click","."+e.pre+"selset",(async function(t){let i=e.icn3d;t.stopImmediatePropagation(),i.bSelOneRes=!1;let n=$("."+e.pre+"seloneres");for(let e=0,t=n.length;e0))return{sequencesHtml:a,maxSeqCnt:d};c[s]=1}let h,p=void 0===t||t;p&&(o.hAtoms={});let m,u,g=0,f=0;for(let t=0,l=e.length;t0?m:l,p&&(o.hAtoms=r.hashUtilsCls.unionHash(o.hAtoms,o.alnChains[l]));let b=[],C="",y=void 0!==o.alnChainsSeq[l]?o.alnChainsSeq[l].length:0;y>d&&(d=y);let v,_,w=u.indexOf("_"),S=u.substr(0,w),A=u.substr(w+1);for(let e=0,t=y;e=0;--e)if("-"!=o.alnChainsSeq[l][e].resn){_=o.alnChainsSeq[l][e].resi;break}C+=""+v+"",h=!(void 0===e||!c.hasOwnProperty(u));for(let e=0,t=y;e"}""!==a?-1!=o.alnChainsSeq[l][e].resi?C+=""+o.alnChainsSeq[l][e].resn+"":C+=""+o.alnChainsSeq[l][e].resn+"":C+=""+o.alnChainsSeq[l][e].resn+""}C+=""+_+"";let x=e.length,k=void 0!==o.alnChainsAnno[l]?o.alnChainsAnno[l].length:0;for(let t=0,s=k;t";for(let e=0,i=o.alnChainsAnno[l][t].length;e ':' ';else if("E"==i)if(void 0!==o.alnChainsSeq[s][e]){let i=s+"_"+o.alnChainsSeq[s][e].resi;if(o.residues.hasOwnProperty(i)){o.firstAtomObjCls.getFirstCalphaAtomObj(o.residues[i]).ssend?b[t]+=' ':b[t]+=' '}else b[t]+=' '}else b[t]+=' ';else b[t]+="c"==i?' ':"o"==i?' ':"";else b[t]+=""+i+""}b[t]+=""}let O=l,R=void 0!==o.pdbid_chain2title?o.pdbid_chain2title[u]:"";for(let e=k-1;e>=0;--e){let t=o.alnChainsAnTtl[l][e][0];"SS"==t&&(t=""),a+="
    "+t+"
    "+b[e]+"
    "}a+=''+C+"
    ",g>0&&(f+=y),++g}return{sequencesHtml:a,maxSeqCnt:d}}}class u{constructor(e){this.icn3dui=e}getLink(e,t,s,i){let n=this.icn3dui;return n.icn3d,n.htmlCls.allMenus[e]=t,i&&(n.htmlCls.allMenusSel[e]=i),s&&(n.htmlCls.simpleMenus[e]=1),"
  • "+t+"
  • "}getMenuText(e,t,s,i,n){let l=this.icn3dui;l.icn3d,l.htmlCls.allMenus[e]=t,n&&(l.htmlCls.allMenusSel[e]=n),i&&(l.htmlCls.simpleMenus[e]=1);let r="icn3d-menupd"==s?" style='padding-left:1.5em!important;'":"";return"
  • "+t+""}getMenuUrl(e,t,s,i,n){let l=this.icn3dui;return l.icn3d,l.htmlCls.allMenus[e]=s,n&&(l.htmlCls.allMenusSel[e]=n),i&&(l.htmlCls.simpleMenus[e]=1),"
  • "+s+"
  • "}getMenuSep(){return this.icn3dui.icn3d,"
  • -
  • "}getLinkWrapper(e,t,s,i,n,l){let r=this.icn3dui;r.icn3d,r.htmlCls.allMenus[e]=t,n&&(r.htmlCls.allMenusSel[e]=n),i&&(r.htmlCls.simpleMenus[e]=1);let o=l?' style="display:none"':"";return"
  • "+t+"
  • "}getLinkWrapper2(e,t,s,i,n){let l=this.icn3dui;return l.icn3d,l.htmlCls.allMenus[e]=t,n&&(l.htmlCls.allMenusSel[e]=n),i&&(l.htmlCls.simpleMenus[e]=1),"
  • "+t+""}getRadio(e,t,s,i,n,l){let r=this.icn3dui;r.icn3d,r.htmlCls.allMenus[t]=s,l&&(r.htmlCls.allMenusSel[t]=l),n&&(r.htmlCls.simpleMenus[t]=1);let o=i?" checked":"";return"
  • "}getRadioColor(e,t,s,i,n,l,r){let o=this.icn3dui;o.icn3d,o.htmlCls.allMenus[t]=s,r&&(o.htmlCls.allMenusSel[t]=r),l&&(o.htmlCls.simpleMenus[t]=1);let a=n?" checked":"";return"
  • "}setAdvanced(e){let t=this.icn3dui;t.icn3d;let s=void 0===e?"":e,i=t.cfg.notebook?"icn3d-hidden":"",n=t.htmlCls.divStr+"dl_advanced"+s+"' class='"+i+"'>";return n+="",n+="",n+="
    ",n+="",n+="",n+="",n+="
    Select:"+t.htmlCls.inputTextStr+"id='"+t.pre+"command"+s+"' placeholder='$[structures].[chains]:[residues]@[atoms]' size='60'>
    Name:"+t.htmlCls.inputTextStr+"id='"+t.pre+"command_name"+s+"' placeholder='my_selection' size='60'>
    "+t.htmlCls.space3+t.htmlCls.buttonStr+"command_apply"+s+"'>Save Selection to Defined Sets
    ",n+='Specification Tips:

    ',n+=t.htmlCls.divStr+"specguide"+s+"' style='display:none; width:500px' class='icn3d-box'>",n+='Specification: In the selection "$1HHO,4N7N.A,B,C:5-10,LV,3AlaVal,chemicals@CA,C,C*":',n+='
    • "$1HHO,4N7N" uses "$" to indicate structure selection.
      ',n+='
    • ".A,B,C" uses "." to indicate chain selection.
      ',n+='
    • ":5-10,LV,3LeuVal,chemicals" uses the colon ":" to indicate residue selection. Residue selection could be residue number(5-10), one-letter IUPAC residue name abbreviations(LV), three-letter residue names(AlaVal, "3" indicates each residue name has three letters), or predefined names: "proteins", "nucleotides", "chemicals", "ions", and "water". IUPAC abbreviations can be written either as a contiguous string(e.g., ":LV"), in order to find all instances of that sequence in the structure, or they can be separated by commas(e.g., ":L,V") to select all residues of a given type in the structure(in the latter case, select all Leucine and Valine in the structure).
      ',n+='
    • "@CA,C,C*" uses "@" to indicate atom name selection. "C*" selects any atom names starting with "C".
      ',n+='
    • Partial definition is allowed, e.g., ":1-10" selects all residue IDs 1-10 in all chains.
      ',n+='
    • Different selections can be unioned(with "or", default), intersected(with "and"), or negated(with "not"). For example, ":1-10 or :K" selects all residues 1-10 and all Lys residues. ":1-10 and :K" selects all Lys residues in the range of residue number 1-10. ":1-10 or not :K" selects all residues 1-10, which are not Lys residues.
      ',n+='
    • The wild card character "X" or "x" can be used to represent any character.',n+="
    ",n+="Set Operation:",n+='
    • Users can select multiple sets in the menu "Select > Defined Sets".
      ',n+='
    • Different sets can be unioned(with "or", default), intersected(with "and"), or negated(with "not"). For example, if the "Defined Sets" menu has four sets ":1-10", ":11-20", ":5-15", and ":7-8", the command "saved atoms :1-10 or :11-20 and :5-15 not :7-8" unions all residues 1-10 and 11-20 to get the residues 1-20, then intersects with the residues 5-15 to get the residues 5-15, then exclude the residues 7-8 to get the final residues 5-6 and 9-15.
    ',n+="Full commands in url or command window:",n+="
    • Select without saving the set: select $1HHO,4N7N.A,B,C:5-10,LV,chemicals@CA,C,C*
      ",n+="
    • Select and save: select $1HHO,4N7N.A,B,C:5-10,LV,chemicals@CA,C,C* | name my_name
    ",n+="",n+="
    ",n+="",n}getOptionHtml(e,t){let s=this.icn3dui;s.icn3d;let i="";for(let n=0,l=e.length;n"+l+"":s.htmlCls.optionStr+"'"+l+"'>"+l+""}return i}setColorHints(){let e=this.icn3dui;e.icn3d;let t="";return t+=e.htmlCls.divNowrapStr+'Green: H-Bonds; ',t+='Cyan: Salt Bridge/Ionic; ',t+='Grey: contacts',t+=e.htmlCls.divNowrapStr+'Magenta: Halogen Bonds; ',t+='Red: π-Cation; ',t+='Blue: π-Stacking',t}setThicknessHtml(e){let t=this.icn3dui,s=t.icn3d,i="",n="3dprint"==e?"1":"0.1",l="3dprint"==e?"1.2":"0.3",r="3dprint"==e?"0.8":"0.4",o="3dprint"==e?"0.8":"0.4",a="3dprint"==e?"1":"0.4",d="3dprint"==e?"0.6":"0.3",c="3dprint"==e?"1":"0.2",h="3dprint"==e?"2":"1.3",p="3dprint"==e?"1.4":"0.8",m=40,u=.8,g=.4,f=.2,b=0,C=1,y=0;if("style"==e){if(""!=this.getCookie("shininess")&&(m=parseFloat(this.getCookie("shininess"))),""!=this.getCookie("light1")&&(u=parseFloat(this.getCookie("light1")),g=parseFloat(this.getCookie("light2")),f=parseFloat(this.getCookie("light3"))),""!=this.getCookie("lineRadius")){n=parseFloat(this.getCookie("lineRadius")),l=parseFloat(this.getCookie("coilWidth")),r=parseFloat(this.getCookie("cylinderRadius"));let e=this.getCookie("crosslinkRadius");o=isNaN(e)?s.crosslinkRadius:parseFloat(e),a=parseFloat(this.getCookie("traceRadius")),d=parseFloat(this.getCookie("dotSphereScale")),c=parseFloat(this.getCookie("ribbonthickness")),h=parseFloat(this.getCookie("helixSheetWidth")),p=parseFloat(this.getCookie("nucleicAcidWidth"))}""!=this.getCookie("glycan")&&(b=parseFloat(this.getCookie("glycan"))),""!=this.getCookie("membrane")&&(C=parseFloat(this.getCookie("membrane"))),""!=this.getCookie("cmdwindow")&&(y=parseFloat(this.getCookie("cmdwindow"))),i+="Note: The following parameters will be saved in cache. You just need to set them once.

    ",i+="1. Shininess: "+t.htmlCls.inputTextStr+"id='"+t.pre+"shininess' value='"+m+"' size=4>"+t.htmlCls.space3+"(for the shininess of the 3D objects, default 40)

    ",i+="2. Three directional lights:
    ",i+="Key Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light1' value='"+u+"' size=4>"+t.htmlCls.space3+"(for the light strength of the key light, default 0.8)
    ",i+="Fill Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light2' value='"+g+"' size=4>"+t.htmlCls.space3+"(for the light strength of the fill light, default 0.4)
    ",i+="Back Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light3' value='"+f+"' size=4>"+t.htmlCls.space3+"(for the light strength of the back light, default 0.2)

    ",i+="3. Thickness:
    "}return i+="Line Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"linerad_"+e+"' value='"+n+"' size=4>"+t.htmlCls.space3+"(for stabilizers, hydrogen bonds, distance lines, default 0.1)
    ",i+="Coil Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"coilrad_"+e+"' value='"+l+"' size=4>"+t.htmlCls.space3+"(for coils, default 0.3)
    ",i+="Stick Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"stickrad_"+e+"' value='"+r+"' size=4>"+t.htmlCls.space3+"(for sticks, default 0.4)
    ",i+="Cross-Linkage Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"crosslinkrad_"+e+"' value='"+o+"' size=4>"+t.htmlCls.space3+"(for cross-linkages, default 0.4)
    ",i+="Trace Radius: "+t.htmlCls.inputTextStr+"id='"+t.pre+"tracerad_"+e+"' value='"+a+"' size=4>"+t.htmlCls.space3+"(for C alpha trace, O3' trace, default 0.4)
    ",i+="Ribbon Thickness: "+t.htmlCls.inputTextStr+"id='"+t.pre+"ribbonthick_"+e+"' value='"+c+"' size=4>"+t.htmlCls.space3+"(for helix and sheet ribbons, nucleotide ribbons, default 0.2)
    ",i+="Protein Ribbon Width: "+t.htmlCls.inputTextStr+"id='"+t.pre+"prtribbonwidth_"+e+"' value='"+h+"' size=4>"+t.htmlCls.space3+"(for helix and sheet ribbons, default 1.3)
    ",i+="Nucleotide Ribbon Width: "+t.htmlCls.inputTextStr+"id='"+t.pre+"nucleotideribbonwidth_"+e+"' value='"+p+"' size=4>"+t.htmlCls.space3+"(for nucleotide ribbons, default 0.8)
    ",i+="Ball Scale: "+t.htmlCls.inputTextStr+"id='"+t.pre+"ballscale_"+e+"' value='"+d+"' size=4>"+t.htmlCls.space3+"(for styles 'Ball and Stick' and 'Dot', default 0.3)
    ","style"==e&&(i+="
    4. Show Glycan Cartoon: "+t.htmlCls.inputTextStr+"id='"+t.pre+"glycan' value='"+b+"' size=4>"+t.htmlCls.space3+"(0: hide, 1: show, default 0)
    ",i+="
    5. Show Membrane: "+t.htmlCls.inputTextStr+"id='"+t.pre+"membrane' value='"+C+"' size=4>"+t.htmlCls.space3+"(0: hide, 1: show, default 1)
    ",i+="
    6. Enlarge Command Window: "+t.htmlCls.inputTextStr+"id='"+t.pre+"cmdwindow' value='"+y+"' size=4>"+t.htmlCls.space3+"(0: Regular, 1: Large, default 0)

    "),i+=t.htmlCls.spanNowrapStr+""+t.htmlCls.buttonStr+"apply_thickness_"+e+"'>Apply   ",i+=t.htmlCls.spanNowrapStr+""+t.htmlCls.buttonStr+"reset_thickness_"+e+"'>Reset",i}getCookie(e){let t=e+"=",s=decodeURIComponent(document.cookie).split(";");for(let e=0;e":(n+='
    ',n+="
    Selection: Name: "+s.htmlCls.inputTextStr+"id='"+s.pre+"seq_command_name"+e+"' value='seq_"+l+"' size='5'> "+s.htmlCls.space2+"

    ",n+=s.htmlCls.divStr+"seqguide"+e+"' style='display:none; white-space:normal;' class='icn3d-box'>"),n+=this.getSelectionHints();return n+="Residue labeling: standard residue with coordinates: UPPER case letter; nonstandard residue with coordinates: the first UPPER case letter plus a period except that water residue uses the letter 'O'; residue missing coordinates: lower case letter."+(s.utilsCls.isMac()&&!s.utilsCls.isMobile()?"

    Turn on scroll bar: System preferences -> General -> show scroll bars -> check Always":"")+"
    ",n}setAlignSequenceGuide(e,t){let s=this.icn3dui,i=s.icn3d,n="";let l=i&&i.defNames2Atoms?Object.keys(i.defNames2Atoms).length:1;n+='
    ',n+="
    Selection: Name: "+s.htmlCls.inputTextStr+"id='"+s.pre+"alignseq_command_name' value='alseq_"+l+"' size='10'> "+s.htmlCls.space2+"

    ",n+=s.htmlCls.divStr+"alignseqguide' style='display:none; white-space:normal;' class='icn3d-box'>",n+=this.getSelectionHints();return n+="Residue labeling: aligned residue with coordinates: UPPER case letter; non-aligned residue with coordinates: lower case letter which can be highlighted; residue missing coordinates: lower case letter which can NOT be highlighted."+(s.utilsCls.isMac()&&!s.utilsCls.isMobile()?"

    Turn on scroll bar: System preferences -> General -> show scroll bars -> check Always":"")+"
    ",n}getSelectionHints(){let e=this.icn3dui;e.icn3d;let t="";if(e.utilsCls.isMobile())t+='Select Aligned Sequences: touch to select, touch again to deselect, multiple selection is allowed without Ctrl key, click "Save Selection" to save the current selection.
    ';else{t+='Select on 1D sequences: drag to select, drag again to deselect, multiple selection is allowed without Ctrl key, click "Save Selection" to save the current selection.

    ',t+="Select on 2D interaction diagram: click on the nodes or lines. The nodes are chains and can be united with the Ctrl key. The lines are interactions and can NOT be united. Each click on the lines selects half of the lines, i.e., select the interacting residues in one of the two chains.

    ",t+="Select on 3D structures: "+(e.utilsCls.isMobile()?"use finger to pick":'hold "Alt" and use mouse to pick')+', click the second time to deselect, hold "Ctrl" to union selection, hold "Shift" to select a range, press the up/down arrow to switch among atom/residue/strand/chain/structure, click "Save Selection" to save the current selection.

    ',t+='Save the current selection(either on 3D structure, 2D interactions, or 1D sequence): open the menu "Select -> Save Selection", specify the name and description for the selection, and click "Save".

    '}return t}addGsizeSalt(e){let t=this.icn3dui;t.icn3d;let s="";s+="Grid Size: ",s+="Salt Concentration: M
    ",s}getFootHtml(e,t){let s=this.icn3dui;s.icn3d;let i="
    ";return"delphi"==e?s.cfg.cid?i+="Note: Partial charges(MMFF94) are from PubChem Compound SDF files.

    ":(i+="Note: Only the selected residues are used for DelPhi potential calculation by solving linear Poisson-Boltzmann equation.",i+='

    ',i+=s.htmlCls.divStr+t+"' style='display:none;'>",i+="
    The hydrogens and partial charges of proteins and nucleotides are added using DelPhiPKa with the Amber charge and size files. The hydrogens of ligands are added using Open Babel. The partial charges of ligands are calculated using Antechamber with the Gasteiger charge method. All partial charges are calculated at pH 7.

    ",i+='Lipids are treated as ligands. Please use "HETATM" instead of "ATOM " for each lipid atom in your PDB file. Each phosphate in lipids is assigned with a charge of -1. You can download PQR and modify it, or prepare your PQR file using other tools. Then load the PQR file at the menu "Analysis > Load PQR/Potential".

    ',i+="
    "):(i+="Note: Always load a PDB file before loading a PQR or DelPhi potential file.",i+='

    ',i+=s.htmlCls.divStr+t+"' style='display:none;'>",i+='The PDB file can be loaded in the URL with "pdbid=" or at "File > Open File". The PQR file can be prepared at the menu "Analysis > Download PQR" with your modification or using other tools. The DelPhi potential file can be calculated at DelPhi Web Server and be exported as a Cube file. ',"url"==e&&(i+="The PQR or potential file can be accessed in a URL if it is located in the same host as iCn3D."),i+="

    ",i+=""),i+="",i}getPotentialHtml(e,t){let s=this.icn3dui;s.icn3d;let i,n,l,r,o,a="";r="Equipotential Map",o="Surface with Potential","delphi"==e?n="delphi":"local"==e?(i="pqr",n="phi",l="cube"):"url"==e&&(i="pqrurl",n="phiurl",l="cubeurl"),a+=s.htmlCls.divStr+"dl_"+n+"' class='"+t+"'>",a+=s.htmlCls.setDialogCls.addNotebookTitle("dl_"+n,"DelPhi Potential"),a+=s.htmlCls.divStr+"dl_"+n+"_tabs' style='border:0px;'>",a+="",a+=s.htmlCls.divStr+n+"tab1'>","delphi"==e&&(a+=this.addGsizeSalt(n+"1")+"
    "),a+="Potential contour at: kT/e(25.6mV at 298K)

    ","delphi"==e?(a+=s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map",a+=s.htmlCls.buttonStr+n+"mapNo' style='margin-left:30px;'>Remove Map
    "):"local"==e?(a+=s.htmlCls.divStr+n+"tab1_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo'>Remove Map",a+=s.htmlCls.divStr+n+"tab1_"+i+"'>",a+=this.addGsizeSalt(i)+"
    ",a+="PQR File: "+s.htmlCls.inputFileStr+"id='"+s.pre+i+"file'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+n+"'>",a+="Phi File: "+s.htmlCls.inputFileStr+"id='"+s.pre+n+"file'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+l+"'>",a+="Cube File: "+s.htmlCls.inputFileStr+"id='"+s.pre+l+"file'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=""):"url"==e&&(a+=s.htmlCls.divStr+n+"tab1_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo'>Remove Map",a+=s.htmlCls.divStr+n+"tab1_"+i+"2'>",a+=this.addGsizeSalt(i)+"
    ",a+="PQR URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+i+"file'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+n+"2'>",a+="Phi URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+n+"file'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+l+"2'>",a+="Cube URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+l+"file'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=""),a+="
    "+this.getFootHtml(e,n+"tab1_foot"),a+="",a+=s.htmlCls.divStr+n+"tab2'>","delphi"==e&&(a+=this.addGsizeSalt(n+"2")+"
    "),a+="Surface with max potential at: kT/e(25.6mV at 298K)

    ",a+="Surface: ",a+="Opacity: ",a+="Wireframe:
    ",a+="
    ","delphi"==e?(a+=s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential",a+=s.htmlCls.buttonStr+n+"mapNo2' style='margin-left:30px;'>Remove Surface
    "):"local"==e?(a+=s.htmlCls.divStr+n+"tab2_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo2'>Remove Surface",a+=s.htmlCls.divStr+n+"tab2_"+i+"'>",a+=this.addGsizeSalt(i+"2")+"
    ",a+="PQR File: "+s.htmlCls.inputFileStr+"id='"+s.pre+i+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+n+"'>",a+="Phi File: "+s.htmlCls.inputFileStr+"id='"+s.pre+n+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+l+"'>",a+="Cube File: "+s.htmlCls.inputFileStr+"id='"+s.pre+l+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=""):"url"==e&&(a+=s.htmlCls.divStr+n+"tab2_tabs' style='border:0px;'>",a+="",d=""+s.htmlCls.buttonStr+n+"mapNo2'>Remove Surface",a+=s.htmlCls.divStr+n+"tab2_"+i+"2'>",a+=this.addGsizeSalt(i+"2")+"
    ",a+="PQR URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+i+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+i+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+n+"2'>",a+="Phi URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+n+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+l+"2'>",a+="Cube URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+l+"file2'>

    "+s.htmlCls.buttonStr+"reload_"+l+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=""),a+="
    "+this.getFootHtml(e,n+"tab2_foot"),a+="",a+="",a+="",a}async exportPqr(e){let t=this.icn3dui,s=t.icn3d,i={},n={},l=t.hashUtilsCls.intHash(s.dAtoms,s.hAtoms);for(let e in l)s.atoms[e],s.ions.hasOwnProperty(e)?i[e]=1:n[e]=1;let r=e?"pdb":"pqr";if(t.cfg.cid){let l="",o=!e;l+=s.saveFileCls.getAtomPDB(n,o)+s.saveFileCls.getAtomPDB(i,o);let a=Object.keys(t.utilsCls.getHlStructures()).join(",");s.saveFileCls.saveFile(a+"_icn3d."+r,"text",[l])}else{if(t.utilsCls.isCalphaPhosOnly(t.hashUtilsCls.hash2Atoms(n,s.atoms)))return void alert("The potential will not be shown because the side chains are missing in the structure...");let l="",o=!0;l+=s.saveFileCls.getAtomPDB(n,void 0,void 0,void 0,void 0,void 0,o),l+=s.saveFileCls.getAtomPDB(i,!0,void 0,!0);let a=t.htmlCls.baseUrl+"delphi/delphi.cgi",d={pdb2pqr:l,pdbid:t.cfg.cid?t.cfg.cid:Object.keys(s.structures).toString()},c=await t.getAjaxPostPromise(a,d,!0,void 0,void 0,!0,"text");if(e){let e=c.split("\n"),s="";for(let i=0,n=e.length;i Save File > iCn3D PNG Image"...');else if(-1!=l){let t=e.substr(l+n.length);s.htmlCls.clickMenuCls.setLogCmd("load iCn3D PNG image "+$("#"+s.pre+"pngimage").val(),!1),window.open(t,"_self")}else if(-1!=o){let n="Start of data file======\n",l=e.indexOf(n);i.bInputfile=-1!=l,i.bInputPNGWithData=i.bInputfile;let a,d=t?t.replace(/;/g,"\n"):"";if(i.bInputfile){let t=e.indexOf("End of data file======\n"),s=e.substr(l+n.length,t-l-n.length);i.InputfileData=i.InputfileData?i.InputfileData+"\nENDMDL\n"+s:s;let c="Start of type file======\n",h=e.indexOf(c),p=e.indexOf("End of type file======\n"),m=e.substr(h+c.length,p-h-c.length-1);i.InputfileType=m;let u=e.indexOf("End of state file======\n");a=e.substr(o+r.length,u-o-r.length),a=decodeURIComponent(a+"\n"+d),"pdb"===m?(await i.pdbParserCls.loadPdbData(s),i.commands=[],i.optsHistory=[]):("mol2"===m?await i.mol2ParserCls.loadMol2Data(s):"sdf"===m?await i.sdfParserCls.loadSdfData(s):"xyz"===m?await i.xyzParserCls.loadXyzData(s):"mmcif"===m&&await i.mmcifParserCls.loadMmcifData(s),i.commands=[],i.optsHistory=[])}else{let t=e.indexOf("End of state file======\n");a=e.substr(o+r.length,t-o-r.length),a=decodeURIComponent(a+"\n"+d),i.commands=[],i.optsHistory=[]}await i.loadScriptCls.loadScript(a,!0),s.htmlCls.clickMenuCls.setLogCmd("load iCn3D PNG image "+$("#"+s.pre+"pngimage").val(),!1)}}fileSupport(){window.File&&window.FileReader&&window.FileList&&window.Blob||alert("The File APIs are not fully supported in this browser.")}getLinkColor(){let e="";return e+=", linkmap: {\n",e+='3: {"type": "peptidebond", "c":""},\n',e+='4: {"type": "ssbond", "c":"FFA500"},\n',e+='5: {"type": "ionic", "c":"0FF"},\n',e+='6: {"type": "ionicInside", "c":"FFF"},\n',e+='11: {"type": "contact", "c":"888"},\n',e+='12: {"type": "contactInside", "c":"FFF"},\n',e+='13: {"type": "hbond", "c":"0F0"},\n',e+='14: {"type": "hbondInside", "c":"FFF"},\n',e+='15: {"type": "clbond", "c":"006400"},\n',e+='17: {"type": "halogen", "c":"F0F"},\n',e+='18: {"type": "halogenInside", "c":"FFF"},\n',e+='19: {"type": "pication", "c":"F00"},\n',e+='20: {"type": "picationInside", "c":"FFF"},\n',e+='21: {"type": "pistacking", "c":"00F"},\n',e+='22: {"type": "pistackingInside", "c":"FFF"}\n',e+="}}\n",', linkmap: {\n3: {"type": "peptidebond", "c":""},\n4: {"type": "ssbond", "c":"FFA500"},\n5: {"type": "ionic", "c":"0FF"},\n6: {"type": "ionicInside", "c":"FFF"},\n11: {"type": "contact", "c":"888"},\n12: {"type": "contactInside", "c":"FFF"},\n13: {"type": "hbond", "c":"0F0"},\n14: {"type": "hbondInside", "c":"FFF"},\n15: {"type": "clbond", "c":"006400"},\n17: {"type": "halogen", "c":"F0F"},\n18: {"type": "halogenInside", "c":"FFF"},\n19: {"type": "pication", "c":"F00"},\n20: {"type": "picationInside", "c":"FFF"},\n21: {"type": "pistacking", "c":"00F"},\n22: {"type": "pistackingInside", "c":"FFF"}\n}}\n'}setCookieForThickness(){let e=this.icn3dui,t=e.icn3d;if(!e.bNode){let e=3650;this.setCookie("lineRadius",t.lineRadius,e),this.setCookie("coilWidth",t.coilWidth,e),this.setCookie("cylinderRadius",t.cylinderRadius,e),this.setCookie("crosslinkRadius",t.crosslinkRadius,e),this.setCookie("traceRadius",t.traceRadius,e),this.setCookie("dotSphereScale",t.dotSphereScale,e),this.setCookie("ribbonthickness",t.ribbonthickness,e),this.setCookie("helixSheetWidth",t.helixSheetWidth,e),this.setCookie("nucleicAcidWidth",t.nucleicAcidWidth,e)}}setLineThickness(e,t){let s=this.icn3dui,i=s.icn3d;if(i.bSetThickness=!0,"style"==e&&(t&&($("#"+s.pre+"shininess").val("40"),$("#"+s.pre+"light1").val("0.8"),$("#"+s.pre+"light2").val("0.4"),$("#"+s.pre+"light3").val("0.2"),$("#"+s.pre+"glycan").val("0"),$("#"+s.pre+"membrane").val("1"),$("#"+s.pre+"cmdwindow").val("0")),i.shininess=parseFloat($("#"+s.pre+"shininess").val()),i.light1=parseFloat($("#"+s.pre+"light1").val()),i.light2=parseFloat($("#"+s.pre+"light2").val()),i.light3=parseFloat($("#"+s.pre+"light3").val()),i.bGlycansCartoon=parseInt($("#"+s.pre+"glycan").val()),i.bMembrane=parseInt($("#"+s.pre+"membrane").val()),i.bCmdWindow=parseInt($("#"+s.pre+"cmdwindow").val())),t&&($("#"+s.pre+"linerad_"+e).val(.1),$("#"+s.pre+"coilrad_"+e).val(.3),$("#"+s.pre+"stickrad_"+e).val(.4),$("#"+s.pre+"crosslinkrad_"+e).val(.4),$("#"+s.pre+"tracerad_"+e).val(.4),$("#"+s.pre+"ballscale_"+e).val(.3),$("#"+s.pre+"ribbonthick_"+e).val(.2),$("#"+s.pre+"prtribbonwidth_"+e).val(1.3),$("#"+s.pre+"nucleotideribbonwidth_"+e).val(.8)),i.lineRadius=parseFloat($("#"+s.pre+"linerad_"+e).val()),i.coilWidth=parseFloat($("#"+s.pre+"coilrad_"+e).val()),i.cylinderRadius=parseFloat($("#"+s.pre+"stickrad_"+e).val()),i.crosslinkRadius=parseFloat($("#"+s.pre+"crosslinkrad_"+e).val()),i.traceRadius=parseFloat($("#"+s.pre+"tracerad_"+e).val()),i.dotSphereScale=parseFloat($("#"+s.pre+"ballscale_"+e).val()),i.ribbonthickness=parseFloat($("#"+s.pre+"ribbonthick_"+e).val()),i.helixSheetWidth=parseFloat($("#"+s.pre+"prtribbonwidth_"+e).val()),i.nucleicAcidWidth=parseFloat($("#"+s.pre+"nucleotideribbonwidth_"+e).val()),!s.bNode){let e=3650;this.setCookie("shininess",i.shininess,e),this.setCookie("light1",i.light1,e),this.setCookie("light2",i.light2,e),this.setCookie("light3",i.light3,e),this.setCookie("glycan",i.bGlycansCartoon,e),this.setCookie("membrane",i.bMembrane,e),this.setCookie("cmdwindow",i.bCmdWindow,e)}if(this.setCookieForThickness(),e=t){let e="reset thickness";s.htmlCls.clickMenuCls.setLogCmd(e,!0),i.bSetThickness=!1,i.threeDPrintCls.resetAfter3Dprint()}else s.htmlCls.clickMenuCls.setLogCmd("set thickness | linerad "+i.lineRadius+" | coilrad "+i.coilWidth+" | stickrad "+i.cylinderRadius+" | crosslinkrad "+i.crosslinkRadius+" | tracerad "+i.traceRadius+" | ribbonthick "+i.ribbonthickness+" | proteinwidth "+i.helixSheetWidth+" | nucleotidewidth "+i.nucleicAcidWidth+" | ballscale "+i.dotSphereScale,!0),s.htmlCls.clickMenuCls.setLogCmd("set glycan "+i.bGlycansCartoon,!0),s.htmlCls.clickMenuCls.setLogCmd("set membrane "+i.bMembrane,!0),s.htmlCls.clickMenuCls.setLogCmd("set cmdwindow "+i.bCmdWindow,!0);i.drawCls.draw()}setCookie(e,t,s){let i=new Date;i.setTime(i.getTime()+24*s*60*60*1e3);let n="expires="+i.toUTCString();document.cookie=e+"="+t+";"+n+";path=/"}updateSurfPara(e){let t=this.icn3dui,s=t.icn3d;s.phisurftype=$("#"+t.pre+e+"surftype").val(),s.phisurfop=$("#"+t.pre+e+"surfop").val(),s.phisurfwf=$("#"+t.pre+e+"surfwf").val()}exportPdb(){let e=this.icn3dui,t=e.icn3d,s="",i=e.hashUtilsCls.intHash(t.dAtoms,t.hAtoms);if(s+=t.saveFileCls.getAtomPDB(i),!e.bNode){let i=Object.keys(e.utilsCls.getHlStructures()).join(",");t.saveFileCls.saveFile(i+"_icn3d.pdb","text",[s])}return s}exportSecondary(){let e=this.icn3dui,t=e.icn3d,s="",i=e.hashUtilsCls.intHash(t.dAtoms,t.hAtoms);if(s+=t.saveFileCls.getSecondary(i),!e.bNode){let i=Object.keys(e.utilsCls.getHlStructures()).join(",");t.saveFileCls.saveFile(i+"_icn3d_ss.txt","text",[s])}return s}}class g{constructor(e){let t=e;this.icn3dui=e,this.cfg=this.icn3dui.cfg,this.opts={},this.opts.background="black",this.allMenus={},this.allMenusSel={},this.simpleMenus={},this.shownMenus={},this.WIDTH=400,this.HEIGHT=400,this.RESIDUE_WIDTH=10,t.utilsCls.isMobile()||this.cfg.mobilemenu?this.MENU_HEIGHT=0:this.MENU_HEIGHT=40,this.LOG_HEIGHT=65,this.MENU_WIDTH=750,this.LESSWIDTH=20,this.LESSWIDTH_RESIZE=20,this.LESSHEIGHT=20,this.width2d=200,this.CMD_HEIGHT=.8*this.LOG_HEIGHT,this.EXTRAHEIGHT=this.MENU_HEIGHT+this.CMD_HEIGHT,null!=this.cfg.showmenu&&0==this.cfg.showmenu&&(this.EXTRAHEIGHT-=this.MENU_HEIGHT),null!=this.cfg.showcommand&&0==this.cfg.showcommand&&(this.EXTRAHEIGHT-=this.CMD_HEIGHT),this.GREY8="#AAAAAA",this.GREYB="#CCCCCC",this.GREYC="#DDDDDD",this.GREYD="#EEEEEE",this.ORANGE="#FFA500",this.themecolor="blue",this.defaultValue=1,this.ssValue=3,this.coilValue=3,this.contactValue=11,this.contactInsideValue=12,this.hbondValue=13,this.hbondInsideValue=14,this.ssbondValue=4,this.ionicValue=5,this.ionicInsideValue=6,this.clbondValue=15,this.halogenValue=17,this.halogenInsideValue=18,this.picationValue=19,this.picationInsideValue=20,this.pistackingValue=21,this.pistackingInsideValue=22,this.contactColor="888",this.contactInsideColor="FFF",this.hbondColor="0F0",this.hbondInsideColor="FFF",this.ssbondColor="FFA500",this.ionicColor="0FF",this.ionicInsideColor="FFF",this.clbondColor="006400",this.halogenColor="F0F",this.halogenInsideColor="FFF",this.picationColor="F00",this.picationInsideColor="FFF",this.pistackingColor="00F",this.pistackingInsideColor="FFF",this.hideedges=1,this.force=4,this.simulation=void 0,this.baseUrl=window&&window.location&&"structure.ncbi.nlm.nih.gov"==window.location.hostname?"https://structure.ncbi.nlm.nih.gov/Structure/":"https://www.ncbi.nlm.nih.gov/Structure/",this.divStr="
    ",this.spanNowrapStr="",this.inputTextStr="=2.0 are supported.")));const a=new pe(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});a.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===r[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}a.setExtensions(l),a.setPlugins(r),a.parse(s,i)}parseAsync(e,t){const s=this;return new Promise((function(i,n){s.parse(e,t,i,n)}))}}function b(){let e={};return{get:function(t){return e[t]},add:function(t,s){e[t]=s},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const C={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class y{constructor(e){this.parser=e,this.name=C.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,i=t.length;s=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,n.source,l)}}class R{constructor(e){this.parser=e,this.name=C.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,i=s.json,n=i.textures[e];if(!n.extensions||!n.extensions[t])return null;const l=n.extensions[t],r=i.images[l.source];let o=s.textureLoader;if(r.uri){const e=s.options.manager.getHandler(r.uri);null!==e&&(o=e)}return this.detectSupport().then((function(n){if(n)return s.loadTextureImage(e,l.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class I{constructor(e){this.name=C.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const e=s.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),n=this.parser.options.meshoptDecoder;if(!n||!n.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([i,n.ready]).then((function(t){const s=e.byteOffset||0,i=e.byteLength||0,l=e.count,r=e.byteStride,o=new ArrayBuffer(l*r),a=new Uint8Array(t[0],s,i);return n.decodeGltfBuffer(new Uint8Array(o),l,r,a,e.mode,e.filter),o}))}return null}}const T="glTF",E=1313821514,P=5130562;class M{constructor(e){this.name=C.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:THREE.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==T)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-12,i=new DataView(e,12);let n=0;for(;n",t).replace("#include ",s).replace("#include ",i).replace("#include ",n).replace("#include ",l)},Object.defineProperties(this,{specular:{get:function(){return r.specular.value},set:function(e){r.specular.value=e}},specularMap:{get:function(){return r.specularMap.value},set:function(e){r.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return r.glossiness.value},set:function(e){r.glossiness.value=e}},glossinessMap:{get:function(){return r.glossinessMap.value},set:function(e){r.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class L{constructor(){this.name=C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity"]}getMaterialType(){return F}extendParams(e,t,s){const i=t.extensions[this.name];e.color=new Color(1,1,1),e.opacity=1;const n=[];if(Array.isArray(i.diffuseFactor)){const t=i.diffuseFactor;e.color.fromArray(t),e.opacity=t[3]}if(void 0!==i.diffuseTexture&&n.push(s.assignTexture(e,"map",i.diffuseTexture,sRGBEncoding)),e.emissive=new Color(0,0,0),e.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,e.specular=new Color(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){const t=i.specularGlossinessTexture;n.push(s.assignTexture(e,"glossinessMap",t)),n.push(s.assignTexture(e,"specularMap",t,sRGBEncoding))}return Promise.all(n)}createMaterial(e){const t=new F(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=TangentSpaceNormalMap,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t}}class N{constructor(){this.name=C.KHR_MESH_QUANTIZATION}}class q extends THREE.Interpolant{constructor(e,t,s,i){super(e,t,s,i)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,i=this.valueSize,n=e*i*3+i;for(let e=0;e!==i;e++)t[e]=s[n+e];return t}}q.prototype.beforeStart_=q.prototype.copySampleValue_,q.prototype.afterEnd_=q.prototype.copySampleValue_,q.prototype.interpolate_=function(e,t,s,i){const n=this.resultBuffer,l=this.sampleValues,r=this.valueSize,o=2*r,a=3*r,d=i-t,c=(s-t)/d,h=c*c,p=h*c,m=e*a,u=m-a,g=-2*p+3*h,f=p-h,b=1-g,C=f-h+c;for(let e=0;e!==r;e++){const t=l[u+e+r],s=l[u+e+o]*d,i=l[m+e+r],a=l[m+e]*d;n[e]=b*t+C*s+g*i+f*a}return n};const U=new THREE.Quaternion;class j extends q{interpolate_(e,t,s,i){const n=super.interpolate_(e,t,s,i);return U.fromArray(n).normalize().toArray(n),n}}const B=0,z=1,G=2,V=3,W=4,Y=5,X=6,K={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},J={9728:THREE.NearestFilter,9729:THREE.LinearFilter,9984:THREE.NearestMipmapNearestFilter,9985:THREE.LinearMipmapNearestFilter,9986:THREE.NearestMipmapLinearFilter,9987:THREE.LinearMipmapLinearFilter},Q={33071:THREE.ClampToEdgeWrapping,33648:THREE.MirroredRepeatWrapping,10497:THREE.RepeatWrapping},Z={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ee={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},te={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},se={CUBICSPLINE:void 0,LINEAR:THREE.InterpolateLinear,STEP:THREE.InterpolateDiscrete},ie="OPAQUE",ne="MASK",le="BLEND";function re(e,t,s){for(const i in s.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=s.extensions[i])}function oe(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function ae(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let s=0,i=t.weights.length;s{const s=this.associations.get(e);null!=s&&this.associations.set(t,s);for(const[s,i]of e.children.entries())n(i,t.children[s])};return n(s,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s=2&&m.setY(t,c[e*l+1]),l>=3&&m.setZ(t,c[e*l+2]),l>=4&&m.setW(t,c[e*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m}))}loadTexture(e){const t=this.json,s=this.options,i=t.textures[e].source,n=t.images[i];let l=this.textureLoader;if(n.uri){const e=s.manager.getHandler(n.uri);null!==e&&(l=e)}return this.loadTextureImage(e,i,l)}loadTextureImage(e,t,s){const i=this,n=this.json,l=n.textures[e],r=n.images[t],o=(r.uri||r.bufferView)+":"+l.sampler;if(this.textureCache[o])return this.textureCache[o];const a=this.loadImageSource(t,s).then((function(t){t.flipY=!1,l.name&&(t.name=l.name);const s=(n.samplers||{})[l.sampler]||{};return t.magFilter=J[s.magFilter]||LinearFilter,t.minFilter=J[s.minFilter]||LinearMipmapLinearFilter,t.wrapS=Q[s.wrapS]||RepeatWrapping,t.wrapT=Q[s.wrapT]||RepeatWrapping,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=a,a}loadImageSource(e,t){const s=this,i=this.json,n=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const l=i.images[e],r=self.URL||self.webkitURL;let o=l.uri||"",a=!1;if(void 0!==l.bufferView)o=s.getDependency("bufferView",l.bufferView).then((function(e){a=!0;const t=new Blob([e],{type:l.mimeType});return o=r.createObjectURL(t),o}));else if(void 0===l.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(o).then((function(e){return new Promise((function(s,i){let l=s;!0===t.isImageBitmapLoader&&(l=function(e){const t=new Texture(e);t.needsUpdate=!0,s(t)}),t.load(THREE.LoaderUtils.resolveURL(e,n.path),l,void 0,i)}))})).then((function(e){var t;return!0===a&&r.revokeObjectURL(o),e.userData.mimeType=l.mimeType||((t=l.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),e}));return this.sourceCache[e]=d,d}assignTexture(e,t,s,i){const n=this;return this.getDependency("texture",s.index).then((function(l){if(void 0===s.texCoord||0==s.texCoord||"aoMap"===t&&1==s.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+s.texCoord+" for texture "+t+" not yet supported."),n.extensions[C.KHR_TEXTURE_TRANSFORM]){const e=void 0!==s.extensions?s.extensions[C.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=n.associations.get(l);l=n.extensions[C.KHR_TEXTURE_TRANSFORM].extendTexture(l,e),n.associations.set(l,t)}}return void 0!==i&&(l.encoding=i),e[t]=l,l}))}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const i=void 0===t.attributes.tangent,n=void 0!==t.attributes.color,l=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new PointsMaterial,Material.prototype.copy.call(t,s),t.color.copy(s.color),t.map=s.map,t.sizeAttenuation=!1,this.cache.add(e,t)),s=t}else if(e.isLine){const e="LineBasicMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new LineBasicMaterial,Material.prototype.copy.call(t,s),t.color.copy(s.color),this.cache.add(e,t)),s=t}if(i||n||l){let e="ClonedMaterial:"+s.uuid+":";s.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),i&&(e+="derivative-tangents:"),n&&(e+="vertex-colors:"),l&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=s.clone(),n&&(t.vertexColors=!0),l&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(s))),s=t}s.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=s}getMaterialType(){return MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,i=this.extensions,n=s.materials[e];let l;const r={},o=n.extensions||{},a=[];if(o[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=i[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];l=e.getMaterialType(),a.push(e.extendParams(r,n,t))}else if(o[C.KHR_MATERIALS_UNLIT]){const e=i[C.KHR_MATERIALS_UNLIT];l=e.getMaterialType(),a.push(e.extendParams(r,n,t))}else{const s=n.pbrMetallicRoughness||{};if(r.color=new Color(1,1,1),r.opacity=1,Array.isArray(s.baseColorFactor)){const e=s.baseColorFactor;r.color.fromArray(e),r.opacity=e[3]}void 0!==s.baseColorTexture&&a.push(t.assignTexture(r,"map",s.baseColorTexture,sRGBEncoding)),r.metalness=void 0!==s.metallicFactor?s.metallicFactor:1,r.roughness=void 0!==s.roughnessFactor?s.roughnessFactor:1,void 0!==s.metallicRoughnessTexture&&(a.push(t.assignTexture(r,"metalnessMap",s.metallicRoughnessTexture)),a.push(t.assignTexture(r,"roughnessMap",s.metallicRoughnessTexture))),l=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),a.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,r)}))))}!0===n.doubleSided&&(r.side=DoubleSide);const d=n.alphaMode||ie;if(d===le?(r.transparent=!0,r.depthWrite=!1):(r.transparent=!1,d===ne&&(r.alphaTest=void 0!==n.alphaCutoff?n.alphaCutoff:.5)),void 0!==n.normalTexture&&l!==MeshBasicMaterial&&(a.push(t.assignTexture(r,"normalMap",n.normalTexture)),r.normalScale=new Vector2(1,1),void 0!==n.normalTexture.scale)){const e=n.normalTexture.scale;r.normalScale.set(e,e)}return void 0!==n.occlusionTexture&&l!==MeshBasicMaterial&&(a.push(t.assignTexture(r,"aoMap",n.occlusionTexture)),void 0!==n.occlusionTexture.strength&&(r.aoMapIntensity=n.occlusionTexture.strength)),void 0!==n.emissiveFactor&&l!==MeshBasicMaterial&&(r.emissive=(new Color).fromArray(n.emissiveFactor)),void 0!==n.emissiveTexture&&l!==MeshBasicMaterial&&a.push(t.assignTexture(r,"emissiveMap",n.emissiveTexture,sRGBEncoding)),Promise.all(a).then((function(){let s;return s=l===F?i[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(r):new l(r),n.name&&(s.name=n.name),oe(s,n),t.associations.set(s,{materials:e}),n.extensions&&re(i,s,n),s}))}createUniqueName(e){const t=PropertyBinding.sanitizeNodeName(e||"");let s=t;for(let e=1;this.nodeNamesUsed[s];++e)s=t+"_"+e;return this.nodeNamesUsed[s]=!0,s}loadGeometries(e){const t=this,s=this.extensions,i=this.primitiveCache;function n(e){return s[C.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(s){return ue(s,e,t)}))}const l=[];for(let s=0,r=e.length;s0&&ae(h,n),h.name=t.createUniqueName(n.name||"mesh_"+e),oe(h,n),c.extensions&&re(i,h,c),t.assignFinalMaterial(h),a.push(h)}for(let s=0,i=a.length;s1?new Group:1===t.length?t[0]:new Object3D,r!==t[0])for(let e=0,s=t.length;e{const t=new Map;for(const[e,s]of n.associations)(e instanceof Material||e instanceof Texture)&&t.set(e,s);return e.traverse((e=>{const s=n.associations.get(e);null!=s&&t.set(e,s)})),t})(l),l}))}}function me(e,t,s,i){const n=s.nodes[e];return i.getDependency("node",e).then((function(e){if(void 0===n.skin)return e;let t;return i.getDependency("skin",n.skin).then((function(e){t=e;const s=[];for(let e=0,n=t.joints.length;e{const s=n[e];return s&&(l={profileId:e,profilePath:`${t}/${s.path}`,deprecated:!!s.deprecated}),!!l})),!l){if(!s)throw new Error("No matching profile name found");const e=n[s];if(!e)throw new Error(`No matching profile name found and default profile "${s}" missing.`);l={profileId:s,profilePath:`${t}/${e.path}`,deprecated:!!e.deprecated}}const r=await be(l.profilePath);let o;if(i){let t;if(t="any"===e.handedness?r.layouts[Object.keys(r.layouts)[0]]:r.layouts[e.handedness],!t)throw new Error(`No matching handedness, ${e.handedness}, in profile ${l.profileId}`);t.assetPath&&(o=l.profilePath.replace("profile.json",t.assetPath))}return{profile:r,assetPath:o}}const ye={xAxis:0,yAxis:0,button:0,state:fe.ComponentState.DEFAULT};class ve{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===fe.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(ye)}updateFromComponent({xAxis:e,yAxis:t,button:s,state:i}){const{normalizedXAxis:n,normalizedYAxis:l}=function(e=0,t=0){let s=e,i=t;if(Math.sqrt(e*e+t*t)>1){const n=Math.atan2(t,e);s=Math.cos(n),i=Math.sin(n)}return{normalizedXAxis:.5*s+.5,normalizedYAxis:.5*i+.5}}(e,t);switch(this.componentProperty){case fe.ComponentProperty.X_AXIS:this.value=this.states.includes(i)?n:.5;break;case fe.ComponentProperty.Y_AXIS:this.value=this.states.includes(i)?l:.5;break;case fe.ComponentProperty.BUTTON:this.value=this.states.includes(i)?s:0;break;case fe.ComponentProperty.STATE:this.valueNodeProperty===fe.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(i):this.value=this.states.includes(i)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class _e{constructor(e,t){if(!(e&&t&&t.visualResponses&&t.gamepadIndices&&0!==Object.keys(t.gamepadIndices).length))throw new Error("Invalid arguments supplied");this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach((e=>{const s=new ve(t.visualResponses[e]);this.visualResponses[e]=s})),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:fe.ComponentState.DEFAULT,button:void 0!==this.gamepadIndices.button?0:void 0,xAxis:void 0!==this.gamepadIndices.xAxis?0:void 0,yAxis:void 0!==this.gamepadIndices.yAxis?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(e){if(this.values.state=fe.ComponentState.DEFAULT,void 0!==this.gamepadIndices.button&&e.buttons.length>this.gamepadIndices.button){const t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||1===this.values.button?this.values.state=fe.ComponentState.PRESSED:(t.touched||this.values.button>fe.ButtonTouchThreshold)&&(this.values.state=fe.ComponentState.TOUCHED)}void 0!==this.gamepadIndices.xAxis&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===fe.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>fe.AxisTouchThreshold&&(this.values.state=fe.ComponentState.TOUCHED)),void 0!==this.gamepadIndices.yAxis&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===fe.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>fe.AxisTouchThreshold&&(this.values.state=fe.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach((e=>{e.updateFromComponent(this.values)}))}}class we{constructor(e,t,s){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No profile supplied");this.xrInputSource=e,this.assetUrl=s,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach((e=>{const t=this.layoutDescription.components[e];this.components[e]=new _e(e,t)})),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const e=[];return Object.values(this.components).forEach((t=>{e.push(t.data)})),e}updateFromGamepad(){Object.values(this.components).forEach((e=>{e.updateFromGamepad(this.xrInputSource.gamepad)}))}}class Se extends THREE.Object3D{constructor(){super(),this.motionController=null,this.envMap=null}setEnvironmentMap(e){return this.envMap==e||(this.envMap=e,this.traverse((e=>{e.isMesh&&(e.material.envMap=this.envMap,e.material.needsUpdate=!0)}))),this}updateMatrixWorld(e){super.updateMatrixWorld(e),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach((e=>{Object.values(e.visualResponses).forEach((e=>{const{valueNode:t,minNode:s,maxNode:i,value:n,valueNodeProperty:l}=e;t&&(l===fe.VisualResponseProperty.VISIBILITY?t.visible=n:l===fe.VisualResponseProperty.TRANSFORM&&(t.quaternion.slerpQuaternions(s.quaternion,i.quaternion,n),t.position.lerpVectors(s.position,i.position,n)))}))})))}}function Ae(e,t){!function(e,t){Object.values(e.components).forEach((e=>{const{type:s,touchPointNodeName:i,visualResponses:n}=e;if(s===fe.ComponentType.TOUCHPAD)if(e.touchPointNode=t.getObjectByName(i),e.touchPointNode){const t=new SphereGeometry(.001),s=new MeshBasicMaterial({color:255}),i=new Mesh(t,s);e.touchPointNode.add(i)}else console.warn(`Could not find touch dot, ${e.touchPointNodeName}, in touchpad component ${e.id}`);Object.values(n).forEach((e=>{const{valueNodeName:s,minNodeName:i,maxNodeName:n,valueNodeProperty:l}=e;if(l===fe.VisualResponseProperty.TRANSFORM){if(e.minNode=t.getObjectByName(i),e.maxNode=t.getObjectByName(n),!e.minNode)return void console.warn(`Could not find ${i} in the model`);if(!e.maxNode)return void console.warn(`Could not find ${n} in the model`)}e.valueNode=t.getObjectByName(s),e.valueNode||console.warn(`Could not find ${s} in the model`)}))}))}(e.motionController,t),e.envMap&&t.traverse((t=>{t.isMesh&&(t.material.envMap=e.envMap,t.material.needsUpdate=!0)})),e.add(t)}class xe{constructor(e=null){this.gltfLoader=e,this.path="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",this._assetCache={},this.gltfLoader||(this.gltfLoader=new f)}createControllerModel(e){const t=new Se;let s=null;return e.addEventListener("connected",(e=>{const i=e.data;"tracked-pointer"===i.targetRayMode&&i.gamepad&&Ce(i,this.path,"generic-trigger").then((({profile:e,assetPath:n})=>{t.motionController=new we(i,e,n);const l=this._assetCache[t.motionController.assetUrl];if(l)s=l.scene.clone(),Ae(t,s);else{if(!this.gltfLoader)throw new Error("GLTFLoader not set.");this.gltfLoader.setPath(""),this.gltfLoader.load(t.motionController.assetUrl,(e=>{this._assetCache[t.motionController.assetUrl]=e,s=e.scene.clone(),Ae(t,s)}),null,(()=>{throw new Error(`Asset ${t.motionController.assetUrl} missing or malformed.`)}))}})).catch((e=>{console.warn(e)}))})),e.addEventListener("disconnected",(()=>{t.motionController=null,t.remove(s),s=null})),t}}class ke extends THREE.EventDispatcher{constructor(e){if(super(),void 0===e)return void console.error("ControllerGestures must be passed a renderer");const t=new THREE.Clock;this.controller1=e.xr.getController(0),this.controller1.userData.gestures={index:0},this.controller1.userData.selectPressed=!1,this.controller1.addEventListener("selectstart",i),this.controller1.addEventListener("selectend",n),this.controller2=e.xr.getController(1),this.controller2.userData.gestures={index:1},this.controller2.userData.selectPressed=!1,this.controller2.addEventListener("selectstart",i),this.controller2.addEventListener("selectend",n),this.doubleClickLimit=.2,this.pressMinimum=.4,this.right=new THREE.Vector3(1,0,0),this.up=new THREE.Vector3(0,1,0),this.type="unknown",this.prevTap="none",this.clock=t;const s=this;function i(){const e=this.userData.gestures;e.startPosition=void 0,e.startTime=t.getElapsedTime(),-1==s.type.indexOf("tap")&&(e.taps=0),s.type="unknown",this.userData.selectPressed=!0}function n(){const e=this.userData.gestures;e.endTime=t.getElapsedTime();e.endTime-e.startTime.05&&(e.startPosition=this.controller1.position.clone())),this.controller2.userData.selectPressed&&void 0===t.startPosition&&(i=s-t.startTime,i>.05&&(t.startPosition=this.controller2.position.clone())),!this.controller1.userData.selectPressed&&"tap"===this.type&&(i=this.clock.getElapsedTime()-e.endTime,i>this.doubleClickLimit)){switch(e.taps){case 1:self.prevTap="tap";break;case 2:this.dispatchEvent({type:"doubletap",position:this.controller1.position,matrixWorld:this.controller1.matrixWorld}),self.prevTap="doubletap"}this.type="unknown",e.taps=0}if("unknown"===this.type&&this.touch)"doubletap"==self.prevTap?(this.type="pinch",this.startDistance=this.controller1.position.distanceTo(this.controller2.position),this.dispatchEvent({type:"pinch",delta:new THREE.Vector3(0,0,0),scale:1,initialise:!0})):(this.type="pan",this.startPosition=this.controller1.position.clone(),this.dispatchEvent({type:"pan",delta:new THREE.Vector3(0,0,0),initialise:!0}));else if(("pinch"===this.type||"pan"===this.type)&&"doubletap"==self.prevTap&&this.controller2.position){const e=this.controller1.position.distanceTo(this.controller2.position)/this.startDistance,t=this.controller1.position.clone().sub(this.startPosition);this.dispatchEvent({type:"pinch",delta:t,scale:e})}}}class Oe{constructor(e,t){this.config=void 0===t?{panelSize:{width:1,height:1},width:512,height:512,opacity:.7,body:{fontFamily:"Arial",fontSize:30,padding:2,backgroundColor:"#000",fontColor:"#fff",borderRadius:6}}:t,void 0===this.config.width&&(this.config.width=512),void 0===this.config.height&&(this.config.height=512),void 0===this.config.body&&(this.config.body={fontFamily:"Arial",size:30,padding:2,backgroundColor:"#000",fontColor:"#fff",borderRadius:6});const s=this.config.body;void 0===s.borderRadius&&(s.borderRadius=6),void 0===s.fontFamily&&(s.fontFamily="Arial"),void 0===s.padding&&(s.padding=2),void 0===s.fontSize&&(s.fontSize=30),void 0===s.backgroundColor&&(s.backgroundColor="#000"),void 0===s.fontColor&&(s.fontColor="#fff"),Object.entries(this.config).forEach((([e,t])=>{if(!("object"!=typeof t||"panelSize"===e||t instanceof THREE.WebGLRenderer||t instanceof THREE.Scene)){const e=void 0!==t.position?t.position:{x:0,y:0};void 0!==e.left&&void 0===e.x&&(e.x=e.left),void 0!==e.top&&void 0===e.y&&(e.y=e.top);const s=void 0!==t.width?t.width:this.config.width,i=void 0!==t.height?t.height:this.config.height;void 0!==e.right&&void 0===e.x&&(e.x=this.config.width-e.right-s),void 0!==e.bottom&&void 0===e.y&&(e.y=this.config.height-e.bottom-i),void 0===e.x&&(e.x=0),void 0===e.y&&(e.y=0),t.position=e,void 0===t.type&&(t.type="text")}}));const i=this.createOffscreenCanvas(this.config.width,this.config.height);this.context=i.getContext("2d"),this.context.save();const n=void 0!==this.config.opacity?this.config.opacity:.7,l=new THREE.MeshBasicMaterial({transparent:!0,opacity:n});this.panelSize=void 0!==this.config.panelSize?this.config.panelSize:{width:1,height:1};const r=new THREE.PlaneGeometry(this.panelSize.width,this.panelSize.height);this.mesh=new THREE.Mesh(r,l),this.texture=new THREE.CanvasTexture(i),this.mesh.material.map=this.texture,this.scene=this.config.scene;if(Object.values(this.config).filter((e=>"input-text"===e.type)).length>0){this.keyboard=new Re(this.panelSize.width,this.config.renderer);this.keyboard.mesh.position.set(0,-.3,.2),this.mesh.add(this.keyboard.mesh)}if(void 0===e)this.content={body:""},this.config.body.type="text";else{this.content=e;Object.values(t).filter((e=>"button"===e.type||"scroll"===e.overflow||"input-text"===e.type)).length>0&&(void 0===t||void 0===t.renderer?console.warn("CanvasUI: button, scroll or input-text in the config but no renderer"):(this.renderer=t.renderer,this.initControllers()))}this.selectedElements=[void 0,void 0],this.selectPressed=[!1,!1],this.scrollData=[void 0,void 0],this.intersects=[void 0,void 0],this.needsUpdate=!0,this.update()}getIntersectY(e){const t=this.config.height||512,s=this.intersects[e];return void 0===s||void 0===s.uv?0:(1-s.uv.y)*t}initControllers(){this.vec3=new THREE.Vector3,this.mat4=new THREE.Matrix4,this.raycaster=new THREE.Raycaster;const e=this;function t(t){const s=t.target===e.controller?0:1,i=e.selectedElements[s];if(void 0!==i)if("button"==i.type)e.select(s);else if("input-text"==i.type&&e.keyboard)if(e.keyboard.visible)e.keyboard.linkedUI=void 0,e.keyboard.linkedText=void 0,e.keyboard.linkedElement=void 0,e.keyboard.visible=!1;else{let t;e.keyboard.linkedUI=e,Object.entries(e.config).forEach((([e,s])=>{s==i&&(t=e)}));const s=(.5-(i.position.y+i.height+e.config.body.padding)/e.config.height)*e.panelSize.height,n=Math.max(e.panelSize.width,e.panelSize.height)/2;e.keyboard.position.set(0,-n/1.5-s,.1),e.keyboard.linkedText=e.content[t],e.keyboard.linkedName=t,e.keyboard.linkedElement=i,e.keyboard.visible=!0}}function s(t){const s=t.target===e.controller?0:1;if(e.selectPressed[s]=!0,void 0!==e.selectedElements[s]&&"scroll"==e.selectedElements[s].overflow){const t=e.selectedElements[s];e.scrollData[s]={scrollY:t.scrollY,rayY:e.getIntersectY(s)}}}function i(t){const s=t.target===e.controller?0:1;e.selectPressed[s]=!1,void 0!==e.selectedElements[s]&&"scroll"==e.selectedElements[s].overflow&&(e.scrollData[s]=void 0)}if(this.controller=this.renderer.xr.getController(0),this.controller.addEventListener("select",t),this.controller.addEventListener("selectstart",s),this.controller.addEventListener("selectend",i),this.controller1=this.renderer.xr.getController(1),this.controller1.addEventListener("select",t),this.controller1.addEventListener("selectstart",s),this.controller1.addEventListener("selectend",i),this.scene){const e=.015,t=new THREE.IcosahedronBufferGeometry(e),s=new THREE.MeshBasicMaterial({color:170}),i=new THREE.Mesh(t,s);i.visible=!1,this.scene.add(i);const n=new THREE.Mesh(t,s);n.visible=!1,this.scene.add(n),this.intersectMesh=[i,n]}}setClip(e){const t=this.context;if(t.restore(),t.save(),void 0!==e.clipPath){const s=new Path2D(e.clipPath);t.clip(s)}else{const s=void 0!==e.position?e.position:{x:0,y:0},i=e.borderRadius||0,n=e.width||this.config.width,l=e.height||this.config.height;if(t.beginPath(),0!==i){const e=Math.PI/2;t.moveTo(s.x+i,s.y),t.arc(s.x+i,s.y+i,i,e,2*e,!0),t.lineTo(s.x,s.y+l-i),t.arc(s.x+i,s.y+l-i,i,0,e,!0),t.lineTo(s.x+n-i,s.y+l),t.arc(s.x+n-i,s.y+l-i,i,3*e,4*e,!0),t.lineTo(s.x+n,s.y+i),t.arc(s.x+n-i,s.y+i,i,2*e,3*e,!0),t.closePath(),t.clip()}else t.rect(s.x,s.y,n,l),t.clip()}}setPosition(e,t,s){void 0!==this.mesh&&this.mesh.position.set(e,t,s)}setRotation(e,t,s){void 0!==this.mesh&&this.mesh.rotation.set(e,t,s)}updateElement(e,t){let s=this.content[e];void 0!==s?("object"==typeof s?s.content=t:s=t,this.content[e]=s,this.needsUpdate=!0):console.warn(`CanvasGUI.updateElement: No ${e} found`)}get panel(){return this.mesh}getElementAtLocation(e,t){const s=this,i=Object.entries(this.config).filter((([i,n])=>{if(!("object"!=typeof n||"panelSize"===i||"body"===i||n instanceof THREE.WebGLRenderer||n instanceof THREE.Scene)){const i=n.position,l=void 0!==n.width?n.width:s.config.width,r=void 0!==n.height?n.height:s.config.height;return e>=i.x&&e=i.y&&t0?(this.hover(t,s[0].uv),this.intersects[t]=s[0],this.scroll(t)):(this.hover(t),this.intersects[t]=void 0,this.scroll(t))}update(){if(void 0===this.mesh)return;if(this.controller&&this.handleController(this.controller,0),this.controller1&&this.handleController(this.controller1,1),this.keyboard&&this.keyboard.visible&&this.keyboard.update(),!this.needsUpdate)return;let e=this.context;e.clearRect(0,0,this.config.width,this.config.height);const t=this.config.body.backgroundColor?this.config.body.backgroundColor:"#000";!this.config.body.fontFamily||this.config.body.fontFamily;const s=this.config.body.fontColor?this.config.body.fontColor:"#fff";!this.config.body.fontSize||this.config.body.fontSize,this.setClip(this.config.body),e.fillStyle=t,e.fillRect(0,0,this.config.width,this.config.height);const i=this;Object.entries(this.content).forEach((([t,n])=>{const l=void 0!==i.config[t]?i.config[t]:i.config.body;if("none"!==(void 0!==l.display?l.display:"block")){const r=void 0!==l.position?l.position:{x:0,y:0},o=void 0!==l.width?l.width:i.config.width,a=void 0!==l.height?l.height:i.config.height;"button"!=l.type||n.toLowerCase().startsWith("")||(void 0===l.borderRadius&&(l.borderRadius=6),void 0===l.textAlign&&(l.textAlign="center")),i.setClip(l);const d=n.toLowerCase().startsWith(""),c=void 0!==i.selectedElements[0]&&this.selectedElements[0]===l||void 0!==i.selectedElements[1]&&this.selectedElements[1]===l;if(void 0!==l.backgroundColor&&(c&&"button"==l.type&&void 0!==l.hover?e.fillStyle=l.hover:e.fillStyle=l.backgroundColor,e.fillRect(r.x,r.y,o,a)),"text"==l.type||"button"==l.type||"input-text"==l.type){let h=!1;if(c?(d||"button"!=l.type?e.fillStyle=void 0!==l.hover?l.hover:void 0!==l.fontColor?l.fontColor:s:e.fillStyle=void 0!==l.fontColor?l.fontColor:s,h=void 0===l.hover):e.fillStyle=void 0!==l.fontColor?l.fontColor:s,d){const t=n.toUpperCase().substring(6,n.length-7);e.save(),e.translate(r.x,r.y);const s=new Path2D(t);e.fill(s),e.restore()}else i.wrapText(t,n);h&&(e.beginPath(),e.strokeStyle="#fff",e.lineWidth=2,e.rect(r.x,r.y,o,a),e.stroke())}else if("img"==l.type)if(void 0===l.img)this.loadImage(n).then((e=>{console.log(`w: ${e.width} | h: ${e.height}`),l.img=e,i.needsUpdate=!0,i.update()})).catch((e=>console.error(e)));else{const t=o/(l.img.width/l.img.height);e.drawImage(l.img,r.x,r.y,o,t)}}})),this.needsUpdate=!1,this.texture.needsUpdate=!0}loadImage(e){return new Promise(((t,s)=>{const i=new THREE.Image;i.addEventListener("load",(()=>t(i))),i.addEventListener("error",(e=>s(e))),i.src=e}))}createOffscreenCanvas(e,t){const s=document.createElement("canvas");return s.width=e,s.height=t,s}fillRoundedRect(e,t,s,i,n){const l=this.context;l.beginPath(),l.moveTo(e+n,t),l.lineTo(e+s-n,t),l.quadraticCurveTo(e+s,t,e+s,t+n),l.lineTo(e+s,t+i-n),l.quadraticCurveTo(e+s,t+i,e+s-n,t+i),l.lineTo(e+n,t+i),l.quadraticCurveTo(e,t+i,e,t+i-n),l.lineTo(e,t+n),l.quadraticCurveTo(e,t,e+n,t),l.closePath(),l.fill()}lookAt(e){void 0!==this.mesh&&(e instanceof Vector3?this.mesh.lookAt(e):console.error("CanvasUI lookAt called parameter not a THREE.Vector3"))}get visible(){return void 0!==this.mesh&&this.mesh.visible}set visible(e){this.mesh&&(this.mesh.visible=e)}get position(){if(void 0!==this.mesh)return this.mesh.position}set position(e){void 0!==this.mesh&&(e instanceof Vector3?this.mesh.position.copy(e):console.error("CanvasUI trying to set the mesh position using a parameter that is not a THREE.Vector3"))}get quaternion(){if(void 0!==this.mesh)return this.mesh.quaternion}set quaternion(e){void 0!==this.mesh&&(e instanceof QUaternion?this.mesh.quaternion.copy(e):console.error("CanvasUI trying to set the mesh quaternion using a parameter that is not a THREE.Quaternion"))}wrapText(e,t){const s=t.split(" ");let i="";const n=[],l=void 0!==this.config[e]?this.config[e]:this.config.body,r=void 0!==l.width?l.width:this.config.width,o=void 0!==l.height?l.height:this.config.height,a=void 0!==l.position?l.position:{x:0,y:0},d=void 0!==l.padding?l.padding:void 0!==this.config.body.padding?this.config.body.padding:10,c=void 0!==l.paddingTop?l.paddingTop:d,h=void 0!==l.paddingLeft?l.paddingLeft:d,p=void 0!==l.paddingBottom?l.paddingBottom:d,m=void 0!==l.paddingRight?l.paddingRight:d,u={x:a.x+h,y:a.y+c,width:r-h-m,height:o-c-p},g=void 0!==l.textAlign?l.textAlign:void 0!==this.config.body.textAlign?this.config.body.textAlign:"left",f=void 0!==l.fontSize?l.fontSize:void 0!==this.config.body.fontSize?this.config.body.fontSize:30,b=void 0!==l.fontFamily?l.fontFamily:void 0!==this.config.body.fontFamily?this.config.body.fontFamily:"Arial",C=f+(void 0!==l.leading?l.leading:void 0!==this.config.body.leading?this.config.body.leading:8),y=this.context;y.textAlign=g,y.font=`${f}px '${b}'`,s.forEach((function(e){let t=s.length>1?`${i}${e} `:e,l=y.measureText(t);if(l.width>u.width&&e.length>1)if(0==i.length&&l.width>u.width){for(;l.width>u.width;){let s=0;do{s++,t=e.substr(0,s),l=y.measureText(t)}while(l.widthu.height&&"scroll"===l.overflow){void 0===l.scrollY&&(l.scrollY=0);const e=void 0!==l.fontColor?l.fontColor:this.config.body.fontColor;y.fillStyle="#aaa",this.fillRoundedRect(a.x+r-12,a.y,12,o,6),y.fillStyle="#666";const t=u.height/v,s=t*o,i=-l.scrollY*t;this.fillRoundedRect(a.x+r-12,a.y+i,12,s,6),y.fillStyle=e,_=l.scrollY,l.minScrollY=u.height-v}let w,S=_+u.y+f/2;switch(g){case"center":w=u.x+u.width/2;break;case"right":w=u.x+u.width;break;default:w=u.x}n.forEach((e=>{S+C>0&&y.fillText(e,w,S),S+=C}))}}class Re{constructor(e,t,s="EN"){const i=this.getConfig(s);i.panelSize={width:e,height:.5*e},i.height=256,i.body={backgroundColor:"#555"},i.renderer=t;const n=this.getContent(s);this.keyboard=new Oe(n,i),this.keyboard.mesh.visible=!1,this.shift=!1}get mesh(){return this.keyboard.mesh}getConfig(e){const t={};let s=10;const i=39.2,n=49,l="#333",r="#000";let o=s,a=s;for(let e=0;e<10;e++){const d={type:"button",position:{x:a,y:o},width:i,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e)};t[`btn${e}`]=d,a+=49.2}o+=59,a=s;for(let e=0;e<10;e++){const d={type:"button",position:{x:a,y:o},width:i,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+10)};t[`btn${e+10}`]=d,a+=49.2}o+=59,a=s;for(let e=0;e<9;e++){const d=0==e||8==e?1.5*i+5:i,c={type:"button",position:{x:a,y:o},width:d,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+20)};t[`btn${e+20}`]=c,a+=d+s}o+=59,a=s;for(let e=0;e<5;e++){const d=0==e||4==e?88.4:2==e?186.8:i,c={type:"button",position:{x:a,y:o},width:d,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+30)};0==e&&(c.fontSize=20),t[`btn${e+30}`]=c,a+=d+s}return t}getContent(e,t=0){let s,i={};switch(this.language=e,this.keyboardIndex=t,t){case 0:s=["q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","@","⇧","z","x","c","v","b","n","m","⇦","","?123",","," ",".","↲"];for(let e=0;e","_","`","~",":",";","⇦","","abc",","," ",".","↲"];for(let e=0;e=0;e--){let s=t.scene.children[e];t.scene.remove(s)}else t.scene=new THREE.Scene;if(void 0!==t.scene_ghost)for(let e=t.scene_ghost.children.length-1;e>=0;e--){let s=t.scene_ghost.children[e];t.scene_ghost.remove(s)}else t.scene_ghost=new THREE.Scene;if(""!=s.htmlCls.setHtmlCls.getCookie("shininess")){let e=parseFloat(s.htmlCls.setHtmlCls.getCookie("shininess"));t.shininess!=e&&s.htmlCls.clickMenuCls.setLogCmd("set shininess "+e,!0),t.shininess=e}if(!s.bNode&&""!=s.htmlCls.setHtmlCls.getCookie("light1")){let e=parseFloat(s.htmlCls.setHtmlCls.getCookie("light1")),i=parseFloat(s.htmlCls.setHtmlCls.getCookie("light2")),n=parseFloat(s.htmlCls.setHtmlCls.getCookie("light3"));t.light1==e&&t.light2==i&&t.light3==n||s.htmlCls.clickMenuCls.setLogCmd("set light | light1 "+e+" | light2 "+i+" | light3 "+n,!0),t.light1=e,t.light2=i,t.light3=n}t.directionalLight=new THREE.DirectionalLight(16777215,t.light1),t.directionalLight2=new THREE.DirectionalLight(16777215,t.light2),t.directionalLight3=new THREE.DirectionalLight(16777215,t.light3),t.cam_z>0?(t.directionalLight.position.set(-1,1,1),t.directionalLight2.position.set(1,1,1),t.directionalLight3.position.set(1,1,-1),t.lightPos=new THREE.Vector3(-1,1,1),t.lightPos2=new THREE.Vector3(1,1,1),t.lightPos3=new THREE.Vector3(1,1,-1)):(t.directionalLight.position.set(-1,1,-1),t.directionalLight2.position.set(1,1,-1),t.directionalLight3.position.set(1,1,1),t.lightPos=new THREE.Vector3(-1,1,-1),t.lightPos2=new THREE.Vector3(1,1,-1),t.lightPos3=new THREE.Vector3(1,1,1));let i=new THREE.AmbientLight(4210752);if(t.scene.add(t.directionalLight),t.scene.add(i),void 0!==t.mdl)for(let e=t.mdl.children.length-1;e>=0;e--){let s=t.mdl.children[e];s.geometry&&s.geometry.dispose(),s.material&&s.material.dispose(),t.mdl.remove(s)}if(void 0!==t.mdlImpostor){for(let e=t.mdlImpostor.children.length-1;e>=0;e--){let s=t.mdlImpostor.children[e];s.geometry&&s.geometry.dispose(),s.material&&s.material.dispose(),t.mdlImpostor.remove(s)}t.mdlImpostor.children.length=0}s.bNode||t.renderer.renderLists.dispose(),t.mdl=new THREE.Object3D,t.mdlImpostor=new THREE.Object3D,t.scene.add(t.mdl),t.scene.add(t.mdlImpostor),t.mdl_ghost=new THREE.Object3D,t.scene_ghost.add(t.mdl_ghost),t.objects=[],t.objects_ghost=[],t.raycaster=new THREE.Raycaster,t.projector=new THREE.Projector,t.mouse=new THREE.Vector2;let n=s.parasCls.backgroundColors[t.opts.background.toLowerCase()];s.bNode||("transparent"===t.opts.background.toLowerCase()?t.renderer.setClearColor(n,0):t.renderer.setClearColor(n,1)),t.perspectiveCamera=new THREE.PerspectiveCamera(20,t.container.whratio,.1,1e4),t.perspectiveCamera.position.set(0,0,t.cam_z),t.perspectiveCamera.lookAt(new THREE.Vector3(0,0,0)),t.orthographicCamera=new THREE.OrthographicCamera,t.orthographicCamera.position.set(0,0,t.cam_z),t.orthographicCamera.lookAt(new THREE.Vector3(0,0,0)),t.cams={perspective:t.perspectiveCamera,orthographic:t.orthographicCamera}}setVrAr(){let e=this.icn3d;e.icn3dui;let t=this;e.bSetVrAr=!0,e.bVr?(e.canvasUI=this.createUI(),e.raycasterVR=new THREE.Raycaster,e.workingMatrix=new THREE.Matrix4,e.workingVector=new THREE.Vector3,e.origin=new THREE.Vector3,e.dolly=new THREE.Object3D,e.dolly.position.z=5,e.dolly.add(e.cam),e.scene.add(e.dolly),e.dollyId=e.dolly.id,e.dummyCam=new THREE.Object3D,e.cam.add(e.dummyCam),e.clock=new THREE.Clock,e.controllers=this.getControllers(),e.controllers.forEach((s=>{s.addEventListener("connected",(function(e){try{const s={},i="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",n="generic-trigger";Ce(e.data,i,n).then((({profile:i,assetPath:n})=>{s.name=i.profileId,s.targetRayMode=e.data.targetRayMode,Object.entries(i.layouts).forEach((([e,t])=>{const i={};Object.values(t.components).forEach((e=>{i[e.rootNodeName]=e.gamepadIndices})),s[e]=i})),t.updateControllers(s)}))}catch(e){}})),s.addEventListener("disconnected",(function(){this.remove(this.children[0]),e.controllers.forEach((e=>{}))}))}))):e.bAr&&(e.gestures=new ke(e.renderer),e.scene.add(e.gestures.controller1),e.scene.add(e.gestures.controller2),e.gestures.addEventListener("doubletap",(e=>{t.positionCenter()})),e.gestures.addEventListener("pinch",(s=>{if(void 0!==s.initialise)t.startPosition=e.mdl.position.clone(),t.startScale=e.mdl.scale.clone();else{let i=1;const n=t.startScale.clone().multiplyScalar(s.scale*i);e.mdl.scale.copy(n)}})))}positionCenter(){let e=this.icn3d;e.icn3dui;const t=e.gestures.controller1;e.mdl.position.set(-.06,0,-.6).applyMatrix4(t.matrixWorld),e.mdl.scale.copy(new THREE.Vector3(.005,.005,.005))}setVrArButtons(){let e=this.icn3d,t=e.icn3dui;e.bSetVrArButtons=!0,t.bNode||($("#"+t.pre+"VRButton").remove(),$("#"+t.pre+"viewer").get(0).appendChild(e.VRButtonCls.createButton(e.renderer)),$("#"+t.pre+"ARButton").remove(),$("#"+t.pre+"viewer").get(0).appendChild(e.ARButtonCls.createButton(e.renderer)))}updateControllers(e){this.icn3d.icn3dui,this.addEventForController(e,"right"),this.addEventForController(e,"left")}addEventForController(e,t){let s=this.icn3d;s.icn3dui;const i="right"==t?s.renderer.xr.getController(0):s.renderer.xr.getController(1),n="right"==t?e.right:e.left;if(i&&void 0!==n){let e=!1,t=!1;Object.keys(n).forEach((i=>{-1!=i.indexOf("trigger")&&(e=!0),-1!=i.indexOf("squeeze")&&(t=!0),-1==i.indexOf("thumbstick")&&-1==i.indexOf("touchpad")||(s.xAxisIndex=n[i].xAxis,s.yAxisIndex=n[i].yAxis)})),e&&(i.addEventListener("selectstart",(function(){this.userData.selectPressed=!0})),i.addEventListener("selectend",(function(){this.userData.selectPressed=!1,this.userData.selected=void 0}))),t&&(i.addEventListener("squeezestart",(function(){this.userData.squeezePressed=!0,s.cam.add(s.canvasUI.mesh)})),i.addEventListener("squeezeend",(function(){this.userData.squeezePressed=!1,s.cam.remove(s.canvasUI.mesh)})))}}createUI(){let e=this.icn3d,t=e.icn3dui,s=94,i=50,n=94,l=34,r=12,o="#1c94c4",a="#ccc",d="#fbcb09",c=20;const h={panelSize:{width:2,height:1.6},height:400,select:{type:"button",paddingTop:c,position:{top:6,left:6},width:s,height:i,fontColor:"#000",fontSize:14,backgroundColor:a},residue:{type:"button",paddingTop:c,position:{top:62,left:6},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.pk=2,e.pAtomNum||(e.pAtomNum=0),e.cam.remove(e.canvasUI.mesh)}},secondarySelect:{type:"button",paddingTop:12,position:{top:118,left:6},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.pk=3,e.pAtomNum||(e.pAtomNum=0),e.cam.remove(e.canvasUI.mesh)}},chainSelect:{type:"button",paddingTop:c,position:{top:174,left:6},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.pk=5,e.pAtomNum||(e.pAtomNum=0),e.cam.remove(e.canvasUI.mesh)}},atom:{type:"button",paddingTop:c,position:{top:230,left:6},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.pk=1,e.pAtomNum||(e.pAtomNum=0),e.cam.remove(e.canvasUI.mesh)}},reset:{type:"button",paddingTop:c,position:{top:286,left:6},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.viewInterPairsCls.resetInteractionPairs(),e.selectionCls.resetAll(),e.cam.remove(e.canvasUI.mesh)}},togglehl:{type:"button",paddingTop:12,position:{top:342,left:6},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.hlUpdateCls.toggleHighlight(),e.cam.remove(e.canvasUI.mesh)}},style:{type:"button",paddingTop:c,position:{top:6,left:106},width:s,height:i,fontColor:"#000",fontSize:14,backgroundColor:a},ribbon:{type:"button",paddingTop:c,position:{top:62,left:106},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.setOptionCls.setStyle("proteins","ribbon"),e.setOptionCls.setStyle("nucleotides","nucleotide cartoon"),e.cam.remove(e.canvasUI.mesh)}},schematic:{type:"button",paddingTop:c,position:{top:118,left:106},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.setOptionCls.setStyle("proteins","schematic"),e.setOptionCls.setStyle("nucleotides","schematic"),e.cam.remove(e.canvasUI.mesh)}},stick:{type:"button",paddingTop:c,position:{top:174,left:106},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.setOptionCls.setStyle("proteins","stick"),e.setOptionCls.setStyle("nucleotides","stick"),e.cam.remove(e.canvasUI.mesh)}},sphere:{type:"button",paddingTop:c,position:{top:230,left:106},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.setOptionCls.setStyle("proteins","sphere"),e.setOptionCls.setStyle("nucleotides","sphere"),e.cam.remove(e.canvasUI.mesh)}},surface:{type:"button",paddingTop:c,position:{top:286,left:106},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.opts.surface="molecular surface",e.applyMapCls.applySurfaceOptions(),e.cam.remove(e.canvasUI.mesh)}},surfaceTrn:{type:"button",paddingTop:12,position:{top:342,left:106},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.opts.surface="molecular surface",e.opts.opacity="0.2",e.applyMapCls.applySurfaceOptions(),e.cam.remove(e.canvasUI.mesh)}},color:{type:"button",paddingTop:c,position:{top:6,left:206},width:s,height:i,fontColor:"#000",fontSize:14,backgroundColor:a},rainbow:{type:"button",paddingTop:c,position:{top:62,left:206},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.setOptionCls.setOption("color","rainbow for chains"),e.cam.remove(e.canvasUI.mesh)}},atomColor:{type:"button",paddingTop:c,position:{top:118,left:206},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.setOptionCls.setOption("color","atom"),e.cam.remove(e.canvasUI.mesh)}},chainColor:{type:"button",paddingTop:c,position:{top:174,left:206},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.setOptionCls.setOption("color","chain"),e.cam.remove(e.canvasUI.mesh)}},secondaryColor:{type:"button",paddingTop:12,position:{top:230,left:206},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.setOptionCls.setOption("color","secondary structure green"),e.cam.remove(e.canvasUI.mesh)}},charge:{type:"button",paddingTop:c,position:{top:342,left:206},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.setOptionCls.setOption("color","charge"),e.cam.remove(e.canvasUI.mesh)}},AlphaFold:{type:"button",paddingTop:c,position:{top:286,left:206},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){e.setOptionCls.setOption("color","confidence"),e.cam.remove(e.canvasUI.mesh)}},unicolor:{type:"button",paddingTop:c,position:{top:6,left:306},width:s,height:i,fontColor:"#000",fontSize:14,backgroundColor:a},red:{type:"button",position:{top:i,left:300},width:n,height:l,fontColor:"red",hover:d,onSelect:function(){e.setOptionCls.setOption("color","red"),e.cam.remove(e.canvasUI.mesh)}},green:{type:"button",position:{top:78,left:300},width:n,height:l,fontColor:"green",hover:d,onSelect:function(){e.setOptionCls.setOption("color","green"),e.cam.remove(e.canvasUI.mesh)}},blue:{type:"button",position:{top:106,left:300},width:n,height:l,fontColor:"blue",hover:d,onSelect:function(){e.setOptionCls.setOption("color","blue"),e.cam.remove(e.canvasUI.mesh)}},blueviolet:{type:"button",position:{top:134,left:300},width:n,height:l,fontColor:"#8A2BE2",hover:d,onSelect:function(){e.setOptionCls.setOption("color","8A2BE2"),e.cam.remove(e.canvasUI.mesh)}},magenta:{type:"button",position:{top:162,left:300},width:n,height:l,fontColor:"magenta",hover:d,onSelect:function(){e.setOptionCls.setOption("color","magenta"),e.cam.remove(e.canvasUI.mesh)}},yellow:{type:"button",position:{top:190,left:300},width:n,height:l,fontColor:"yellow",hover:d,onSelect:function(){e.setOptionCls.setOption("color","yellow"),e.cam.remove(e.canvasUI.mesh)}},orange:{type:"button",position:{top:218,left:300},width:n,height:l,fontColor:"orange",hover:d,onSelect:function(){e.setOptionCls.setOption("color","FFA500"),e.cam.remove(e.canvasUI.mesh)}},cyan:{type:"button",position:{top:246,left:300},width:n,height:l,fontColor:"cyan",hover:d,onSelect:function(){e.setOptionCls.setOption("color","cyan"),e.cam.remove(e.canvasUI.mesh)}},gray:{type:"button",position:{top:274,left:300},width:n,height:l,fontColor:"gray",hover:d,onSelect:function(){e.setOptionCls.setOption("color","888888"),e.cam.remove(e.canvasUI.mesh)}},white:{type:"button",position:{top:302,left:300},width:n,height:l,fontColor:"white",hover:d,onSelect:function(){e.setOptionCls.setOption("color","white"),e.cam.remove(e.canvasUI.mesh)}},analysis:{type:"button",paddingTop:c,position:{top:6,left:406},width:s,height:i,fontColor:"#000",fontSize:14,backgroundColor:a},distance:{type:"button",paddingTop:c,position:{top:62,left:406},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){try{e.bMeasureDistance=!0;let s=e.pickingCls.getPickedAtomList(e.pk,e.pAtom),i=e.pickingCls.getPickedAtomList(e.pk,e.pAtom2),n=e.applyCenterCls.centerAtoms(t.hashUtilsCls.hash2Atoms(s,e.atoms)).center,l=e.applyCenterCls.centerAtoms(t.hashUtilsCls.hash2Atoms(i,e.atoms)).center,r=0,o=0,a="#FFFF00",d=(n.x+l.x)/2,c=(n.y+l.y)/2,h=(n.z+l.z)/2,p=!0;e.analysisCls.addLine(n.x,n.y,n.z,l.x,l.y,l.z,a,p,"distance");let m=(parseInt(10*n.distanceTo(l))/10).toString()+" A";e.analysisCls.addLabel(m,d,c,h,r,a,o,"distance"),e.drawCls.draw(),e.cam.remove(e.canvasUI.mesh)}catch(e){}}},interaction:{type:"button",paddingTop:c,position:{top:118,left:406},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){try{e.viewInterPairsCls.viewInteractionPairs(["selected"],["non-selected"],!1,"3d",1,1,1,1,1,1),e.cam.remove(e.canvasUI.mesh)}catch(e){}}},delphi:{type:"button",paddingTop:c,position:{top:174,left:406},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:async function(){e.phisurftype=22,e.phisurfop=1,e.phisurfwf="no",await e.delphiCls.CalcPhi(65,.15,2,!0),e.cam.remove(e.canvasUI.mesh)}},removeLabel:{type:"button",paddingTop:c,position:{top:230,left:406},width:s,height:i,fontColor:o,fontSize:r,backgroundColor:a,hover:d,onSelect:function(){for(let t in e.labels)e.labels[t]=[];e.drawCls.draw(),e.cam.remove(e.canvasUI.mesh)}},renderer:e.renderer},p=new Oe({select:"Select",residue:"Residue",secondarySelect:"Secondary Structure",chainSelect:"Chain",atom:"Atom",reset:"Reset",togglehl:"Toggle Highlight",style:"Style",ribbon:"Ribbon",schematic:"Schematic",stick:"Stick",sphere:"Sphere",surface:"Surface",surfaceTrn:"Transparent Surface",color:"Color",rainbow:"Rainbow",atomColor:"Atom",chainColor:"Chain",secondaryColor:"Secondary Structure",AlphaFold:"AlphaFold",charge:"Charge",unicolor:"UniColor",red:"M 100 15 L 15 15 L 15 100 L 100 100 Z",green:"M 100 15 L 15 15 L 15 100 L 100 100 Z",blue:"M 100 15 L 15 15 L 15 100 L 100 100 Z",blueviolet:"M 100 15 L 15 15 L 15 100 L 100 100 Z",magenta:"M 100 15 L 15 15 L 15 100 L 100 100 Z",yellow:"M 100 15 L 15 15 L 15 100 L 100 100 Z",orange:"M 100 15 L 15 15 L 15 100 L 100 100 Z",cyan:"M 100 15 L 15 15 L 15 100 L 100 100 Z",gray:"M 100 15 L 15 15 L 15 100 L 100 100 Z",white:"M 100 15 L 15 15 L 15 100 L 100 100 Z",analysis:"Analysis",distance:"Distance",interaction:"Interaction",delphi:"DelPhi Potential",removeLabel:"Remove Label"},h);return p.mesh.position.set(0,0,-3),p}createUILog(){let e=this.icn3d;e.icn3dui;const t={panelSize:{width:2,height:2},height:512,info:{type:"text",overflow:"scroll",position:{top:6,left:6},width:506,height:506,backgroundColor:"#aaa",fontColor:"#000"},renderer:e.renderer},s=new Oe({info:"Debug info"},t);return s.mesh.position.set(0,-1,-2),s}getControllers(){let e=this.icn3d;e.icn3dui;const t=new xe,s=(new THREE.BufferGeometry).setFromPoints([new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,-1)]),i=new THREE.Line(s);i.name="line",i.scale.z=50;const n=[];for(let s=0;s<=1;s++){const l=e.renderer.xr.getController(s);if(!l)continue;e.dolly.add(l),l.add(i.clone()),l.userData.selectPressed=!1,e.cam.add(l),n.push(l);const r=e.renderer.xr.getControllerGrip(s);r.add(t.createControllerModel(r)),e.scene.add(r)}return n}}class Te{constructor(e){this.icn3d=e}setCamera(){let e=this.icn3d,t=e.icn3dui;if(e.bControlGl&&!t.bNode){window.cam=e.cams[e.opts.camera.toLowerCase()];let s=e.maxD;if(window.cam===e.perspectiveCamera){let i=void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>e.maxatomcnt;i?window.camMaxDFactor=1:void 0!==window.camMaxDFactorFog?window.camMaxDFactor=window.camMaxDFactorFog:window.camMaxDFactor=3,window.cam_z>0?window.cam.position.z=s*window.camMaxDFactor:window.cam.position.z=-s*window.camMaxDFactor,"yes"===e.opts.slab?i?window.cam.near=.1:void 0!==window.camMaxDFactorFog?window.cam.near=s*window.camMaxDFactorFog-10:window.cam.near=s*window.camMaxDFactor:window.cam.near=.1,window.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.TrackballControls(window.cam,void 0,e):t.bNode?e.controls=new THREE.TrackballControls(e.cam,document,e):e.controls=new THREE.TrackballControls(e.cam,document.getElementById(e.id),e)}else window.cam===e.orthographicCamera&&(void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>10*e.maxatomcnt?window.cam.right=e.maxD/2*1.5:window.cam.right=e.maxD/2*2.5,window.cam.left=-window.cam.right,window.cam.top=window.cam.right/e.container.whratio,window.cam.bottom=-window.cam.right/e.container.whratio,"yes"===e.opts.slab?window.cam.near=2*e.maxD:window.cam.near=0,window.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.OrthographicTrackballControls(window.cam,void 0,e):t.bNode?e.controls=new THREE.OrthographicTrackballControls(e.cam,document,e):e.controls=new THREE.OrthographicTrackballControls(e.cam,document.getElementById(e.id),e));window.cam.updateProjectionMatrix()}e.cam=e.cams[e.opts.camera.toLowerCase()];let s=e.maxD;if(e.cam===e.perspectiveCamera){let i=void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>e.maxatomcnt;i?e.camMaxDFactor=1:void 0!==e.camMaxDFactorFog?e.camMaxDFactor=e.camMaxDFactorFog:e.camMaxDFactor=3,e.cam_z>0?e.cam.position.z=s*e.camMaxDFactor:e.cam.position.z=-s*e.camMaxDFactor,"yes"===e.opts.slab?i?e.cam.near=.1:void 0!==e.camMaxDFactorFog?e.cam.near=s*e.camMaxDFactorFog-10:e.cam.near=s*e.camMaxDFactor:e.cam.near=.1,e.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.TrackballControls(e.cam,void 0,e):t.bNode?e.controls=new THREE.TrackballControls(e.cam,document,e):e.controls=new THREE.TrackballControls(e.cam,document.getElementById(e.id),e)}else e.cam===e.orthographicCamera&&(void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>10*e.maxatomcnt?e.cam.right=e.maxD/2*1.5:e.cam.right=e.maxD/2*2.5,e.cam.left=-e.cam.right,e.cam.top=e.cam.right/e.container.whratio,e.cam.bottom=-e.cam.right/e.container.whratio,"yes"===e.opts.slab?e.cam.near=2*e.maxD:e.cam.near=0,e.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.OrthographicTrackballControls(e.cam,void 0,e):t.bNode?e.controls=new THREE.OrthographicTrackballControls(e.cam,document,e):e.controls=new THREE.OrthographicTrackballControls(e.cam,document.getElementById(e.id),e));e.cam.updateProjectionMatrix()}}class Ee{constructor(e){this.icn3d=e}setFog(e){let t=this.icn3d,s=t.icn3dui.parasCls.backgroundColors[t.opts.background.toLowerCase()];if(e){let e=t.applyCenterCls.centerAtoms(t.hAtoms);t.maxD=e.maxD,t.maxD<25&&(t.maxD=25)}let i=void 0!==t.biomtMatrices&&t.biomtMatrices.length*t.cnt>t.maxatomcnt;if("yes"===t.opts.fog)if("perspective"===t.opts.camera)if(i)t.scene.fog=void 0,t.bSetFog=!1;else{let e=t._zoomFactor>1?1*t._zoomFactor:t._zoomFactor;t.scene.fog=new THREE.Fog(s,2.5*t.maxD*e,4*t.maxD*e),t.bSetFog=!0,t.camMaxDFactorFog=3}else"orthographic"===t.opts.camera&&(t.scene.fog=void 0,t.bSetFog=!1);else t.scene.fog=void 0,t.bSetFog=!1}}class Pe{constructor(e){this.icn3d=e}createBox(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(o.bNode)return;void 0===t&&(t=.8),void 0===s&&(s=!1),void 0===i&&(i=.8),l?void 0===n&&(n=r.hColor):void 0===n&&(n=e.color);let a=s?t:(o.parasCls.vdwRadii[e.elem.toUpperCase()]||t)*(i||1);this.createBox_base(e.coord,a,n,l)}createBox_base(e,t,s,i,n,l,r){let o,a=this.icn3d;a.icn3dui.bNode||(void 0===r&&(r=l?.5:1),new THREE.BoxGeometry(1,1,1),o=new THREE.Mesh(a.boxGeometry,new THREE.MeshPhongMaterial({transparent:!0,opacity:r,specular:a.frac,shininess:a.shininess,emissive:a.emissive,color:s})),o.scale.x=o.scale.y=o.scale.z=t,o.position.copy(e),a.mdl.add(o),i?a.prevHighlightObjects.push(o):n?a.prevOtherMesh.push(o):a.objects.push(o))}createBoxRepresentation_P_CA(e,t,s){let i=this.icn3d;if(i.icn3dui.bNode)return;let n=this;i.reprSubCls.createRepresentationSub(e,(function(e){"CA"!==e.name&&"O3'"!==e.name&&"O3*"!==e.name||n.createBox(e,void 0,void 0,t,void 0,s)}))}}class Me{constructor(e){this.icn3d=e}createBrick(e,t,s,i){let n=this.icn3d;if(n.icn3dui.bNode)return;let l=new THREE.CylinderGeometry(1,1,1,4,1),r=new THREE.Mesh(l,new THREE.MeshPhongMaterial({specular:n.frac,shininess:n.shininess,emissive:n.emissive,color:i}));r.position.copy(e).add(t).multiplyScalar(.5),r.matrixAutoUpdate=!1,r.lookAt(t.clone().sub(e)),r.updateMatrix(),r.matrix.multiply((new THREE.Matrix4).makeScale(s,s,e.distanceTo(t))).multiply((new THREE.Matrix4).makeRotationX(.5*Math.PI)),n.mdl.add(r)}}class De{constructor(e){this.icn3d=e}createCurveSubArrow(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u){if(this.icn3d.icn3dui.bNode)return;let g=[],f=[];g.push(e),f.push(o),this.prepareStrand(g,f,t,s,i,void 0,n,l,r,a,d,!1,c,h,p,m,u),g=[],f=[]}createStripArrow(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g){if(this.icn3d.icn3dui.bNode)return;let f=[],b=[];f.push(e),f.push(t),b.push(o),b.push(a),this.prepareStrand(f,b,void 0,s,i,n,l,void 0,r,d,c,!0,h,p,m,u,g),f=[],b=[]}prepareStrand(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g,f){let b=this.icn3d,C=b.icn3dui;if(1===d.length)return;let y=i,v=!u,_=[];_.push(i[i.length-2]),_.push(i[i.length-1]),n=n||b.axisDIV;let w,S,A,x,k=2/(a-1),O={};for(let e=0,s=t.length;e1)if(void 0!==d){let i,n,l=[];for(let r=0,o=p.length;r0&&i.tubeCls.createTube(a,"CA",i.coilWidth,s),Object.keys(d).length>0&&i.strandCls.createStrand(d,void 0,void 0,!0,0,i.helixSheetWidth,!1,2*i.ribbonthickness,s)):(Object.keys(a).length>0&&i.tubeCls.createTube(a,"CA",i.coilWidth),Object.keys(d).length>0&&i.strandCls.createStrand(d,void 0,void 0,!0,0,i.helixSheetWidth,!1,2*i.ribbonthickness))}createCylinderCurve(e,t,s,i,n){let l=this.icn3d;if(l.icn3dui.bNode)return;let r,o,a,d,c,h,p=null;for(a in e)if(d=e[a],!d.het&&(c=d.structure+"_"+d.chain,h=d.structure+"_"+r,-1!=t.indexOf(d.name))){if(null!==p&&r===d.chain&&l.ParserUtilsCls.getResiNCBI(h,o)+1===l.ParserUtilsCls.getResiNCBI(c,d.resi)&&Math.abs(p.coord.x-d.coord.x)<8&&Math.abs(p.coord.y-d.coord.y)<8&&Math.abs(p.coord.z-d.coord.z)<8){let e=p.coord.clone().add(d.coord).multiplyScalar(.5);if(n)1===n&&(this.createCylinder(p.coord,e,s,p.color,n),this.createCylinder(e,d.coord,s,d.color,n),l.sphereCls.createSphere(d,s,!0,1,n));else if(i){let t=l.lineCls.createSingleLine(p.coord,e,p.color,!1);l.mdl.add(t),l.objects.push(t),t=l.lineCls.createSingleLine(e,d.coord,d.color,!1),l.mdl.add(t),l.objects.push(t)}else this.createCylinder(p.coord,e,s,p.color),this.createCylinder(e,d.coord,s,d.color),l.sphereCls.createSphere(d,s,!0,1,n)}p=d,r=d.chain,o=d.resi,l.sphereCls.createSphere(d,s,!0,1,n),2===n&&l.boxCls.createBox(d,void 0,void 0,void 0,void 0,n)}if(null!==p&&r===d.chain&&l.ParserUtilsCls.getResiNCBI(h,o)+1===l.ParserUtilsCls.getResiNCBI(c,d.resi)&&Math.abs(p.coord.x-d.coord.x)<8&&Math.abs(p.coord.y-d.coord.y)<8&&Math.abs(p.coord.z-d.coord.z)<8){let e=p.coord.add(d.coord).multiplyScalar(.5);if(n)1===n&&(this.createCylinder(p.coord,e,s,p.color,n),this.createCylinder(e,d.coord,s,d.color,n),l.sphereCls.createSphere(d,s,!0,1,n));else if(i){let t=l.lineCls.createSingleLine(p.coord,e,p.color,!1);l.mdl.add(t),l.objects.push(t),t=l.lineCls.createSingleLine(e,d.coord,d.color,!1),l.mdl.add(t),l.objects.push(t)}else this.createCylinder(p.coord,e,s,p.color),this.createCylinder(e,d.coord,s,d.color)}}}class Le{constructor(e){this.icn3d=e}createLineRepresentation(e,t){let s=this.icn3d;if(s.icn3dui.bNode)return;let i=new THREE.BufferGeometry,n=[],l=[],r=0,o=0;s.reprSubCls.createRepresentationSub(e,void 0,(function(e,t){if(e.color===t.color)n[r++]=e.coord.x,n[r++]=e.coord.y,n[r++]=e.coord.z,n[r++]=t.coord.x,n[r++]=t.coord.y,n[r++]=t.coord.z,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b;else{let s=e.coord.clone().add(t.coord).multiplyScalar(.5);n[r++]=e.coord.x,n[r++]=e.coord.y,n[r++]=e.coord.z,n[r++]=s.x,n[r++]=s.y,n[r++]=s.z,n[r++]=t.coord.x,n[r++]=t.coord.y,n[r++]=t.coord.z,n[r++]=s.x,n[r++]=s.y,n[r++]=s.z,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b}}));if(i.setAttribute("position",new THREE.BufferAttribute(new Float32Array(n),3)),i.setAttribute("color",new THREE.BufferAttribute(new Float32Array(l),3)),2!==t){let e;1===t||(e=new THREE.LineSegments(i,new THREE.LineBasicMaterial({linewidth:s.linewidth,vertexColors:!0})),s.mdl.add(e)),1===t?s.prevHighlightObjects.push(e):s.objects.push(e)}else 2===t&&s.boxCls.createBoxRepresentation_P_CA(e,.8,t)}createConnCalphSidechain(e,t){let s=this.icn3d;if(s.icn3dui.bNode)return;let i={};for(let s in e){let n=e[s];if(!n.het&&n.style2===t){i[n.structure+"_"+n.chain+"_"+n.resi]=1}}let n=[],l=[];for(let e in i){let t=s.firstAtomObjCls.getFirstAtomObjByName(s.residues[e],"CA");if(void 0!==t)for(let e=0,i=t.bonds.length;e=t.bonds.length&&e.bonds.length>1)s=e.serial,l=e.bonds[0],d=e.bonds[1];else{if(!(t.bonds.length>=e.bonds.length&&t.bonds.length>1))return void console.log("Double bond was not drawn due to the undefined cross plane");s=t.serial,l=t.bonds[0],d=t.bonds[1]}let i=r.atoms[s].coord.clone();i.sub(r.atoms[l].coord);let n=r.atoms[s].coord.clone();n.sub(r.atoms[d].coord),i.cross(n),0==parseInt(1e4*i.length())&&(i=new THREE.Vector3(.2,.3,.5)),c=t.coord.clone(),c.sub(e.coord),c.cross(i).normalize().multiplyScalar(.2*o),0==parseInt(1e4*c.length())&&(i=new THREE.Vector3(.5,.3,.2),c.cross(i).normalize().multiplyScalar(.2*o))}e.color===t.color?r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),t.coord.clone().add(c),a,e.color,n),r.cylinderCls.createCylinder(e.coord.clone().sub(c),t.coord.clone().sub(c),a,e.color,n)):r.bImpo?r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),t.coord.clone().add(c),a,e.color,n,t.color),r.cylinderCls.createCylinder(e.coord.clone().sub(c),t.coord.clone().sub(c),a,e.color,n,t.color)):r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),i.clone().add(c),a,e.color,n),r.cylinderCls.createCylinder(t.coord.clone().add(c),i.clone().add(c),a,t.color,n),r.cylinderCls.createCylinder(e.coord.clone().sub(c),i.clone().sub(c),a,e.color,n),r.cylinderCls.createCylinder(t.coord.clone().sub(c),i.clone().sub(c),a,t.color,n))}else if(r.aromaticbonds.hasOwnProperty(l)){let s,l,d;if(e.bonds.length>t.bonds.length&&e.bonds.length>1)s=e.serial,l=e.bonds[0],d=e.bonds[1];else{if(!(t.bonds.length>1))return;s=t.serial,l=t.bonds[0],d=t.bonds[1]}let c=r.atoms[s].coord.clone();c.sub(r.atoms[l].coord);let h=r.atoms[s].coord.clone();h.sub(r.atoms[d].coord),c.cross(h);let p=t.coord.clone();p.sub(e.coord),p.cross(c).normalize().multiplyScalar(.2*o);let m=0;for(let s=0,i=e.bondOrder.length;so+1?(s=k.clone(),i=d.atoms[G[G.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random()))):d.bCalphaOnly&&"CA"===b.name&&(G.length>o+1?(s=k.clone(),i=d.atoms[G[G.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(f),null!==I&&s.dot(I)<0&&s.negate(),I=s;for(let e=0,s=2/(t-1);e6||c&&Math.abs(S.y-c.y)>6||c&&Math.abs(S.z-c.z)>6;if((u!==b.chain||b.ssbegin||b.ssend||B===j-1||p)&&m[0].length>0){let c="CA",u=[],g=[];if(isNaN(d.atoms[M].resi))u=[];else{let e=d.atoms[M].structure+"_"+d.atoms[M].chain+"_"+(parseInt(d.atoms[M].resi)-1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);u=void 0!==t?[t]:[]}if(!isNaN(d.atoms[M].resi)){let e=d.atoms[M].structure+"_"+d.atoms[M].chain+"_"+(parseInt(d.atoms[M].resi)+1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);void 0!==t&&g.push(t);let s=d.atoms[M].structure+"_"+d.atoms[M].chain+"_"+(parseInt(d.atoms[M].resi)+2).toString(),i=d.firstAtomObjCls.getAtomCoordFromResi(s,c);void 0!==i&&g.push(i)}if(!p){1===a||2===a?w.push(d.hColor):w.push(R),f=b.ssend&&"sheet"===b.ss?0:"coil"===T&&b.ssbegin||E&&b.ssbegin||"coil"===b.ss?n:l;let s,i,o=4;"O"===b.name?(s=A.clone(),s.sub(S)):d.bCalphaOnly&&"CA"===b.name&&(G.length>o?(s=S.clone(),i=d.atoms[G[G.length-1-o]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(f),null!==I&&s.dot(I)<0&&s.negate(),I=s;for(let e=0,s=2/(t-1);e0){let e="CA",n=[],l=[];if(isNaN(d.atoms[M].resi))n=[];else{let t=d.atoms[M].structure+"_"+d.atoms[M].chain+"_"+(parseInt(d.atoms[M].resi)-1).toString();d.firstAtomObjCls.getAtomCoordFromResi(t,e)}for(let e=0;!i&&e0;--e){let t=a.structure+"_"+a.chain+"_"+e;if(!c.residues.hasOwnProperty(t))break;let s=c.firstAtomObjCls.getFirstCalphaAtomObj(c.residues[t]);if(s.ss===a.ss&&s.ssbegin){g=s.resi;break}}for(let e=g;e0&&(o!==c.chain||Math.abs(c.coord.x-h.coord.x)>6||Math.abs(c.coord.y-h.coord.y)>6||Math.abs(c.coord.z-h.coord.z)>6||r.ParserUtilsCls.getResiNCBI(c.structure+"_"+o,a)+13||Math.abs(c.coord.y-h.coord.y)>3||Math.abs(c.coord.z-h.coord.z)>3))){if(2!==i){if(!isNaN(d.resi)&&!isNaN(h.resi)){let e=d.structure+"_"+d.chain+"_"+(parseInt(d.resi)-1).toString(),i=r.firstAtomObjCls.getAtomCoordFromResi(e,t);g=void 0!==i?[i]:[];let l=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+1).toString(),o=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+2).toString(),a=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+3).toString();if(r.residues.hasOwnProperty(l)){let e=r.firstAtomObjCls.getAtomFromResi(l,t);void 0!==e&&e.ssbegin&&(l=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+2).toString(),o=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+3).toString(),p.push(e.coord),n?u.push(this.getCustomtubesize(l)):u.push(this.getRadius(s,e)),m.push(e.color))}if(1==p.length&&r.residues.hasOwnProperty(l)){let e=r.firstAtomObjCls.getAtomFromResi(l,t);if(e){p.push(e.coord),m.push(e.color);let t=this.getRadius(s,c);u.push(t),l=o,o=a}}let b=r.firstAtomObjCls.getAtomCoordFromResi(l,t);void 0!==b&&f.push(b);let C=r.firstAtomObjCls.getAtomCoordFromResi(o,t);void 0!==C&&f.push(C)}C.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}p=[],m=[],u=[],g=[],f=[],d=c,b=0}if(0==p.length&&!isNaN(c.resi)){let e=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)-1).toString();r.residues.hasOwnProperty(e)&&(h=r.firstAtomObjCls.getAtomFromResi(e,t),void 0!==h&&h.ssend&&(p.push(h.coord),n?u.push(this.getCustomtubesize(e)):u.push(this.getRadius(s,h)),m.push(h.color)))}let e;p.push(c.coord),e=n?this.getCustomtubesize(c.structure+"_"+c.chain+"_"+c.resi):this.getRadius(s,c),u.push(e),m.push(c.color),1===b&&(m[m.length-2]=c.color),o=c.chain,a=c.resi;let l=1.2;2!==i||c.ssbegin||r.boxCls.createBox(c,void 0,void 0,l,void 0,i),++b,h=c}if(2!==i){if(g=[],void 0!==d&&!isNaN(d.resi)){let e=d.structure+"_"+d.chain+"_"+(parseInt(d.resi)-1).toString(),s=r.firstAtomObjCls.getAtomCoordFromResi(e,t);g=void 0!==s?[s]:[]}if(f=[],void 0!==c&&!isNaN(c.resi)){let e=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+1).toString(),i=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+2).toString(),n=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+3).toString();if(1==p.length&&r.residues.hasOwnProperty(e)){let l=r.firstAtomObjCls.getAtomFromResi(e,t);if(l){p.push(l.coord),m.push(l.color);let t=this.getRadius(s,c);u.push(t),e=i,i=n}}let l=r.firstAtomObjCls.getAtomCoordFromResi(e,t);void 0!==l&&f.push(l);let o=r.firstAtomObjCls.getAtomCoordFromResi(i,t);void 0!==o&&f.push(o)}C.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}for(let e=0,t=C.length;e1?a.parasCls.thr(t[t.length-2]):a.parasCls.thr(t[e]),f[y++]=d.r,f[y++]=d.g,f[y++]=d.b}}let x,k=0;for(let e=0,t=w.length-1;er&&(l=r,e=1);for(let t=0;t0&&t.b<=100?.01*t.b:t.b>100?1:s.coilWidth),i}}class ze{constructor(e){this.icn3d=e}drawCartoonNucleicAcid(e,t,s,i){this.drawStrandNucleicAcid(e,2,t,!0,void 0,s,i)}drawStrandNucleicAcid(e,t,s,i,n,l,r){let o,a,d,c=this.icn3d;if(c.icn3dui.bNode)return;2===r&&(t=void 0,l=void 0),n=n||c.nucleicAcidWidth,s=s||c.axisDIV,t=t||c.nucleicAcidStrandDIV;let h=[];for(d=0;dy?y=C:C=y);let v=.8*b/y;if(g.width=C,g.height=y,f.clearRect(0,0,C,y),h)if(f.fillStyle="rgba("+n.r+","+n.g+","+n.b+","+n.a+")",f.strokeStyle="rgba("+l.r+","+l.g+","+l.b+","+l.a+")",f.lineWidth=r,p){let e=.4*C;this.circle(f,0,0,C,y,e)}else{let e=0;this.roundRect(f,0,0,C,y,e)}f.font="Bold "+a+"px "+o,f.textAlign="center",f.textBaseline="middle",f.fillStyle="rgba("+u.r+", "+u.g+", "+u.b+", 1.0)",f.strokeStyle="rgba("+u.r+", "+u.g+", "+u.b+", 1.0)",f.fillText(e,.5*C,.5*y);let _=new THREE.Texture(g);_.needsUpdate=!0;let w=new THREE.SpriteMaterial({map:_,depthTest:!1,depthWrite:!1});w.map.minFilter=THREE.LinearFilter;let S=new THREE.Sprite(w);return p?S.scale.set(.3*d,.3*d,1):S.scale.set(v*d,d,1),S.renderOrder=1,S}roundRect(e,t,s,i,n,l){e.beginPath(),e.moveTo(t+l,s),e.lineTo(t+i-l,s),e.quadraticCurveTo(t+i,s,t+i,s+l),e.lineTo(t+i,s+n-l),e.quadraticCurveTo(t+i,s+n,t+i-l,s+n),e.lineTo(t+l,s+n),e.quadraticCurveTo(t,s+n,t,s+n-l),e.lineTo(t,s+l),e.quadraticCurveTo(t,s,t+l,s),e.closePath(),e.fill(),e.stroke()}circle(e,t,s,i,n,l){e.beginPath(),e.arc(t+i/2,.9*(s+n/2),l,0,2*Math.PI,!0),e.closePath(),e.fill(),e.stroke()}}class Ve{constructor(e){this.icn3d=e,this.textSpriteCls=new Ge(e)}createLabelRepresentation(e){let t=this.icn3d;t.icn3dui;let s=t.oriMaxD/100;s<.4&&(s=.4);let i=3*s*t.labelScale;for(let s in e){let n=void 0!==e[s]?e[s]:[],l="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd;for(let e=0,r=n.length;e.99999)h.set(0,0,0,1);else if(e.y<-.99999)h.set(1,0,0,0);else{let t=new THREE.Vector3;t.set(e.z,0,-e.x).normalize();let s=Math.acos(e.y);h.setFromAxisAngle(t,s)}return c.applyQuaternion(h),c.scale.set(l,n,l),c.position.copy(t),c}setPc1Axes(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s=t.hashUtilsCls.intHash(e.hAtoms,e.dAtoms),i=[],n=Object.keys(s).length<100;for(let t in s){let s=e.atoms[t],l=s.structure+"_"+s.chain+"_"+s.resi;(n||""!=l)&&i.push(s.coord.clone())}let l=t.rmsdSuprCls.getEigenForSelection(i,i.length),r=new THREE.Vector3(l.h1[0],l.h1[1],l.h1[2]);if(0==l.k&&e.bRender)return void alert("Can't determine the first principal component. Please select a subset and try it again.");let o=e.applyCenterCls.centerAtoms(s),a=o.maxD,d=o.center,c=d.clone().add(r.normalize().multiplyScalar(.4*a)),h=new THREE.Vector3(l.h2[0],l.h2[1],l.h2[2]),p=d.clone().add(h.normalize().multiplyScalar(.3*a)),m=new THREE.Vector3(l.h3[0],l.h3[1],l.h3[2]),u=d.clone().add(m.normalize().multiplyScalar(.3*a));this.buildAxes(void 0,d,c,p,u,!0);let g=[d,c,p,u];return e.axes.push(g),e.drawCls.draw(),g}}class Ye{constructor(e){this.icn3d=e}showGlycans(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s={},i=e.dAtoms;for(let n in i){let i=e.atoms[n];i.het&&-1!=t.parasCls.glycanHash.hasOwnProperty(i.resn)&&(void 0===s[i.resn]&&(s[i.resn]={}),"Misc"!=i.chain&&(s[i.resn][i.structure+"_"+i.chain+"_"+i.resi]=1))}let n=Object.keys(s);for(let i=0,l=n.length;i>2))+i+((2&t)>>1))*c+n+(1&t)]&this.ISDONE)<=3&&(t.push(t[i]),i=t.length-1,t.push(t[n]),n=t.length-1,t.push(t[l]),l=t.length-1),s.push(i),s.push(n),s.push(l)}}},Xe.prototype.laplacianSmooth=function(e,t,s){let i,n,l,r,o,a=new Array(t.length);for(i=0,n=t.length;ithis.origextent[1][0])&&(!(tthis.origextent[1][1])&&!(sthis.origextent[1][2]))},Ke.prototype.getFacesAndVertices=function(){let e,t,s=this.verts;for(e=0,t=s.length;eh&&(h=this.pmaxy-this.pminy),this.pmaxz-this.pminz>h&&(h=this.pmaxz-this.pminz),this.scaleFactor=(c-1)/h,this.scaleFactor=this.defaultScaleFactor,this.defaultScaleFactor*h>this.threshbox&&(c=Math.floor(this.threshbox),this.scaleFactor=(this.threshbox-1)/h),this.bCalcArea&&(this.scaleFactor=this.defaultScaleFactor),this.pLength=Math.ceil(this.scaleFactor*(this.pmaxx-this.pminx))+1,this.pWidth=Math.ceil(this.scaleFactor*(this.pmaxy-this.pminy))+1,this.pHeight=Math.ceil(this.scaleFactor*(this.pmaxz-this.pminz))+1,this.boundingatom(t),this.cutRadius=this.probeRadius*this.scaleFactor,this.vpBits=new Uint8Array(this.pLength*this.pWidth*this.pHeight),this.vpDistance=new Float64Array(this.pLength*this.pWidth*this.pHeight),this.vpAtomID=new Int32Array(this.pLength*this.pWidth*this.pHeight),this.vpColor=[],this.vpPot=[]},Ke.prototype.boundingatom=function(e){let t,s,i,n,l=[];for(let r in this.vdwRadii){if(!this.vdwRadii.hasOwnProperty(r))continue;let o=this.vdwRadii[r];l[r]=e?(o+this.probeRadius)*this.scaleFactor+.5:o*this.scaleFactor+.5,i=l[r]*l[r],this.widxz[r]=Math.floor(l[r])+1,this.depty[r]=new Int32Array(this.widxz[r]*this.widxz[r]),n=0;for(let e=0;ei?this.depty[r][n]=-1:(s=Math.sqrt(i-t),this.depty[r][n]=Math.floor(s)),n++}},Ke.prototype.fillvoxels=function(e,t){let s,i,n,l;for(s=0,l=this.vpBits.length;sc&&(a=c),C>h&&(C=h),v>p&&(v=p);let _,w=g[o*m+d*u+y],S=g[a*m+d*u+y],A=g[o*m+C*u+y],x=g[o*m+d*u+v],k=g[a*m+C*u+y],O=g[o*m+C*u+v],R=g[a*m+d*u+v],I=g[a*m+C*u+v],T=r.x-o,E=r.y-d,P=r.z-y,M=((w*(1-T)+S*T)*(1-E)+(A*(1-T)+k*T)*E)*(1-P)+((x*(1-T)+R*T)*(1-E)+(O*(1-T)+I*T)*E)*P,D=s*f+i*b+n;this.vpPot[D]=M,M>this.isovalue&&(M=this.isovalue),M<-this.isovalue&&(M=-this.isovalue),M>0?(M/=1*this.isovalue,_=new THREE.Color(1-M,1-M,1)):(M/=-1*this.isovalue,_=new THREE.Color(1,1-M,1-M)),this.vpColor[D]=_}}for(s=0,l=this.vpBits.length;s=this.pLength||g>=this.pWidth||f>=this.pHeight)continue;let h=u*S+g*this.pHeight+f;if(this.vpBits[h]&this.INOUT){let p=t[this.vpAtomID[h]];p.serial!=e.serial&&(l=s+a-Math.floor(.5+this.scaleFactor*(p.x+this.ptranx)),r=i+d-Math.floor(.5+this.scaleFactor*(p.y+this.ptrany)),o=n+c-Math.floor(.5+this.scaleFactor*(p.z+this.ptranz)),a*a+d*d+c*c=this.pLength||p>=this.pWidth||m>=this.pHeight)continue;let u=h*S+p*this.pHeight+m;if(this.vpBits[u]&this.ISDONE){let h=t[this.vpAtomID[u]];h.serial!=e.serial&&(l=s+a-Math.floor(.5+this.scaleFactor*(h.x+this.ptranx)),r=i+d-Math.floor(.5+this.scaleFactor*(h.y+this.ptrany)),o=n+c-Math.floor(.5+this.scaleFactor*(h.z+this.ptranz)),a*a+d*d+c*c-1&&r-1&&a-1&&o=h)||(this.vpBits[n]|=this.ISBOUND))},Ke.prototype.fastoneshell=function(e,t){let s,i,n,l,r,o,a,d,c,h,p,m,u=[];if(0===e.length)return u;let g={ix:-1,iy:-1,iz:-1},f=this.pWidth*this.pHeight;for(a=0,c=e.length;a-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,h-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,h-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,hm&&(m=this.pmaxy-this.pminy),this.pmaxz-this.pminz>m&&(m=this.pmaxz-this.pminz),this.scaleFactor=1,this.pLength=Math.floor(.5+this.scaleFactor*(this.pmaxx-this.pminx))+1,this.pWidth=Math.floor(.5+this.scaleFactor*(this.pmaxy-this.pminy))+1,this.pHeight=Math.floor(.5+this.scaleFactor*(this.pmaxz-this.pminz))+1,this.cutRadius=this.probeRadius*this.scaleFactor,this.vpBits=new Uint8Array(this.pLength*this.pWidth*this.pHeight),this.header.ccp4&&(this.vpGridTrans=new Array(this.pLength*this.pWidth*this.pHeight)),this.vpAtomID=new Uint8Array(this.pLength*this.pWidth*this.pHeight)},Je.prototype.transformMemPro=function(e,t,s,i){let n=e.clone();n.sub(s);let l=n.x*t[0]+n.y*t[1]+n.z*t[2]+i.x,r=n.x*t[3]+n.y*t[4]+n.z*t[5]+i.y,o=n.x*t[6]+n.y*t[7]+n.z*t[8]+i.z;return n.x=l,n.y=r,n.z=o,n},Je.prototype.fillvoxels=function(e,t){let s,i,n,l,r,o;for(s=0,l=this.vpBits.length;sthis.pLength&&(o=this.pLength),p>this.pWidth&&(p=this.pWidth),b>this.pHeight&&(b=this.pHeight);let C,y=l[r*a+h*d+f],v=l[o*a+h*d+f],_=l[r*a+p*d+f],w=l[r*a+h*d+b],S=l[o*a+p*d+f],A=l[r*a+p*d+b],x=l[o*a+h*d+b],k=l[o*a+p*d+b],O=n.x-r,R=n.y-h,I=n.z-f,T=((y*(1-O)+v*O)*(1-R)+(_*(1-O)+S*O)*R)*(1-I)+((w*(1-O)+x*O)*(1-R)+(A*(1-O)+k*O)*R)*I;T>this.isovalue&&(T=this.isovalue),T<-this.isovalue&&(T=-this.isovalue),T>0?(T/=1*this.isovalue,C=new THREE.Color(1-T,1-T,1)):(T/=-1*this.isovalue,C=new THREE.Color(1,1-T,1-T)),this.icn3d.atoms[t[s]].color=C,this.icn3d.atomPrevColors[t[s]]=C}}else{for(let p in t){let f,b=e[t[p]];if("DUM"!==b.resn){if(void 0!==this.rmsd_supr&&void 0!==this.rmsd_supr.rot){f=this.transformMemPro(b.coord,g,u,m).applyMatrix4(c)}else f=b.coord.clone().applyMatrix4(c);for(s=Math.floor(f.x)-this.maxdist,l=Math.ceil(f.x)+this.maxdist;s<=l;++s)if(!(s<0||s>this.header.xExtent*this.scaleFactor-1))for(i=Math.floor(f.y)-this.maxdist,r=Math.ceil(f.y)+this.maxdist;i<=r;++i)if(!(i<0||i>this.header.yExtent*this.scaleFactor-1))for(n=Math.floor(f.z)-this.maxdist,o=Math.ceil(f.z)+this.maxdist;n<=o;++n){if(n<0||n>this.header.zExtent*this.scaleFactor-1)continue;let e=s*a+i*d+n;h.push(e)}}}for(s=0,l=h.length;s=this.isovalue?1:0:"fofc"==this.type?(this.vpBits[e]=this.dataArray[e]>=this.isovalue||this.dataArray[e]<=-this.isovalue?1:0,this.vpAtomID[e]=this.dataArray[e]>=0?1:0):"em"==this.type&&(this.vpBits[e]=this.dataArray[e]>=this.isovalue?1:0)}}}else for(s=0;s=this.isovalue||this.dataArray[e]<=-this.isovalue?1:0,this.vpAtomID[t]=this.dataArray[e]>=0?1:0)}for(s=0,l=this.vpBits.length;s-1&&r-1&&a-1&&o1?"Structure":"",a=Object.keys(i).length>1?"Chain":"";n+=""+o+a+"ResidueNumberSASA (Å2)Percent OutIn/Out";for(let e in l.resid2area){let d=e.lastIndexOf("_"),c=e.substr(d+1),h=r.utilsCls.getIdArray(e.substr(0,d));o=Object.keys(s).length>1?""+h[0]+"":"",a=Object.keys(i).length>1?""+h[1]+"":"";let p="",m="";l.resid2area[e]=(l.resid2area[e]/t).toFixed(2),r.parasCls.residueArea.hasOwnProperty(c)&&(m=parseInt(l.resid2area[e]/r.parasCls.residueArea[c]*100),m>100&&(m=100),m>=50&&(p="out"),m<20&&(p="in")),n+=''+o+a+""+c+''+h[2]+''+l.resid2area[e]+''+m+"%"+p+""}return n+="",void(l.areahtml=n)}let p,m,u,g=c.vertices,f=c.faces,b=r.parasCls.thr("#00FFFF"),C=r.parasCls.thr("#00FF00"),y=r.parasCls.thr("#ff0000"),v=r.parasCls.thr("#00FFFF"),_=r.parasCls.thr("#0000FF"),w=r.parasCls.thr("#FF0000");11!=t&&12!=t&&13!=t&&14!=t||void 0===l.rmsd_supr||void 0===l.rmsd_supr.rot||(p=l.rmsd_supr.rot,m=l.rmsd_supr.trans1,u=l.rmsd_supr.trans2);let S=(11==t||12==t||13==t||14==t&&"delphi"!=l.loadPhiFrom)&&void 0!==l.rmsd_supr&&void 0!==l.rmsd_supr.rot;n=new THREE.BufferGeometry;let A,x=[],k=[],O=[],R=0;for(let e=0,s=g.length;e0?-parseInt(C.z):parseInt(C.z),y.onBeforeRender=function(e,t,s,i,n,o){let a,d=new THREE.Vector3(0,0,0),c=i.getAttribute("position").array;for(let e=0,t=c.length;e0?-parseInt(a.z):parseInt(a.z)},l.mdl.add(y),11==t||12==t?l.prevMaps.push(y):13==t?l.prevEmmaps.push(y):14==t?l.prevPhimaps.push(y):l.prevSurfaces.push(y)}}else{let e=new THREE.Mesh(n,new THREE.MeshPhongMaterial({specular:l.frac,shininess:20,emissive:l.emissive,vertexColors:!0,wireframe:s,opacity:i,transparent:!0,depthWrite:10==parseInt(10*i),side:THREE.DoubleSide}));e.renderOrder=-2,l.mdl.add(e),11==t||12==t?l.prevMaps.push(e):13==t?l.prevEmmaps.push(e):14==t?l.prevPhimaps.push(e):l.prevSurfaces.push(e)}c=null,g=null,f=null,n=null}transformMemPro(e,t,s,i,n){this.icn3d.icn3dui;let l=e.clone();l.sub(s),n&&console.log("sub coord: "+JSON.stringify(l));let r=l.x*t[0]+l.y*t[1]+l.z*t[2]+i.x,o=l.x*t[3]+l.y*t[4]+l.z*t[5]+i.y,a=l.x*t[6]+l.y*t[7]+l.z*t[8]+i.z;return l.x=r,l.y=o,l.z=a,n&&console.log("out coord: "+JSON.stringify(l)),l}SetupSurface(e){let t=this.icn3d;t.icn3dui;let s=e.threshbox,i=new Ke(t,s);i.initparm(e.extent,1!==e.type,e.bCalcArea,e.atomsToShow,e.header,e.data,e.matrix,e.isovalue,e.loadPhiFrom),i.fillvoxels(e.allatoms,e.extendedAtoms),i.buildboundary(),2===e.type&&(i.fastdistancemap(),i.boundingatom(!1),i.fillvoxelswaals(e.allatoms,e.extendedAtoms));let n=i.marchingcube();i.vpBits=null,i.vpDistance=null,i.vpAtomID=null;let l=i.getFacesAndVertices(e.atomsToShow);return l.area=n.area,l.serial2area=n.serial2area,l.scaleFactor=n.scaleFactor,i.faces=null,i.verts=null,l}SetupMap(e){let t=this.icn3d;if(t.icn3dui,!e.ccp4){let s,i=new Je(t);return i.initparm(e.header,e.data,e.matrix,e.isovalue,e.center,e.maxdist,e.pmin,e.pmax,e.water,e.type,e.rmsd_supr,e.loadPhiFrom,e.icn3d),i.fillvoxels(e.allatoms,e.extendedAtoms),e.header.bSurface||i.buildboundary(),e.header.bSurface||i.marchingcube(),i.vpBits=null,i.vpAtomID=null,e.header.bSurface||(s=i.getFacesAndVertices(e.allatoms,e.atomsToShow)),i.faces=null,i.verts=null,s}{let s,i=10,n=t.center?[t.center.x,t.center.y,t.center.z]:[0,0,0];if("2fofc"==e.type){s="2fofc";let l=t.ccp4ParserCls.extract_block(e.grid,e.unit_cell,i,n,s),r=t.ccp4ParserCls.marchingCubes(l.size,l.values,l.points,e.isovalue,"marching cubes");t.ccp4ParserCls.makeChickenWire(r,s),l=null,r=null}else if("fofc"==e.type){s="fofc_neg";let l=t.ccp4ParserCls.extract_block(e.grid,e.unit_cell,i,n,s),r=t.ccp4ParserCls.marchingCubes(l.size,l.values,l.points,e.isovalue,"marching cubes");t.ccp4ParserCls.makeChickenWire(r,s),s="fofc_pos",l=t.ccp4ParserCls.extract_block(e.grid,e.unit_cell,i,n,s),r=t.ccp4ParserCls.marchingCubes(l.size,l.values,l.points,e.isovalue,"marching cubes"),t.ccp4ParserCls.makeChickenWire(r,s),l=null,r=null}}}}class Ze{constructor(e){this.icn3d=e}applyCenterOptions(e){let t,s=this.icn3d;switch(s.icn3dui,void 0===e&&(e=s.opts),e.rotationcenter.toLowerCase()){case"molecule center":void 0!==s.center&&this.setRotationCenter(s.center);break;case"pick center":void 0!==s.pAtom&&this.setRotationCenter(s.pAtom.coord);break;case"display center":t=this.centerAtoms(s.dAtoms).center,this.setRotationCenter(t);break;case"highlight center":t=this.centerAtoms(s.hAtoms).center,this.setRotationCenter(t)}}setRotationCenter(e){this.icn3d.icn3dui,this.setCenter(e)}setCenter(e){let t=this.icn3d;t.icn3dui,t.mdl.position.set(0,0,0),t.mdlImpostor.position.set(0,0,0),t.mdl_ghost.position.set(0,0,0),t.mdl.position.sub(e),t.mdlImpostor.position.sub(e),t.mdl_ghost.position.sub(e)}centerSelection(e,t){let s=this.icn3d,i=s.icn3dui;if(s.opts.rotationcenter="highlight center",void 0===e&&(e=i.hashUtilsCls.hash2Atoms(s.hAtoms,s.atoms)),t||(s._zoomFactor=1,s.mouseChange=new THREE.Vector2(0,0),s.quaternion=new THREE.Quaternion(0,0,0,1)),Object.keys(e).length>1){let t=this.centerAtoms(e);s.center=t.center,this.setCenter(s.center),s.cameraCls.setCamera()}}centerAtoms(e){let t=this.icn3d;t.icn3dui;let s=new THREE.Vector3(9999,9999,9999),i=new THREE.Vector3(-9999,-9999,-9999),n=new THREE.Vector3;for(let l in e){let e=t.atoms[l].coord;n.add(e),s.min(e),i.max(e)}let l=t.ParserUtilsCls.getGeoCenter(s,i);return{center:l,maxD:t.ParserUtilsCls.getStructureSize(e,s,i,l),pmin:s,pmax:i}}setWidthHeight(e,t){let s=this.icn3d;s.icn3dui,void 0===s.scaleFactor&&(s.scaleFactor=1),s.renderer.setSize(e*s.scaleFactor,t*s.scaleFactor),s.renderer.domElement.style.width=e*s.scaleFactor+"px",s.renderer.domElement.style.height=t*s.scaleFactor+"px",s.renderer.domElement.width=e*s.scaleFactor,s.renderer.domElement.height=t*s.scaleFactor,s.container.whratio=e/t}}class et{constructor(e){this.icn3d=e}applyClbondsOptions(e){let t=this.icn3d,s=t.icn3dui;if(void 0===e&&(e=t.opts),t.bCalcCrossLink||(t.clbondpnts={},t.clbondResid2serial={},this.applyClbondsOptions_base("chemical"),this.applyClbondsOptions_base("all"),t.bCalcCrossLink=!0),"yes"===e.clbonds.toLowerCase()&&"nothing"!==e.chemicals){let e="#006400";if(s.parasCls.thr(25600),t.lines.clbond=[],t.residuesHashClbonds={},t.structures){let i=Object.keys(t.structures);for(let n=0,l=i.length;n1&&"sphere"!==a[Object.keys(a)[0]].style&&"dot"!==a[Object.keys(a)[0]].style){if(void 0===i.bCid||!i.bCid)for(let e in a){let t=a[e],n=1;i.boxCls.createBox(t,void 0,void 0,n,void 0,s)}}else for(let e in o){let l=i.firstAtomObjCls.getFirstCalphaAtomObj(i.residues[e]),r=l,o=r.structure+"_"+r.chain+"_"+(parseInt(r.resi)-1).toString(),a=r.structure+"_"+r.chain+"_"+(parseInt(r.resi)+1).toString();if("cylinder and plate"===r.style&&"helix"===r.ss)for(let t in i.residues[e]){let e=i.atoms[t],n=1;i.boxCls.createBox(e,void 0,void 0,n,void 0,s)}else if("ribbon"===r.style&&"coil"===r.ss||"strand"===r.style&&"coil"===r.ss||"o3 trace"===r.style||"schematic"===r.style||"c alpha trace"===r.style||"b factor tube"===r.style||"cylinder and plate"===r.style&&"helix"!==r.ss){if(void 0!==l&&void 0!==l.style2&&"nothing"!==l.style2)continue;let e=!1;if(!isNaN(r.resi)&&!e&&i.residues.hasOwnProperty(a)){let s=Object.keys(i.residues[a])[0],l=n.hashUtilsCls.hash2Atoms(i.residues[a],i.atoms)[s];if(r.style===l.style&&!l.ssbegin||l.ssbegin){let s=i.residues[a];if(t=n.hashUtilsCls.unionHash(t,s),e=!0,l.ssbegin)for(let e in s)i.atoms[e].notshow=!0}}if(!isNaN(r.resi)&&!e&&i.residues.hasOwnProperty(o)){let s=Object.keys(i.residues[o])[0],l=n.hashUtilsCls.hash2Atoms(i.residues[o],i.atoms)[s];r.style===l.style&&(t=n.hashUtilsCls.unionHash(t,i.residues[o]),e=!0)}}else if("ribbon"===r.style&&"coil"!==r.ss&&r.ssend||"strand"===r.style&&"coil"!==r.ss&&r.ssend){if(void 0!==l&&void 0!==l.style2&&"nothing"!==l.style2)continue;let e=!1;if(!isNaN(r.resi)&&!e&&i.residues.hasOwnProperty(a)){let s=Object.keys(i.residues[a])[0];n.hashUtilsCls.hash2Atoms(i.residues[a],i.atoms)[s],t=n.hashUtilsCls.unionHash(t,i.residues[a]),e=!0}}}a={}}if(i.bInitial){if(""!=n.htmlCls.setHtmlCls.getCookie("membrane")){let e=parseInt(n.htmlCls.setHtmlCls.getCookie("membrane"));i.bMembrane!=e&&n.htmlCls.clickMenuCls.setLogCmd("set membrane "+e,!0),i.bMembrane=isNaN(e)?0:parseInt(e)}i.bMembrane?i.selectionCls.toggleMembrane(!0):i.selectionCls.toggleMembrane(!1)}i.setStyleCls.setStyle2Atoms(t);let d=.5*i.cylinderRadius;void 0!==i.labels&&delete i.labels.schematic;for(let e in i.style2atoms){let t=i.style2atoms[e],l=n.hashUtilsCls.intHash(t,i.nucleotides),r=n.utilsCls.isCalphaPhosOnly(n.hashUtilsCls.hash2Atoms(l,i.atoms));if("ribbon"===e)i.strandCls.createStrand(n.hashUtilsCls.hash2Atoms(t,i.atoms),2,void 0,!0,void 0,void 0,!1,i.ribbonthickness,s);else if("strand"===e)i.strandCls.createStrand(n.hashUtilsCls.hash2Atoms(t,i.atoms),null,null,null,null,null,!1,void 0,s);else if("cylinder and plate"===e)i.cylinderCls.createCylinderHelix(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderHelixRadius,s);else if("nucleotide cartoon"===e)r?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["P"],i.traceRadius,!1,s):(i.cartoonNuclCls.drawCartoonNucleicAcid(n.hashUtilsCls.hash2Atoms(t,i.atoms),null,i.ribbonthickness,s),2!==s&&i.cartoonNuclCls.drawNucleicAcidStick(n.hashUtilsCls.hash2Atoms(t,i.atoms),s));else if("o3 trace"===e)r?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["P"],i.traceRadius,!1,s):i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["O3'","O3*"],i.traceRadius,!1,s);else if("schematic"===e){let e=i.firstAtomObjCls.getFirstAtomObj(t);if(i.chemicals.hasOwnProperty(e.serial)){i.residueLabelsCls.addNonCarbonAtomLabels(n.hashUtilsCls.hash2Atoms(t,i.atoms));let e=!0;i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),d,d,void 0,s,e)}else i.residueLabelsCls.addResidueLabels(n.hashUtilsCls.hash2Atoms(t,i.atoms),!0),r?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["P"],i.traceRadius,!1,s):i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["O3'","O3*"],i.traceRadius,!1,s),i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["CA"],i.traceRadius,!1,s)}else"c alpha trace"===e?i.cylinderCls.createCylinderCurve(n.hashUtilsCls.hash2Atoms(t,i.atoms),["CA"],i.traceRadius,!1,s):"b factor tube"===e?i.tubeCls.createTube(n.hashUtilsCls.hash2Atoms(t,i.atoms),"CA",null,s,!1,!0):"custom tube"===e?i.tubeCls.createTube(n.hashUtilsCls.hash2Atoms(t,i.atoms),"CA",null,s,!0,!0):"lines"===e||"lines2"===e?(1===s?i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.hlLineRadius,i.hlLineRadius,void 0,s):i.lineCls.createLineRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),s),i.lineCls.createConnCalphSidechain(n.hashUtilsCls.hash2Atoms(t,i.atoms),e)):"stick"===e||"stick2"===e?(i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderRadius,i.cylinderRadius,void 0,s,void 0),i.lineCls.createConnCalphSidechain(n.hashUtilsCls.hash2Atoms(t,i.atoms),e)):"backbone"===e?(t=this.selectMainChainSubset(t),i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderRadius,i.cylinderRadius,void 0,s,void 0)):"ball and stick"===e||"ball and stick2"===e?(i.stickCls.createStickRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.cylinderRadius,.5*i.cylinderRadius,i.dotSphereScale,s,void 0),i.lineCls.createConnCalphSidechain(n.hashUtilsCls.hash2Atoms(t,i.atoms),e)):"sphere"===e||"sphere2"===e?i.sphereCls.createSphereRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.sphereRadius,void 0,void 0,s):"dot"===e&&i.sphereCls.createSphereRepresentation(n.hashUtilsCls.hash2Atoms(t,i.atoms),i.sphereRadius,!1,i.dotSphereScale,s)}if(i.cnt>i.maxmaxatomcnt&&i.init_base(),void 0!==i.labels&&Object.keys(i.labels).length>0){i.labelCls.hideLabels();for(let e in i.labels)"schematic"!=e&&this.changeLabelColor(i.labels[e]);i.labelCls.createLabelRepresentation(i.labels)}}changeLabelColor(e){let t=this.icn3d;if(t.icn3dui,e)for(let s=0,i=e.length;s0){this.updateStabilizer();let e="#FFFFFF",s=t.stabilizerpnts;t.lines.stabilizer=[];for(let i=0,n=Math.floor(s.length/2);i0)for(let e=0,s=t.distPnts.length;e0&&t.applySymdCls.applySymd(),void 0!==t.prevOtherMesh)for(let e=0,s=t.prevOtherMesh.length;e0&&(e=s.hashUtilsCls.hash2Atoms(t.chemicals,t.atoms));let i=4;if(void 0!==e){let n=t.contactCls.getAtomsWithinAtom(t.atoms,e,i),l=3.5;t.opts.hbonds="yes",Object.keys(n).length>0&&t.hBondCls.calculateChemicalHbonds(e,n,parseFloat(l)),t.bSetFog||t.transformCls.zoominSelection(s.hashUtilsCls.unionHash(e,n))}}else"hide"===e.chemicalbinding&&(t.hBondCls.hideHbonds(),t.showInterCls.hideExtraBonds(),t.bSetFog||t.transformCls.zoominSelection(t.atoms))}updateStabilizer(){let e=this.icn3d;if(e.icn3dui,e.stabilizerpnts=[],void 0!==e.pairArray)for(let t=0,s=e.pairArray.length;t=0;i--){let r=t.ssbondpnts[e][2*i],o=t.ssbondpnts[e][2*i+1],a={};a.color=n,a.dashed=!1;let d=[],c=[],h=[],p=[],m=!1,u=!1;for(let e in t.residues[r])"SG"===t.atoms[e].name&&(h.push(t.atoms[e].coord),d.push(t.atoms[e].serial),m=!0);if(!m)for(let e in t.residues[r])if("CA"===t.atoms[e].name){h.push(t.atoms[e].coord),d.push(t.atoms[e].serial),m=!0,u=!0;break}m=!1;for(let e in t.residues[o])"SG"===t.atoms[e].name&&(p.push(t.atoms[e].coord),c.push(t.atoms[e].serial),m=!0);if(!m)for(let e in t.residues[o])if("CA"===t.atoms[e].name){p.push(t.atoms[e].coord),c.push(t.atoms[e].serial),m=!0,u=!0;break}let g=u?7:3,f=!1;for(let e=0,t=h.length;e1&&(l=!0)}if(t)if(l){let t=Object.keys(r)[0];e=i.chains[t]}else{0==Object.keys(i.hAtoms).length&&(i.hAtoms=n.hashUtilsCls.cloneHash(i.dAtoms));let t,s=parseInt(Object.keys(i.hAtoms).length/u),l=0;for(let n in i.hAtoms)if(e[n]=1,t=n,++l,l>s)break;let r=i.atoms[t].structure+"_"+i.atoms[t].chain+"_"+i.atoms[t].resi;e=n.hashUtilsCls.unionHash(e,i.residues[r])}else{let t=Object.keys(i.structures)[0]+"_"+g;if(i.chains.hasOwnProperty(t)||(t=Object.keys(i.structures)[0]+"_"+g.toLowerCase()),!i.chains.hasOwnProperty(t)){t=Object.keys(i.chains)[0];for(let e in i.chains){let s=Object.keys(i.chains[e])[0];if(i.proteins.hasOwnProperty(s)){t=e;break}}}e=i.chains[t]}let a=s.clone().add(h).multiplyScalar(.5),c=new THREE.Vector3,p=0,f=h.clone().sub(s).normalize(),b=new THREE.Vector3(0,0,1),C=new THREE.Quaternion;C.setFromUnitVectors(f,b);let y=-9999;for(let t in e){let e=i.atoms[t].coord.clone();c.add(e),e.sub(a).applyQuaternion(C);let s=e.x*e.x+e.y*e.y;s>y&&(y=s),++p}let v=i.ParserUtilsCls.getMassCenter(c,p),_=new THREE.Line3(s,h),w=new THREE.Vector3;_.closestPointToPoint(v,!0,w);let S,A,x,k,O=Math.sqrt(y),R=v.clone().sub(w).normalize().multiplyScalar(O),I=a.clone().add(s.clone().sub(a).multiplyScalar(.83)).add(R),T=a.clone().add(h.clone().sub(a).multiplyScalar(.83)).add(R),E=2*Math.PI/o;for(let e=0;et&&(i.sphereCls.createSphereBase(r,colorPolygon,d,1,0),i.cylinderCls.createCylinder(e,r,d,colorPolygon,0),i.cylinderCls.createCylinder(s,r,d,colorPolygon,0),void 0!==n&&i.cylinderCls.createCylinder(c[n],r,d,colorPolygon,0),n=l)}}else if("O"==r)for(let e=0,t=c.length;e0&&(e.mdl.remove(e.prevSurfaces[e.prevSurfaces.length-1]),e.prevSurfaces.slice(e.prevSurfaces.length-1,1))}removeMaps(){let e=this.icn3d;e.icn3dui;for(let t=0,s=e.prevMaps.length;t0&&(e.mdl.remove(e.prevMaps[e.prevMaps.length-1]),e.prevMaps.slice(e.prevMaps.length-1,1))}removeLastEmmap(){let e=this.icn3d;e.icn3dui,e.prevEmmaps.length>0&&(e.mdl.remove(e.prevEmmaps[e.prevEmmaps.length-1]),e.prevEmmaps.slice(e.prevEmmaps.length-1,1))}removeLastPhimap(){let e=this.icn3d;e.icn3dui,e.prevPhimaps.length>0&&(e.mdl.remove(e.prevPhimaps[e.prevPhimaps.length-1]),e.prevPhimaps.slice(e.prevPhimaps.length-1,1))}}class ot{constructor(e){this.icn3d=e}addResidueLabels(e,t,s,i,n){let l=this.icn3d,r=l.icn3dui;if(r.bNode)return;let o=r.hashUtilsCls.intHash(l.hAtoms,e);t?void 0===l.labels.schematic&&(l.labels.schematic=[]):void 0===l.labels.residue&&(l.labels.residue=[]);let a="";for(let e in o){let s=l.atoms[e],o={},d=s.structure+"_"+s.chain+"_"+s.resi;if(!s.het&&("CA"===s.name||"O3'"===s.name||"O3*"===s.name)||l.water.hasOwnProperty(s.serial)||l.ions.hasOwnProperty(s.serial)||l.chemicals.hasOwnProperty(s.serial)&&d!==a){if(o.position=s.coord,o.bSchematic=0,t&&(o.bSchematic=1),o.text=r.utilsCls.residueName2Abbr(s.resn),i)o.text+=s.resi;else if(n){let e=s.structure+"_"+s.chain+"_"+s.resi,t="";l.resid2refnum[e]&&(t=" "==l.resid2refnum[e].substr(0,1)?"":l.resid2refnum[e]),o.text=t}o.size=18,o.factor=.3;let e=s.color.getHexString().toUpperCase();o.color=i?"black"!=l.opts.background?l.colorWhitebkgd:l.colorBlackbkgd:n?"#00FFFF":"CCCCCC"===e||"C8C8C8"===e?"#888888":"#"+e,o.background="#FFFFFF",t?l.labels.schematic.push(o):l.labels.residue.push(o)}a=d}l.hlObjectsCls.removeHlObjects()}addNonCarbonAtomLabels(e){let t=this.icn3d,s=t.icn3dui;if(s.bNode)return;let i=s.hashUtilsCls.intHash(t.hAtoms,e);void 0===t.labels.schematic&&(t.labels.schematic=[]);for(let e in i){let s=t.atoms[e];if(!t.residues.hasOwnProperty(s.structure+"_"+s.chain+"_"+s.resi))continue;if("C"===s.elem)continue;let i={};i.position=s.coord,i.bSchematic=1,i.text=s.elem,i.size=18,i.color="black"!=t.opts.background?t.colorWhitebkgd:s.color.getHexString(),i.background="#FFFFFF",t.labels.schematic.push(i)}t.hlObjectsCls.removeHlObjects()}addAtomLabels(e,t){let s=this.icn3d,i=s.icn3dui;if(i.bNode)return;let n=i.hashUtilsCls.intHash(s.hAtoms,e);n=i.hashUtilsCls.intHash(s.dAtoms,n),void 0===s.labels.residue&&(s.labels.residue=[]);for(let e in n){let i=s.atoms[e],n={};n.position=i.coord,n.bSchematic=0,n.text=t?i.elem:i.name.padEnd(2," "),n.size=18,t&&(n.bSchematic=!0);let l=i.color.getHexString().toUpperCase();n.color="black"!=s.opts.background?s.colorWhitebkgd:s.colorBlackbkgd,t&&(n.color="CCCCCC"===l||"C8C8C8"===l?"#888888":"#"+l),n.background="#FFFFFF",s.labels.residue.push(n)}s.hlObjectsCls.removeHlObjects()}}class at{constructor(e){this.icn3d=e}onBeforeRender(e,t,s,i,n,l){let r=n.uniforms,o=[];if(r.objectId&&(r.objectId.value=SupportsReadPixelsFloat?this.id:this.id/255,o.push("objectId")),(r.modelViewMatrixInverse||r.modelViewMatrixInverseTranspose||r.modelViewProjectionMatrix||r.modelViewProjectionMatrixInverse)&&this.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,this.matrixWorld),r.modelViewMatrixInverse&&(r.modelViewMatrixInverse.value.copy(this.modelViewMatrix).invert(),o.push("modelViewMatrixInverse")),r.modelViewMatrixInverseTranspose&&(r.modelViewMatrixInverse?r.modelViewMatrixInverseTranspose.value.copy(r.modelViewMatrixInverse.value).transpose():r.modelViewMatrixInverseTranspose.value.copy(this.modelViewMatrix).invert().transpose(),o.push("modelViewMatrixInverseTranspose")),r.modelViewProjectionMatrix&&(s.updateProjectionMatrix(),r.modelViewProjectionMatrix.value.multiplyMatrices(s.projectionMatrix,this.modelViewMatrix),o.push("modelViewProjectionMatrix")),r.modelViewProjectionMatrixInverse){let e=new THREE.Matrix4;r.modelViewProjectionMatrix?(e.copy(r.modelViewProjectionMatrix.value),r.modelViewProjectionMatrixInverse.value.copy(e).invert()):(s.updateProjectionMatrix(),e.multiplyMatrices(s.projectionMatrix,this.modelViewMatrix),r.modelViewProjectionMatrixInverse.value.copy(e).invert()),o.push("modelViewProjectionMatrixInverse")}if(r.projectionMatrix&&(s.updateProjectionMatrix(),r.projectionMatrix.value.copy(s.projectionMatrix),o.push("projectionMatrix")),r.projectionMatrixInverse&&(s.updateProjectionMatrix(),r.projectionMatrixInverse.value.copy(s.projectionMatrix).invert(),o.push("projectionMatrixInverse")),o.length){let t=e.properties.get(n);if(t.program){let s=e.getContext(),i=t.program;s.useProgram(i.program);let n=i.getUniforms();o.forEach((function(e){n.setValue(s,e,r[e].value)}))}}}setParametersForShader(e){let t,s=this.icn3d,i=s.icn3dui.parasCls.backgroundColors[s.opts.background.toLowerCase()],n=2.5*s.maxD,l=4*s.maxD,r=void 0!==s.biomtMatrices&&s.biomtMatrices.length*s.cnt>s.maxatomcnt;"yes"===s.opts.slab?r?t=.1:void 0!==s.camMaxDFactorFog?(t=s.maxD*s.camMaxDFactorFog-10,n=2.5*s.maxD-t<0?0:2.5*s.maxD-t,l=4*s.maxD-t):t=s.maxD*s.camMaxDFactor:t=.1;let o=void 0!==e?e:1,a=s.shininess/100*.5;s.uniforms=THREE.UniformsUtils.merge([THREE.UniformsLib.common,{modelViewMatrix:{value:new THREE.Matrix4},modelViewMatrixInverse:{value:new THREE.Matrix4},modelViewMatrixInverseTranspose:{value:new THREE.Matrix4},modelViewProjectionMatrix:{value:new THREE.Matrix4},modelViewProjectionMatrixInverse:{value:new THREE.Matrix4},projectionMatrix:{value:new THREE.Matrix4},projectionMatrixInverse:{value:new THREE.Matrix4},diffuse:{type:"v3",value:[1,1,1]},emissive:{type:"v3",value:[.06,.06,.06]},roughness:{type:"f",value:.5},metalness:{type:"f",value:a},opacity:{type:"f",value:o},nearClip:{type:"f",value:t},ortho:{type:"f",value:0},shrink:{type:"f",value:.13},fogColor:{type:"v3",value:[i.r,i.g,i.b]},fogNear:{type:"f",value:n},fogFar:{type:"f",value:l},fogDensity:{type:"f",value:2}},THREE.UniformsLib.ambient,THREE.UniformsLib.lights]),s.defines={USE_COLOR:1,NEAR_CLIP:1,CAP:1},"yes"!==s.opts.fog||r||(s.defines.USE_FOG=1,"orthographic"===s.opts.camera&&(s.defines.FOG_EXP2=1)),s.bExtFragDepth&&(s.defines.USE_LOGDEPTHBUF_EXT=1)}drawImpostorShader(){this.icn3d.icn3dui.bNode||(this.setParametersForShader(),this.createImpostorShaderSphere("SphereImpostor"),this.createImpostorShaderCylinder("CylinderImpostor"))}getShader(e){this.icn3d.icn3dui;let t=$NGL_shaderTextHash[e];return t=t.replace(/#include\s+(\S+)/gim,(function(e,t){let s;return THREE.ShaderChunk.hasOwnProperty(t)&&(s=THREE.ShaderChunk[t]),s||""})),t}createImpostorShaderBase(e,t,s,i,n,l,r,o,a){let d=this.icn3d;d.icn3dui;let c=new THREE.ShaderMaterial({defines:d.defines,uniforms:d.uniforms,vertexShader:this.getShader(e+".vert"),fragmentShader:this.getShader(e+".frag"),depthTest:!0,depthWrite:!0,lights:!0});c.extensions.fragDepth=!0,"CylinderImpostor"==e?d.CylinderImpostorMaterial=c:"SphereImpostor"==e&&(d.SphereImpostorMaterial=c);let h,p,m=l*r,u=l*o,g=new(m>65535?Uint32Array:Uint16Array)(u);for(let e=0;e=0;t--){let s=a.children[t];s.onBeforeRender=e.impostorCls.onBeforeRender,s.frustumCulled=!1}l.add(a)}void 0!==e.mdl_ghost&&(a=e.mdl_ghost.clone(),this.applyMat(a,d),r.add(a));let c=e.center.clone();this.applyMat(c,d,!0),s.add(c),++t}e.mdl.add(n),e.mdlImpostor.add(l),e.mdl_ghost.add(r),void 0!==e.bSetInstancing&&e.bSetInstancing?(e.maxD=e.maxDAssembly,e.center=e.centerAssembly.clone(),e.applyCenterCls.setCenter(e.center),e.cameraCls.setCamera()):(e.maxD*=Math.sqrt(t),e.center=e.ParserUtilsCls.getMassCenter(s,t),e.maxDAssembly=e.maxD,e.centerAssembly=e.center.clone(),e.applyCenterCls.setCenter(e.center),e.cameraCls.setCamera()),e.bSetInstancing=!0}createInstancedGeometry(e){let t=this.icn3d,s=t.icn3dui,i=e.geometry,n=new THREE.InstancedBufferGeometry,l=[],r=[],o=[],a=[],d=[],c=[],h=[],p=[];if(t.bImpo&&"Cylinder"==e.type){t.instancedMaterial=this.getInstancedMaterial("CylinderInstancing");let e=s.hashUtilsCls.hashvalue2array(i.attributes.position1.array),r=s.hashUtilsCls.hashvalue2array(i.attributes.color.array),m=s.hashUtilsCls.hashvalue2array(i.attributes.position2.array),u=s.hashUtilsCls.hashvalue2array(i.attributes.color2.array),g=s.hashUtilsCls.hashvalue2array(i.index.array),f=s.hashUtilsCls.hashvalue2array(i.attributes.radius.array),b=s.hashUtilsCls.hashvalue2array(i.attributes.mapping.array);l=l.concat(e),o=o.concat(r),h=h.concat(m),p=p.concat(u),a=a.concat(g),d=d.concat(f),c=c.concat(b),n.setAttribute("position1",new THREE.BufferAttribute(new Float32Array(l),3)),n.setAttribute("color",new THREE.BufferAttribute(new Float32Array(o),3)),n.setAttribute("position2",new THREE.BufferAttribute(new Float32Array(h),3)),n.setAttribute("color2",new THREE.BufferAttribute(new Float32Array(p),3)),n.setAttribute("radius",new THREE.BufferAttribute(new Float32Array(d),1)),n.setAttribute("mapping",new THREE.BufferAttribute(new Float32Array(c),3)),n.setIndex(new THREE.BufferAttribute(new Uint32Array(a),1)),e=null,r=null,m=null,u=null,g=null,f=null,b=null}else if(t.bImpo&&"Sphere"==e.type){t.instancedMaterial=this.getInstancedMaterial("SphereInstancing");let e=s.hashUtilsCls.hashvalue2array(i.attributes.position.array),r=s.hashUtilsCls.hashvalue2array(i.attributes.color.array),h=s.hashUtilsCls.hashvalue2array(i.index.array),p=s.hashUtilsCls.hashvalue2array(i.attributes.radius.array),m=s.hashUtilsCls.hashvalue2array(i.attributes.mapping.array);l=l.concat(e),o=o.concat(r),a=a.concat(h),d=d.concat(p),c=c.concat(m),n.setAttribute("position",new THREE.BufferAttribute(new Float32Array(l),3)),n.setAttribute("color",new THREE.BufferAttribute(new Float32Array(o),3)),n.setAttribute("radius",new THREE.BufferAttribute(new Float32Array(d),1)),n.setAttribute("mapping",new THREE.BufferAttribute(new Float32Array(c),2)),n.setIndex(new THREE.BufferAttribute(new Uint32Array(a),1)),e=null,r=null,h=null,p=null,m=null}else{t.instancedMaterial=this.getInstancedMaterial("Instancing");let e=i.attributes.position?s.hashUtilsCls.hashvalue2array(i.attributes.position.array):[],d=i.attributes.normal?s.hashUtilsCls.hashvalue2array(i.attributes.normal.array):[],c=i.attributes.color?s.hashUtilsCls.hashvalue2array(i.attributes.color.array):[],h=i.index?s.hashUtilsCls.hashvalue2array(i.index.array):[];l=l.concat(e),r=r.concat(d),o=o.concat(c),a=a.concat(h);let p=[],m="CylinderGeometry"==i.type?1:0;for(let e=0,t=l.length/3;e0&&(e.dAtoms=t.hashUtilsCls.cloneHash(s)),e.bShowHighlight=!1}e.applyMapCls.removeSurfaces(),e.applyMapCls.applySurfaceOptions(),e.applyMapCls.removeMaps(),e.applyMapCls.applyMapOptions(),e.applyMapCls.removeEmmaps(),e.applyMapCls.applyEmmapOptions(),e.applyMapCls.removePhimaps(),e.applyMapCls.applyPhimapOptions(),e.applyMapCls.removeSurfaces(),e.applyMapCls.applyphisurfaceOptions(),e.axes=[],e.pc1&&e.axesCls.setPc1Axes(),e.opts.rotationcenter="highlight center",e.drawCls.draw(),e.bShowHighlight=!0}async alternateWrapper(){let e=this.icn3d;e.icn3dui,e.bAlternate=!0,await this.alternateStructures(),e.bAlternate=!1}}class ht{constructor(e){this.icn3d=e}draw(e){let t=this.icn3d,s=t.icn3dui;if(t.impostorCls.clearImpostors(),!t.bRender||t.hAtoms&&0!=Object.keys(t.hAtoms)||(t.hAtoms=s.hashUtilsCls.cloneHash(t.atoms)),t.sceneCls.rebuildScene(),t.bImpo&&t.impostorCls.drawImpostorShader(),t.setColorCls.applyPrevColor(),void 0!==t.biomtMatrices&&t.biomtMatrices.length>1)if(t.bAssembly&&1==Object.keys(t.structures).length&&(void 0===s.cfg.mmdbid&&1==s.cfg.bu||void 0!==s.cfg.mmdbid&&1==s.cfg.bu&&Object.keys(t.atoms).length*t.biomtMatrices.length>t.maxatomcnt))t.instancingCls.drawSymmetryMates();else{let e=!0;t.applyCenterCls.centerSelection(void 0,e)}let i=void 0!==t.hAtoms?Object.keys(t.hAtoms).length:0;if(i>0&&i0){e.children[0].scale.z=t[0].distance,t[0].point.sub(r.mdl.position);let s=r.rayThreshold,i=r.rayCls.getAtomsFromPosition(t[0].point,s);for(;!i&&s<10;)s+=.5,i=r.rayCls.getAtomsFromPosition(t[0].point,s);i&&(r.pAtomNum%2==0?r.pAtom=i:r.pAtom2=i,++r.pAtomNum,this.showPickingVr(r.pk,i))}}}}catch(e){}}showPickingVr(e,t){let s=this.icn3d;s.icn3dui,e||(e=2),s.hAtoms=s.pickingCls.getPickedAtomList(e,t),2===e?s.residueLabelsCls.addResidueLabels(s.hAtoms,void 0,void 0,!0):1===e&&s.residueLabelsCls.addAtomLabels(s.hAtoms),s.setOptionCls.setStyle("proteins",t.style)}render_base(){let e=this.icn3d,t=e.icn3dui,s=this;if(t.bNode)return;let i=e.bControlGl&&!t.bNode?window.cam:e.cam;if(e.directionalLight){let t=new THREE.Quaternion;t.setFromUnitVectors(new THREE.Vector3(0,0,e.cam_z).normalize(),i.position.clone().normalize()),e.directionalLight.position.copy(e.lightPos.clone().applyQuaternion(t).normalize()),e.directionalLight2.position.copy(e.lightPos2.clone().applyQuaternion(t).normalize()),e.directionalLight3.position.copy(e.lightPos3.clone().applyQuaternion(t).normalize())}if(e.bVr||e.renderer.setPixelRatio(window.devicePixelRatio),e.bVr){let t=.04;if(e.controllers){let i=this.updateGamepadState();for(let n=0,l=e.controllers.length;n{const i=e.gamepad.axes;let r=parseInt(1e3*i[t]),o=parseInt(-1e3*i[s]);n.push(r),l.push(o)})),{xArray:n,yArray:l}}return{xArray:[0,0],yArray:[0,0]}}}class pt{constructor(e){this.icn3d=e}getAtomsWithinAtom(e,t,s,i,n,l,r){let o=this.icn3d;o.icn3dui;let a=this.getNeighboringAtoms(e,t,s,r);i&&(o.resid2Residhash={});let d={};for(let e in t){let c,h,p=o.atoms[e],m=p.structure+"_"+p.chain+"_"+p.resi;for(let e in o.residues[m])if(o.atoms[e]&&("CA"===o.atoms[e].name&&"C"===o.atoms[e].elem||"O3'"===o.atoms[e].name||"O3*"===o.atoms[e].name)){c=o.atoms[e];break}void 0===c&&(c=p),i&&(h=p.resn+" $"+p.structure+"."+p.chain+":"+p.resi,void 0===o.resid2Residhash[h]&&(o.resid2Residhash[h]={}));let u=p.structure+"_"+p.chain+"_"+p.resi;for(let e in a){let m=a[e];if(!o.crossstrucinter&&p.structure!=m.structure)continue;if(!r&&m.serial in t)continue;if(o.bOpm&&"DUM"===m.resn)continue;let g=m.coord.distanceTo(p.coord);if(go?r:o,d=Math.sqrt(a),c=(d+s)*(d+s),h={};for(let r in e){let e=n.atoms[r];!i&&t.hasOwnProperty(e.serial)||(this.bOpm&&"DUM"===e.resn||e.coord.xl[1][0]+s||e.coord.yl[1][1]+s||e.coord.zl[1][2]+s||(e.coord.x-l[2][0])*(e.coord.x-l[2][0])+(e.coord.y-l[2][1])*(e.coord.y-l[2][1])+(e.coord.z-l[2][2])*(e.coord.z-l[2][2])e.coord.x?n:e.coord.x,l=l>e.coord.y?l:e.coord.y,r=r>e.coord.z?r:e.coord.z}return[[t,s,i],[n,l,r],[o/c,a/c,d/c]]}hideContact(){let e=this.icn3d;e.icn3dui,e.opts.contact="no",void 0===e.lines&&(e.lines={}),e.lines.contact=[],e.contactpnts=[]}}class mt{constructor(e){this.icn3d=e}isHbondDonorAcceptor(e){let t=this.icn3d;if(t.icn3dui,"N"==e.name&&!e.het||"N"==e.elem&&"Arg"==e.resn||"N"==e.elem&&"Asn"==e.resn||"N"==e.elem&&"Gln"==e.resn||"N"==e.elem&&"Lys"==e.resn||"N"==e.elem&&"Trp"==e.resn)return"donor";if("O"==e.name&&!e.het||"S"==e.elem&&"Met"==e.resn||"O"==e.elem&&"Asn"==e.resn||"O"==e.elem&&"Asp"==e.resn||"O"==e.elem&&"Gln"==e.resn||"O"==e.elem&&"Glu"==e.resn)return"acceptor";if("S"==e.elem&&"Cys"==e.resn||"N"==e.elem&&"His"==e.resn||"O"==e.elem&&"Ser"==e.resn||"O"==e.elem&&"Thr"==e.resn||"O"==e.elem&&"Tyr"==e.resn)return"both";if("Pro"==e.resn)return"none";if("N"==e.elem){if("Asn"==e.resn||"Gln"==e.resn)return"both";let s=0,i=0;for(let i=0,n=e.bonds.length;i1?"ring":"donor":"none"}if("O"==e.elem&&1==e.bonds.length){if("Asn"==e.resn||"Gln"==e.resn)return"both";for(let s=0,i=e.bonds.length;s=2?"acceptor":"both"}if("O"==e.elem&&2==e.bonds.length){for(let s=0,i=e.bonds.length;s1);++t)"H"!=s.atoms[e.bonds[t]].elem&&(i=s.atoms[e.bonds[t]],l[r++].subVectors(s.atoms[e.bonds[t]].coord,e.coord));if(1===r)for(let t=0,n=i.bonds.length;t1);++t)"H"!=s.atoms[i.bonds[t]].elem&&s.atoms[i.bonds[t]].serial!=e.serial&&l[r++].subVectors(s.atoms[i.bonds[t]].coord,e.coord);if(2!==r)return;let o=l[0].cross(l[1]);return Math.abs(Math.PI/2-o.angleTo(n))}isValidHbond(e,t,s){let i=this.icn3d;i.icn3dui;let n,l,r=this.isHbondDonorAcceptor(e),o=this.isHbondDonorAcceptor(t),a=50*Math.PI/180,d=50*Math.PI/180,c=90*Math.PI/180,h=30*Math.PI/180;if("donor"==r&&("acceptor"==o||"both"==o||"ring"==o)||"acceptor"==o&&("donor"==r||"both"==r||"ring"==r))n=e,l=t;else if("acceptor"==r&&("donor"==o||"both"==o||"ring"==o)||"donor"==o&&("acceptor"==r||"both"==r||"ring"==r))l=e,n=t;else{if("both"!=r&&"ring"!=r||"both"!=o&&"ring"!=o)return!1;n=e,l=t,i.nucleotides.hasOwnProperty(e.serial)&&i.nucleotides.hasOwnProperty(t.serial)&&("ring"==r||"ring"==o)||(e.het||t.het)&&"ring"==r&&"ring"==o||(h=90*Math.PI/180)}let p=this.calcAngles(n,l),m=90*Math.PI/180;for(let e=0,t=p.length;ed)return!1;let u=this.calcPlaneAngle(n,l);if(void 0!==u&&u>h)return!1;let g=this.calcAngles(l,n),f=90*Math.PI/180;for(let e=0,t=g.length;ea)return!1;let b=this.calcPlaneAngle(l,n);return!(void 0!==b&&b>c)}calculateChemicalHbonds(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(0===Object.keys(e).length||0===Object.keys(t).length)return;r.resid2Residhash={};let a,d,c={},h=s*s;for(let t in e){let s=e[t],n=i?"LYS"===s.resn&&"N"===s.elem&&"N"!==s.name||"ARG"===s.resn&&("NH1"===s.name||"NH2"===s.name)||("GLU"===s.resn||"ASP"===s.resn)&&"O"===s.elem&&"O"!==s.name||s.het&&("N"===s.elem||"O"===s.elem||"S"===s.elem):"N"===s.elem||"O"===s.elem||"S"===s.elem&&(s.het||"Cys"===s.resn||"Met"===s.resn);n=r.bOpm?n&&"DUM"!==s.resn:n,n&&(a=s.structure+"_"+s.chain+"_"+s.resi,d=a+"_"+s.name,c[d]=s)}let p={},m={},u=.5,g=-27.888,f={};for(let e in t){let b=t[e],C=i?"LYS"===b.resn&&"N"===b.elem&&"N"!==b.name||"ARG"===b.resn&&("NH1"===b.name||"NH2"===b.name)||("GLU"===b.resn||"ASP"===b.resn)&&"O"===b.elem&&"O"!==b.name||b.het&&("N"===b.elem||"O"===b.elem||"S"===b.elem):"N"===b.elem||"O"===b.elem||"S"===b.elem&&(b.het||"Cys"===b.resn||"Met"===b.resn);if(C=r.bOpm?C&&"DUM"!==b.resn:C,C){a=b.structure+"_"+b.chain+"_"+b.resi,d=a+"_"+b.name;let e=b.resn+" $"+b.structure+"."+b.chain+":"+b.resi+"@"+b.name;void 0===r.resid2Residhash[e]&&(r.resid2Residhash[e]={});for(let t in c){if(i&&!(("LYS"!==b.resn&&"ARG"!==b.resn||"LYS"!==c[t].resn&&"ARG"!==c[t].resn)&&("GLU"!==b.resn&&"ASP"!==b.resn||"GLU"!==c[t].resn&&"ASP"!==c[t].resn)))continue;if(!r.crossstrucinter&&b.structure!=c[t].structure)continue;if(a==t.substr(0,t.lastIndexOf("_")))continue;let d=Math.abs(b.coord.x-c[t].coord.x);if(d>s)continue;let C=Math.abs(b.coord.y-c[t].coord.y);if(C>s)continue;let y=Math.abs(b.coord.z-c[t].coord.z);if(y>s)continue;let v=d*d+C*C+y*y;if(v>h)continue;if(!r.proteins.hasOwnProperty(b.serial)||!r.proteins.hasOwnProperty(c[t].serial)||"N"!==b.name&&"O"!==b.name||"O"!==c[t].name&&"N"!==c[t].name){if(!this.isValidHbond(b,c[t],s))continue}else{if(b.name===c[t].name)continue;if(b.structure==c[t].structure&&b.chain==c[t].chain&&Math.abs(b.resi-c[t].resi)<=1)continue;let e,i="N"===b.name?b:c[t],n="O"===b.name?b:c[t];if("Pro"===i.resn)continue;if(void 0===i.hcoord){if(!this.isValidHbond(b,c[t],s))continue}else{let s,l=i.hcoord,o=i.coord,a=n.structure+"_"+n.chain+"_"+n.resi;for(let e in r.residues[a])if("C"===r.atoms[e].name){s=r.atoms[e];break}if(!s)continue;let d=s.coord,h=n.coord,p=l.distanceTo(h),m=l.distanceTo(d),f=o.distanceTo(d),C=o.distanceTo(h);e=p2||f[c[t].serial]>2)continue;void 0===f[b.serial]?f[b.serial]=1:++f[b.serial],void 0===f[c[t].serial]?f[c[t].serial]=1:++f[c[t].serial],"graph"!==n&&(i?(r.saltbridgepnts.push({serial:b.serial,coord:b.coord}),r.saltbridgepnts.push({serial:c[t].serial,coord:c[t].coord})):(r.hbondpnts.push({serial:b.serial,coord:b.coord}),r.hbondpnts.push({serial:c[t].serial,coord:c[t].coord})));let _=c[t].structure+"_"+c[t].chain+"_"+c[t].resi;p=o.hashUtilsCls.unionHash(p,r.residues[a]),p=o.hashUtilsCls.unionHash(p,r.residues[_]),m[a]=1,m[_]=1;let w=c[t].resn+" $"+c[t].structure+"."+c[t].chain+":"+c[t].resi+"@"+c[t].name,S=a+"_"+b.resn+","+_+"_"+c[t].resn;void 0!==r.resids2interAll[S]&&void 0!==r.resids2interAll[S].ionic&&r.resids2interAll[S].ionic.hasOwnProperty(e+","+w)||(r.resid2Residhash[e][w]=v.toFixed(1),l||(void 0===r.resids2inter[S]&&(r.resids2inter[S]={}),void 0===r.resids2inter[S].hbond&&(r.resids2inter[S].hbond={}),r.resids2inter[S].hbond[e+","+w]=v.toFixed(1)),void 0===r.resids2interAll[S]&&(r.resids2interAll[S]={}),void 0===r.resids2interAll[S].hbond&&(r.resids2interAll[S].hbond={}),r.resids2interAll[S].hbond[e+","+w]=v.toFixed(1))}}}let b=Object.keys(m);if("graph"!==n)for(let e=0,t=b.length;en)return!1;let c=Math.abs(e.coord.y-t.coord.y);if(c>n)return!1;let h=Math.abs(e.coord.z-t.coord.z);if(h>n)return!1;let p=d*d+c*c+h*h;if(p>l)return!1;"graph"!==s&&("halogen"==i?(a.halogenpnts.push({serial:e.serial,coord:e.coord}),a.halogenpnts.push({serial:t.serial,coord:t.coord})):"pi-cation"==i?(a.picationpnts.push({serial:e.serial,coord:e.coord}),a.picationpnts.push({serial:t.serial,coord:t.coord})):"pi-stacking"==i&&(a.pistackingpnts.push({serial:e.serial,coord:e.coord}),a.pistackingpnts.push({serial:t.serial,coord:t.coord})));let m=t.resn+" $"+t.structure+"."+t.chain+":"+t.resi+"@"+t.name;a.resid2Residhash[r][m]=p.toFixed(1);let u=e.structure+"_"+e.chain+"_"+e.resi+"_"+e.resn+","+t.structure+"_"+t.chain+"_"+t.resi+"_"+t.resn;return o||(void 0===a.resids2inter[u]&&(a.resids2inter[u]={}),void 0===a.resids2inter[u][i]&&(a.resids2inter[u][i]={}),a.resids2inter[u][i][r+","+m]=p.toFixed(1)),void 0===a.resids2interAll[u]&&(a.resids2interAll[u]={}),void 0===a.resids2interAll[u][i]&&(a.resids2interAll[u][i]={}),a.resids2interAll[u][i][r+","+m]=p.toFixed(1),!0}getRingNormal(e){if(this.icn3d.icn3dui,e.length<3)return;let t=e[0].clone().sub(e[1]),s=e[1].clone().sub(e[2]);return t.cross(s).normalize()}getAromaticRings(e,t,s){let i=this.icn3d;i.icn3dui;let n=[],l=[],r=[],o=[];if("nucleotide"==s){let s=new THREE.Vector3,a=new THREE.Vector3;if("A"==e.trim().toUpperCase()||"DA"==e.trim().toUpperCase()||"G"==e.trim().toUpperCase()||"DG"==e.trim().toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"N1"==t.name||"C2"==t.name||"N3"==t.name||"C6"==t.name?(s.add(t.coord),r.push(t.coord)):"C4"==t.name||"C5"==t.name?(s.add(t.coord),a.add(t.coord),r.push(t.coord),o.push(t.coord)):"N7"!=t.name&&"C8"!=t.name&&"N9"!=t.name||(a.add(t.coord),o.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r))),5==o.length&&(a.multiplyScalar(.2),n.push(a),l.push(this.getRingNormal(o)))}else if("C"==e.trim().toUpperCase()||"DC"==e.trim().toUpperCase()||"T"==e.trim().toUpperCase()||"DT"==e.trim().toUpperCase()||"U"==e.trim().toUpperCase()||"DU"==e.trim().toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"N1"==t.name||"C2"==t.name||"N3"==t.name||"C6"==t.name?(s.add(t.coord),r.push(t.coord)):"C4"!=t.name&&"C5"!=t.name||(s.add(t.coord),r.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r)))}}else if("protein"==s){let s=new THREE.Vector3,a=new THREE.Vector3;if("PHE"==e.toUpperCase()||"TYR"==e.toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"CG"!=t.name&&"CD1"!=t.name&&"CE1"!=t.name&&"CZ"!=t.name&&"CE2"!=t.name&&"CD2"!=t.name||(s.add(t.coord),r.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r)))}else if("HIS"==e.toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"CG"!=t.name&&"ND1"!=t.name&&"CE1"!=t.name&&"NE2"!=t.name&&"CD2"!=t.name||(s.add(t.coord),r.push(t.coord))}5==r.length&&(s.multiplyScalar(.2),n.push(s),l.push(this.getRingNormal(r)))}else if("TRP"==e.toUpperCase()){for(let e in i.residues[t]){let t=i.atoms[e];"CZ2"==t.name||"CH2"==t.name||"CZ3"==t.name||"CE3"==t.name?(s.add(t.coord),r.push(t.coord)):"CD2"==t.name||"CE2"==t.name?(s.add(t.coord),a.add(t.coord),r.push(t.coord),o.push(t.coord)):"CG"!=t.name&&"CD1"!=t.name&&"NE1"!=t.name||(a.add(t.coord),o.push(t.coord))}6==r.length&&(s.multiplyScalar(1/6),n.push(s),l.push(this.getRingNormal(r))),5==o.length&&(a.multiplyScalar(.2),n.push(a),l.push(this.getRingNormal(o)))}}return{piPosArray:n,normalArray:l}}dfs_cycle(e,t,s){let i=this.icn3d;if(i.icn3dui,2==i.ring_color[e])return s;if(1==i.ring_color[e]){s++;let n=t;for(i.ring_mark[n]=s;n!=e;)n=i.ring_par[n],i.ring_mark[n]=s;return s}if(i.ring_par[e]=t,i.ring_color[e]=1,void 0!==i.atoms[e])for(let t=0,n=i.atoms[e].bonds.length;t=3&&o<=6&&a[0]&&a[1]&&a[2]&&a[3]){let i=a[0].clone().sub(a[1]).normalize(),r=a[1].clone().sub(a[2]).normalize(),d=a[2].clone().sub(a[3]).normalize(),c=i.cross(r).normalize(),h=c.dot(d);if(Math.abs(h)<.052){l.multiplyScalar(1/o);let i=t.atoms[n];s[e+"_pi"+n]={resn:i.resn,name:"pi"+n,coord:l,serial:i.serial,structure:i.structure,chain:i.chain,resi:i.resi,normal:c}}}}return s}hideHalogenPi(){let e=this.icn3d;e.icn3dui,e.opts.halogen="no",e.opts["pi-cation"]="no",e.opts["pi-stacking"]="no",void 0===e.lines&&(e.lines={}),e.lines.halogen=[],e.lines["pi-cation"]=[],e.lines["pi-stacking"]=[],e.halogenpnts=[],e.picationpnts=[],e.pistackingpnts=[]}}class gt{constructor(e){this.icn3d=e}calculateIonicInteractions(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(0===Object.keys(e).length||0===Object.keys(t).length)return;r.resid2Residhash={};let a,d,c={},h={},p=s*s;for(let t in e){let s=e[t];if("ARG"===s.resn&&"NH2"===s.name||"GLU"===s.resn&&"OE2"===s.name||"ASP"===s.resn&&"OD2"===s.name)continue;let i=("LYS"===s.resn||"HIS"===s.resn)&&"N"===s.elem&&"N"!==s.name||"ARG"===s.resn&&("NH1"===s.name||"NH2"===s.name)||s.het&&-1!==o.parasCls.cationsTrimArray.indexOf(s.elem)||s.het&&"N"===s.elem&&1==s.bonds.length,n=this.isAnion(s);i=r.bOpm?i&&"DUM"!==s.resn:i,n=r.bOpm?n&&"DUM"!==s.resn:n,(i||n)&&(a=s.structure+"_"+s.chain+"_"+s.resi,d=a+"_"+s.name,i&&(c[d]=s),n&&(h[d]=s))}let m={},u={};for(let e in t){let i=t[e];if("ARG"===i.resn&&"NH2"===i.name||"GLU"===i.resn&&"OE2"===i.name||"ASP"===i.resn&&"OD2"===i.name)continue;let g=("LYS"===i.resn||"HIS"===i.resn)&&"N"===i.elem&&"N"!==i.name||"ARG"===i.resn&&("NH1"===i.name||"NH2"===i.name)||i.het&&-1!==o.parasCls.cationsTrimArray.indexOf(i.elem),f=this.isAnion(i);if(g=r.bOpm?g&&"DUM"!==i.resn:g,f=r.bOpm?f&&"DUM"!==i.resn:f,g||f){a=i.structure+"_"+i.chain+"_"+i.resi,d=a+"_"+i.name;let e=i.resn+" $"+i.structure+"."+i.chain+":"+i.resi+"@"+i.name;void 0===r.resid2Residhash[e]&&(r.resid2Residhash[e]={});let t={};g?t=h:f&&(t=c);let b,C=i.structure+"_"+i.chain+"_"+i.resi;g&&"ARG"===i.resn&&"NH1"===i.name?b=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[C],"NH2"):f&&"GLU"===i.resn&&"OE1"===i.name?b=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[C],"OE2"):f&&"ASP"===i.resn&&"OD1"===i.name&&(b=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[C],"OD2"));let y=void 0===b?i.coord:i.coord.clone().add(b.coord).multiplyScalar(.5);for(let d in t){if(a==d.substr(0,d.lastIndexOf("_")))continue;if(!r.crossstrucinter&&i.structure!=t[d].structure)continue;let c,h=t[d].structure+"_"+t[d].chain+"_"+t[d].resi;f&&"ARG"===t[d].resn&&"NH1"===t[d].name?c=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[h],"NH2"):g&&"GLU"===t[d].resn&&"OE1"===t[d].name?c=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[h],"OE2"):g&&"ASP"===t[d].resn&&"OD1"===t[d].name&&(c=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[h],"OD2"));let b=void 0===c?t[d].coord:t[d].coord.clone().add(c.coord).multiplyScalar(.5),C=Math.abs(y.x-b.x);if(C>s)continue;let v=Math.abs(y.y-b.y);if(v>s)continue;let _=Math.abs(y.z-b.z);if(_>s)continue;let w=C*C+v*v+_*_;if(w>p)continue;"graph"!==n&&(r.saltbridgepnts.push({serial:i.serial,coord:y}),r.saltbridgepnts.push({serial:t[d].serial,coord:b}));let S=t[d].structure+"_"+t[d].chain+"_"+t[d].resi;m=o.hashUtilsCls.unionHash(m,r.residues[a]),m=o.hashUtilsCls.unionHash(m,r.residues[S]),u[a]=1,u[S]=1;let A=t[d].resn+" $"+t[d].structure+"."+t[d].chain+":"+t[d].resi+"@"+t[d].name;r.resid2Residhash[e][A]=w.toFixed(1);let x=a+"_"+i.resn+","+S+"_"+t[d].resn;l||(void 0===r.resids2inter[x]&&(r.resids2inter[x]={}),void 0===r.resids2inter[x].ionic&&(r.resids2inter[x].ionic={}),r.resids2inter[x].ionic[e+","+A]=w.toFixed(1)),void 0===r.resids2interAll[x]&&(r.resids2interAll[x]={}),void 0===r.resids2interAll[x].ionic&&(r.resids2interAll[x].ionic={}),r.resids2interAll[x].ionic[e+","+A]=w.toFixed(1)}}}let g=Object.keys(u);if("graph"!==n)for(let e=0,t=g.length;e1?1/(n-1):1;for(let n in e){let e=t.atoms[n];e.color=e.het?s.parasCls.atomColors[e.elem]||s.parasCls.defaultAtomColor:s.parasCls.thr().setHSL(3/4*(1-i++*l),1,.45),t.atomPrevColors[n]=e.color}}colorRainbow(e){let t=this.icn3d,s=t.icn3dui,i=0,n=0;e=s.hashUtilsCls.intHash(e,t.hAtoms);for(let s in e){t.atoms[s].het||++n}let l=n>1?1/(n-1):1;for(let n in e){let e=t.atoms[n];e.color=e.het?s.parasCls.atomColors[e.elem]||s.parasCls.defaultAtomColor:s.parasCls.thr().setHSL(3/4*i++*l,1,.45),t.atomPrevColors[n]=e.color}}setColorAcrossSets(e,t){let s=this.icn3d,i=s.icn3dui,n=0,l=e.length,r=l>1?1/(l-1):1;for(let l=0,o=e.length;l0)this.setMmdbChainColor();else{let e=-1,s="",l=n.parasCls.stdChainColors.length;for(let r in t){let t=i.atoms[r];t.chain!=s&&(++e,e%=l),t.het?(t.color=n.parasCls.atomColors[t.elem],i.atomPrevColors[r]=t.color):(t.color=n.parasCls.stdChainColors[e],Object.keys(i.chainsColor).length>0&&this.updateChainsColor(t),i.atomPrevColors[r]=t.color),s=t.chain}}break;case"domain":s=0,l=0;let m=Object.keys(i.tddomains);l=m.length,r=l>1?1/(l-1):1;for(let e=0,t=m.length;e1?1/(l-1):1;for(let e=0;e Defined Sets", and try it again.');break;case"secondary structure green":i.sheetcolor="green";for(let e in t){let t=i.atoms[e];t.color=t.het?n.parasCls.atomColors[t.elem]||n.parasCls.defaultAtomColor:n.parasCls.ssColors[t.ss]||n.parasCls.thr(16711935),i.atomPrevColors[e]=t.color}break;case"secondary structure yellow":case"secondary structure":i.sheetcolor="yellow";for(let e in t){let t=i.atoms[e];t.color=t.het?n.parasCls.atomColors[t.elem]||n.parasCls.defaultAtomColor:n.parasCls.ssColors2[t.ss]||n.parasCls.thr(16711935),i.atomPrevColors[e]=t.color}break;case"secondary structure spectrum":s=0,l=0;let u,g,f=[],b=-9999;for(let e in t){if(!i.proteins.hasOwnProperty(e))continue;let t=i.atoms[e];-9999==b&&(u=parseInt(e)),-9999!=b&&(t.ss!=g.ss||Math.abs(t.resi-g.resi)>1||t.ssbegin&&g.ssend)&&("coil"==g.ss||f.push([u,b]),u=e),b=parseInt(e),g=t}"coil"==g.ss||f.push([u,b]),l=f.length,r=l>1?1/(l-1):1;for(let e=0,t=f.length;e100&&(e=100);let r=(i.middB-e)*i.spanBinv1,o=(e-i.middB)*i.spanBinv2;e=90?t.color=n.parasCls.thr().setRGB(0,.325,.839):e>=70&&e<90?t.color=n.parasCls.thr().setRGB(.396,.572,.953):e>=50&&e<70?t.color=n.parasCls.thr().setRGB(1,.859,.075):e<50&&(t.color=n.parasCls.thr().setRGB(1,.49,.271))}i.atomPrevColors[e]=t.color}break;case"b factor":i.middB=50,i.spanBinv1=.02,i.spanBinv2=.02;for(let e in t){let t=i.atoms[e];if(void 0===t.b||isNaN(t.b)||0==parseInt(1e3*t.b))t.color=n.parasCls.thr().setRGB(0,1,0);else{let e=t.b;e>100&&(e=100),e=t.structure.substr(0,4)!=i.defaultPdbId&&t.structure.length>5?100-e:e;let s=(i.middB-e)*i.spanBinv1,l=(e-i.middB)*i.spanBinv2;t.color=et.b&&(o=t.b),a5?100-t.b:t.b,s=i.bfactorArray.indexOf(e)/C;t.color=s<.5?n.parasCls.thr().setRGB(2*s,2*s,1):n.parasCls.thr().setRGB(1,2*(1-s),2*(1-s))}i.atomPrevColors[e]=t.color}break;case"area":if(void 0===i.resid2area){let e=n.hashUtilsCls.cloneHash(i.hAtoms);i.hAtoms=n.hashUtilsCls.cloneHash(i.atoms),i.bCalcArea=!0,i.opts.surface="solvent accessible surface",i.applyMapCls.applySurfaceOptions(),i.bCalcArea=!1,i.hAtoms=n.hashUtilsCls.cloneHash(e)}let y=void 0!==i.midpercent?i.midpercent:35;i.spanBinv1=.02,i.spanBinv2=.02;for(let e in t){let t=i.atoms[e],s=t.structure+"_"+t.chain+"_"+t.resi+"_"+t.resn,l=n.parasCls.residueArea.hasOwnProperty(t.resn)?i.resid2area[s]/n.parasCls.residueArea[t.resn]*100:y;l>100&&(l=100);let r=(y-l)*i.spanBinv1,o=(l-y)*i.spanBinv2;t.color=l

    ";if("atom"==e){let e=["proteins","nucleotides","chemicals","ions","water"];for(let i=0,l=e.length;i[e,s.parasCls.hydrophobicValues[e]]));l.sort(((e,t)=>parseFloat(e[1])-parseFloat(t[1])));var r=l.map((e=>[e[0],Object.keys(o[e[0]])[0]]));n+="
    ","normalized hydrophobic"==e?(n+="Dark green (W, F, L, I, Y, M, V, C): Hydrophobic
    ",n+="Light green (P, T, S, A, Q, N, G): Polar
    ",n+="Grey: Charged, not hydrophobic

    "):(n+="Green (W, F, L, I, Y, M, V, C): Hydrophobic
    ",n+="Yellow (P, T, S, A, Q, N, G): Polar
    ",n+="Red: Negatively Charged
    ",n+="Blue: Positively Charged

    ");let a=0;for(let e of r)s.parasCls.residueAbbrev[e[0]]&&(n+="
    ",n+="
    ",n+=s.parasCls.residueAbbrev[e[0]]+"
    ",a%4==3&&(n+="
    "),++a);n+="
    "}else"b factor"==e?(n+="
    B factor quantitates the uncertainty for each atom. A high B factor reflects that the position is less certain.

    ",n+=s.htmlCls.clickMenuCls.setLegendHtml()):"confidence"==e?n+=s.htmlCls.clickMenuCls.setLegendHtml(!0):"exon"==e?(t.startColor="red",t.midColor="white",t.endColor="blue",t.startValue="Start",t.midValue="Middle",t.endValue="End",n+=s.htmlCls.clickMenuCls.setLegendHtml()):n="";n?($("#"+s.pre+"dl_legend_html").html(n),s.htmlCls.dialogCls.openDlg("dl_legend","Color Legend")):$("#"+s.pre+"dl_legend").hasClass("ui-dialog-content")&&$("#"+s.pre+"dl_legend").dialog("isOpen")&&$("#"+s.pre+"dl_legend").dialog("close")}getColorLegendForElem(e,t){let s=this.icn3d,i=s.icn3dui,n="",l={};for(let e in t){let t=s.atoms[e],i=void 0===t||void 0===t.color||"FFFFFF"===t.color.getHexString().toUpperCase()?"DDDDDD":t.color.getHexString();void 0===l[t.elem]&&(l[t.elem]={}),l[t.elem][i]=1}if(Object.keys(l).length>0){n+=""+e+"
    ";let t=Object.keys(l).sort();for(let e=0,s=t.length;e";for(let e in l[s])n+="
    ";n+=i.parasCls.atomnames[s.toUpperCase()]+"

    "}n+="
    "}return n}getRes2color(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=s.firstAtomObjCls.getResiduesFromAtoms(e);for(let e in l){let l=s.residues[e],r=s.firstAtomObjCls.getFirstAtomObj(l),o=t?r.resn:i.parasCls.residueAbbrev[r.resn],a=void 0===r||void 0===r.color||"FFFFFF"===r.color.getHexString().toUpperCase()?"DDDDDD":r.color.getHexString();null!=o&&(void 0===n[o]&&(n[o]={}),n[o][a]=1)}return n}getColorLegendForResidue(e){this.icn3d.icn3dui;let t="",s=this.getRes2color(e);if(Object.keys(s).length>0){t+="
    ";let e=Object.keys(s).sort(),i="",n=0;for(let l=0,r=e.length;l";for(let e in s[o])r+="
    ";r+=o+"
    ",n%4==3&&(r+="
    "),-1!=o.indexOf("(")?(t+=r,++n):i+=r}i&&(t+="
    "+i),t+="
    "}return t}getColorLegendForCharge(e){let t=this.icn3d;t.icn3dui;let s="",i=t.firstAtomObjCls.getResiduesFromAtoms(e),n={};for(let e in i){let s=t.residues[e],i=t.firstAtomObjCls.getFirstAtomObj(s);"ARG"==i.resn||"LYS"==i.resn?n.Positive=1:"HIS"==i.resn?n["Partial-Positive"]=1:"ASP"==i.resn||"GLU"==i.resn||t.nucleotides[i.serial]?n.Negative=1:n.Neutral=1}const l={Positive:"0000ff","Partial-Positive":"8080ff",Negative:"ff0000",Neutral:"888888"};let r=["Positive","Partial-Positive","Negative","Neutral"];s+="
    ";for(let e=0,t=r.length;e",s+="
    ",s+=t,s+="
    ")}return s+="
    (Charges are at pH 7)",s+="
    ",s}getColorLegendForIgstrand(e){this.icn3d.icn3dui;let t="";const s={"A Strand":"9400D3","B Strand":"ba55d3","C Strand":"0000FF","C' Strand":"6495ED","C'' Strand":"006400","D Strand":"00FF00","E Strand":"FFD700","F Strand":"FF8C00","G Strand":"FF0000",Loop:"CCCCCC"};t+="
    ";for(let e in s){t+="",t+="
    ",t+=e,t+="

    "}return t+="
    ",t}getColorLegendForIgproto(e){this.icn3d.icn3dui;let t="";const s={"Protodomain 1":"","A Strand":"0000FF","B Strand":"006400","C Strand":"FFD700","C' Strand":"FF8C00","
    Linker":"","C'' Strand":"FF0000","
    Protodomain 2":"","D Strand":"0000FF","E Strand":"006400","F Strand":"FFD700","G Strand":"FF8C00","":"",Loop:"CCCCCC"};t+="
    A protodomain is a supersecondary structure
    that by its duplication, symmetry operations
    can generate a structural domain.

    ";for(let e in s){let i=s[e];t+="",i&&(t+="
    "),t+=e,t+="

    "}return t+="
    ",t}}class vt{constructor(e){this.icn3d=e}async showCddSiteAll(){let e=this.icn3d,t=e.icn3dui,s=this;e.chainid2pssmid={};let i=$.map(e.protein_chainid,(function(e){return e})),n=Object.keys(e.protein_chainid),l="https://www.ncbi.nlm.nih.gov/Structure/cdannots/cdannots.fcgi?fmt&frclive&live=lcl&queries="+i;if(1==Object.keys(e.structures).length&&!t.cfg.afid&&(t.cfg.mmtfid||t.cfg.pdbid||t.cfg.opmid||t.cfg.mmdbid||t.cfg.gi||t.cfg.uniprotid||t.cfg.blast_rep_id||t.cfg.cid||t.cfg.mmcifid)||2==Object.keys(e.structures).length&&t.cfg.align){let e={};try{t.bNode?e=await t.getAjaxPromise(l,"jsonp"):e.value=await t.getAjaxPromise(l,"jsonp"),s.parseCddData([e],n)}catch(e){return void s.getNoCdd(i)}}else{let i=[];for(let s=0,r=n.length;s',p=h,m=h,u=d.doms;n.bNode&&!i.resid2cdd[c]&&(i.resid2cdd[c]=[]);let g=l.setDomainFeature(u,c,!0,h,p,m);i.chainid2pssmid[c]={pssmid2name:g.pssmid2name,pssmid2fromArray:g.pssmid2fromArray,pssmid2toArray:g.pssmid2toArray};let f=g.acc2domain;h=g.html+"",p=g.html2+"",m=g.html3+"",$("#"+i.pre+"dt_cdd_"+c).html(h),$("#"+i.pre+"ov_cdd_"+c).html(p),$("#"+i.pre+"tt_cdd_"+c).html(m),h='
    ',p=h,m=h;let b=d.motifs;n.bNode&&!i.resid2site[c]&&(i.resid2site[c]=[]),g=l.setDomainFeature(b,c,!1,h,p,m,f),h=g.html,p=g.html2,m=g.html3;let C=a.data[e].sites,y=void 0!==C?C.length:0;for(let e=0;e17&&(s=s.substr(0,17)+"...");let l,r=C[e].title,o=[];for(let t=0,s=C[e].locs.length;t'+s+"
    ",u=''+t.toString()+" Res",g='';m+=d+u+"
    ",h+=d+u+g,p+=d+u+g;let f="site"+e.toString(),b=0,y=0,v=1;i.seqStartLen&&i.seqStartLen[c]&&(p+=i.showSeqCls.insertMulGapOverview(c,i.seqStartLen[c])),i.seqStartLen&&i.seqStartLen[c]&&(h+=i.showSeqCls.insertMulGap(i.seqStartLen[c],"-"));for(let t=0,s=i.giSeq[c].length;t1&&(l=s[0]+"..");let r=i.ParserUtilsCls.getResi(c,t);if(h+=''+s+"",n.bNode){let t={};t[c+"_"+r]="site: "+C[e].title,i.resid2site[c].push(t)}p+=i.showSeqCls.insertGapOverview(c,t);let o=n.cfg.blast_rep_id==c?Math.round(i.seqAnnWidth*t/(i.maxAnnoLength+i.nTotalGap)-b-y):Math.round(i.seqAnnWidth*t/i.maxAnnoLength-b-y);o>=0&&(p+='
     
    ',p+='
     
    ',b+=o,y+=v)}else h+="-";i.seqStartLen&&i.seqStartLen[c]&&(h+=i.showSeqCls.insertMulGap(i.seqEndLen[c],"-")),g=' '+t.toString()+" Residues",g+="
    ",g+="
    ",h+=g,p+=g}h+="",p+="",m+="",$("#"+i.pre+"dt_site_"+c).html(h),$("#"+i.pre+"ov_site_"+c).html(p),$("#"+i.pre+"tt_site_"+c).html(m)}}for(let e in i.protein_chainid)r.hasOwnProperty(e)||($("#"+i.pre+"dt_cdd_"+e).html(""),$("#"+i.pre+"ov_cdd_"+e).html(""),$("#"+i.pre+"tt_cdd_"+e).html(""),$("#"+i.pre+"dt_site_"+e).html(""),$("#"+i.pre+"ov_site_"+e).html(""),$("#"+i.pre+"tt_site_"+e).html(""));i.showAnnoCls.enableHlSeq(),i.bAjaxCddSite=!0}getNoCdd(e){let t=this.icn3d;t.icn3dui,console.log("No CDD data were found for the protein "+e+"...");for(let e in t.protein_chainid)$("#"+t.pre+"dt_cdd_"+e).html(""),$("#"+t.pre+"ov_cdd_"+e).html(""),$("#"+t.pre+"tt_cdd_"+e).html(""),$("#"+t.pre+"dt_site_"+e).html(""),$("#"+t.pre+"ov_site_"+e).html(""),$("#"+t.pre+"tt_site_"+e).html("");t.showAnnoCls.enableHlSeq(),t.bAjaxCddSite=!0}setDomainFeature(e,t,s,i,n,l,r){let o,a,d,c=this.icn3d,h=c.icn3dui;s&&(r={},o={},a={},d={});let p=void 0!==e?e.length:0,m=s?14:19,u=s?100:120;for(let g=0;gm&&(v=v.substr(0,m)+"...");let _=b+": "+C;s&&(o[p]=C);let w=e[g].locs;if(w)for(let e=0,r=w.length;e'+v+" ",I=''+S.toString()+" Res";l+=R+I+"
    ";let T='';i+=R+I+T,s&&(n+='
    '),n+='
    '+v+"
    ",n+=I+T;let E=b+g.toString();c.seqStartLen&&c.seqStartLen[t]&&(i+=c.showSeqCls.insertMulGap(c.seqStartLen[t],"-"));for(let e=0,n=c.giSeq[t].length;e1&&(l=n[0]+"..");let r=c.ParserUtilsCls.getResi(t,e);if(i+=''+n+"",h.bNode){let e={};e[t+"_"+r]=_,s?c.resid2cdd[t].push(e):c.resid2site[t].push(e)}}else i+="-";c.seqStartLen&&c.seqStartLen[t]&&(i+=c.showSeqCls.insertMulGap(c.seqEndLen[t],"-"));let P=c.firstAtomObjCls.getFirstCalphaAtomObj(c.chains[t]),M=void 0===P.color||"FFFFFF"===P.color.getHexString()?"DDDDDD":P.color.getHexString(),D=void 0!==P.color?M:"CCCCCC";if(c.seqStartLen&&c.seqStartLen[t]&&(n+=c.showSeqCls.insertMulGapOverview(t,c.seqStartLen[t])),h.cfg.blast_rep_id!=t)for(let s=0,i=r.length;s ',n+='
    '+C+"
    "}else{let s=[],i=[];for(let e=0,t=r.length;e ',n+='
    '+C+"
    "}}T=' '+S.toString()+" Residues",T+="
    ",T+="
    ",i+=T,n+=T,s&&(n+='')}}return{html:i,html2:n,html3:l,acc2domain:r,pssmid2name:o,pssmid2fromArray:a,pssmid2toArray:d}}showAnnoType(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui,a='
    ',d=a,c=a;if(0==n.length)return $("#"+r.pre+"dt_"+s+"_"+e).html(""),$("#"+r.pre+"ov_"+s+"_"+e).html(""),void $("#"+r.pre+"tt_"+s+"_"+e).html("");let h=i;i.length>17&&(i=i.substr(0,17)+"...");let p=[];for(let e=0,t=n.length;e'+i+"
    ",f=''+m.toString()+" Res";c+=g+f+"
    ";let b='';a+=g+f+b,d+=g+f+b;let C=s,y=0,v=0;r.seqStartLen&&r.seqStartLen[e]&&(d+=r.showSeqCls.insertMulGapOverview(e,r.seqStartLen[e])),r.seqStartLen&&r.seqStartLen[e]&&(a+=r.showSeqCls.insertMulGap(r.seqStartLen[e],"-"));for(let t=0,i=r.giSeq[e].length;t1&&(c=n[0]+"..");let h=i,p=e+"_"+i,m=n+i;if("ssbond"==s){m="Residue "+p+" has disulfide bond with";let t="";if(void 0!==l[p])for(let e=0,s=l[p].length;e'+c+"",d+=r.showSeqCls.insertGapOverview(e,t);let u=o.cfg.blast_rep_id==e?Math.round(r.seqAnnWidth*t/(r.maxAnnoLength+r.nTotalGap)-y-v):Math.round(r.seqAnnWidth*t/r.maxAnnoLength-y-v);u>=0&&(d+='
     
    ',d+='
     
    ',y+=u,v+=1)}else a+="-"}r.seqStartLen&&r.seqStartLen[e]&&(a+=r.showSeqCls.insertMulGap(r.seqEndLen[e],"-")),b=' '+m.toString()+" Residues",b+="",b+="
    ",a+=b,d+=b,a+="",d+="",c+="",$("#"+r.pre+"dt_"+s+"_"+e).html(a),$("#"+r.pre+"ov_"+s+"_"+e).html(d),$("#"+r.pre+"tt_"+s+"_"+e).html(c)}setToolTip(){let e=this.icn3d;e.icn3dui,$("[id^="+e.pre+"snp]").add("[id^="+e.pre+"clinvar]").add("[id^="+e.pre+"ssbond]").add("[id^="+e.pre+"crosslink]").tooltip({content:function(){return $(this).prop("title")},show:null,close:function(e,t){t.tooltip.hover((function(){$(this).stop(!0).fadeTo(400,1)}),(function(){$(this).fadeOut("400",(function(){$(this).remove()}))}))}})}}class _t{constructor(e){this.icn3d=e}showInteraction(e,t){this.icn3d.icn3dui,this.showInteraction_base(e,t)}showInteraction_base(e,t){let s=this.icn3d,i=s.icn3dui;i.bNode&&(s.resid2contact||(s.resid2contact={}),s.resid2contact[e]||(s.resid2contact[e]=[])),void 0===s.chainname2residues&&(s.chainname2residues={});let n=Object.keys(s.chains),l=e,r=Math.round(l.indexOf("_"));if(s.firstAtomObjCls.getFirstCalphaAtomObj(s.chains[l]),void 0===s.chainname2residues[l]){s.chainname2residues[l]={};let t=n.length;if(t>100&&void 0===i.cfg.mmdbid&&void 0===i.cfg.gi&&void 0===i.cfg.blast_rep_id&&void 0===i.cfg.align&&void 0===i.cfg.chainalign)return $("#"+s.pre+"dt_interaction_"+e).html(""),void $("#"+s.pre+"ov_interaction_"+e).html("");for(let e=0;e4)continue;let o,a=s.firstAtomObjCls.getFirstCalphaAtomObj(s.chains[t]);s.chemicals.hasOwnProperty(a.serial)?o="chemical":s.nucleotides.hasOwnProperty(a.serial)?o="nucleotide":s.ions.hasOwnProperty(a.serial)?o="ion":s.proteins.hasOwnProperty(a.serial)?o="protein":s.water.hasOwnProperty(a.serial)&&(o="water");let d=s.contactCls.getAtomsWithinAtom(i.hashUtilsCls.hash2Atoms(s.chains[l],s.atoms),i.hashUtilsCls.hash2Atoms(s.chains[t],s.atoms),4);if(0==Object.keys(d).length)continue;let c={};for(let e in d){let t=s.atoms[e];c[t.structure+"_"+t.chain+"_"+t.resi]=1}let h=t.substr(t.indexOf("_")+1)+"("+o+")";s.chainname2residues[l][h]=Object.keys(c)}}let o='
    ',a=o,d=o,c=0;for(let t in s.chainname2residues[e]){let n=s.chainname2residues[e][t];if(!n)continue;let l="Interact ."+t;l.length>17&&(l=l.substr(0,17)+"...");let r="Interact ."+t,h=[];for(let e=0,t=n.length;e'+l+"
    ",g=''+p.toString()+" Res";d+=u+g+"
    ";let f='';o+=u+g+f,a+=u+g+f;let b="inter"+c.toString(),C=0,y=0,v=1;s.seqStartLen&&s.seqStartLen[e]&&(a+=s.showSeqCls.insertMulGapOverview(e,s.seqStartLen[e])),s.seqStartLen&&s.seqStartLen[e]&&(o+=s.showSeqCls.insertMulGap(s.seqStartLen[e],"-"));for(let t=0,n=s.giSeq[e].length;t1&&(d=l[0]+"..");let c=n;if(o+=''+d+"",i.bNode){let t={};t[e+"_"+c]=r,s.resid2contact[e].push(t)}a+=s.showSeqCls.insertGapOverview(e,t);let h=i.cfg.blast_rep_id==e?Math.round(s.seqAnnWidth*t/(s.maxAnnoLength+s.nTotalGap)-C-y):Math.round(s.seqAnnWidth*t/s.maxAnnoLength-C-y);h>=0&&(a+='
     
    ',a+='
     
    ',C+=h,y+=v)}else o+="-"}s.seqStartLen&&s.seqStartLen[e]&&(o+=s.showSeqCls.insertMulGap(s.seqEndLen[e],"-")),f=' '+p.toString()+" Residues",f+="
    ",f+="
    ",o+=f,a+=f,++c}o+="",a+="",d+="",$("#"+s.pre+"dt_interaction_"+e).html(o),$("#"+s.pre+"ov_interaction_"+e).html(a),$("#"+s.pre+"tt_interaction_"+e).html(d),i.utilsCls.isMobile()?(s.hlSeqCls.selectSequenceMobile(),s.hlSeqCls.selectChainMobile()):s.hlSeqCls.selectSequenceNonMobile()}}class wt{constructor(e){this.icn3d=e}async showPTM(e,t,s,i,n){let l=this.icn3d,r=l.icn3dui,o=this,a=e.substr(0,e.indexOf("_")),d=e.substr(e.indexOf("_")+1);if("afmem"==s){let t={Transmembrane:[{begin:i,end:n}]};this.setAnnoPtmTransmem("transmem",t,e)}else if(a.length>5){let t,i="https://www.ebi.ac.uk/proteins/api/features/"+a;try{t=await r.getAjaxPromise(i,"json"),o.parsePTM(t,e,s)}catch{return void o.getNoPTM(e,s)}}else{let t,i=a.substr(0,4).toLowerCase(),n="https://www.ebi.ac.uk/pdbe/api/mappings/uniprot/"+i;try{t=await r.getAjaxPromise(n,"json");let a="";l.UPResi2ResiPosPerChain||(l.UPResi2ResiPosPerChain={}),l.UPResi2ResiPosPerChain[e]={};let c=t[i].UniProt,h=!1;for(let t in c){let s=c[t].mappings;for(let i=0,n=s.length;i',o+=r,a+=r;let d=s.substr(0,s.indexOf("_"));for(let c in t){let h=t[c],p=[],m=!1;for(let e=0,t=h.length;e5?p.push(e-1):i.UPResi2ResiPosPerChain&&i.UPResi2ResiPosPerChain[s][e]&&p.push(i.UPResi2ResiPosPerChain[s][e]),!m&&i.residues.hasOwnProperty(s+"_"+e)&&(m=!0)}if(0==p.length)continue;let u=p.length,g="ptm"==e?"PTM: "+c:"Transmembrane";g.length>17&&(g=g.substr(0,17)+"...");let f=c,b='
    '+g+"
    ",C=''+u.toString()+" Res",y='';a+=b+C+"
    ",r+=b+C+y,o+=b+C+y;let v=e+l.toString(),_=0,w=0,S=1;i.seqStartLen&&i.seqStartLen[s]&&(o+=i.showSeqCls.insertMulGapOverview(s,i.seqStartLen[s])),i.seqStartLen&&i.seqStartLen[s]&&(r+=i.showSeqCls.insertMulGap(i.seqStartLen[s],"-"));for(let e=0,t=i.giSeq[s].length;e1&&(l=t[0]+"..");let a=i.ParserUtilsCls.getResi(s,e);if(r+=''+t+"",n.bNode){let e={};e[s+"_"+a]=g,i.resid2ptm[s].push(e)}o+=i.showSeqCls.insertGapOverview(s,e);let d=n.cfg.blast_rep_id==s?Math.round(i.seqAnnWidth*e/(i.maxAnnoLength+i.nTotalGap)-_-w):Math.round(i.seqAnnWidth*e/i.maxAnnoLength-_-w);d>=0&&(o+='
     
    ',o+='
     
    ',_+=d,w+=S)}else r+="-";i.seqStartLen&&i.seqStartLen[s]&&(r+=i.showSeqCls.insertMulGap(i.seqEndLen[s],"-")),y=' '+u.toString()+" Residues",y+="
    ",y+="
    ",r+=y,o+=y,++l}r+="",o+="",a+="",$("#"+i.pre+"dt_"+e+"_"+s).html(r),$("#"+i.pre+"ov_"+e+"_"+s).html(o),$("#"+i.pre+"tt_"+e+"_"+s).html(a)}getNoPTM(e,t){let s=this.icn3d;s.icn3dui,console.log("No PTM data were found for the chain "+e+"...");let i="ptm"==t?"ptm":"transmem";$("#"+s.pre+"dt_"+i+"_"+e).html(""),$("#"+s.pre+"ov_"+i+"_"+e).html(""),$("#"+s.pre+"tt_"+i+"_"+e).html(""),s.showAnnoCls.enableHlSeq(),s.bAjaxPTM=!0}}class St{constructor(e){this.icn3d=e}showCrosslink(e,t){let s=this.icn3d;s.icn3dui;let i=this;void 0===s.clbondpnts?setTimeout((function(){i.showCrosslink_base(e,t)}),1e3):this.showCrosslink_base(e,t)}showCrosslink_base(e,t){let s=this.icn3d;s.icn3dui.bNode&&(s.resid2crosslink||(s.resid2crosslink={}),s.resid2crosslink[e]||(s.resid2crosslink[e]=[]));let i=t,n={},l=i.substr(0,i.indexOf("_")),r=s.clbondpnts[l];if(void 0===r)return $("#"+s.pre+"dt_crosslink_"+e).html(""),$("#"+s.pre+"ov_crosslink_"+e).html(""),void $("#"+s.pre+"tt_crosslink_"+e).html("");for(let e=0,t=r.length;e',a=o,d=o,c=e.indexOf("_"),h=e.substr(c+1);if(h.length>1&&"1"==h.substr(h.length-1)&&(h=h.substr(0,h.length-1)),s)n=e,i=t.domains[e]?t.domains[e].domains:[];else{let e,s=t.moleculeInfor;for(let t in s)if(s[t].chain===h){e=t,n=s[t].name;break}void 0!==e&&void 0!==t.domains[e]&&(i=t.domains[e].domains),void 0===i&&(i=[])}for(let t=0,s=i.length;t17?s.substr(0,17)+"...":s,h=i[t].intervals,p={},m={},u=[],g=[],f={},b=0;for(let e=0,t=h.length;e'+c+" ",y=''+b.toString()+" Res";d+=C+y+"
    ";let v='';o+=C+y+v,a+=C+y+v;let _="domain3d"+t.toString();l.seqStartLen&&l.seqStartLen[e]&&(o+=l.showSeqCls.insertMulGap(l.seqStartLen[e],"-"));for(let t=0,s=l.giSeq[e].length;t1&&(n=i[0]+"..");let r=s;o+=''+i+""}else o+="-"}l.seqStartLen&&l.seqStartLen[e]&&(o+=l.showSeqCls.insertMulGap(l.seqEndLen[e],"-"));let w=l.firstAtomObjCls.getFirstCalphaAtomObj(l.chains[e]),S=void 0===w.color||"FFFFFF"===w.color.getHexString()?"DDDDDD":w.color.getHexString(),A=void 0!==w.color?S:"CCCCCC";if(l.seqStartLen&&l.seqStartLen[e]&&(a+=l.showSeqCls.insertMulGapOverview(e,l.seqStartLen[e])),r.cfg.blast_rep_id!=e)for(let i=0,n=u.length;i ',a+='"}else{let i=[],n=[];for(let e=0,t=u.length;e ',a+='"}}v=' '+b.toString()+" Residues",v+="",v+="
    ",o+=v,a+=v}o+="",a+="",d+="",$("#"+l.pre+"dt_domain_"+e).html(o),$("#"+l.pre+"ov_domain_"+e).html(a),$("#"+l.pre+"tt_domain_"+e).html(d)}}class xt{constructor(e){this.icn3d=e}async showSnp(e,t){this.icn3d.icn3dui,await this.showSnpClinvar(e,t,!0)}async showClinvar(e,t){this.icn3d.icn3dui,await this.showSnpClinvar(e,t,!1)}async showSnpClinvar(e,t,s){let i=this.icn3d.icn3dui,n=this,l=i.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainid="+t;try{let r=await i.getAjaxPromise(l,"jsonp"),o=r.snpgi,a=r.gi;if(s)await n.showSnpPart2(e,t,o);else{let s=o;[6137708,1942289,224510717,2624886,253723219,2554905,75765331,3660278,312207882,319443632,342350956,1827805,109157826,1065265,40889086,6730307,163931185,494469,163931091,60594093,55669745,18655489,17942684,6980537,166235465,6435586,4139398,4389047,364506122,78101667,262118402,20664221,2624640,158430173,494395,28948777,34810587,13399647,3660342,261278854,342350965,384482350,378792570,15988303,213424334,4558333,2098365,10835631,3318817,374074330,332639529,122919696,4389286,319443573,2781341,67464020,194709238,210061039,364506106,28949044,40889076,161172338,17943181,4557976,62738484,365813173,6137343,350610552,17942703,576308,223674070,15826518,1310997,93279697,4139395,255311799,157837067,361132363,357380836,146387678,383280379,1127268,299856826,13786789,1311054,46015217,3402130,381353319,30750059,218766885,340707375,27065817,355333104,2624634,62738384,241913553,304446010].includes(a)&&(s=a),await n.showClinvarPart2(e,t,s)}}catch(t){return void(s?n.processNoSnp(e):n.processNoClinvar(e))}}navClinVar(e){let t=this.icn3d;t.icn3dui;let s=this;t.currClin[e]=-1,$(document).on("click","#"+t.pre+e+"_prevclin",(function(t){let i=s.icn3d;t.stopImmediatePropagation();let n=void 0!==i.resi2disease_nonempty[e]?Object.keys(i.resi2disease_nonempty[e]).length:0;--i.currClin[e],i.currClin[e]<0&&(i.currClin[e]=n-1),s.showClinVarLabelOn3D(e)})),$(document).on("click","#"+t.pre+e+"_nextclin",(function(t){let i=s.icn3d;t.stopImmediatePropagation();let n=void 0!==i.resi2disease_nonempty[e]?Object.keys(i.resi2disease_nonempty[e]).length:0;++i.currClin[e],i.currClin[e]>n-1&&(i.currClin[e]=0),s.showClinVarLabelOn3D(e)}))}showClinVarLabelOn3D(e){let t,s,i=this.icn3d,n=i.icn3dui,l=Object.keys(i.resi2disease_nonempty[e]);t=e,s=t+"_"+(parseInt(l[i.currClin[e]])+i.baseResi[e]).toString();let r="",o=i.resi2disease_nonempty[e][l[i.currClin[e]]];for(let e=0,t=o.length;e0?o[0]:"N/A");let a=i.applyCenterCls.centerAtoms(n.hashUtilsCls.hash2Atoms(i.residues[s],i.atoms));r.length>30&&(r=r.substr(0,30)+"..."),i.selectionCls.removeSelection(),null==i.labels&&(i.labels={}),i.labels.clinvar=[];let d=i.LABELSIZE,c="black"!=i.opts.background?i.colorWhitebkgd:i.colorBlackbkgd;i.analysisCls.addLabel(r,a.center.x+1,a.center.y+1,a.center.z+1,d,c,void 0,"clinvar"),i.hAtoms={};for(let e in i.residues[s])i.hAtoms[e]=1;$("#clinvar_"+i.pre+s).addClass("icn3d-highlightSeq"),void 0===$("#"+i.pre+"modeswitch")[0]||$("#"+i.pre+"modeswitch")[0].checked||i.definedSetsCls.setMode("selection"),i.drawCls.draw()}getSnpLine(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g){let f=this.icn3d,b=f.icn3dui,C="",y=m?"clinvar":"snp",v=!1;for(let e in i){for(let t=0,s=i[e].length;t(from human)",i=" (based on human sequences and mapped to this structure by sequence similarity)"),C+=m?'":'"}else if(2==e&&m){let e=b.utilsCls.isMobile()?"none":"button";C+='
    ',C+='
    '}else C+='
    ';let _=y,w=0,S=0,A={},x={};for(let t=1,i=f.giSeq[h].length;t<=i;++t)if(void 0!==r[t]){++w;let i="";for(let n=0,r=s[t].length;n'+k+" Res":'',u)return C+"
    ";C+='';let O="",R=0,I=0;p?f.seqStartLen&&f.seqStartLen[h]&&(C+=f.showSeqCls.insertMulGapOverview(h,f.seqStartLen[h])):f.seqStartLen&&f.seqStartLen[h]&&(C+=f.showSeqCls.insertMulGap(f.seqStartLen[h],"-"));for(let t=1,a=f.giSeq[h].length;t<=a;++t)if(p){if(void 0!==r[t]){let e=f.giSeq[h][t-1],i=e;e.length>1&&(i=e[0]+"..");let n=f.ParserUtilsCls.getResi(h,t-1)+i+">";for(let e=0,i=s[t].length;e=0&&(C+='
     
    ',C+='
     
    ',R+=r,I+=1):r>0&&(C+='
     
    ',C+='
     
    ',R+=r,I+=1)}}else if(C+=f.showSeqCls.insertGap(h,t-1,"-"),void 0!==r[t])if(m||1!=e){let r=f.giSeq[h][t-1],a=r;r.length>1&&(a=r[0]+"..");let d,c=f.ParserUtilsCls.getResi(h,t-1),p="",u="
    ",y=s[t].length,v=0,w=0;if(2==e&&(v=0,w=y),m){d=1;let r=0;for(let e=v;e0?w+="; ":0!==e&&1!==e||(O='disease="'+v[t]+'"'),w+=v[t]+"("+_[t]+")",++S;""!=w&&(r"+s[t][e],u+=": "+w,C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(m,"snpin3d","3D with scap","SNP in 3D with scap",70,g)+"  ",u+=f.showAnnoCls.addSnpButton(m,"snpinter","Interactions","SNP Interactions in 3D",70,g)+"  ",u+=f.showAnnoCls.addSnpButton(m,"snppdb","PDB","Download SNP PDB",35,g)),u+="
    Links: ClinVar, dbSNP(rs"+i[t][e]+")",e
    "),++r)}r>d&&2==e&&(p+="..")}else{d=1;for(let e=v;e"+s[t][e],g)C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),0!=i[t][e]&&(u+="
    Link: dbSNP(rs"+i[t][e]+")"),e
    ");else{let s=l[t][e].split("; "),a=o[t][e].split("; "),d="",c=0;for(let t=0,i=s.length;t0?d+="; ":0!==e&&1!==e||(O='disease="'+s[t]+'"'),d+=s[t]+"("+a[t]+")",++c;""!=d?(u+=": "+d,C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),u+="
    Links: ClinVar, dbSNP(rs"+i[t][e]+")"):(C&&!b.cfg.hidelicense&&(u+="
    "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+"  ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),u+="
    Link: dbSNP(rs"+i[t][e]+")"),e
    ")}}y>d&&2==e&&(p+="..")}u+="
    ",m?"icn3d-clinvar"==A[t]||"icn3d-clinvar-path"==A[t]?C+=1==e?"":""==p||" "==p?"-":''+p+"":C+="-":C+=""==p||" "==p?"-":g?''+p+"":''+p+""}else C+="";else C+="-";return p||f.seqStartLen&&f.seqStartLen[h]&&(C+=f.showSeqCls.insertMulGap(f.seqEndLen[h],"-")),C+=1==e?' '+k+" Residues":'',C+="
    ",C+="
    ",C}processSnpClinvar(e,t,s,i,n){let l=this.icn3d,r=l.icn3dui,o='
    ',a=o,d=o,c='
    ',h=c,p=c,m=!i||n?e.data:e.split("\n"),u={},g={},f={};void 0===l.resi2disease_nonempty[t]&&(l.resi2disease_nonempty[t]={});let b={},C={},y={},v={},_={},w="";r.bNode&&(i?(l.resid2snp||(l.resid2snp={}),l.resid2snp[t]||(l.resid2snp[t]=[])):(l.resid2clinvar||(l.resid2clinvar={}),l.resid2clinvar[t]||(l.resid2clinvar[t]=[])));for(let e=0,s=m.length;e")+1),h=s[4],p=i?"":s[5],S=i?"":s[6],A=i?"":s[7],x=l.ParserUtilsCls.getResi(t,d-1);v[x]=1,""!=S&&(_[x]=1),g[d]=e+1,void 0===u[d]&&(u[d]=[]),u[d].push(c),void 0===C[d]&&(C[d]=[]),C[d].push(h),void 0===y[d]&&(y[d]=[]),y[d].push(p),void 0===f[d]&&(f[d]=[]),f[d].push(S),""!=S&&(void 0===l.resi2disease_nonempty[t][d]&&(l.resi2disease_nonempty[t][d]=[]),l.resi2disease_nonempty[t][d].push(S)),void 0===b[d]&&(b[d]=[]),b[d].push(A)}let S=Object.keys(v),A=Object.keys(_);if(i){let e=!1;o+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,void 0,i),o+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,void 0,i),d+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,!0,i),d+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,!0,i),a+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!0,e,void 0,i),o+="
    ",a+="
    ",d+="",$("#"+l.pre+"dt_snp_"+t).html(o),$("#"+l.pre+"ov_snp_"+t).html(a),$("#"+l.pre+"tt_snp_"+t).html(d)}else{let e=!0;c+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,void 0,i),c+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,void 0,i),p+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!1,e,!0,i),p+=this.getSnpLine(2,2,u,C,y,f,g,b,S,A,0,t,!1,e,!0,i),h+=this.getSnpLine(1,2,u,C,y,f,g,b,S,A,1,t,!0,e,void 0,i),c+="",h+="",p+="",$("#"+l.pre+"dt_clinvar_"+t).html(c),$("#"+l.pre+"ov_clinvar_"+t).html(h),$("#"+l.pre+"tt_clinvar_"+t).html(p),this.navClinVar(t,s)}l.showAnnoCls.enableHlSeq(),i?l.bAjaxSnp=!0:l.bAjaxClinvar=!0}async showClinvarPart2(e,t,s){let i=this.icn3d,n=i.icn3dui,l=this,r=n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainid_clinvar="+t;i.chainsGene[e]&&i.chainsGene[e].geneSymbol&&(r+="&gene="+i.chainsGene[e].geneSymbol);try{let s=await n.getAjaxPromise(r,"jsonp");if(s&&s.data&&s.data.length>0){let i=!1,n=s;l.processSnpClinvar(n,e,t,i)}else l.processNoClinvar(e)}catch(t){return void l.processNoClinvar(e)}}async showSnpPart2(e,t,s){let i=this.icn3d,n=i.icn3dui,l=this;if(void 0!==s){let s=n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainid_snp="+t;i.chainsGene[e]&&i.chainsGene[e].geneSymbol&&(s+="&gene="+i.chainsGene[e].geneSymbol);try{let i=await n.getAjaxPromise(s,"jsonp");if(i&&i.data&&i.data.length>0){let s=!0,n=!0;l.processSnpClinvar(i,e,t,s,n)}else l.processNoSnp(e)}catch(t){return void l.processNoSnp(e)}}else this.processNoSnp(e),console.log("No gi was found for the chain "+t+"...")}processNoClinvar(e){let t=this.icn3d;t.icn3dui,console.log("No ClinVar data were found for the protein "+e+"..."),$("#"+t.pre+"dt_clinvar_"+e).html(""),$("#"+t.pre+"ov_clinvar_"+e).html(""),t.showAnnoCls.enableHlSeq(),t.bAjaxClinvar=!0}processNoSnp(e){let t=this.icn3d;t.icn3dui,console.log("No SNP data were found for the protein "+e+"..."),$("#"+t.pre+"dt_snp_"+e).html(""),$("#"+t.pre+"ov_snp_"+e).html(""),t.showAnnoCls.enableHlSeq(),t.bAjaxSnp=!0}}class kt{constructor(e){this.icn3d=e}showSsbond(e,t){let s=this.icn3d;s.icn3dui;let i=this;void 0===s.ssbondpnts?setTimeout((function(){i.showSsbond_base(e,t)}),1e3):this.showSsbond_base(e,t)}showSsbond_base(e,t){let s=this.icn3d;s.icn3dui.bNode&&(s.resid2ssbond||(s.resid2ssbond={}),s.resid2ssbond[e]||(s.resid2ssbond[e]=[]));let i=t,n={},l=i.substr(0,i.indexOf("_")),r=s.ssbondpnts[l];if(void 0===r)return $("#"+s.pre+"dt_ssbond_"+e).html(""),$("#"+s.pre+"ov_ssbond_"+e).html(""),void $("#"+s.pre+"tt_ssbond_"+e).html("");for(let e=0,t=r.length;e-s.halfBilayerSize){i[t.structure+"_"+t.chain+"_"+t.resi]=1}}let n=Object.keys(i);s.annoCddSiteCls.showAnnoType(e,t,"transmem","Transmembrane",n)}}class Rt{constructor(e){this.icn3d=e,this.dcut=8,this.min_contacts=5,this.MAX_SSE=512,this.ctc_cnt=[];for(let e=0;e=this.curr_ratio+.01||f>this.split_ratio)return e;if(f>this.curr_ratio-.01&&Math.min(m,u)=0&&l[i]==t-e+i;i--);if(i<0)break;for(l[i]++,s=i+1;s-1;i++);for(l=Math.min(i-1,this.max_csz),this.curr_ne0=this.curr_ne1=0,this.curr_ratio=100,s=1;s<=l;s++)this.cut_size(s,i);if(this.top--,0==this.curr_ne0){for(n=this.stack[this.top],e=n;e-1;e++)this.parts[this.np++]=this.elements[e];this.parts[this.np++]=-1,this.n_doms++}else{if(this.save_ratios[this.saved++]=this.curr_ratio,this.curr_ne0>this.min_sse){for(n=this.stack[this.top],e=0;ethis.min_sse){for(n=this.stack[this.top],e=0;e0;)this.process_set()}output(e){let t,s;this.icn3d.icn3dui;let i=[];for(t=0;t<2*e;t++)i.push(0);for(t=s=0;st+n)break;let p=(t-a)*(t-a);p+=(s-c)*(s-c),p+=(i-h)*(i-h);let m=Math.sqrt(p);if(m>n)continue;let u={},g={};parseInt(e.rnum)this.MAX_SSE)return{subdomains:a,substruct:o,pos2resi:u};let f=h.length,b=f,C=this.c2b_AlphaContacts(f,i,n,l,t,r),y=[];for(let e=0;e=this.min_contacts&&(k[s]||(k[s]={}),k[i]||(k[i]={}),k[s][i]=1,k[i][s]=1)}let O=0,R={};this.groupnum2sheet={},this.visited={};for(let e in k)this.visited[e]=!1;for(let e in k)0==this.visited[e]&&(O++,this.countUtil(e,k,O));for(let e in this.groupnum2sheet){let t=this.groupnum2sheet[e].sort();for(let e=0,s=t.length;e0&&this.elt_size[s.sse-1]>=6&&0!=s.adj_strand2&&e++}for(let e=0;e0)for(let e=0;e0){let e=0;for(let t=0;t<=T;t++){let t=[];for(;e<2*g;){let s=this.parts[e++];if(0==s){E.push(t);break}t.push(s)}}}E.sort((function(e,t){return e[0]-t[0]}));for(let e=0,t=E.length;e=o.length)return{subdomains:a,substruct:o,pos2resi:u};let n=o[i],l=n.From,r=n.To;for(let e=l;e<=r;e++)s[e]=1;if(0==i&&l>1)for(let e=1;e0){let e=o[i-1].To,t=parseInt(.5*(l-e-1));if(t>0)for(let e=l-t;e<=l-1;e++)s[e]=1}if(i0)for(let e=r+1;e<=r+t;e++)s[e]=1}}let i,n=!1,l=[];for(let e=0;e0&&(h+=", "),h+='{"ss": [';let t=0;for(let i=0,n=l[e].length;i=n&&m<=a&&(t>0&&(h+=", "),h+="["+i+","+p+","+m+","+r[e].x1.toFixed(2)+","+r[e].y1.toFixed(2)+","+r[e].z1.toFixed(2)+","+r[e].x2.toFixed(2)+","+r[e].y2.toFixed(2)+","+r[e].z2.toFixed(2)+"]",++t))}}h+="]",h+=', "domain": [';let n=0;for(let t=0,r=l[e].length;t=r&&l<=o&&(n>0&&(h+=", "),h+="["+l+","+c+","+a.coord.x.toFixed(2)+","+a.coord.y.toFixed(2)+","+a.coord.z.toFixed(2)+"]",++n)}}h+="]}"}return h+="]}",h}}class It{constructor(e){this.icn3d=e}clickAddTrackButton(){let e=this.icn3d,t=e.icn3dui,s=this;t.myEventCls.onIds("#"+e.pre+"addtrack_button1","click",(async function(e){let i=s.icn3d;e.stopImmediatePropagation(),dialog.dialog("close");let n=$("#"+i.pre+"track_chainid").val(),l=$("#"+i.pre+"track_gi").val(),r=isNaN(l)?"Acc "+l:"gi "+l,o=t.htmlCls.baseUrl+"pwaln/pwaln.fcgi?from=track",a={targets:n,queries:l},d=await t.getAjaxPostPromise(o,a);s.alignSequenceToStructure(n,d,r)})),t.myEventCls.onIds("#"+e.pre+"addtrack_button2","click",(async function(e){let i=s.icn3d;e.stopImmediatePropagation(),dialog.dialog("close");let n=$("#"+i.pre+"track_chainid").val(),l=$("#"+i.pre+"track_fasta").val(),r=$("#"+i.pre+"fasta_title").val(),o=n.substr(0,n.indexOf("_")),a=n;if(5==o.length)a=a.substr(0,4);else if(o.length>5){a="";for(let e=0,t=i.chainsSeq[n].length;e8||d.length<6)&&(a=!1),d.length<9&&(o=!1),d[0];let c,h,p=d[1],m=d[2],u=d[3];d.length,d.length>5&&(c=d[5]),d.length,d.length,d.length>8&&(h=d[8]),d.length,d.length,d.length;let g=u,f="51,51,51";o?f=h:a&&("+"==c&&l.length>0?f=l[0]:"-"==c&&l.length>1?f=l[1]:"."==c&&l.length>2&&(f=l[2]));let b="",C=[];for(let e=0,t=m;e1&&(s=t[0]);let l=i.ParserUtilsCls.getResi(n,e);if(a.hasOwnProperty(n+"_"+l)){let e=i.firstAtomObjCls.getFirstCalphaAtomObj(i.residues[n+"_"+l]),t=void 0===e.color||"FFFFFF"===e.color.getHexString().toUpperCase()?"DDDDDD":e.color.getHexString(),o=void 0!==e.color?t:"CCCCCC";r+=s,d.push("#"+o)}else r+="-",d.push("")}s.showNewTrack(n,l,r,d,void 0,"selection",void 0),t.htmlCls.clickMenuCls.setLogCmd("add track | chainid "+n+" | title "+l+" | text "+s.simplifyText(r)+" | type selection",!0)}))}showNewTrack(e,t,s,i,n,l,r,o,a,d,c,h){let p=this.icn3d,m=p.icn3dui,u=!1;"cannot be aligned"==s&&(u=!0);let g=s.replace(/-/g,"").length;if(!o)if(s.length>p.giSeq[e].length)s=s.substr(0,p.giSeq[e].length);else if(s.length20&&(f=f.substr(0,20));let b=m.htmlCls.RESIDUE_WIDTH*s.length+200;$("#"+p.pre+"dt_custom_"+e).append("
    "),$("#"+p.pre+"dt_custom_"+e+"_"+f).width(b),$("#"+p.pre+"ov_custom_"+e).append("
    "),$("#"+p.pre+"ov_custom_"+e+"_"+f).width(b),$("#"+p.pre+"tt_custom_"+e).append("
    "),$("#"+p.pre+"tt_custom_"+e+"_"+f).width(b);let C='
    ',y=C,v=C,_=C,w=C,S=parseInt(10*Math.random()),A='",x='
    Exons
    ',k=''+g.toString()+" Pos";_+=A+k+"
    ",w+=x+k+"
    ";let O='';C+=A+k+O,y+=x+k+O,v+=A+k+O;let R=e.indexOf("_"),I="cst"+e.substr(R+1),T=0,E=0,P=(void 0===l||"seq"===l||"custom"===l)&&-1==s.indexOf("cannot-be-aligned")&&-1==s.indexOf("cannot be aligned"),M="identity"===l&&-1==s.indexOf("cannot-be-aligned")&&-1==s.indexOf("cannot be aligned"),D={},H=0;A="";let F={},L={},N={},q=0;if(h)for(let e=0,t=h.length;e"+d+"";let g='style="background-color:'+F[q]+'"';y+=' ";for(let t in p.residues[e+"_"+u]){let e=p.atoms[t];e.color=m.parasCls.thr(F[q]),p.atomPrevColors[t]=e.color}A+=p.showSeqCls.insertGapOverview(e,t);let f=Math.round(p.seqAnnWidth*t/(p.maxAnnoLength+p.nTotalGap)-T-E);f<0&&(f=0),A+='
     
    ',s=void 0!==i&&""!=i[t]?i[t]:r?"rgb("+r+")":P?"#"+c:"#333",A+='
     
    ',T+=f,E+=1,++q}else u?C+=""+d+"":(C+="-",y+="")}if(void 0!==a){A="";let s=[],i=[];for(let e=0,t=a.length;e 
    ',h){let t,s;n=d[l]-a[l]+1;let i,r,o,c=m,p=m+n-1;m+=n;for(let e=0,i=h.length;e=i&&c<=n&&(t={exonIndex:e,rangeStart:i,rangeEnd:n,from:c,genomeRange:h[e].genomeRange}),p>=i&&p<=n&&(s={exonIndex:e,rangeStart:i,rangeEnd:n,to:p,genomeRange:h[e].genomeRange})}if(t&&s&&t.exonIndex==s.exonIndex)i=this.getExonColor(t.rangeStart,t.rangeEnd,c),r=this.getExonColor(t.rangeStart,t.rangeEnd,p),o=i+" 0%, #FFF 50%, "+r+" 100%",A+=this.getExonHtml(t.exonIndex,o,t.from,s.to,t.genomeRange,e,f);else if(t&&(i=this.getExonColor(t.rangeStart,t.rangeEnd,c),o=i+" 0%, #FFF 50%, #00F 100%",A+=this.getExonHtml(t.exonIndex,o,t.from,t.rangeEnd,t.genomeRange,e,f)),t&&s){for(let i=t.exonIndex+1;i'+t+""}}O=''+g.toString()+" Pos",O+="",O+="
    ",O+="",C+=O,v+=A+O,y+=O,_+="",w+="",h?($("#"+p.pre+"dt_custom_"+e+"_"+f).html(y+C),$("#"+p.pre+"ov_custom_"+e+"_"+f).html(v),$("#"+p.pre+"tt_custom_"+e+"_"+f).html(w+_)):($("#"+p.pre+"dt_custom_"+e+"_"+f).html(C),$("#"+p.pre+"ov_custom_"+e+"_"+f).html(v),$("#"+p.pre+"tt_custom_"+e+"_"+f).html(_))}getExonHtml(e,t,s,i,n,l,r){let o=this.icn3d;return o.icn3dui,''}getExonColor(e,t,s){this.icn3d.icn3dui;let i=.5*(e+t);if(s1e-200&&(h=parseFloat(h).toExponential()),n.scores.bit_score;let p=t.targets[l].seqdata,m=i.seqdata,u=n.segs;for(let e=0,t=u.length;e0&&(l=n+"H"+d.toString().padStart(2,"0")+")","coil"==t&&(s.selectionCls.selectResidueList(r,l,l,o,a),o||(o=!0)),r={})),n=e+"_H"+d.toString().padStart(2,"0"),r[p]=1,i.ssend&&(h=e+"_C(H"+d.toString().padStart(2,"0"),"helix"==t&&(s.selectionCls.selectResidueList(r,n,n,o,a),o||(o=!0)),r={})):"E"==m?(i.ssbegin&&(++c,Object.keys(r).length>0&&(l=n+"S"+c.toString().padStart(2,"0")+")","coil"==t&&(s.selectionCls.selectResidueList(r,l,l,o,a),o||(o=!0)),r={})),n=e+"_S"+c.toString().padStart(2,"0"),r[p]=1,i.ssend&&(h=e+"_C(S"+c.toString().padStart(2,"0"),"sheet"==t&&(s.selectionCls.selectResidueList(r,n,n,o,a),o||(o=!0)),r={})):(n=h+"-",r[p]=1)}}Object.keys(r).length>0&&(l=n+"Cterm)","coil"==t&&s.selectionCls.selectResidueList(r,l,l,o,a))}defineIgstrand(e,t){let s=this.icn3d,i=s.icn3dui;$("#"+s.pre+"dl_definedsets").hasClass("ui-dialog-content")&&$("#"+s.pre+"dl_definedsets").dialog("isOpen")||(i.htmlCls.dialogCls.openDlg("dl_definedsets","Select sets"),$("#"+s.pre+"atomsCustom").resizable());let n,l,r,o,a,d={},c=!1,h=!0,p=0,m=0,u="NT";s.hAtoms={};let g=!1;for(let i=0,f=s.chainsSeq[e].length;i0&&("igstrand"==a?(++p,n="Strand-"+r+"-"+e+"-"+p.toString().padStart(3,"0"),n=n.replace(/'/g,"`"),"igstrand"==t&&(s.selectionCls.selectResidueList(d,n,n,c,h),c||(c=!0)),u=r):"igloop"==a&&(++m,n="Loop-"+u+"_"+l+"-"+e+"-"+m.toString().padStart(3,"0"),n=n.replace(/'/g,"`"),"igloop"==t&&(s.selectionCls.selectResidueList(d,n,n,c,h),c||(c=!0))),d={}),d[C]=1,r=l,a=o,g=!0))}"igstrand"==a?(++p,n="Strand-"+r+"-"+e+"-"+p.toString().padStart(3,"0"),n=n.replace(/'/g,"`"),"igstrand"==t&&s.selectionCls.selectResidueList(d,n,n,c,h)):"igloop"==a&&(++m,l="CT",n="Loop-"+u+"_"+l+"-"+e+"-"+m.toString().padStart(3,"0"),n=n.replace(/'/g,"`"),"igloop"==t&&s.selectionCls.selectResidueList(d,n,n,c,h))}simplifyText(e){this.icn3d.icn3dui;let t,s,i="",n=!1,l=-1;for(t=0,s=(e=e.replace(/undefined/g," ")).length;t20)return!1;if(void 0!==o.giSeq&&void 0!==o.giSeq[e]){let r=this.getFullText(s);return s=r.text,this.showNewTrack(e,t,s,void 0,void 0,i,n,l),!1}setTimeout((function(){a.checkGiSeq(e,t,s,i,n,l,r+1)}),100)}getFullText(e){this.icn3d.icn3dui;let t="",s=[],i=[],n=e.split(","),l=-1;for(let e=0,r=n.length;ep?t+=c.substr(0,p):t+=c;for(let e=0;ed&&(d=t.length,c=h),++h}o=n.htmlCls.baseUrl+"pwaln/pwaln.fcgi?from=msa";let p=e.split(","),m={};m[t]=0;for(let e=0,t=p.length;e0&&(g+=","+p.join(","));let f={targets:u,queries:g},b=await n.getAjaxPostPromise(o,f);if(!b.data)return void console.log("The protein accessions "+u+","+g+" can not be aligned...");let C=[];i.qt_start_end={};let y=[],v=[],_=Object.keys(b.targets)[0],w=b.targets[_].seqdata;p.splice(0,0,t);for(let e=0,s=p.length;eA&&(A=e)}let x=S,k=w.length-(A+1),O=[],R=[];for(let e=0,t=p.length;ea&&(a=t.length,d=c),++c}s.qt_start_end={};let m="genomeRes",u={};for(let e=0,i=h.length;ef&&(f=e)}for(let e=0,t=h.length;e0&&(d=h,o.targetGapHash[a+o.startposGiSeq]={from:a+o.startposGiSeq,to:d+m-1+o.startposGiSeq}),c=t[s],h=p,"-"!=t[s]?(++p,f=s,o.seqEndLen[e]=b-1-f,u||(g=s,o.seqStartLen[e]=g,u=!0)):++m;o.maxAnnoLength0&&(C+=" "),C+=e+"_"+o.targetGapHash[e].from+"_"+o.targetGapHash[e].to,++y;let v={};for(let a=0,d=i.length;a5?(l.uniprot2acc&&l.uniprot2acc[y]&&(y=l.uniprot2acc[y]),f=y):f=e,y.length>5){let e="";for(let t=0,s=l.chainsSeq.length;t"),d=a[1].indexOf("\n");n=a[1].substr(d+1).replace(/\n/g,"");for(let e=2,t=a.length;e0&&($("#"+e.pre+"anno_cdd")[0].checked?(this.setAnnoTabCdd(),t.htmlCls.clickMenuCls.setLogCmd("set annotation cdd",!0)):(this.hideAnnoTabCdd(),t.htmlCls.clickMenuCls.setLogCmd("hide annotation cdd",!0)))}showAnnoSelectedChains(){let e=this.icn3d,t=e.icn3dui,s={};for(let t in e.hAtoms){let i=e.atoms[t];s[i.structure+"_"+i.chain]=1}$("#"+e.pre+"dl_annotations > .icn3d-annotation").hide();for(let i in s){$("#"+e.pre+"anno_"+i).length&&$("#"+e.pre+"anno_"+i).show();let s=e.firstAtomObjCls.getFirstCalphaAtomObj(e.chains[i]);if(void 0!==s.resn){let i=t.utilsCls.residueName2Abbr(s.resn.substr(0,3));$("#"+e.pre+"anno_"+i).show()}}}showAnnoAllChains(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"dl_annotations > .icn3d-annotation").show()}setAnnoView(e){let t=this.icn3d;t.icn3dui.bNode||("detailed view"===e?(t.view="detailed view",$("#"+t.pre+"dl_anno_view_tabs").tabs("option","active",1)):(t.view="overview",$("#"+t.pre+"dl_anno_view_tabs").tabs("option","active",0)))}setAnnoDisplay(e,t){let s=this.icn3d;s.icn3dui;let i=["giseq","custom","site","ptm","snp","clinvar","cdd","domain","interaction","ssbond","crosslink","transmem"];for(let n in i){let l=i[n];$("[id^="+s.pre+t+"_"+l+"]").attr("style",e)}}showFixedTitle(){this.icn3d.icn3dui;this.setAnnoDisplay("display:block;","tt")}hideFixedTitle(){this.icn3d.icn3dui;this.setAnnoDisplay("display:none!important;","tt")}setAnnoViewAndDisplay(e){let t=this.icn3d;if(t.icn3dui,"detailed view"===e){this.setAnnoView("detailed view");let e="display:block;";this.setAnnoDisplay(e,"dt"),$("#"+t.pre+"seqguide_wrapper").attr("style",e),e="display:none;",this.setAnnoDisplay(e,"ov")}else{this.setAnnoView("overview"),this.hideFixedTitle();let e="display:none;";this.setAnnoDisplay(e,"dt"),$("#"+t.pre+"seqguide_wrapper").attr("style",e),e="display:block;",this.setAnnoDisplay(e,"ov")}}async updateClinvar(){let e=this.icn3d;if(e.icn3dui,void 0===e.bClinvarShown||!e.bClinvarShown)for(let t in e.protein_chainid){let s=e.protein_chainid[t];await e.annoSnpClinVarCls.showClinvar(t,s)}e.bClinvarShown=!0}async updateSnp(){let e=this.icn3d;if(e.icn3dui,void 0===e.bSnpShown||!e.bSnpShown)for(let t in e.protein_chainid){let s=e.protein_chainid[t];await e.annoSnpClinVarCls.showSnp(t,s)}e.bSnpShown=!0}updateDomain(){let e=this.icn3d;e.icn3dui,void 0!==e.bDomainShown&&e.bDomainShown||e.annoDomainCls.showDomainAll(),e.bDomainShown=!0}updateInteraction(){let e=this.icn3d;if(e.icn3dui,void 0===e.bInteractionShown||!e.bInteractionShown)for(let t in e.interactChainbase){let s=e.interactChainbase[t];e.annoContactCls.showInteraction(t,s)}e.bInteractionShown=!0}async updatePTM(){let e=this.icn3d;if(e.icn3dui,void 0===e.bPTMShown||!e.bPTMShown)for(let t in e.PTMChainbase){let s=e.PTMChainbase[t];await e.annoPTMCls.showPTM(t,s,"ptm")}e.bPTMShown=!0}updateSsbond(){let e=this.icn3d;if(e.icn3dui,void 0===e.bSSbondShown||!e.bSSbondShown)for(let t in e.ssbondChainbase){let s=e.ssbondChainbase[t];e.annoSsbondCls.showSsbond(t,s)}e.bSSbondShown=!0}updateCrosslink(){let e=this.icn3d;if(e.icn3dui,void 0===e.bCrosslinkShown||!e.bCrosslinkShown)for(let t in e.crosslinkChainbase){let s=e.crosslinkChainbase[t];e.annoCrossLinkCls.showCrosslink(t,s)}e.bCrosslinkShown=!0}async updateTransmem(){let e=this.icn3d,t=e.icn3dui;if(void 0===e.bTranememShown||!e.bTranememShown)for(let s in e.protein_chainid){let i=e.protein_chainid[s];if(void 0!==t.cfg.opmid)e.annoTransMemCls.showTransmem(s,i);else if(e.bAfMem&&e.afmem_start_end){let t=e.afmem_start_end[0],n=e.afmem_start_end[1];await e.annoPTMCls.showPTM(s,i,"afmem",t,n)}else await e.annoPTMCls.showPTM(s,i,"transmem")}e.bTranememShown=!0}}class Et{constructor(e){this.icn3d=e}showAnnotations_part1(){let e=this.icn3d,t=e.icn3dui;if(t.htmlCls.dialogCls.openDlg("dl_selectannotations","Sequences and Annotations"),(void 0===e.bAssemblyNote||!e.bAssemblyNote)&&void 0!==e.asuCnt){let t="
    Assembly Tips: Only the asymmetric unit is shown in the sequence window.
    Click \"Assembly\" in the menu \"View\" to switch between asymmetric unit and biological assembly("+e.asuCnt+" asymmetric unit).
    ";$("#"+e.pre+"dl_annotations_tabs").append(t),e.bAssemblyNote=!0}e.bResetAnno&&(e.giSeq={},e.currClin={},e.resi2disease_nonempty={},e.baseResi={},e.matchedPos={},$("#"+t.pre+"dl_annotations").empty(),e.annotationCls.setAnnoView("overview"));let s={},i={},n={};if(void 0===e.bAnnoShown||!e.bAnnoShown||e.bResetAnno){e.protein_chainid={};let l,r=Object.keys(e.chains);void 0===e.giSeq&&(e.giSeq={}),void 0===e.currClin&&(e.currClin={}),void 0===e.resi2disease_nonempty&&(e.resi2disease_nonempty={}),void 0===e.baseResi&&(e.baseResi={}),void 0===e.matchedPos&&(e.matchedPos={}),l=t.bNode?500:t.cfg.notebook?t.htmlCls.WIDTH/2:$("#"+e.pre+"dl_selectannotations").dialog("option","width"),e.seqAnnWidth=l-120-60-50;for(let l=0,o=r.length;l1&&"1"==d.substr(d.length-1)?(d=d.substr(0,d.length-1),a=r[l].substr(0,r[l].indexOf("_"))+"_"+d):a=r[l],e.proteins.hasOwnProperty(o.serial)&&e.chainsSeq[r[l]].length>1)e.protein_chainid[r[l]]=a;else if(e.nucleotides.hasOwnProperty(o.serial)&&e.chainsSeq[r[l]].length>1)s[r[l]]=a;else if(e.chainsSeq[r[l]].length>1)i[r[l]]=a;else{let t=e.chainsSeq[r[l]][0].name,s=r[l]+"_"+e.chainsSeq[r[l]][0].resi;void 0===n[t]&&(n[t]=[]),n[t].push(s)}if((void 0!==t.cfg.pdbid||void 0!==t.cfg.opmid||void 0!==t.cfg.mmcifid||void 0!==t.cfg.mmtfid)&&(e.proteins.hasOwnProperty(o.serial)||e.nucleotides.hasOwnProperty(o.serial)))for(let t=0,s=e.chainsSeq[r[l]].length;te.maxAnnoLengthOri&&(e.protein_chainid.hasOwnProperty(t)||s.hasOwnProperty(t))&&(e.maxAnnoLengthOri=e.chainsSeq[t].length);e.maxAnnoLength=e.maxAnnoLengthOri}return{nucleotide_chainid:s,chemical_chainid:i,chemical_set:n}}async showAnnotations(){let e=this.icn3d,t=e.icn3dui,s=this,i=this.showAnnotations_part1(),n=i.nucleotide_chainid,l=i.chemical_chainid,r=i.chemical_set;if(!e.bAnnoShown||e.bResetAnno)if(e.bAnnoShown=!0,void 0===t.cfg.blast_rep_id){if(e.bFullUi){if(void 0!==t.cfg.mmtfid){let t=Object.keys(e.structures)[0];await e.mmcifParserCls.downloadMmcifSymmetry(t,"mmtfid")}await this.showAnnoSeqData(n,l,r)}}else if(void 0===t.cfg.blast_rep_id||e.bSmithwm||e.bLocalSmithwm){if(void 0!==t.cfg.blast_rep_id&&(e.bSmithwm||e.bLocalSmithwm)){let i,o,a=[t.cfg.blast_rep_id];if(-1!=t.cfg.query_id.indexOf(">")?o=t.cfg.query_id.substr(t.cfg.query_id.indexOf("\n")+1):!/\d/.test(t.cfg.query_id)||t.cfg.query_id.length>50?o=t.cfg.query_id:a.push(t.cfg.query_id),e.blastAcxn){let s=t.cfg.afid+"_A",n="";for(let t=0,i=e.chainsSeq[s].length;t5){let n;e.uniprot2acc&&e.uniprot2acc[i]?e.uniprot2acc[i]:e.uniprot2acc={},n="https://rest.uniprot.org/uniprotkb/search?format=json&fields=xref_geneid,gene_names&query="+i;let l=await t.getAjaxPromise(n,"json"),r=l.results[0]&&l.results[0].uniProtKBCrossReferences&&l.results[0].uniProtKBCrossReferences[0]?l.results[0].uniProtKBCrossReferences[0].id:void 0,o=l.results[0]&&l.results[0].genes&&l.results[0].genes[0]&&l.results[0].genes[0].geneName?l.results[0].genes[0].geneName.value:"ID "+r;e.chainsGene[s]={geneId:r,geneSymbol:o}}}for(let s in e.protein_chainid){let i=t.utilsCls.isMobile()?"none":"button",l=e.showSeqCls.getProteinName(s),r=l,o=0==n?"Proteins:

    ":"",a=e.chainsGene[s]&&e.chainsGene[s].geneId&&e.chainsGene[s].geneDesc?"(Gene: "+e.chainsGene[s].geneSymbol+")":"",d=s.substr(0,s.indexOf("_")),c=d.length>5?''+s+"":s,h="
    "+o+"Annotations of "+c+": "+r+""+a+"   "+this.addButton(s,"icn3d-addtrack","Add Track","Add a custom track",60,i)+"   ";h+=this.addButton(s,"icn3d-customcolor","Custom Color/Tube","Use a custom file to define the colors or tubes in 3D structure",110,i)+"   ",h+=this.addButton(s,"icn3d-helixsets","Helix Sets",'Define sets for each helix in this chain and add them to the menu of "Defined Sets"',60,i)+" "+this.addButton(s,"icn3d-sheetsets","Sheet Sets",'Define sets for each sheet in this chain and add them to the menu of "Defined Sets"',60,i)+" "+this.addButton(s,"icn3d-coilsets","Coil Sets",'Define sets for each coil in this chain and add them to the menu of "Defined Sets"',60,i),e.bShowRefnum&&e.chainid2refpdbname.hasOwnProperty(s)&&e.chainid2refpdbname[s].length>0&&(h+=" "+this.addButton(s,"icn3d-igstrandsets","Ig Strand Sets",'Define sets for each Ig strand in this chain and add them to the menu of "Defined Sets"',80,i)+" "+this.addButton(s,"icn3d-igloopsets","Ig Loop Sets",'Define sets for each Ig loop in this chain and add them to the menu of "Defined Sets"',80,i)),$("#"+e.pre+"dl_annotations").append(h);let p=["giseq","cdd","clinvar","snp","site","ptm","ssbond","crosslink","transmem","domain","custom","interaction"];for(let t in p){let i=p[t];$("#"+e.pre+"anno_"+s).append(this.getAnDiv(s,i))}$("#"+e.pre+"anno_"+s).append("


    "),++n}if(t.bNode||e.annoCddSiteCls.setToolTip(),void 0!==e.chainid_seq)await this.processSeqData(e.chainid_seq);else try{let n=[],l=[];for(let e=0,t=i.length;e=6?l.push(i[e]):n.push(i[e])}if(n.length>0){let s=t.htmlCls.baseUrl+"/vastdyn/vastdyn.cgi?chainlist="+n;e.chainid_seq=await t.getAjaxPromise(s,"jsonp")}else e.chainid_seq={};for(let t=0,s=l.length;t40&&(r=r.substr(0,40)+"...");let o="";0==i&&("protein"==s?o="Proteins:

    ":"nucleotide"==s?o="Nucleotides:

    ":"chemical"==s&&(o="Chemicals/Ions/Water:

    ")),$("#"+n.pre+"dl_annotations").append("
    "+o+""+e+": "+r+"
    "),$("#"+n.pre+"anno_"+e).append(this.getAnDiv(e,"giseq")),$("#"+n.pre+"anno_"+e).append(this.getAnDiv(e,"interaction")),$("#"+n.pre+"anno_"+e).append("


    "),n.giSeq[e]=[];for(let t=0;tChemicals/Ions/Water:

    ":"",o=t[0].lastIndexOf("_"),a=t[0].substr(0,o),d=void 0!==l.cfg.mmdbid&&void 0!==n.chainid2sid?n.chainid2sid[a]:void 0;i=void 0!==d?""+e+" ":""+e+"",$("#"+n.pre+"dl_annotations").append("
    "+r+i+"
    "),$("#"+n.pre+"anno_"+e).append("
    "),$("#"+n.pre+"anno_"+e).append("


    ");let c='
    ';c+='",c+='Count: '+t.length+"",c+='';let h=c,p=c;for(let s=0,i=t.length;s3&&(l=i.substr(0,3)),s'+l+""}let m=l.htmlCls.GREY8,u=Math.round(n.seqAnnWidth*t.length/n.maxAnnoLength);u<1&&(u=1),p+='
     
    ',c="",c+="
    ",c+="
    ",h+=c,p+=c,$("#"+n.pre+"dt_giseq_"+e).html(h),$("#"+n.pre+"ov_giseq_"+e).html(p)}async processSeqData(e){let t=this.icn3d,s=t.icn3dui;for(let i in t.protein_chainid){let n=t.protein_chainid[i];if(e.hasOwnProperty(n)){let s=e[n];t.giSeq[i]=s;let l="";for(let e=0;e<10&&e14?"Query: "+o.substr(0,6)+"...":isNaN(s.cfg.query_id)?"Query: "+o:"Query: gi "+o;let a="cannot be aligned";t.queryStart="",t.queryEnd="",t.bRender&&alert("The sequence can NOT be aligned to the structure"),t.showSeqCls.showSeq(i,n,void 0,e,l,a,r)}else if(s.cfg.blast_rep_id==i&&(void 0!==t.seqStructAlignData||void 0!==t.seqStructAlignDataSmithwm)){let e,l,r,o,a,d=s.cfg.oriQuery_id?s.cfg.oriQuery_id:s.cfg.query_id;if(e=d.length>14?"Query: "+d.substr(0,6)+"...":isNaN(s.cfg.query_id)?"Query: "+d:"Query: gi "+d,void 0!==t.seqStructAlignData){let e,s,i=t.seqStructAlignData;if(void 0!==i.data){e=i.data[0].query;let t=Object.keys(i.data[0].targets);s=i.data[0].targets[t[0]],s=void 0!==s&&s.hsps.length>0?s.hsps[0]:void 0}if(void 0!==e&&void 0!==s){l=s.scores.e_value.toPrecision(2),l>1e-200&&(l=parseFloat(l).toExponential()),s.scores.bit_score;let t=Object.keys(i.targets);r=i.targets[t[0]].seqdata,o=e.seqdata,a=s.segs}}else{let e=t.seqStructAlignDataSmithwm;l=e.score,r=e.target.replace(/-/g,""),o=e.query.replace(/-/g,""),a=[];let s=-1,i=-1,n=!1,d={};for(let t=0,l=e.target.length;t0)if(i.orifrom-ni.from-l)for(let t=n+1;t
    "+i+"
    "}addButton(e,t,s,i,n,l){return this.icn3d.icn3dui,"
    "}addSnpButton(e,t,s,i,n,l){let r=this.icn3d;return r.icn3dui,"
    "}conservativeReplacement(e,t){let s=this.icn3d.icn3dui,i=-1!==s.parasCls.b62ResArray.indexOf(e)?s.parasCls.b62ResArray.indexOf(e):s.parasCls.b62ResArray.length-1,n=-1!==s.parasCls.b62ResArray.indexOf(t)?s.parasCls.b62ResArray.indexOf(t):s.parasCls.b62ResArray.length-1;return s.parasCls.b62Matrix[i][n]>0}getColorhexFromBlosum62(e,t){let s=this.icn3d.icn3dui,i="333333";if(!e||!t)return i;e=e.toUpperCase(),t=t.toUpperCase();let n=-1!==s.parasCls.b62ResArray.indexOf(e)?s.parasCls.b62ResArray.indexOf(e):s.parasCls.b62ResArray.length-1,l=-1!==s.parasCls.b62ResArray.indexOf(t)?s.parasCls.b62ResArray.indexOf(t):s.parasCls.b62ResArray.length-1,r=s.parasCls.b62Matrix[n][l];if(void 0===r)return"333333";if(r>0){let e=221-parseInt(r/11*221),t=e<10?"0"+e.toString(16):e.toString(16);i="DD"+t+t}else{let e=221-parseInt(-1*r/4*221),t=e<10?"0"+e.toString(16):e.toString(16);i=t+t+"DD"}return i}}class Pt{constructor(e){this.icn3d=e}showSeq(e,t,s,i,n,l,r){let o,a=this.icn3d,d=a.icn3dui,c=!1;if(void 0===d.cfg.mmdbid&&void 0===d.cfg.gi&&void 0===d.cfg.blast_rep_id&&void 0===d.cfg.align&&void 0===d.cfg.chainalign&&void 0===d.cfg.mmdbafid){c=!0,o=[];for(let t=0;t10){u='
    ';let t=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]);void 0===d.cfg.mmdbid&&void 0===d.cfg.gi&&void 0===d.cfg.blast_rep_id&&void 0===d.cfg.align&&void 0===d.cfg.chainalign&&void 0===d.cfg.mmdbafid||void 0===t.resi_ori||t.resi_ori==t.resi||-1!=e.indexOf("Misc")?u+='
    ':u+='
    NCBI Residue Numbers
    ',u+='',b+=u+"
    ",g+=u+'';let s=0,i=0,n="";a.seqStartLen&&a.seqStartLen[e]&&(g+=this.insertMulGap(a.seqStartLen[e]," "));for(let t=0,l=o.length;t",l%10==0&&(g+=l);let r=e+"_"+l,o=l%10!=0&&l%10!=1&&l%10!=9;if(a.residues.hasOwnProperty(r)){let e=a.firstAtomObjCls.getFirstCalphaAtomObj(a.residues[r]);"H"==a.secondaries[r]&&e.ssbegin?(++s,n='H'+s+"",o&&(g+=n,n="")):"E"==a.secondaries[r]&&e.ssbegin?(++i,"green"==a.sheetcolor?n='S'+i+"":"yellow"==a.sheetcolor&&(n='S'+i+""),o&&(g+=n,n="")):e.ssend&&(n=""),""!=n&&o&&(g+=n,n="")}g+=""}a.seqStartLen&&a.seqStartLen[e]&&(g+=this.insertMulGap(a.seqEndLen[e]," ")),g+='',g+="",g+="
    ",g+="
    ",b+=""}u='
    ',u+='
    ',u+='',b+=u+"
    ",g+=u+'',a.seqStartLen&&a.seqStartLen[e]&&(g+=this.insertMulGap(a.seqStartLen[e],"-"));for(let t=0,s=o.length;t':'',g+=" ";else if("E"==a.secondaries[s]){a.firstAtomObjCls.getFirstCalphaAtomObj(a.residues[s]).ssend?"green"==a.sheetcolor?g+='':"yellow"==a.sheetcolor&&(g+=''):"green"==a.sheetcolor?g+='':"yellow"==a.sheetcolor&&(g+=''),g+=" "}else"c"==a.secondaries[s]?g+=' ':"o"==a.secondaries[s]&&(g+=' ');else g+="-"}a.seqStartLen&&a.seqStartLen[e]&&(g+=this.insertMulGap(a.seqEndLen[e],"-")),g+='',g+="",g+="
    ",g+="
    ",g+="",b+="",u=d.cfg.blast_rep_id===e?'
    ':'
    ';let C="Protein",y="Protein";void 0!==s&&("nucleotide"==s?(C="Nucl.",y="Nucleotide"):"chemical"==s&&(C="Chem.",y="Chemical")),u+='",u+=''+(a.baseResi[e]+1).toString()+"",b+=u+"
    ";let v='';g+=u+v,f+=u+v;let _,w=0;a.seqStartLen&&a.seqStartLen[e]&&(g+=this.insertMulGap(a.seqStartLen[e],"-"));for(let t=0,s=o.length;t1&&(i=s[0]+".."),_=a.ParserUtilsCls.getResi(e,t),a.residues.hasOwnProperty(e+"_"+_)){let n="333333";if(d.cfg.blast_rep_id==e&&void 0!==a.fullpos2ConsTargetpos&&void 0!==a.fullpos2ConsTargetpos[t+w])n=a.fullpos2ConsTargetpos[t+w].color;else{let t=a.firstAtomObjCls.getFirstCalphaAtomObj(a.residues[e+"_"+_]),s=void 0===t.color||"FFFFFF"===t.color.getHexString().toUpperCase()||"FFF"===t.color.getHexString().toUpperCase()?"DDDDDD":t.color.getHexString();n=void 0!==t.color?s:"CCCCCC"}g+=''+i+""}else i=i.toLowerCase(),g+=''+i+""}a.seqStartLen&&a.seqStartLen[e]&&(g+=this.insertMulGap(a.seqEndLen[e],"-")),d.cfg.blast_rep_id==e&&(a.opts.color=a.blastAcxn?"confidence":"conservation",a.setColorCls.setColorByOptions(a.opts,a.atoms));let S=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]),A=S.color?S.color.getHexString():"CCCCCC",x=Math.round(a.seqAnnWidth*o.length/(a.maxAnnoLength+a.nTotalGap));if(x<1&&(x=1),a.seqStartLen&&a.seqStartLen[e]&&(f+=this.insertMulGapOverview(e,a.seqStartLen[e])),d.cfg.blast_rep_id!=e)f+='";else{let t=[],s=[];t.push(0);for(let e=0,i=o.length;e';for(let i=0,n=t.length;i'+e+"
    ";f+="
    "}if(u=''+_+"",u+="",u+="
    ",g+=u,f+=u,d.cfg.blast_rep_id==e){if(void 0!==r&&""!==r){u='",u+='',b+=u+"
    ";let t='';g+=u+t,f+=u+t;let s=0,i=0,l=1;a.queryStart;for(let t=0,n=r.length;t-";else if(" "==n)g+=" ";else{let r=a.fullpos2ConsTargetpos[t].pos;if(a.residues.hasOwnProperty(e+"_"+r)){let s=a.fullpos2ConsTargetpos[t].color;g+=''+n+""}else n=n.toLowerCase(),g+=''+n+"";f+=this.insertGapOverview(e,t);let o=Math.round(a.seqAnnWidth*t/(a.maxAnnoLength+a.nTotalGap)-s-i);o>=0&&(f+='
     
    ',f+='
     
    ',s+=o,i+=l)}}u='',u+="",u+="
    ",g+=u,f+=u}u='
    '+i+"
    ",u+=''+a.queryStart+"",b+=u+"
    ";let t='';g+=u+t,f+=u+t;let s=a.queryStart;for(let t=0,i=l.length;t-":(void 0===a.fullpos2ConsTargetpos||void 0===a.fullpos2ConsTargetpos[t]||a.residues.hasOwnProperty(e+"_"+a.fullpos2ConsTargetpos[t].pos)||(i=i.toLowerCase()),g+=''+i+"",++s)}let o=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]),d=void 0===o.color||"FFFFFF"===o.color.getHexString()?"DDDDDD":o.color.getHexString(),c=void 0!==o.color?d:"CCCCCC",h=[],p=[],m="-";for(let e=0,t=l.length;e ',f+='
    '+i+"
    "}u=''+a.queryEnd+"",u+="",u+="
    ",g+=u,f+=u}if(g+="",f+="",b+="",a.giSeq[e].length>10){let t=a.firstAtomObjCls.getFirstCalphaAtomObj(a.chains[e]);if((void 0!==d.cfg.mmdbid||void 0!==d.cfg.gi||void 0!==d.cfg.blast_rep_id||void 0!==d.cfg.align||void 0!==d.cfg.chainalign||void 0!==d.cfg.mmdbafid)&&void 0!==t.resi_ori&&t.resi_ori!=t.resi&&-1==e.indexOf("Misc")){u='
    ',u+='
    ',u+='
    PDB Residue Numbers
    ',u+='',b+=u+"
    ",g+=u+'',a.seqStartLen&&a.seqStartLen[e]&&(g+=this.insertMulGap(a.seqStartLen[e],"-"));for(let t=0,s=o.length;t",e%10==0&&(g+=e+" "),g+=""}else g+=""}a.seqStartLen&&a.seqStartLen[e]&&(g+=this.insertMulGap(a.seqEndLen[e],"-")),g+='',g+="",g+="
    ",g+="
    ",g+="
    ",b+=""}if(a.bShowRefnum&&a.chainid2refpdbname.hasOwnProperty(e)&&a.chainid2refpdbname[e].length>0){let t=this.showAllRefNum(o,e);g+=t.html,b+=t.html3}if(a.bShowCustomRefnum&&a.chainsMapping.hasOwnProperty(e)){let t=!0,s=this.showRefNum(o,e,void 0,t);g+=s.html,b+=s.html3}}a.bShowRefnum&&a.hlUpdateCls.updateHlAll(),$("#"+a.pre+"dt_giseq_"+e).html(g),$("#"+a.pre+"ov_giseq_"+e).html(f),$("#"+a.pre+"tt_giseq_"+e).html(b)}showAllRefNum(e,t){let s=this.icn3d;s.icn3dui;let i="",n="",l=this.showRefNum(e,t);i+=l.html,n+=l.html3;let r=1;return l=this.showRefNum(e,t,r),i+=l.html,n+=l.html3,r=2,l=this.showRefNum(e,t,r),i+=l.html,n+=l.html3,s.bShowRefnum&&(s.opts.color="ig strand",s.setColorCls.setColorByOptions(s.opts,s.dAtoms),s.hlUpdateCls.updateHlAll(),s.drawCls.draw()),{html:i,html3:n}}showRefNum(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r="",o="";if(!n.chainid2refpdbname[t])return{html:r,html3:o};let a=n.refnumCls.getTemplateList(t),d=a.refpdbnameList,c=a.scoreList,h=a.seqidList,p=a.nresAlignList,m=d?"based on "+d+". The TM-score(s) is(are) "+c+". The sequence identitie(s) is(are) "+h+". The number of aligned residue(s) is(are) "+p+".":"",u='
    ';u+='
    ',u+=i?'
    Custom Ref. No.
    ':1==s?'
    Kabat Ref. No.
    ':2==s?'
    IMGT Ref. No.
    ':'
    IgStRAnD Ref. No.
    ',u+='',o+=u+"
    ",r+=u+'';let g=!1;for(let s=0,l=e.length;s0){g=!0;break}}if(1==s&&!g)return{html:"",html3:""};let f=!1;for(let s=0,l=e.length;s0){f=!0;break}}if(2==s&&!f)return{html:"",html3:""};let b,C,y,v,_,w,S,A,x=!1,k="",O="",R=!1,I=!1,T=1,E=!1;if(!i&&!s&&!l.bNode){let e=l.hashUtilsCls.intHash(n.chains[t],n.hAtoms),s=n.firstAtomObjCls.getResiduesFromAtoms(e);for(let e in s)delete n.residIgLoop[e]}let P,M=[],D={},H=0,F=0,L=0,N=0;if(!i&&!s){for(let s=0,i=e.length;s=0;--t)"G"!=M[t].strand.substr(0,1)&&M[t].endRefnum-M[t].startRefnum+1<3&&(t!=e-1&&(M[t+1].loopResCnt+=M[t].loopResCnt+parseInt(M[t].endResi)-parseInt(M[t].startResi)+1),M.splice(t,1));H=0;let s,i,l=0,r=!0,o=!0,a=0;E=!1;let d=0;if(M.length>0)for(let c=0,h=e.length;cM[H].endResi:parseInt(e)>parseInt(M[H].endResi),c=!t&&!p,t)if(n.residIgLoop[h]=1,r)E?(i=M[H].startRefnum-M[H].loopResCnt+l,s=M[H].strand+i,b=s+M[H].strandPostfix):(s=void 0,b=void 0);else if(a>=0&&"G"==M[a].strand.substr(0,1))o?E&&n.resid2refnum[h]?(o=!0,i=M[a].endRefnum+l,s=M[a].strand+i,b=s+M[a].strandPostfix):(E=!1,r=!0,o=!1,s=void 0,b=void 0):(s=void 0,b=void 0);else{o=!0;let e=M[H].loopResCnt;l<=parseInt(e/2+.5)?(i=M[a].endRefnum+l,s=M[a].strand+i,b=s+M[a].strandPostfix):(i=M[H].startRefnum-e+l-1,s=M[H].strand+i,b=s+M[H].strandPostfix)}else c?(r=!1,M[H].anchorRefnum&&(e==M[H].startResi?(d=M[H].anchorRefnum-M[H].resCntBfAnchor,M[H].startRefnum=d):e==M[H].endResi&&(M[H].endRefnum=d),s=M[H].strand+d,b=s+M[H].strandPostfix),e==M[H].endResi&&(++H,l=0,M[H]||--H)):p&&(n.residIgLoop[h]=1,o?n.resid2refnum[h]?(o=!0,i=M[H].endRefnum+l,s=M[H].strand+i,b=s+M[H].strandPostfix):(o=!1,s=void 0,b=void 0):(s=void 0,b=void 0))}else b=void 0;O=k,a=H-1,n.resid2refnum[h]=b,y=n.refnumCls.rmStrandFromRefnumlabel(b),n.refnum2residArray.hasOwnProperty(y)?n.refnum2residArray[y].push(h):n.refnum2residArray[y]=[h],n.chainsMapping.hasOwnProperty(t)||(n.chainsMapping[t]={}),n.chainsMapping[t][h]=s}}for(let l=0,o=e.length;l'+y+"":' '}else r+="";else if(1==s||2==s)if(y){let e=parseInt(y).toString(),t='style="color:'+this.getRefnumColor(k,!0)+'"';r+=parseInt(e.substr(e.length-2,2))%2==0?"'+y+"":" '}else r+="";else" "!=k?(x=n.residIgLoop[e],r+=this.getRefnumHtml(e,y,C,b,k,x,a)):r+="";else r+="";O=P}return r+='',r+="",r+="
    ",r+="
    ",r+="
    ",o+="",{html:r,html3:o}}getRefnumHtml(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui,d=parseInt(t).toString(),c=(d-1e3*parseInt(d/1e3)).toString(),h=parseInt(d.toString().substr(0,2)),p="5"!=c.substr(0,1)&&"18"!=h,m=this.getRefnumColor(n,!0),u=l?'style="color:'+m+'"':'style="color:'+m+'; text-decoration: underline overline;"',g=d.substr(d.length-2,2),f=parseInt(g);parseInt(d.substr(d.length-3,3));let b="";return!i||50!=f||p||l?i&&f%2==0&&52!=f&&!r?(g=isNaN(t)?g+t.substr(t.length-1,1):g,b+="'+g+""):b+=" ':(o.hAtomsRefnum=a.hashUtilsCls.unionHash(o.hAtomsRefnum,o.residues[e]),b+="'+i.substr(0,1)+""+i.substr(1)+""),b}getRefnumColor(e,t){let s=this.icn3d.icn3dui,i=e?e.substr(0,1):"";return"C"==e?"#0000FF":"C'"==e?"#6495ED":"C''"==e?"#006400":"A"==i?"#9400D3":"B"==i?"#ba55d3":"D"==i?"#00FF00":"E"==i?"#FFD700":"F"==i?"#FF8C00":"G"==i?"#FF0000":s.htmlCls.GREYB}getProtodomainColor(e){let t=this.icn3d.icn3dui,s=e?e.substr(0,1):"";return"A"==s||"D"==s?"#0000FF":"B"==s||"E"==s?"#006400":"C"==e||"F"==s?"#FFD700":"C'"==e||"G"==s?"#FF8C00":"C''"==e?"#FF0000":t.htmlCls.GREYB}insertGap(e,t,s,i){let n=this.icn3d;n.icn3dui;let l="";return void 0!==n.targetGapHash&&n.targetGapHash.hasOwnProperty(t)&&(l+=this.insertMulGap(n.targetGapHash[t].to-n.targetGapHash[t].from+1,s,i)),l}insertMulGap(e,t,s){this.icn3d.icn3dui;let i="";for(let n=0;n"+t+"";return i}insertGapOverview(e,t){let s=this.icn3d;s.icn3dui;let i="";return void 0!==s.targetGapHash&&s.targetGapHash.hasOwnProperty(t)&&(i+=this.insertMulGapOverview(e,s.targetGapHash[t].to-s.targetGapHash[t].from+1)),i}insertMulGapOverview(e,t){let s=this.icn3d;s.icn3dui;let i="",n=s.seqAnnWidth*t/(s.maxAnnoLength+s.nTotalGap);return n=parseInt(n),i+='
     
    ',i}setAlternativeSeq(e,t){let s=this.icn3d;s.icn3dui;let i=s.chainsSeq[e];s.giSeq[e]=[];for(let t=0,n=i.length;t1&&s.htmlCls.clickMenuCls.setLogCmd("select sets "+e,!0)}else{let o={};if(void 0!==$(e).attr("domain")||void 0!==$(e).attr("feat")||void 0!==$(e).attr("3ddomain")||void 0!==$(e).attr("custom")){t.hlUpdateCls.hlSummaryDomain3ddomain(e);let a,d,c,h=$(e).attr("from").split(","),p=$(e).attr("to").split(",");r.substr(0,r.indexOf("_"));for(let s=0,i=h.length;s1&&s.htmlCls.clickMenuCls.setLogCmd("select sets "+c,!0)}}else{t.bCtrl||t.bShift?(t.currSelectedSets.push(i),t.selectionCls.selectAChain(r,i,!0,!0)):(t.currSelectedSets=[i],t.selectionCls.selectAChain(r,i,t.bAlignSeq)),t.bAlignSeq?s.htmlCls.clickMenuCls.setLogCmd("select alignChain "+r,!0):s.htmlCls.clickMenuCls.setLogCmd("select chain "+r,!0);let e=t.currSelectedSets.join(" or ");t.currSelectedSets.length>1&&s.htmlCls.clickMenuCls.setLogCmd("select sets "+e,!0)}else t.hlObjectsCls.removeHlObjects(),t.hlUpdateCls.removeHl2D(),$("#"+t.pre+"atomsCustom").val("")}}selectResidues(e,t){let s=this.icn3d,i=s.icn3dui;if(!i.bNode&&(!1!==s.bSelectResidue||s.bShift||s.bCtrl||s.selectionCls.removeSelection(),void 0!==e&&""!==e)){e=e.substr(e.indexOf("_")+1),s.bSelectResidue=!0,$(t).toggleClass("icn3d-highlightSeq");let n=e.substr(e.indexOf("_")+1);if(s.residues.hasOwnProperty(n))if($(t).hasClass("icn3d-highlightSeq")){for(let e in s.residues[n])s.hAtoms[e]=1;if(s.selectedResidues[n]=1,s.bAnnotations&&void 0!==$(t).attr("disease")){let e=$(t).attr("disease"),l=s.applyCenterCls.centerAtoms(i.hashUtilsCls.hash2Atoms(s.residues[n],s.atoms)),r=15;e.length>r&&(e=e.substr(0,r)+"...");let o=s.LABELSIZE,a=i.htmlCls.GREYD;s.analysisCls.addLabel(e,l.center.x,l.center.y,l.center.z,o,a,void 0,"custom")}}else{for(let e in s.residues[n])delete s.hAtoms[e];delete s.selectedResidues[n],s.hlObjectsCls.removeHlObjects()}}}}class Dt{constructor(e){this.icn3d=e}update2DdgmContent(){let e=this.icn3d,t=e.icn3dui,s="";void 0!==t.cfg.mmdbid||void 0!==t.cfg.gi?(s+=e.diagram2dCls.draw2Ddgm(e.interactionData,e.inputid,void 0,!0),s+=e.diagram2dCls.set2DdgmNote(),$("#"+e.pre+"dl_2ddgm_html").html(s)):e.mmdbidArray&&(void 0!==t.cfg.align||void 0!==t.cfg.chainalign||e.bRealign)&&(s+=e.diagram2dCls.draw2Ddgm(e.interactionData1,e.mmdbidArray[0].toUpperCase(),0,!0),void 0!==e.mmdbid_q&&e.mmdbid_q===e.mmdbid_t?s+=e.diagram2dCls.draw2Ddgm(e.interactionData2,e.mmdbidArray[0].toUpperCase(),1,!0):s+=e.diagram2dCls.draw2Ddgm(e.interactionData2,e.mmdbidArray[1].toUpperCase(),1,!0),s+=e.diagram2dCls.set2DdgmNote(!0),$("#"+e.pre+"dl_2ddgm_html").html(s))}changeSeqColor(e){let t=this.icn3d,s=t.icn3dui;for(let i=0,n=e.length;i0&&($("#"+e.pre+"dl_2ddgm svg line").attr("stroke","#000000"),$("#"+e.pre+"dl_2ddgm line").attr("stroke-width",1))}removeHlMenus(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"atomsCustom").val(""),$("#"+e.pre+"atomsCustom")[0].blur()}updateHlAll(e,t,s,i){let n=this.icn3d,l=n.icn3dui;n.prevHighlightAtoms=l.hashUtilsCls.cloneHash(n.hAtoms),this.updateHlObjects(i),void 0!==e?this.updateHlSeqInChain(e,s):this.updateHlSeq(void 0,void 0,s),this.updateHl2D(),(void 0===t||t)&&this.updateHlMenus(e)}updateHlObjects(e){let t=this.icn3d;t.icn3dui,t.hlObjectsCls.removeHlObjects(),(t.hAtoms&&t.atoms&&Object.keys(t.hAtoms).length0&&(e=s.defNames2Residues[i]);let t={};if(void 0!==s.defNames2Atoms[i]&&s.defNames2Atoms[i].length>0){for(let e=0,n=s.defNames2Atoms[i].length;e0&&(r=t.firstAtomObjCls.getFirstCalphaAtomObj(l))}let o=void 0!==r&&void 0!==r.color?"#"+r.color.getHexString():"#FFFFFF",a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] rect[class='icn3d-hlnode']"),d=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] rect[class='icn3d-basenode']");void 0!==a&&(t.diagram2dCls.highlightNode("rect",a,d,l),$(a).attr("fill",o)),a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] circle[class='icn3d-hlnode']"),d=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] circle[class='icn3d-basenode']"),void 0!==a&&(t.diagram2dCls.highlightNode("circle",a,d,l),$(a).attr("fill",o)),a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] ellipse[class='icn3d-hlnode']"),void 0!==a&&t.diagram2dCls.highlightNode("ellipse",a,void 0,l),a=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] polygon[class='icn3d-hlnode']"),d=$("#"+t.pre+"dl_2ddgm g[chainid="+e[i]+"] polygon[class='icn3d-basenode']"),void 0!==a&&(t.diagram2dCls.highlightNode("polygon",a,d,l),$(a).attr("fill",o))}if(void 0!==t.lineArray2d)for(let e=0,i=t.lineArray2d.length;e1){let e={},l=[],o=[],a=[],c=[],h=[],m=[],u=[],g=[],f=[],b=[],C=[],y=[],v={},_={};for(let t=0,s=p.length;t0&&(T=1,t=i.getGraphCls.getNodeTopBottom(c[e],d,void 0,T,g[e]),h[e]=t.nodeArray1,m[e]=t.nodeArray2,d=n.hashUtilsCls.unionHash(d,t.name2node),T=2,t=i.getGraphCls.getNodeTopBottom(c[e],d,void 0,T,y[e]),f[e]=t.nodeArray1,b[e]=t.nodeArray2,d=n.hashUtilsCls.unionHash(d,t.name2node)),k[e]=l[e].length,O[e]=o[e].length,R=Math.max(R,O[e]),I.push(p[e])}let E,P,M,D,H,F=1,L=3*F,N=7*F,q=10,U=10,$=30,j=20;t?(M=(n.utilsCls.sumArray(k)+2*I.length)*(L+N)+4*U+2*$+j*I.length,P=(R+2)*(L+N)+2*q+$):(E=110+j,M=E*I.length,P=(R+2)*(L+N)+2*q,P+=20),Object.keys(i.chainsMapping).length>0&&(M*=3),t?(i.scatterplotWidth=2*P,H=i.scatterplotWidth,D=n.scatterplotid):(i.linegraphWidth=2*P,H=i.linegraphWidth,D=n.linegraphid),s=0==I.length?"No interactions found for each structure

    ":"2D integration graph for "+I.length+" structure(s) "+I+'. There are three sections: "Interactions", "Common interactions", and "Different interactions". Each section has '+I.length+" graphs.

    ",s+="";let B,z=0;T=0,B=this.drawGraphPerType(T,p,t,l,o,a,d,z,E,j,k,L,N,U),z=B.heightFinal,s+=B.html,Object.keys(i.chainsMapping).length>0&&(T=1,B=this.drawGraphPerType(T,p,t,h,m,u,d,z,E,j,k,L,N,U),z=B.heightFinal,s+=B.html,T=2,B=this.drawGraphPerType(T,p,t,f,b,C,d,z,E,j,k,L,N,U),z=B.heightFinal,s+=B.html),s+=""}else if(t){let e,t,l,c,h=p[0],m=o.length,u=a.length,g=1,f=3*g,b=7*g,C=30;t=(m+2)*(f+b)+2*10+C,e=(u+2)*(f+b)+2*10+C,i.scatterplotWidth=2*e,c=i.scatterplotWidth,l=n.scatterplotid,s=r.length>0?"":"No interactions found for these two sets

    ",s+="",s+=this.drawScatterplot_base(o,a,r,d,0),i.lineGraphStr+=i.getGraphCls.updateGraphJson(h,1,o,a,r),s+=""}else{let e=p[0],t=o.length,l=a.length,c=1,h=3*c,m=7*c,u=110,g=10,f=t>l?t*(h+m)+2*g:l*(h+m)+2*g;i.linegraphWidth=2*f,s=r.length>0?"":"No interactions found for these two sets

    ",s+="",s+=this.drawLineGraph_base(o,a,r,d,0),i.lineGraphStr+=i.getGraphCls.updateGraphJson(e,1,o,a,r),s+=""}return i.lineGraphStr+="}\n",i.scatterplotStr=i.lineGraphStr,t?$("#"+i.pre+"scatterplotDiv").html(s):$("#"+i.pre+"linegraphDiv").html(s),s}drawGraphPerType(e,t,s,i,n,l,r,o,a,d,c,h,p,m){let u=this.icn3d;u.icn3dui;let g,f,b="",C=2==t.length&&"2"==t[1].replace(t[0],"");0==e?(g="Interactions in ",f=""):1==e?(g="Common interactions in ",f="_common"):2==e&&(g="Different interactions in ",f="_diff");for(let y=0,v=t.length;y0&&(u.lineGraphStr+=", \n"):u.lineGraphStr+=", \n",u.lineGraphStr+=u.getGraphCls.updateGraphJson(t[y],y+f,i[y],n[y],l[y])}return{heightFinal:o,html:b}}getIdArrayFromNode(e){let t=this.icn3d.icn3dui,s=[];s.push(""),s.push("");let i=e.r.substr(4);return s=s.concat(t.utilsCls.getIdArray(i)),s}drawLineGraph_base(e,t,s,i,n,l,r){let o,a,d=this.icn3d,c=d.icn3dui,h="",p=e.length,m=t.length;p>m?(o=10,a=10*Math.abs(p-m)*.5+10):(a=10,o=10*Math.abs(p-m)*.5+10),l&&(h+=""+l+"");let u=30+n,g=80+n,f="",b={},C={};for(let t=0;t";let u=1==t.n?"Interaction":t.n+" interactions";t.n>1&&(h+=""+u+" of residue "+n.id+" with residue "+l.id+""),h+="
    "}return h+=f,h}drawScatterplot_base(e,t,s,i,n,l,r,o,a){let d=this.icn3d;d.icn3dui;let c="",h=e.length,p=t.length,m=l?3:7,u=(h+1)*(3+m)+30+40;r&&(c+=""+r+"");let g=n+u-(50+(3+m)),f=40+(3+m),b="",C={},y={};for(let t=0;t";else{h+="";let i=1==e.n?"Interaction":e.n+" interactions";e.n>1&&(h+=""+i+" of residue "+t.id+" with residue "+s.id+""),h+=l?"":"",h+=""}return h}copyStylesInline(e,t){this.icn3d.icn3dui;let s=["svg","g"];for(let i=0;i=i.domainid2score[a].split("_")[0])&&(i.domainid2score[a]=o[0].score+"_"+o[0].frac_identical+"_"+o[0].num_res,i.domainid2refpdbname[a]=d,r[a]=o[0].segs,i.domainid2ig2kabat[a]=o[0].ig2kabat,i.domainid2ig2imgt[a]=o[0].ig2imgt)}if(s){n.bNode||console.log("Start round 2 alignment with the reference culsters "+JSON.stringify(i.domainid2refpdbname));let e=[],t=[],s=n.htmlCls.baseUrl+"tmalign/tmalign.cgi";for(let l in i.domainid2refpdbname){let r=[],o=i.domainid2refpdbname[l],a=l.substr(0,l.indexOf(","));if(i.refpdbHash.hasOwnProperty(a)&&(o=a,n.bNode||console.log("Adjusted refpdbname for domainid "+l+": "+o)),!i.refpdbHash[o])continue;for(let e=0,t=i.refpdbHash[o].length;e0){if(i.bShowRefnum=!0,i.hAtomsRefnum={},i.bAnnoShown)for(let e in i.protein_chainid){let t=i.protein_chainid[e];i.showSeqCls.showSeq(e,t,"protein")}else await i.showAnnoCls.showAnnotations();i.annotationCls.setAnnoViewAndDisplay("detailed view")}else alert("No Ig reference numbers are assigned based on the reference structures in iCn3D...")}getLabelFromRefnum(e,t,s){this.icn3d.icn3dui;let i=parseInt(e);return i<1e3?void 0:i>=1200&&i<1290?"A---"+e:i>=1320&&i<1390?"A--"+e:i>=1420&&i<1490?"A-"+e:i>=1520&&i<1590?"A"+e:i>=1620&&i<1690?"A+"+e:i>=1820&&i<1890?"A'"+e:i>=2e3&&i<2900?"B"+e:i>=3300&&i<3390?"C--"+e:i>=3420&&i<3490?"C-"+e:i>=3520&&i<3590?"C"+e:i>=4e3&&i<4900?"C'"+e:i>=5e3&&i<5900?"C''"+e:i>=6e3&&i<6900?"D"+e:i>=7500&&i<7590?"E"+e:i>=7620&&i<7900?"E+"+e:i>=8e3&&i<8900?"F"+e:i>=9500&&i<9590?"G"+e:i>=9620&&i<9690?"G+"+e:i>=9720&&i<9790?"G++"+e:i>9900?void 0:" "+e}async parseCustomRefFile(e){let t=this.icn3d;t.icn3dui,t.bShowCustomRefnum=!0;let s=e.split("\n");t.resid2refnum||(t.resid2refnum={}),t.refnum2residArray||(t.refnum2residArray={}),t.chainsMapping||(t.chainsMapping={});let i=[];for(let e=0,t=s.length;e",C=e.id;return c.resid2refnum[p]&&(C+="=>"+c.resid2refnum[p]),b+=""+C+"",o?(b+="",b+=""+g+""):(b+="",b+=""+g+""),b+="",b}getNodeTopBottom(e,t,s,i,n){let l=this.icn3d.icn3dui,r=this,o=[],a=[],d={};for(let s in e){let e=t[s];if(e){if(1==i||2==i){if(e=l.hashUtilsCls.cloneHash(e),1==i){let t=n[s]?n[s]:"-";e.id+="=>"+t}else{let t=n[s]?n[s]:"--";e.id+="==>"+t}d[e.id]=e}"a"==e.s?o.push(e):"b"==e.s?a.push(e):"ab"==e.s&&(o.push(e),a.push(e))}}return o.sort((function(e,t){return r.compNode(e,t)})),a.sort((function(e,t){return r.compNode(e,t,s)})),{nodeArray1:o,nodeArray2:a,name2node:d}}updateGraphJson(e,t,s,i,n){let l=this.icn3d.icn3dui,r="";return r+='"structure'+t+'": {"id": "'+e+'", "nodes1":[',r+=l.utilsCls.getJSONFromArray(s),r+='], \n"nodes2":[',r+=l.utilsCls.getJSONFromArray(i),r+='], \n"links":[',r+=l.utilsCls.getJSONFromArray(n),r+="]}",r}updateGraphColor(){let e=this.icn3d,t=e.icn3dui;if(void 0!==e.graphStr){let s=JSON.parse(e.graphStr),i={};for(let t in e.residues){let s=e.firstAtomObjCls.getFirstAtomObj(e.residues[t]);i[t]=s.color.getHexString().toUpperCase()}let n={};for(let e=0,l=s.nodes.length;e0&&c==e.chain&&(n.resid2ncbi[e.resi]==n.resid2ncbi[p]+1||n.resid2ncbi[e.resi]==n.resid2ncbi[p])&&(o.push('{"source": "'+h+'", "target": "'+u+'", "v": '+d+', "c": "'+f+'"}'),e.ssbegin&&(d=l.htmlCls.ssValue),e.ssend&&(d=l.htmlCls.coilValue)),c=e.chain,h=u,p=e.resi,++a}}return{node:r,link:o}}getHbondLinksForSet(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=parseFloat($("#"+s.pre+"hbondthreshold").val()),r=e,o=r;if(Object.keys(o).length>0&&Object.keys(r).length>0){let e=!1;s.hBondCls.calculateChemicalHbonds(i.hashUtilsCls.hash2Atoms(o,s.atoms),i.hashUtilsCls.hash2Atoms(r,s.atoms),parseFloat(l),e,"graph",!0),n=i.hashUtilsCls.cloneHash(s.resid2Residhash)}return this.getGraphLinks(n,n,i.htmlCls.hbondInsideColor,t,i.htmlCls.hbondInsideValue)}getIonicLinksForSet(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=parseFloat($("#"+s.pre+"saltbridgethreshold").val()),r=e,o=r;if(Object.keys(o).length>0&&Object.keys(r).length>0){let e=!1;s.saltbridgeCls.calculateIonicInteractions(i.hashUtilsCls.hash2Atoms(o,s.atoms),i.hashUtilsCls.hash2Atoms(r,s.atoms),parseFloat(l),e,"graph",!0),n=i.hashUtilsCls.cloneHash(s.resid2Residhash)}return this.getGraphLinks(n,n,i.htmlCls.ionicInsideColor,t,i.htmlCls.ionicInsideValue)}getHalogenPiLinksForSet(e,t){let s,i=this.icn3d,n=i.icn3dui,l={},r=e,o=r,a="";return s=parseFloat($("#"+i.pre+"halogenthreshold").val()),Object.keys(o).length>0&&Object.keys(r).length>0&&(i.piHalogenCls.calculateHalogenPiInteractions(n.hashUtilsCls.hash2Atoms(r,i.atoms),n.hashUtilsCls.hash2Atoms(o,i.atoms),parseFloat(s),"graph","halogen",!0),l=n.hashUtilsCls.cloneHash(i.resid2Residhash)),a+=this.getGraphLinks(l,l,n.htmlCls.halogenInsideColor,t,n.htmlCls.halogenInsideValue),s=parseFloat($("#"+i.pre+"picationthreshold").val()),Object.keys(o).length>0&&Object.keys(r).length>0&&(i.piHalogenCls.calculateHalogenPiInteractions(n.hashUtilsCls.hash2Atoms(r,i.atoms),n.hashUtilsCls.hash2Atoms(o,i.atoms),parseFloat(s),"graph","pi-cation",!0),l=n.hashUtilsCls.cloneHash(i.resid2Residhash)),a+=this.getGraphLinks(l,l,n.htmlCls.picationInsideColor,t,n.htmlCls.picationInsideValue),s=parseFloat($("#"+i.pre+"pistackingthreshold").val()),Object.keys(o).length>0&&Object.keys(r).length>0&&(i.piHalogenCls.calculateHalogenPiInteractions(n.hashUtilsCls.hash2Atoms(r,i.atoms),n.hashUtilsCls.hash2Atoms(o,i.atoms),parseFloat(s),"graph","pi-stacking",!0),l=n.hashUtilsCls.cloneHash(i.resid2Residhash)),a+=this.getGraphLinks(l,l,n.htmlCls.pistackingInsideColor,t,n.htmlCls.pistackingInsideValue),a}getContactLinksForSet(e,t,s){let i=this.icn3d;i.icn3dui;let n=[],l="",r="",o={};for(let t in e){let e=i.atoms[t];e.ss==l&&e.chain==r||(Object.keys(o).length>0&&n.push(o),o={}),o[e.serial]=1,l=e.ss,r=e.chain}Object.keys(o).length>0&&n.push(o);let a=n.length,d="";for(let e=0;ed?s?-1:1:ah?1:c0&&Object.keys(a).length>0)){let t,s=c.hBondCls.calculateChemicalHbonds(h.hashUtilsCls.hash2Atoms(d,c.atoms),h.hashUtilsCls.hash2Atoms(a,c.atoms),parseFloat(e),n);n?(c.resid2ResidhashSaltbridge=h.hashUtilsCls.cloneHash(c.resid2Residhash),t="all atoms that have salt bridges with the selected atoms"):(c.resid2ResidhashHbond=h.hashUtilsCls.cloneHash(c.resid2Residhash),t="all atoms that are hydrogen-bonded with the selected atoms");let i={};for(let e in s){i[c.atoms[e].structure+"_"+c.atoms[e].chain+"_"+c.atoms[e].resi]=1}c.hAtoms={};for(let e in i)for(let t in c.residues[e])c.hAtoms[t]=1,c.atoms[t].style2="stick";let l=r+"_auto";c.selectionCls.addCustomSelection(Object.keys(i),l,t,o,!0),c.selectionCls.saveSelectionIfSelected(),c.drawCls.draw()}}showHydrogens(){let e=this.icn3d;if(void 0!==e.icn3dui.cfg.cid)for(let t in e.hAtoms){let s=e.atoms[t];if("H"!==s.elem.substr(0,1)){e.atoms[s.serial].bonds=e.atoms[s.serial].bonds2.concat(),e.atoms[s.serial].bondOrder=e.atoms[s.serial].bondOrder2.concat();for(let t=0,i=e.atoms[s.serial].bonds.length;t0){let i=e.atoms[t].bonds[0];e.atoms[i].bonds.push(s.serial),e.atoms[i].bondOrder&&e.atoms[i].bondOrder.push(1)}e.dAtoms[t]=1}}e.bShowHighlight=!1}hideHydrogens(){let e=this.icn3d;e.icn3dui;for(let t in e.hAtoms){let s=e.atoms[t];if("H"===s.elem.substr(0,1)){if(e.atoms[s.serial].bonds.length>0){let t=e.atoms[s.serial].bonds[0],i=e.atoms[t].bonds?e.atoms[t].bonds.indexOf(s.serial):-1;-1!==i&&(e.atoms[t].bonds.splice(i,1),e.atoms[t].bondOrder&&e.atoms[t].bondOrder.splice(i,1))}delete e.dAtoms[s.serial],delete e.hAtoms[s.serial]}}}hideExtraBonds(){let e=this.icn3d;e.icn3dui;for(let t in e.atoms)e.atoms[t].style2="nothing";for(let t in e.sidec)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style2=e.opts.sidec);for(let t in e.water)e.hAtoms.hasOwnProperty(t)&&(e.atoms[t].style=e.opts.water)}hideHbondsContacts(){let e=this.icn3d,t=e.icn3dui,s="set hbonds off";t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.hBondCls.hideHbonds(),s="set salt bridge off",t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.saltbridgeCls.hideSaltbridge(),s="set contact off",t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.contactCls.hideContact(),s="set halogen pi off",t.htmlCls.clickMenuCls.setLogCmd(s,!0),e.piHalogenCls.hideHalogenPi(),this.hideExtraBonds()}showIonicInteractions(e,t,s,i,n,l){let r,o,a,d,c=this.icn3d,h=c.icn3dui;if(!i&&(r="saltbridge",o="salt bridge "+e+" | sets "+t+" "+s+" | "+i,c.opts.saltbridge="yes",a=c.definedSetsCls.getAtomsFromNameArray(t),d=c.definedSetsCls.getAtomsFromNameArray(s),c.firstAtomObjCls.getFirstAtomObj(a),Object.keys(d).length>0&&Object.keys(a).length>0)){let t,s=c.saltbridgeCls.calculateIonicInteractions(h.hashUtilsCls.hash2Atoms(d,c.atoms),h.hashUtilsCls.hash2Atoms(a,c.atoms),parseFloat(e),n);c.resid2ResidhashSaltbridge=h.hashUtilsCls.cloneHash(c.resid2Residhash),t="all atoms that have ionic interactions with the selected atoms";let i={};for(let e in s){i[c.atoms[e].structure+"_"+c.atoms[e].chain+"_"+c.atoms[e].resi]=1}c.hAtoms={};for(let e in i)for(let t in c.residues[e])c.hAtoms[t]=1,c.atoms[t].style2="stick",c.ions.hasOwnProperty(t)&&(c.atoms[t].style2="sphere");let l="saltbridge_auto";c.selectionCls.addCustomSelection(Object.keys(i),l,t,o,!0),c.selectionCls.saveSelectionIfSelected(),c.drawCls.draw()}}showHalogenPi(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(i)return;let a,d,c=l+" "+e+" | sets "+t+" "+s+" | "+i;if(r.opts[l]="yes",a=r.definedSetsCls.getAtomsFromNameArray(t),d=r.definedSetsCls.getAtomsFromNameArray(s),r.firstAtomObjCls.getFirstAtomObj(a),Object.keys(d).length>0&&Object.keys(a).length>0){let t,s=r.piHalogenCls.calculateHalogenPiInteractions(o.hashUtilsCls.hash2Atoms(a,r.atoms),o.hashUtilsCls.hash2Atoms(d,r.atoms),parseFloat(e),n,l);"halogen"==l?(r.resid2ResidhashHalogen=o.hashUtilsCls.cloneHash(r.resid2Residhash),t="all atoms that have halogen bonds with the selected atoms"):"pi-cation"==l?(r.resid2ResidhashPication=o.hashUtilsCls.cloneHash(r.resid2Residhash),t="all atoms that have pi-cation interactions with the selected atoms"):"pi-stacking"==l&&(r.resid2ResidhashPistacking=o.hashUtilsCls.cloneHash(r.resid2Residhash),t="all atoms that have pi-stacking with the selected atoms");let i={};for(let e in s){i[r.atoms[e].structure+"_"+r.atoms[e].chain+"_"+r.atoms[e].resi]=1}r.hAtoms={};for(let e in i)for(let t in r.residues[e])r.hAtoms[t]=1,r.atoms[t].style2="stick",r.ions.hasOwnProperty(t)&&(r.atoms[t].style2="sphere");let h=l+"_auto";r.selectionCls.addCustomSelection(Object.keys(i),h,t,c,!0),r.selectionCls.saveSelectionIfSelected(),r.drawCls.draw()}}showClbonds(){let e=this.icn3d,t=e.icn3dui;e.opts.clbonds="yes";let s=e.applyClbondsCls.applyClbondsOptions();for(let i in s)e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.residues[i]);if(Object.keys(s).length>0){let t="clbonds",i="all atoms that have cross-linkages";e.selectionCls.addCustomSelection(Object.keys(s),t,i,"cross linkage",!0),e.selectionCls.saveSelectionIfSelected(),e.drawCls.draw()}}showSsbonds(){let e=this.icn3d,t=e.icn3dui;e.opts.ssbonds="yes";let s={},i=Object.keys(e.structures);for(let n=0,l=i.length;n0){let t="ssbonds",i="all atoms that have disulfide bonds";e.selectionCls.addCustomSelection(Object.keys(s),t,i,"disulfide bonds",!0),e.selectionCls.saveSelectionIfSelected(),e.drawCls.draw()}}pickCustomSphere(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(i)return;let a,d,c="select zone cutoff "+e+" | sets "+t+" "+s+" | "+i;n&&(c="interactions "+e+" | sets "+t+" "+s+" | "+i,r.opts.contact="yes"),a=r.definedSetsCls.getAtomsFromNameArray(t),d=r.definedSetsCls.getAtomsFromNameArray(s);let h,p,m=this.pickCustomSphere_base(e,a,d,i,n,l,c,!0),u=Object.keys(m.residues);r.hAtoms={};for(let e=0,t=u.length;e1?"structure":v>1?"chain":"residue";let w=[];if(n&&w.push("hbonds"),l&&w.push("salt bridge"),r&&w.push("interactions"),o&&w.push("halogen"),a&&w.push("pi-cation"),d&&w.push("pi-stacking"),s||(p.resids2inter={},p.resids2interAll={}),l){let n=parseFloat($("#"+p.pre+"saltbridgethreshold").val());n&&!isNaN(n)||(n=p.tsIonic),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showIonicInteractions(n,e,t,s,!0,i)),g=m.hashUtilsCls.unionHash(g,p.hAtoms)}if(n){let n=parseFloat($("#"+p.pre+"hbondthreshold").val());n&&!isNaN(n)||(n=p.tsHbond),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHbonds(n,e,t,s,void 0,i)),g=m.hashUtilsCls.unionHash(g,p.hAtoms)}let S,A,x,k,O="";if(n&&(O+=this.exportHbondPairs(i,u)),l&&(O+=this.exportSaltbridgePairs(i,u)),o){let n=parseFloat($("#"+p.pre+"halogenthreshold").val());n&&!isNaN(n)||(n=p.tsHalogen),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHalogenPi(n,e,t,s,i,"halogen")),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportHalogenPiPairs(i,u,"halogen")}if(a){let n=parseFloat($("#"+p.pre+"picationthreshold").val());n&&!isNaN(n)||(n=p.tsPication),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHalogenPi(n,e,t,s,i,"pi-cation")),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportHalogenPiPairs(i,u,"pi-cation")}if(d){let n=parseFloat($("#"+p.pre+"pistackingthreshold").val());n&&!isNaN(n)||(n=p.tsPistacking),s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.showHalogenPi(n,e,t,s,i,"pi-stacking")),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportHalogenPiPairs(i,u,"pi-stacking")}if(r){let n=b?c:parseFloat($("#"+p.pre+"contactthreshold").val());if(n&&!isNaN(n)||(n=p.tsContact),1!=e.length||1!=t.length||e[0]!=t[0])s||(p.hAtoms=m.hashUtilsCls.cloneHash(f),p.showInterCls.pickCustomSphere(n,e,t,s,!0,i)),g=m.hashUtilsCls.unionHash(g,p.hAtoms),O+=this.exportSpherePairs(!0,i,u);else{if(!s){let l={},o={};if(b){let e=!0,t=p.showInterCls.pickCustomSphere_base(n,C,y,s,!0,void 0,void 0,!0,e);l=m.hashUtilsCls.unionHash(l,t.residues);for(let e in t.resid2Residhash)o[e]=m.hashUtilsCls.unionHash(o[e],t.resid2Residhash[e])}else{let r=[],a="",d="",c={};for(let e in C){let t=p.atoms[e];t.ss==a&&t.chain==d||(Object.keys(c).length>0&&r.push(c),c={}),c[t.serial]=1,a=t.ss,d=t.chain}Object.keys(c).length>0&&r.push(c);let h=r.length;A="interactions "+n+" | sets "+e+" "+t+" | true",p.opts.contact="yes";for(let e=0;e
    ",E=p.resid2specCls.atoms2residues(Object.keys(C)),P=p.resid2specCls.atoms2residues(Object.keys(y)),M="select "+p.resid2specCls.residueids2spec(E),D="select "+p.resid2specCls.residueids2spec(P);T+="Set 1: "+e+'
    ',T+="Set 2: "+t+'

    ',T+='
    The interfaces are:
    ';let H=p.resid2specCls.atoms2residues(Object.keys(R)),F=p.resid2specCls.atoms2residues(Object.keys(I)),L="select "+p.resid2specCls.residueids2spec(H),N="select "+p.resid2specCls.residueids2spec(F);T+='interface_1
    ',T+='interface_2

    ',T+='
    Note: Each checkbox below selects the corresponding residue. You can click "Save Selection" in the "Select" menu to save the selection and click on "Highlight" button to clear the checkboxes.

    ';let q=T;if(("graph"==i||"linegraph"==i||"scatterplot"==i||b)&&(T=""),T+=O,"save1"==i||"save2"==i){T=q;let e="";"save1"==i?e="Set 1":"save2"==i&&(e="Set 2"),T+='

    Interactions Sorted on '+e+':
    ';let t=this.getAllInteractionTable(i);T+=t.html,h=t.bondCnt,$("#"+p.pre+"dl_interactionsorted_html").html(T),m.htmlCls.dialogCls.openDlg("dl_interactionsorted","Show sorted interactions")}else if("view"==i)$("#"+p.pre+"dl_allinteraction_html").html(T),m.htmlCls.dialogCls.openDlg("dl_allinteraction","Show interactions");else if("linegraph"==i){m.htmlCls.dialogCls.openDlg("dl_linegraph","Show interactions between two lines of residue nodes"),p.graphStr=p.getGraphCls.getGraphData(C,y,e,t,T,u),p.bLinegraph=!0;let s=p.lineGraphCls.drawLineGraph(p.graphStr);$("#"+p.pre+"linegraphDiv").html(s)}else if("scatterplot"==i){m.htmlCls.dialogCls.openDlg("dl_scatterplot","Show interactions as scatterplot"),p.graphStr=p.getGraphCls.getGraphData(C,y,e,t,T,u),p.bScatterplot=!0;let s=p.lineGraphCls.drawLineGraph(p.graphStr,!0);$("#"+p.pre+"scatterplotDiv").html(s)}else if(b){m.htmlCls.dialogCls.openDlg("dl_contactmap","Show contact map");let s=!0,i=p.getGraphCls.getGraphData(C,y,e,t,T,u,s);p.bContactMap=!0;let n=p.contactMapCls.drawContactMap(i);$("#"+p.pre+"contactmapDiv").html(n)}else if("graph"==i){if(p.graphStr=p.getGraphCls.getGraphData(C,y,e,t,T,u),p.bGraph=!0,Object.keys(y).length+Object.keys(C).length>Object.keys(p.dAtoms).length&&(p.graphStr=p.selectionCls.getGraphDataForDisplayed()),void 0===p.bD3){let e="./script/d3v4-force-all.min.js";await m.getAjaxPromise(e,"script"),p.bD3=!0}$("#"+m.svgid).empty(),m.htmlCls.dialogCls.openDlg("dl_graph","Force-directed graph"),p.drawGraphCls.drawGraph(p.graphStr,p.pre+"dl_graph")}return{interactionTypes:w.toString(),bondCnt:h}}clearInteractions(){let e=this.icn3d;e.icn3dui,e.lines.hbond=[],e.hbondpnts=[],e.lines.saltbridge=[],e.saltbridgepnts=[],e.lines.contact=[],e.contactpnts=[],e.lines.halogen=[],e.lines["pi-cation"]=[],e.lines["pi-stacking"]=[],e.halogenpnts=[],e.picationpnts=[],e.pistackingpnts=[]}resetInteractionPairs(){let e=this.icn3d;e.icn3dui,e.bHbondCalc=!1,e.showInterCls.hideHbondsContacts(),e.hlUpdateCls.clearHighlight(),e.resids2inter={},e.resids2interAll={}}async retrieveInteractionData(){let e=this.icn3d,t=e.icn3dui;if(!e.b2DShown)if(void 0!==t.cfg.align){let s=Object.keys(e.structures);if(2==t.cfg.atype){let t=!0;await e.alignParserCls.downloadAlignment(s[0]+","+s[1],t)}await e.ParserUtilsCls.set2DDiagramsForAlign(s[0].toUpperCase(),s[1].toUpperCase())}else void 0!==t.cfg.chainalign?(Object.keys(e.structures),await e.ParserUtilsCls.set2DDiagramsForChainalign(e.chainidArray)):e.ParserUtilsCls.download2Ddgm(e.inputid.toUpperCase())}getAllInteractionTable(e){let t=this.icn3d,s=t.icn3dui,i=[],n=Object.keys(t.resids2inter);("save1"==e||"save2"==e)&&n.sort((function(t,i){return s.utilsCls.compResid(t,i,e)}));let l,r,o="",a="",d="",c="",h="",p="",m="",u="",g="",f=0,b=0,C=0,y=0,v=0,_=0,w="";for(let s=0,S=n.length;s0&&l!=a&&(i.push({res1:a,res2:w,cntHbond:f,cntIonic:b,cntContact:C,cntHalegen:y,cntPication:v,cntPistacking:_}),o+=this.getInteractionPerResidue(d,c,h,p,m,u,g,f,b,C,y,v,_),c="",h="",p="",m="",u="",g="",f=0,b=0,C=0,y=0,v=0,_=0,w=""),x=t.resids2inter[S].hbond,k=this.getInteractionPairDetails(x,e,"hbond"),c+=k.html,f+=k.cnt,k.cnt>0&&(w+=r+":hbond_"+k.cnt+" "),x=t.resids2inter[S].ionic,k=this.getInteractionPairDetails(x,e,"ionic"),h+=k.html,b+=k.cnt,k.cnt>0&&(w+=r+":ionic_"+k.cnt+" "),x=t.resids2inter[S].contact,k=this.getContactPairDetails(x,e,"contact"),p+=k.html,C+=k.cnt,k.cnt>0&&(w+=r+":contact_"+k.cnt+" "),x=t.resids2inter[S].halogen,k=this.getInteractionPairDetails(x,e,"halogen"),m+=k.html,y+=k.cnt,k.cnt>0&&(w+=r+":halogen_"+k.cnt+" "),x=t.resids2inter[S]["pi-cation"],k=this.getInteractionPairDetails(x,e,"pi-cation"),u+=k.html,v+=k.cnt,k.cnt>0&&(w+=r+":pi-cation_"+k.cnt+" "),x=t.resids2inter[S]["pi-stacking"],k=this.getInteractionPairDetails(x,e,"pi-stacking"),g+=k.html,_+=k.cnt,k.cnt>0&&(w+=r+":pi-stacking_"+k.cnt+" "),a=l,d=O}i.push({res1:a,res2:w,cntHbond:f,cntIonic:b,cntContact:C,cntHalegen:y,cntPication:v,cntPistacking:_}),o+=this.getInteractionPerResidue(d,c,h,p,m,u,g,f,b,C,y,v,_);let S="";if(n.length>0){S+='
    ',S+="",S+="",S+="",S+="",S+="";let e='';S+=e,S+=e,S+='',S+=e,S+=e,S+=e,S+="",S+="",S+=o,S+="
    Residue# Hydrogen
    Bond
    # Salt Bridge
    /Ionic Interaction
    # Contact# Halogen
    Bond
    # π-Cation# π-StackingHydrogen Bond (backbone atoms: @CA, @N, @C, @O)Salt Bridge/Ionic InteractionContactHalogen Bondπ-Cationπ-Stacking
    Atom1Atom2Distance(Å)Highlight in 3D
    Atom1Atom2# ContactsMin Distance(Å)C-alpha Distance(Å)Highlight in 3D

    "}return{html:S,bondCnt:i}}getInteractionPerResidue(e,t,s,i,n,l,r,o,a,d,c,h,p){this.icn3d.icn3dui;let m="";m+=''+e[3]+e[2]+""+o+""+a+""+d+""+c+""+h+""+p+"";let u=[t,s,i,n,l,r];for(let e in u){m+=''+u[e]+"
    "}return m+="",m}getInteractionPairDetails(e,t,s){let i=this.icn3d;i.icn3dui;let n="",l=0,r='    ';if(void 0!==e)for(let a in e){let d=a.split(","),c="save1"==t?d[0]:d[1],h="save1"==t?d[1]:d[0],p=i.getGraphCls.convertLabel2Resid(c),m=i.firstAtomObjCls.getFirstAtomObj(i.residues[p]),u=m.color?m.color.getHexString():"",g=i.getGraphCls.convertLabel2Resid(h),f=i.firstAtomObjCls.getFirstAtomObj(i.residues[g]),b=f.color?f.color.getHexString():"",C=Math.sqrt(e[a]).toFixed(1);n+=' '+c+r+u+o+' '+h+r+b+o+''+C+"",n+='',n+="",++l}return{html:n,cnt:l}}getContactPairDetails(e,t){let s=this.icn3d;s.icn3dui;let i="",n=0,l='    ';if(void 0!==e)for(let o in e){let a=o.split(","),d="save1"==t?a[0]:a[1],c="save1"==t?a[1]:a[0],h=s.getGraphCls.convertLabel2Resid(d),p=s.firstAtomObjCls.getFirstAtomObj(s.residues[h]),m=p.color?p.color.getHexString():"",u=s.getGraphCls.convertLabel2Resid(c),g=s.firstAtomObjCls.getFirstAtomObj(s.residues[u]),f=g.color?g.color.getHexString():"",b=e[o].split("_"),C=b[0],y=b[1],v=b[2],_=b[3],w=b[4];i+=' '+d+"@"+v+l+m+r+' '+c+"@"+_+l+f+r+''+w+''+C+''+y+"",i+='',i+="",n+=parseInt(w)}return{html:i,cnt:n}}exportInteractions(){var e=this.icn3d,t=e.icn3dui;let s='

    Interacting residues:
    ';for(let t in e.chainname2residues)for(let i in e.chainname2residues[t]){let n=t.substr(0,t.indexOf("_"))+"_"+i.substr(0,i.indexOf(" "));s+=""}s+="
    Base Chain: ResiduesInteracting Chain
    "+t+": ",s+=e.resid2specCls.residueids2spec(e.chainname2residues[t][i]),s+=""+n+"

    ";let i=Object.keys(t.utilsCls.getHlStructures()).join(",");e.saveFileCls.saveFile(i+"_interactions.html","html",s)}exportSsbondPairs(){var e=this.icn3d,t=e.icn3dui;let s="",i=0;for(let t in e.structures){let n=e.ssbondpnts[t];if(void 0===n)break;for(let e=0,t=n.length;e"+n[e]+" Cys"+n[e+1]+" Cys",++i}}let n='

    '+i+" disulfide pairs:

    ";n+=s,n+="
    Residue ID 1Residue ID 2

    ";let l=Object.keys(t.utilsCls.getHlStructures()).join(",");e.saveFileCls.saveFile(l+"_disulfide_pairs.html","html",n)}exportClbondPairs(){var e=this.icn3d,t=e.icn3dui;let s="",i=0,n={};for(let t in e.structures){let l=e.clbondpnts[t];if(void 0===l)break;for(let t=0,r=l.length;t"+r+" "+t.resn+""+o+" "+n.resn+"",++i}n[r+"_"+o]=1,n[o+"_"+r]=1}}let l='

    '+i+" cross-linkage pairs:

    ";l+=s,l+="
    Residue ID 1Residue ID 2

    ";let r=Object.keys(t.utilsCls.getHlStructures()).join(",");e.saveFileCls.saveFile(r+"_crosslinkage_pairs.html","html",l)}exportHbondPairs(e,t){var s=this.icn3d,i=s.icn3dui;let n="",l=0,r='    ';for(let t in s.resid2ResidhashHbond){let i=s.getGraphCls.convertLabel2Resid(t),a=s.firstAtomObjCls.getFirstAtomObj(s.residues[i]),d=a.color?a.color.getHexString():"";for(let i in s.resid2ResidhashHbond[t]){let a=s.getGraphCls.convertLabel2Resid(i),c=s.firstAtomObjCls.getFirstAtomObj(s.residues[a]),h=c.color?c.color.getHexString():"",p=Math.sqrt(s.resid2ResidhashHbond[t][i]).toFixed(1);n+=' '+t+r+d+o+' '+i+r+h+o+''+p+"","view"==e&&(n+=''),n+="",++l}}let a='

    '+l+" hydrogen bond pairs (backbone atoms: @CA, @N, @C, @O):

    ";if(l>0&&(a+="
    ","view"==e&&(a+=''),a+="",a+=n,a+="
    Atom 1Atom 2Distance(Å)Highlight in 3D

    "),"graph"==e||"linegraph"==e||"scatterplot"==e){return s.getGraphCls.getGraphLinks(s.resid2ResidhashHbond,s.resid2ResidhashHbond,i.htmlCls.hbondColor,t,i.htmlCls.hbondValue)}return a}exportSaltbridgePairs(e,t){var s=this.icn3d,i=s.icn3dui;let n="",l=0,r='    ';for(let t in s.resid2ResidhashSaltbridge){let i=s.getGraphCls.convertLabel2Resid(t),a=s.firstAtomObjCls.getFirstAtomObj(s.residues[i]),d=a.color?a.color.getHexString():"";for(let i in s.resid2ResidhashSaltbridge[t]){let a=s.getGraphCls.convertLabel2Resid(i),c=s.firstAtomObjCls.getFirstAtomObj(s.residues[a]),h=c.color?c.color.getHexString():"",p=Math.sqrt(s.resid2ResidhashSaltbridge[t][i]).toFixed(1);n+=' '+t+r+d+o+' '+i+r+h+o+''+p+"","view"==e&&(n+=''),n+="",++l}}let a='

    '+l+" salt bridge/ionic interaction pairs:

    ";if(l>0&&(a+="
    ","view"==e&&(a+=''),a+="",a+=n,a+="
    Atom 1Atom 2Distance(Å)Highlight in 3D

    "),"graph"==e||"linegraph"==e||"scatterplot"==e){return s.getGraphCls.getGraphLinks(s.resid2ResidhashSaltbridge,s.resid2ResidhashSaltbridge,i.htmlCls.ionicColor,t,i.htmlCls.ionicValue)}return a}exportHalogenPiPairs(e,t,s){var i=this.icn3d,n=i.icn3dui;let l,r,o,a="",d=0,c='    ';"halogen"==s?(l=i.resid2ResidhashHalogen,r=n.htmlCls.halogenColor,o=n.htmlCls.halogenValue):"pi-cation"==s?(l=i.resid2ResidhashPication,r=n.htmlCls.picationColor,o=n.htmlCls.picationValue):"pi-stacking"==s&&(l=i.resid2ResidhashPistacking,r=n.htmlCls.pistackingColor,o=n.htmlCls.pistackingValue);for(let t in l){let n=i.getGraphCls.convertLabel2Resid(t),r=i.firstAtomObjCls.getFirstAtomObj(i.residues[n]),o=r.color?r.color.getHexString():"";for(let n in l[t]){let r=i.getGraphCls.convertLabel2Resid(n),p=i.firstAtomObjCls.getFirstAtomObj(i.residues[r]),m=p.color?p.color.getHexString():"",u=Math.sqrt(l[t][n]).toFixed(1);a+=' '+t+c+o+h+' '+n+c+m+h+''+u+"","view"==e&&(a+=''),a+="",++d}}let p='

    '+d+" "+s+" pairs:

    ";if(d>0&&(p+="
    ","view"==e&&(p+=''),p+="",p+=a,p+="
    Atom 1Atom 2Distance(Å)Highlight in 3D

    "),"graph"==e||"linegraph"==e||"scatterplot"==e){return i.getGraphCls.getGraphLinks(l,l,r,t,o)}return p}exportSpherePairs(e,t,s){var i=this.icn3d,n=i.icn3dui;let l="",r=0,o=e?i.resid2ResidhashInteractions:i.resid2ResidhashSphere,a='    ';for(let s in o){let n=i.getGraphCls.convertLabel2Resid(s),c=i.firstAtomObjCls.getFirstAtomObj(i.residues[n]),h=c.color?c.color.getHexString():"";for(let n in o[s]){let p=i.getGraphCls.convertLabel2Resid(n),m=i.firstAtomObjCls.getFirstAtomObj(i.residues[p]),u=m.color?m.color.getHexString():"",g=o[s][n].split("_"),f=g[0],b=g[1];c=g[2],m=g[3];let C=g[4];e?(l+=' '+s+"@"+c+a+h+d+' '+n+"@"+m+a+u+d+''+C+''+f+''+b+"","view"==t&&(l+=''),l+=""):l+=""+s+""+n+''+C+''+f+''+b+"",++r}}let c='

    '+r+" residue pairs in "+(e?"the contacts":"sphere")+":

    ";if(r>0&&(e?(c+='
    ',"view"==t&&(c+=''),c+=""):c+='
    Residue 1Residue 2Num ContactsMin Distance(Å)C-alpha Distance(Å)Highlight in 3D
    ',c+=l,c+="
    Residue 1Residue 2Num ContactsMin Distance(Å)C-alpha Distance(Å)

    "),"graph"==t||"linegraph"==t||"scatterplot"==t||"calpha"==t||"cbeta"==t||"heavyatoms"==t){return i.getGraphCls.getGraphLinks(o,o,n.htmlCls.contactColor,s,n.htmlCls.contactValue)}return c}}class $t{constructor(e){this.icn3d=e}drawGraph(e,t){var s=this.icn3d,i=s.icn3dui;if(void 0===n)var n=d3;var l=JSON.parse(e),r=$("#"+t).width(),o=$("#"+t).height(),a=isNaN(r)?300:1*r,d=isNaN(o)?300:1*o,c=r,h=o,p=d3.select("#"+i.svgid).attr("width",r).attr("height",o).attr("viewBox","0,0,"+a+","+d);p.selectAll(".g-main").remove();var m=p.append("g").classed("g-main",!0),u=m.append("rect").attr("width",c).attr("height",h).style("fill","#FFF"),g=m.append("g"),f=n.zoom().on("zoom",(function(){g.attr("transform",n.event.transform)}));if(m.call(f),l.links){for(var b=[],C={},y=0,v=l.nodes.length;y0?n.structures[0]:n.defaultPdbId;p=10*(a.length+2)+20+30,h=10*(d.length+2)+20+30,t?(n.alignerrormapWidth=2*h,u=n.alignerrormapWidth,m=l.alignerrormapid):(n.contactmapWidth=2*h,u=n.contactmapWidth,m=l.contactmapid),i=o.length>0?"":"No interactions found for these two sets

    ",i+="";if(t){n.hex2id={};let e=29/s;n.hex2skip={};let t=1e3;for(let s=0;se&&(n.hex2skip[d]=c)}}if(i+=n.lineGraphCls.drawScatterplot_base(a,d,o,c,0,!0,void 0,void 0,t),g+=n.getGraphCls.updateGraphJson(f,1,a,d,o),i+="",g+="}\n",t){n.alignerrormapStr=g,$("#"+n.pre+"alignerrormapDiv").html(i);let e=$("#"+l.alignerrormapid+"_scale").val();$("#"+l.alignerrormapid).attr("width",(n.alignerrormapWidth*parseFloat(e)).toString()+"px")}else n.contactmapStr=g,$("#"+n.pre+"contactmapDiv").html(i);return i}}class Bt{constructor(e){this.icn3d=e}async downloadAlignment(e,t){let s=this.icn3d,i=s.icn3dui,n=this;s.opts.proteins="c alpha trace";let l=e.split(","),r="ids="+e,o=i.htmlCls.baseUrl+"vastplus/vastplus.cgi?v=3&cmd=c&b=1&s=1&w3d&"+r;void 0!==i.cfg.inpara&&(o+=i.cfg.inpara),s.pdbid_chain2title={},void 0===s.chainids2resids&&(s.chainids2resids={});let a={},d="These two MMDB IDs "+l+' do not have 3D alignment data in the VAST+ database. You can try the VAST alignment by visiting the VAST+ page https://www.ncbi.nlm.nih.gov/Structure/vastplus/vastplus.cgi?uid=[PDB ID] (e.g., uid=1KQ2), and clicking "Original VAST"',c=await i.getAjaxPromise(o,"jsonp",!0,d);if(a=c.seqalign,void 0===a)return alert(d),!1;s.pdbid_molid2chain={},s.chainsColor={};for(let e=0,t=2;e5){let t=!1,s=!0;d=await r.pdbParserCls.loadPdbData(e,n,!1,t,"target",h,s)}else{let t=!0;d=await r.mmdbParserCls.parseMmdbData(e,"target",i[0],0,h,t)}for(let e=0,s=t.length;e5){let s=!0,i=!0;c=await r.pdbParserCls.loadPdbData(t[e],l,!1,s,"query",h,i)}else{let s=!0;c=await r.mmdbParserCls.parseMmdbData(t[e],"query",i[e+1],e,h,s)}d=o.hashUtilsCls.unionHash(d,c)}if(o.cfg.resnum)await r.realignParserCls.realignChainOnSeqAlign(s,i);else if(o.cfg.resdef)await r.realignParserCls.realignChainOnSeqAlign(s,i,void 0,!0);else{await r.pdbParserCls.applyCommandDssp(!0);for(let e in r.pdbChainIndexHash){let t=r.pdbChainIndexHash[e].split("_");l=t[0],t[1],n=t[2],t[3],a.transformStructure(l,e-1,"query")}let e=[],t=[],c=[],h=o.htmlCls.baseUrl+"vastdyn/vastdyn.cgi",p=o.htmlCls.baseUrl+"tmalign/tmalign.cgi";for(let s in r.afChainIndexHash){let i=r.afChainIndexHash[s].split("_");l=i[0];let a=i[1];n=i[2];let d,m=i[3];if("tmalign"!=o.cfg.aligntool){let e={domains1:r.domain3dCls.getDomainJsonForAlign(r.chains[l+"_"+a]),domains2:r.domain3dCls.getDomainJsonForAlign(r.chains[n+"_"+m])};d=o.getAjaxPostPromise(h,e)}else{let e={pdb_query:r.saveFileCls.getAtomPDB(r.chains[l+"_"+a]),pdb_target:r.saveFileCls.getAtomPDB(r.chains[n+"_"+m])};d=o.getAjaxPostPromise(p,e)}e.push(d),t.push(s-1),c.push(l)}let m=Promise.allSettled(e),u=await m;await a.downloadChainalignmentPart2b(s,i,d,u,t,n,c)}}async downloadChainalignmentPart2b(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui;for(let e=0,t=i.length;ec&&(c=l[t[0]],a=t[0]),l[t[1]]>c&&(c=l[t[1]],a=t[1])}let h={},p={},m={},u={};for(let e in r){let t,s,i=e.split("_"),n=r[e].split(","),l=n[2];a==i[0]?(t=i[0],s=i[1]):a==i[1]?(t=i[1],s=i[0]):(t=i[0],s=i[1]),m[t]=1,m.hasOwnProperty(s)||(m[s]=1,u[e]=r[e],d="target",this.transformStructure(t,l,d),d="query",this.transformStructure(s,l,d),h[n[0]]=1,h[n[1]]=1)}for(let e in u)if(void 0!==i.q_rotation){let t=u[e].split(","),s=[t[1],t[0],t[2]],l=i.setSeqAlignCls.setSeqAlignChain(void 0,void 0,s);p=n.hashUtilsCls.unionHash(p,l);let r=!1,o=n.htmlCls.alignSeqCls.getAlignSequencesAnnotations(Object.keys(i.alnChains),void 0,void 0,!1,void 0,r),a=$("#"+i.pre+"dl_sequence2").html();$("#"+i.pre+"dl_sequence2").html(a+o.sequencesHtml),$("#"+i.pre+"dl_sequence2").width(n.htmlCls.RESIDUE_WIDTH*o.maxSeqCnt+200)}i.dAtoms=n.hashUtilsCls.cloneHash(p),i.hAtoms=n.hashUtilsCls.cloneHash(p);let g="protein_aligned";i.selectionCls.saveSelection(g,g),i.opts.color="identity",i.setColorCls.setColorByOptions(i.opts,i.hAtoms),n.htmlCls.dialogCls.openDlg("dl_alignment","Select residues in aligned sequences"),i.drawCls.draw(),i.transformCls.zoominSelection(),i.hlUpdateCls.updateHlAll()}transformStructure(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=n.structures[e];for(let e=0,o=r.length;e2){let e=i.firstAtomObjCls.getResiduesFromAtoms(s),t="protein_aligned",n="protein aligned",l="select "+i.resid2specCls.residueids2spec(Object.keys(e));i.selectionCls.addCustomSelection(Object.keys(e),t,n,l,!0)}i.hlUpdateCls.updateHlAll(),n.htmlCls.dialogCls.openDlg("dl_alignment","Select residues in aligned sequences"),void 0!==n.cfg.rotate&&i.resizeCanvasCls.rotStruc(n.cfg.rotate,!0),i.html2ddgm="",n.cfg.show2d&&i.bFullUi&&(n.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions"),i.bFullUi&&(i.bChainAlign?await i.ParserUtilsCls.set2DDiagramsForChainalign(t):i.ParserUtilsCls.download2Ddgm(i.inputid.toUpperCase())))}addPostfixForChainids(e){this.icn3d.icn3dui;let t={};for(let s=0,i=e.length;s5?(d="https://alphafold.ebi.ac.uk/files/AF-"+i.mmdbid_t+"-F1-model_"+i.AFUniprotVersion+".pdb",a=n.getAjaxPromise(d,"text")):(d=n.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+n.cfg.bu+"&uid="+i.mmdbid_t,void 0!==n.cfg.inpara&&(d+=n.cfg.inpara),a=n.getAjaxPromise(d,"jsonp")),c.push(a),i.ParserUtilsCls.setYourNote(e.toUpperCase()+" in iCn3D"),i.pdbid_chain2title={},void 0===i.chainids2resids&&(i.chainids2resids={}),i.afChainIndexHash={},i.pdbChainIndexHash={};for(let e=1,t=l.length;e5?(t="https://alphafold.ebi.ac.uk/files/AF-"+i.mmdbid_q+"-F1-model_"+i.AFUniprotVersion+".pdb",s=n.getAjaxPromise(t,"text")):(t=n.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+n.cfg.bu+"&uid="+i.mmdbid_q,void 0!==n.cfg.inpara&&(t+=n.cfg.inpara),s=n.getAjaxPromise(t,"jsonp")),c.push(s)}for(let e=1,t=l.length;e0?r[e]+","+r[0]:void 0;if("tmalign"!=n.cfg.aligntool&&4==i.mmdbid_t.length&&4==i.mmdbid_q.length){let o;o=r.length>0?n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?domainpairs="+l:n.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainpairs="+t;let a=n.getAjaxPromise(o,"jsonp");c.push(a),i.pdbChainIndexHash[e]=s+"_"+i.chain_q+"_"+i.mmdbid_t+"_"+i.chain_t}else i.afChainIndexHash[e]=i.mmdbid_q+"_"+i.chain_q+"_"+i.mmdbid_t+"_"+i.chain_t}}let h=Promise.allSettled(c),p=await h;await this.parseChainAlignData(p,l,i.mmdbid_t,i.chain_t)}async parseChainAlignData(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=e[0].value,o="HEADER "+s+"\n";isNaN(s)&&s.length>5&&(r=o+r),n.t_trans_add=[],n.q_trans_sub=[],"tmalign"==l.cfg.aligntool&&(n.q_trans_add=[]),n.q_rotation=[],n.qt_start_end=[],n.mmdbidArray=[],n.mmdbidArray.push(s);let a=[];for(let s=1,i=t.length;s5&&(i=o+i),void 0===i||-1!==JSON.stringify(i).indexOf("Oops there was a problem"))return void alert("The coordinate data can NOT be retrieved for the structure "+r+"...");n.mmdbidArray.push(r),a.push(i)}let d=0;for(let r=1,o=t.length;r";"tmalign"==o.cfg.aligntool&&(n+="TM-score: "+e[0].score.toPrecision(4)+"

    ",r.tmscore=e[0].score.toPrecision(4)),$("#"+r.pre+"dl_rmsd_html").html(n),o.cfg.bSidebyside||o.htmlCls.dialogCls.openDlg("dl_rmsd","RMSD of alignment"),a=!0}return a}async loadOpmDataForChainalign(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=this;if(l.cfg.resnum||l.cfg.resdef)n.bCommandLoad||n.init(),await this.downloadChainalignmentPart2(e,t,void 0,s);else{let o=l.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?mmdbids2opm="+i.join("','"),a=await l.getAjaxPromise(o,"jsonp");if(a&&a.mmdbid){let i=a.mmdbid;n.selectedPdbid=i;let o="https://opm-assets.storage.googleapis.com/pdb/"+i.toLowerCase()+".pdb",d=await l.getAjaxPromise(o,"text");n.bOpm=!0;let c=!0,h=n.loadPDBCls.loadPDB(d,i,n.bOpm,c);$("#"+n.pre+"selectplane_z1").val(n.halfBilayerSize),$("#"+n.pre+"selectplane_z2").val(-n.halfBilayerSize),$("#"+n.pre+"extra_mem_z").val(n.halfBilayerSize),$("#"+n.pre+"intra_mem_z").val(-n.halfBilayerSize),n.bCommandLoad||n.init(),await r.downloadChainalignmentPart2(e,t,h,s)}else n.bCommandLoad||n.init(),await r.downloadChainalignmentPart2(e,t,void 0,s)}}async downloadMmdbAf(e,t,s){let i=this.icn3d,n=i.icn3dui;i.structArray=i.structures?Object.keys(i.structures):[],0==i.structArray.length?i.init():(i.resetConfig(),i.bResetAnno=!0,i.bResetSets=!0);let l=e.split(","),r=[];for(let e=0,t=l.length;e5)t="https://alphafold.ebi.ac.uk/files/AF-"+l+"-F1-model_"+i.AFUniprotVersion+".pdb",s=n.getAjaxPromise(t,"text");else{let e=l;5==l.length&&(e=l.substr(0,4)),t=n.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+n.cfg.bu+"&uid="+e,void 0!==n.cfg.inpara&&(t+=n.cfg.inpara),s=n.getAjaxPromise(t,"jsonp")}o.push(s)}i.ParserUtilsCls.setYourNote(i.structArray+" in iCn3D"),i.ParserUtilsCls.showLoading();let a=Promise.allSettled(o),d=await a;await this.parseMMdbAfData(d,r,t,s),void 0===s&&i.ParserUtilsCls.hideLoading()}async parseMMdbAfData(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=[];for(let s=0,i=t.length;s5&&(i=n+i),void 0===i||-1!==JSON.stringify(i).indexOf("Oops there was a problem"))return void alert("The coordinate data can NOT be retrieved for the structure "+t[s]+"...");r.push(i)}let o={},a={},d=!1;n.opts.color=n.structArray.length>1?"structure":t[0].length>5?"confidence":"chain";for(let e=0,i=t.length;e5){let s=!1;a=await n.pdbParserCls.loadPdbData(r[e],t[e],!1,c,i,d,s)}else{let s=!0,l=t[e];a=await n.mmdbParserCls.parseMmdbData(r[e],i,void 0,void 0,d,s,l)}o=l.hashUtilsCls.unionHash(o,a)}if(n.structArray.length>1&&(n.opts.color="structure"),n.setColorCls.setColorByOptions(n.opts,n.atoms),await n.ParserUtilsCls.renderStructure(),void 0!==l.cfg.rotate&&n.resizeCanvasCls.rotStruc(l.cfg.rotate,!0),s&&l.cfg.matchedchains){let e=!0,t=!0;await n.realignParserCls.realignChainOnSeqAlign(void 0,n.chainidArray,e,t),$("#"+n.pre+"dl_annotations").html(""),n.bAnnoShown=!1,$("#"+l.pre+"dl_selectannotations").hasClass("ui-dialog-content")&&$("#"+n.pre+"dl_selectannotations").dialog("isOpen")&&$("#"+n.pre+"dl_selectannotations").dialog("close")}else if(void 0!==i){let e=Object.keys(n.structures);await n.vastplusCls.vastplusAlign(e,i)}}}class Gt{constructor(e){this.icn3d=e}async dsn6Parser(e,t,s){this.icn3d.icn3dui;let i="https://edmaps.rcsb.org/maps/"+e.toLowerCase()+"_"+t+".dsn6";await this.dsn6ParserBase(i,t,s,"url",!0)}async dsn6ParserBase(e,t,s,i,n){let l=this.icn3d,r=l.icn3dui,o=this;if("2fofc"==t&&l.bAjax2fofc)l.mapData.sigma2=s,l.setOptionCls.setOption("map",t);else if("fofc"==t&&l.bAjaxfofc)l.mapData.sigma=s,l.setOptionCls.setOption("map",t);else{let a=await r.getXMLHttpRqstPromise(e,"GET","arraybuffer","rcsbEdmaps");s=o.loadDsn6Data(a,t,s,i,n),"2fofc"==t?l.bAjax2fofc=!0:"fofc"==t&&(l.bAjaxfofc=!0),l.setOptionCls.setOption("map",t)}return s}loadDsn6Data(e,t,s,i,n){let l=this.icn3d;l.icn3dui;let r,o,a={},d=e.buffer&&e.buffer instanceof ArrayBuffer?e.buffer:e,c=new Int16Array(d),h=new Uint8Array(d),p=String.fromCharCode.apply(null,h.subarray(0,512));if(0==p.indexOf(":-)"))a.xStart=parseInt(p.substr(10,5)),a.yStart=parseInt(p.substr(15,5)),a.zStart=parseInt(p.substr(20,5)),a.xExtent=parseInt(p.substr(32,5)),a.yExtent=parseInt(p.substr(38,5)),a.zExtent=parseInt(p.substr(42,5)),a.xRate=parseInt(p.substr(52,5)),a.yRate=parseInt(p.substr(58,5)),a.zRate=parseInt(p.substr(62,5)),a.xlen=1*parseFloat(p.substr(73,10)),a.ylen=1*parseFloat(p.substr(83,10)),a.zlen=1*parseFloat(p.substr(93,10)),a.alpha=parseFloat(p.substr(103,10)),a.beta=parseFloat(p.substr(113,10)),a.gamma=parseFloat(p.substr(123,10)),r=parseFloat(p.substr(138,12))/100,o=parseInt(p.substr(155,8)),a.sigma=100*parseFloat(p.substr(170,12));else{if(100!==c[18])for(let e=0,t=c.length;e>8&255}a.xStart=c[0],a.yStart=c[1],a.zStart=c[2],a.xExtent=c[3],a.yExtent=c[4],a.zExtent=c[5],a.xRate=c[6],a.yRate=c[7],a.zRate=c[8];let e=1/c[17],t=1*e;a.xlen=c[9]*t,a.ylen=c[10]*t,a.zlen=c[11]*t,a.alpha=c[12]*e,a.beta=c[13]*e,a.gamma=c[14]*e,r=c[15]/c[18],o=c[16]}let m=new Float32Array(a.xExtent*a.yExtent*a.zExtent),u=512,g=Math.ceil(a.xExtent/8),f=Math.ceil(a.yExtent/8),b=Math.ceil(a.zExtent/8),C=-999;for(let e=0;eC&&(C=m[e]),++u}}}}return n||(s=this.setSigma(C,i,t,s)),"2fofc"==t?(l.mapData.header2=a,l.mapData.data2=m,l.mapData.matrix2=this.getMatrix(a),l.mapData.type2=t,l.mapData.sigma2=s):(l.mapData.header=a,l.mapData.data=m,l.mapData.matrix=this.getMatrix(a),l.mapData.type=t,l.mapData.sigma=s),s}setSigma(e,t,s,i){let n,l=this.icn3d.icn3dui;"file"==t?n="dsn6sigma"+s:"url"==t&&(n="dsn6sigmaurl"+s);let r="2fofc"==s?.5:.3;return n&&($("#"+l.pre+n).val()?i=$("#"+l.pre+n).val():(i=(r*e).toFixed(2),$("#"+l.pre+n).val(i))),i}getMatrix(e){this.icn3d.icn3dui;let t=e,s=[t.xlen,0,0],i=[t.ylen*Math.cos(Math.PI/180*t.gamma),t.ylen*Math.sin(Math.PI/180*t.gamma),0],n=[t.zlen*Math.cos(Math.PI/180*t.beta),t.zlen*(Math.cos(Math.PI/180*t.alpha)-Math.cos(Math.PI/180*t.gamma)*Math.cos(Math.PI/180*t.beta))/Math.sin(Math.PI/180*t.gamma),0];n[2]=Math.sqrt(t.zlen*t.zlen*Math.sin(Math.PI/180*t.beta)*Math.sin(Math.PI/180*t.beta)-n[1]*n[1]);let l=[[],s,i,n],r=[0,t.xRate,t.yRate,t.zRate],o=[0,1,2,3],a=new THREE.Matrix4;return a.set(l[o[1]][0]/r[o[1]],l[o[2]][0]/r[o[2]],l[o[3]][0]/r[o[3]],0,l[o[1]][1]/r[o[1]],l[o[2]][1]/r[o[2]],l[o[3]][1]/r[o[3]],0,l[o[1]][2]/r[o[1]],l[o[2]][2]/r[o[2]],l[o[3]][2]/r[o[3]],0,0,0,0,1),a.multiply((new THREE.Matrix4).makeTranslation(t.xStart,t.yStart,t.zStart)),a}loadDsn6File(e){var t=this.icn3d,s=t.icn3dui;let i=this,n=$("#"+t.pre+"dsn6file"+e)[0].files[0],l=$("#"+t.pre+"dsn6sigma"+e).val();if(n){s.utilsCls.checkFileAPI();let t=new FileReader;t.onload=function(t){let n=i.icn3d,r=t.target.result;l=i.loadDsn6Data(r,e,l,"file"),"2fofc"==e?n.bAjax2fofc=!0:"fofc"==e&&(n.bAjaxfofc=!0),n.setOptionCls.setOption("map",e),s.htmlCls.clickMenuCls.setLogCmd("load map file "+$("#"+n.pre+"dsn6file"+e).val()+" with sigma "+l,!1)},t.readAsArrayBuffer(n)}else alert("Please select a file before clicking 'Load'")}loadDsn6FileUrl(e){var t=this.icn3d,s=t.icn3dui;let i=$("#"+t.pre+"dsn6fileurl"+e).val(),n=$("#"+t.pre+"dsn6sigmaurl"+e).val();i?(n=this.dsn6ParserBase(i,e,n,"url"),s.htmlCls.clickMenuCls.setLogCmd("set map "+e+" sigma "+n+" file dsn6 | "+encodeURIComponent(i),!0)):alert("Please input the file URL before clicking 'Load'")}}class Vt{constructor(e){this.icn3d=e}async ccp4ParserBase(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=await l.getXMLHttpRqstPromise(e,"GET","arraybuffer","");return s=this.load_map_from_buffer(r,t,s,i,!0),n.setOptionCls.setOption("map",t),s}load_map_from_buffer(e,t,s,i,n){let l=this.icn3d;if(l.icn3dui,e.byteLength<1024)throw Error("File shorter than 1024 bytes.");const r=new Int32Array(e,0,256);if(542130509!==r[52])throw Error("not a CCP4 map");const o=[r[0],r[1],r[2]],a=r[3];let d;if(2===a)d=4;else{if(0!==a)throw Error("Only Mode 2 and Mode 0 of CCP4 map is supported.");d=1}const c=[r[4],r[5],r[6]],h=[r[7],r[8],r[9]],p=r[23];if(1024+p+d*o[0]*o[1]*o[2]!==e.byteLength)throw Error("ccp4 file too short or too long");const m=new Float32Array(e,0,e.byteLength/4),u=new Yt(h),g=new Wt(m[10],m[11],m[12],m[13],m[14],m[15]),f=[r[16],r[17],r[18]],b=f.indexOf(1),C=f.indexOf(2),y=f.indexOf(3),v=m[19],_=m[20];if(p%4!=0)throw Error("CCP4 map with NSYMBT not divisible by 4 is not supported.");let w;w=2===a?m:new Int8Array(e);let S=(1024+p)/d|0,A=1,x=0;0===a&&-128===r[39]&&127===r[40]&&(A=(_-v)/255,x=.5*(v+_+A));const k=[c[0]+o[0],c[1]+o[1],c[2]+o[2]];let O=[0,0,0],R=-999;for(O[2]=c[2];O[2]R&&(R=e),S++}return n||(s=l.dsn6ParserCls.setSigma(R,i,t,s)),"2fofc"==t?(l.mapData.ccp4=1,l.mapData.grid2=u,l.mapData.unit_cell2=g,l.mapData.type2=t,l.mapData.sigma2=s):(l.mapData.ccp4=1,l.mapData.grid=u,l.mapData.unit_cell=g,l.mapData.type=t,l.mapData.sigma=s),s}load_maps_from_mtz_buffer(e,t,s,i,n){let l=this.icn3d;l.icn3dui;let r="fofc"==t,o=e.calculate_map(r),a=e.cell;const d=new Wt(a.a,a.b,a.c,a.alpha,a.beta,a.gamma);let c=-999;for(let e=0,t=o.length;ec&&(c=o[e]);n||(s=l.dsn6ParserCls.setSigma(c,i,t,s));const h=new Yt([e.nx,e.ny,e.nz]);return h.values.set(o),"2fofc"==t?(l.mapData.ccp4=1,l.mapData.grid2=h,l.mapData.unit_cell2=d,l.mapData.type2=t,l.mapData.sigma2=s):(l.mapData.ccp4=1,l.mapData.grid=h,l.mapData.unit_cell=d,l.mapData.type=t,l.mapData.sigma=s),e.delete(),s}parse_symop(e){const t=e.toLowerCase().replace(/\s+/g,"").split(",");if(3!==t.length)throw Error("Unexpected symop: "+e);let s=[];for(let i=0;i<3;i++){const n=t[i].split(/(?=[+-])/);let l=[0,0,0,0];for(let t=0;t0;for(let s=a[0];s<=d[0];s++)for(let i=a[1];i<=d[1];i++)for(let r=a[2];r<=d[2];r++){let o=e.grid2frac(s,i,r),a=t.orthogonalize(o);h.push(a);let d=new THREE.Vector3(a[0],a[1],a[2]),c=l.rayCls.getAtomsFromPosition(d,1,l.hAtoms)||!m?e.get_grid_value(s,i,r):0;"fofc_pos"==n&&c<0&&(c=0),"fofc_neg"==n&&(c=c>0?0:-c),p.push(c)}return{size:c,values:p,points:h}}marchingCubes(e,t,s,i,n){this.icn3d.icn3dui;const l=new Int32Array([0,0,514,770,1030,1030,1540,1796,2052,2053,2566,2566,3082,3331,3592,3840,144,152,658,658,1174,1182,1684,1684,2196,2196,2710,2710,3226,3218,3729,3728,560,560,51,314,1590,1590,1076,1084,2612,2613,2103,2358,3642,3890,3121,3376,672,680,163,170,1702,1711,1444,1196,2724,2724,2470,2214,4010,3747,3233,3232,1120,1120,1634,1890,102,102,613,868,3172,3173,3686,3686,2154,2147,2665,2656,1264,1272,1778,1778,246,254,757,764,3316,3316,3830,3830,2298,2291,2809,2800,1616,1616,1107,1362,598,598,84,340,3668,3924,3159,3414,2650,2898,2137,2384,1984,1729,1474,1218,966,718,197,196,4036,3781,3526,3270,3018,2754,2241,2240,2240,2240,2754,3010,3270,3270,3780,4044,196,197,710,966,1218,1474,1729,1984,2384,2137,2898,2650,3414,3159,3668,3676,340,84,606,598,1362,1107,1624,1616,2800,2800,2291,2298,3830,3830,3316,3324,756,1013,255,502,1778,1779,1273,1520,2656,2665,2147,2154,3686,3687,3429,3180,868,613,358,102,1898,1635,1120,1120,3232,3232,3746,4002,2214,2214,2724,2980,1196,1444,1710,1958,170,163,680,672,3376,3121,3890,3642,2358,2103,2869,2612,1084,1076,1854,1590,314,51,825,560,3728,3728,3218,3226,2710,2710,2196,2204,1684,1685,1183,1174,658,914,152,144,3840,3592,3331,3082,2566,2574,2053,2052,1796,1540,1286,1030,770,514,0,0]),r="snapped MC"===n,o=[[],[],[1,9],[1,8,1,9],[2,10,10,1],[2,10,10,1],[9,2,2,10,10,9],[2,8,2,10,10,8,10,9],[11,2],[0,11,11,2],[1,9,11,2],[1,11,11,2,1,9,9,11],[3,10,10,1,11,10],[0,10,10,1,8,10,11,10],[3,9,11,9,11,10,10,9],[8,10,10,9,11,10],[4,7],[4,3,4,7],[1,9,4,7],[4,1,1,9,4,7,7,1],[2,10,10,1,4,7],[3,4,4,7,2,10,10,1],[9,2,2,10,10,9,4,7],[2,10,10,9,9,2,9,7,7,2,4,7],[4,7,11,2],[11,4,4,7,11,2,2,4],[1,9,4,7,11,2],[4,7,11,4,11,9,11,2,2,9,1,9],[3,10,10,1,11,10,4,7],[1,11,11,10,10,1,1,4,4,11,4,7],[4,7,0,11,11,9,11,10,10,9],[4,7,11,4,11,9,11,10,10,9],[9,5,5,4],[9,5,5,4],[0,5,5,4,1,5],[8,5,5,4,3,5,1,5],[2,10,10,1,9,5,5,4],[2,10,10,1,9,5,5,4],[5,2,2,10,10,5,5,4,4,2],[2,10,10,5,5,2,5,3,5,4,4,3],[9,5,5,4,11,2],[0,11,11,2,9,5,5,4],[0,5,5,4,1,5,11,2],[1,5,5,2,5,8,8,2,11,2,5,4],[10,3,11,10,10,1,9,5,5,4],[9,5,5,4,8,1,8,10,10,1,11,10],[5,4,0,5,0,11,11,5,11,10,10,5],[5,4,8,5,8,10,10,5,11,10],[9,7,5,7,9,5],[9,3,9,5,5,3,5,7],[0,7,1,7,1,5,5,7],[1,5,5,3,5,7],[9,7,9,5,5,7,10,1,2,10],[10,1,2,10,9,5,5,0,5,3,5,7],[2,8,2,5,5,8,5,7,10,5,2,10],[2,10,10,5,5,2,5,3,5,7],[7,9,9,5,5,7,11,2],[9,5,5,7,7,9,7,2,2,9,11,2],[11,2,1,8,1,7,1,5,5,7],[11,2,1,11,1,7,1,5,5,7],[9,5,5,8,5,7,10,1,3,10,11,10],[5,7,7,0,0,5,9,5,11,0,0,10,10,1,11,10],[11,10,10,0,0,11,10,5,5,0,0,7,5,7],[11,10,10,5,5,11,5,7],[10,6,6,5,5,10],[5,10,10,6,6,5],[1,9,5,10,10,6,6,5],[1,8,1,9,5,10,10,6,6,5],[1,6,6,5,5,1,2,6],[1,6,6,5,5,1,2,6],[9,6,6,5,5,9,0,6,2,6],[5,9,8,5,8,2,2,5,2,6,6,5],[11,2,10,6,6,5,5,10],[11,0,11,2,10,6,6,5,5,10],[1,9,11,2,5,10,10,6,6,5],[5,10,10,6,6,5,1,9,9,2,9,11,11,2],[6,3,11,6,6,5,5,3,5,1],[11,0,11,5,5,0,5,1,11,6,6,5],[11,6,6,3,6,0,6,5,5,0,5,9],[6,5,5,9,9,6,9,11,11,6],[5,10,10,6,6,5,4,7],[4,3,4,7,6,5,5,10,10,6],[1,9,5,10,10,6,6,5,4,7],[10,6,6,5,5,10,1,9,9,7,7,1,4,7],[6,1,2,6,6,5,5,1,4,7],[2,5,5,1,2,6,6,5,4,3,4,7],[4,7,0,5,5,9,0,6,6,5,2,6],[3,9,9,7,4,7,2,9,5,9,9,6,6,5,2,6],[11,2,4,7,10,6,6,5,5,10],[5,10,10,6,6,5,4,7,7,2,2,4,11,2],[1,9,4,7,11,2,5,10,10,6,6,5],[9,2,1,9,9,11,11,2,4,11,4,7,5,10,10,6,6,5],[4,7,11,5,5,3,5,1,11,6,6,5],[5,1,1,11,11,5,11,6,6,5,0,11,11,4,4,7],[0,5,5,9,0,6,6,5,3,6,11,6,4,7],[6,5,5,9,9,6,9,11,11,6,4,7,7,9],[10,4,9,10,6,4,10,6],[4,10,10,6,6,4,9,10],[10,0,1,10,10,6,6,0,6,4],[1,8,1,6,6,8,6,4,1,10,10,6],[1,4,9,1,2,4,2,6,6,4],[2,9,9,1,2,4,2,6,6,4],[2,4,2,6,6,4],[2,8,2,4,2,6,6,4],[10,4,9,10,10,6,6,4,11,2],[8,2,11,2,9,10,10,4,10,6,6,4],[11,2,1,6,6,0,6,4,1,10,10,6],[6,4,4,1,1,6,1,10,10,6,8,1,1,11,11,2],[9,6,6,4,9,3,3,6,9,1,11,6],[11,1,1,8,11,6,6,1,9,1,1,4,6,4],[11,6,6,3,6,0,6,4],[6,4,8,6,11,6],[7,10,10,6,6,7,8,10,9,10],[0,7,0,10,10,7,9,10,6,7,10,6],[10,6,6,7,7,10,1,10,7,1,8,1],[10,6,6,7,7,10,7,1,1,10],[2,6,6,1,6,8,8,1,9,1,6,7],[2,6,6,9,9,2,9,1,6,7,7,9,9,3],[0,7,0,6,6,7,2,6],[2,7,6,7,2,6],[11,2,10,6,6,8,8,10,9,10,6,7],[0,7,7,2,11,2,9,7,6,7,7,10,10,6,9,10],[1,8,1,7,1,10,10,7,6,7,10,6,11,2],[11,2,1,11,1,7,10,6,6,1,1,10,6,7],[9,6,6,8,6,7,9,1,1,6,11,6,6,3],[9,1,11,6,6,7],[0,7,0,6,6,7,11,0,11,6],[11,6,6,7],[7,6,6,11],[7,6,6,11],[1,9,7,6,6,11],[8,1,1,9,7,6,6,11],[10,1,2,10,6,11,7,6],[2,10,10,1,6,11,7,6],[2,9,2,10,10,9,6,11,7,6],[6,11,7,6,2,10,10,3,10,8,10,9],[7,2,6,2,7,6],[7,0,7,6,6,0,6,2],[2,7,7,6,6,2,1,9],[1,6,6,2,1,8,8,6,1,9,7,6],[10,7,7,6,6,10,10,1,1,7],[10,7,7,6,6,10,1,7,10,1,1,8],[7,0,7,10,10,0,10,9,6,10,7,6],[7,6,6,10,10,7,10,8,10,9],[6,8,4,6,6,11],[3,6,6,11,0,6,4,6],[8,6,6,11,4,6,1,9],[4,6,6,9,6,3,3,9,1,9,6,11],[6,8,4,6,6,11,2,10,10,1],[2,10,10,1,0,11,0,6,6,11,4,6],[4,11,4,6,6,11,2,9,2,10,10,9],[10,9,9,3,3,10,2,10,4,3,3,6,6,11,4,6],[8,2,4,2,4,6,6,2],[4,2,4,6,6,2],[1,9,3,4,4,2,4,6,6,2],[1,9,4,1,4,2,4,6,6,2],[8,1,8,6,6,1,4,6,6,10,10,1],[10,1,0,10,0,6,6,10,4,6],[4,6,6,3,3,4,6,10,10,3,3,9,10,9],[10,9,4,10,6,10,4,6],[9,5,5,4,7,6,6,11],[9,5,5,4,7,6,6,11],[5,0,1,5,5,4,7,6,6,11],[7,6,6,11,3,4,3,5,5,4,1,5],[9,5,5,4,10,1,2,10,7,6,6,11],[6,11,7,6,2,10,10,1,9,5,5,4],[7,6,6,11,5,4,4,10,10,5,4,2,2,10],[3,4,3,5,5,4,2,5,10,5,2,10,7,6,6,11],[7,2,7,6,6,2,5,4,9,5],[9,5,5,4,8,6,6,0,6,2,7,6],[3,6,6,2,7,6,1,5,5,0,5,4],[6,2,2,8,8,6,7,6,1,8,8,5,5,4,1,5],[9,5,5,4,10,1,1,6,6,10,1,7,7,6],[1,6,6,10,10,1,1,7,7,6,0,7,9,5,5,4],[0,10,10,4,10,5,5,4,3,10,6,10,10,7,7,6],[7,6,6,10,10,7,10,8,5,4,4,10,10,5],[6,9,9,5,5,6,6,11,11,9],[3,6,6,11,0,6,0,5,5,6,9,5],[0,11,0,5,5,11,1,5,5,6,6,11],[6,11,3,6,3,5,5,6,1,5],[2,10,10,1,9,5,5,11,11,9,5,6,6,11],[0,11,0,6,6,11,9,6,5,6,9,5,2,10,10,1],[8,5,5,11,5,6,6,11,0,5,10,5,5,2,2,10],[6,11,3,6,3,5,5,6,2,10,10,3,10,5],[5,8,9,5,5,2,2,8,5,6,6,2],[9,5,5,6,6,9,6,0,6,2],[1,5,5,8,8,1,5,6,6,8,8,2,6,2],[1,5,5,6,6,1,6,2],[3,6,6,1,6,10,10,1,8,6,5,6,6,9,9,5],[10,1,0,10,0,6,6,10,9,5,5,0,5,6],[5,6,6,10,10,5],[10,5,5,6,6,10],[11,5,5,10,10,11,7,5],[11,5,5,10,10,11,7,5],[5,11,7,5,5,10,10,11,1,9],[10,7,7,5,5,10,10,11,8,1,1,9],[11,1,2,11,7,1,7,5,5,1],[2,7,7,1,7,5,5,1,2,11],[9,7,7,5,5,9,9,2,2,7,2,11],[7,5,5,2,2,7,2,11,5,9,9,2,2,8],[2,5,5,10,10,2,3,5,7,5],[8,2,8,5,5,2,7,5,10,2,5,10],[1,9,5,10,10,3,3,5,7,5,10,2],[8,2,2,9,1,9,7,2,10,2,2,5,5,10,7,5],[3,5,5,1,7,5],[7,0,7,1,7,5,5,1],[3,9,3,5,5,9,7,5],[7,9,5,9,7,5],[5,8,4,5,5,10,10,8,10,11],[5,0,4,5,5,11,11,0,5,10,10,11],[1,9,4,10,10,8,10,11,4,5,5,10],[10,11,11,4,4,10,4,5,5,10,3,4,4,1,1,9],[2,5,5,1,2,8,8,5,2,11,4,5],[4,11,11,0,4,5,5,11,2,11,11,1,5,1],[2,5,5,0,5,9,2,11,11,5,4,5,5,8],[4,5,5,9,2,11],[2,5,5,10,10,2,3,5,3,4,4,5],[5,10,10,2,2,5,2,4,4,5],[3,10,10,2,3,5,5,10,8,5,4,5,1,9],[5,10,10,2,2,5,2,4,4,5,1,9,9,2],[4,5,5,8,5,3,5,1],[4,5,5,0,5,1],[4,5,5,8,5,3,0,5,5,9],[4,5,5,9],[4,11,7,4,9,11,9,10,10,11],[9,7,7,4,9,11,9,10,10,11],[1,10,10,11,11,1,11,4,4,1,7,4],[1,4,4,3,1,10,10,4,7,4,4,11,10,11],[4,11,7,4,9,11,9,2,2,11,9,1],[9,7,7,4,9,11,9,1,1,11,2,11],[7,4,4,11,4,2,2,11],[7,4,4,11,4,2,2,11,3,4],[2,9,9,10,10,2,2,7,7,9,7,4],[9,10,10,7,7,9,7,4,10,2,2,7,7,0],[7,10,10,3,10,2,7,4,4,10,1,10,10,0],[1,10,10,2,7,4],[9,1,1,4,1,7,7,4],[9,1,1,4,1,7,7,4,8,1],[3,4,7,4],[7,4],[9,10,10,8,10,11],[9,3,9,11,9,10,10,11],[1,10,10,0,10,8,10,11],[1,10,10,3,10,11],[2,11,11,1,11,9,9,1],[9,3,9,11,2,9,9,1,2,11],[2,11,11,0],[2,11],[8,2,8,10,10,2,9,10],[9,10,10,2,2,9],[8,2,8,10,10,2,1,8,1,10],[1,10,10,2],[8,1,9,1],[9,1],[],[]];let a=new Array(12);const d=this.calculateVertOffsets(e),c=[[0,1],[1,2],[2,3],[3,0],[4,5],[5,6],[6,7],[7,4],[0,4],[1,5],[2,6],[3,7]];let h=new Float32Array(8),p=[0,0,0],m=[p,p,p,p,p,p,p,p];const u=e[0],g=e[1],f=e[2];if(null==t||null==s)return;let b=[],C=[],y=0;for(let e=0;e.85?t=1:t<.15&&(t=0));const s=m[e[0]],n=m[e[1]];b.push(s[0]+(n[0]-s[0])*t,s[1]+(n[1]-s[1])*t,s[2]+(n[2]-s[2])*t),a[v]=y++}const A=o[w];for(v=0;v=0?s:s+t}grid2index(e,t,s){return e=this.modulo(e,this.dim[0]),t=this.modulo(t,this.dim[1]),s=this.modulo(s,this.dim[2]),this.dim[2]*(this.dim[1]*e+t)+s}grid2index_unchecked(e,t,s){return this.dim[2]*(this.dim[1]*e+t)+s}grid2frac(e,t,s){return[e/this.dim[0],t/this.dim[1],s/this.dim[2]]}frac2grid(e){return[0|Math.floor(e[0]*this.dim[0]),0|Math.floor(e[1]*this.dim[1]),0|Math.floor(e[2]*this.dim[2])]}set_grid_value(e,t,s,i){const n=this.grid2index(e,t,s);this.values[n]=i}get_grid_value(e,t,s){const i=this.grid2index(e,t,s);return this.values[i]}}class Xt{constructor(e){this.icn3d=e}async mtzParserBase(e,t,s,i,n){let l=this.icn3d,r=l.icn3dui,o=await r.getXMLHttpRqstPromise(e,"GET","arraybuffer","");return s=await this.loadMtzFileBase(o,t,s,i,n,e),l.setOptionCls.setOption("map",t),s}loadMtzFile(e){var t=this.icn3d,s=t.icn3dui;let i=this,n=$("#"+t.pre+"dsn6file"+e)[0].files[0],l=$("#"+t.pre+"dsn6sigma"+e).val();if(n){s.utilsCls.checkFileAPI();let t=new FileReader;t.onload=async function(t){let n=i.icn3d;l=await i.loadMtzFileBase(t.target.result,e,l,"file"),s.htmlCls.clickMenuCls.setLogCmd("load map file "+$("#"+n.pre+"dsn6file"+e).val()+" with sigma "+l,!1)},t.readAsArrayBuffer(n)}else alert("Please select a file before clicking 'Load'")}async loadMtzFileBase(e,t,s,i,n,l){var r=this.icn3d,o=r.icn3dui;if(void 0===r.bMtz){let e="./script/mtz.js";await o.getAjaxPromise(e,"script"),r.bMtz=!0}GemmiMtz().then((function(a){let d=a.readMtz(e);return s=r.ccp4ParserCls.load_maps_from_mtz_buffer(d,t,s,i,n),r.setOptionCls.setOption("map",t),l&&o.htmlCls.clickMenuCls.setLogCmd("set map "+t+" sigma "+s+" file mtz | "+encodeURIComponent(l),!0),s}))}async loadMtzFileUrl(e){var t=this.icn3d;t.icn3dui;let s=$("#"+t.pre+"dsn6fileurl"+e).val(),i=$("#"+t.pre+"dsn6sigmaurl"+e).val();s?(i=await this.mtzParserBase(s,e,i,"url"),console.log("### sigma "+i)):alert("Please input the file URL before clicking 'Load'")}}class Kt{constructor(e){this.icn3d=e}async downloadMmcif(e){let t=this.icn3d,s=t.icn3dui;t.ParserUtilsCls.setYourNote(e.toUpperCase()+"(MMCIF) in iCn3D");let i="https://files.rcsb.org/view/"+e+".cif",n=await s.getAjaxPromise(i,"text",!0);i=s.htmlCls.baseUrl+"mmcifparser/mmcifparser.cgi";let l={mmciffile:n},r=await s.getAjaxPostPromise(i,l,!0);await this.loadMmcifData(r,e)}async downloadMmcifSymmetry(e,t){let s=this.icn3d,i=s.icn3dui,n=i.bNode||i.utilsCls.isMac()?"https://files.rcsb.org/view/"+e+".cif":"https://files.rcsb.org/header/"+e+".cif",l=await i.getAjaxPromise(n,"text",!1,"The structure "+e+" was not found...");n=i.htmlCls.baseUrl+"mmcifparser/mmcifparser.cgi";let r={mmcifheader:l},o=await i.getAjaxPostPromise(n,r,!1,"The mmCIF data of "+e+" can not be parsed...");if(void 0!==o.emd&&(s.emd=o.emd),void 0!==o.organism&&(s.organism=o.organism),s.bAssemblyUseAsu){for(let e=0,t=o.assembly.length;es.maxatomcnt&&(s.bAssembly=!0)}if("mmtfid"===t&&void 0!==o.missingseq){let t=0,n="";for(let l=0,r=o.missingseq.length;lt)&&(s.chainMissingResidueArray[c].push(h),t=d,n=a)}s.loadPDBCls.adjustSeq(s.chainMissingResidueArray)}}async loadMmcifData(e,t){let s=this.icn3d;if(s.icn3dui,t||(t=e.mmcif),t||(t=s.defaultPdbId),void 0===e.atoms)return!1;s.init(),void 0!==e.emd&&(s.emd=e.emd),void 0!==e.organism&&(s.organism=e.organism),void 0!==s.emd?($("#"+s.pre+"mapWrapper1").hide(),$("#"+s.pre+"mapWrapper2").hide(),$("#"+s.pre+"mapWrapper3").hide()):($("#"+s.pre+"emmapWrapper1").hide(),$("#"+s.pre+"emmapWrapper2").hide(),$("#"+s.pre+"emmapWrapper3").hide()),await s.opmParserCls.loadOpmData(e,t,void 0,"mmcif")}}class Jt{constructor(e){this.icn3d=e}async downloadMmdb(e,t){let s,i=this.icn3d,n=i.icn3dui;try{if(s=await this.loadMmdbPrms(e,t),!s||s.error)return void this.getNoData(e,t)}catch(s){return void this.getNoData(e,t)}if(0!=Object.keys(s.atoms).length)if(n.utilsCls.isCalphaPhosOnly(s.atoms)||s.atomCount<=i.maxatomcnt)await this.parseMmdbData(s);else{let s;try{s=await this.loadMmdbPrms(e,t,!0)}catch(s){return void this.getNoData(e,t)}await this.parseMmdbData(s)}else{let e=s.pdbId;await i.mmtfParserCls.downloadMmtf(e)}}async downloadGi(e){let t=this.icn3d;t.icn3dui,t.bCid=void 0;await this.downloadMmdb(e,!0)}async downloadBlast_rep_id(e){let t=this.icn3d,s=t.icn3dui,i=e.split(",");s.cfg.query_id=i[0],s.cfg.blast_rep_id=i[1];let n=s.cfg.blast_rep_id.split("_")[0];4==n.length?await this.downloadMmdb(n):(t.blastAcxn=s.cfg.blast_rep_id.split(".")[0],await this.downloadRefseq(t.blastAcxn,!0))}async downloadRefseq(e,t){let s=this.icn3d,i=s.icn3dui,n=i.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?refseq2uniprot="+e;i.cfg.refseqid=e;let l=await i.getAjaxPromise(n,"jsonp",!1,"The protein accession "+e+" can not be mapped to AlphaFold UniProt ID...");if(!l||!l.uniprot)return void alert("The accession "+e+" can not be mapped to AlphaFold UniProt ID. It will be treated as a UniProt ID instead.");i.cfg.afid=l.uniprot,s.uniprot2acc||(s.uniprot2acc={}),s.uniprot2acc[l.uniprot]=e,t&&(i.cfg.blast_rep_id=i.cfg.afid+"_A");await s.pdbParserCls.downloadPdb(i.cfg.afid,!0)}async downloadProteinname(e){let t=this.icn3d,s=t.icn3dui;s.icn3d.bCid=void 0;let i=s.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?protein2acc="+e,n=(await s.getAjaxPromise(i,"jsonp")).acc;if(0==n.length)return void(s.bNode||alert("The protein/gene name "+e+" can not be mapped to RefSeq proteins..."));let l=[];for(let e=0,t=n.length;e=20231001||!i.cfg.date&&parseInt(i.utilsCls.getDateDigitStr())>=20231001)&&(h=h.replace(/_/g,"")),void 0===d[h]?d[h]=1:++d[h];let p=n+"_"+(1===d[h]?h:h+d[h].toString());r[e]=c,o[p]=e,a[e]=p,s.chainsColor[p]=void 0===t||i.cfg.mmdbafid?i.parasCls.thr(c):i.parasCls.thr(i.htmlCls.GREY8);let m=void 0===l[e].geneId?"":l[e].geneId,u=void 0===l[e].geneSymbol?"":l[e].geneSymbol,g=void 0===l[e].geneDesc?"":l[e].geneDesc;s.chainsGene[p]={geneId:m,geneSymbol:u,geneDesc:g}}s.molid2chain=a,$("#"+s.pre+"accordion5").show()}loadMmdbPrms(e,t,s){let i,n=this.icn3d,l=n.icn3dui;return i=t?l.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+l.cfg.bu+"&simple=1&gi="+e:l.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+l.cfg.bu+"&simple=1&uid="+e,void 0!==l.cfg.blast_rep_id&&(i+="&bu=0"),void 0!==l.cfg.inpara&&(i+=l.cfg.inpara),s&&(i+="&complexity=2"),void 0===n.chainids2resids&&(n.chainids2resids={}),l.getAjaxPromise(i,"jsonp",!0)}}class Qt{constructor(e){this.icn3d=e}async downloadMmtf(e){let t=this.icn3d,s=t.icn3dui;t.ParserUtilsCls.setYourNote(e.toUpperCase()+"(MMTF) in iCn3D");let i=await s.getMmtfReducedPromise(e);if(10*i.numAtoms>t.maxatomcnt){let s=!1;if(0==Object.keys(i).length)return void alert("This PDB structure is not found at RCSB...");await t.opmParserCls.loadOpmData(i,e,s,"mmtf")}else{let i=await s.getMmtfPromise(e),n=!0;if(0==Object.keys(i).length)return void alert("This PDB structure is not found at RCSB...");await t.opmParserCls.loadOpmData(i,e,n,"mmtf")}}async parseMmtfData(e,t,s){let i=this.icn3d,n=i.icn3dui;e.numAtoms,i.init();let l=new THREE.Vector3(9999,9999,9999),r=new THREE.Vector3(-9999,-9999,-9999),o=new THREE.Vector3,a=e.structureId;if(i.molTitle=e.title,void 0!==e.bioAssemblyList&&void 0!==e.bioAssemblyList[0]&&e.bioAssemblyList[0].transformList.length>1){i.biomtMatrices=[];for(let t=0,s=e.bioAssemblyList[0].transformList.length;t1&&($("#"+i.pre+"assemblyWrapper").show(),i.asuCnt=i.biomtMatrices.length);let d,c,h,p,m,u,g,f,b,C,y,v,_,w,S,A,x,k,O,R={},I=[],T="coil",E="",P=0,M=0,D={onModel:function(e){d=0===e.modelIndex?a:a+(e.modelIndex+1).toString()},onChain:function(e){c=e.chainName;let t=d+"_"+c;void 0===i.structures[d]&&(i.structures[d]=[]),i.structures[d].push(t)},onGroup:function(e){h=e.groupName,p=e.groupId;let t=d+"_"+c+"_"+p;m=0===e.secStruct||2===e.secStruct||4===e.secStruct?"helix":3===e.secStruct?"sheet":-1===e.secStruct?"other":"coil";let s=!1;if(c!==E){if(x=void 0,O=void 0,"coil"!==m&&"other"!==m?(u=!0,g=!1):(u=!1,g=!1),"coil"!==T&&"other"!==T){let e=d+"_"+E+"_"+P.toString();for(let t in i.residues[e])i.atoms[t].ssbegin=!1,i.atoms[t].ssend=!0}}else x=A,O=k,m!==T?"coil"===T||"other"===T?(u=!0,g=!1):"coil"===m||"other"===m?(s=!0,u=!1,g=!1):("sheet"===T&&"helix"===m||"helix"===T&&"sheet"===m)&&(s=!0,u=!0,g=!1):(u=!1,g=!1);if(s&&!isNaN(p)){let e=d+"_"+c+"_"+(p-1).toString();for(let t in i.residues[e])i.atoms[t].ssbegin=!1,i.atoms[t].ssend=!0}T=m,E=c,P=p,f=!1,b=!1,C=!1,"non-polymer"===e.chemCompType.toLowerCase()||"other"===e.chemCompType.toLowerCase()||-1!==e.chemCompType.toLowerCase().indexOf("saccharide")?f=!0:-1!==e.chemCompType.toLowerCase().indexOf("peptide")?b=!0:-1!==e.chemCompType.toLowerCase().indexOf("dna")||-1!==e.chemCompType.toLowerCase().indexOf("rna")?C=!0:b=!0;let l=d+"_"+c,r={};r.resi=p,r.name=n.utilsCls.residueName2Abbr(h),i.residueId2Name[t]=r.name,r.resi%10==0&&r.resi.toString();let o="-";"helix"===m?o="H":"sheet"===m?o="E":"coil"===m?o="c":"other"===m&&(o="o"),void 0===i.chainsSeq[l]&&(i.chainsSeq[l]=[]),i.bFullUi&&i.chainsSeq[l].push(r),i.secondaries[t]=o},onAtom:function(e){if(y=e.element,v=e.atomName,_=new THREE.Vector3(e.xCoord,e.yCoord,e.zCoord),w=e.bFactor,S=e.altLoc,"\0"===e.altLoc&&(S=""),""===S||"A"===S){++M,"SG"===v&&I.push(M),R[e.atomIndex]=M;let t={het:f,serial:M,name:v,alt:S,resn:h,structure:d,chain:c,resi:p,coord:_,b:w,elem:y,bonds:[],bondOrder:[],ss:m,ssbegin:u,ssend:g};if(t.het||"C"!==t.name||(A=M),t.het||"O"!==t.name||(k=M),!t.het&&"N"===t.name&&void 0!==x&&void 0!==O){let e=i.atoms[x].coord.distanceTo(i.atoms[O].coord),s=t.coord.x+(i.atoms[x].coord.x-i.atoms[O].coord.x)/e,n=t.coord.y+(i.atoms[x].coord.y-i.atoms[O].coord.y)/e,l=t.coord.z+(i.atoms[x].coord.z-i.atoms[O].coord.z)/e;t.hcoord=new THREE.Vector3(s,n,l)}i.atoms[M]=t,l.min(_),r.max(_),o.add(_);let a=d+"_"+c,T=a+"_"+p;void 0===i.chains[a]&&(i.chains[a]={}),i.chains[a][M]=1,void 0===i.residues[T]&&(i.residues[T]={}),i.residues[T][M]=1,b?(i.proteins[M]=1,"CA"===v&&(i.calphas[M]=1),"N"!==v&&"H"!==v&&"CA"!==v&&"HA"!==v&&"C"!==v&&"O"!==v&&(i.sidec[M]=1)):C?(i.nucleotides[M]=1,(!s||"O3'"!=v&&"O3*"!=v)&&(s||"P"!=v)||(i.nucleotidesO3[M]=1),-1===n.parasCls.nuclMainArray.indexOf(v)&&(i.ntbase[M]=1)):y.toLowerCase()===h.toLowerCase()?i.ions[M]=1:"HOH"===h||"WAT"===h||"SQL"===h||"H2O"===h||"W"===h||"DOD"===h||"D3O"===h?i.water[M]=1:i.chemicals[M]=1,i.dAtoms[M]=1,i.hAtoms[M]=1}},onBond:function(e){let t=R[e.atomIndex1],s=R[e.atomIndex2];if(R.hasOwnProperty(e.atomIndex1)&&R.hasOwnProperty(e.atomIndex2)&&(i.atoms[t].bonds.push(s),i.atoms[s].bonds.push(t),f)){let n=e.bondOrder;i.atoms[t].bondOrder.push(n),i.atoms[s].bondOrder.push(n),2===n?(i.doublebonds[t+"_"+s]=1,i.doublebonds[s+"_"+t]=1):3===n&&(i.triplebonds[t+"_"+s]=1,i.triplebonds[s+"_"+t]=1)}}};MMTF.traverse(e,D),i.loadPDBCls.setResidMapping();for(let e=0,t=I.length;ei.maxatomcnt||void 0!==i.biomtMatrices&&i.biomtMatrices.length*i.cnt>10*i.maxatomcnt)&&(i.opts.proteins="c alpha trace",i.opts.nucleotides="o3 trace"),i.pmin=l,i.pmax=r,i.center=i.ParserUtilsCls.getGeoCenter(i.pmin,i.pmax),i.maxD=i.ParserUtilsCls.getStructureSize(i.atoms,i.pmin,i.pmax,i.center),i.maxD<5&&(i.maxD=5),i.oriMaxD=i.maxD,i.oriCenter=i.center.clone(),i.ParserUtilsCls.transformToOpmOri(t),void 0===n.cfg.align&&1==Object.keys(i.structures).length&&$("#"+i.pre+"alternateWrapper").hide(),i.setStyleCls.setAtomStyleByOptions(i.opts),i.setColorCls.setColorByOptions(i.opts,i.atoms),await i.ParserUtilsCls.renderStructure(),i.saveFileCls.showTitle(),void 0!==n.cfg.rotate&&i.resizeCanvasCls.rotStruc(n.cfg.rotate,!0)}}class Zt{constructor(e){this.icn3d=e}async loadMol2Data(e){let t=this.icn3d,s=t.icn3dui,i=this.loadMol2AtomData(e);void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),i?(t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.atoms),await t.ParserUtilsCls.renderStructure(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0)):alert("The Mol2 file has the wrong format...")}loadMol2AtomData(e){let t=this.icn3d;t.icn3dui;let s=e.split(/\r?\n|\r/);if(s.length<4)return!1;t.init();let i,n,l="LIG",r={},o="1_A",a=0,d=0,c=1,h=!1,p=!1,m={},u={};for(let e=0,o=s.length;eMOLECULE"==o){t.molTitle=s[e+1].trim();let l=s[e+2].trim().replace(/\s+/g," ").split(" ");i=l[0],n=l[1],e+=4}else"@ATOM"==o?(c=1,h=!0,++e):"@BOND"==o?(p=!0,h=!1,++e):"@SUBSTRUCTURE"==o&&(p=!1,++e);if(o=s[e].trim(),""!==o&&"#"!==o.substr(0,1)){if(h&&a1&&($("#"+l.pre+"assemblyWrapper").show(),l.asuCnt=l.biomtMatrices.length),l.setStyleCls.setAtomStyleByOptions(l.opts),l.setColorCls.setColorByOptions(l.opts,l.atoms),await l.ParserUtilsCls.renderStructure(),void 0!==r.cfg.rotate&&l.resizeCanvasCls.rotStruc(r.cfg.rotate,!0)}else"pdb"===i?await l.pdbParserCls.loadPdbData(e,t):"align"===i&&(l.bOpm?await l.alignParserCls.downloadAlignmentPart2(t):void 0!==n?await this.loadOpmData(e,n,s,i):await l.alignParserCls.downloadAlignmentPart2(t))}}class ts{constructor(e){this.icn3d=e}async downloadPdb(e,t){let s,i=this.icn3d,n=i.icn3dui;t?(s="https://alphafold.ebi.ac.uk/files/AF-"+e+"-F1-model_"+i.AFUniprotVersion+".pdb",n.cfg.refseqid?i.ParserUtilsCls.setYourNote(n.cfg.refseqid.toUpperCase()+"(NCBI Protein Acc.) in iCn3D"):n.cfg.protein?i.ParserUtilsCls.setYourNote(n.cfg.protein+"(NCBI Protein/Gene) in iCn3D"):i.ParserUtilsCls.setYourNote(e.toUpperCase()+"(AlphaFold) in iCn3D")):(s="https://files.rcsb.org/view/"+e+".pdb",e=e.toUpperCase(),i.ParserUtilsCls.setYourNote(e+"(PDB) in iCn3D"));let l=await n.getAjaxPromise(s,"text",!0,"The ID "+e+" can not be found in the server "+s+"...");if(t){l="HEADER "+e+"\n"+l,await i.opmParserCls.parseAtomData(l,e,void 0,"pdb",void 0)}else await i.opmParserCls.loadOpmData(l,e,void 0,"pdb")}async downloadUrl(e,t,s){let i=this.icn3d,n=i.icn3dui,l=e.lastIndexOf("/");if(-1!=l){let t=e.lastIndexOf(".");i.filename=e.substr(l+1,t-l-1)}else{let t=e.lastIndexOf(".");i.filename=e.substr(0,t)}let r=await n.getAjaxPromise(e,"text",!0);if(i.InputfileData=i.InputfileData?i.InputfileData+"\nENDMDL\n"+r:r,i.InputfileType=t,"pdb"===t)await this.loadPdbData(r);else if("mmcif"===t){let e=n.htmlCls.baseUrl+"mmcifparser/mmcifparser.cgi",t={mmciffile:r},s=await n.getAjaxPostPromise(e,t,!0);await i.mmcifParserCls.loadMmcifData(s,void 0)}else if("mol2"===t)await i.mol2ParserCls.loadMol2Data(r);else if("sdf"===t)await i.sdfParserCls.loadSdfData(r);else if("xyz"===t)await i.xyzParserCls.loadXyzData(r);else if("mmcif"===t)await i.mmcifParserCls.loadMmcifData(r);else if("icn3dpng"===t)await n.htmlCls.setHtmlCls.loadPng(r,s);else if("pae"===t){n.htmlCls.dialogCls.openDlg("dl_alignerrormap","Show Predicted Aligned Error (PAE) map");let e=!0;i.contactMapCls.processAfErrorMap(JSON.parse(r),e)}}async loadPdbData(e,t,s,i,n,l,r,o){let a=this.icn3d,d=a.icn3dui;if(!i&&(void 0===n||"target"===n)){let e=!!a.bCommandLoad;a.bStatefile||a.init(e)}let c=a.loadPDBCls.loadPDB(e,t,s,void 0,void 0,i,n,o);void 0===d.cfg.opmid&&a.ParserUtilsCls.transformToOpmOri(t),void 0!==a.biomtMatrices&&a.biomtMatrices.length>1&&(d.bNode||$("#"+a.pre+"assemblyWrapper").show(),a.asuCnt=a.biomtMatrices.length),d.bNode||(void 0!==a.emd?($("#"+a.pre+"mapWrapper1").hide(),$("#"+a.pre+"mapWrapper2").hide(),$("#"+a.pre+"mapWrapper3").hide()):($("#"+a.pre+"emmapWrapper1").hide(),$("#"+a.pre+"emmapWrapper2").hide(),$("#"+a.pre+"emmapWrapper3").hide()));let h=!1;return a.bSecondaryStructure&&1==Object.keys(a.structures).length?h=!1:d.cfg.mmtfid||d.cfg.pdbid||d.cfg.opmid||d.cfg.mmdbid||d.cfg.gi||d.cfg.uniprotid||d.cfg.blast_rep_id||d.cfg.cid||d.cfg.mmcifid||d.cfg.align||d.cfg.chainalign||(h=!0),(!a.bSecondaryStructure||h)&&Object.keys(a.proteins).length>0&&!r?await this.applyCommandDssp(i):(await this.loadPdbDataRender(i),d.bNode||await a.ParserUtilsCls.checkMemProteinAndRotate()),c}async applyCommandDssp(e){let t=this.icn3d,s=t.icn3dui,i=s.utilsCls.isCalphaPhosOnly(s.hashUtilsCls.hash2Atoms(t.proteins,t.atoms));await t.dsspCls.applyDssp(i,e)}async loadPdbDataRender(e){let t=this.icn3d,s=t.icn3dui;void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),(s.cfg.afid&&!t.bAfMem||t.bEsmfold)&&(t.opts.color="confidence"),t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.hAtoms),await t.ParserUtilsCls.renderStructure(),t.saveFileCls.showTitle(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0),e&&!s.bNode&&t.definedSetsCls.setModeAndDisplay("all")}}class ss{constructor(e){this.icn3d=e}async downloadCid(e){let t=this.icn3d,s=t.icn3dui;t.ParserUtilsCls.setYourNote("PubChem CID "+e+" in iCn3D"),t.bCid=!0;let i="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+t.inputid+"/cids/JSONP?cids_type=parent",n="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+(await s.getAjaxPromise(i,"jsonp",!0,"Can not retrieve the parant CID...")).IdentifierList.CID[0]+"/record/SDF/?record_type=3d&response_type=display",l=await s.getAjaxPromise(n,"text",!0,"This CID may not have 3D structure..."),r=this.loadSdfAtomData(l,e);void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),r?(t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.atoms),await t.ParserUtilsCls.renderStructure(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0)):alert("The SDF of CID "+e+" has the wrong format...")}async loadSdfData(e){let t=this.icn3d,s=t.icn3dui,i=this.loadSdfAtomData(e);void 0===s.cfg.align&&1==Object.keys(t.structures).length&&$("#"+t.pre+"alternateWrapper").hide(),i?(t.setStyleCls.setAtomStyleByOptions(t.opts),t.setColorCls.setColorByOptions(t.opts,t.atoms),await t.ParserUtilsCls.renderStructure(),void 0!==s.cfg.rotate&&t.resizeCanvasCls.rotStruc(s.cfg.rotate,!0)):alert("The SDF file has the wrong format...")}loadSdfAtomData(e,t){let s=this.icn3d;s.icn3dui;let i=e.split(/\r?\n|\r/);if(i.length<4)return!1;s.init();let n=t||1,l="LIG",r=n,o=n+"_A",a=o+"_1",d=parseInt(i[3].substr(0,3));if(isNaN(d)||d<=0)return!1;let c=parseInt(i[3].substr(3,3)),h=4;if(i.lengthr||(Math.abs(t.coord.y-i.coord.y)>r||Math.abs(t.coord.z-i.coord.z)>r||l.utilsCls.hasCovalentBond(t,i)&&(n.atoms[o[e]].bonds.push(o[s]),n.atoms[o[s]].bonds.push(o[e])))}}}loadXyzAtomData(e){let t=this.icn3d;t.icn3dui;let s=e.split(/\r?\n|\r/);if(s.length<3)return!1;t.init();let i,n,l,r={},o=0,a=1;t.molTitle="";for(let e=0,d=s.length;e1&&(t.molTitle+="; "),t.molTitle+=s[e+1].trim(),e+=2),d=s[e].trim(),""===d)continue;let c=d.replace(/,/," ").replace(/\s+/g," ").split(" "),h=c[0],p=parseFloat(c[1]),m=parseFloat(c[2]),u=parseFloat(c[3]),g={het:!0,serial:a,name:h,resn:"LIG",structure:l,chain:"A",resi:1,coord:new THREE.Vector3(p,m,u),b:0,elem:h,bonds:[],ss:"coil",ssbegin:!1,ssend:!1,bondOrder:[]};t.atoms[a]=g,r[a]=1,++a}return this.setXyzAtomSeq(r,o,i,n),t.ParserUtilsCls.setMaxD(),t.saveFileCls.showTitle(),!0}}class ns{constructor(e){this.icn3d=e}realign(){let e=this.icn3d,t=e.icn3dui;e.selectionCls.saveSelectionPrep();let s="alseq_"+Object.keys(e.defNames2Atoms).length;e.selectionCls.saveSelection(s,s),t.htmlCls.clickMenuCls.setLogCmd("realign",!0);let i={},n={};e.realignResid={};let l="";for(let s in e.hAtoms){let r=e.atoms[s],o=r.structure+"_"+r.chain;if(e.proteins.hasOwnProperty(s)&&"CA"==r.name||e.nucleotides.hasOwnProperty(s)&&("O3'"==r.name||"O3*"==r.name)){if(r.structure+"_"+r.resi==l)continue;i.hasOwnProperty(r.structure)||(i[r.structure]=[]),i[r.structure].push(r.coord.clone()),e.realignResid.hasOwnProperty(o)||(e.realignResid[o]=[]),e.realignResid[o].push({resid:o+"_"+r.resi,resn:t.utilsCls.residueName2Abbr(r.resn.substr(0,3)).substr(0,1)}),n[r.structure]=r.structure+"_"+r.chain,l=r.structure+"_"+r.resi}}let r=Object.keys(i),o=r[0],a=[];e.qt_start_end=[],a.push(n[o]);for(let t=1,s=r.length;t5){let e=r.cfg.chainalign.split(",");e.length>0&&(l.hAtoms=l.definedSetsCls.getAtomsFromNameArray(e)),r.cfg.aligntool="tmalign",await l.realignParserCls.realignOnStructAlign()}else l.hAtoms=l.chainalignParserCls.setMsa(e),l.transformCls.zoominSelection(),await l.chainalignParserCls.downloadChainalignmentPart3(void 0,e,l.hAtoms)}async parseChainRealignData(e,t,s,i,n,l,r){let o=this.icn3d,a=o.icn3dui,d=s[0].substr(0,s[0].indexOf("_"));r||(d=d.toUpperCase());let c={};o.realignResid={},o.opts.color="grey",o.setColorCls.setColorByOptions(o.opts,o.dAtoms),o.qt_start_end=[];for(let t=0,h=e.length;t=6&&C.length>=6&&!a.cfg.command&&o.bRender&&alert("These sequences can not be aligned to each other")):o.bRender&&alert("Please do not align residues in the same structure")}if(r){o.hAtoms=o.chainalignParserCls.setMsa(s);let e="protein_aligned";if(o.selectionCls.saveSelection(e,e),o.bAfMem?(o.selectionCls.selectAll_base(),o.opts.chemicals="stick",o.opts.color="confidence",o.setColorCls.setColorByOptions(o.opts,o.atoms)):(o.transformCls.zoominSelection(),o.dAtoms=a.hashUtilsCls.cloneHash(o.hAtoms),o.opts.color="identity",o.setColorCls.setColorByOptions(o.opts,o.hAtoms)),o.drawCls.draw(),o.hlUpdateCls.updateHlAll(),o.bAfMem){let e=new THREE.Vector3(1,0,0),t=-.5*Math.PI;o.transformCls.setRotation(e,t)}}else o.hAtoms=o.chainalignParserCls.setMsa(s),o.transformCls.zoominSelection(),await o.chainalignParserCls.downloadChainalignmentPart3(t,s,o.hAtoms)}async realignOnSeqAlign(e){let t=this.icn3d;t.icn3dui;let s=t.firstAtomObjCls.getChainsFromAtoms(t.hAtoms),i=Object.keys(s),n=[],l="";for(let e=0,t=i.length;ei){n[e][o]=a;break}}}let l=[],r=[],o=s.htmlCls.baseUrl+"vastdyn/vastdyn.cgi",a=s.htmlCls.baseUrl+"tmalign/tmalign.cgi",d=Object.keys(n);e&&(d=d.reverse());for(let e=0,i=d.length;ei){n[r]=o;break}}let l=[],r=[],o=[],a=s.htmlCls.baseUrl+"vastdyn/vastdyn.cgi",d=s.htmlCls.baseUrl+"tmalign/tmalign.cgi",c=e[0],h=c.substr(0,c.indexOf("_")),p=t.domain3dCls.getDomainJsonForAlign(n[c]);for(let i=1,m=e.length;if&&(f=s)}}}return{data:n,min:g,max:f}}(e.getCategory("_volume_data_3d").getColumn("values"),o,n.sampleCount,l);return{name:n.name,spacegroup:function(e,t,s){let i=Math.PI/180*s[0],n=Math.PI/180*s[1],l=Math.PI/180*s[2],r=t[0],o=t[1],a=t[2],d=Math.cos(n),c=(Math.cos(i)-Math.cos(n)*Math.cos(l))/Math.sin(l),h=Math.sqrt(1-d*d-c*c);return{number:e,size:t,angles:s,basis:{x:[r,0,0],y:[Math.cos(l)*o,Math.sin(l)*o,0],z:[d*a,c*a,h*a]}}}(n.spacegroupNumber,n.cellSize,n.cellAngles),box:{origin:r(n.origin),dimensions:r(n.dimensions),sampleCount:o},data:a.data,valuesInfo:{min:a.min,max:a.max,mean:n.mean,sigma:n.sigma}}}BinaryParse(e){this.icn3d.icn3dui;let t=new Uint8Array(e),s=this.MessagePackParse({buffer:t,offset:0,dataView:new DataView(t.buffer)}),i=function(){function e(e){this.additionalData={},this.header=e.header,this.categoryList=e.categories.map((function(e){return new n(e)})),this.categoryMap=new Map;for(let e=0,t=this.categoryList;e=0;s--)t=c(t,e.encoding[s]);return t}function p(e){if(!e.data.data)return _UndefinedColumn;let t,s=h(e.data);return e.mask&&(t=h(e.mask)),s.buffer&&s.byteLength&&s.BYTES_PER_ELEMENT?t?new f(s,t):new g(s):t?new C(s,t):new b(s)}function m(e,t,s){let i=0,n=1;for(45===e.charCodeAt(t)&&(n=-1,t++);t9||s<0)return n*i|0;i=10*i+s|0}return n*i}function u(e,t,s){let i=1,n=0,l=0,r=1;for(45===e.charCodeAt(t)&&(i=-1,++t);t=0&&o<10)){if(-2===o){for(++t;t=0&&o<10))return 53===o||21===o?parseScientific(i*(n+l/r),e,t+1,s):i*(n+l/r);l=10*l+o,r*=10,++t}return i*(n+l/r)}if(53===o||21===o)return parseScientific(i*n,e,t+1,s);break}n=10*n+o,++t}return i*n}let g=function(){function e(e){this.data=e,this.isDefined=!0}return e.prototype.getString=function(e){return""+this.data[e]},e.prototype.getInteger=function(e){return 0|this.data[e]},e.prototype.getFloat=function(e){return 1*this.data[e]},e.prototype.stringEquals=function(e,t){return this.data[e]===u(t,0,t.length)},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return 0},e}(),f=function(){function e(e,t){this.data=e,this.mask=t,this.isDefined=!0}return e.prototype.getString=function(e){return 0===this.mask[e]?""+this.data[e]:null},e.prototype.getInteger=function(e){return 0===this.mask[e]?this.data[e]:0},e.prototype.getFloat=function(e){return 0===this.mask[e]?this.data[e]:0},e.prototype.stringEquals=function(e,t){return 0===this.mask[e]?this.data[e]===u(t,0,t.length):null==t},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return this.mask[e]},e}(),b=function(){function e(e){this.data=e,this.isDefined=!0}return e.prototype.getString=function(e){return this.data[e]},e.prototype.getInteger=function(e){let t=this.data[e];return m(t,0,t.length)},e.prototype.getFloat=function(e){let t=this.data[e];return u(t,0,t.length)},e.prototype.stringEquals=function(e,t){return this.data[e]===t},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return 0},e}(),C=function(){function e(e,t){this.data=e,this.mask=t,this.isDefined=!0}return e.prototype.getString=function(e){return 0===this.mask[e]?this.data[e]:null},e.prototype.getInteger=function(e){if(0!==this.mask[e])return 0;let t=this.data[e];return m(t||"",0,(t||"").length)},e.prototype.getFloat=function(e){if(0!==this.mask[e])return 0;let t=this.data[e];return u(t||"",0,(t||"").length)},e.prototype.stringEquals=function(e,t){return this.data[e]===t},e.prototype.areValuesEqual=function(e,t){return this.data[e]===this.data[t]},e.prototype.getValuePresence=function(e){return this.mask[e]},e}(),y=function(){function e(e){this.dataBlocks=e.dataBlocks.map((function(e){return new i(e)}))}return e.prototype.toJSON=function(){return this.dataBlocks.map((function(e){return e.toJSON()}))},e}();return new y(s)}MessagePackParse(e){this.icn3d.icn3dui;let t=this;function s(e,s){let i={};for(let n=0;n0&&(i[i.length]=l.slice(0,a).join(""));return i.join("")}(e.buffer,e.offset,t);return e.offset+=t,s}let r=function(){let e=[];for(let t=0;t<1024;t++)e[t]=String.fromCharCode(t);return e}();let o,a,d=e.buffer[e.offset];if(0==(128&d))return e.offset++,d;if(128==(240&d))return a=15&d,e.offset++,s(e,a);if(144==(240&d))return a=15&d,e.offset++,n(e,a);if(160==(224&d))return a=31&d,e.offset++,l(e,a);if(224==(224&d))return o=e.dataView.getInt8(e.offset),e.offset++,o;switch(d){case 192:return e.offset++,null;case 194:return e.offset++,!1;case 195:return e.offset++,!0;case 196:return a=e.dataView.getUint8(e.offset+1),e.offset+=2,i(e,a);case 197:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,i(e,a);case 198:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,i(e,a);case 202:return o=e.dataView.getFloat32(e.offset+1),e.offset+=5,o;case 203:return o=e.dataView.getFloat64(e.offset+1),e.offset+=9,o;case 204:return o=e.buffer[e.offset+1],e.offset+=2,o;case 205:return o=e.dataView.getUint16(e.offset+1),e.offset+=3,o;case 206:return o=e.dataView.getUint32(e.offset+1),e.offset+=5,o;case 208:return o=e.dataView.getInt8(e.offset+1),e.offset+=2,o;case 209:return o=e.dataView.getInt16(e.offset+1),e.offset+=3,o;case 210:return o=e.dataView.getInt32(e.offset+1),e.offset+=5,o;case 217:return a=e.dataView.getUint8(e.offset+1),e.offset+=2,l(e,a);case 218:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,l(e,a);case 219:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,l(e,a);case 220:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,n(e,a);case 221:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,n(e,a);case 222:return a=e.dataView.getUint16(e.offset+1),e.offset+=3,s(e,a);case 223:return a=e.dataView.getUint32(e.offset+1),e.offset+=5,s(e,a)}}}class rs{constructor(e){this.icn3d=e}alignCoords(e,t,s,i,n,l,r,o){let a,d=this.icn3d,c=d.icn3dui,h=e.length=4&&(d.bAfMem?d.rmsd_suprTmp=c.rmsdSuprCls.getRmsdSuprCls(t,e,h):d.rmsd_suprTmp=c.rmsdSuprCls.getRmsdSuprCls(e,t,h),void 0!==d.rmsd_suprTmp.rot)){let e=d.rmsd_suprTmp.rot;null===e[0]&&alert("Please select more residues in each structure...");let t=d.rmsd_suprTmp.trans1,i=d.rmsd_suprTmp.trans2;if(a=d.rmsd_suprTmp.rmsd,a){c.htmlCls.clickMenuCls.setLogCmd("realignment RMSD: "+a.toPrecision(4),!1);let e="
    Realignment RMSD: "+a.toPrecision(4)+" Å

    ";d.bAfMem&&!c.cfg.chainalign&&(e+=c.utilsCls.getMemDesc()),$("#"+d.pre+"dl_rmsd_html").html(e),c.cfg.bSidebyside||c.htmlCls.dialogCls.openDlg("dl_rmsd","Realignment RMSD")}let r={};for(let n=0,l=d.structures[s].length;n"+s.diagram2dCls.set2DdgmNote(!0),$("#"+s.pre+"dl_2ddgm_html").html(s.html2ddgm),s.b2DShown=!0}async set2DDiagramsForChainalign(e){let t=this.icn3d.icn3dui,s=this;t.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions");let i=[];for(let s=0,n=e.length;s"+s.diagram2dCls.set2DdgmNote(!0),s.b2DShown=!0,$("#"+s.pre+"dl_2ddgm_html").html(s.html2ddgm),i.cfg.show2d&&i.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions")}download2Ddgm(e,t){this.set2DDiagrams(e)}set2DDiagrams(e){let t=this.icn3d;t.icn3dui.htmlCls.dialogCls.openDlg("dl_2ddgm","Interactions"),void 0!==t.b2DShown&&t.b2DShown||(t.html2ddgm="",t.diagram2dCls.draw2Ddgm(t.interactionData,e),t.html2ddgm+="
    "+t.diagram2dCls.set2DdgmNote(),$("#"+t.pre+"dl_2ddgm_html").html(t.html2ddgm)),t.b2DShown=!0}showLoading(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"wait")&&$("#"+e.pre+"wait").show(),$("#"+e.pre+"canvas")&&$("#"+e.pre+"canvas").hide(),$("#"+e.pre+"cmdlog")&&$("#"+e.pre+"cmdlog").hide()}hideLoading(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"wait")&&$("#"+e.pre+"wait").hide(),$("#"+e.pre+"canvas")&&$("#"+e.pre+"canvas").show(),$("#"+e.pre+"cmdlog")&&$("#"+e.pre+"cmdlog").show()}setYourNote(e){let t=this.icn3d,s=t.icn3dui;t.yournote=e,$("#"+t.pre+"yournote").val(t.yournote),s.cfg.shownote&&(document.title=t.yournote)}transformToOpmOri(e){let t=this.icn3d;if(t.icn3dui,void 0!==t.rmsd_supr&&void 0!==t.rmsd_supr.rot){let s=t.rmsd_supr.rot,i=t.rmsd_supr.trans1,n=t.rmsd_supr.trans2;t.rmsd_supr.rmsd;let l=0;for(let e in t.atoms){let r=t.atoms[e];r.coord=t.surfaceCls.transformMemPro(r.coord,s,i,n);let o=r.coord.x*r.coord.x+r.coord.y*r.coord.y;Math.abs(r.coord.z)<=25&&o>l&&(l=o)}this.addMemAtoms(t.halfBilayerSize,e,Math.sqrt(l)),t.bStopRotate=!0,t.bOpm=!0,$("#"+t.pre+"togglememli").show(),$("#"+t.pre+"adjustmemli").show(),$("#"+t.pre+"selectplaneli").show()}else t.bOpm=!1}transformToOpmOriForAlign(e,t,s){let i=this.icn3d,n=i.icn3dui;if(void 0!==t){let l=i.loadPDBCls.getChainCalpha(i.chains,i.atoms,s,e),r=1==Object.keys(l.chainresiCalphaHash).length||1==Object.keys(t.chainresiCalphaHash).length,o=[],a=[];for(let e in l.chainresiCalphaHash)if(t.chainresiCalphaHash.hasOwnProperty(e)){let s=l.chainresiCalphaHash[e],i=t.chainresiCalphaHash[e];if((s.length==i.length||r)&&(o=o.concat(s),a=a.concat(i)),o.length>500)break}let d=o.length=4)if(i.rmsd_supr=n.rmsdSuprCls.getRmsdSuprCls(o,a,d),void 0!==i.rmsd_supr.rot&&i.rmsd_supr.rmsd<.1){let s=i.rmsd_supr.rot,l=i.rmsd_supr.trans1,r=i.rmsd_supr.trans2,o=i.rmsd_supr.rmsd;n.htmlCls.clickMenuCls.setLogCmd("RMSD of alignment to OPM: "+o.toPrecision(4),!1);let a=0;for(let e in i.atoms){let t=i.atoms[e];t.coord=i.surfaceCls.transformMemPro(t.coord,s,l,r);let n=t.coord.x*t.coord.x+t.coord.y*t.coord.y;Math.abs(t.coord.z)<=25&&n>a&&(a=n)}i.center=t.center,i.oriCenter=i.center.clone(),this.addMemAtoms(i.halfBilayerSize,e,Math.sqrt(a)),i.bStopRotate=!0,i.bOpm=!0,$("#"+i.pre+"togglememli").show(),$("#"+i.pre+"adjustmemli").show(),$("#"+i.pre+"selectplaneli").show()}else i.bOpm=!1;else i.bOpm=!1}}addOneDumAtom(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui,a={het:!0,serial:++l,name:t,alt:void 0,resn:"DUM",structure:e,chain:"MEM",resi:1,coord:new THREE.Vector3(s,i,n),b:void 0,elem:t,bonds:[],ss:"",ssbegin:!1,ssend:!1,color:o.parasCls.atomColors[t]};return r.atoms[l]=a,r.chains[e+"_MEM"][l]=1,r.residues[e+"_MEM_1"][l]=1,r.chemicals[l]=1,r.dAtoms[l]=1,r.hAtoms[l]=1,l}addMemAtoms(e,t,s){let i=this.icn3d;if(i.icn3dui,!t)return;t=t?t.toUpperCase():i.defaultPdbId,i.structures[t].push(t+"_MEM"),i.chains[t+"_MEM"]={},i.residues[t+"_MEM_1"]={},i.chainsSeq[t+"_MEM"]=[{name:"DUM",resi:1}];let n=Object.keys(i.atoms).length;for(let e=0;e<1e3;++e)if(!i.atoms.hasOwnProperty(n+e)){n=n+e-1;break}for(let i=0;i<81;++i)for(let l=0;l<81;++l){let r=2*i-80,o=2*l-80;if(Math.sqrt(r*r+o*o)=2?$("#"+e.pre+"mn2_alternateWrap").show():$("#"+e.pre+"mn2_alternateWrap").hide(),setTimeout((async function(){if(e.bInitial){if(void 0!==t.cfg.align||void 0!==t.cfg.chainalign){let s=e.pre+"selection";if($("#"+s).show(),$("#"+s+"_expand").hide(),$("#"+s+"_shrink").show(),void 0!==t.cfg.align&&2!=t.cfg.atype){let s=!1,i=t.htmlCls.alignSeqCls.getAlignSequencesAnnotations(Object.keys(e.alnChains),void 0,void 0,s);$("#"+e.pre+"dl_sequence2").html(i.sequencesHtml),$("#"+e.pre+"dl_sequence2").width(t.htmlCls.RESIDUE_WIDTH*i.maxSeqCnt+200)}}if(t.cfg.showanno){let s="view annotations";t.htmlCls.clickMenuCls.setLogCmd(s,!0),await e.showAnnoCls.showAnnotations()}(t.cfg.closepopup||t.cfg.imageonly)&&e.resizeCanvasCls.closeDialogs()}else e.hlUpdateCls.updateHlAll();$("#"+e.pre+"atomsCustom").length>0&&$("#"+e.pre+"atomsCustom")[0].blur(),e.bInitial=!1,t.cfg.imageonly&&e.saveFileCls.saveFile(void 0,"png",void 0,!0)}),0)}processCommand(){let e=this.icn3d,t=e.icn3dui;if(1==Object.keys(e.structures).length){let s=Object.keys(e.structures)[0];t.cfg.command=t.cfg.command.replace(new RegExp("!","g"),s+"_")}}getMassCenter(e,t){return this.icn3d.icn3dui,e.multiplyScalar(1/t)}getGeoCenter(e,t){return this.icn3d.icn3dui,e.clone().add(t).multiplyScalar(.5)}getStructureSize(e,t,s,i){let n=this.icn3d;n.icn3dui;let l=0;for(let r in e){let e=n.atoms[r].coord;if(Math.round(t.x)==Math.round(e.x)||Math.round(t.y)==Math.round(e.y)||Math.round(t.z)==Math.round(e.z)||Math.round(s.x)==Math.round(e.x)||Math.round(s.y)==Math.round(e.y)||Math.round(s.z)==Math.round(e.z)){let t=2*e.distanceTo(i);t>l&&(l=t)}}return l}async checkMemProteinAndRotate(){let e=this.icn3d,t=e.icn3dui;if(!e.bCheckMemProtein){e.bCheckMemProtein=!0;let s=t.cfg.afid?t.cfg.afid:t.cfg.mmdbafid;if(await e.ParserUtilsCls.checkMemProtein(s),t.cfg.url&&-1!=t.cfg.url.indexOf("membranome")){let t=new THREE.Vector3(1,0,0),s=-.5*Math.PI;e.transformCls.setRotation(t,s)}}}async checkMemProtein(e){let t=this.icn3d,s=t.icn3dui;try{let i=s.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?afid2mem="+e,n=await s.getAjaxPromise(i,"jsonp");if(n&&n.pdbid){let e='This is a single-spanning (bitopic) transmembrane protein according to the Membranome database. Do you want to align the protein with the model from Membranome? If you click "OK", you can press the letter "a" to alternate the structures.';if("off"==s.cfg.afmem);else if("on"==s.cfg.afmem||confirm(e))try{let e="https://storage.googleapis.com/membranome-assets/pdb_files/proteins/"+n.pdbid+".pdb",i=await s.getAjaxPromise(e,"text");t.bAfMem=!0,s.bNode||$("#"+s.pre+"togglememli").show();let l=n.pdbid.substr(0,n.pdbid.indexOf("_")),r=!0,o=!0;await t.pdbParserCls.loadPdbData(i,l,r,o),o&&(t.bSetChainsAdvancedMenu&&t.definedSetsCls.showSets(),t.bAnnoShown&&(await t.showAnnoCls.showAnnotations(),t.annotationCls.resetAnnoTabAll()));let a=n.segment.replace(/ /gi,"").split("(")[0];t.afmem_start_end=a.split("-"),t.hAtoms={},t.dAtoms={};for(let e in t.atoms)t.atoms[e].structure!=l&&(t.hAtoms[e]=1),t.dAtoms[e]=1;for(let e=parseInt(t.afmem_start_end[0]);e<=parseInt(t.afmem_start_end[1]);++e)t.hAtoms=s.hashUtilsCls.unionHash(t.hAtoms,t.residues[l+"_A_"+e]);await t.realignParserCls.realignOnSeqAlign(l)}catch(e){return void console.log("Error in retrieving matched PDB from Membranome...")}}}catch(e){return void console.log("Error in finding matched PDB in Membranome...")}}getResi(e,t){let s=this.icn3d;s.icn3dui;let i=s.ncbi2resid[e+"_"+(t+1).toString()];return i?i.substr(i.lastIndexOf("_")+1):""}getResiNCBI(e,t){let s=this.icn3d;s.icn3dui;let i=s.resid2ncbi[e+"_"+t];return i?parseInt(i.substr(i.lastIndexOf("_")+1)):0}}class os{constructor(e){this.icn3d=e}loadAtomDataIn(e,t,s,i,n,l,r,o,a){let d=this.icn3d,c=d.icn3dui;d.pmin=new THREE.Vector3(9999,9999,9999),d.pmax=new THREE.Vector3(-9999,-9999,-9999),d.psum=new THREE.Vector3;let h=e.atoms,p=d.atoms?Object.keys(d.atoms).length:0,m={},u={};d.pmid=e.pubmedId,void 0===d.chainid2title&&(d.chainid2title={}),void 0===d.chainid2sid&&(d.chainid2sid={});let g={},f={};if("align"===s){d.pmid="",d.molTitle="",c.cfg.inpara&&-1!==c.cfg.inpara.indexOf("atype=1")?d.molTitle="Invariant Core Structure Alignment (VAST) of ":c.cfg.inpara&&-1!==c.cfg.inpara.indexOf("atype=2")?d.molTitle="Structure Alignment (TM-align) of ":d.molTitle="Structure Alignment (VAST) of ";let t=!1;for(let s=0,i=e.alignedStructures[0].length;s'+i.pdbId.toUpperCase()+"",void 0!==i.descr&&(d.pmid+=i.descr.pubmedid),0===s&&(d.molTitle+=" and ",void 0!==i.descr&&(d.pmid+="_")),t=!0}d.molTitle+=" from VAST+",t||(d.molTitle="")}else if(void 0!==e.descr&&(d.molTitle+=e.descr.name),"mmdbid"===s){let s=isNaN(t)?t:e.pdbId,i={};void 0===d.alignmolid2color&&(d.alignmolid2color=[]);let n=1;for(let t in e.moleculeInfor){if(0===Object.keys(e.moleculeInfor[t]).length)continue;let l=e.moleculeInfor[t].chain.trim();(parseInt(c.cfg.date)>=20231001||!c.cfg.date&&parseInt(c.utilsCls.getDateDigitStr())>=20231001)&&(l=l.replace(/_/g,""));let r=s+"_"+l;i.hasOwnProperty(l)?(++i[l],r+=i[l]):i[l]=1,void 0!==d.mmdbid_q&&(d.mmdbid_q,d.mmdbid_t);let o=e.moleculeInfor[t].kind,a=e.moleculeInfor[t].color,h=e.moleculeInfor[t].sid;if(g[r]=o,f[r]=a,"protein"==o&&(d.organism=e.moleculeInfor[t].taxonomyName.toLowerCase()),void 0!==h&&(d.chainid2sid[r]=h),void 0===d.pdbid_chain2title&&(d.pdbid_chain2title={}),d.pdbid_chain2title[r]=e.moleculeInfor[t].name,l==r.substr(r.lastIndexOf("_"))){let e={};e[t]=n.toString(),d.alignmolid2color.push(e)}++n}}"mmdbid"===s&&(d.molTitleHash||(d.molTitleHash={}),d.molTitleHash[t]=d.molTitle);let b,C,y,v,_,w={},S="",A="",x="",k="",O="",R="",I=0,T=0,E="",P=!0,M=!1,D="",H=c.utilsCls.isCalphaPhosOnly(h),F=0,L={};for(let e in h){++p,w[e]=p;let i,n=h[e];n.serial=p,"mmdbid"===s||"mmcifid"===s?i=t:"align"===s&&(i=m[p]);let l=!1;if(void 0!==n.chain||"mmdbid"!==s&&"align"!==s)n.chain=""===n.chain?"Misc":n.chain;else if("mmdbid"===s)if(b=n.ids.m,void 0!==d.molid2chain[b]){let e=d.molid2chain[b].indexOf("_");n.chain=d.molid2chain[b].substr(e+1)}else{let e="Misc";("protein"===g[O]&&"nucleotide"===g[O]&&n.resi!=T||"protein"!==g[O]&&"nucleotide"!==g[O]&&(n.resn.substr(0,3)!=E.substr(0,3)||n.resi!=T||"solvent"===g[O]||"HOH"===n.resn))&&++F,n.resi_ori=n.resi,n.resi=F,l=!0,n.chain=e}else if("align"===s)if(b=n.ids.m,void 0!==d.pdbid_molid2chain[i+"_"+b])n.chain=d.pdbid_molid2chain[i+"_"+b];else{let e="Misc";("protein"===g[O]&&"nucleotide"===g[O]&&n.resi!=T||"protein"!==g[O]&&"nucleotide"!==g[O]&&(n.resn.substr(0,3)!=E.substr(0,3)||n.resi!=T||"solvent"===g[O]||"HOH"===n.resn))&&(++F,n.resi_ori=n.resi,n.resi=F,l=!0),n.chain=e}if(n.chain=n.chain.trim(),(parseInt(c.cfg.date)>=20231001||!c.cfg.date&&parseInt(c.utilsCls.getDateDigitStr())>=20231001)&&(n.chain=n.chain.replace(/_/g,"")),"mmdbid"!==s&&"align"!==s||(n.structure=i,"mmdbid"===s&&void 0!==d.mmdbid_q&&(d.mmdbid_q,d.mmdbid_t)),k=n.structure,O=k+"_"+n.chain,"mmdbid"===s||"align"===s){l||(n.resi_ori=n.resi,d.bUsePdbNum?n.resi=n.resi_ori:n.resi=n.ids.r);let e=n.resn.indexOf(" ");-1!==e&&0!=e&&(n.resn=n.resn.substr(0,e))}O!==A&&(I=0),n.resi!==I&&(O!==A?(y=void 0,_=void 0):(y=C,_=v)),n.coord="mmdbid"===s?new THREE.Vector3(n.coord[0],n.coord[1],n.coord[2]):new THREE.Vector3(n.coord.x,n.coord.y,n.coord.z);let r=c.utilsCls.residueName2Abbr(n.resn.substr(0,3));"mmdbid"!==s&&"align"!==s||!d.bFullUi||(void 0===d.mmdbMolidResid2mmdbChainResi&&(d.mmdbMolidResid2mmdbChainResi={}),d.mmdbMolidResid2mmdbChainResi[i+"_"+n.ids.m+"_"+n.ids.r]=i+"_"+n.chain+"_"+n.resi),d.pmin.min(n.coord),d.pmax.max(n.coord),d.psum.add(n.coord);let o=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"protein"===g[O]:"p"===n.mt,a=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"nucleotide"===g[O]:"n"===n.mt,u=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"solvent"===g[O]:"s"===n.mt,N=void 0===c.cfg.mmcifid&&"mmcif"!=d.InputfileType?"ligand"===g[O]||void 0!==g[O]&&-1!==g[O].indexOf("other")||void 0===g[O]:"l"===n.mt;if("Misc"!==n.chain&&"other"!==g[O]||"protein"===L[O]||"nucleotide"===L[O]||("CA"===n.name&&"C"===n.elem?L[O]="protein":"P"===n.name&&"P"===n.elem?L[O]="nucleotide":L[O]="chemical"),o||a?(o?(d.proteins[p]=1,"CA"===n.name&&(d.calphas[p]=1),"N"!==n.name&&"H"!==n.name&&"CA"!==n.name&&"HA"!==n.name&&"C"!==n.name&&"O"!==n.name&&(d.sidec[p]=1)):a&&(d.nucleotides[p]=1,("O3'"==n.name||"O3*"==n.name||H&&"P"==n.name)&&(d.nucleotidesO3[p]=1),-1===c.parasCls.nuclMainArray.indexOf(n.name)&&(d.ntbase[p]=1)),n.het=!1):u?(d.water[p]=1,n.het=!0):N&&("HOH"===n.resn||"O"===n.resn?d.water[p]=1:n.elem===n.resn?d.ions[p]=1:d.chemicals[p]=1,n.het=!0),"mmdbid"===s?n.het?n.color=c.parasCls.atomColors[n.elem]||c.parasCls.defaultAtomColor:n.color=void 0!==f[O]?c.parasCls.thr(f[O]):c.parasCls.chargeColors[n.resn]:void 0!==n.color&&(n.color=c.parasCls.thr(n.color))," "!==n.resn.charAt(0)&&" "===n.resn.charAt(1)&&(n.resn=n.resn.charAt(0)),n.het||"C"!==n.name||(C=p),n.het||"O"!==n.name||(v=p),!n.het&&"N"===n.name&&void 0!==y&&void 0!==_){let e=d.atoms[y].coord.distanceTo(d.atoms[_].coord),t=n.coord.x+(d.atoms[y].coord.x-d.atoms[_].coord.x)/e,s=n.coord.y+(d.atoms[y].coord.y-d.atoms[_].coord.y)/e,i=n.coord.z+(d.atoms[y].coord.z-d.atoms[_].coord.z)/e;n.hcoord=new THREE.Vector3(t,s,i)}"HOH"==n.resn&&(d.water[p]=1),d.atoms[p]=n,d.dAtoms[p]=1,d.hAtoms[p]=1;let q=n.structure+"_"+n.chain;void 0===d.chains[q]&&(d.chains[q]={}),d.chains[q][p]=1;let U=q+"_"+n.resi;void 0===d.residues[U]&&(d.residues[U]={}),d.residues[U][p]=1,R=O+"_"+n.resi,R!==x&&O!==A&&(P=!0,""!==S&&(void 0===d.structures[S]&&(d.structures[S]=[]),d.structures[S].push(A))),d.residueId2Name[U]=r;let $="-";if("helix"===n.ss?$="H":"sheet"===n.ss?$="E":n.het||a?$="o":(!n.het&&c.parasCls.residueColors.hasOwnProperty(n.resn.toUpperCase())||"coil"===n.ss)&&($="c"),d.secondaries[n.structure+"_"+n.chain+"_"+n.resi]=$,(n.resi!=I||b!=D)&&d.bFullUi&&(void 0===d.chainsSeq[q]&&(d.chainsSeq[q]=[],P=!1),!isNaN(n.resi)))if(P&&!M&&void 0!==d.chainsSeq[q][n.resi-1])d.chainsSeq[q][n.resi-1].name=r;else if(!P||!d.chainsSeq[q].hasOwnProperty(n.resi-1)){let e={};e.resi=n.resi,e.name=r,n.resi%10==0&&n.resi.toString(),d.chainsSeq[q].push(e),M=!0}I=n.resi,T=n.resi_ori,E=n.resn,S=k,A=O,x=R,D=b}for(let e in d.chemicals){let t=d.atoms[e];if("P"==t.elem&&t.bonds.length>=4)for(let e=t.bonds.length-1;e>=0;--e){"P"==d.atoms[t.bonds[e]].elem&&t.bonds.splice(e,1)}}for(let e in L)if(!(Object.keys(d.chains[e]).length<10)&&"chemical"!==L[e])for(let t in d.chains[e]){let s=d.atoms[t];delete d.chemicals[t],s.het=!1,"protein"===L[e]?(d.proteins[t]=1,"CA"===s.name&&(d.calphas[t]=1),"N"!==s.name&&"H"!==s.name&&"CA"!==s.name&&"HA"!==s.name&&"C"!==s.name&&"O"!==s.name&&(d.sidec[t]=1)):"nucleotide"===L[e]&&(d.nucleotides[t]=1,("O3'"==s.name||"O3*"==s.name||H&&"P"==s.name)&&(d.nucleotidesO3[t]=1),-1===c.parasCls.nuclMainArray.indexOf(s.name)&&(d.ntbase[t]=1))}if(void 0===d.structures[k]&&(d.structures[k]=[]),d.structures[k].push(O),d.bFullUi)if("mmdbid"===s||"mmcifid"===s)for(let i in e.sequences){let n=e.sequences[i],l=t+"_"+i;void 0!==d.mmdbid_q&&(d.mmdbid_q,d.mmdbid_t),d.ParserUtilsCls.getMissingResidues(n,s,l)}else if("align"===s)for(let e in d.chainid2seq){let t=d.chainid2seq[e];d.ParserUtilsCls.getMissingResidues(t,s,e)}if(d.loadPDBCls.setResidMapping(),"mmcifid"!==s)for(let e in h){let t=w[e],s=void 0===d.atoms[t].bonds?0:d.atoms[t].bonds.length;for(let e=0;ed.maxatomcnt||void 0!==d.biomtMatrices&&d.biomtMatrices.length*d.cnt>10*d.maxatomcnt)&&(d.opts.proteins="c alpha trace",d.opts.nucleotides="o3 trace"),d.center=d.ParserUtilsCls.getGeoCenter(d.pmin,d.pmax),d.maxD=d.ParserUtilsCls.getStructureSize(d.atoms,d.pmin,d.pmax,d.center),d.maxD<5&&(d.maxD=5),d.oriMaxD=d.maxD,("align"===s||o)&&(d.ssbondpnts={},d.loadPDBCls.setSsbond()),"mmdbid"===s&&1==Object.keys(d.structures).length){let t=e.disulfides;if(void 0!==t)for(let e=0,s=t.length;ep&&(p=e)),c[e]={resi:t,resn:i,aligned:n}}r=e[t][1];let u=r.moleculeId,g=s.pdbid_molid2chain[l+"_"+u],f=l+"_"+g;void 0===s.alnChainsAnTtl[d]&&(s.alnChainsAnTtl[d]=[]),void 0===s.alnChainsAnTtl[d][0]&&(s.alnChainsAnTtl[d][0]=[]),void 0===s.alnChainsAnTtl[d][1]&&(s.alnChainsAnTtl[d][1]=[]),void 0===s.alnChainsAnTtl[d][2]&&(s.alnChainsAnTtl[d][2]=[]),void 0===s.alnChainsAnTtl[d][3]&&(s.alnChainsAnTtl[d][3]=[]),void 0===s.alnChainsAnTtl[d][4]&&(s.alnChainsAnTtl[d][4]=[]),void 0===s.alnChainsAnTtl[d][5]&&(s.alnChainsAnTtl[d][5]=[]),void 0===s.alnChainsAnTtl[d][6]&&(s.alnChainsAnTtl[d][6]=[]),s.alnChainsAnTtl[d][0].push(f),s.alnChainsAnTtl[d][1].push(d),s.alnChainsAnTtl[d][2].push(""),s.alnChainsAnTtl[d][3].push(""),s.alnChainsAnTtl[d][4].push(f),s.alnChainsAnTtl[d][5].push(d),s.alnChainsAnTtl[d][6].push("");let b=1;s.chainsMapping[d]||(s.chainsMapping[d]={}),s.chainsMapping[f]||(s.chainsMapping[f]={});for(let e=h;e<=p;++e){let t,o,p,m=s.bUsePdbNum?s.ParserUtilsCls.getResi(f,r.sequence[e][0]-1):r.sequence[e][0],u="~"===r.sequence[e][2]?"-":r.sequence[e][2],C=r.sequence[e][3]?1:0,y=c[e].aligned+C;2===y?(c[e].resn===u?(t="#FF0000",p="icn3d-cons",s.consHash1[d+"_"+c[e].resi]=1,s.consHash2[f+"_"+m]=1):(t="#0000FF",p="icn3d-ncons",s.nconsHash1[d+"_"+c[e].resi]=1,s.nconsHash2[f+"_"+m]=1),s.chainsMapping[d][d+"_"+c[e].resi]=c[e].resn+c[e].resi,s.chainsMapping[f][f+"_"+m]=c[e].resn+c[e].resi,o="#"+s.showAnnoCls.getColorhexFromBlosum62(c[e].resn,u)):(t=i.htmlCls.GREY8,p="icn3d-nalign",s.nalignHash1[d+"_"+c[e].resi]=1,s.nalignHash2[f+"_"+m]=1),void 0===s.alnChainsSeq[d]&&(s.alnChainsSeq[d]=[]);let v={};v.mmdbid=n,v.chain=a,v.resi=c[e].resi,v.resn=""===v.resi||"icn3d-nalign"===p?c[e].resn.toLowerCase():c[e].resn,v.aligned=y,v.color=""===v.resi?i.htmlCls.GREYC:t,v.color2=""===v.resi?i.htmlCls.GREYC:o,v.class=p,s.alnChainsSeq[d].push(v),""!==c[e].resi&&(void 0===s.alnChains[d]&&(s.alnChains[d]={}),$.extend(s.alnChains[d],s.residues[d+"_"+c[e].resi])),void 0===s.alnChainsSeq[f]&&(s.alnChainsSeq[f]=[]),v={},v.mmdbid=l,v.chain=g,v.resi=m,v.resn=""===v.resi||"icn3d-nalign"===p?u.toLowerCase():u,v.aligned=y,v.color=""===v.resi?i.htmlCls.GREYC:t,v.color2=""===v.resi?i.htmlCls.GREYC:o,v.class=p,s.alnChainsSeq[f].push(v),""!==v.resi&&(void 0===s.alnChains[f]&&(s.alnChains[f]={}),$.extend(s.alnChains[f],s.residues[f+"_"+m])),void 0===s.alnChainsAnno[d]&&(s.alnChainsAnno[d]=[]),void 0===s.alnChainsAnno[d][0]&&(s.alnChainsAnno[d][0]=[]),void 0===s.alnChainsAnno[d][1]&&(s.alnChainsAnno[d][1]=[]),void 0===s.alnChainsAnno[d][2]&&(s.alnChainsAnno[d][2]=[]),void 0===s.alnChainsAnno[d][3]&&(s.alnChainsAnno[d][3]=[]),e===h&&(void 0===s.alnChainsAnno[d][4]&&(s.alnChainsAnno[d][4]=[]),void 0===s.alnChainsAnno[d][5]&&(s.alnChainsAnno[d][5]=[]),void 0===s.alnChainsAnno[d][6]&&(s.alnChainsAnno[d][6]=[]),s.alnChainsAnno[d][4].push(s.pdbid_chain2title[f]),s.alnChainsAnno[d][5].push(s.pdbid_chain2title[d]),s.alnChainsAnno[d][6].push(""));let _=d+"_"+c[e].resi,w=f+"_"+m,S=s.secondaries[_],A=s.secondaries[w];A?s.alnChainsAnno[d][0].push(A):s.alnChainsAnno[d][0].push("-"),S?s.alnChainsAnno[d][1].push(S):s.alnChainsAnno[d][1].push("-");let x=".";b%5==0&&(x="*"),b%10==0&&(x="|"),s.alnChainsAnno[d][2].push(x);let k="";b%10==0&&(k=b.toString()),s.alnChainsAnno[d][3].push(k),++b}}e={}}getPosFromResi(e,t){let s=this.icn3d;s.icn3dui;let i,n=s.resid2ncbi[e+"_"+t];if(n){i=n.substr(n.lastIndexOf("_")+1)-1}return i}getResnFromResi(e,t){let s=this.icn3d;s.icn3dui;let i=e+"_"+t,n=s.residueId2Name[i];return n||(n="?"),n}getResiAferAlign(e,t,s){let i,n=this.icn3d,l=n.icn3dui;if(t&&"tmalign"==l.cfg.aligntool)i=s;else if(n.posid2resid){let t=n.posid2resid[e+"_"+s];i=t.substr(t.lastIndexOf("_")+1)}else i=n.chainsSeq[e][s].resi;return i}setSeqAlignChain(e,t,s){let i,n,l,r,o,a,d,c,h,p,m,u=this.icn3d,g=u.icn3dui,f={},b=!!s;if(b){if(o=s[1],a=s[0],t=s[2],d=o.indexOf("_"),c=a.indexOf("_"),i=o.substr(0,d).toUpperCase(),n=a.substr(0,c).toUpperCase(),l=o.substr(d+1),r=a.substr(d+1),i==n&&l==r){let e=u.chainsSeq[n+"_"+r].length;u.qt_start_end[t]={q_start:1,q_end:e,t_start:1,t_end:e}}}else{let d=s[0].indexOf("_"),c=e.indexOf("_");if(i=u.mmdbid_t,n=e.substr(0,c).toUpperCase(),l=s[0].substr(d+1),r=e.substr(c+1),i==n&&l==r){let e=u.chainsSeq[u.mmdbid_q+"_"+u.chain_q].length;u.qt_start_end[t]={q_start:1,q_end:e,t_start:1,t_end:e}}o=i+"_"+l,a=n+"_"+r,void 0!==n&&u.mmdbid_t}u.conservedName1=o+"_cons",u.nonConservedName1=o+"_ncons",u.notAlignedName1=o+"_nalign",u.conservedName2=a+"_cons",u.nonConservedName2=a+"_ncons",u.notAlignedName2=a+"_nalign",u.consHash1={},u.nconsHash1={},u.nalignHash1={},u.consHash2={},u.nconsHash2={},u.nalignHash2={},u.alnChains={},u.alnChainsSeq[o]=[],u.alnChains[o]={},u.alnChainsSeq[a]=[],u.alnChains[a]={},u.alnChainsAnno[o]=[],u.alnChainsAnTtl[o]=[],void 0===u.alnChainsAnTtl[o]&&(u.alnChainsAnTtl[o]=[]);for(let e=0;e<7;++e)void 0===u.alnChainsAnTtl[o][e]&&(u.alnChainsAnTtl[o][e]=[]);u.alnChainsAnTtl[o][0].push(a),u.alnChainsAnTtl[o][1].push(o),u.alnChainsAnTtl[o][2].push(""),u.alnChainsAnTtl[o][3].push(""),u.alnChainsAnTtl[o][4].push(a),u.alnChainsAnTtl[o][5].push(o),u.alnChainsAnTtl[o][6].push("");let C=0,y=0;if(void 0===u.qt_start_end[t])return;let v=1;u.chainsMapping[o]||(u.chainsMapping[o]={}),u.chainsMapping[a]||(u.chainsMapping[a]={});let _={},w={};for(let e=0,s=u.qt_start_end[t].length;e0){let e=v;for(let t=C+1,i=s;tc&&(c=t)}}}"tmalign"==n.cfg.aligntool&&(s=!0);let p=Object.keys(a);p.sort((function(e,t){return parseInt(e)-parseInt(t)}));let m=-999,u=0,g=0,f=[],b=0;for(let e=0,t=p.length;e0&&i.resid2ncbi[t]!=i.resid2ncbi[m]+1&&i.resid2ncbi[t]!=i.resid2ncbi[m]){g=m;for(let e=0,t=f.length;ec)continue;let o={},p=r.indexOf("_");o.mmdbid=r.substr(0,p),o.chain=r.substr(p+1),o.resi=t,o.resn=a[t]?i.chainsSeq[r][e].name.toUpperCase():i.chainsSeq[r][e].name.toLowerCase(),o.aligned=!!a[t],o.color=a[t]?"#FF0000":n.htmlCls.GREYC,o.color2=a[t]?"#FF0000":n.htmlCls.GREYC,o.class=a[t]?"icn3d-align":"icn3d-nalign",i.alnChainsSeq[r].push(o),a[t]&&($.extend(i.alnChains[r],i.residues[r+"_"+o.resi]),l=n.hashUtilsCls.unionHash(l,i.residues[r+"_"+o.resi]))}let C=[0];for(let i=0,r=t.length;in)for(let e=0,t=u-m;e=n)for(let e=0,s=t-n;en)for(let e=0,t=d-a;e=n)for(let t=0,s=e-n;t0?void 0!==n?p.alnChainsAnno[t][0].push(n):p.alnChainsAnno[t][0].push("-"):console.log("Error: ic.alnChainsAnno[chainid1] is undefined")}}}class ds{constructor(e){this.icn3d=e}getStructureId(e,t,s){let i=this.icn3d;i.icn3dui;let n=e;return(e==i.defaultPdbId||s||i.structures.hasOwnProperty(e))&&(n=1===t?e:e+t.toString()),n}loadPDB(e,t,s,i,n,l,r,o){let a,d,c=this.icn3d,h=c.icn3dui,p={},m=!1,u=e.split("\n"),g={},f={};c.atoms||(l=!1),n||l?(c.oriNStru=c.structures?Object.keys(c.structures).length:0,d=c.oriNStru+1,a=c.atoms?Object.keys(c.atoms).length:0):(c.init(),d=1,a=0);let b,C,y,v,_,w,S,A=[],x=[],k=[],O=[],R=[],I=[],T="",E="",P="",M={},D=t||c.defaultPdbId,H=D,F="",L=!1,N=!0;for(let e in u){let r=u[e],q=r.substr(0,6);if("HEADER"!==q||L||t)if("TITLE "===q){let e=r.substr(10).replace(/ALPHAFOLD MONOMER V2.0 PREDICTION FOR /gi,"");c.molTitle+=e.trim()+" ",o&&c.esmTitle&&(c.molTitle=c.esmTitle),c.molTitleHash||(c.molTitleHash={}),c.molTitleHash[H]=c.molTitle}else if("HELIX "===q){c.bSecondaryStructure=!0;let e=""==r.substr(18,2).trim()?"A":r.substr(18,2).trim(),t=parseInt(r.substr(21,4)),s=parseInt(r.substr(33,4));for(let i=t;i<=s;++i){let n=H+"_"+e+"_"+i;O.push(n),i===t&&R.push(n),i===s&&I.push(n)}}else if("SHEET "===q){void 0!==s&&s||(c.bSecondaryStructure=!0);let e=""==r.substr(20,2).trim()?"A":r.substr(20,2).trim(),t=parseInt(r.substr(22,4)),i=parseInt(r.substr(33,4));for(let s=t;s<=i;++s){let n=H+"_"+e+"_"+s;A.push(n),s===t&&x.push(n),s===i&&k.push(n)}}else if("HBOND "===q)void 0!==s&&s||(c.bSecondaryStructure=!0);else if("SSBOND"===q){c.bSsbondProvided=!0;let e=D+"_"+(" "==r.substr(15,1)?"A":r.substr(15,1))+"_"+r.substr(17,4).trim(),t=D+"_"+(" "==r.substr(29,1)?"A":r.substr(29,1))+"_"+r.substr(31,4).trim();void 0===c.ssbondpnts[D]&&(c.ssbondpnts[D]=[]),c.ssbondpnts[D].push(e),c.ssbondpnts[D].push(t)}else if("REMARK"===q){let e=parseInt(r.substr(7,3));if(-1!==r.indexOf("1/2 of bilayer thickness:"))c.halfBilayerSize=parseFloat(r.substr(r.indexOf(":")+1).trim());else if(210==e)"EXPERIMENT TYPE"==r.substr(11,32).trim()&&"NMR"==r.substr(45).trim()&&(m=!0);else if(350==e&&"BIOMT"==r.substr(13,5)){let e=parseInt(r[18])-1,t=parseInt(r.substr(21,2))-1;null==c.biomtMatrices[t]&&(c.biomtMatrices[t]=(new THREE.Matrix4).identity()),c.biomtMatrices[t].elements[e]=parseFloat(r.substr(24,9)),c.biomtMatrices[t].elements[e+4]=parseFloat(r.substr(34,9)),c.biomtMatrices[t].elements[e+8]=parseFloat(r.substr(44,9)),c.biomtMatrices[t].elements[e+12]=parseFloat(r.substr(54,14))}else if(465==e&&" "==r.substr(18,1)&&" "==r.substr(20,1)&&"S"!=r.substr(21,1)){let e=r.substr(15,3),t=r.substr(18,2).trim(),s=r.substr(21,5).trim(),i=D+"_"+t;void 0===c.chainMissingResidueArray[i]&&(c.chainMissingResidueArray[i]=[]);let n={};n.resi=s,n.name=h.utilsCls.residueName2Abbr(e).toLowerCase(),""!=F&&t==F&&t!=F||(c.chainMissingResidueArray[i].push(n),F=t)}else 900==e&&void 0===c.emd&&"RELATED DB: EMDB"==r.substr(34).trim()&&(c.emd=r.substr(23,11).trim())}else if("SOURCE"===q&&void 0===c.organism&&"ORGANISM_COMMON"==r.substr(11,15).trim())c.organism=r.substr(28).toLowerCase().trim(),c.organism=c.organism.substr(0,c.organism.length-1);else if("ENDMDL"===q)++d,D=c.defaultPdbId,H=this.getStructureId(D,d,n),m||(A=[],x=[],k=[],O=[],R=[],I=[]),L=!1;else if("JRNL "===q)"PMID"===r.substr(12,4)&&(c.pmid=r.substr(19).trim());else if("ATOM "===q||"HETATM"===q){N&&(H=this.getStructureId(D,d,n),N=!1);let e=r.substr(16,1);++a,M[parseInt(r.substr(6,5))]=a;let t=r.substr(76,2).trim();""===t&&(t=r.substr(12,2).trim());let l=r.substr(12,4).trim(),u=r.substr(17,3),F=r.substr(20,2).trim();""===F&&(F="A");let L=r.substr(22,5).trim(),U=L;if(s&&"DUM"===u&&(t=l,F="MEM",U=1,L=1),i&&"DUM"===u)break;b=H+"_"+F,y=b+"_"+L,C=b+"_"+U;let $=parseFloat(r.substr(30,8)),j=parseFloat(r.substr(38,8)),B=parseFloat(r.substr(46,8)),z=new THREE.Vector3($,j,B),G=parseFloat(r.substr(60,8));o&&(G*=100);let V={het:"H"===q[0],serial:a,name:l,alt:e,resn:u,structure:H,chain:F,resi:U,coord:z,b:G,elem:t,bonds:[],ss:"coil",ssbegin:!1,ssend:!1};if(V.het||"C"!==V.name||(v=a),V.het||"O"!==V.name||(w=a),!V.het&&"N"===V.name&&void 0!==_&&void 0!==S){let e=c.atoms[_].coord.distanceTo(c.atoms[S].coord),t=V.coord.x+(c.atoms[_].coord.x-c.atoms[S].coord.x)/e,s=V.coord.y+(c.atoms[_].coord.y-c.atoms[S].coord.y)/e,i=V.coord.z+(c.atoms[_].coord.z-c.atoms[S].coord.z)/e;V.hcoord=new THREE.Vector3(t,s,i)}c.atoms[a]=V,c.dAtoms[a]=1,c.hAtoms[a]=1,p[a]=1,this.isSecondary(C,A,m)?(c.atoms[a].ss="sheet",this.isSecondary(C,x,m)&&(c.atoms[a].ssbegin=!0),this.isSecondary(C,k,m)&&(c.atoms[a].ssend=!0)):this.isSecondary(C,O,m)&&(c.atoms[a].ss="helix",this.isSecondary(C,R,m)&&(c.atoms[a].ssbegin=!0),this.isSecondary(C,I,m)&&(c.atoms[a].ssend=!0));let W="-";if(W="helix"===c.atoms[a].ss?"H":"sheet"===c.atoms[a].ss?"E":!c.atoms[a].het&&h.parasCls.residueColors.hasOwnProperty(c.atoms[a].resn.toUpperCase())?"c":"o",c.secondaries[C]=W,y!==P){let e=h.utilsCls.residueName2Abbr(u);if(c.residueId2Name[C]=e,1!==a&&""!==E&&(c.residues[E]=f),C!==E&&(f={}),b!==T){_=void 0,S=void 0,1!==a&&""!==T&&(void 0===c.chains[T]&&(c.chains[T]={}),c.chains[T]=h.hashUtilsCls.unionHash(c.chains[T],g)),g={},void 0===c.structures[H.toString()]&&(c.structures[H.toString()]=[]),c.structures[H.toString()].includes(b)||c.structures[H.toString()].push(b),void 0===c.chainsSeq[b]&&(c.chainsSeq[b]=[]);let t={};t.resi=U,t.name=e,c.chainsSeq[b].push(t)}else{_=v,S=w;let t={};t.resi=U,t.name=e,c.chainsSeq[b].push(t)}}g[a]=1,f[a]=1,T=b,E=C,P=y}else if("CONECT"===q){let e=parseInt(r.substr(6,5));for(let t=0;t<4;++t){let s=parseInt(r.substr([11,16,21,26][t],5));isNaN(s)||void 0!==c.atoms[M[e]]&&c.atoms[M[e]].bonds.push(M[s])}}else q.substr(0,3);else D=r.substr(62).trim(),""==D&&(D=l?c.defaultPdbId:c.inputid&&-1==c.inputid.indexOf("/")?c.inputid.substr(0,10):c.defaultPdbId),H=this.getStructureId(D,d,n),c.molTitle="",c.molTitleHash={},L=!0}c.residues[C]=f,void 0===c.chains[b]&&(c.chains[b]={}),c.chains[b]=h.hashUtilsCls.unionHash2Atoms(c.chains[b],g,c.atoms),this.adjustSeq(c.chainMissingResidueArray);let q=Object.keys(c.structures);for(let e=0,t=q.length;e=l?n:l,o=new Array(s+i),a=0,d=0,c=0,h=!1;for(;ar&&i>r&&(h=!0),s<=r&&i>r?s>i||h?(o[c]=t[d],d++):(o[c]=e[a],a++):s>r&&i<=r?s<=i||h?(o[c]=e[a],a++):(o[c]=t[d],d++):s<=i?(o[c]=e[a],a++):(o[c]=t[d],d++),c++}if(a4||Math.abs(l.y-r.y)>4||Math.abs(l.z-r.z)>4||(l.x-r.x)*(l.x-r.x)+(l.y-r.y)*(l.y-r.y)+(l.z-r.z)*(l.z-r.z)<16&&(void 0===t.ssbondpnts[e]&&(t.ssbondpnts[e]=[]),t.ssbondpnts[e].push(o),t.ssbondpnts[e].push(a)))}}}getChainCalpha(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r={};for(let o in e){if(void 0!==i){if(o.split("_")[0]!==i)continue}let a=Object.keys(e[o]),d=[],c=0,h=0;for(let e=0,i=a.length;e3?i.resn.trim().substr(0,3):i.resn.trim();if(!l.parasCls.chargeColors.hasOwnProperty(e))continue;s?i.resi_ori:i.resi,d.push(i.coord.clone()),++c,h=i.resi}}if(c>0){r[t[a[0]].chain]=d}}return{chainresiCalphaHash:r,center:n.center.clone()}}isSecondary(e,t,s){if(this.icn3d.icn3dui,s){let s=e.substr(e.indexOf("_")+1),i=!1;for(let e=0,n=t.length;e0&&(d=!0);for(let n=0,l=t.length;na&&(a=l),s.push(l)}o.push(s)}if(!d)return void(n.bRender&&alert("These structures can not be aligned..."));a<1e-6&&(a=1);for(let e=0,s=t.length;ep[e]=4&&(n.rmsd_suprTmp=l.rmsdSuprCls.getRmsdSuprCls(c,a,p),void 0!==n.rmsd_suprTmp.rot))){let e=n.rmsd_suprTmp.rot;if(null===e[0])continue;let i=n.rmsd_suprTmp.trans1,r=n.rmsd_suprTmp.trans2,a=n.rmsd_suprTmp.rmsd;if(aRealignment RMSD: "+a.toPrecision(4)+" Å

    "),l.cfg.bSidebyside||l.htmlCls.dialogCls.openDlg("dl_rmsd","Realignment RMSD"),n.q_rotation=[],n.q_trans_sub=[],n.t_trans_add=[],n.q_rotation.push({x1:e[0],y1:e[1],z1:e[2],x2:e[3],y2:e[4],z2:e[5],x3:e[6],y3:e[7],z3:e[8]}),n.q_trans_sub.push(i),n.t_trans_add.push({x:-r.x,y:-r.y,z:-r.z}),l.cfg.aligntool="vast";//!= 'tmalign'; +let c=0,h="query",p=o.substr(0,o.indexOf("_")),m=!0;n.chainalignParserCls.transformStructure(p,c,h,m);let u="";for(let e=0,i=s.length;e8)return s;let g=[];g[0]=n[0]*r[0]+n[1]*r[1]+n[2]*r[2],g[1]=n[3]*r[0]+n[4]*r[1]+n[5]*r[2],g[2]=n[6]*r[0]+n[7]*r[1]+n[8]*r[2],g[0]-=n[0]*a[0]+n[1]*a[1]+n[2]*a[2],g[1]-=n[3]*a[0]+n[4]*a[1]+n[5]*a[2],g[2]-=n[6]*a[0]+n[7]*a[1]+n[8]*a[2];let f=0;return f=c[0]*g[0],f+=c[1]*g[1],f+=c[2]*g[2],f/=p*m,f<.866?s:(g[0]=l[0]*r[0]+l[1]*r[1]+l[2]*r[2],g[1]=l[3]*r[0]+l[4]*r[1]+l[5]*r[2],g[2]=l[6]*r[0]+l[7]*r[1]+l[8]*r[2],g[0]-=l[0]*a[0]+l[1]*a[1]+l[2]*a[2],g[1]-=l[3]*a[0]+l[4]*a[1]+l[5]*a[2],g[2]-=l[6]*a[0]+l[7]*a[1]+l[8]*a[2],f=c[0]*g[0],f+=c[1]*g[1],f+=c[2]*g[2],f/=p*m,f<.866?s:(u=0,u+=Math.pow(e.q_rotation.x1-t.q_rotation.x1,2),u+=Math.pow(e.q_rotation.y1-t.q_rotation.y1,2),u+=Math.pow(e.q_rotation.z1-t.q_rotation.z1,2),u+=Math.pow(e.q_rotation.x2-t.q_rotation.x2,2),u+=Math.pow(e.q_rotation.y2-t.q_rotation.y2,2),u+=Math.pow(e.q_rotation.z2-t.q_rotation.z2,2),u+=Math.pow(e.q_rotation.x3-t.q_rotation.x3,2),u+=Math.pow(e.q_rotation.y3-t.q_rotation.y3,2),u+=Math.pow(e.q_rotation.z3-t.q_rotation.z3,2),Math.sqrt(u)))}GetRotMatrix(e,t,s){this.icn3d.icn3dui;let i=[];return i&&(i[0]=e.q_rotation.x1/t,i[1]=e.q_rotation.y1/t,i[2]=e.q_rotation.z1/t,i[3]=e.q_rotation.x2/t,i[4]=e.q_rotation.y2/t,i[5]=e.q_rotation.z2/t,i[6]=e.q_rotation.x3/t,i[7]=e.q_rotation.y3/t,i[8]=e.q_rotation.z3/t,2!=s?(i[9]=e.t_trans_add.x/t,i[10]=e.t_trans_add.y/t,i[11]=e.t_trans_add.z/t,i[12]=-e.q_trans_sub.x/t,i[13]=-e.q_trans_sub.y/t,i[14]=-e.q_trans_sub.z/t):(i[9]=-e.q_trans_add.x/t,i[10]=-e.q_trans_add.y/t,i[11]=-e.q_trans_add.z/t,i[12]=0,i[13]=0,i[14]=0)),i}cbu_dist(e,t,s){return er&&(s.push(e[n].leaves),i.push(e[n].dist));return{clusters:s,scores:i}}}class hs{constructor(e){this.icn3d=e}async applyCommand(e){let t=this.icn3d,s=t.icn3dui;t.bAddCommands=!1;let i=e.split("|||")[0].split("%7C%7C%7C")[0].replace(/\s+/g," ").trim(),n=i.toLowerCase();if("share link"==n)await t.shareLinkCls.shareLink();else if("export state file"==n);else if(0==n.indexOf("export canvas"))setTimeout((async function(){let e=n.substr(13).trim();t.scaleFactor=""===e?1:parseInt(e);let s=""!==e;await t.shareLinkCls.shareLink(!0,s)}),500);else if("export interactions"==n)t.viewInterPairsCls.exportInteractions();else if("export stl file"==n)setTimeout((function(){t.export3DCls.exportStlFile("")}),500);else if("export vrml file"==n)setTimeout((function(){t.export3DCls.exportVrmlFile("")}),500);else if("export stl stabilizer file"==n)setTimeout((function(){t.threeDPrintCls.hideStabilizer(),t.threeDPrintCls.resetAfter3Dprint(),t.threeDPrintCls.addStabilizer(),t.export3DCls.exportStlFile("_stab")}),500);else if("export vrml stabilizer file"==n)setTimeout((function(){t.threeDPrintCls.hideStabilizer(),t.threeDPrintCls.resetAfter3Dprint(),t.threeDPrintCls.addStabilizer(),t.export3DCls.exportVrmlFile("_stab")}),500);else if("export pdb"==n)s.htmlCls.setHtmlCls.exportPdb();else if("export pdb missing atoms"==n)await t.scapCls.exportPdbProfix(!1);else if("export pdb hydrogen"==n)await t.scapCls.exportPdbProfix(!0);else if(-1!=n.indexOf("export refnum ")){let e=n.substr(14);t.refnumCls.exportRefnum(e)}else if("export secondary structure"==n)s.htmlCls.setHtmlCls.exportSecondary();else if("select all"==n)t.selectionCls.selectAll();else if("show all"==n)t.selectionCls.showAll();else if("select complement"==n)t.resid2specCls.selectComplement();else if("set pk atom"==n)t.pk=1,t.opts.pk="atom";else if("set pk off"==n)t.pk=0,t.opts.pk="no",t.drawCls.draw(),t.hlObjectsCls.removeHlObjects();else if("set pk residue"==n)t.pk=2,t.opts.pk="residue";else if("set pk strand"==n)t.pk=3,t.opts.pk="strand";else if("set pk domain"==n)t.pk=4,t.opts.pk="domain";else if("set pk chain"==n)t.pk=5,t.opts.pk="chain";else if("set surface wireframe on"==n)t.opts.wireframe="yes",t.applyMapCls.applySurfaceOptions();else if("set surface wireframe off"==n)t.opts.wireframe="no",t.applyMapCls.applySurfaceOptions();else if("set map wireframe on"==n)t.opts.mapwireframe="yes",t.applyMapCls.applyMapOptions();else if("set map wireframe off"==n)t.opts.mapwireframe="no",t.applyMapCls.applyMapOptions();else if("set emmap wireframe on"==n)t.opts.emmapwireframe="yes",t.applyMapCls.applyEmmapOptions();else if("set emmap wireframe off"==n)t.opts.emmapwireframe="no",t.applyMapCls.applyEmmapOptions();else if("set surface neighbors on"==n)t.bConsiderNeighbors=!0,t.applyMapCls.applySurfaceOptions();else if("set surface neighbors off"==n)t.bConsiderNeighbors=!1,t.applyMapCls.applySurfaceOptions();else if("set axis on"==n)t.opts.axis="yes";else if("set pc1 axis"==n)t.pc1=!0,t.axesCls.setPc1Axes();else if("set axis off"==n)t.opts.axis="no",t.pc1=!1;else if("set fog on"==n)t.opts.fog="yes",t.fogCls.setFog(!0);else if("set fog off"==n)t.opts.fog="no",t.fogCls.setFog(!0);else if("set slab on"==n)t.opts.slab="yes";else if("set slab off"==n)t.opts.slab="no";else if("set assembly on"==n)t.bAssembly=!0;else if("set assembly off"==n)t.bAssembly=!1;else if("set chemicalbinding show"==n)t.setOptionCls.setOption("chemicalbinding","show");else if("set chemicalbinding hide"==n)t.setOptionCls.setOption("chemicalbinding","hide");else if("set hbonds off"==n)t.hBondCls.hideHbonds(),t.showInterCls.hideExtraBonds(),t.drawCls.draw();else if("set salt bridge off"==n)t.saltbridgeCls.hideSaltbridge(),t.showInterCls.hideExtraBonds(),t.drawCls.draw();else if("set contact off"==n)t.contactCls.hideContact(),t.showInterCls.hideExtraBonds(),t.drawCls.draw();else if("set halogen pi off"==n)t.piHalogenCls.hideHalogenPi(),t.showInterCls.hideExtraBonds(),t.drawCls.draw();else if("hydrogens"==n)t.showInterCls.showHydrogens(),t.drawCls.draw();else if("set hydrogens off"==n)t.showInterCls.hideHydrogens(),t.drawCls.draw();else if("close popup"==n)t.resizeCanvasCls.closeDialogs();else if("set stabilizer off"==n)t.threeDPrintCls.hideStabilizer(),t.drawCls.draw();else if("set disulfide bonds off"==n)t.opts.ssbonds="no",t.drawCls.draw();else if("set cross linkage off"==n)t.opts.clbonds="no",t.drawCls.draw();else if("set lines off"==n)t.labels.distance=[],t.lines.distance=[],t.drawCls.draw();else if("set labels off"==n){for(let e in t.labels)t.labels[e]=[];t.drawCls.draw()}else if("set mode all"==n)t.definedSetsCls.setModeAndDisplay("all");else if("set mode selection"==n)t.definedSetsCls.setModeAndDisplay("selection");else if("set view detailed view"==n)t.annotationCls.setAnnoViewAndDisplay("detailed view");else if("set view overview"==n)t.annotationCls.setAnnoViewAndDisplay("overview");else if("set annotation custom"==n)t.annotationCls.setAnnoTabCustom();else if("set annotation interaction"==n)t.annotationCls.setAnnoTabInteraction();else if("set annotation ptm"==n)await t.annotationCls.setAnnoTabPTM();else if("set annotation cdd"==n)t.annotationCls.setAnnoTabCdd();else if("set annotation site"==n)t.annotationCls.setAnnoTabSite();else if("set annotation ssbond"==n)t.annotationCls.setAnnoTabSsbond();else if("set annotation crosslink"==n)t.annotationCls.setAnnoTabCrosslink();else if("set annotation transmembrane"==n)await t.annotationCls.setAnnoTabTransmem();else if("highlight level up"==n)t.resid2specCls.switchHighlightLevelUp();else if("highlight level down"==n)t.resid2specCls.switchHighlightLevelDown();else if(0==n.indexOf("hide annotation")){let e=n.lastIndexOf(" "),s=n.substr(e+1);"all"==s?t.annotationCls.hideAnnoTabAll():"custom"==s?t.annotationCls.hideAnnoTabCustom():"clinvar"==s?t.annotationCls.hideAnnoTabClinvar():"snp"==s?t.annotationCls.hideAnnoTabSnp():"cdd"==s?t.annotationCls.hideAnnoTabCdd():"3ddomain"==s?t.annotationCls.hideAnnoTab3ddomain():"site"==s?t.annotationCls.hideAnnoTabSite():"ptm"==s?t.annotationCls.hideAnnoTabPTM():"interaction"==s?t.annotationCls.hideAnnoTabInteraction():"ssbond"==s?t.annotationCls.hideAnnoTabSsbond():"crosslink"==s?t.annotationCls.hideAnnoTabCrosslink():"transmembrane"==s&&t.annotationCls.hideAnnoTabTransmem()}else if("add residue labels"==n)t.residueLabelsCls.addResidueLabels(t.hAtoms),t.drawCls.draw();else if("add residue number labels"==n)t.residueLabelsCls.addResidueLabels(t.hAtoms,void 0,void 0,!0),t.drawCls.draw();else if("add reference number labels"==n)t.residueLabelsCls.addResidueLabels(t.hAtoms,void 0,void 0,void 0,!0),t.drawCls.draw();else if("add atom labels"==n)t.residueLabelsCls.addAtomLabels(t.hAtoms),t.drawCls.draw();else if("add element labels"==n)t.residueLabelsCls.addAtomLabels(t.hAtoms,!0),t.drawCls.draw();else if("add chain labels"==n)t.analysisCls.addChainLabels(t.hAtoms),t.drawCls.draw();else if("add terminal labels"==n)t.analysisCls.addTerminiLabels(t.hAtoms),t.drawCls.draw();else if("rotate left"==n)t.bStopRotate=!1,t.ROT_DIR="left",t.transformCls.rotateCountMax=6e3,t.resizeCanvasCls.rotStruc("left");else if("rotate right"==n)t.bStopRotate=!1,t.ROT_DIR="right",t.transformCls.rotateCountMax=6e3,t.resizeCanvasCls.rotStruc("right");else if("rotate up"==n)t.bStopRotate=!1,t.ROT_DIR="up",t.transformCls.rotateCountMax=6e3,t.resizeCanvasCls.rotStruc("up");else if("rotate down"==n)t.bStopRotate=!1,t.ROT_DIR="down",t.transformCls.rotateCountMax=6e3,t.resizeCanvasCls.rotStruc("down");else if("rotate x"==n){let e=new THREE.Vector3(1,0,0),s=.5*Math.PI;t.transformCls.setRotation(e,s)}else if("rotate y"==n){let e=new THREE.Vector3(0,1,0),s=.5*Math.PI;t.transformCls.setRotation(e,s)}else if("rotate z"==n){let e=new THREE.Vector3(0,0,1),s=.5*Math.PI;t.transformCls.setRotation(e,s)}else if("reset"===n)t.selectionCls.resetAll();else if("reset orientation"===n)t.transformCls.resetOrientation(),t.drawCls.draw();else if("reset thickness"==n)t.threeDPrintCls.resetAfter3Dprint(),t.drawCls.draw();else if("clear selection"==n)t.hlObjectsCls.removeHlObjects(),t.hlUpdateCls.removeHl2D(),t.bShowHighlight=!1,t.bSelectResidue=!1;else if("zoom selection"==n)t.transformCls.zoominSelection(),t.drawCls.draw();else if("center selection"==n)t.applyCenterCls.centerSelection(),t.drawCls.draw();else if("show selection"==n)t.selectionCls.showSelection();else if("hide selection"==n)t.selectionCls.hideSelection();else if("output selection"==n)t.threeDPrintCls.outputSelection();else if("toggle selection"==n)t.selectionCls.toggleSelection();else if("toggle highlight"==n)t.hlUpdateCls.toggleHighlight();else if("stabilizer"==n)t.threeDPrintCls.addStabilizer(),t.threeDPrintCls.prepareFor3Dprint();else if("disulfide bonds"==n)t.showInterCls.showSsbonds();else if("cross linkage"==n)t.showInterCls.showClbonds();else if("back"==n)await t.resizeCanvasCls.back();else if("forward"==n)await t.resizeCanvasCls.forward();else if("clear all"==n)t.selectionCls.selectAll();else if("defined sets"==n)t.definedSetsCls.showSets();else if("delete selected sets"==n)t.definedSetsCls.deleteSelectedSets();else if("view interactions"==n)void 0===s.cfg.mmdbid&&void 0===s.cfg.gi||t.ParserUtilsCls.set2DDiagrams(t.inputid);else if("show annotations all chains"==n)t.annotationCls.showAnnoAllChains();else if("save color"==n)t.setOptionCls.saveColor();else if("apply saved color"==n)t.setOptionCls.applySavedColor();else if("save style"==n)t.setOptionCls.saveStyle();else if("apply saved style"==n)t.setOptionCls.applySavedStyle();else if("select main chains"==n)t.selectionCls.selectMainChains();else if("select side chains"==n)t.selectionCls.selectSideChains();else if("select main side chains"==n)t.selectionCls.selectMainSideChains();else if("realign"==n)t.realignParserCls.realign();else if(-1!=n.indexOf("realign predefined ")){let e="realign predefined ",n=i.substr(e.length),l=n.indexOf(" "),r=n.substr(0,l).split(",");s.cfg.resdef=n.substr(l+1).replace(/:/gi,";"),await t.realignParserCls.realignChainOnSeqAlign(void 0,r,!0,!0)}else if("area"==n)t.analysisCls.calculateArea();else if("table inter count only"==n)$(".icn3d-border").hide();else if("table inter details"==n)$(".icn3d-border").show();else if("setoption map nothing"==n)t.setOptionCls.setOption("map","nothing");else if("setoption emmap nothing"==n)t.setOptionCls.setOption("emmap","nothing");else if("setoption phimap nothing"==n)t.setOptionCls.setOption("phimap","nothing");else if("setoption phisurface nothing"==n)t.setOptionCls.setOption("phisurface","nothing");else if("clear symd symmetry"==n)t.symdArray=[];else if("show axis"==n)t.bAxisOnly=!0;else if(0==i.indexOf("define helix sets")){let e=i.split(" | ")[1].split(" ")[1];t.addTrackCls.defineSecondary(e,"helix")}else if(0==i.indexOf("define sheet sets")){let e=i.split(" | ")[1].split(" ")[1];t.addTrackCls.defineSecondary(e,"sheet")}else if(0==i.indexOf("define coil sets")){let e=i.split(" | ")[1].split(" ")[1];t.addTrackCls.defineSecondary(e,"coil")}else if(0==i.indexOf("define igstrand sets")){let e=i.split(" | ")[1].split(" ")[1];t.addTrackCls.defineIgstrand(e,"igstrand")}else if(0==i.indexOf("define igloop sets")){let e=i.split(" | ")[1].split(" ")[1];t.addTrackCls.defineIgstrand(e,"igloop")}else if(0==i.indexOf("select interaction")){let e=i.substr(i.lastIndexOf(" ")+1).split(",");if(null!==e){let s=e[0].split("_")[0];t.b2DShown||t.ParserUtilsCls.download2Ddgm(s.toUpperCase()),t.diagram2dCls.selectInteraction(e[0],e[1])}}else if(0==i.indexOf("select saved atoms")||0==i.indexOf("select sets")){i=i.replace(/aligned_protein/g,"protein_aligned");let e=i.split(" | "),s=e[0].replace(/,/g," or "),n=19;0==i.indexOf("select sets")&&(n=12);let l=s.substr(n),r=l;2==e.length&&(r=e[1].substr(5)),t.definedSetsCls.selectCombinedSets(l,r)}else if(-1!==i.indexOf("select chain")){let e=i.substr(i.lastIndexOf(" ")+1).split(",");for(let s=0,i=e.length;s6?e[6].substr(e[6].lastIndexOf(" ")+1):0,d=e.length>7?e[7].substr(e[7].lastIndexOf(" ")+1):1;t.analysisCls.addLine(parseFloat(s[1]),parseFloat(s[3]),parseFloat(s[5]),parseFloat(i[1]),parseFloat(i[3]),parseFloat(i[5]),l,r,o,parseFloat(a),parseFloat(d)),t.drawCls.draw()}else if(0==n.indexOf("add sphere"))this.addShape(n,"sphere");else if(0==n.indexOf("add cube"))this.addShape(n,"cube");else if(0==n.indexOf("clear shape"))t.shapeCmdHash={};else if(0==n.indexOf("clear line between sets"))t.lines.cylinder=[];else if(0==i.indexOf("add label")){let e,n,l,r,o,a,d,c=i.split(" | "),h=c[0].substr("add label".length+1),p=!1;for(let t=1,s=c.length;t=5&&(e=l[4].substr(5)),l.length>=6&&(s=l[5].substr(6)),l.length>=7&&(n=l[6].substr(4)),$("#"+t.pre+"anno_custom")[0]&&($("#"+t.pre+"anno_custom")[0].checked=!0),$("[id^="+t.pre+"custom]").show(),"0"==s&&(s=void 0),t.addTrackCls.checkGiSeq(r,o,a,e,s,n,0)}else if(0==n.indexOf("remove one stabilizer")){let e=n.split(" | ")[1].split(" "),s=[];s.push(parseInt(e[0])),s.push(parseInt(e[1])),t.threeDPrintCls.removeOneStabilizer(s),t.drawCls.draw()}else if(0==n.indexOf("add one stabilizer")){let e=n.split(" | ")[1].split(" ");void 0===t.pairArray&&(t.pairArray=[]),t.pairArray.push(parseInt(e[0])),t.pairArray.push(parseInt(e[1])),t.drawCls.draw()}else if(0==n.indexOf("select planes z-axis")){let e=n.split(" ");if(5==e.length){let s=parseFloat(e[3]),i=parseFloat(e[4]);t.selectionCls.selectBtwPlanes(s,i)}}else if(0==n.indexOf("adjust membrane z-axis")){let e=n.split(" ");if(5==e.length){let s=parseFloat(e[3]),i=parseFloat(e[4]);t.selectionCls.adjustMembrane(s,i)}}else if(0==n.indexOf("toggle membrane"))t.selectionCls.toggleMembrane();else if(0==i.indexOf("calc buried surface")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(" ");if(2==s.length){let e=s[0].split(","),i=s[1].split(",");t.analysisCls.calcBuriedSurface(e,i)}}}else if(0==i.indexOf("dist ")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(" ");if(2==s.length){let e=s[0].split(","),i=s[1].split(",");t.analysisCls.measureDistTwoSets(e,i)}}}else if(0==i.indexOf("disttable")){let e=i.split(" | ");if(2==e.length){let i=e[1].split(" ");if(2==i.length){let e=i[0].split(","),n=i[1].split(",");t.analysisCls.measureDistManySets(e,n),s.htmlCls.dialogCls.openDlg("dl_disttable","Distance among the sets")}}}else if(0==i.indexOf("display interaction 3d")||0==i.indexOf("view interaction pairs")||0==i.indexOf("save1 interaction pairs")||0==i.indexOf("save2 interaction pairs")||0==i.indexOf("line graph interaction pairs")||0==i.indexOf("scatterplot interaction pairs")){let e=i.split(" | ");if(e.length>=3){let s=e[1].split(" ");if(2==s.length){let n,l,r=s[0].split(","),o=s[1].split(","),a=-1!==e[2].indexOf("hbonds"),d=-1!==e[2].indexOf("salt bridge"),c=-1!==e[2].indexOf("interactions"),h=-1!==e[2].indexOf("halogen"),p=-1!==e[2].indexOf("pi-cation"),m=-1!==e[2].indexOf("pi-stacking");if(e.length>=4&&(n="true"==e[3]),e.length>=5){let s=e[4].split(" ");s.length>=4&&($("#"+t.pre+"hbondthreshold").val(s[1]),$("#"+t.pre+"saltbridgethreshold").val(s[2]),$("#"+t.pre+"contactthreshold").val(s[3]),7==s.length&&($("#"+t.pre+"halogenthreshold").val(s[4]),$("#"+t.pre+"picationthreshold").val(s[5]),$("#"+t.pre+"pistackingthreshold").val(s[6])))}0==i.indexOf("display interaction 3d")?l="3d":0==i.indexOf("view interaction pairs")?l="view":0==i.indexOf("save1 interaction pairs")?l="save1":0==i.indexOf("save2 interaction pairs")?l="save2":0==i.indexOf("line graph interaction pairs")?l="linegraph":0==i.indexOf("scatterplot interaction pairs")&&(l="scatterplot"),await t.viewInterPairsCls.viewInteractionPairs(r,o,n,l,a,d,c,h,p,m)}}}else if(0==i.indexOf("export pairs")){let e=i.split(" | ");if(3==e.length){let i=e[1].split(" ");if(2==i.length){let n=i[0].split(","),l=i[1].split(","),r=e[2].split(" ")[1];t.showInterCls.pickCustomSphere(r,n,l,t.bSphereCalc),t.bSphereCalc=!0;let o=t.viewInterPairsCls.exportSpherePairs(),a=Object.keys(s.utilsCls.getHlStructures()).join(",");t.saveFileCls.saveFile(a+"_sphere_pairs.html","html",o)}}}else if(0==n.indexOf("graph label")){let e=n.lastIndexOf(" "),t=n.substr(e+1);$("#"+s.svgid+"_label").val(t),$("#"+s.svgid+" text").removeClass(),$("#"+s.svgid+" text").addClass(t)}else if(0==n.indexOf("cartoon label")){let e=n.lastIndexOf(" "),t=n.substr(e+1);$("#"+s.svgid_ct+"_label").val(t),$("#"+s.svgid_ct+" text").removeClass(),$("#"+s.svgid_ct+" text").addClass(t)}else if(0==n.indexOf("line graph scale")){let e=n.lastIndexOf(" "),i=n.substr(e+1);$("#"+s.linegraphid+"_scale").val(i),$("#"+s.linegraphid).attr("width",(t.linegraphWidth*parseFloat(i)).toString()+"px")}else if(0==n.indexOf("scatterplot scale")){let e=n.lastIndexOf(" "),i=n.substr(e+1);$("#"+s.scatterplotid+"_scale").val(i),$("#"+s.scatterplotid).attr("width",(t.scatterplotWidth*parseFloat(i)).toString()+"px")}else if(0==n.indexOf("contactmap scale")){let e=n.lastIndexOf(" "),i=n.substr(e+1);$("#"+s.contactmapid+"_scale").val(i),$("#"+s.contactmapid).attr("width",(t.contactmapWidth*parseFloat(i)).toString()+"px")}else if(0==n.indexOf("alignerrormap scale")){let e=n.lastIndexOf(" "),i=n.substr(e+1);$("#"+s.alignerrormapid+"_scale").val(i),$("#"+s.alignerrormapid).attr("width",(t.alignerrormapWidth*parseFloat(i)).toString()+"px")}else if(0==n.indexOf("graph force")){let e=n.lastIndexOf(" ");s.htmlCls.force=parseInt(n.substr(e+1)),$("#"+s.svgid+"_force").val(s.htmlCls.force),t.getGraphCls.handleForce()}else if(0==n.indexOf("hide edges")){let e=n.lastIndexOf(" ");s.htmlCls.hideedges=parseInt(n.substr(e+1)),$("#"+s.svgid+"_hideedges").val(s.htmlCls.hideedges),s.htmlCls.hideedges?(s.htmlCls.contactInsideColor="FFF",s.htmlCls.hbondInsideColor="FFF",s.htmlCls.ionicInsideColor="FFF"):(s.htmlCls.contactInsideColor="DDD",s.htmlCls.hbondInsideColor="AFA",s.htmlCls.ionicInsideColor="8FF"),void 0!==t.graphStr&&t.bRender&&s.htmlCls.force&&t.drawGraphCls.drawGraph(t.graphStr,t.pre+"dl_graph")}else if(0==n.indexOf("reset interaction pairs"))t.viewInterPairsCls.resetInteractionPairs();else if(0==n.indexOf("side by side")){let e=n.split(" | ")[1],t="_blank";window.open(e,t)}else if(0==i.indexOf("your note")){let e=i.split(" | ");t.yournote=e[1],$("#"+t.pre+"yournote").val(t.yournote),s.cfg.shownote&&(document.title=t.yournote)}else if(0==n.indexOf("cross structure interaction"))t.crossstrucinter=parseInt(n.substr(n.lastIndexOf(" ")+1)),$("#"+t.pre+"crossstrucinter").val(t.crossstrucinter);else if("replay on"==n)await t.resizeCanvasCls.replayon();else if("replay off"==n)await t.resizeCanvasCls.replayoff();else if(0==n.indexOf("contact map")){let e=n.split(" | ");if(3===e.length){let s=parseFloat(e[1].split(" ")[1]),i=e[2].split(" ")[1];await t.contactMapCls.contactMap(s,i)}}else if(0==n.indexOf("pickatom")){let e=parseInt(n.substr(n.lastIndexOf(" ")+1));t.pAtom=t.atoms[e],t.pickingCls.showPicking(t.pAtom)}else if(0==i.indexOf("set color spectrum")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(","),i=!0;t.setColorCls.setColorAcrossSets(s,i)}}else if(0==i.indexOf("set residues color spectrum")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(","),i=!0;t.setColorCls.setColorBySets(s,i)}}else if(0==i.indexOf("set color rainbow")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(","),i=!1;t.setColorCls.setColorAcrossSets(s,i)}}else if(0==i.indexOf("set residues color rainbow")){let e=i.split(" | ");if(2==e.length){let s=e[1].split(","),i=!1;t.setColorCls.setColorBySets(s,i)}}else if(0==i.indexOf("color")){let e=i.split(" | "),n=e[0].substr(e[0].indexOf(" ")+1);if(t.opts.color=n,"residue custom"==n&&2==e.length){t.customResidueColors=JSON.parse(e[1]);for(let e in t.customResidueColors)t.customResidueColors[e.toUpperCase()]=s.parasCls.thr("#"+t.customResidueColors[e])}else if("align custom"==n&&3==e.length){let s=e[1],i=e[2].split(", ");t.queryresi2score={},t.queryresi2score[s]={};for(let e=0,n=i.length;e=4?this.setQueryresi2score(e):"area"==n&&2==e.length&&(t.midpercent=e[1],$("#"+t.pre+"midpercent").val(t.midpercent));t.setColorCls.setColorByOptions(t.opts,t.hAtoms),t.hlUpdateCls.updateHlAll(),t.getGraphCls.updateGraphColor()}else if(0==i.indexOf("remove legend"))$("#"+s.pre+"legend").hide();else if(0==i.indexOf("custom tube")){let e=i.split(" | ");this.setQueryresi2score(e),t.setOptionCls.setStyle("proteins","custom tube")}else if(0==n.indexOf("style")){let e=n.substr(n.indexOf(" ")+1),s=e.substr(0,e.indexOf(" ")),i=e.substr(e.indexOf(" ")+1);t.setOptionCls.setStyle(s,i)}else if(0==n.indexOf("window")){let e=n.substr(n.indexOf(" ")+1);setTimeout((function(){"aligned sequences"==e?s.htmlCls.dialogCls.openDlg("dl_alignment","Select residues in aligned sequences"):"interaction table"==e?s.htmlCls.dialogCls.openDlg("dl_allinteraction","Show interactions"):"interaction graph"==e?s.htmlCls.dialogCls.openDlg("dl_linegraph","Show interactions between two lines of residue nodes"):"interaction scatterplot"==e?s.htmlCls.dialogCls.openDlg("dl_scatterplot","Show interactions as scatterplot"):"force-directed graph"==e&&s.htmlCls.dialogCls.openDlg("dl_graph","Force-directed graph")}),1e3)}else if(0==n.indexOf("set theme")){let e=n.substr(n.lastIndexOf(" ")+1);s.htmlCls.setMenuCls.setTheme(e)}else if(0==n.indexOf("set double color")){let e=n.substr(n.lastIndexOf(" ")+1);"on"==e?(t.bDoublecolor=!0,t.setOptionCls.setStyle("proteins","ribbon")):"off"==e&&(t.bDoublecolor=!1)}else if(0==n.indexOf("adjust dialog")){let e=n.substr(n.lastIndexOf(" ")+1);t.scapCls.adjust2DWidth(e)}else if(0==n.indexOf("glycans cartoon")){let e=n.substr(n.lastIndexOf(" ")+1);t.bGlycansCartoon="yes"==e}else if(0==n.indexOf("save html")){let e=n.substr(n.lastIndexOf(" ")+1);s.htmlCls.eventsCls.saveHtml(e)}else if(0==n.indexOf("resdef"))s.cfg.resdef=n.substr(n.indexOf(" ")+1);else if(0==n.indexOf("vast_search_chainid")){t.chainidArray=i.substr(i.indexOf(" ")+1).split(",");let e=!0,s=!0;await t.realignParserCls.realignChainOnSeqAlign(void 0,t.chainidArray,e,s)}else if(0==n.indexOf("ig refnum off"))await t.refnumCls.hideIgRefNum();else if(0==n.indexOf("custom refnum")){let e=i.split(" | ")[1].replace(/\\n/g,"\n");await t.refnumCls.parseCustomRefFile(e)}else if(0==n.indexOf("show ref number"))t.bShownRefnum=!0;else if(0==n.indexOf("hide ref number"))t.bShownRefnum=!1;else if(-1!==n.indexOf("select displayed set"))t.hAtoms=s.hashUtilsCls.cloneHash(t.viewSelectionAtoms),t.hlUpdateCls.updateHlAll();else if(-1!==n.indexOf("select prop")){let e,s,n=i.split(" | "),l=n[0].substr("select prop".length+1);if(2==n.length){let t=n[1].split("_");e=t[0],s=t[1]}t.resid2specCls.selectProperty(l,e,s)}else if(-1!==n.indexOf("select each residue"))t.selectionCls.saveEachResiInSel();else if(0==n.indexOf("select")&&-1!==n.indexOf("name")){let e=i.split(" | "),s="",n="",l="";for(let t=0,i=e.length;t1&&(n=e[1].substr(e[1].indexOf(" ")+1)),e.length>2&&(l=e[2].substr(e[2].indexOf(" ")+1)),-1!==s.indexOf(" or ")?await t.selByCommCls.selectByCommand(s,n,l):await t.selByCommCls.selectBySpec(s,n,l)}s.htmlCls.clickMenuCls.setLogCmd(i,!1),t.bAddCommands=!0}setStrengthPara(e){let t=this.icn3d;if(t.icn3dui,e.length>=5){let s=e[4].split(" ");s.length>=4&&($("#"+t.pre+"hbondthreshold").val(s[1]),$("#"+t.pre+"saltbridgethreshold").val(s[2]),$("#"+t.pre+"contactthreshold").val(s[3]),s.length>=7&&($("#"+t.pre+"halogenthreshold").val(s[4]),$("#"+t.pre+"picationthreshold").val(s[5]),$("#"+t.pre+"pistackingthreshold").val(s[6])))}if(6==e.length){let s=e[5].split(" ");s.length>=6&&($("#"+t.pre+"dist_ss").val(s[0]),$("#"+t.pre+"dist_coil").val(s[1]),$("#"+t.pre+"dist_hbond").val(s[2]),$("#"+t.pre+"dist_inter").val(s[3]),$("#"+t.pre+"dist_ssbond").val(s[4]),$("#"+t.pre+"dist_ionic").val(s[5]),9==s.length&&($("#"+t.pre+"dist_halogen").val(s[6]),$("#"+t.pre+"dist_pication").val(s[7]),$("#"+t.pre+"dist_pistacking").val(s[8])))}}getThresholdNameArrays(e){this.icn3d.icn3dui.htmlCls.clickMenuCls.SetChainsAdvancedMenu();let t,s=e.split(" | "),i=parseFloat(s[0].substr(s[0].lastIndexOf(" ")+1)),n=[],l=[];if(s.length>=2&&s[1].length>4){let e=s[1].split(" ");e.length>1&&(l=e[1].split(",")),e.length>2&&(n=e[2].split(","))}else l=["selected"],n=["non-selected"];return 3==s.length&&(t="true"==s[2]),{threshold:i,nameArray2:l,nameArray:n,bHbondCalc:t}}setQueryresi2score(e){let t=this.icn3d,s=t.icn3dui,i=e[1],n=e[2].split(" ")[1].split("_"),l=e[3];void 0===t.queryresi2score&&(t.queryresi2score={}),t.queryresi2score[i]={};for(let e=parseInt(n[0]),s=0;e<=parseInt(n[1]);++e,++s)"_"!=l[s]&&(t.queryresi2score[i][e]=11.11111111111111*parseInt(l[s]));if(e.length>4){let i=e[4].split(" ");t.startColor=i[1],t.midColor=i[2],t.endColor=i[3];let n=s.htmlCls.clickMenuCls.setLegendHtml();$("#"+s.pre+"dl_legend_html").html(n),s.htmlCls.dialogCls.openDlg("dl_legend","Color Range")}}addShape(e,t){let s=this.icn3d,i=s.icn3dui;s.shapeCmdHash[e]=1;let n=e.split(" | "),l=n[1].split(" "),r=n[2].substr(n[2].lastIndexOf(" ")+1),o=n[3].substr(n[3].lastIndexOf(" ")+1),a=n[4].substr(n[4].lastIndexOf(" ")+1);r="#"+r.replace(/\#/g,"");let d=i.parasCls.thr(r),c=new THREE.Vector3(parseFloat(l[1]),parseFloat(l[3]),parseFloat(l[5]));"sphere"==t?s.sphereCls.createSphereBase(c,d,parseFloat(a),void 0,void 0,void 0,parseFloat(o)):s.boxCls.createBox_base(c,parseFloat(a),d,void 0,void 0,void 0,parseFloat(o))}getMenuFromCmd(e){this.icn3d.icn3dui;let t="Windows > View Sequences & Annotations",s="Analysis > Interactions",i=s+" > 2D Graph(Force-Directed)",n="View > Rotate > Auto Rotation > Rotate ",l="View > Rotate > Rotate 90 deg > ",r="Select > Select on 3D > ",o="Analysis > Label > ",a="File > 3D Printing > ";return 0==(e=e.trim()).indexOf("load")?"File > Retrieve by ID, Align":0==e.indexOf("set map")&&-1==e.indexOf("set map wireframe")?"Style > Electron Density":0==e.indexOf("set emmap")&&-1==e.indexOf("set emmap wireframe")?"Style > EM Density Map":0==e.indexOf("set phi")?"Analysis > Load Potential > URL(CORS) Phi/Cube":0==e.indexOf("set delphi")?"Analysis > DelPhi Potential":0==e.indexOf("setoption map")?"Style > Remove Map":0==e.indexOf("setoption emmap")?"Style > Remove EM Map":0==e.indexOf("view annotations")?t:0==e.indexOf("set annotation all")?t+': "All" checkbox':0==e.indexOf("set annotation clinvar")?t+': "ClinVar" checkbox':0==e.indexOf("set annotation snp")?t+': "SNP" checkbox':0==e.indexOf("set annotation 3ddomain")?t+': "3D Domains" checkbox':0==e.indexOf("view interactions")?"Windows > View 2D Diagram":0==e.indexOf("symmetry")?"Analysis > Symmetry":0==e.indexOf("realign on seq align")?"File > Realign Selection > on Sequence Alignment":0==e.indexOf("realign")?"File > Realign Selection > Residue by Residue":0==e.indexOf("graph interaction pairs")?s+" > 2D Graph(Force-Directed)":0==e.indexOf("export canvas")?"File > Save File > iCn3D PNG Image":"export stl file"==e?a+"STL":"export vrml file"==e?a+"VRML(Color)":"export stl stabilizer file"==e?a+"STL W/ Stabilizers":"export vrml stabilizer file"==e?a+"VRML(Color, W/ Stabilizers)":"select all"==e?'Select > All; or Toggle to "All"(next to "Help")':"show all"==e?"View > View Full Structure":"select complement"==e?"Select > Inverse":"set pk atom"==e?r+"Atom":"set pk residue"==e?r+"Residue":"set pk strand"==e?r+"Strand/Helix":"set pk domain"==e?r+"3D Domain":"set pk chain"==e?r+"Chain":"set surface wireframe on"==e?"Style > Surface Wireframe > Yes":"set surface wireframe off"==e?"Style > Surface Wireframe > No":"set map wireframe on"==e?"Style > Map Wireframe > Yes":"set map wireframe off"==e?"Style > Map Wireframe > No":"set emmap wireframe on"==e?"Style > EM Map Wireframe > Yes":"set emmap wireframe off"==e?"Style > EM Map Wireframe > No":"set surface neighbors on"==e?"Style > Surface Type > ... with Context":"set axis on"==e?"View > XYZ-axes > Show":"set axis off"==e?"View > XYZ-axes > Hide":"set fog on"==e?"View > Fog for Selection > On":"set fog off"==e?"View > Fog for Selection > Off":"set slab on"==e?"View > Slab for Selection > On":"set slab off"==e?"View > Slab for Selection > Off":"set assembly on"==e?"Analysis > Assembly > Biological Assembly":"set assembly off"==e?"Analysis > Assembly > Asymmetric Unit":"set chemicalbinding show"==e?"Analysis > Chem. Binding > Show":"set chemicalbinding hide"==e?"Analysis > Chem. Binding > Hide":"set hbonds off"==e||"set salt bridge off"==e||"set contact off"==e||"set halogen pi off"==e?s+" > Reset":"hydrogens"==e?"Style > Hydrogens > Show":"set hydrogens off"==e?"Style > Hydrogens > Hide":"set stabilizer off"==e?"File > 3D Printing > Remove All Stabilizers":"set disulfide bonds off"==e?"Analysis > Disulfide Bonds > Hide":"set cross linkage off"==e?"Analysis > Cross-Linkages > Hide":"set lines off"==e?"Analysis > Distance > Hide":"set labels off"==e?"Analysis > Label > Remove":"set mode all"==e?'Toggle to "All"(next to "Help")':"set mode selection"==e?'Toggle to "Selection"(next to "Help")':"set view detailed view"==e?t+': "Details" tab':"set view overview"==e?t+': "Summary" tab':"set annotation custom"==e?t+': "Custom" checkbox':"set annotation interaction"==e?t+': "Interactions" checkbox':"set annotation ptm"==e?t+': "PTM" checkbox':"set annotation cdd"==e?t+': "Conserved Domains" checkbox':"set annotation site"==e?t+': "Functional Sites" checkbox':"set annotation ssbond"==e?t+': "Disulfide Bonds" checkbox':"set annotation crosslink"==e?t+': "Cross-Linkages" checkbox':"set annotation transmembrane"==e?t+': "Transmembrane" checkbox':"highlight level up"==e?"Keyboard Arrow Up":"highlight level down"==e?"Keyboard Arrow Down":0==e.indexOf("hide annotation")?t+": checkboxes off":"add residue labels"==e?o+"per Residue":"add residue number labels"==e?o+"per Residue & Number":"add atom labels"==e?o+"per Atom":"add chain labels"==e?o+"per Chain":"add terminal labels"==e?o+"N- & C- Termini":"rotate left"==e?n+"Left; or Key l":"rotate right"==e?n+"Right; or Key j":"rotate up"==e?n+"Up; or Key i":"rotate down"==e?n+"Down; or Key m":"rotate x"==e?l+"X-axis":"rotate y"==e?l+"Y-axis":"rotate z"==e?l+"Z-axis":"reset"==e?"View > Reset > All":"reset orientation"==e?"View > Reset > Orientation":"clear selection"==e?"Select > Clear Selection":"zoom selection"==e?"Select > Zoom in Selection":"center selection"==e?"Select > Center Selection":"show selection"==e?"Select > View Only Selection":"hide selection"==e?"Select > Hide Selection":"output selection"==e?"Select > Clear Selection":"toggle highlight"==e?"Select > Toggle Highlight":"stabilizer"==e?"File > 3D Printing > Add all Stabilizers":"disulfide bonds"==e?"Analysis > Disulfide Bonds > Show":"cross linkage"==e?"Analysis > Cross-Linkages > Show":"back"==e?"View > Undo":"forward"==e?"View > Redo":"clear all"==e?"Select > Clear Selection":"defined sets"==e?"Windows > Defined Sets":"delete selected sets"==e?'Windows > Defined Sets: "Delete Selected Sets" button':"view interactions"==e?"Windows > View Interactions":"show annotations all chains"==e?t+': "Show All Chains" button':"save color"==e?"Color > Save Color":"apply saved color"==e?"Color > Apply Saved Color":"save style"==e?"Style > Save Style":"apply saved style"==e?"Style > Apply Saved Style":"select main chains"==e?"Select > Main Chains":"select side chains"==e?"Select > Side Chains":"select main side chains"==e?"Select > Main & Side Chains":"area"==e?"View > Surface Area":"table inter count only"==e?s+': "Set 1" button: "Show Count Only" button':"table inter details"==e?s+': "Set 1" button: "Show Details" button':0==e.indexOf("define helix sets")?t+': "Helix Sets" button':0==e.indexOf("define sheet sets")?t+': "Sheet Sets" button':0==e.indexOf("define coil sets")?t+': "Coil Sets" button':0==e.indexOf("select interaction")?"Windows > View 2D Diagram: click on edges":0==e.indexOf("select saved atoms")||0==e.indexOf("select sets")?"Windows > Defined Sets: select in menu":-1!==e.indexOf("select chain")?t+": click on chain names":-1!==e.indexOf("select alignChain")?"Windows > View Aligned Sequences: click on chain names":0==e.indexOf("select zone cutoff")?"Select > by Distance":0==e.indexOf("set surface opacity")?"Style > Surface Opacity":0==e.indexOf("set label scale")?"View > Label Scale":0==e.indexOf("set surface")?"Style > Surface Type":0==e.indexOf("set camera")?"View > Camera":0==e.indexOf("set background")?"Style > Background":0==e.indexOf("set thickness")?"File > 3D Printing > Set Thickness":0==e.indexOf("set highlight color")?"Select > Highlight Color":0==e.indexOf("set highlight style")?"Select > Highlight Style":0==e.indexOf("add line")||0==e.indexOf("add label")?"Analysis > Distance > between Two Atoms":0==e.indexOf("dist")?"Analysis > Distance > between Two Sets":0==e.indexOf("msa")?t+': "Add Track" button: "FASTA Alignment" button':0==e.indexOf("add track")?t+': "Add Track" button':0==e.indexOf("remove one stabilizer")?"File > 3D Printing > Remove One Stablizer":0==e.indexOf("add one stabilizer")?"File > 3D Printing > Add One Stablizer":0==e.indexOf("select planes z-axis")?"View > Select between Two X-Y Planes":0==e.indexOf("adjust membrane z-axis")?"View > Adjust Membrane":0==e.indexOf("toggle membrane")?"View > Toggle Membrane":0==e.indexOf("calc buried surface")?s+': "Buried Surface Area" button':0==e.indexOf("display interaction 3d")?s+': "3D Display Interactions" button':0==e.indexOf("view interaction pairs")?s+': "Highlight Interactions in Table" button':0==e.indexOf("save1 interaction pairs")?s+': "Set 1" button':0==e.indexOf("save2 interaction pairs")?s+': "Set 2" button':0==e.indexOf("line graph interaction pairs")?s+': "2D Interaction Network" button':0==e.indexOf("scatterplot interaction pairs")?s+': "2D Interaction Map" button':0==e.indexOf("graph label")?i+': "Label Size" menu':0==e.indexOf("graph force")?i+': "Force on Nodes" menu':0==e.indexOf("hide edges")?i+': "Internal Edges" menu':0==e.indexOf("reset interaction pairs")?s+" > Reset":0==e.indexOf("side by side")?"View > Side by Side":0==e.indexOf("your note")?"Windows > Your Notes / Window Title":0==e.indexOf("pickatom")?"Hold Alt key and click on 3D structure":0==e.indexOf("color")?"Color menu":0==e.indexOf("custom tube")?t+': "Custom Color/Tube" button: "Custom Tube" button':0==e.indexOf("style")?"Style menu":-1!==e.indexOf("select displayed set")?"Select > Displayed Set":-1!==e.indexOf("select prop")?"Select > by Property":0==e.indexOf("select")&&-1!==e.indexOf("name")?t+": drag on residues to select":-1!==e.indexOf("select $")||-1!==e.indexOf("select .")||-1!==e.indexOf("select :")||-1!==e.indexOf("select @")?"Select > Advanced; or other selection":-1!==e.indexOf("replay on")?"File > Replay Each Step > On":-1!==e.indexOf("replay off")?"File > Replay Each Step > Off":-1!==e.indexOf("set theme")?"Style > Theme Color":-1!==e.indexOf("set double color")?"Style > Two-color Helix":""}}class ps{constructor(e){this.icn3d=e}setProtNuclLigInMenu(){let e=this.icn3d;if(e.icn3dui,Object.keys(e.proteins).length>0&&(e.defNames2Residues.proteins=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.proteins)),e.defNames2Descr.proteins="proteins",e.defNames2Command.proteins="select :proteins"),Object.keys(e.nucleotides).length>0&&(e.defNames2Residues.nucleotides=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.nucleotides)),e.defNames2Descr.nucleotides="nucleotides",e.defNames2Command.nucleotides="select :nucleotides"),Object.keys(e.chemicals).length>0)if(e.bOpm){let t={},s={};for(let i in e.chemicals){let n=e.atoms[i],l=n.structure+"_"+n.chain+"_"+n.resi;"DUM"===n.resn?s[l]=1:t[l]=1}Object.keys(t).length>0&&(e.defNames2Residues.chemicals=Object.keys(t),e.defNames2Descr.chemicals="chemicals",e.defNames2Command.chemicals="select :chemicals"),Object.keys(s).length>0&&(e.defNames2Residues.membrane=Object.keys(s),e.defNames2Descr.membrane="membrane",e.defNames2Command.membrane="select :membrane")}else e.defNames2Residues.chemicals=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.chemicals)),e.defNames2Descr.chemicals="chemicals",e.defNames2Command.chemicals="select :chemicals";Object.keys(e.ions).length>0&&(e.defNames2Residues.ions=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.ions)),e.defNames2Descr.ions="ions",e.defNames2Command.ions="select :ions"),Object.keys(e.water).length>0&&(e.defNames2Residues.water=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.water)),e.defNames2Descr.water="water",e.defNames2Command.water="select :water"),this.setTransmemInMenu(e.halfBilayerSize,-e.halfBilayerSize)}setPredefinedInMenu(){let e=this.icn3d,t=e.icn3dui;if(this.setChainsInMenu(),this.setProtNuclLigInMenu(),void 0!==t.cfg.mmdbid||void 0!==t.cfg.gi||void 0!==t.cfg.chainalign||void 0!==t.cfg.mmdbafid)for(let t in e.tddomains)e.selectionCls.selectResidueList(e.tddomains[t],t,t,!1,!1);if((void 0!==t.cfg.align||void 0!==t.cfg.chainalign&&2==e.chainidArray.length)&&e.bFullUi){e.selectionCls.selectResidueList(e.consHash1,e.conservedName1,e.conservedName1,!1,!1),e.selectionCls.selectResidueList(e.consHash2,e.conservedName2,e.conservedName2,!1,!1),e.selectionCls.selectResidueList(e.nconsHash1,e.nonConservedName1,e.nonConservedName1,!1,!1),e.selectionCls.selectResidueList(e.nconsHash2,e.nonConservedName2,e.nonConservedName2,!1,!1),e.selectionCls.selectResidueList(e.nalignHash1,e.notAlignedName1,e.notAlignedName1,!1,!1),e.selectionCls.selectResidueList(e.nalignHash2,e.notAlignedName2,e.notAlignedName2,!1,!1);let s={};for(let i in e.alnChains)s=t.hashUtilsCls.unionHash(s,e.alnChains[i]);let i=e.firstAtomObjCls.getResiduesFromAtoms(s),n="protein_aligned",l="aligned protein and nucleotides",r="select "+e.resid2specCls.residueids2spec(Object.keys(i));e.selectionCls.addCustomSelection(Object.keys(i),n,l,r,!0)}}setAtomMenu(e){let t=this.icn3d;t.icn3dui;let s="",i=void 0!==t.defNames2Residues?Object.keys(t.defNames2Residues):[],n=void 0!==t.defNames2Atoms?Object.keys(t.defNames2Atoms):[],l=i.concat(n).sort(),r=[];l.forEach((e=>{-1===$.inArray(e,r)&&r.push(e)}));for(let i=0,n=r.length;i0&&(n=t.atoms[e[0]])}else if(void 0!==t.defNames2Residues&&t.defNames2Residues.hasOwnProperty(o)){let e=t.defNames2Residues[o];e.length>0&&(l=t.residues[e[0]],l&&(n=t.atoms[Object.keys(l)[0]]))}let a=void 0===n||void 0===n.color||"FFFFFF"===n.color.getHexString().toUpperCase()?"DDDDDD":n.color.getHexString(),d=void 0!==n&&void 0!==n.color?a:"000000";-1!=e.indexOf(o)?s+="":s+=""}return s}setChainsInMenu(){let e=this.icn3d;e.icn3dui;for(let t in e.chains)if(e.chainsSeq[t]&&e.chainsSeq[t].length>1){e.defNames2Residues[t]=Object.keys(e.firstAtomObjCls.getResiduesFromAtoms(e.chains[t])),e.defNames2Descr[t]=t;let s=t.indexOf("_"),i=t.substr(0,s),n=t.substr(s+1);e.defNames2Command[t]="select $"+i+"."+n}if(1==Object.keys(e.structures)){let t=Object.keys(e.structures)[0];e.defNames2Residues[t]=Object.keys(e.residues),e.defNames2Descr[t]=t,e.defNames2Command[t]="select $"+t}else{let t=Object.keys(e.residues),s={};for(let e=0,i=t.length;ee?l[a]=1:o.coord.z0&&(i.defNames2Residues["transmembrane"+o]=Object.keys(n),i.defNames2Descr["transmembrane"+o]="transmembrane"+o,i.defNames2Command["transmembrane"+o]="select :transmembrane"+o),Object.keys(l).length>0&&(i.defNames2Residues["extracellular"+o]=Object.keys(l),i.defNames2Descr["extracellular"+o]="extracellular"+o,i.defNames2Command["extracellular"+o]="select :extracellular"+o),Object.keys(r).length>0&&(i.defNames2Residues["intracellular"+o]=Object.keys(r),i.defNames2Descr["intracellular"+o]="intracellular"+o,i.defNames2Command["intracellular"+o]="select :intracellular"+o)}}showSets(){let e=this.icn3d,t=e.icn3dui;t.bNode||(t.htmlCls.dialogCls.openDlg("dl_definedsets","Select sets"),$("#"+e.pre+"dl_setsmenu").show(),$("#"+e.pre+"dl_setoperations").show(),$("#"+e.pre+"dl_command").hide(),$("#"+e.pre+"atomsCustom").resizable());let s=t.hashUtilsCls.cloneHash(e.hAtoms),i=t.hashUtilsCls.cloneHash(e.dAtoms);void 0!==e.bSetChainsAdvancedMenu&&e.bSetChainsAdvancedMenu&&!e.bResetSets||(this.setPredefinedInMenu(),e.bSetChainsAdvancedMenu=!0),e.hAtoms=t.hashUtilsCls.cloneHash(s),e.dAtoms=t.hashUtilsCls.cloneHash(i),e.hlUpdateCls.updateHlMenus()}clickCustomAtoms(){let e=this.icn3d,t=e.icn3dui,s=this;$("#"+e.pre+"atomsCustom").change((function(e){let i=s.icn3d,n=$(this).val();if(i.nameArray=n,null!==n){let e=!1;s.changeCustomAtoms(n,e),t.htmlCls.clickMenuCls.setLogCmd("select sets "+n.join(" "+i.setOperation+" "),!0),i.bSelectResidue=!1}})),t.myEventCls.onIds("#"+e.pre+"atomsCustom","focus",(function(e){let i=s.icn3d;t.utilsCls.isMobile()&&$("#"+i.pre+"atomsCustom").val("")}))}deleteSelectedSets(){let e=this.icn3d;e.icn3dui;let t=$("#"+e.pre+"atomsCustom").val();for(let s=0;s0)for(let n=0,l=t.defNames2Residues[e].length;n0)for(let s=0,n=t.defNames2Atoms[e].length;s0&&(n[0]=i.commands[0]);let l=e.trim().split("\n");i.commands=l;let r=l[0].indexOf("command=");if(t&&-1!=r){let e=l[0].substr(0,r-1);i.commands.splice(0,1,e)}i.STATENUMBER=i.commands.length,i.commands=n.concat(i.commands),i.STATENUMBER=i.commands.length,i.CURRENTNUMBER=0,i.bReplay?await this.replayFirstStep(i.CURRENTNUMBER):await this.execCommands(i.CURRENTNUMBER,i.STATENUMBER-1,i.STATENUMBER,s)}async execCommands(e,t,s,i){let n=this.icn3d;n.icn3dui,n.bRender=!1,i||n.reinitAfterLoad(),await this.execCommandsBase(e,t,s)}getNameArray(e){let t=this.icn3d;t.icn3dui;let s=e.split(" | "),i=[];return 2==s.length&&(i=s[1].split(","),t.hAtoms=t.definedSetsCls.getAtomsFromNameArray(i)),i}async execCommandsBase(e,t,s,i){let n,l=this.icn3d,r=l.icn3dui,o=this;for(n=e;n<=t;++n){let i=n===s-1;if(!l.commands[n].trim())continue;if(0==(l.atoms?Object.keys(l.atoms).length:0)&&-1==l.commands[n].indexOf("load"))continue;let a=l.commands[n].split("|||"),d=a[0].trim();if(-1!==d.indexOf("load")){if(0===t&&e===t)return void(l.bNotLoadStructure?(l.hAtoms=r.hashUtilsCls.cloneHash(l.atoms),1===l.commands.length&&(l.bAddCommands=!0),i&&this.renderFinalStep(s)):(await o.applyCommandLoad(l.commands[n]),1===l.commands.length&&(l.bAddCommands=!0),i&&o.renderFinalStep(s)));l.bNotLoadStructure?(l.hAtoms=r.hashUtilsCls.cloneHash(l.atoms),l.backForward&&this.renderFinalStep(1)):(await o.applyCommandLoad(l.commands[n]),l.backForward&&o.renderFinalStep(1))}else if(0==d.indexOf("set map")&&-1==d.indexOf("set map wireframe"))await o.applyCommandMap(a[0].trim());else if(0==d.indexOf("set emmap")&&-1==d.indexOf("set emmap wireframe")){let e=a[0].trim().substr(10).split(" ");2==e.length&&"percentage"==e[0]&&(e[1],await o.applyCommandEmmap(a[0].trim()))}else if(0==d.indexOf("set phi"))await l.delphiCls.applyCommandPhi(a[0].trim());else if(0==d.indexOf("set delphi"))await l.delphiCls.applyCommandDelphi(a[0].trim());else if(0==d.indexOf("view annotations"))Object.keys(l.proteins).length>0&&await o.applyCommandAnnotationsAndCddSite(a[0].trim());else if(0==d.indexOf("set annotation clinvar"))Object.keys(l.proteins).length>0&&await o.applyCommandClinvar(a[0].trim());else if(0==d.indexOf("set annotation snp"))Object.keys(l.proteins).length>0&&await o.applyCommandSnp(a[0].trim());else if(0==d.indexOf("set annotation ptm"))Object.keys(l.proteins).length>0&&await o.applyCommandPTM(a[0].trim());else if(0==d.indexOf("ig refnum on"))await l.refnumCls.showIgRefNum();else if(0==d.indexOf("ig template")){let e=d.substr(d.lastIndexOf(" ")+1);await l.refnumCls.showIgRefNum(e)}else if(0==d.indexOf("set annotation 3ddomain"))Object.keys(l.proteins).length>0&&o.applyCommand3ddomain(a[0].trim());else if(0==d.indexOf("set annotation all"))Object.keys(l.proteins).length>0&&(await o.applyCommandClinvar(a[0].trim()),await o.applyCommandSnp(a[0].trim()),o.applyCommand3ddomain(a[0].trim())),await l.annotationCls.setAnnoTabAll();else if(0==d.indexOf("view interactions")&&void 0!==r.cfg.align)await o.applyCommandViewinteraction(a[0].trim());else if(0==d.indexOf("symmetry")){l.bAxisOnly=!1;let e=d.substr(d.indexOf(" ")+1);l.symmetrytitle="none"===e?void 0:e,"none"!==e&&await l.symdCls.retrieveSymmetry(Object.keys(l.structures)[0]),l.drawCls.draw()}else if(0==d.indexOf("symd symmetry"))l.bAxisOnly=!1,await l.symdCls.applyCommandSymd(d),l.drawCls.draw();else if(0==d.indexOf("scap"))await l.scapCls.applyCommandScap(d);else if(0==d.indexOf("realign on seq align"))this.getNameArray(d),await o.applyCommandRealign(d);else if(0==d.indexOf("realign on structure align msa")){let e=this.getNameArray(d);r.cfg.aligntool="vast",await l.realignParserCls.realignOnStructAlignMsa(e)}else if(0==d.indexOf("realign on structure align"))this.getNameArray(d),r.cfg.aligntool="vast",await l.realignParserCls.realignOnStructAlign();else if(0==d.indexOf("realign on tmalign msa")){let e=this.getNameArray(d);r.cfg.aligntool="tmalign",await l.realignParserCls.realignOnStructAlignMsa(e)}else if(0==d.indexOf("realign on tmalign"))this.getNameArray(d),r.cfg.aligntool="tmalign",await l.realignParserCls.realignOnStructAlign();else if(0==d.indexOf("realign on vastplus"))o.getHAtoms(l.commands[n]),await l.vastplusCls.realignOnVastplus();else if(0==d.indexOf("graph interaction pairs"))await o.applyCommandGraphinteraction(d);else if(0==d.indexOf("cartoon 2d domain"))await o.applyCommandCartoon2d(d);else if(0==d.indexOf("set half pae map"))await o.applyCommandAfmap(d);else if(0==d.indexOf("set full pae map"))await o.applyCommandAfmap(d,!0);else if(0==d.indexOf("export pqr"))await r.htmlCls.setHtmlCls.exportPqr();else if(0==d.indexOf("cartoon 2d chain")||0==d.indexOf("cartoon 2d secondary")){let e=d.lastIndexOf(" "),t=d.substr(e+1);await l.cartoon2dCls.draw2Dcartoon(t)}else if(0==d.indexOf("add msa track")){let e=d.split(" | "),t=e[1].substr(8),s=e[2].substr(9),i=e[3].substr(5),n=e[4].substr(10);$("#"+l.pre+"anno_custom")[0]&&($("#"+l.pre+"anno_custom")[0].checked=!0),$("[id^="+l.pre+"custom]").show(),await l.addTrackCls.addMsaTracks(t,s,i,n)}else if(0==d.indexOf("add exon track")){let e=d.split(" | "),t=e[1].substr(8),s=e[2].substr(7),i=e[3].substr(9),n=e[4].substr(5);$("#"+l.pre+"anno_custom")[0]&&($("#"+l.pre+"anno_custom")[0].checked=!0),$("[id^="+l.pre+"custom]").show(),await l.addTrackCls.addExonTracks(t,s,i,n)}else await l.applyCommandCls.applyCommand(l.commands[n])}(n===s||i)&&this.renderFinalStep(n)}pressCommandtext(){let e=this.icn3d,t=e.icn3dui,s=this;$("#"+e.pre+"logtext").keypress((async function(e){let i=s.icn3d;if(i.bAddLogs=!1,13==(e.keyCode?e.keyCode:e.which)){e.preventDefault();let n=$(this).val();i.bRender=!0;let l=n.split("\n"),r=i.logs.length;for(let e=r,n=l.length;e "+i.logs.join("\n> ")+"\n> ").scrollTop($("#"+i.pre+"logtext")[0].scrollHeight)}i.bAddLogs=!0}))}async applyCommandLoad(e){let t=this.icn3d,s=t.icn3dui;t.bAddCommands=!1;let i=e.split("|||")[0].replace(/\s\s/g," ").trim();if(-1!==i.indexOf("load")){let e=i.split(" | "),n=e[0];if(e.length>1){let t=e[e.length-1].indexOf(" ");s.cfg.inpara=e[e.length-1].substr(t+1),"undefined"===s.cfg.inpara&&(s.cfg.inpara="")}let l=n.substr(n.lastIndexOf(" ")+1);if(4==l.length&&(l=l.toUpperCase()),t.bInputPNGWithData||t.structures&&t.structures.hasOwnProperty(l))return;if(t.inputid=l,-1!==i.indexOf("load mmtf"))s.cfg.mmtfid=l,await t.mmtfParserCls.downloadMmtf(l);else if(-1!==i.indexOf("load pdb"))s.cfg.pdbid=l,await t.pdbParserCls.downloadPdb(l);else if(-1!==i.indexOf("load af"))s.cfg.afid=l,await t.pdbParserCls.downloadPdb(l,!0);else if(-1!==i.indexOf("load opm"))s.cfg.opmid=l,await t.opmParserCls.downloadOpm(l);else if(-1!==i.indexOf("load mmcif"))s.cfg.mmcifid=l,await t.mmcifParserCls.downloadMmcif(l);else if(-1!==i.indexOf("load mmdb ")||-1!==i.indexOf("load mmdb1 "))s.cfg.mmdbid=l,s.cfg.bu=1,await t.mmdbParserCls.downloadMmdb(l);else if(-1!==i.indexOf("load mmdb0"))s.cfg.mmdbid=l,s.cfg.bu=0,await t.mmdbParserCls.downloadMmdb(l);else if(-1!==i.indexOf("load mmdbaf1"))s.cfg.mmdbafid=l,s.cfg.bu=1,await t.chainalignParserCls.downloadMmdbAf(l);else if(-1!==i.indexOf("load mmdbaf0"))s.cfg.mmdbafid=l,s.cfg.bu=0,await t.chainalignParserCls.downloadMmdbAf(l);else if(-1!==i.indexOf("load gi"))s.cfg.gi=l,await t.mmdbParserCls.downloadGi(l);else if(-1!==i.indexOf("load refseq"))s.cfg.refseqid=l,await t.mmdbParserCls.downloadRefseq(l);else if(-1!==i.indexOf("load protein"))s.cfg.protein=l,await t.mmdbParserCls.downloadProteinname(l);else if(-1!==i.indexOf("load seq_struct_ids "))t.bSmithwm=!1,t.bLocalSmithwm=!1,await t.mmdbParserCls.downloadBlast_rep_id(l);else if(-1!==i.indexOf("load seq_struct_ids_smithwm "))t.bSmithwm=!0,await t.mmdbParserCls.downloadBlast_rep_id(l);else if(-1!==i.indexOf("load seq_struct_ids_local_smithwm "))t.bLocalSmithwm=!0,await t.mmdbParserCls.downloadBlast_rep_id(l);else if(-1!==i.indexOf("load cid"))s.cfg.cid=l,await t.sdfParserCls.downloadCid(l);else if(-1!==i.indexOf("load alignment"))if(s.cfg.align=l,s.cfg.inpara||-1==s.cfg.inpara.indexOf("atype=2"))await t.alignParserCls.downloadAlignment(s.cfg.align);else{let e=2;await t.chainalignParserCls.downloadMmdbAf(s.cfg.align,void 0,e)}else if(-1!==i.indexOf("load chainalignment")){let e=i.split(" | ");e.length>1&&-1!=e[1].indexOf("resnum")&&(s.cfg.resnum=e[1].substr(e[1].indexOf("resnum")+7)),e.length>2&&-1!=e[2].indexOf("resdef")&&(s.cfg.resdef=e[2].substr(e[1].indexOf("resdef")+7)),e.length>3&&-1!=e[3].indexOf("aligntool")&&(s.cfg.aligntool=e[3].substr(e[1].indexOf("aligntool")+10)),s.cfg.chainalign=l,await t.chainalignParserCls.downloadChainalignment(l,s.cfg.resnum,s.cfg.resdef)}else if(-1!==i.indexOf("load url")){let i=e[1],n=void 0!==i?i.indexOf("type "):-1,r="pdb";-1!==n&&(r=i.substr(n+5)),s.cfg.url=l,await t.pdbParserCls.downloadUrl(l,r)}}t.bAddCommands=!0}async applyCommandMap(e){let t=this.icn3d;t.icn3dui;let s=e.split(" | "),i=s[0].substr(8).split(" ");if("sigma"==i[1]){let e=i[2],n=i[0],l="dsn6";if(5==i.length&&(l=i[4]),2==s.length){let i=!0;"dsn6"==l?await t.dsn6ParserCls.dsn6ParserBase(s[1],n,e,"url",i):"ccp4"==l?await t.ccp4ParserCls.ccp4ParserBase(s[1],n,e,"url",i):"mtz"==l&&await t.mtzParserCls.mtzParserBase(s[1],n,e,"url",i)}else await t.dsn6ParserCls.dsn6Parser(t.inputid,n,e)}}async applyCommandEmmap(e){let t=this.icn3d;t.icn3dui;let s=e.substr(10).split(" ");if(2==s.length&&"percentage"==s[0]){let e=s[1],i="em";await t.densityCifParserCls.densityCifParser(t.inputid,i,e,t.emd)}}async applyCommandRealign(e){let t=this.icn3d;t.icn3dui,await t.realignParserCls.realignOnSeqAlign()}async applyCommandRealignByStruct(e){let t=this.icn3d;t.icn3dui,t.drawCls.draw(),await t.realignParserCls.realignOnStructAlign()}async applyCommandAfmap(e,t){let s=this.icn3d;s.icn3dui;let i=e.substr(e.lastIndexOf(" ")+1);await s.contactMapCls.afErrorMap(i,t)}async applyCommandGraphinteraction(e){let t=this.icn3d;t.icn3dui;let s=e.split(" | ");if(s.length>=3){let e,i=s[1].split(" "),n=i[0].split(","),l=i[1].split(","),r=-1!==s[2].indexOf("hbonds"),o=-1!==s[2].indexOf("salt bridge"),a=-1!==s[2].indexOf("interactions"),d=-1!==s[2].indexOf("halogen"),c=-1!==s[2].indexOf("pi-cation"),h=-1!==s[2].indexOf("pi-stacking");s.length>=4&&(e="true"==s[3]),t.applyCommandCls.setStrengthPara(s),await t.viewInterPairsCls.viewInteractionPairs(n,l,e,"graph",r,o,a,d,c,h)}}async applyCommandCartoon2d(e){let t=this.icn3d;t.icn3dui;let s=e.substr(e.lastIndexOf(" ")+1);await t.cartoon2dCls.draw2Dcartoon(s)}async applyCommandAnnotationsAndCddSite(e){let t=this.icn3d;t.icn3dui,"view annotations"==e&&await t.showAnnoCls.showAnnotations()}async applyCommandClinvar(e){let t=this.icn3d;t.icn3dui;let s=e.lastIndexOf(" ");e.substr(s+1),await t.annotationCls.setAnnoTabClinvar()}async applyCommandSnp(e){let t=this.icn3d;t.icn3dui;let s=e.lastIndexOf(" ");e.substr(s+1),await t.annotationCls.setAnnoTabSnp()}async applyCommandPTM(e){let t=this.icn3d;t.icn3dui;let s=e.lastIndexOf(" ");e.substr(s+1),await t.annotationCls.setAnnoTabPTM()}applyCommand3ddomain(e){let t=this.icn3d;t.icn3dui;let s=e.lastIndexOf(" "),i=e.substr(s+1);"3ddomain"!=i&&"all"!=i||t.annotationCls.setAnnoTab3ddomain()}async applyCommandViewinteraction(e){let t=this.icn3d,s=t.icn3dui;if(void 0!==s.cfg.align||void 0!==s.cfg.chainalign){let e=Object.keys(t.structures);await t.ParserUtilsCls.set2DDiagramsForAlign(e[0].toUpperCase(),e[1].toUpperCase())}}async renderFinalStep(e){let t=this.icn3d,s=t.icn3dui;t.bCommandLoad=!1,t.ParserUtilsCls.hideLoading(),e+1===t.commands.length&&(t.bAddCommands=!0),t.bRender=!0;let i=t.commands[e-1]?t.commands[e-1].split("|||"):[];if(2==i.length){let e=JSON.parse(i[1]);t._zoomFactor=e.factor,t.mouseChange.x=e.mouseChange.x,t.mouseChange.y=e.mouseChange.y,t.quaternion._x=e.quaternion._x,t.quaternion._y=e.quaternion._y,t.quaternion._z=e.quaternion._z,t.quaternion._w=e.quaternion._w}if(t.selectionCls.oneStructurePerWindow(),1===e||t.hAtoms&&t.atoms&&Object.keys(t.hAtoms).length===Object.keys(t.atoms).length||void 0!==t.optsHistory[e-1]&&t.optsHistory[e-1].hasOwnProperty("hlatomcount")&&t.optsHistory[e-1].hlatomcount===Object.keys(t.atoms).length)if(t.optsHistory.length>=e){let s=t.optsHistory[e-1].pk;"no"===s?t.pk=0:"atom"===s?t.pk=1:"residue"===s?t.pk=2:"strand"===s&&(t.pk=3),t.hlUpdateCls.updateHlAll(),t.drawCls.draw()}else t.hlUpdateCls.updateHlAll(),t.drawCls.draw();else t.hlUpdateCls.updateHlAll(),t.drawCls.draw();(s.cfg.closepopup||s.cfg.imageonly)&&(setTimeout((function(){t.resizeCanvasCls.closeDialogs()}),100),t.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,s.htmlCls.HEIGHT,!0)),t.bTransparentSurface&&t.bRender&&t.drawCls.render(),s.cfg.imageonly&&t.saveFileCls.saveFile(void 0,"png",void 0,!0)}async replayFirstStep(e){let t=this.icn3d,s=t.icn3dui;t.reinitAfterLoad(),await this.execCommandsBase(e,e,t.STATENUMBER);let i=t.commands[e],n=t.commands[e].indexOf("|");-1!=n&&(i=t.commands[e].substr(0,n));let l=i.length>20?i.substr(0,20)+"...":i,r=t.applyCommandCls.getMenuFromCmd(i);$("#"+t.pre+"replay_cmd").html("Cmd: "+l),$("#"+t.pre+"replay_menu").html("Menu: "+r),s.htmlCls.clickMenuCls.setLogCmd(i,!0),t.bCommandLoad=!1,t.ParserUtilsCls.hideLoading(),t.bRender=!0,t.drawCls.draw()}getHAtoms(e){let t=this.icn3d;t.icn3dui;let s=e.split("|||")[0].trim().split(" | ");if(2==s.length){let e=s[1].split(",");t.hAtoms=t.definedSetsCls.getAtomsFromNameArray(e)}}}class us{constructor(e){this.icn3d=e}async selectByCommand(e,t,s){let i=this.icn3d,n=i.icn3dui;if(0===e.indexOf("saved atoms")){let s=12,n=e.substr(s);i.definedSetsCls.selectCombinedSets(n,t)}else{let l=e.replace(/ AND /g," and ").replace(/ OR /g," or ").replace(/ or and /g," and ").replace(/ and /g," or and ").replace(/ or not /g," not ").replace(/ not /g," or not "),r=("select"===l.trim().substr(0,6)?l.trim().substr(7):l.trim()).split(" or "),o={};for(let e=0,t=r.length;e1||1==o.length&&"*"!==o[0])&&(h=!1);let C,y,v,_,w=[],S=[];if(w="*"===t?Object.keys(l.structures):t.split(","),"*"===s){let e=Object.keys(l.chains);for(let t=0,s=e.length;t1&&"3"===x[t][0]&&isNaN(x[t][1])&&"-"!==x[t][0]){i=x[t].toUpperCase().substr(1),m=!0}else if(""===x[t]||isNaN(parseInt(x[t]))){if("*"===x[t])h=!0;else if("proteins"!==x[t]&&"nucleotides"!==x[t]&&"chemicals"!==x[t]&&"ions"!==x[t]&&"water"!==x[t]&&"anchors"!==x[t]&&"strands"!==x[t]&&"loops"!==x[t]){s=x[t].toUpperCase(),p=!0}}else v=x[t],_=v,n=!0;for(let a=0,u=S.length;a1?e.substr(0,l-1)===n.atoms[i].name.substr(0,l-1)&&(0===s?t[i]=1:t.hasOwnProperty(i)||delete t[i]):"*"!==e&&e!==n.atoms[i].name||(0===s?t[i]=1:t.hasOwnProperty(i)||delete t[i]),t}}class gs{constructor(e){this.icn3d=e}selectAll(){let e=this.icn3d;e.icn3dui,this.selectAll_base(),e.hlObjectsCls.removeHlObjects(),e.hlUpdateCls.removeHl2D(),e.hlUpdateCls.removeHlMenus(),e.bSelectResidue=!1,e.bSelectAlignResidue=!1,e.hlUpdateCls.removeSeqResidueBkgd(),e.hlUpdateCls.update2DdgmContent(),$("#"+e.pre+"dl_annotations > .icn3d-annotation").show(),e.definedSetsCls.setMode("all"),e.saveFileCls.showTitle()}selectAll_base(){let e=this.icn3d,t=e.icn3dui;e.hAtoms={},e.dAtoms={};for(let s in e.chains)e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.chains[s]);e.dAtoms=t.hashUtilsCls.cloneHash(e.hAtoms),e.viewSelectionAtoms=t.hashUtilsCls.cloneHash(e.hAtoms),e.ALTERNATE_STRUCTURE=-1}selectAChain(e,t,s,i){let n=this.icn3d,l=n.icn3dui;t=t.replace(/\s/g,"");let r=void 0!==s||s?"select alignChain "+e:"select chain "+e;void 0!==i&&i?(n.hAtoms=l.hashUtilsCls.unionHash(n.hAtoms,n.chains[e]),void 0===n.nameArray&&(n.nameArray=[])):(n.hAtoms={},n.nameArray=[]),n.nameArray.push(e);let o,a=s?n.alnChainsSeq[e]:n.chainsSeq[e];o=void 0===a?0:a.length;let d={};for(let t=0,s=o;t0){if(void 0!==i&&i?void 0===r.nameArray&&(r.nameArray=[]):(r.hAtoms={},r.nameArray=[]),l)for(let t in e)r.hAtoms[t]=1;else for(let t in e)for(let e in r.residues[t])r.hAtoms[e]=1;let o,a;t=t.replace(/\s/g,""),r.nameArray.push(t),l?(o="select "+r.resid2specCls.atoms2spec(r.hAtoms),a=!1):(o="select "+r.resid2specCls.residueids2spec(Object.keys(e)),a=!0);let d=Object.keys(e);this.addCustomSelection(d,t,s,o,a),(void 0===n||n)&&r.hlUpdateCls.updateHlAll(r.nameArray,void 0,i)}}selectMainChains(){let e=this.icn3d,t=e.icn3dui.hashUtilsCls.cloneHash(e.hAtoms);e.hAtoms=e.applyDisplayCls.selectMainChainSubset(t),e.hlUpdateCls.showHighlight()}selectSideChains(){let e=this.icn3d,t=e.icn3dui,s=t.hashUtilsCls.cloneHash(e.hAtoms);e.hAtoms={};for(let i in s)(e.proteins.hasOwnProperty(i)&&"N"!==e.atoms[i].name&&"H"!==e.atoms[i].name&&"C"!==e.atoms[i].name&&"O"!==e.atoms[i].name&&("CA"!==e.atoms[i].name||"C"!==e.atoms[i].elem)&&"HA"!==e.atoms[i].name||e.nucleotides.hasOwnProperty(i)&&-1===t.parasCls.nuclMainArray.indexOf(e.atoms[i].name))&&(e.hAtoms[i]=1);e.hlUpdateCls.showHighlight()}selectMainSideChains(){let e=this.icn3d,t=e.icn3dui,s=e.firstAtomObjCls.getResiduesFromAtoms(e.hAtoms);e.hAtoms={};for(let i in s)e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.residues[i]),e.dAtoms=t.hashUtilsCls.unionHash(e.dAtoms,e.residues[i]);e.drawCls.draw(),e.hlUpdateCls.showHighlight()}clickShow_selected(){let e=this.icn3d,t=e.icn3dui,s=this;t.myEventCls.onIds(["#"+e.pre+"show_selected","#"+e.pre+"mn2_show_selected"],"click",(function(e){s.icn3d,s.showSelection(),t.htmlCls.clickMenuCls.setLogCmd("show selection",!0)}))}clickHide_selected(){let e=this.icn3d,t=e.icn3dui,s=this;t.myEventCls.onIds("#"+e.pre+"mn2_hide_selected","click",(function(e){s.icn3d,s.hideSelection(),t.htmlCls.clickMenuCls.setLogCmd("hide selection",!0)}))}getGraphDataForDisplayed(){let e=this.icn3d;e.icn3dui;let t=JSON.parse(e.graphStr),s=e.firstAtomObjCls.getResiduesFromAtoms(e.dAtoms),i=[],n=[],l={};for(let e=0,n=t.nodes.length;e0)if(1==s.pk){let n=!0;this.selectResidueList(s.hAtoms,e,t,void 0,void 0,n),this.updateSelectionNameDesc(),i.htmlCls.clickMenuCls.setLogCmd("select "+s.resid2specCls.atoms2spec(s.hAtoms)+" | name "+e,!0)}else this.selectResidueList(s.selectedResidues,e,t),this.updateSelectionNameDesc(),i.htmlCls.clickMenuCls.setLogCmd("select "+s.resid2specCls.residueids2spec(Object.keys(s.selectedResidues))+" | name "+e,!0)}saveSelInCommand(){let e=this.icn3d,t=e.icn3dui;e.selectedResidues=e.firstAtomObjCls.getResiduesFromCalphaAtoms(e.hAtoms),t.htmlCls.clickMenuCls.setLogCmd("select "+e.resid2specCls.residueids2spec(Object.keys(e.selectedResidues)),!0)}saveEachResiInSel(){let e=this.icn3d;e.icn3dui,e.selectionCls.saveSelectionPrep(),e.selectedResidues={},e.selectedResidues=e.firstAtomObjCls.getResiduesFromCalphaAtoms(e.hAtoms);for(let t in e.selectedResidues){let s={};s[t]=1;let i=t+"_"+e.selectedResidues[t];this.selectResidueList(s,i,i)}}removeSelection(){let e=this.icn3d;e.icn3dui,e.bAnnotations||e.hlUpdateCls.removeSeqChainBkgd(),e.bCtrl||e.bShift||(e.hlUpdateCls.removeSeqResidueBkgd(),e.hlUpdateCls.removeSeqChainBkgd()),e.selectedResidues={},e.bSelectResidue=!1,e.hAtoms={},e.hlObjectsCls.removeHlObjects(),e.hlUpdateCls.removeHl2D()}resetAll(){let e=this.icn3d,t=e.icn3dui;e.maxD=e.oriMaxD,e.center=e.oriCenter.clone(),e.opts=t.hashUtilsCls.cloneHash(e.optsOri),e.setOptionCls.setStyle("sidec","nothing"),e.reinitAfterLoad(),e.definedSetsCls.setMode("all"),e.selectionCls.selectAll(),t.htmlCls.clickMenuCls.setLogCmd("reset",!0),e.hlUpdateCls.removeSeqChainBkgd(),e.hlUpdateCls.removeSeqResidueBkgd(),e.hlUpdateCls.removeHl2D(),e.hlUpdateCls.removeHlMenus(),e.loadScriptCls.renderFinalStep(1)}async loadSelection(e){let t=this.icn3d,s=t.icn3dui,i=e.trim().split("\n");for(let e=0,n=i.length;e=t&&l.coord.z<=e)){i[l.structure+"_"+l.chain+"_"+l.resi]=1}}let n="z_planes_"+e+"_"+t,l=n;this.selectResidueList(i,n,l,!1)}}class fs{constructor(e){this.icn3d=e}residueids2spec(e){var t=this.icn3d;t.icn3dui;let s="";if(void 0!==e){let i,n,l,r,o,a,d,c=e.sort((function(e,t){if(""!==e&&!isNaN(e))return parseInt(e)-parseInt(t);{let s=e.lastIndexOf("_"),i=t.lastIndexOf("_");if(e.substr(0,s)t.substr(0,i))return 1;if(e.substr(0,s)==t.substr(0,i)){if(parseInt(e.substr(s+1))parseInt(t.substr(i+1)))return 1;if(parseInt(e.substr(s+1))==parseInt(t.substr(i+1)))return 0}}})),h="",p=0,m=1!=Object.keys(t.structures).length;for(let e=0,u=c.length;e0&&(s+=p===d?m?"$"+o+"."+a+":"+d+" or ":"."+a+":"+d+" or ":m?"$"+o+"."+a+":"+d+"-"+p+" or ":"."+a+":"+d+"-"+p+" or "),d=n;else if(h===i){let e=t.ParserUtilsCls.getResiNCBI(h,p);t.ParserUtilsCls.getResiNCBI(i,n)!=e+1&&(s+=p===d?m?"$"+o+"."+a+":"+d+" or ":"."+a+":"+d+" or ":m?"$"+o+"."+a+":"+d+"-"+p+" or ":"."+a+":"+d+"-"+p+" or ",d=n)}h=i,p=n}}r=h.indexOf("_"),o=h.substr(0,r),a=h.substr(r+1),s+=p===d?m?"$"+o+"."+a+":"+d:"."+a+":"+d:m?"$"+o+"."+a+":"+d+"-"+p:"."+a+":"+d+"-"+p}return s}atoms2spec(e){var t=this.icn3d;t.icn3dui;let s,i="",n=0,l={},r={},o={};for(let a in e)s=t.atoms[a],n>0&&(i+=" or "),i+="$"+s.structure+"."+s.chain+":"+s.resi+"@"+s.name,l[s.structure]=1,r[s.structure+"_"+s.chain]=1,o[s.structure+"_"+s.chain+"_"+s.resi]=1,++n;if(1==Object.keys(o).length){let e="\\$"+s.structure+"\\."+s.chain+":"+s.resi;i=i.replace(new RegExp(e,"g"),"")}else if(1==Object.keys(r).length){let e="\\$"+s.structure+"\\."+s.chain;i=i.replace(new RegExp(e,"g"),"")}else if(1==Object.keys(l).length){let e="\\$"+s.structure;i=i.replace(new RegExp(e,"g"),"")}return i}atoms2residues(e){var t=this.icn3d;t.icn3dui;let s={};for(let t=0,i=e.length;t=parseInt(t)&&e.b<=parseInt(s)&&(i.hAtoms=n.hashUtilsCls.unionHash(i.hAtoms,i.residues[e.structure+"_"+e.chain+"_"+e.resi]))}}else if("percent out"==e){i.bCalcArea=!0,i.opts.surface="solvent accessible surface",i.applyMapCls.applySurfaceOptions(),i.bCalcArea=!1,i.hAtoms={};for(let e in i.resid2area){let l=e.lastIndexOf("_"),r=e.substr(l+1);if(n.parasCls.residueArea.hasOwnProperty(r)){let o=parseInt(i.resid2area[e]/n.parasCls.residueArea[r]*100);if(o>=t&&o<=s){let t=e.substr(0,l);i.hAtoms=n.hashUtilsCls.unionHash(i.hAtoms,i.residues[t])}}}}i.hAtoms=n.hashUtilsCls.intHash(i.hAtoms,l),i.drawCls.draw(),i.hlUpdateCls.updateHlAll()}selectComplement(){let e=this.icn3d,t=e.icn3dui,s={};for(let t in e.atoms)e.hAtoms.hasOwnProperty(t)||(s[t]=1);e.hAtoms=t.hashUtilsCls.cloneHash(s),e.hlUpdateCls.updateHlAll()}switchHighlightLevel(){var e=this.icn3d.icn3dui;if(e.bNode)return;let t=this;document.addEventListener("keydown",(function(s){let i=t.icn3d;38===s.keyCode?(s.preventDefault(),0!=Object.keys(i.pickedAtomList).length&&i.hAtoms.hasOwnProperty(i.firstAtomObjCls.getFirstAtomObj(i.pickedAtomList).serial)||(i.pickedAtomList=e.hashUtilsCls.cloneHash(i.hAtoms)),t.switchHighlightLevelUp(),e.htmlCls.clickMenuCls.setLogCmd("highlight level up",!0)):40===s.keyCode&&(s.preventDefault(),0!=Object.keys(i.pickedAtomList).length&&i.hAtoms.hasOwnProperty(i.firstAtomObjCls.getFirstAtomObj(i.pickedAtomList).serial)||(i.pickedAtomList=e.hashUtilsCls.cloneHash(i.hAtoms)),t.switchHighlightLevelDown(),e.htmlCls.clickMenuCls.setLogCmd("highlight level down",!0))}))}switchHighlightLevelUp(){var e=this.icn3d,t=e.icn3dui;if(!t.bNode){if(e.bShift||e.bCtrl||e.hlObjectsCls.removeHlObjects(),void 0!==e.pickedAtomList&&0!==Object.keys(e.pickedAtomList).length||(e.pickedAtomList=t.hashUtilsCls.cloneHash(e.hAtoms)),0===Object.keys(e.pickedAtomList).length&&(e.pickedAtomList=e.dAtoms),1===e.highlightlevel){e.highlightlevel=2;let s=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);e.bShift||e.bCtrl?e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.residues[s.structure+"_"+s.chain+"_"+s.resi]):e.hAtoms=t.hashUtilsCls.cloneHash(e.residues[s.structure+"_"+s.chain+"_"+s.resi])}else if(2===e.highlightlevel){e.highlightlevel=3;let s=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);e.bShift||e.bCtrl?e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.pickingCls.selectStrandHelixFromAtom(s)):e.hAtoms=t.hashUtilsCls.cloneHash(e.pickingCls.selectStrandHelixFromAtom(s))}else if(3===e.highlightlevel){let s;if(void 0!==t.cfg.mmdbid||void 0!==t.cfg.gi){e.highlightlevel=4;let i=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);s=e.pickingCls.select3ddomainFromAtom(i),e.bShift||e.bCtrl?e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,s):e.hAtoms=t.hashUtilsCls.cloneHash(s)}if(void 0===t.cfg.mmdbid&&void 0===t.cfg.gi||0==Object.keys(s).length){e.highlightlevel=5;let s=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);e.bShift||e.bCtrl?e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.chains[s.structure+"_"+s.chain]):e.hAtoms=t.hashUtilsCls.cloneHash(e.chains[s.structure+"_"+s.chain])}}else if(4===e.highlightlevel){e.highlightlevel=5;let s=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);e.bShift||e.bCtrl?e.hAtoms=t.hashUtilsCls.unionHash(e.hAtoms,e.chains[s.structure+"_"+s.chain]):e.hAtoms=t.hashUtilsCls.cloneHash(e.chains[s.structure+"_"+s.chain])}else if(5===e.highlightlevel||6===e.highlightlevel){e.highlightlevel=6;let s=e.firstAtomObjCls.getFirstAtomObj(e.pickedAtomList);e.bShift||e.bCtrl||(e.hAtoms={});let i=e.structures[s.structure];for(let s=0,n=i.length;s3e4)return void(e?console.log("The maximum number of allowed atoms is 30,000. Please try it again with selected chains..."):alert("The maximum number of allowed atoms is 30,000. Please try it again with selected chains..."));let o="";return o+=s.cfg.cid?t.saveFileCls.getAtomPDB(n,!0,void 0,void 0,void 0,void 0,true):t.saveFileCls.getAtomPDB(n,void 0,void 0,void 0,void 0,void 0,true),o+=t.saveFileCls.getAtomPDB(i,!0,void 0,!0),o}async CalcPhi(e,t,s,i,n){let l=this.icn3d;l.icn3dui;let r=await this.CalcPhiPrms(e,t,s,i,n);this.loadPhiData(r,s,i),l.bAjaxPhi=!0,i?l.setOptionCls.setOption("phisurface","phi"):l.setOptionCls.setOption("phimap","phi")}CalcPhiPrms(e,t,s,i,n){let l=this.icn3d,r=l.icn3dui;l.loadPhiFrom="delphi";let o=r.htmlCls.baseUrl+"delphi/delphi.cgi",a=r.cfg.cid?r.cfg.cid:Object.keys(l.structures).toString(),d={};if(n)d={pqr2phi:n,gsize:e,salt:t,pdbid:a};else{let s=this.getPdbStr();d={pdb2phi:s,gsize:e,salt:t,pdbid:a}}return new Promise((function(e,t){$.ajax({url:o,type:"POST",data:d,dataType:"binary",responseType:"arraybuffer",cache:!0,beforeSend:function(){l.ParserUtilsCls.showLoading()},complete:function(){l.ParserUtilsCls.hideLoading()},success:function(t){e(t)},error:function(e,t,s){}})}))}async PhiParser(e,t,s,i){let n,l=this.icn3d,r=l.icn3dui,o=this;n="phiurl"==t||"phiurl2"==t?"arraybuffer":"text";let a=await r.getXMLHttpRqstPromise(e,"GET",n,"potential");"phiurl"==t||"phiurl2"==t?o.loadPhiData(a,s,i):o.loadCubeData(a,s,i),l.bAjaxPhi=!0,i?l.setOptionCls.setOption("phisurface","phi"):l.setOptionCls.setOption("phimap","phi")}loadPhiData(e,t,s){let i=this.icn3d;i.icn3dui;let n={filetype:"phi"},l=e.buffer&&e.buffer instanceof ArrayBuffer?e.buffer:e,r=new Float32Array(l.slice(l.byteLength-24,l.byteLength-8));n.scale=r[0];let o=r[1],a=r[2],d=r[3];n.n=new Int32Array(l.slice(l.byteLength-8,l.byteLength-4)),n.xExtent=n.yExtent=n.zExtent=n.n;let c=1/n.scale*((n.n-1)/2);n.ori=new THREE.Vector3(o-c,a-c,d-c);let h=new Float32Array(l.slice(110,l.byteLength-56));n.bSurface=s,i.mapData.headerPhi=n,i.mapData.dataPhi=h,i.mapData.contourPhi=t;let p=new THREE.Matrix4;p.identity(),p.multiply((new THREE.Matrix4).makeTranslation(n.ori.x,n.ori.y,n.ori.z)),i.mapData.matrixPhi=p}loadCubeData(e,t,s){let i=this.icn3d;i.icn3dui;let n={filetype:"cube"},l=e.split("\n"),r=[];r.push(parseFloat(l[0].substr(0,10))),r.push(parseFloat(l[0].substr(10,6))),r.push(parseFloat(l[0].substr(16,10))),r.push(parseFloat(l[0].substr(26,10))),r.push(parseFloat(l[0].substr(36,10))),n.scale=r[0];let o=r[2],a=r[3],d=r[4];n.n=r[1],n.xExtent=n.yExtent=n.zExtent=n.n;let c=1/n.scale*((n.n-1)/2);n.ori=new THREE.Vector3(o-c,a-c,d-c);let h=[];for(let e=7,t=l.length;e1e4)return void alert("The maximum number of allowed atoms is 10,000. Please try it again with smaller sets...");let o="";o+=e.saveFileCls.getAtomPDB(n);let a,d={pdb:o,pdbid:Object.keys(e.structures).toString()};try{a=await t.getAjaxPostPromise(i,d,!0);let n,l,o,c=a.rcsb_struct_symmetry,h="none";if(void 0!==c){let i;void 0!==e.rmsd_supr&&void 0!==e.rmsd_supr.rot&&(n=e.rmsd_supr.rot,l=e.rmsd_supr.trans1,o=e.rmsd_supr.trans2),void 0===e.symdArray&&(e.symdArray=[]);for(let t=0,n=c.length;tThe selected residues have no detected symmetry with a Z score of "+a.zscore+" from the program SymD."),t.htmlCls.dialogCls.openDlg("dl_symd","Dynamically Calculated Symmetry Using SymD");else{let n=a.seqalign.replace(/ /g,"").split(","),l=a.nres,o=a.shift,d=a.rmsd,h=Object.keys(r),p={},m={},u=[],g=[],f=0,b=0,C={};for(let e=0,s=n[0].length;et&&(t=C[s].length,e=s);let s=Object.keys(p),i=Object.keys(m);for(let t=0,n=C[e].length;tSymD. The Z score "+a.zscore+" is greater than the threshold Z score 8. The RMSD is "+d+' angstrom.

    The following sequence alignment shows the residue mapping of the best aligned sets: "symOri" and "symPerm", which are also available in the menu "Analysis > Defined Sets".
    ',$("#"+e.pre+"symd_info").html(A),s.setSeqAlignForSymmetry(_,w,S);let x=!1,k=t.htmlCls.alignSeqCls.getAlignSequencesAnnotations(Object.keys(e.alnChains),void 0,void 0,x,S);A=$("#"+e.pre+"dl_sequence2").html()+k.sequencesHtml,$("#"+e.pre+"dl_sequence2").html(A),$("#"+e.pre+"dl_sequence2").width(t.htmlCls.RESIDUE_WIDTH*k.maxSeqCnt+200),t.htmlCls.dialogCls.openDlg("dl_alignment","Select residues in aligned sequences from SymD");let O=Object.keys(e.defNames2Residues).length+Object.keys(e.defNames2Atoms).length,R="symOri"+O;e.selectionCls.selectResidueList(y,R,R),e.selectionCls.updateSelectionNameDesc(),t.htmlCls.clickMenuCls.setLogCmd("select "+e.resid2specCls.residueids2spec(Object.keys(y))+" | name "+R,!1),R="symPerm"+O,e.selectionCls.selectResidueList(v,R,R),e.selectionCls.updateSelectionNameDesc(),t.htmlCls.clickMenuCls.setLogCmd("select "+e.resid2specCls.residueids2spec(Object.keys(v))+" | name "+R,!1),R="symBoth"+O,y=t.hashUtilsCls.unionHash(y,v),e.selectionCls.selectResidueList(y,R,R),e.selectionCls.updateSelectionNameDesc(),t.htmlCls.clickMenuCls.setLogCmd("select "+e.resid2specCls.residueids2spec(Object.keys(y))+" | name "+R,!1)}}else $("#"+e.pre+"dl_symd").html("
    The selected residues have no detected symmetry with a Z score of "+a.zscore+" from the program SymD."),t.htmlCls.dialogCls.openDlg("dl_symd","Dynamically Calculated Symmetry Using SymD");e.symdtitle="none"===h?void 0:h,e.drawCls.draw()}catch(s){return $("#"+e.pre+"dl_symd").html("
    The web service can not determine the symmetry of the input set."),t.htmlCls.dialogCls.openDlg("dl_symd","Dynamically Calculated Symmetry Using SymD"),void e.ParserUtilsCls.hideLoading()}}getResObj(e){this.icn3d.icn3dui;let t=e.substr(0,e.indexOf(" ")),s=e.indexOf("$"),i=e.indexOf("."),n=e.indexOf(":"),l=e.substr(s+1,i-s-1),r=e.substr(i+1,n-i-1),o=e.substr(n+1);return{resn:t,resid:l+"_"+r+"_"+o,resi:o,aligned:!0}}setSeqAlignForSymmetry(e,t,s){let i=this.icn3d,n=i.icn3dui;i.conservedName1="symOri_cons",i.conservedName2="symPerm_cons",i.consHash1={},i.consHash2={},i.alnChainsAnTtl={},i.alnChainsAnno={},i.alnChainsSeq={},i.alnChains={},i.alnChainsSeq={};let l={};for(let r=0,o=e.length;rThis structure has no symmetry."),void i.htmlCls.dialogCls.openDlg("dl_symmetry","Symmetry")}let r,o,a,d=t.rcsb_struct_symmetry;if(void 0!==d){void 0!==s.rmsd_supr&&void 0!==s.rmsd_supr.rot&&(r=s.rmsd_supr.rot,o=s.rmsd_supr.trans1,a=s.rmsd_supr.trans2),s.symmetryHash={};for(let e=0,t=d.length;eThis structure has no symmetry.");else{let e="",t=0;for(let i in s.symmetryHash){e+="",++t}$("#"+s.pre+"selectSymmetry").html(e)}}else $("#"+s.pre+"dl_symmetry").html("
    This structure has no symmetry.");i.htmlCls.dialogCls.openDlg("dl_symmetry","Symmetry")}getPolygonColor(e){let t=this.icn3d.icn3dui,s=e.substr(0,1);return"C"==s?t.parasCls.thr(16747520):"D"==s?t.parasCls.thr(65535):"T"==s?t.parasCls.thr(15631086):"O"==s?t.parasCls.thr(16753920):"I"==s?t.parasCls.thr(65280):t.parasCls.thr(11119017)}getAxisColor(e,t){let s=this.icn3d.icn3dui,i=e.substr(0,1);return"C"==i?s.parasCls.thr(16711680):"D"==i?2==t?s.parasCls.thr(65535):s.parasCls.thr(16711680):"T"==i?2==t?s.parasCls.thr(65535):s.parasCls.thr(65280):"O"==i||"I"==i?2==t?s.parasCls.thr(65535):3==t?s.parasCls.thr(65280):s.parasCls.thr(16711680):s.parasCls.thr(16711680)}}class ws{constructor(e){this.icn3d=e}alignSW(e,t,s,i,n,l,r){this.icn3d.icn3dui;let o=this.bsa_align(r,e,t,[s,i],[n,l]),a="score: "+o[0]+"\n";a+="start: "+o[1]+"\n",a+="cigar: "+this.bsa_cigar2str(o[2])+"\n\n",a+="alignment:\n\n";let d=this.bsa_cigar2gaps(e,t,o[1],o[2]),c={};return c.score=o[0],c.start=o[1],c.cigar=this.bsa_cigar2str(o[2]),c.target=d[0],c.query=d[1],c}bsg_enc_seq(e,t){if(this.icn3d.icn3dui,null==t)return null;let s=[];s.length=e.length;for(let i=0;i0&&(s=-s),i=0;i=2&&"number"==typeof t[0]&&"number"==typeof t[1]){if(null==s)return null;let e="number"==typeof s?s:s[s.length-1]+1;i=this.bsa_gen_score_matrix(e,t[0],t[1])}else i=t;for(let e=0;eo.length?d:o.length;l=null==l||l<0?c:l;let h,p,m=o.target>d?o.target-d:d-o.target;l=l>m?l:m,"number"==typeof n?(h=0,p=n>0?n:-n):(h=n[0]>0?n[0]:-n[0],p=n[1]>0?n[1]:-n[1]);let u,g=h+p,f=-1073741824,b=[],C=[],y=[],v=0,_=-1,w=-1;if(e)for(let e=0;e<=d;++e)b[e]=C[e]=0;else{b[0]=0,C[0]=-g-g;for(let e=1;e<=d;++e)e>=l?b[e]=C[e]=f:(b[e]=-(g+p*(e-1)),C[e]=-(g+g+p*e))}for(let t=0;tl?t-l:0,u=t+l+10?f:-(g+p*t),n=m>0?f:-(g+g+p*t));for(let t=m;t=o?0:1,a=a>=o?a:o,l=a>=n?l:2,a=a>=n?a:n,l=!e||a>0?l:64,i=a,c=r>a?c:t,r=r>a?r:a,a-=g,a=!e||a>0?a:0,o-=p,l|=o>a?4:0,o=o>a?o:a,C[t]=o,n-=p,l|=n>a?32:0,n=n>a?n:a,s[t]=l}b[u]=i,C[u]=e?0:f,r>v&&(v=r,_=t,w=c)}if(e&&0==v)return null;u=e?v:b[d];let S,A,x,k=[],O=0,R=0;for(e?(A=_,x=w,w!=d-1&&this.push_cigar(k,4,d-1-w)):(A=o.length-1,x=(A+l+1=0&&x>=0&&(S=y[A][x-(A>l?A-l:0)],O=S>>(O<<1)&3,!(0==O&&S>>6));)0==O&&(O=3&S),0==O?(this.push_cigar(k,0,1),--A,--x):1==O?(this.push_cigar(k,2,1),--A):(this.push_cigar(k,1,1),--x);e?(x>=0&&this.push_cigar(k,4,x+1),R=A+1):(A>=0&&this.push_cigar(k,2,A+1),x>=0&&this.push_cigar(k,1,x+1));for(let e=0;e>1;++e)S=k[e],k[e]=k[k.length-1-e],k[k.length-1-e]=S;return[u,R,k]}push_cigar(e,t,s){this.icn3d.icn3dui,0==e.length||t!=(15&e[e.length-1])?e.push(s<<4|t):e[e.length-1]+=s<<4}bsa_cigar2gaps(e,t,s,i){this.icn3d.icn3dui;let n="",l="",r="",o=0,a=s;for(let s=0;s>4;0==r?(n+=t.substr(o,d),l+=e.substr(a,d),o+=d,a+=d):1==r?(n+=t.substr(o,d),l+=Array(d+1).join("-"),o+=d):2==r?(n+=Array(d+1).join("-"),l+=e.substr(a,d),a+=d):4==r&&(o+=d)}let d=l.toUpperCase(),c=n.toUpperCase();for(let e=0;e>4).toString()+"MIDNSHP=XB".charAt(15&e[s]));return t.join("")}}class Ss{constructor(e){this.icn3d=e}calculateArea(){var e=this.icn3d,t=e.icn3dui;e.bCalcArea=!0,e.opts.surface="solvent accessible surface",e.applyMapCls.applySurfaceOptions(),$("#"+e.pre+"areavalue").val(e.areavalue),$("#"+e.pre+"areatable").html(e.areahtml),t.htmlCls.dialogCls.openDlg("dl_area","Surface area calculation"),e.bCalcArea=!1}calcBuriedSurface(e,t){var s=this.icn3d,i=s.icn3dui;if(0==e.length)alert("Please select the first set");else{let n=i.hashUtilsCls.cloneHash(s.hAtoms),l=s.definedSetsCls.getAtomsFromNameArray(e),r=s.definedSetsCls.getAtomsFromNameArray(t);s.bCalcArea=!0,s.opts.surface="solvent accessible surface",s.hAtoms=i.hashUtilsCls.cloneHash(l),s.applyMapCls.applySurfaceOptions();let o=s.areavalue,a=i.hashUtilsCls.cloneHash(s.resid2area);s.hAtoms=i.hashUtilsCls.cloneHash(r),s.applyMapCls.applySurfaceOptions();let d=s.areavalue,c=i.hashUtilsCls.cloneHash(s.resid2area);s.hAtoms=i.hashUtilsCls.unionHash(s.hAtoms,l),s.applyMapCls.applySurfaceOptions();let h=s.areavalue,p=i.hashUtilsCls.cloneHash(s.resid2area),m=0,u=0,g=0,f=0;for(let e in a)p.hasOwnProperty(e)&&(f+=parseFloat(p[e]));u=(o-f).toFixed(2);for(let e in c)p.hasOwnProperty(e)&&(g+=parseFloat(p[e]));m=(d-g).toFixed(2),s.bCalcArea=!1,s.hAtoms=i.hashUtilsCls.cloneHash(n);let b=(parseFloat(d)+parseFloat(o)-parseFloat(h)).toFixed(2),C="
    Calculate solvent accessible surface area in the interface:

    ";C+="Set 1: "+e+", Surface: "+o+" Å2
    ",C+="Set 2: "+t+", Surface: "+d+" Å2
    ",C+="Total Surface: "+h+" Å2
    ",C+="Buried Surface for Set 1: "+u+" Å2
    ",C+="Buried Surface for Set 2: "+m+" Å2

    ",$("#"+s.pre+"dl_buriedarea_html").html(C),i.htmlCls.dialogCls.openDlg("dl_buriedarea","Buried solvent accessible surface area in the interface"),i.htmlCls.clickMenuCls.setLogCmd("buried surface "+b,!1)}}measureDistTwoSets(e,t){var s=this.icn3d,i=s.icn3dui;if(0==e.length||0==t.length)alert("Please select two sets");else{let n=i.hashUtilsCls.cloneHash(s.hAtoms),l=s.definedSetsCls.getAtomsFromNameArray(e),r=s.definedSetsCls.getAtomsFromNameArray(t),o=s.contactCls.getExtent(l),a=s.contactCls.getExtent(r),d=new THREE.Vector3(o[2][0],o[2][1],o[2][2]),c=new THREE.Vector3(a[2][0],a[2][1],a[2][2]);s.hAtoms=i.hashUtilsCls.cloneHash(n),void 0===s.distPnts&&(s.distPnts=[]),s.distPnts.push(d),s.distPnts.push(c);let h=$("#"+s.pre+"distancecolor2").val();this.addLine(d.x,d.y,d.z,c.x,c.y,c.z,h,!0,"distance");let p=0,m=0,u=d.clone().add(c).multiplyScalar(.5),g=(parseInt(10*d.distanceTo(c))/10).toString()+" A";this.addLabel(g,u.x,u.y,u.z,p,h,m,"distance"),s.drawCls.draw()}}measureDistManySets(e,t){var s=this.icn3d,i=s.icn3dui;if(0==e.length||0==t.length)alert("Please select sets for distance calculation...");else{let n=i.hashUtilsCls.cloneHash(s.hAtoms),l={};for(let i=0,n=e.length;i"+t[e]+" (Å)"}r+="";for(let s=0,i=e.length;s"+i+" (Å)";for(let e=0,s=t.length;e'+l[i][s]+"":r+="0"}r+=""}r+="

    ",$("#"+i.pre+"dl_disttable_html").html(r)}}addLine(e,t,s,i,n,l,r,o,a,d,c){var h=this.icn3d;h.icn3dui;let p={};p.position1=new THREE.Vector3(e,t,s),p.position2=new THREE.Vector3(i,n,l),p.color=r,p.dashed=o,p.radius=d,p.opacity=c,void 0===h.lines[a]&&(h.lines[a]=[]),void 0!==a?h.lines[a].push(p):(void 0===h.lines.custom&&(h.lines.custom=[]),h.lines.custom.push(p)),h.hlObjectsCls.removeHlObjects()}addLineFromPicking(e){var t=this.icn3d,s=t.icn3dui;let i=$("#"+t.pre+e+"color").val();t.pAtom.coord.x,t.pAtom2.coord.x,t.pAtom.coord.y,t.pAtom2.coord.y,t.pAtom.coord.z,t.pAtom2.coord.z;let n="stabilizer"!=e;s.htmlCls.clickMenuCls.setLogCmd("add line | x1 "+t.pAtom.coord.x.toPrecision(4)+" y1 "+t.pAtom.coord.y.toPrecision(4)+" z1 "+t.pAtom.coord.z.toPrecision(4)+" | x2 "+t.pAtom2.coord.x.toPrecision(4)+" y2 "+t.pAtom2.coord.y.toPrecision(4)+" z2 "+t.pAtom2.coord.z.toPrecision(4)+" | color "+i+" | dashed "+n+" | type "+e,!0),this.addLine(t.pAtom.coord.x,t.pAtom.coord.y,t.pAtom.coord.z,t.pAtom2.coord.x,t.pAtom2.coord.y,t.pAtom2.coord.z,i,n,e),t.pickpair=!1}addLabel(e,t,s,i,n,l,r,o){var a=this.icn3d;a.icn3dui;let d={};"0"!==n&&""!==n&&"undefined"!==n||(n=void 0),"0"!==l&&""!==l&&"undefined"!==l||(l=void 0),"0"!==r&&""!==r&&"undefined"!==r||(r=void 0);let c=new THREE.Vector3;c.x=t,c.y=s,c.z=i,d.position=c,d.text=e,d.size=n,d.color=l,d.background=r,void 0===a.labels[o]&&(a.labels[o]=[]),void 0!==o?a.labels[o].push(d):(void 0===a.labels.custom&&(a.labels.custom=[]),a.labels.custom.push(d)),a.hlObjectsCls.removeHlObjects()}addChainLabels(e){var t=this.icn3d;let s=t.icn3dui.hashUtilsCls.intHash(t.hAtoms,e);void 0===t.labels.chain&&(t.labels.chain=[]);let i=t.firstAtomObjCls.getChainsFromAtoms(s);for(let e in i){let s={};s.position=t.applyCenterCls.centerAtoms(t.chains[e]).center;let i=e.indexOf("_"),n=e.substr(i+1),l=t.showSeqCls.getProteinName(e);l.length>20&&(l=l.substr(0,20)+"..."),s.text="Chain "+n+": "+l,s.size=18,t.firstAtomObjCls.getFirstCalphaAtomObj(t.chains[e]).color.getHexString().toUpperCase(),s.color="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd,s.background="#FFFFFF",t.labels.chain.push(s)}t.hlObjectsCls.removeHlObjects()}addTerminiLabels(e){var t=this.icn3d,s=t.icn3dui;let i,n="#FFFFFF";i=s.hashUtilsCls.unionHash(i,t.proteins),i=s.hashUtilsCls.unionHash(i,t.nucleotides);let l=s.hashUtilsCls.intHash(t.dAtoms,i),r=s.hashUtilsCls.intHash(l,e);void 0===t.labels.chain&&(t.labels.chain=[]);let o=t.firstAtomObjCls.getChainsFromAtoms(r);for(let e in o){let i=s.hashUtilsCls.intHash(l,t.chains[e]),r=Object.keys(i),o=t.atoms[r[0]],a=t.atoms[r[r.length-1]],d={},c={};d.position=o.coord,c.position=a.coord,d.text="N-",c.text="C-",t.nucleotides.hasOwnProperty(o.serial)&&(d.text="5'",c.text="3'"),d.size=18,c.size=18,o.color.getHexString().toUpperCase(),a.color.getHexString().toUpperCase(),d.color="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd,c.color="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd,d.background=n,c.background=n,t.labels.chain.push(d),t.labels.chain.push(c)}t.hlObjectsCls.removeHlObjects()}}class As{constructor(e){this.icn3d=e}draw2Ddgm(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=.667,o={},a={},d={},c={},h={};if(void 0===e)return"";for(let s in e.moleculeInfor){let i="#"+("000000"+e.moleculeInfor[s].color.toString(16)).slice(-6),l=e.moleculeInfor[s].chain.trim();void 0===h[l]?h[l]=1:++h[l];let r=t+"_"+(1===h[l]?l:l+h[l].toString());void 0!==n.mmdbid_q&&(n.mmdbid_q,n.mmdbid_t),o[s]=r,a[s]=i,d[s]=e.moleculeInfor[s].name,c[r]=s}if(void 0===i||!i)for(let s=0,i=e.intracResidues.length;s";p+=""+t.toUpperCase()+"
    ",p+="";let m={},u=[],g="",f="",b={};if(i)for(let e in n.dAtoms){let t=n.atoms[e];b[c[t.structure+"_"+t.chain]]=1}let C=Object.keys(e.moleculeInfor),y=Object.keys(e.intrac),v=[];for(let e=0,t=C.length;e0)for(let t in e.intrac){let s=e.intrac[t];for(let e=0,i=s.intrac.length;e0&&(y="#"+n.atoms[e[0]].color.getHexString().toUpperCase())}let S="";n.bInitial&&void 0!==s&&(void 0!==n.alignmolid2color&&n.alignmolid2color[s].hasOwnProperty(l)?(S=n.alignmolid2color[s][l],y="#FF0000"):y="#FFFFFF");let A=d[l],x=" ",k=" ";if(void 0!==c){let e=c.indexOf("_");k=c.substr(e+1),x=k.length>1?k.substr(0,1)+"..":k}else c="Misc";void 0===y&&(y="#FFFFFF");let O=1;if(n.bInitial&&void 0!==n.alnChains[c]){let e=0;for(let t in n.alnChains[c]){let s=n.atoms[t].color.getHexString().toUpperCase();"FF0000"!==s&&"00FF00"!==s||++e}O=1*e/Object.keys(n.chains[c]).length}if(O<.2&&(O=.2),-1===v.indexOf(l)){for(let e=0,t=h.intrac.length;e1){let s=0,i=0;for(let e=0,t=_[l].length;e",p+="Interaction of chain "+c+" with chain "+h+"",p+="",p+="",p+="Interaction of chain "+h+" with chain "+c+"",p+=""}return p+=f+g,p+="",p+="",n.html2ddgm+=p,$("#"+n.pre+"dl_2ddgm_html").html(n.html2ddgm),p}set2DdgmNote(e){let t="
    Nodes:
    ";return this.icn3d.icn3dui.utilsCls.isMac()?(t+="Protein
    ",t+="Nucleotide
    ",t+="Chemical
    ",t+="Biopolymer
    "):(t+="OProtein
    ",t+="Nucleotide
    ",t+="Chemical
    ",t+="Biopolymer
    "),t+="
    Lines:
    Interactions at 4 Å
    ",e&&(t+="Numbers in red:
    Aligned chains"),t+="

    ",t}highlightNode(e,t,s,i){let n=this.icn3d.icn3dui;i<.2&&(i=.2);if("rect"===e){$(t).attr("stroke",n.htmlCls.ORANGE),$(t).attr("stroke-width",3);let e=Number($(s).attr("x")),l=Number($(s).attr("y")),r=Number($(s).attr("width")),o=Number($(s).attr("height"));$(t).attr("x",e+r/2*(1-i)),$(t).attr("y",l+o/2*(1-i)),$(t).attr("width",r*i),$(t).attr("height",o*i)}else if("circle"===e)$(t).attr("stroke",n.htmlCls.ORANGE),$(t).attr("stroke-width",3),$(t).attr("r",Number($(s).attr("r"))*i);else if("polygon"===e){$(t).attr("stroke",n.htmlCls.ORANGE),$(t).attr("stroke-width",3);let e=Number($(s).attr("x")),l=Number($(s).attr("y")),r=Number($(s).attr("x0d")),o=Number($(s).attr("y0d")),a=Number($(s).attr("x1d")),d=Number($(s).attr("y1d")),c=Number($(s).attr("x2d")),h=Number($(s).attr("y2d")),p=Number($(s).attr("x3d")),m=Number($(s).attr("y3d"));$(t).attr("points",(e+r*i).toString()+", "+(l+o*i).toString()+", "+(e+a*i).toString()+", "+(l+d*i).toString()+", "+(e+c*i).toString()+", "+(l+h*i).toString()+", "+(e+p*i).toString()+", "+(l+m*i).toString())}}removeLineGraphSelection(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"dl_linegraph circle").attr("stroke","#000000"),$("#"+e.pre+"dl_linegraph circle").attr("stroke-width",1),$("#"+e.pre+"dl_linegraph svg line.icn3d-hlline").attr("stroke","#FFF")}removeScatterplotSelection(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"dl_scatterplot circle").attr("stroke","#000000"),$("#"+e.pre+"dl_scatterplot circle").attr("stroke-width",1),$("#"+e.pre+"dl_scatterplot rect").attr("stroke","#000000"),$("#"+e.pre+"dl_scatterplot rect").attr("stroke-width",1)}click2Ddgm(){let e=this.icn3d,t=e.icn3dui,s=this;$(document).on("click","#"+e.pre+"dl_2ddgm .icn3d-node",(function(e){let i=s.icn3d;e.stopImmediatePropagation(),Object.keys(i.hAtoms).length1)s="inter_"+e+"_"+t;else{let i=e.indexOf("_"),n=t.indexOf("_");s="inter_"+e.substr(i+1)+"_"+t.substr(n+1)}i="select the atoms in chain "+e+" interacting with chain "+t+" in a distance of 4 angstrom";let o="select interaction "+e+","+t;n.selectionCls.addCustomSelection(r,s,i,o,!0)}draw2DProtein(e,t,s,i,n,l,r,o,a,d,c){this.icn3d.icn3dui;let h=20*d,p="";return p+="Chain "+i+": "+l+"",p+="",p+="",p+=""+n+"",""!==r&&(p+=""+r+""),p+="",p}draw2DNucleotide(e,t,s,i,n,l,r,o,a,d,c){this.icn3d.icn3dui;let h=30*d,p=30*d,m="";return m+="Chain "+i+": "+l+"",m+="",m+="",m+=""+n+"",""!==r&&(m+=""+r+""),m+="",m}draw2DChemical(e,t,s,i,n,l,r,o,a,d,c,h){this.icn3d.icn3dui;let p,m,u,g,f,b,C,y,v=30*d;if(h){let s=.5*v/Math.sqrt(3),i=.5*v;p=e-s,m=t-i,u=e+3*s,g=t-i,f=e+s,b=t+i,C=e-3*s,y=t+i}else{let s=.5*v,i=.5*v;p=e-s,m=t,u=e,g=t+i,f=e+s,b=t,C=e,y=t-i}let _=p-e,w=m-t,S=u-e,A=g-t,x=f-e,k=b-t,O=C-e,R=y-t,I="";return I+="Chain "+i+": "+l+"",I+="",I+="",I+=""+n+"",""!==r&&(I+=""+r+""),I+="",I}}class xs{constructor(e){this.icn3d=e}async draw2Dcartoon(e,t){let s=this.icn3d,i=s.icn3dui,n=this;if(i.htmlCls.clickMenuCls.setLogCmd("cartoon 2d "+e,!0),s.cartoon2dType=e,t){let t=n.getCartoonSvg(e,s.graphStr);$("#"+i.svgid_ct).html(t)}else{await this.getNodesLinksForSetCartoon(e),s.graphStr=n.getCartoonData(e,s.node_link);let t=n.getCartoonSvg(e,s.graphStr);$("#"+i.svgid_ct).html(t),n.setEventsForCartoon2d(),i.htmlCls.dialogCls.openDlg("dl_2dctn","2D Cartoon")}}getCartoonSvg(e,t){let s=this.icn3d,i=s.icn3dui,n="",l="",r=JSON.parse(t);s.ctnNodeHash={};for(let t=0,i=r.nodes.length;t":"domain"==e?n+="":"secondary"==e&&(a=s.ctnNodeHash[l].x2,d=i.htmlCls.width2d-s.ctnNodeHash[l].y2,c=s.ctnNodeHash[o].x1,h=i.htmlCls.width2d-s.ctnNodeHash[o].y1,n+="");let p=l+"--"+o;n+="Interaction of "+e+" "+this.getLabelFromId(l,e)+" with "+e+" "+this.getLabelFromId(o,e)+"",n+="",s.nodeid2lineid.hasOwnProperty(l)||(s.nodeid2lineid[l]=[]),s.nodeid2lineid.hasOwnProperty(o)||(s.nodeid2lineid[o]=[]),s.nodeid2lineid[l].push(p),s.nodeid2lineid[o].push(p)}return n+=l,n}setEventsForCartoon2d(){let e=this.icn3d,t=e.icn3dui;$("#"+t.svgid_ct+" .icn3d-ctnode").draggable({start:function(e,t){let s=parseFloat(e.target.getAttribute("cx")),i=parseFloat(e.target.getAttribute("cy"));e.target.setAttribute("cx",s),e.target.setAttribute("cy",i);let n=e.target.getAttribute("ang");if(n)e.target.setAttribute("transform","rotate("+n+","+s+","+i+")");else{let t=parseFloat(e.target.getAttribute("x1")),s=parseFloat(e.target.getAttribute("y1")),i=parseFloat(e.target.getAttribute("x2")),n=parseFloat(e.target.getAttribute("y2"));e.target.setAttribute("x1",t),e.target.setAttribute("y1",s),e.target.setAttribute("x2",i),e.target.setAttribute("y2",n)}},drag:function(s,i){let n=$("#"+t.svgid_ct).offset().left,l=$("#"+t.svgid_ct).offset().top,r=s.target.getAttribute("id"),o=s.target.getAttribute("ang"),a=s.clientX-n,d=s.clientY-l,c=parseFloat(s.target.getAttribute("cx")),h=parseFloat(s.target.getAttribute("cy")),p=(a-c)/e.resizeRatioX,m=(d-h)/e.resizeRatioY,u=parseFloat($("#"+r+"_text").attr("x")),g=parseFloat($("#"+r+"_text").attr("y"));if($("#"+r+"_text").attr("x",u+p),$("#"+r+"_text").attr("y",g+m),s.target.setAttribute("cx",a),s.target.setAttribute("cy",d),o)s.target.setAttribute("transform","rotate("+o+","+a+","+d+")");else{let e=parseFloat(s.target.getAttribute("x1")),t=parseFloat(s.target.getAttribute("y1")),i=parseFloat(s.target.getAttribute("x2")),n=parseFloat(s.target.getAttribute("y2"));if(s.target.setAttribute("x1",e+p),s.target.setAttribute("y1",t+m),s.target.setAttribute("x2",i+p),s.target.setAttribute("y2",n+m),"S"==r.substr(0,1)){let e=parseFloat($("#"+r+"_box").attr("x1")),t=parseFloat($("#"+r+"_box").attr("y1")),s=parseFloat($("#"+r+"_box").attr("x2")),i=parseFloat($("#"+r+"_box").attr("y2"));$("#"+r+"_box").attr("x1",e+p),$("#"+r+"_box").attr("y1",t+m),$("#"+r+"_box").attr("x2",s+p),$("#"+r+"_box").attr("y2",i+m)}}if(e.nodeid2lineid[r])for(let t=0,s=e.nodeid2lineid[r].length;t";return u+=""+e+" "+m+"","H"==t.substr(0,1)?u+="":(u+="",u+=""),u+=""+m+"",u+="",u}drawOval(e,t,s,i,n,l,r,o,a,d){let c=this.icn3d.icn3dui,h=this.getLabelFromId(t,e);i=c.htmlCls.width2d-i,r=180-r;let p="chain"==e?"":"";return p+=""+e+" "+h+"",p+="",p+="",p+=" ",p+=" ",p+="",p+="",p+="":" from='"+a+"' to='"+d+"' />",p+=""+h+"",p+="",p}getCartoonData(e,t){let s=this.icn3d;s.icn3dui;let i,n,l=[],r=[];l=t.node;let o=[],a={},d=0;for(let e=0,t=l.length;e0?n.y=s.htmlCls.width2d-n.y:n.y=-n.y,n}async getNodesLinksForSetCartoon(e){let t,s,i,n,l,r=this.icn3d,o=r.icn3dui,a=this,d=[],c=[],h=0,p=o.htmlCls.defaultValue,m="",u="",g="",f=!1,b=!0;if("chain"==e){let e={};for(let t in r.hAtoms){let s=r.atoms[t];if("DUM"==s.chain)continue;let i=s.structure+"_"+s.chain;(r.proteins.hasOwnProperty(t)||r.nucleotides.hasOwnProperty(t))&&(e.hasOwnProperty(i)||(e[i]={}),e[i][s.serial]=s)}let t=r.contactCls.getExtent(r.atoms),s=9999,i=9999,n=-9999,a=-9999,h=-9999,p=[];for(let d in e){r.hAtom={},r.hAtoms=o.hashUtilsCls.cloneHash(r.chains[d]);let e=r.axesCls.setPc1Axes(),c=e[0],m=e[1].distanceTo(e[0]),u=e[2].distanceTo(e[0]),g=180*new THREE.Vector2(e[1].x-e[0].x,e[1].y-e[0].y).angle()/Math.PI;g>180&&(g-=180);let f=Object.keys(r.hAtoms)[0],b=r.atoms[f];l=d,c=this.projectTo2d(c);let C=c.x,y=c.y;Cn&&(n=C),ya&&(a=y);let v=.5;m=v*o.htmlCls.width2d*m/(t[1][0]-t[0][0]),u=v*o.htmlCls.width2d*u/(t[1][1]-t[0][1]),m>h&&(h=m),u>h&&(h=u),p.push({id:d,r:l,x:C,y:y,rx:m,ry:u,ang:g,c:b.color.getHexString()})}let m=h+2,u=n-s,g=a-i;for(let e=0,t=p.length;e1&&(e+="__"+S.structure),a.push(e)),g==S.chain&&f&&S.ssend){let o=this.projectTo2d(t.coord.clone()),d=o.x,g=o.y,x=this.projectTo2d(S.coord.clone()),k=x.x,O=x.y;s=.5*(d+k),i=.5*(g+O),d=.5*(s+d),g=.5*(i+g),k=.5*(s+k),O=.5*(i+O),d_&&(_=d),gw&&(w=g),k_&&(_=k),Ow&&(w=O),f=!1,b=!0,n+="-"+S.resi,l+="-"+S.resi,n+="__"+S.chain,Object.keys(r.structures).length>1&&(n+="__"+S.structure);for(let t=0,s=a.length;t0&&m==S.chain&&c.push('{"source": "'+u+'", "target": "'+n+'", "v": '+p+', "c": "'+t.color.getHexString().toUpperCase()+'"}'),A.push({id:n,r:l,ss:C,x:s,y:i,x1:d,y1:g,x2:k,y2:O,c:S.color.getHexString()}),m=S.chain,u=n,++h}}}let x=S+2,k=_-y,O=w-v;for(let e=0,t=A.length;e1&&(v+="__"+i.substr(0,i.indexOf("_")));let _=g[b],w=f[b];t.hAtoms={};for(let e=0,n=_.length;e180&&(O-=180);let R=Object.keys(t.hAtoms)[0],I=t.atoms[R];A=this.projectTo2d(A);let T=A.x,E=A.y;Tc&&(c=T),Eh&&(h=E);let P=.5;x=P*s.htmlCls.width2d*x/(o[1][0]-o[0][0]),k=P*s.htmlCls.width2d*k/(o[1][1]-o[0][1]),x>p&&(p=x),k>p&&(p=k),void 0!==C&&n.push('{"source": "'+C+'", "target": "'+v+'", "v": '+l+', "c": "'+y.color.getHexString().toUpperCase()+'"}'),m.push({id:v,from:_+"",to:w+"",x:T,y:E,rx:x,ry:k,ang:O,c:I.color.getHexString()}),C=v,y=I}}let g=p+2,f=c-a,b=h-d;for(let e=0,t=m.length;e=2?d+"_"+e[1]:Object.keys(i.chains)[0];for(let e=0,t=o.length;e0&&(void 0===i||i)&&n.drawCls.draw()}}windowResize(){let e=this.icn3d.icn3dui,t=this;e.cfg.resize&&!e.utilsCls.isMobile()&&$(window).resize((function(){let s=t.icn3d;e.utilsCls.setViewerWidthHeight(s.icn3dui);let i=e.htmlCls.WIDTH,n=e.htmlCls.HEIGHT;void 0===s||s.bFullscreen||t.resizeCanvas(i,n)}))}openFullscreen(e){this.icn3d.icn3dui.bNode||document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement||(e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen())}rotStruc(e,t){var s=this.icn3d;s.icn3dui;let i=this;if(s.bStopRotate)return!1;if(s.transformCls.rotateCount>s.transformCls.rotateCountMax)return s.transformCls.resetOrientation(),!1;if(++s.transformCls.rotateCount,t)if("left"===e)s.ROT_DIR="left";else if("right"===e)s.ROT_DIR="right";else if("up"===e)s.ROT_DIR="up";else{if("down"!==e)return!1;s.ROT_DIR="down"}if("left"===e&&"left"===s.ROT_DIR)s.transformCls.rotateLeft(1);else if("right"===e&&"right"===s.ROT_DIR)s.transformCls.rotateRight(1);else if("up"===e&&"up"===s.ROT_DIR)s.transformCls.rotateUp(1);else{if("down"!==e||"down"!==s.ROT_DIR)return!1;s.transformCls.rotateDown(1)}setTimeout((function(){i.rotStruc(e)}),100)}async back(){var e=this.icn3d;e.icn3dui,e.backForward=!0,e.STATENUMBER--,e.bAddCommands=!1,e.bAddLogs=!1,e.bNotLoadStructure=!0,e.STATENUMBER<1?e.STATENUMBER=1:await e.loadScriptCls.execCommands(0,e.STATENUMBER-1,e.STATENUMBER,!0),e.setStyleCls.adjustIcon(),e.bAddCommands=!0,e.bAddLogs=!0}async forward(){var e=this.icn3d;e.icn3dui,e.backForward=!0,e.STATENUMBER++,e.bAddCommands=!1,e.bAddLogs=!1,e.bNotLoadStructure=!0,e.STATENUMBER>e.commands.length?e.STATENUMBER=e.commands.length:await e.loadScriptCls.execCommands(0,e.STATENUMBER-1,e.STATENUMBER,!0),e.setStyleCls.adjustIcon(),e.bAddCommands=!0,e.bAddLogs=!0}async replayon(){var e=this.icn3d;e.icn3dui,e.CURRENTNUMBER=0,e.bReplay=1,$("#"+e.pre+"replay").show(),e.commands.length>0&&await e.loadScriptCls.replayFirstStep(e.CURRENTNUMBER)}async replayoff(){var e=this.icn3d;e.icn3dui,e.bReplay=0,$("#"+e.pre+"replay").hide(),++e.CURRENTNUMBER,await e.loadScriptCls.execCommands(e.CURRENTNUMBER,e.STATENUMBER-1,e.STATENUMBER)}closeDialogs(){var e=this.icn3d,t=e.icn3dui;let s=["dl_2ddgm","dl_2dctn","dl_alignment","dl_sequence2","dl_definedsets","dl_setsmenu","dl_command","dl_setoperations","dl_vast","dl_foldseek","dl_mmtfid","dl_pdbid","dl_afid","dl_opmid","dl_pdbfile","dl_pdbfile_app","dl_rescolorfile","dl_customcolor","dl_align","dl_alignaf","dl_chainalign","dl_chainalign2","dl_chainalign3","dl_mutation","dl_mol2file","dl_sdffile","dl_xyzfile","dl_afmapfile","dl_urlfile","dl_mmciffile","dl_mmcifid","dl_mmdbid","dl_mmdbafid","dl_blast_rep_id","dl_yournote","dl_proteinname","dl_refseqid","dl_cid","dl_pngimage","dl_state","dl_fixedversion","dl_selection","dl_dsn6","dl_dsn6url","dl_clr","dl_symmetry","dl_symd","dl_contact","dl_hbonds","dl_realign","dl_realignbystruct","dl_allinteracton","dl_interactionsorted","dl_linegraph","dl_linegraphcolor","dl_scatterplot","dl_scatterploitcolor","dl_contactmap","dl_alignerrormap","dl_elecmap2fofc","dl_elecmapfofc","dl_emmap","dl_aroundsphere","dl_adjustmem","dl_selectplane","dl_addlabel","dl_addlabelselection","dl_labelColor","dl_distance","dl_stabilizer","dl_disttwosets","dl_distmanysets","dl_stabilizer_rm","dl_thickness","dl_thickness2","dl_addtrack","dl_addtrack_tabs","dl_saveselection","dl_copyurl","dl_selectannotations","dl_annotations_tabs","dl_anno_view_tabs","dl_annotations","dl_graph","dl_svgcolor","dl_area","dl_colorbyarea","dl_rmsd","dl_buriedarea","dl_propbypercentout","dl_propbybfactor","dl_legend","dl_disttable"];for(let i in s){let n=s[i];t.cfg.notebook?$("#"+e.pre+n).hide():$("#"+e.pre+n).hasClass("ui-dialog-content")&&$("#"+e.pre+n).dialog("isOpen")&&$("#"+e.pre+n).dialog("close").remove()}t.cfg.notebook||this.resizeCanvas(t.htmlCls.WIDTH,t.htmlCls.HEIGHT,!0)}}class Os{constructor(e){this.icn3d=e}resetOrientation(){let e=this.icn3d;e.icn3dui;let t=!1;if(e.commands.length>0){let s=e.commands[0].split("|||");if(2==s.length){let i=JSON.parse(s[1]);e._zoomFactor=i.factor,e.mouseChange.x=i.mouseChange.x,e.mouseChange.y=i.mouseChange.y,e.quaternion._x=i.quaternion._x,e.quaternion._y=i.quaternion._y,e.quaternion._z=i.quaternion._z,e.quaternion._w=i.quaternion._w,t=!0}}t||(e._zoomFactor=1,e.mouseChange=new THREE.Vector2(0,0),e.quaternion=new THREE.Quaternion(0,0,0,1)),e.maxD=e.oriMaxD,e.center=e.oriCenter.clone(),"show"==e.ori_chemicalbinding?e.bSkipChemicalbinding=!1:"hide"==e.ori_chemicalbinding&&(e.bSkipChemicalbinding=!0)}rotateLeft(e){let t=this.icn3d,s=t.icn3dui,i=new THREE.Vector3(0,1,0),n=-e/180*Math.PI;t.bControlGl&&!s.bNode?i.applyQuaternion(window.cam.quaternion).normalize():i.applyQuaternion(t.cam.quaternion).normalize();let l=new THREE.Quaternion;l.setFromAxisAngle(i,-n);let r={};r.quaternion=l,r.update=!0,t.bControlGl&&!s.bNode?window.controls.update(r):t.controls.update(r),t.bRender&&t.drawCls.render()}rotateRight(e){let t=this.icn3d,s=t.icn3dui,i=new THREE.Vector3(0,1,0),n=e/180*Math.PI;t.bControlGl&&!s.bNode?i.applyQuaternion(window.cam.quaternion).normalize():i.applyQuaternion(t.cam.quaternion).normalize();let l=new THREE.Quaternion;l.setFromAxisAngle(i,-n);let r={};r.quaternion=l,r.update=!0,t.bControlGl&&!s.bNode?window.controls.update(r):t.controls.update(r),t.bRender&&t.drawCls.render()}rotateUp(e){this.icn3d.icn3dui,this.rotate_base(-e)}rotateDown(e){this.icn3d.icn3dui,this.rotate_base(e)}rotate_base(e){let t=this.icn3d,s=t.icn3dui,i=new THREE.Vector3(1,0,0),n=e/180*Math.PI;t.bControlGl&&!s.bNode?i.applyQuaternion(window.cam.quaternion).normalize():i.applyQuaternion(t.cam.quaternion).normalize();let l=new THREE.Quaternion;l.setFromAxisAngle(i,-n);let r={};r.quaternion=l,r.update=!0,t.bControlGl&&!s.bNode?window.controls.update(r):t.controls.update(r),t.bRender&&t.drawCls.render()}setRotation(e,t){let s=this.icn3d,i=s.icn3dui;s.bControlGl&&!i.bNode&&window.cam?e.applyQuaternion(window.cam.quaternion).normalize():s.cam&&e.applyQuaternion(s.cam.quaternion).normalize();let n=new THREE.Quaternion;n.setFromAxisAngle(e,-t);let l={};l.quaternion=n,l.update=!0,s.bControlGl&&!i.bNode&&window.controls?window.controls.update(l):s.controls&&s.controls.update(l),s.bRender&&s.drawCls.render()}translateLeft(e){this.icn3d.icn3dui,this.translate_base(-e,0)}translateRight(e){this.icn3d.icn3dui,this.translate_base(e,0)}translateUp(e){this.icn3d.icn3dui,this.translate_base(0,-e)}translateDown(e){this.icn3d.icn3dui,this.translate_base(0,e)}translate_base(e,t){let s=this.icn3d,i=s.icn3dui,n=new THREE.Vector2(0,0);n.x+=e/100,n.y+=t/100;let l={};l.mouseChange=n,l.update=!0,s.bControlGl&&!i.bNode?window.controls.update(l):s.controls.update(l),s.bRender&&s.drawCls.render()}zoominSelection(e){let t=this.icn3d,s=t.icn3dui,i={};if(i._zoomFactor=1/t._zoomFactor,i.update=!0,t.bControlGl&&!s.bNode?window.controls&&window.controls.update(i):t.controls&&t.controls.update(i),void 0===e&&(e=s.hashUtilsCls.hash2Atoms(t.hAtoms,t.atoms)),Object.keys(e).length>1){let s=t.applyCenterCls.centerAtoms(e);t.maxD=s.maxD,t.maxD<5&&(t.maxD=5),t.center=s.center,t.applyCenterCls.setCenter(t.center),t.cameraCls.setCamera()}}getTransformationStr(e){this.icn3d.icn3dui;let t={factor:1,mouseChange:{x:0,y:0},quaternion:{_x:0,_y:0,_z:0,_w:1}};return t.factor=parseFloat(e.factor).toPrecision(4),t.mouseChange.x=parseFloat(e.mouseChange.x).toPrecision(4),t.mouseChange.y=parseFloat(e.mouseChange.y).toPrecision(4),t.quaternion._x=parseFloat(e.quaternion._x).toPrecision(4),t.quaternion._y=parseFloat(e.quaternion._y).toPrecision(4),t.quaternion._z=parseFloat(e.quaternion._z).toPrecision(4),t.quaternion._w=parseFloat(e.quaternion._w).toPrecision(4),"1.0000"==t.factor&&(t.factor=1),"0.0000"==t.mouseChange.x&&(t.mouseChange.x=0),"0.0000"==t.mouseChange.y&&(t.mouseChange.y=0),"0.0000"==t.quaternion._x&&(t.quaternion._x=0),"0.0000"==t.quaternion._y&&(t.quaternion._y=0),"0.0000"==t.quaternion._z&&(t.quaternion._z=0),"1.0000"==t.quaternion._w&&(t.quaternion._w=1),JSON.stringify(t)}}class Rs{constructor(e){this.icn3d=e}saveFile(e,t,s,i){let n,l=this.icn3d,r=l.icn3dui,o=this;if("command"===t){let e=l.loadCmd?l.loadCmd+"\n":"";for(let t=0,s=l.commands.length;t4e3||0!==s.indexOf("http")||l.bInputfile&&!l.bInputUrlfile?$("#"+l.pre+"viewer").html(""):$("#"+l.pre+"viewer").html(""),$("#"+l.pre+"viewer").width(i),$("#"+l.pre+"viewer").height(n),$("#"+l.pre+"cmdlog").hide(),$("#"+l.pre+"title").hide(),$("#"+l.pre+"mnlist").hide(),$("#"+l.pre+"fullscreen").length>0&&$("#"+l.pre+"fullscreen").hide(),l={}}else saveAs(e,t)}saveSvg(e,t,s){if(this.icn3d.icn3dui.bNode)return"";let i=$("#"+e).width(),n=$("#"+e).height();s&&(n=i);let l=this.getSvgXml(e,i,n,s),r=new Blob([l],{type:"image/svg+xml"});saveAs(r,t)}getSvgXml(e,t,s,i){if(this.icn3d.icn3dui.bNode)return"";return(t&&s?''+""+document.getElementById(e).innerHTML+""}savePng(e,t,s){let i=this.icn3d,n=i.icn3dui;if(n.bNode)return"";let l=$("#"+e).width(),r=$("#"+e).height();s&&(r=l);let o=document.getElementById(e),a=o.getBBox(),d=o.cloneNode(!0);i.lineGraphCls.copyStylesInline(d,o);let c=document.createElement("CANVAS");c.width=l,c.height=r;let h=c.getContext("2d");h.clearRect(0,0,a.width,a.height);let p=this.getSvgXml(e,l,r,s),m=window.URL||window.webkitURL||window,u=new Blob([p],{type:"image/svg+xml;charset=utf-8"}),g=new Image;g.src=m.createObjectURL(u),g.onload=function(){if(h.drawImage(g,0,0),m.revokeObjectURL(this.src),n.utilsCls.isIE()){let e=c.msToBlob();e&&(saveAs(e,t),c.remove())}else c.toBlob((function(e){e&&(saveAs(e,t),c.remove())}))}}exportCustomAtoms(e){var t=this.icn3d;t.icn3dui;let s="",i=void 0!==t.defNames2Residues?Object.keys(t.defNames2Residues).sort():[];for(let n=0,l=i.length;n0)if(s){let s={};for(let e=0,l=t.length;eparseInt(p)+1&&(s.ss=" ",f.push(s)),"helix"==t.ss?(s.ss="H",f.push(s)):"sheet"==t.ss&&(s.ss="S",f.push(s)),t.ssend){let e=a.hashUtilsCls.cloneHash(s);e.ss=" ",f.push(e)}p=t.resi}let b,C,y=0,v=!1,_=!1;for(let e=0,t=f.length;e1,A=1,x="",k="",O=0,R="",I={};for(let l in e){let e=o.atoms[l];if(s&&e.het)continue;if(e.structure!=x){r&&S||(d+=w,w="",A>1&&(d+="\nENDMDL\n"),S&&(d+="MODEL "+A+"\n"));let t=n?"Mutated chain_residue "+Object.keys(n)+"; ":"";i||r&&S||(d+=this.getPDBHeader(A-1,g,t,e.structure)),++A}e.chain!=k&&e.structure==x&&k&&(d+="TER\n");let p=e.chain+"_"+e.resi;if(n&&n.hasOwnProperty(p)){I.hasOwnProperty(p)||(d+=n[p],I[p]=1);continue}let m="";m+=e.het?"HETATM":"ATOM ",m+=l.toString().padStart(5," "),m+=" ";let u=e.name.trim();isNaN(u.substr(0,1))||(u=u.substr(1)+u.substr(0,1)),4==u.length?m+=u:(m+=" ",u=u.replace(/\*/g,"'"),"O1P"==u?u="OP1":"O2P"==u?u="OP2":"C5M"==u&&(u="C7 "),m+=u.padEnd(3," ")),m+=" ";let f=e.resn;if(m+=f.length<=3?f.padStart(3," "):f.substr(0,3),r&&A>2&&(o.proteins.hasOwnProperty(e.serial)||o.nucleotides.hasOwnProperty(e.serial)))e.structure==x&&e.chain==k||(R=O<36?"abcdefghijklmnopqrstuvwxyz0123456789"[O]:"?",++O),m+=" "+R;else if(e.chain.length>=2){m+=e.chain.replace(/_/gi,"").substr(0,2)}else 1==e.chain.length?m+=" "+e.chain.substr(0,1):0==e.chain.length&&(m+=" A");let b=e.resi;!isNaN(b)&&e.chain.length>3&&!isNaN(e.chain.substr(3))&&(b=b-1+parseInt(e.chain.substr(3)));let C=parseInt(b);m+=C.toString().length<=4?C.toString().padStart(4," "):C.toString().substr(0,4);let y=e.resi.toString().substr(e.resi.toString().length-1,1);if(isNaN(y)?m+=y:m+=" ",m+=" ".padStart(3," "),m+=e.coord.x.toFixed(3).toString().padStart(8," "),m+=e.coord.y.toFixed(3).toString().padStart(8," "),m+=e.coord.z.toFixed(3).toString().padStart(8," "),t&&e.het){let t=1.5,s=0;"C"==e.elem?t=1.908:"N"==e.elem?t=1.824:"O"==e.elem?t=1.6612:"H"==e.elem?t=1.25:"S"==e.elem?t=2:"P"==e.elem?t=2.1:a.parasCls.vdwRadii.hasOwnProperty(e.elem)&&(t=a.parasCls.vdwRadii[e.elem]),void 0!==a.cfg.cid&&void 0!==e.crg?s=e.crg:c.hasOwnProperty(l)?s=1.38:h.hasOwnProperty(l)?s=-.595:a.parasCls.ionCharges.hasOwnProperty(e.elem)&&(s=a.parasCls.ionCharges[e.elem]),m+=s.toFixed(4).toString().padStart(8," "),m+=t.toFixed(4).toString().padStart(7," ")}else m+="1.00".padStart(6," "),m+=e.b?parseFloat(e.b).toFixed(2).toString().padStart(6," "):" ".padStart(6," "),m+=" ".padStart(10," "),m+=e.elem.padStart(2," "),m+=" ".padStart(2," ");if(e.het&&e.bonds.length>0){w+="CONECT"+l.toString().padStart(5," ");let t={};for(let s=0,i=e.bonds.length;s50?n.molTitle.substr(0,47)+"...":n.molTitle;-1!=e.indexOf('"')&&(e=""),s&&(e=s+e),l+="TITLE "+e+"\n"}return t&&t[r]&&(l+=t[r]),l}showTitle(){var e=this.icn3d,t=e.icn3dui;let s=e.molTitle?e.molTitle:"",i="black"==e.opts.background?t.htmlCls.GREYD:"black";if(void 0===e.inputid)s.length>40&&(s=s.substr(0,40)+"..."),$("#"+e.pre+"title").html(s);else if(void 0!==t.cfg.cid){let t=this.getLinkToStructureSummary();$("#"+e.pre+"title").html("PubChem CID "+e.inputid.toUpperCase()+": "+s)}else if(void 0!==t.cfg.align)s="VAST+ alignment of "+Object.keys(e.structures),$("#"+e.pre+"title").html(s);else if(void 0!==t.cfg.chainalign){s="Dynamic Structure Alignment of Chains: "+t.cfg.chainalign.split(","),$("#"+e.pre+"title").html(s)}else{let n=Object.keys(t.utilsCls.getStructures(e.dAtoms));if(n.length>1){s="Multiple structures: ";for(let e=0,t=n.length;e'+n[e]+"",e5?"https://alphafold.ebi.ac.uk/entry/"+n[0]:"https://www.ncbi.nlm.nih.gov/structure/?term="+n[0];this.setStructureTitle(e,s,i)}}}setStructureTitle(e,t,s){var i=this.icn3d,n=i.icn3dui;t.length>40&&(t=t.substr(0,40)+"...");let l,r,o=i.inputid;if(-1!=o.indexOf("http"))r="Data from",e=o,l=o;else{let e=n.utilsCls.getHlStructures(),s=!1,a=!1;for(let t in e)t.length>5?a=!0:s=!0;let d=Object.keys(e);if(o=d.join(","),l=n.cfg.refseqid||n.cfg.protein?i.inputid:o.toUpperCase(),s&&a?r="AlphaFold/PDB ID":s?r="PDB ID":a&&(r="AlphaFold ID"),d.length>1&&(r+="s"),i.molTitleHash){t="";for(let e=0,s=d.length;e20&&(e=e.substr(0,17)+"..."),l="Query: "+e+"; target: "+s,$("#"+i.pre+"title").html(l+", "+t)}else $("#"+i.pre+"title").html(r+" "+l+": "+t);else $("#"+i.pre+"title").html(t)}getLinkToStructureSummary(e){var t=this.icn3d,s=t.icn3dui;let i="https://www.ncbi.nlm.nih.gov/structure/?term=";if(i=void 0!==s.cfg.cid?"https://www.ncbi.nlm.nih.gov/pccompound/?term=":void 0!==s.cfg.refseqid?"https://www.ncbi.nlm.nih.gov/protein/":void 0!==s.cfg.afid?"https://alphafold.ebi.ac.uk/search/text/":Object.keys(t.structures).length>1?"https://www.ncbi.nlm.nih.gov/structure/?term=":s.htmlCls.baseUrl+"pdb/",void 0===t.inputid)i="https://www.ncbi.nlm.nih.gov/pccompound/?term="+t.molTitle;else{let n=t.inputid.split("_");1===n.length?(i+=t.inputid,e&&s.htmlCls.clickMenuCls.setLogCmd("link to "+t.inputid+": "+i,!1)):2===n.length&&(s.cfg.afid?i+=n[0]+" "+n[1]:i+=n[0]+" OR "+n[1],e&&s.htmlCls.clickMenuCls.setLogCmd("link to structures "+n[0]+" and "+n[1]+": "+i,!1))}return i}setEntrezLinks(e){var t=this.icn3d,s=t.icn3dui;let i,n=Object.keys(t.structures);if(1===n.length){i="https://www.ncbi.nlm.nih.gov/"+e+"/?term="+n[0],s.htmlCls.clickMenuCls.setLogCmd("Entrez "+e+" about PDB "+n[0]+": "+i,!1);let l=t.structures&&Object.keys(t.structures).length>0?"_blank":"_self";window.open(i,l)}else if(2===n.length){i="https://www.ncbi.nlm.nih.gov/"+e+"/?term="+n[0]+" OR "+n[1],s.htmlCls.clickMenuCls.setLogCmd("Entrez "+e+" about PDB "+n[0]+" OR "+n[1]+": "+i,!1);let l=t.structures&&Object.keys(t.structures).length>0?"_blank":"_self";window.open(i,l)}}}class Is{constructor(e){this.icn3d=e}async shareLink(e,t){let s=this.icn3d,i=s.icn3dui,n=this.shareLinkUrl(),l=n.length>4e3||0!==n.indexOf("http"),r=Object.keys(s.structures).join("_");if(r==s.defaultPdbId&&(s.filename?r=s.filename:s.inputid&&(r=s.inputid)),e){if(t||s.bInputfile||l)return void s.saveFileCls.saveFile(r+"_icn3d_loadable.png","png")}else{if(s.bInputfile&&!s.bInputUrlfile)return void alert("Share Link does NOT work when the data are from custom files. Please save 'iCn3D PNG Image' in the File menu and open it in iCn3D.");if(l)return void alert("The url is more than 4000 characters and may not work. Please save 'iCn3D PNG Image' or 'State File' and open them in iCn3D.");i.htmlCls.clickMenuCls.setLogCmd("share link: "+n,!1)}let o="Problem in getting shortened URL";if(!i.cfg.notebook){let t=await this.getShareLinkPrms(n,e);if(void 0!==t.shortLink&&(o=t.shortLink,e)){let e=o.split("/"),t=e[e.length-1];s.saveFileCls.saveFile(r+"-"+t+".png","png");let i='\n\n",s.saveFileCls.saveFile(r+"-"+t+".html","html",i)}e&&void 0===t.shortLink&&s.saveFileCls.saveFile(r+"_icn3d_loadable.png","png");let i=o.split("page.link/");2==i.length&&(o="https://structure.ncbi.nlm.nih.gov/icn3d/share.html?"+i[1]),$("#"+s.pre+"short_url").val(o),$("#"+s.pre+"short_url_title").val(o+"&t="+s.yournote)}let a=this.shareLinkUrl(void 0,!0),d="view = icn3dpy.view(q='"+(i.cfg.url?"url="+i.cfg.url:i.cfg.idname+"="+i.cfg.idvalue)+"',command='"+a+"')\nview";(i.cfg.url||i.cfg.idname)&&$("#"+s.pre+"jn_commands").val(d),$("#"+s.pre+"ori_url").val(n),e||i.htmlCls.dialogCls.openDlg("dl_copyurl","Copy a Share Link URL or Jupyter Notebook Commands")}getShareLinkPrms(e,t){let s=this.icn3d,i=s.icn3dui;return new Promise((function(n,l){$.ajax({url:"https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=AIzaSyBxl9CgM0dY5lagHL4UOhEpLWE1fuwdnvc",type:"POST",data:{longDynamicLink:"https://icn3d.page.link/?link="+encodeURIComponent(e)},dataType:"json",success:function(e){n(e)},error:function(n,l,r){let o="Problem in getting shortened URL";$("#"+s.pre+"ori_url").val(e),$("#"+s.pre+"short_url").val(o),$("#"+s.pre+"short_url_title").val(o+"&t="+s.yournote),t||i.htmlCls.dialogCls.openDlg("dl_copyurl","Copy a Share Link URL")}})}))}shareLinkUrl(e,t){let s=this.icn3d,i=s.icn3dui,n=i.htmlCls.baseUrl+"icn3d/?",l="";if(i.cfg.bSidebyside&&(n=i.htmlCls.baseUrl+"icn3d/full2.html?"),s.bInputUrlfile){n=window.location.href.split("?")[0]+"?"+s.inputurl+"&"}let r,o={};for(let e in s.cfg){let t=s.cfg[e];"inpara"!==e&&"command"!==e&&"usepdbnum"!==e&&"date"!==e&&"v"!==e&&void 0!==t&&("width"===e&&"100%"===t||"height"===e&&"100%"===t||"resize"===e&&!0===t||"showmenu"===e&&!0===t||"showtitle"===e&&!0===t||"showcommand"===e&&!0===t||"mobilemenu"===e&&!1===t||"showanno"===e&&!1===t||"showseq"===e&&!1===t||"showalignseq"===e&&!1===t||"show2d"===e&&!1===t||"showsets"===e&&!1===t||"rotate"===e&&"right"===t||"command"!==e&&("options"===e?Object.keys(t).length>0&&(o[e]=JSON.stringify(t)):!0===t?o[e]=1:!1===t?o[e]=0:""!==t&&(o[e]=t)))}s.bAfMem?o.afmem="on":(i.cfg.afid||1==Object.keys(s.structures).length&&Object.keys(s.structures)[0].length>5)&&(o.afmem="off");let a=-1;void 0!==i.cfg.inpara&&(a=i.cfg.inpara.indexOf("&command=")),r=-1!==a?i.cfg.inpara.substr(0,a):i.cfg.inpara;let d=!1;if(!s.bInputUrlfile){let e=r&&r.substr(1)?r.substr(1).split("&"):[];for(let t=0,s=e.length;tc){u=s.commands[c].split("|||")[0].split("&command=")[0].trim(),-1!==u.indexOf(g)&&++f}let b,C=c+1,y="";for(let e=s.commands.length;C0&&f%2==0&&u!==g&&(y+=g+"; "),y+=u+"|||"+s.transformCls.getTransformationStr(p),m+=u+"|||"+s.transformCls.getTransformationStr(p)+"\n"),n+=y,l=y,m=m.replace(/!/g,Object.keys(s.structures)[0]+"_"),(s.bEsmfold||s.bInputfile&&!s.bInputUrlfile||s.bInputUrlfile&&s.bAppend||n.length>4e3)&&(n=m),void 0!==s.structures&&1==Object.keys(s.structures).length&&void 0!==s.inputid&&(b=Object.keys(s.structures)[0],n=n.replace(new RegExp(b+"_","g"),"!"),l=l.replace(new RegExp(b+"_","g"),"!")),void 0!==i.cfg.blast_rep_id&&(n=n.replace(new RegExp("blast_rep_id=!","g"),"blast_rep_id="+b+"_")),t?l:n}getPngText(){let e,t=this.icn3d;t.icn3dui;let s="";if(t.bInputfile)e=this.shareLinkUrl(true),"http"==e.substr(0,4)?s+="\nShare Link: "+e:(s+="\nStart of type file======\n",s+=t.InputfileType+"\n",s+="End of type file======\n",s+="Start of data file======\n",s+=t.saveFileCls.getAtomPDB(t.atoms),s+="End of data file======\n",s+="Start of state file======\n",s+=e+"\n",s+="End of state file======\n");else{e=this.shareLinkUrl(),e.length>4e3||0!==e.indexOf("http")?(e=this.shareLinkUrl(true),s+="\nStart of state file======\n",s+=e+"\n",s+="End of state file======\n"):s+="\nShare Link: "+e}return s=s.replace(/!/g,Object.keys(t.structures)[0]+"_"),s}}class Ts{constructor(e){this.icn3d=e}setThichknessFor3Dprint(){let e=this.icn3d,t=e.icn3dui;e.lineRadius=1,e.coilWidth=1.2,e.cylinderRadius=.8,e.crosslinkRadius=.8,e.traceRadius=1,e.dotSphereScale=.6,e.sphereRadius=1.5,e.ribbonthickness=1,e.helixSheetWidth=2,e.nucleicAcidWidth=1.4,t.htmlCls.setHtmlCls.setCookieForThickness()}prepareFor3Dprint(){let e=this.icn3d,t=e.icn3dui;if(e.bShowHighlight=!1,e.hlObjectsCls.removeHlObjects(),e.bDashedLines=!1,e.bSetThickness||void 0!==t.cfg.cid||this.setThichknessFor3Dprint(),void 0!==e.lines.hbond)for(let t=0,s=e.lines.hbond.length;tt.substr(0,s))return 1;if(e.substr(0,s)==t.substr(0,s)){if(parseInt(e.substr(s+1))parseInt(t.substr(i+1)))return 1;if(parseInt(e.substr(s+1))==parseInt(t.substr(i+1)))return 0}}})),n="";for(let e=0,t=i.length;e"}let l=Object.keys(t.utilsCls.getHlStructures()).join(",");e.saveFileCls.saveFile(l+"_residues.txt","html",n)}addStabilizer(){let e=this.icn3d,t=e.icn3dui,s=3.5;if(Object.keys(e.dAtoms).length>0){let i,n={},l=12.25,r=3.2*3.2;for(let t in e.dAtoms){let s=e.atoms[t];!e.nucleotides.hasOwnProperty(s.serial)||"N1"!==s.name&&"N2"!==s.name&&"N3"!==s.name&&"N4"!==s.name&&"N6"!==s.name&&"O2"!==s.name&&"O6"!==s.name||(i=s.structure+"_"+s.chain+"_"+s.resi+"_"+s.name,n[i]=s)}let o=Object.keys(n),a=o.length;void 0===e.pairArray&&(e.pairArray=[]);for(let t=0;ts)continue;let h=Math.abs(n[a].coord.y-n[d].coord.y);if(h>s)continue;let p=Math.abs(n[a].coord.z-n[d].coord.z);if(p>s)continue;let m=c*c+h*h+p*p;m>l||ms+1||rs+2||rs+4||r0&&o.length>0)if(a){let t=parseInt((r.length+.5)/2);e.pairArray.push(o[0]),e.pairArray.push(r[t])}else{let t=10,s=parseInt(r.length/(t+1));for(let i=0,n=o.length;i1&&t.bAssembly&&(t.threshbox=180/Math.pow(t.biomtMatrices.length,.33),t.applyMapCls.removeSurfaces(),t.applyMapCls.applySurfaceOptions(),t.applyMapCls.removeMaps(),t.applyMapCls.applyMapOptions(),t.applyMapCls.removeEmmaps(),t.applyMapCls.applyEmmapOptions());let i=this.saveStlFile(),n=Object.keys(s.utilsCls.getHlStructures()).join(",");if(t.saveFileCls.saveFile(n+e+".stl","binary",i),void 0!==t.biomtMatrices&&t.biomtMatrices.length>1&&t.bAssembly&&Object.keys(t.dAtoms).length*t.biomtMatrices.length>t.maxAtoms3DMultiFile){alert(t.biomtMatrices.length+" files will be generated for this assembly. Please merge these files using some software and 3D print the merged file.");let s=new THREE.Matrix4;s.identity();let l=1;for(let r=0;r1&&t.bAssembly&&(t.threshbox=180/Math.pow(t.biomtMatrices.length,.33),t.applyMapCls.removeSurfaces(),t.applyMapCls.applySurfaceOptions(),t.applyMapCls.removeMaps(),t.applyMapCls.applyMapOptions(),t.applyMapCls.removeEmmaps(),t.applyMapCls.applyEmmapOptions());let i=this.saveVrmlFile(),n=Object.keys(s.utilsCls.getHlStructures()).join(",");if(t.saveFileCls.saveFile(n+e+".wrl","text",i),void 0!==t.biomtMatrices&&t.biomtMatrices.length>1&&t.bAssembly&&Object.keys(t.dAtoms).length*t.biomtMatrices.length>t.maxAtoms3DMultiFile){alert(t.biomtMatrices.length+" files will be generated for this assembly. Please merge these files using some software and 3D print the merged file.");let s=new THREE.Matrix4;s.identity();let n=1;for(let l=0;l7e4)return alert("Please display a subset of the structure to export 3D files. Then merge the files for 3D printing..."),[""];t.threeDPrintCls.prepareFor3Dprint();let i=0;i+=this.getFaceCnt(t.mdl),i+=this.getFaceCnt(t.mdl_ghost);let n=[],l=new Uint8Array(84),r="STL file for the structure(s) ",o=Object.keys(t.structures);for(let e=0,t=o.length;e80&&(r=r.substr(0,80));for(let e=0;e<80;++e)e1&&t.bAssembly&&Object.keys(t.dAtoms).length*t.biomtMatrices.length<=t.maxAtoms3DMultiFile?this.updateArray(l,s.convertTypeCls.passInt32([i*t.biomtMatrices.length]),80):this.updateArray(l,s.convertTypeCls.passInt32([i]),80),n.push(new Blob([l],{type:"application/octet-stream"})),n=this.processStlMeshGroup(t.mdl,n,e),n=this.processStlMeshGroup(t.mdl_ghost,n,e),void 0!==t.biomtMatrices&&t.biomtMatrices.length>1&&t.bAssembly&&Object.keys(t.dAtoms).length*t.biomtMatrices.length<=t.maxAtoms3DMultiFile){let e=new THREE.Matrix4;e.identity();for(let s=0;s5e4)return alert("Please display a subset of the structure to export 3D files. Then merge the files for 3D printing..."),[""];t.threeDPrintCls.prepareFor3Dprint();let s=[];s.push("#VRML V2.0 utf8\n");let i=0,n=this.processVrmlMeshGroup(t.mdl,s,i,e);if(s=n.vrmlStrArray,i=n.vertexCnt,n=this.processVrmlMeshGroup(t.mdl_ghost,s,i,e),s=n.vrmlStrArray,i=n.vertexCnt,void 0!==t.biomtMatrices&&t.biomtMatrices.length>1&&t.bAssembly&&Object.keys(t.dAtoms).length*t.biomtMatrices.length<=t.maxAtoms3DMultiFile){let e=new THREE.Matrix4;e.identity();for(let l=0;l0?h.z=-1:h.z=1,s.cam===s.perspectiveCamera?(s.cam_z>0?h.z=-1:h.z=1,h.unproject(s.cam),s.raycaster.set(s.cam.position,h.sub(s.cam.position).normalize())):s.cam===s.orthographicCamera&&(s.cam_z>0?h.z=1:h.z=-1,h.unproject(s.cam),s.raycaster.set(h,new THREE.Vector3(0,0,-1).transformDirection(s.cam.matrixWorld)));let p=this.isIntersect(s.objects,s.mdl,t,d,c);p||(p=this.isIntersect(s.objects_ghost,s.mdl_ghost,t,d,c))}isIntersect(e,t,s,i,n){let l=this.icn3d;l.icn3dui;let r=l.raycaster.intersectObjects(e),o=!1,a=t.position;if(r.length>0){r[0].point.sub(a);let e=l.rayThreshold,t=this.getAtomsFromPosition(r[0].point,e);for(;!t&&e<10;)e+=.5,t=this.getAtomsFromPosition(r[0].point,e);t?(o=!0,l.pickpair?s&&(l.pAtomNum%2==0?l.pAtom=t:l.pAtom2=t,++l.pAtomNum):l.pAtom=t,s?l.pickingCls.showPicking(t):l.pickingCls.showPicking(t,i,n)):console.log("No atoms were found in 10 andstrom range")}return o}getAtomsFromPosition(e,t,s){let i,n=this.icn3d,l=n.icn3dui;null==t&&(t=1);let r=s||n.dAtoms;for(i in r){let s=n.atoms[i];if(n.ions.hasOwnProperty(i)&&"sphere"===n.opts.ions){let i=l.parasCls.vdwRadii[s.elem.toUpperCase()];if(Math.abs(s.coord.x-e.x)-i>t)continue;if(Math.abs(s.coord.y-e.y)-i>t)continue;if(Math.abs(s.coord.z-e.z)-i>t)continue}else{if(s.coord.xe.x+t)continue;if(s.coord.ye.y+t)continue;if(s.coord.ze.z+t)continue}return s}return null}}class Ms{constructor(e){this.icn3d=e}setControl(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s=this;e.WIDTH=e.container.width(),e.HEIGHT=e.container.height(),e.applyCenterCls.setWidthHeight(e.WIDTH,e.HEIGHT),e._zoomFactor=1,e.mouseChange=new THREE.Vector2(0,0),e.quaternion=new THREE.Quaternion(0,0,0,1),e.container.bind("contextmenu",(function(e){e.preventDefault()})),e.typetext=!1,$(document).bind("keyup",(function(t){16===t.keyCode&&(e.bShift=!1),17!==t.keyCode&&224!==t.keyCode&&91!==t.keyCode||(e.bCtrl=!1)})),$("input[type=text], textarea").focus((function(){e.typetext=!0})),$("input[type=text], textarea").blur((function(){e.typetext=!1})),$(document).bind("keydown",(async function(s){if((s.shiftKey||16===s.keyCode)&&(e.bShift=!0),(s.ctrlKey||17===s.keyCode||224===s.keyCode||91===s.keyCode)&&(e.bCtrl=!0),!e.bControlGl&&!e.controls||e.bControlGl&&!window.controls)return;e.bStopRotate=!0;let i=e.bShift?90:5;if(!e.typetext)if(90===s.keyCode){let s={};e.bControlGl&&!t.bNode?window.cam===e.perspectiveCamera?s._zoomFactor=.9:window.cam===e.orthographicCamera&&(e._zoomFactor<.1?e._zoomFactor=.1:e._zoomFactor>1&&(e._zoomFactor=1),s._zoomFactor=.8*e._zoomFactor,s._zoomFactor<.1&&(s._zoomFactor=.1)):e.cam===e.perspectiveCamera?s._zoomFactor=.9:e.cam===e.orthographicCamera&&(e._zoomFactor<.1?e._zoomFactor=.1:e._zoomFactor>1&&(e._zoomFactor=1),s._zoomFactor=.8*e._zoomFactor,s._zoomFactor<.1&&(s._zoomFactor=.1)),s.update=!0,e.bControlGl&&!t.bNode?window.controls.update(s):e.controls.update(s),e.bRender&&e.drawCls.render()}else if(88===s.keyCode){let s={};e.bControlGl&&!t.bNode?window.cam===e.perspectiveCamera?s._zoomFactor=1.03:window.cam===e.orthographicCamera&&(e._zoomFactor>10?e._zoomFactor=10:e._zoomFactor<1&&(e._zoomFactor=1),s._zoomFactor=1.01*e._zoomFactor,s._zoomFactor>10&&(s._zoomFactor=10)):e.cam===e.perspectiveCamera?s._zoomFactor=1.03:e.cam===e.orthographicCamera&&(e._zoomFactor>10?e._zoomFactor=10:e._zoomFactor<1&&(e._zoomFactor=1),s._zoomFactor=1.01*e._zoomFactor,s._zoomFactor>10&&(s._zoomFactor=10)),s.update=!0,e.bControlGl&&!t.bNode?window.controls.update(s):e.controls.update(s),e.bRender&&e.drawCls.render()}else if(76===s.keyCode){let t=new THREE.Vector3(0,1,0),s=-i/180*Math.PI;e.transformCls.setRotation(t,s)}else if(74===s.keyCode){let t=new THREE.Vector3(0,1,0),s=i/180*Math.PI;e.transformCls.setRotation(t,s)}else if(73===s.keyCode){let t=new THREE.Vector3(1,0,0),s=-i/180*Math.PI;e.transformCls.setRotation(t,s)}else if(77===s.keyCode){let t=new THREE.Vector3(1,0,0),s=i/180*Math.PI;e.transformCls.setRotation(t,s)}else 65===s.keyCode&&Object.keys(e.structures).length>1&&await e.alternateCls.alternateWrapper()})),e.container.bind("mouseup",(function(t){e.isDragging=!1})),e.container.bind("touchend",(function(t){e.isDragging=!1})),e.container.bind("mousedown",(function(s){if(e.isDragging=!0,e.scene){if(e.bStopRotate=!0,e.pk&&(s.altKey||s.ctrlKey||s.shiftKey||18===s.keyCode||16===s.keyCode||17===s.keyCode||224===s.keyCode||91===s.keyCode)){e.highlightlevel=e.pk;let t=!0;e.rayCls.rayCaster(s,t)}e.bControlGl&&!t.bNode?(window.controls.handleResize(),window.controls.update()):(e.controls.handleResize(),e.controls.update()),e.bRender&&e.drawCls.render()}})),e.container.bind("touchstart",(function(s){if(s.preventDefault(),e.isDragging=!0,!e.scene)return;e.bStopRotate=!0,$("#"+e.pre+"popup").hide();e.rayCls.rayCaster(s,!0),e.bControlGl&&!t.bNode?(window.controls.handleResize(),window.controls.update()):(e.controls.handleResize(),e.controls.update()),e.bRender&&e.drawCls.render()})),e.container.bind("mousemove touchmove",(function(e){s.mouseMove(e)})),e.container.bind("mousewheel",(function(s){s.preventDefault(),e.scene&&(e.bStopRotate=!0,e.bControlGl&&!t.bNode?(window.controls.handleResize(),window.controls.update()):(e.controls.handleResize(),e.controls.update()),e.bRender&&e.drawCls.render())})),e.container.bind("DOMMouseScroll",(function(s){s.preventDefault(),e.scene&&(e.bStopRotate=!0,e.bControlGl&&!t.bNode?(window.controls.handleResize(),window.controls.update()):(e.controls.handleResize(),e.controls.update()),e.bRender&&e.drawCls.render())}))}mouseMove(e){let t=this.icn3d,s=t.icn3dui;if(s.bNode)return;if(e.preventDefault(),!t.scene)return;$("#"+t.pre+"popup").hide();if(t.rayCls.rayCaster(e,!1),t.bControlGl&&!s.bNode){window.controls.handleResize(),window.controls.update();for(let e in window.icn3duiHash){let t=window.icn3duiHash[e].icn3d;t.bRender&&t.drawCls.render()}}else t.controls.handleResize(),t.controls.update(),t.bRender&&t.drawCls.render()}}class Ds{constructor(e){this.icn3d=e}showPicking(e,t,s){let i=this.icn3d,n=i.icn3dui;if(void 0!==n.cfg.cid&&0!=i.pk&&(i.pk=1),i.highlightlevel=i.pk,this.showPickingBase(e,t,s),0!=i.pk)if(void 0!==t&&void 0!==s){null!=n.cfg.showmenu&&1==n.cfg.showmenu&&(s+=n.htmlCls.MENU_HEIGHT);let l,r=1==i.pk?e.resn+e.resi+"@"+e.name:e.resn+e.resi,o=e.structure+"_"+e.chain;if(void 0!==i.structures&&Object.keys(i.structures).length>1?(r=o+" "+r,l=i.chainid2refpdbname&&i.chainid2refpdbname[o]?240:160,$("#"+i.pre+"popup").css("width",l+"px")):(l=i.chainid2refpdbname&&i.chainid2refpdbname[o]?160:80,$("#"+i.pre+"popup").css("width",l+"px")),i.chainid2refpdbname&&i.chainid2refpdbname[o]){let t=i.resid2refnum[o+"_"+e.resi];t&&(r+=", Ig: "+t)}$("#"+i.pre+"popup").html(r),$("#"+i.pre+"popup").css("top",s).css("left",t+20).show()}else{i.hlUpdateCls.updateHlAll();let t={};t.factor=i._zoomFactor,t.mouseChange=i.mouseChange,t.quaternion={},t.quaternion._x=parseFloat(i.quaternion._x).toPrecision(5),t.quaternion._y=parseFloat(i.quaternion._y).toPrecision(5),t.quaternion._z=parseFloat(i.quaternion._z).toPrecision(5),t.quaternion._w=parseFloat(i.quaternion._w).toPrecision(5),n.htmlCls.clickMenuCls.setLogCmd("pickatom "+e.serial,!0),i.selectionCls.saveSelInCommand(),i.bSphereCalc=!1,i.bHbondCalc=!1}}showPickingBase(e,t,s){this.icn3d.icn3dui,void 0===t&&void 0===s&&this.showPickingHilight(e)}getPickedAtomList(e,t){let s=this.icn3d;s.icn3dui;let i={};if(1===e)i[t.serial]=1;else if(2===e){let e=t.structure+"_"+t.chain+"_"+t.resi;i=s.residues[e]}else if(3===e)i=this.selectStrandHelixFromAtom(t);else if(4===e)i=this.select3ddomainFromAtom(t);else if(5===e){let e=t.structure+"_"+t.chain;i=s.chains[e]}return i}showPickingHilight(e){let t=this.icn3d,s=t.icn3dui;t.bShift||t.bCtrl||t.hlObjectsCls.removeHlObjects(),t.pickedAtomList=this.getPickedAtomList(t.pk,e),0===t.pk?t.bShowHighlight=!1:t.bShowHighlight=!0;let i=Object.keys(t.hAtoms).length==Object.keys(t.atoms).length?{}:s.hashUtilsCls.intHash(t.hAtoms,t.pickedAtomList),n=Object.keys(i).length;if(t.bShift||t.bCtrl)if(t.bShift){if(void 0===t.prevPickedAtomList)t.hAtoms=s.hashUtilsCls.unionHash(t.hAtoms,t.pickedAtomList);else{let e=t.firstAtomObjCls.getFirstAtomObj(t.prevPickedAtomList),i=t.firstAtomObjCls.getFirstAtomObj(t.pickedAtomList);if(e.structure+"_"+e.chain!=i.structure+"_"+i.chain)t.hAtoms=s.hashUtilsCls.unionHash(t.hAtoms,t.pickedAtomList);else{let e;e=s.hashUtilsCls.unionHash(e,t.prevPickedAtomList),e=s.hashUtilsCls.unionHash(e,t.pickedAtomList);let i=t.firstAtomObjCls.getFirstAtomObj(e),n=t.firstAtomObjCls.getLastAtomObj(e);for(let e=i.serial;e<=n.serial;++e)t.hAtoms[e]=1}}t.prevPickedAtomList=s.hashUtilsCls.cloneHash(t.pickedAtomList)}else t.bCtrl&&(t.hAtoms=n>0?s.hashUtilsCls.exclHash(t.hAtoms,t.pickedAtomList):s.hashUtilsCls.unionHash(t.hAtoms,t.pickedAtomList));else t.hAtoms=s.hashUtilsCls.cloneHash(t.pickedAtomList);t.hlObjectsCls.removeHlObjects(),t.hlObjectsCls.addHlObjects()}select3ddomainFromAtom(e){let t,s=this.icn3d,i=s.icn3dui,n=e.structure+"_"+e.chain,l=n+"_"+e.resi;for(let e in s.tddomains){let i=e.indexOf("_3d_domain");if(e.substr(0,i)==n&&-1!==Object.keys(s.tddomains[e]).indexOf(l)){t=e;break}}let r={};for(let e in s.tddomains[t])r=i.hashUtilsCls.unionHash(r,s.residues[e]);return r}selectStrandHelixFromAtom(e){let t=this.icn3d,s=t.icn3dui,i=e,n=e,l={},r=i.resi;if(!i.ssbegin&&!isNaN(i.resi)){for(let e=i.resi-1;e>0;--e){let s=i.structure+"_"+i.chain+"_"+e;if(!t.residues.hasOwnProperty(s))break;let n=t.firstAtomObjCls.getFirstCalphaAtomObj(t.residues[s]);if(r=n.resi,"coil"!==i.ss&&n.ss===i.ss&&n.ssbegin||"coil"===i.ss&&n.ss!==i.ss){"coil"===i.ss&&n.ss!==i.ss&&(r=parseInt(n.resi)+1);break}}for(let e=r;e<=i.resi;++e){let n=i.structure+"_"+i.chain+"_"+e;l=s.hashUtilsCls.unionHash(l,s.hashUtilsCls.hash2Atoms(t.residues[n],t.atoms))}}let o=n.resi,a=t.firstAtomObjCls.getLastAtomObj(t.chains[n.structure+"_"+n.chain]).resi;for(let e=parseInt(n.resi)+1;e<=parseInt(a);++e){let s=n.structure+"_"+n.chain+"_"+e;if(!t.residues.hasOwnProperty(s))break;let i=t.firstAtomObjCls.getFirstCalphaAtomObj(t.residues[s]);if(o=i.resi,"coil"!==n.ss&&i.ss===n.ss&&i.ssend||"coil"===n.ss&&i.ss!==n.ss){"coil"!==n.ss||i.ss===n.ss||isNaN(i.resi)||(o=i.resi-1);break}}for(let e=parseInt(n.resi)+1;e<=parseInt(o);++e){let i=n.structure+"_"+n.chain+"_"+e;l=s.hashUtilsCls.unionHash(l,s.hashUtilsCls.hash2Atoms(t.residues[i],t.atoms))}return l}}class Hs{constructor(e){this.icn3d=e,this.xrSessionIsGranted=!1}createButton(e,t){let s=this.icn3d,i=s.icn3dui;t&&console.error('THREE.VRButton: The "options" parameter has been removed. Please set the reference space type via renderer.xr.setReferenceSpaceType() instead.');const n=document.createElement("button");function l(){n.style.display="",n.style.cursor="auto",n.style.left="calc(33% - 75px)",n.style.width="150px",n.onmouseenter=null,n.onmouseleave=null,n.onclick=null}let r=this;if("xr"in navigator)return n.id=i.pre+"VRButton",n.style.display="none",(o=n).style.position="absolute",o.style.bottom="20px",o.style.padding="12px 6px",o.style.border="1px solid #fff",o.style.borderRadius="4px",o.style.background="#000",o.style.color="#f8b84e",o.style.font="bold 13px sans-serif",o.style.textAlign="center",o.style.opacity="0.8",o.style.outline="none",o.style.zIndex="999",navigator.xr.isSessionSupported("immersive-vr").then((function(t){t?function(){let t=null;async function i(s){s.addEventListener("end",l),await e.xr.setSession(s),n.textContent="EXIT VR",t=s}function l(){s.transformCls.resetOrientation(),s.bVr=!1,s.drawCls.draw(),t.removeEventListener("end",l),n.textContent="ENTER VR",t=null}n.style.display="",n.style.cursor="pointer",n.style.left="calc(33% - 50px)",n.style.width="100px",n.textContent="ENTER VR",n.onmouseenter=function(){n.style.opacity="1.0"},n.onmouseleave=function(){n.style.opacity="0.8"},n.onclick=function(){if(s.bImpo=!1,s.bVr=!0,s.drawCls.draw(s.bVr),null===t){const e={optionalFeatures:["local-floor","bounded-floor","hand-tracking","layers"]};navigator.xr.requestSession("immersive-vr",e).then(i)}else t.end()}}():(l(),n.style.display="none"),t&&r.xrSessionIsGranted&&n.click()})).catch((function(e){l(),console.warn("Exception when trying to call xr.isSessionSupported",e),n.style.display="none"})),n;return document.createElement("span");var o}registerSessionGrantedListener(){"xr"in navigator&&navigator.xr.addEventListener("sessiongranted",(()=>{this.xrSessionIsGranted=!0}))}}class Fs{constructor(e){this.icn3d=e,this.xrSessionIsGranted=!1}createButton(e,t={}){let s=this.icn3d,i=s.icn3dui;const n=document.createElement("button");function l(){n.style.display="",n.style.cursor="auto",n.style.left="calc(66% - 50px)",n.style.width="150px",n.onmouseenter=null,n.onmouseleave=null,n.onclick=null}function r(e){e.style.position="absolute",e.style.bottom="20px",e.style.padding="12px 6px",e.style.border="1px solid #fff",e.style.borderRadius="4px",e.style.background="#000",e.style.color="#f8b84e",e.style.font="bold 13px sans-serif",e.style.textAlign="center",e.style.opacity="0.8",e.style.outline="none",e.style.zIndex="999"}if(i.utilsCls.isAndroid()&&i.utilsCls.isChrome()){if("xr"in navigator)return n.id=i.pre+"ARButton",n.style.display="none",r(n),navigator.xr.isSessionSupported("immersive-ar").then((function(i){i?function(){if(void 0===t.domOverlay){const e=document.createElement("div");e.style.display="none",document.body.appendChild(e);const s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("width",38),s.setAttribute("height",38),s.style.position="absolute",s.style.right="20px",s.style.top="20px",s.addEventListener("click",(function(){i.end()})),e.appendChild(s);const n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d","M 12,12 L 28,28 M 28,12 12,28"),n.setAttribute("stroke","#fff"),n.setAttribute("stroke-width",2),s.appendChild(n),void 0===t.optionalFeatures&&(t.optionalFeatures=[]),t.optionalFeatures.push("dom-overlay"),t.domOverlay={root:e}}let i=null;async function l(s){s.addEventListener("end",r),e.xr.setReferenceSpaceType("local"),await e.xr.setSession(s),n.textContent="STOP AR",t.domOverlay.root.style.display="",i=s}function r(){s.transformCls.resetOrientation(),s.bAr=!1,s.drawCls.draw(),i.removeEventListener("end",r),n.textContent="START AR",t.domOverlay.root.style.display="none",i=null}n.style.display="",n.style.cursor="pointer",n.style.left="calc(66% - 50px)",n.style.width="100px",n.textContent="START AR",n.onmouseenter=function(){n.style.opacity="1.0"},n.onmouseleave=function(){n.style.opacity="0.8"},n.onclick=function(){s.bImpo=!1,s.opts.background="transparent",s.bAr=!0,s.drawCls.draw(s.bAr),null===i?navigator.xr.requestSession("immersive-ar",t).then(l):i.end()}}():(l(),n.style.display="none")})).catch((function(e){l(),console.warn("Exception when trying to call xr.isSessionSupported",e),n.style.display="none"})),n;return document.createElement("span")}return n.id=i.pre+"ARButton",n.style.display="none",r(n),l(),n.style.display="none",n}}class Ls{constructor(e){let t,s,i,n=e;if(this.icn3dui=e,this.id=this.icn3dui.pre+"canvas",this.pre=this.icn3dui.pre,this.container=$("#"+this.id),this.oriContainer=$("#"+this.id),this.bControlGl=!1,this.maxatomcnt=1e5,this.overdraw=0,this.bDrawn=!1,this.bOpm=!1,this.crossstrucinter=0,this.bSecondaryStructure=!1,this.bHighlight=1,this.renderOrderPicking=-1,this.bInitial=!0,this.bDoublecolor=!1,this.originSize=1,this.ALTERNATE_STRUCTURE=-1,this.bUsePdbNum=!0,!this.icn3dui.bNode){let e=document.createElement("canvas");t=!(!window.WebGLRenderingContext||!e.getContext("webgl")&&!e.getContext("experimental-webgl")),e.remove(),e=document.createElement("canvas"),s=!(!window.WebGLRenderingContext||!e.getContext("webgl2")),e.remove(),i="xr"in navigator,t?(s&&i?(this.renderer=new THREE.WebGLRenderer({canvas:this.oriContainer.get(0),antialias:!0,preserveDrawingBuffer:!0,sortObjects:!1,alpha:!0}),this.renderer.xr.enabled=!0):this.renderer=new THREE.WebGL1Renderer({canvas:this.oriContainer.get(0),antialias:!0,preserveDrawingBuffer:!0,sortObjects:!1,alpha:!0}),this.overdraw=0):alert("Currently your web browser has a problem on WebGL. If you are using Chrome, open a new tab for the same URL and WebGL may work again.")}this.frac=new THREE.Color(.1,.1,.1),this.shininess=40,this.emissive=1118481,this.light1=.8,this.light2=.4,this.light3=.2,this.lineRadius=.1,this.coilWidth=.3,this.cylinderRadius=.4,this.crosslinkRadius=.4,this.traceRadius=.4,this.dotSphereScale=.3,this.sphereRadius=1.5,this.cylinderHelixRadius=1.6,this.ribbonthickness=.2,this.helixSheetWidth=1.3,this.nucleicAcidWidth=.8,this.scaleFactor=1,this.labelScale=1,this.resizeRatioX=1,this.resizeRatioY=1,this.bImpo=!0,this.bInstanced=!0,this.chainMissingResidueArray={},this._zoomFactor=1,this.transparentRenderOrder=!1,this.AFUniprotVersion="v4",this.defaultPdbId="stru",this.icn3dui.bNode||(s&&i?(this.bExtFragDepth=!0,this.bImpo=!0,this.bInstanced=!0):(this.bExtFragDepth=this.renderer.extensions.get("EXT_frag_depth"),this.bExtFragDepth?console.log("EXT_frag_depth is supported. All spheres and cylinders are drawn using shaders."):(this.bImpo=!1,console.log("EXT_frag_depth is NOT supported. All spheres and cylinders are drawn using geometry.")),this.bInstanced=this.renderer.extensions.get("ANGLE_instanced_arrays"),this.bInstanced?console.log("ANGLE_instanced_arrays is supported. Assembly is drawn with one copy of the asymmetric unit using hardware instancing."):console.log("ANGLE_instanced_arrays is NOT supported. Assembly is drawn by making copies of the asymmetric unit."))),this.posArray=new Array,this.colorArray=new Array,this.pos2Array=new Array,this.color2Array=new Array,this.radiusArray=new Array,this.posArraySphere=new Array,this.colorArraySphere=new Array,this.radiusArraySphere=new Array,this.axis=!1,this.pk=1,this.highlightlevel=1,this.pickpair=!1,this.pAtomNum=0,this.pAtom=void 0,this.pAtom2=void 0,this.bCtrl=!1,this.bShift=!1,this.bStopRotate=!1,this.bCalphaOnly=!1,this.bConsiderNeighbors=!1,this.bShowCrossResidueBond=!0,this.bExtrude=!0,this.effects={none:this.renderer},this.maxD=500,this.oriMaxD=this.maxD,this.cam_z=2*this.maxD,this.commands=[],this.optsHistory=[],this.logs=[],this.bRender=!0,this.hColor=new THREE.Color(16777011),this.sphereGeometry=new THREE.SphereGeometry(1,32,32),this.boxGeometry=new THREE.BoxGeometry(1,1,1),this.cylinderGeometry=new THREE.CylinderGeometry(1,1,1,32,1),this.cylinderGeometryOutline=new THREE.CylinderGeometry(1,1,1,32,1,!0),this.axisDIV=15,this.strandDIV=6,this.tubeDIV=8,this.nucleicAcidStrandDIV=6,this.linewidth=1,this.hlLineRadius=.1,this.threshbox=180,this.maxAtoms3DMultiFile=4e4,this.tsHbond=3.8,this.tsIonic=6,this.tsContact=4,this.tsHalogen=3.8,this.tsPication=6,this.tsPistacking=5.5,this.LABELSIZE=30,this.rayThreshold=.5,this.colorBlackbkgd="#ffff00",this.colorWhitebkgd="#000000",this.optsOri={},this.optsOri.camera="perspective",this.optsOri.background="black",this.optsOri.color="chain",this.optsOri.proteins="ribbon",this.optsOri.sidec="nothing",this.optsOri.nucleotides="nucleotide cartoon",this.optsOri.ntbase="nothing",this.optsOri.surface="nothing",this.optsOri.opacity="1.0",this.optsOri.wireframe="no",this.optsOri.map="nothing",this.optsOri.mapwireframe="yes",this.optsOri.emmap="nothing",this.optsOri.emmapwireframe="yes",this.optsOri.phimap="nothing",this.optsOri.phimapwireframe="yes",this.optsOri.phisurface="nothing",this.optsOri.phisurftype="nothing",this.optsOri.phisurfop="1.0",this.optsOri.phisurfwf="yes",this.optsOri.chemicals="stick",this.optsOri.water="nothing",this.optsOri.ions="sphere",this.optsOri.hbonds="no",this.optsOri.saltbridge="no",this.optsOri.contact="no",this.optsOri.halogen="no",this.optsOri["pi-cation"]="no",this.optsOri["pi-stacking"]="no",this.optsOri.ssbonds="yes",this.optsOri.clbonds="yes",this.optsOri.rotationcenter="molecule center",this.optsOri.axis="no",this.optsOri.fog="no",this.optsOri.slab="no",this.optsOri.pk="residue",this.optsOri.chemicalbinding="hide",this.opts=n.hashUtilsCls.cloneHash(this.optsOri),this.sheetcolor="green",this.bShowHighlight=!0,this.mapData={},this.bFullUi=!0,this.divid=this.icn3dui.cfg.divid,this.inputid="",this.setOperation="or",this.ROT_DIR="right",this.currSelectedSets=[],this.selectedResidues={},this.ncbi2resid={},this.resid2ncbi={},this.shapeCmdHash={},this.bHideSelection=!0,this.bSelectResidue=!1,this.bSelectAlignResidue=!1,this.bAnnoShown=!1,this.bSetChainsAdvancedMenu=!1,this.b2DShown=!1,this.bCrashed=!1,this.bAddCommands=!0,this.bAddLogs=!0,this.bNotLoadStructure=!1,this.InputfileData="",this.bVr=!1,this.bAr=!1,this.startColor="blue",this.midColor="white",this.endColor="red",this.startValue=0,this.midValue=50,this.endValue=100,this.crosslinkRadius=.4,this.sceneCls=new Ie(this),this.cameraCls=new Te(this),this.fogCls=new Ee(this),this.boxCls=new Pe(this),this.brickCls=new Me(this),this.curveStripArrowCls=new De(this),this.curveCls=new He(this),this.cylinderCls=new Fe(this),this.lineCls=new Le(this),this.reprSubCls=new Ne(this),this.sphereCls=new qe(this),this.stickCls=new Ue(this),this.strandCls=new $e(this),this.stripCls=new je(this),this.tubeCls=new Be(this),this.cartoonNuclCls=new ze(this),this.surfaceCls=new Qe(this),this.labelCls=new Ve(this),this.axesCls=new We(this),this.glycanCls=new Ye(this),this.applyCenterCls=new Ze(this),this.applyClbondsCls=new et(this),this.applyMissingResCls=new tt(this),this.applyDisplayCls=new st(this),this.applyMapCls=new rt(this),this.applyOtherCls=new it(this),this.applySsbondsCls=new nt(this),this.applySymdCls=new lt(this),this.hlObjectsCls=new Ht(this),this.residueLabelsCls=new ot(this),this.alternateCls=new ct(this),this.drawCls=new ht(this),this.firstAtomObjCls=new bs(this),this.impostorCls=new at(this),this.instancingCls=new dt(this),this.contactCls=new pt(this),this.hBondCls=new mt(this),this.piHalogenCls=new ut(this),this.saltbridgeCls=new gt(this),this.loadPDBCls=new ds(this),this.vastplusCls=new cs(this),this.transformCls=new Os(this),this.setStyleCls=new ft(this),this.setColorCls=new bt(this),this.threeDPrintCls=new Ts(this),this.export3DCls=new Es(this),this.annoCddSiteCls=new vt(this),this.annoContactCls=new _t(this),this.annoPTMCls=new wt(this),this.annoCrossLinkCls=new St(this),this.annoDomainCls=new At(this),this.annoSnpClinVarCls=new xt(this),this.annoSsbondCls=new kt(this),this.annoTransMemCls=new Ot(this),this.domain3dCls=new Rt(this),this.addTrackCls=new It(this),this.annotationCls=new Tt(this),this.showAnnoCls=new Et(this),this.showSeqCls=new Pt(this),this.hlSeqCls=new Mt(this),this.hlUpdateCls=new Dt(this),this.lineGraphCls=new Ft(this),this.getGraphCls=new Nt(this),this.showInterCls=new qt(this),this.viewInterPairsCls=new Ut(this),this.drawGraphCls=new $t(this),this.contactMapCls=new jt(this),this.alignParserCls=new Bt(this),this.chainalignParserCls=new zt(this),this.dsn6ParserCls=new Gt(this),this.ccp4ParserCls=new Vt(this),this.mtzParserCls=new Xt(this),this.mmcifParserCls=new Kt(this),this.mmdbParserCls=new Jt(this),this.mmtfParserCls=new Qt(this),this.mol2ParserCls=new Zt(this),this.opmParserCls=new es(this),this.pdbParserCls=new ts(this),this.sdfParserCls=new ss(this),this.xyzParserCls=new is(this),this.realignParserCls=new ns(this),this.densityCifParserCls=new ls(this),this.ParserUtilsCls=new rs(this),this.loadAtomDataCls=new os(this),this.setSeqAlignCls=new as(this),this.applyCommandCls=new hs(this),this.definedSetsCls=new ps(this),this.legendTableCls=new yt(this),this.loadScriptCls=new ms(this),this.selByCommCls=new us(this),this.selectionCls=new gs(this),this.resid2specCls=new fs(this),this.delphiCls=new Cs(this),this.dsspCls=new ys(this),this.refnumCls=new Lt(this),this.scapCls=new vs(this),this.symdCls=new _s(this),this.alignSWCls=new ws(this),this.analysisCls=new Ss(this),this.resizeCanvasCls=new ks(this),this.saveFileCls=new Rs(this),this.setOptionCls=new Ct(this),this.shareLinkCls=new Is(this),this.diagram2dCls=new As(this),this.cartoon2dCls=new xs(this),this.rayCls=new Ps(this),this.controlCls=new Ms(this),this.pickingCls=new Ds(this),this.VRButtonCls=new Hs(this),this.ARButtonCls=new Fs(this),this.matShader=this.setColorCls.setOutlineColor("yellow")}}Ls.prototype.init=function(e){this.init_base(),this.molTitle="",this.ssbondpnts={},this.clbondpnts={},this.biomtMatrices=[],this.bAssembly=!0,this.bDrawn=!1,this.bSecondaryStructure=!1,this.bHighlight=1,this.axes=[]},Ls.prototype.init_base=function(e){this.resetConfig(),this.structures={},this.chains={},this.tddomains={},this.residues={},this.secondaries={},this.alnChains={},this.chainsSeq={},this.chainsColor={},this.chainsGene={},this.chainsAn={},this.chainsAnTitle={},this.chainsMapping={},this.resid2refnum={},this.residIgLoop={},this.refnum2residArray={},this.bShowRefnum=!1,this.alnChainsSeq={},this.alnChainsAnno={},this.alnChainsAnTtl={},this.pickedAtomList={},this.prevHighlightObjects=[],this.prevHighlightObjects_ghost=[],this.prevSurfaces=[],this.prevMaps=[],this.prevEmmaps=[],this.prevPhimaps=[],this.prevOtherMesh=[],this.defNames2Residues={},this.defNames2Atoms={},this.defNames2Descr={},this.defNames2Command={},this.residueId2Name={},this.atoms={},this.dAtoms={},this.hAtoms={},this.proteins={},this.sidec={},this.ntbase={},this.nucleotides={},this.nucleotidesO3={},this.chemicals={},this.ions={},this.water={},this.calphas={},this.hbondpnts=[],this.saltbridgepnts=[],this.contactpnts=[],this.stabilizerpnts=[],this.halogenpnts=[],this.picationpnts=[],this.pistackingpnts=[],this.distPnts=[],this.doublebonds={},this.triplebonds={},this.aromaticbonds={},this.atomPrevColors={},this.style2atoms={},this.labels={},this.lines={},this.resids2inter={},this.resids2interAll={},this.transformCls.rotateCount=0,this.transformCls.rotateCountMax=20,e&&(this.commands=[]),this.axes=[],this.bGlycansCartoon=0,this.bMembrane=1,this.bCmdWindow=0,this.chainMissingResidueArray={},this.nTotalGap=0},Ls.prototype.reinitAfterLoad=function(){let e=this,t=e.icn3dui;e.resetConfig(),e.setStyleCls.setAtomStyleByOptions(),e.setColorCls.setColorByOptions(e.opts,e.atoms),e.dAtoms=t.hashUtilsCls.cloneHash(e.atoms),e.hAtoms=t.hashUtilsCls.cloneHash(e.atoms),e.prevHighlightObjects=[],e.prevHighlightObjects_ghost=[],e.prevSurfaces=[],e.prevMaps=[],e.prevEmmaps=[],e.prevPhimaps=[],e.prevOtherMesh=[],e.labels={},e.lines={},e.shapeCmdHash={},e.bAssembly=!0},Ls.prototype.resetConfig=function(){let e=this,t=e.icn3dui;if(this.opts=t.hashUtilsCls.cloneHash(this.optsOri),void 0===t.cfg.align&&void 0===t.cfg.chainalign||(this.opts.color="identity",this.opts.proteins="c alpha trace",this.opts.nucleotides="o3 trace"),void 0!==t.cfg.cid&&(this.opts.color="atom",this.opts.pk="atom",this.opts.chemicals="ball and stick"),(void 0!==t.cfg.afid||e.bEsmfold)&&(this.opts.color="confidence"),void 0!==t.cfg.blast_rep_id&&(this.opts.color="conservation"),void 0!==t.cfg.mmdbafid){let s=t.cfg.mmdbafid.split(",");if(s.length>1)e.opts.color="structure";else if(1==s.length){let t=s[0];isNaN(t)&&t.length>5?this.opts.color="confidence":e.opts.color="chain"}}void 0!==t.cfg.options&&$.extend(this.opts,t.cfg.options)};class Ns{constructor(e){this.cfg=e,this.pre=this.cfg.divid+"_",this.REVISION="3.29.0",this.bNode=Object.keys(window).length<2,void 0===this.cfg.command&&(this.cfg.command=""),void 0===this.cfg.width&&(this.cfg.width="100%"),void 0===this.cfg.height&&(this.cfg.height="100%"),void 0===this.cfg.resize&&(this.cfg.resize=!0),void 0===this.cfg.showmenu&&(this.cfg.showmenu=!0),void 0===this.cfg.showtitle&&(this.cfg.showtitle=!0),void 0===this.cfg.showcommand&&(this.cfg.showcommand=!0),void 0===this.cfg.mobilemenu&&(this.cfg.mobilemenu=!1),void 0===this.cfg.imageonly&&(this.cfg.imageonly=!1),void 0===this.cfg.closepopup&&(this.cfg.closepopup=!1),void 0===this.cfg.showanno&&(this.cfg.showanno=!1),void 0===this.cfg.showseq&&(this.cfg.showseq=!1),void 0===this.cfg.showalignseq&&(this.cfg.showalignseq=!1),void 0===this.cfg.show2d&&(this.cfg.show2d=!1),void 0===this.cfg.showsets&&(this.cfg.showsets=!1),void 0===this.cfg.rotate&&(this.cfg.rotate="right"),void 0===this.cfg.hidelicense&&(this.cfg.hidelicense=!1),this.hashUtilsCls=new t(this),this.utilsCls=new s(this),this.parasCls=new i(this),this.myEventCls=new n(this),this.rmsdSuprCls=new l(this),this.subdivideCls=new r(this),this.convertTypeCls=new o(this),this.htmlCls=new g(this)}allCustomEvents(){}}Ns.prototype.show3DStructure=async function(e){let t=this;t.cfg.menuicon?(t.htmlCls.wifiStr=' ',t.htmlCls.licenseStr=' '):(t.htmlCls.wifiStr="",t.htmlCls.licenseStr=""),t.setIcn3d();let s=t.icn3d;t.utilsCls.isSessionStorageSupported()&&s.setStyleCls.getCommandsBeforeCrash();let i=t.htmlCls.WIDTH,n=t.htmlCls.HEIGHT;t.oriWidth=i,t.oriHeight=n,t.htmlCls.eventsCls.allEventFunctions(),this.allCustomEvents();let l=0;if((null==t.cfg.showmenu||t.cfg.showmenu)&&(l+=t.htmlCls.MENU_HEIGHT),(null==t.cfg.showcommand||t.cfg.showcommand)&&(l+=t.htmlCls.CMD_HEIGHT),null!=t.cfg.showmenu&&0==t.cfg.showmenu?t.htmlCls.setMenuCls.hideMenu():t.htmlCls.setMenuCls.showMenu(),null!=t.cfg.showtitle&&0==t.cfg.showtitle?$("#"+s.pre+"title").hide():$("#"+s.pre+"title").show(),$("#"+s.pre+"viewer").width(i).height(parseInt(n)+l),$("#"+s.pre+"canvas").width(i).height(parseInt(n)),$("#"+s.pre+"canvas").resizable({resize:function(e,i){t.htmlCls.WIDTH=i.size.width,t.htmlCls.HEIGHT=i.size.height,void 0===s||t.icn3d.bFullscreen||s.resizeCanvasCls.resizeCanvas(t.htmlCls.WIDTH,t.htmlCls.HEIGHT,!0)}}),void 0!==t.cfg.usepdbnum?t.icn3d.bUsePdbNum=t.cfg.usepdbnum:void 0!==t.cfg.date?t.icn3d.bUsePdbNum=parseInt(t.cfg.date)>=20201222:"1tup"==t.cfg.mmdbid&&1==t.cfg.showanno&&1==t.cfg.show2d&&1==t.cfg.showsets||"118496"==t.cfg.mmdbid&&0==t.cfg.showanno&&-1!=t.cfg.inpara.indexOf("bu=1")||"163605,1,91105,1,1,1"==t.cfg.align&&-1!=t.cfg.inpara.indexOf("atype=1")?t.icn3d.bUsePdbNum=!1:t.icn3d.bUsePdbNum=!0,t.cfg.replay?(s.bReplay=1,$("#"+s.pre+"replay").show()):(s.bReplay=0,$("#"+s.pre+"replay").hide()),t.utilsCls.isMobile()&&(s.threshbox=60),t.cfg.controlGl&&(s.bControlGl=!0,s.container=s.bControlGl&&!t.bNode?$(document):$("#"+s.id)),s.setStyleCls.handleContextLost(),s.applyCenterCls.setWidthHeight(i,n),s.ori_chemicalbinding=s.opts.chemicalbinding,void 0!==t.cfg.bCalphaOnly&&(s.bCalphaOnly=t.cfg.bCalphaOnly),s.opts=t.hashUtilsCls.cloneHash(s.opts),s.STATENUMBER=s.commands.length,t.utilsCls.isSessionStorageSupported()&&s.bCrashed){s.bCrashed=!1;let e=s.commandsBeforeCrash.split("|||")[0],i=e.substr(e.lastIndexOf(" ")+1);if(i===t.cfg.mmtfid||i===t.cfg.pdbid||i===t.cfg.opmid||i===t.cfg.mmdbid||i===t.cfg.gi||i===t.cfg.blast_rep_id||i===t.cfg.cid||i===t.cfg.mmcifid||i===t.cfg.align||i===t.cfg.chainalign||i===t.cfg.mmdbafid)return void await s.loadScriptCls.loadScript(s.commandsBeforeCrash,!0)}if(s.molTitle="",s.loadCmd,t.htmlCls.clickMenuCls.getHiddenMenusFromCache(),t.htmlCls.clickMenuCls.applyShownMenus(),e){if(s.init(),s.bInputfile=!0,s.InputfileType="pdb",s.InputfileData=s.InputfileData?s.InputfileData+"\nENDMDL\n"+e:e,await s.pdbParserCls.loadPdbData(e),void 0!==t.cfg.resdef&&void 0!==t.cfg.chains){let e=Object.keys(s.structures),i=t.cfg.chains.split(" | "),n=[];if(e.length==i.length){for(let t=0,s=e.length;t0&&(l+=","),l+=n[e].substr(0,n[e].indexOf("_"));s.chainidArray=[e].concat(n),s.chainidArray=s.chainalignParserCls.addPostfixForChainids(s.chainidArray),t.htmlCls.clickMenuCls.setLogCmd("resdef "+t.cfg.resdef,!0),s.loadCmd="vast_search_chainid "+s.chainidArray,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),s.bMmdbafid=!0;let r=!0;await s.chainalignParserCls.downloadMmdbAf(l,r)}}else if(void 0!==t.cfg.url){s.bInputUrlfile=!0;let e=t.cfg.url.split("|"),i=e[0],n=e[1];s.molTitle="",s.inputid=n,s.inputurl="type="+i+"&url="+encodeURIComponent(n),s.loadCmd="load url "+n+" | type "+i,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.pdbParserCls.downloadUrl(n,i,t.cfg.command)}else if(void 0!==t.cfg.mmtfid)s.inputid=t.cfg.mmtfid,s.loadCmd="load mmtf "+t.cfg.mmtfid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmtfParserCls.downloadMmtf(t.cfg.mmtfid);else if(void 0!==t.cfg.pdbid)s.inputid=t.cfg.pdbid,s.loadCmd="load pdb "+t.cfg.pdbid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.pdbParserCls.downloadPdb(t.cfg.pdbid);else if(void 0!==t.cfg.afid){s.inputid=t.cfg.afid,s.loadCmd="load af "+t.cfg.afid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0);let e=!0;await s.pdbParserCls.downloadPdb(t.cfg.afid,e)}else if(void 0!==t.cfg.opmid)s.inputid=t.cfg.opmid,s.loadCmd="load opm "+t.cfg.opmid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.opmParserCls.downloadOpm(t.cfg.opmid);else if(void 0!==t.cfg.mmdbid)s.inputid=t.cfg.mmdbid,s.loadCmd="load mmdb "+t.cfg.mmdbid+" | parameters "+t.cfg.inpara,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmdbParserCls.downloadMmdb(t.cfg.mmdbid);else if(void 0!==t.cfg.gi)s.loadCmd="load gi "+t.cfg.gi,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmdbParserCls.downloadGi(t.cfg.gi);else if(void 0!==t.cfg.refseqid)s.inputid=t.cfg.refseqid,s.loadCmd="load refseq "+t.cfg.refseqid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmdbParserCls.downloadRefseq(t.cfg.refseqid);else if(void 0!==t.cfg.protein)s.inputid=t.cfg.protein,s.loadCmd="load protein "+t.cfg.protein,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmdbParserCls.downloadProteinname(t.cfg.protein);else if(void 0!==t.cfg.blast_rep_id)if(s.inputid=t.cfg.query_id+","+t.cfg.blast_rep_id,t.cfg.oriQuery_id=t.cfg.query_id,t.cfg.oriBlast_rep_id=t.cfg.blast_rep_id,"Query"!==t.cfg.query_id.substr(0,5)&&void 0===t.cfg.rid)"icn3d"==t.cfg.from&&"1TSR_A"==t.cfg.blast_rep_id&&"NP_001108451.1"==t.cfg.query_id&&(t.cfg.command="view annotations; set annotation cdd; set annotation site; set view detailed view; select chain 1TSR_A; show selection"),"smithwm"==t.cfg.alg?(s.loadCmd="load seq_struct_ids_smithwm "+t.cfg.query_id+","+t.cfg.blast_rep_id,s.bSmithwm=!0):"local_smithwm"==t.cfg.alg?(s.loadCmd="load seq_struct_ids_local_smithwm "+t.cfg.query_id+","+t.cfg.blast_rep_id,s.bLocalSmithwm=!0):(s.loadCmd="load seq_struct_ids "+t.cfg.query_id+","+t.cfg.blast_rep_id,s.bSmithwm=!1,s.bLocalSmithwm=!1),t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.mmdbParserCls.downloadBlast_rep_id(t.cfg.query_id+","+t.cfg.blast_rep_id);else if(void 0!==t.cfg.rid){let e="https://blast.ncbi.nlm.nih.gov/Blast.cgi?RESULTS_FILE=on&FORMAT_TYPE=JSON2_S&FORMAT_OBJECT=Alignment&CMD=Get&RID="+t.cfg.rid,i=await t.getAjaxPromise(e,"json",!1,"The RID "+t.cfg.rid+" may have expired...");for(let e=0,n=i.BlastOutput2.length;e
    ",s="All atoms  ";e.utilsCls.setViewerWidthHeight(e),e.utilsCls.isMobile()||e.cfg.mobilemenu?e.htmlCls.setMenuCls.setTopMenusHtmlMobile(e.cfg.divid,t,s):e.htmlCls.setMenuCls.setTopMenusHtml(e.cfg.divid,t,s),e.icn3d=new Ls(e),e.icn3d.controlCls.setControl(),e.setDialogAjax()},Ns.prototype.getMmtfPromise=function(e){return new Promise((function(t,s){MMTF.fetch(e,(async function(e){t(e)}),(function(e){s("error")}))}))},Ns.prototype.getMmtfReducedPromise=function(e){return new Promise((function(t,s){MMTF.fetchReduced(e,(async function(e){t(e)}),(function(e){s("error")}))}))},Ns.prototype.getXMLHttpRqstPromise=function(e,t,s,i){let n=this;return new Promise((function(l,r){let o=new XMLHttpRequest;o.open(t,e,!0),o.responseType=s,o.onreadystatechange=function(){if(4==this.readyState)if(200==this.status){let e=o.response;l(e)}else"2fofc"==i||"fofc"==i?alert("Density server at EBI has no corresponding electron density map for this structure."):"em"==i?alert("Density server at EBI has no corresponding EM density map for this structure."):"rcsbEdmaps"==i?alert("RCSB server has no corresponding eletron density map for this structure."):alert("The "+i+" file is unavailable..."),r("error");else n.icn3d.ParserUtilsCls.showLoading()},o.send()}))},Ns.prototype.getAjaxPromise=function(e,t,s,i,n,l,r){let o=this;return new Promise((function(r,a){$.ajax({url:e,dataType:t,cache:!0,beforeSend:function(){s&&o.icn3d.ParserUtilsCls.showLoading()},complete:function(){l&&o.icn3d.ParserUtilsCls.hideLoading()},success:function(e){r(e)},error:function(){i&&alert(i),n&&console.log(n),a("error")}})}))},Ns.prototype.getAjaxPostPromise=async function(e,t,s,i,n,l,r,o){let a=this;return r=r||"json",new Promise((function(o,d){$.ajax({url:e,type:"POST",data:t,dataType:r,cache:!0,beforeSend:function(){s&&a.icn3d.ParserUtilsCls.showLoading()},complete:function(){l&&a.icn3d.ParserUtilsCls.hideLoading()},success:function(e){o(e)},error:function(){i&&alert(i),n&&console.log(n),d("error")}})}))},Ns.prototype.setDialogAjax=function(){this.bNode||$.ui.dialog.prototype._makeDraggableBase||($.ui.dialog.prototype._makeDraggableBase=$.ui.dialog.prototype._makeDraggable,$.ui.dialog.prototype._makeDraggable=function(){this._makeDraggableBase(),this.uiDialog.draggable("option","containment",!1)}),$.ajaxTransport("+binary",(function(e,t,s){if(window.FormData&&(e.dataType&&"binary"==e.dataType||e.data&&(window.ArrayBuffer&&e.data instanceof ArrayBuffer||window.Blob&&e.data instanceof Blob)))return{send:function(t,s){let i=new XMLHttpRequest,n=e.url,l=e.type,r=e.async||!0,o=e.responseType||"blob",a=e.data||null;i.addEventListener("load",(function(){let t={};t[e.dataType]=i.response,s(i.status,i.statusText,t,i.getAllResponseHeaders())})),i.open(l,n,r);for(let e in t)i.setRequestHeader(e,t[e]);i.responseType=o,i.send(a)},abort:function(){s.abort()}}}))};return e.ARButton=Fs,e.AddTrack=It,e.AlignParser=Bt,e.AlignSW=ws,e.AlignSeq=m,e.Alternate=ct,e.Analysis=Ss,e.AnnoCddSite=vt,e.AnnoContact=_t,e.AnnoCrossLink=St,e.AnnoDomain=At,e.AnnoSnpClinVar=xt,e.AnnoSsbond=kt,e.AnnoTransMem=Ot,e.Annotation=Tt,e.ApplyCenter=Ze,e.ApplyClbonds=et,e.ApplyCommand=hs,e.ApplyDisplay=st,e.ApplyMap=rt,e.ApplyOther=it,e.ApplySsbonds=nt,e.ApplySymd=lt,e.Axes=We,e.Box=Pe,e.Brick=Me,e.Camera=Te,e.CartoonNucl=ze,e.ChainalignParser=zt,e.ClickMenu=a,e.Contact=pt,e.Control=Ms,e.ConvertTypeCls=o,e.Curve=He,e.CurveStripArrow=De,e.Cylinder=Fe,e.DefinedSets=ps,e.Delphi=Cs,e.DensityCifParser=ls,e.Diagram2d=As,e.Dialog=c,e.Domain3d=Rt,e.Draw=ht,e.DrawGraph=$t,e.Dsn6Parser=Gt,e.Dssp=ys,e.ElectronMap=Je,e.Events=p,e.Export3D=Es,e.FirstAtomObj=bs,e.Fog=Ee,e.GetGraph=Nt,e.Glycan=Ye,e.HBond=mt,e.HashUtilsCls=t,e.HlObjects=Ht,e.HlSeq=Mt,e.HlUpdate=Dt,e.Html=g,e.Impostor=at,e.Instancing=dt,e.Label=Ve,e.Line=Le,e.LineGraph=Ft,e.LoadAtomData=os,e.LoadPDB=ds,e.LoadScript=ms,e.MarchingCube=Xe,e.MmcifParser=Kt,e.MmdbParser=Jt,e.MmtfParser=Qt,e.Mol2Parser=Zt,e.MyEventCls=n,e.OpmParser=es,e.ParasCls=i,e.ParserUtils=rs,e.PdbParser=ts,e.PiHalogen=ut,e.Picking=Ds,e.ProteinSurface=Ke,e.Ray=Ps,e.RealignParser=ns,e.Refnum=Lt,e.ReprSub=Ne,e.Resid2spec=fs,e.ResidueLabels=ot,e.ResizeCanvas=ks,e.RmsdSuprCls=l,e.Saltbridge=gt,e.SaveFile=Rs,e.Scap=vs,e.Scene=Ie,e.SdfParser=ss,e.SelectByCommand=us,e.Selection=gs,e.SetColor=bt,e.SetDialog=h,e.SetHtml=u,e.SetMenu=d,e.SetOption=Ct,e.SetSeqAlign=as,e.SetStyle=ft,e.ShareLink=Is,e.ShowAnno=Et,e.ShowInter=qt,e.ShowSeq=Pt,e.Sphere=qe,e.Stick=Ue,e.Strand=$e,e.Strip=je,e.SubdivideCls=r,e.Surface=Qe,e.Symd=_s,e.ThreeDPrint=Ts,e.Transform=Os,e.Tube=Be,e.UtilsCls=s,e.VRButton=Hs,e.Vastplus=cs,e.ViewInterPairs=Ut,e.XyzParser=is,e.iCn3D=Ls,e.iCn3DUI=Ns,e.printMsg=class{constructor(){console.log("This is a message from the icn3d package")}},Object.defineProperty(e,"__esModule",{value:!0}),e}({}); diff --git a/build/icn3d.module.js b/build/icn3d.module.js index f97f50fc..125799b0 100644 --- a/build/icn3d.module.js +++ b/build/icn3d.module.js @@ -8192,6 +8192,8 @@ class ClickMenu { let sigma2fofc = parseFloat($("#" + me.pre + "sigma2fofc" ).val()); let type = '2fofc'; await ic.dsn6ParserCls.dsn6Parser(ic.inputid, type, sigma2fofc); + //ic.densityCifParserCls.densityCifParser(ic.inputid, type, sigma2fofc); + //ic.setOptionCls.setOption('map', '2fofc'); thisClass.setLogCmd('set map 2fofc sigma ' + sigma2fofc, true); }); @@ -9454,6 +9456,8 @@ class SetMenu { html += this.getLink('mn1_dsn6url', 'URL(CORS) ' + me.htmlCls.wifiStr, undefined, 3); html += ""; + html += "

  • "; + html += ""; html += ""; @@ -11876,24 +11880,18 @@ class SetDialog { html += me.htmlCls.divStr + "dl_dsn6' class='" + dialogClass + "'>"; html += this.addNotebookTitle('dl_dsn6', 'Load a map file'); - html += "Note: Always load a PDB file before loading map files.


    "; - - html += "2fofc contour at: σ
    "; - html += me.htmlCls.inputFileStr + "id='" + me.pre + "dsn6file2fofc'> " + me.htmlCls.buttonStr + "reload_dsn6file2fofc' style='margin: 6px 20px 0 0;'>Load DSN6


    "; - //html += me.htmlCls.inputFileStr + "id='" + me.pre + "dsn6file2fofc'> " + me.htmlCls.buttonStr + "reload_dsn6file2fofc' style='margin: 6px 20px 0 0;'>Load DSN6" + me.htmlCls.buttonStr + "reload_ccp4file2fofc' style='margin-top: 6px;'>Load CCP4


    "; + html += "Note: Always load a PDB file before loading map files. If you don't specify the threshold
    below, a default one will be chosen.


    "; - html += "fofc contour at: σ
    "; - html += me.htmlCls.inputFileStr + "id='" + me.pre + "dsn6filefofc'> " + me.htmlCls.buttonStr + "reload_dsn6filefofc' style='margin: 6px 20px 0 0;'>Load DSN6


    "; - //html += me.htmlCls.inputFileStr + "id='" + me.pre + "dsn6filefofc'> " + me.htmlCls.buttonStr + "reload_dsn6filefofc' style='margin: 6px 20px 0 0;'>Load DSN6" + me.htmlCls.buttonStr + "reload_ccp4filefofc' style='margin-top: 6px;'>Load CCP4


    "; + //html += me.htmlCls.inputFileStr + "id='" + me.pre + "dsn6filefofc'> " + me.htmlCls.buttonStr + "reload_dsn6filefofc' style='margin: 6px 20px 0 0;'>Load DSN6


    "; + html += me.htmlCls.inputFileStr + "id='" + me.pre + "dsn6filefofc'> " + me.htmlCls.buttonStr + "reload_dsn6filefofc' style='margin: 6px 20px 0 0;'>Load DSN6" + me.htmlCls.buttonStr + "reload_ccp4filefofc' style='margin: 6px 20px 0 0;'>Load CCP4" + me.htmlCls.buttonStr + "reload_mtzfilefofc' style='margin-top: 6px;'>Load MTZ


    "; html += me.htmlCls.buttonStr + "elecmapNo4'>Remove Map
    "; @@ -11901,21 +11899,17 @@ class SetDialog { html += me.htmlCls.divStr + "dl_dsn6url' class='" + dialogClass + "'>"; html += this.addNotebookTitle('dl_dsn6url', 'Load a selection file via a URL'); - html += "Note: Always load a PDB file before loading map files.


    "; - - html += "2fofc contour at: σ
    "; - html += "URL in the same host: " + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6fileurl2fofc' size=20>" + me.htmlCls.space3 + me.htmlCls.buttonStr + "reload_dsn6fileurl2fofc' style='margin-top: 6px;'>Load


    "; + html += "2fofc contour at default threshold or at: " + + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6sigmaurl2fofc' value='' size=8> σ
    "; - html += "fofc contour at: σ
    "; - html += "URL in the same host: " + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6fileurlfofc' size=20>" + me.htmlCls.space3 + me.htmlCls.buttonStr + "reload_dsn6fileurlfofc' style='margin-top: 6px;'>Load


    "; + html += "URL in the same host: " + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6fileurlfofc' size=20>" + me.htmlCls.space3 + me.htmlCls.buttonStr + "reload_dsn6fileurlfofc' style='margin: 6px 20px 0 0;'>Load DSN6" + me.htmlCls.buttonStr + "reload_ccp4fileurlfofc' style='margin: 6px 20px 0 0;'>Load CCP4" + me.htmlCls.buttonStr + "reload_mtzfileurlfofc' style='margin-top: 6px;'>Load MTZ


    "; html += me.htmlCls.buttonStr + "elecmapNo5'>Remove Map
    "; @@ -12255,6 +12249,7 @@ class SetDialog { html += this.addNotebookTitle('dl_elecmap2fofc', 'Electron Density 2F0-Fc Map'); html += "Contour at: σ " + me.htmlCls.buttonStr + "applymap2fofc'>Display " + me.htmlCls.buttonStr + "elecmapNo2'>Remove Map"; @@ -12901,7 +12896,7 @@ class Events { } } - readFile(bAppend, files, index, dataStrAll) { let me = this.icn3dui, ic = me.icn3d, thisClass = this; + async readFile(bAppend, files, index, dataStrAll) { let me = this.icn3dui, ic = me.icn3d, thisClass = this; let file = files[index]; let commandName = (bAppend) ? 'append': 'load'; @@ -12938,7 +12933,20 @@ class Events { await ic.pdbParserCls.loadPdbData(dataStrAll, undefined, undefined, bAppend); } else { - thisClass.readFile(bAppend, files, index + 1, dataStrAll); + await thisClass.readFile(bAppend, files, index + 1, dataStrAll); + } + + if(bAppend) { + if(ic.bSetChainsAdvancedMenu) ic.definedSetsCls.showSets(); + //if(ic.bSetChainsAdvancedMenu) ic.legendTableCls.showSets(); + + ic.bResetAnno = true; + + if(ic.bAnnoShown) { + await ic.showAnnoCls.showAnnotations(); + + ic.annotationCls.resetAnnoTabAll(); + } } }; @@ -12973,13 +12981,7 @@ class Events { ic.dataStrAll = ''; - this.readFile(bAppend, files, 0, ''); - - if(bAppend) { - if(ic.bSetChainsAdvancedMenu) ic.definedSetsCls.showSets(); - //if(ic.bSetChainsAdvancedMenu) ic.legendTableCls.showSets(); - if(ic.bAnnoShown) await ic.showAnnoCls.showAnnotations(); - } + await this.readFile(bAppend, files, 0, ''); } } @@ -13063,7 +13065,10 @@ class Events { if(bStructures) { if(ic.bSetChainsAdvancedMenu) ic.definedSetsCls.showSets(); - if(ic.bAnnoShown) await ic.showAnnoCls.showAnnotations(); + if(ic.bAnnoShown) { + await ic.showAnnoCls.showAnnotations(); + ic.annotationCls.resetAnnoTabAll(); + } } } } @@ -14073,24 +14078,35 @@ class Events { me.myEventCls.onIds("#" + me.pre + "reload_dsn6file2fofc", "click", function(e) { let ic = me.icn3d; e.preventDefault(); - if(!me.cfg.notebook) dialog.dialog( "close" ); + //if(!me.cfg.notebook) dialog.dialog( "close" ); ic.dsn6ParserCls.loadDsn6File('2fofc'); }); me.myEventCls.onIds("#" + me.pre + "reload_dsn6filefofc", "click", function(e) { let ic = me.icn3d; e.preventDefault(); - if(!me.cfg.notebook) dialog.dialog( "close" ); + //if(!me.cfg.notebook) dialog.dialog( "close" ); ic.dsn6ParserCls.loadDsn6File('fofc'); }); me.myEventCls.onIds("#" + me.pre + "reload_ccp4file2fofc", "click", function(e) { let ic = me.icn3d; e.preventDefault(); - if(!me.cfg.notebook) dialog.dialog( "close" ); - ic.dsn6ParserCls.loadDsn6File('2fofc', true); + //if(!me.cfg.notebook) dialog.dialog( "close" ); + ic.ccp4ParserCls.loadCcp4File('2fofc'); }); me.myEventCls.onIds("#" + me.pre + "reload_ccp4filefofc", "click", function(e) { let ic = me.icn3d; e.preventDefault(); - if(!me.cfg.notebook) dialog.dialog( "close" ); - ic.dsn6ParserCls.loadDsn6File('fofc', true); + //if(!me.cfg.notebook) dialog.dialog( "close" ); + ic.ccp4ParserCls.loadCcp4File('fofc'); + }); + + me.myEventCls.onIds("#" + me.pre + "reload_mtzfile2fofc", "click", function(e) { let ic = me.icn3d; + e.preventDefault(); + //if(!me.cfg.notebook) dialog.dialog( "close" ); + ic.mtzParserCls.loadMtzFile('2fofc'); + }); + me.myEventCls.onIds("#" + me.pre + "reload_mtzfilefofc", "click", function(e) { let ic = me.icn3d; + e.preventDefault(); + //if(!me.cfg.notebook) dialog.dialog( "close" ); + ic.mtzParserCls.loadMtzFile('fofc'); }); me.myEventCls.onIds("#" + me.pre + "reload_delphifile", "click", async function(e) { let ic = me.icn3d; @@ -14182,15 +14198,37 @@ class Events { me.myEventCls.onIds("#" + me.pre + "reload_dsn6fileurl2fofc", "click", function(e) { let ic = me.icn3d; e.preventDefault(); - if(!me.cfg.notebook) dialog.dialog( "close" ); + //if(!me.cfg.notebook) dialog.dialog( "close" ); ic.dsn6ParserCls.loadDsn6FileUrl('2fofc'); }); me.myEventCls.onIds("#" + me.pre + "reload_dsn6fileurlfofc", "click", function(e) { let ic = me.icn3d; e.preventDefault(); - if(!me.cfg.notebook) dialog.dialog( "close" ); + //if(!me.cfg.notebook) dialog.dialog( "close" ); ic.dsn6ParserCls.loadDsn6FileUrl('fofc'); }); + me.myEventCls.onIds("#" + me.pre + "reload_ccp4fileurl2fofc", "click", function(e) { let ic = me.icn3d; + e.preventDefault(); + //if(!me.cfg.notebook) dialog.dialog( "close" ); + ic.ccp4ParserCls.loadCcp4FileUrl('2fofc'); + }); + me.myEventCls.onIds("#" + me.pre + "reload_ccp4fileurlfofc", "click", function(e) { let ic = me.icn3d; + e.preventDefault(); + //if(!me.cfg.notebook) dialog.dialog( "close" ); + ic.ccp4ParserCls.loadCcp4FileUrl('fofc'); + }); + + me.myEventCls.onIds("#" + me.pre + "reload_mtzfileurl2fofc", "click", function(e) { let ic = me.icn3d; + e.preventDefault(); + //if(!me.cfg.notebook) dialog.dialog( "close" ); + ic.mtzParserCls.loadMtzFileUrl('2fofc'); + }); + me.myEventCls.onIds("#" + me.pre + "reload_mtzfileurlfofc", "click", function(e) { let ic = me.icn3d; + e.preventDefault(); + //if(!me.cfg.notebook) dialog.dialog( "close" ); + ic.mtzParserCls.loadMtzFileUrl('fofc'); + }); + me.myEventCls.onIds("#" + me.pre + "reload_pdbfile", "click", async function(e) { me.icn3d; e.preventDefault(); @@ -15578,7 +15616,7 @@ class AlignSeq { // for(let i in ic.alnChains) { for (let m = 0, ml = alignChainArray.length; m < ml; ++m) { let i = alignChainArray[m]; - + if (index == 0) firstChainid = i; if (bOnechain && index > 0) { @@ -29353,8 +29391,8 @@ class ElectronMap { this.pLength = 0; this.cutRadius = 0; this.vpBits = null; // uint8 array of bitmasks - this.vpDistance = null; // floatarray of _squared_ distances - this.vpAtomID = null; // intarray + this.vpGridTrans = null; // array of translated number of grids + this.vpAtomID = null; // uint8 array this.vertnumber = 0; this.facenumber = 0; this.pminx = 0; @@ -29404,12 +29442,27 @@ ElectronMap.prototype.getFacesAndVertices = function(allatoms, atomlist) { atomsToShow[atomlist[i]] = 1; let vertices = this.verts; + let vertTrans = {}; for(i = 0, il = vertices.length; i < il; i++) { let r; if(this.type == 'phi') { r = new THREE.Vector3(vertices[i].x, vertices[i].y, vertices[i].z).multiplyScalar(1.0/this.header.scale).applyMatrix4(this.matrix); } else { + // ccp4 has no translation vector. Only translated vertices are used. + if(this.header.ccp4) { + let index = vertices[i].index; + let finalIndex; + if(this.vpGridTrans[index]) { + finalIndex = index; + + vertices[i].x += this.vpGridTrans[finalIndex][0] * this.header.xExtent * this.scaleFactor; + vertices[i].y += this.vpGridTrans[finalIndex][1] * this.header.xExtent * this.scaleFactor; + vertices[i].z += this.vpGridTrans[finalIndex][2] * this.header.xExtent * this.scaleFactor; + + vertTrans[finalIndex] = 1; + } + } r = new THREE.Vector3(vertices[i].x, vertices[i].y, vertices[i].z).applyMatrix4(this.matrix); } // vertices[i].x = r.x / this.scaleFactor - this.ptranx; @@ -29428,13 +29481,22 @@ ElectronMap.prototype.getFacesAndVertices = function(allatoms, atomlist) { let fa = this.faces[i], fb = this.faces[i+1], fc = this.faces[i+2]; if(fa !== fb && fb !== fc && fa !== fc){ - finalfaces.push({"a":fa, "b":fb, "c":fc}); + if(this.header.ccp4) { + // only transfered vertices will be used + if(vertTrans.hasOwnProperty(vertices[fa].index) && vertTrans.hasOwnProperty(vertices[fb].index) + && vertTrans.hasOwnProperty(vertices[fc].index)) { + finalfaces.push({"a":fa, "b":fb, "c":fc}); + } + } + else { + finalfaces.push({"a":fa, "b":fb, "c":fc}); + } } } //try to help the garbage collector this.vpBits = null; // uint8 array of bitmasks - this.vpDistance = null; // floatarray + this.vpGridTrans = null; // uint8 array this.vpAtomID = null; // intarray return { @@ -29493,6 +29555,8 @@ ElectronMap.prototype.initparm = function(inHeader, inData, inMatrix, inIsovalue this.cutRadius = this.probeRadius * this.scaleFactor; this.vpBits = new Uint8Array(this.pLength * this.pWidth * this.pHeight); + if(this.header.ccp4) this.vpGridTrans = new Array(this.pLength * this.pWidth * this.pHeight); + this.vpAtomID = new Uint8Array(this.pLength * this.pWidth * this.pHeight); }; @@ -29518,7 +29582,6 @@ ElectronMap.prototype.fillvoxels = function(atoms, atomlist) { //(int seqinit,in let i, j, k, il, jl, kl; for(i = 0, il = this.vpBits.length; i < il; i++) { this.vpBits[i] = 0; - //this.vpDistance[i] = -1.0; this.vpAtomID[i] = 0; } @@ -29680,6 +29743,7 @@ ElectronMap.prototype.fillvoxels = function(atoms, atomlist) { //(int seqinit,in } } else { + // let index2ori = {}; for(let serial in atomlist) { let atom = atoms[atomlist[serial]]; @@ -29710,6 +29774,7 @@ ElectronMap.prototype.fillvoxels = function(atoms, atomlist) { //(int seqinit,in for(i = 0, il = indexArray.length; i < il; ++i) { let index = indexArray[i]; + if(this.type == '2fofc') { this.vpBits[index] =(this.dataArray[index] >= this.isovalue) ? 1 : 0; //this.vpAtomID[index] =(this.dataArray[index] >= 0) ? 1 : 0; // determine whether it's positive @@ -29723,6 +29788,7 @@ ElectronMap.prototype.fillvoxels = function(atoms, atomlist) { //(int seqinit,in //this.vpAtomID[index] =(this.dataArray[index] >= 0) ? 1 : 0; // determine whether it's positive } } + } } @@ -29946,7 +30012,18 @@ class Surface { cfg.isovalue = ic.mapData.sigma2; cfg.type = '2fofc'; - ps = this.SetupMap(cfg); + //ccp4 + cfg.ccp4 = ic.mapData.ccp4; + cfg.grid = ic.mapData.grid2; + cfg.unit_cell = ic.mapData.unit_cell2; + + if(cfg.header || cfg.ccp4) ps = this.SetupMap(cfg); + else return; + + if(cfg.ccp4) { + ic.mapData = {}; + return; + } } else if(type == 12) { // fofc cfg.header = ic.mapData.header; @@ -29955,7 +30032,18 @@ class Surface { cfg.isovalue = ic.mapData.sigma; cfg.type = 'fofc'; - ps = this.SetupMap(cfg); + //ccp4 + cfg.ccp4 = ic.mapData.ccp4; + cfg.grid = ic.mapData.grid; + cfg.unit_cell = ic.mapData.unit_cell; + + if(cfg.header || cfg.ccp4) ps = this.SetupMap(cfg); + else return; + + if(cfg.ccp4) { + ic.mapData = {}; + return; + } } else if(type == 13) { // em cfg.maxdist = 3; // EM map has no unit cell. It could include more gird space. @@ -30443,29 +30531,60 @@ class Surface { } SetupMap(data) { let ic = this.icn3d; ic.icn3dui; - let ps = new ElectronMap(ic); - - ps.initparm(data.header, data.data, data.matrix, data.isovalue, data.center, data.maxdist, - data.pmin, data.pmax, data.water, data.type, data.rmsd_supr, data.loadPhiFrom, data.icn3d); + if(data.ccp4) { + let radius = 10; + let center = (ic.center) ? [ic.center.x, ic.center.y, ic.center.z] : [0,0,0]; + + let typeDetail; + if(data.type == '2fofc') { + typeDetail = '2fofc'; + let result = ic.ccp4ParserCls.extract_block(data.grid, data.unit_cell, radius, center, typeDetail); + let iso = ic.ccp4ParserCls.marchingCubes(result.size, result.values, result.points, data.isovalue, 'marching cubes'); + ic.ccp4ParserCls.makeChickenWire(iso, typeDetail); + + result = null; + iso = null; + } + else if(data.type == 'fofc') { + typeDetail = 'fofc_neg'; + let result = ic.ccp4ParserCls.extract_block(data.grid, data.unit_cell, radius, center, typeDetail); + let iso = ic.ccp4ParserCls.marchingCubes(result.size, result.values, result.points, data.isovalue, 'marching cubes'); + ic.ccp4ParserCls.makeChickenWire(iso, typeDetail); + + typeDetail = 'fofc_pos'; + result = ic.ccp4ParserCls.extract_block(data.grid, data.unit_cell, radius, center, typeDetail); + iso = ic.ccp4ParserCls.marchingCubes(result.size, result.values, result.points, data.isovalue, 'marching cubes'); + ic.ccp4ParserCls.makeChickenWire(iso, typeDetail); - ps.fillvoxels(data.allatoms, data.extendedAtoms); + result = null; + iso = null; + } + } + else { + let ps = new ElectronMap(ic); + + ps.initparm(data.header, data.data, data.matrix, data.isovalue, data.center, data.maxdist, + data.pmin, data.pmax, data.water, data.type, data.rmsd_supr, data.loadPhiFrom, data.icn3d); - if(!data.header.bSurface) ps.buildboundary(); + ps.fillvoxels(data.allatoms, data.extendedAtoms); - if(!data.header.bSurface) ps.marchingcube(); - - ps.vpBits = null; // uint8 array of bitmasks - //ps.vpDistance = null; // floatarray of _squared_ distances - ps.vpAtomID = null; // intarray + if(!data.header.bSurface) ps.buildboundary(); - let result; + if(!data.header.bSurface) ps.marchingcube(); + + ps.vpBits = null; // uint8 array of bitmasks + //ps.vpDistance = null; // floatarray of _squared_ distances + ps.vpAtomID = null; // intarray - if(!data.header.bSurface) result = ps.getFacesAndVertices(data.allatoms, data.atomsToShow); + let result; - ps.faces = null; - ps.verts = null; + if(!data.header.bSurface) result = ps.getFacesAndVertices(data.allatoms, data.atomsToShow); - return result; + ps.faces = null; + ps.verts = null; + + return result; + } } } @@ -35952,7 +36071,7 @@ class SetColor { for(let resid in residueHash) { if(!ic.resid2refnum[resid]) { - color = me.parasCls.thr('#FFFFFF'); + color = me.parasCls.thr('#00FFFF'); //('#FFFFFF'); } else { let refnumLabel = ic.resid2refnum[resid]; @@ -35987,7 +36106,7 @@ class SetColor { let residueHash = ic.firstAtomObjCls.getResiduesFromAtoms(atoms); for(let resid in residueHash) { if(!ic.resid2refnum[resid]) { - color = me.parasCls.thr('#FFFFFF'); + color = me.parasCls.thr('#00FFFF'); //('#FFFFFF'); } else { let refnumLabel = ic.resid2refnum[resid]; @@ -38200,14 +38319,14 @@ class AnnoDomain { let pdbid = pdbArray[index]; //let url = me.htmlCls.baseUrl + "mmdb/mmdb_strview.cgi?v=2&program=icn3d&domain&molinfor&uid=" + pdbid; - if(index == 0 && ic.mmdb_data !== undefined) { + if(!ic.bResetAnno && index == 0 && ic.mmdb_data !== undefined) { for(let chnid in ic.protein_chainid) { if(chnid.indexOf(pdbid) !== -1) { this.showDomainWithData(chnid, ic.mmdb_data); } } } - else if(ic.mmdb_dataArray[index] !== undefined) { + else if(!ic.bResetAnno && ic.mmdb_dataArray[index] !== undefined) { for(let chnid in ic.protein_chainid) { if(chnid.indexOf(pdbid) !== -1) { this.showDomainWithData(chnid, ic.mmdb_dataArray[index]); @@ -39294,6 +39413,9 @@ class Domain3d { //this.dcut = 7; // threshold for C-alpha interactions this.dcut = 8; // threshold for C-alpha interactions + // added by Jiyao + this.min_contacts = 5; //3; // minimum number of contacts to be considered as neighbors + this.MAX_SSE = 512; //let this.ctc_cnt[this.MAX_SSE][this.MAX_SSE]; // contact count matrix @@ -39326,9 +39448,6 @@ class Domain3d { this.c_delta = 3; // cut set parameter this.nc_fact = 0.0; // size factor for internal contacts - // added by Jiyao - this.min_contacts = 3; // minimum number of contacts to be considered as neighbors - //let this.elements[2*this.MAX_SSE]; // sets of this.elements to be split this.elements = []; this.elements.length = 2*this.MAX_SSE; @@ -44182,8 +44301,10 @@ class ShowSeq { let result = ic.refnumCls.getTemplateList(chnid); let refpdbnameList = result.refpdbnameList; let scoreList = result.scoreList; + let seqidList = result.seqidList; + let nresAlignList = result.nresAlignList; - let refStruTitle = (refpdbnameList) ? "based on " + refpdbnameList + ". The TM-scores are " + scoreList + "." : ""; + let refStruTitle = (refpdbnameList) ? "based on " + refpdbnameList + ". The TM-score(s) is(are) " + scoreList + ". The sequence identitie(s) is(are) " + seqidList + ". The number of aligned residue(s) is(are) " + nresAlignList + "." : ""; let htmlTmp = '
    '; htmlTmp += '
    '; @@ -46805,13 +46926,22 @@ class LineGraph { if(i < il - 1) refpdbnameList += ", "; } - let scoreList = ''; + let scoreList = '', seqidList = '', nresAlignList = ''; for(let i = 0, il = domainidArray.length; i < il; ++i) { - scoreList += domainid2score[domainidArray[i]]; - if(i < il - 1) scoreList += ", "; + let itemArray = domainid2score[domainidArray[i]].split('_'); + + scoreList += itemArray[0]; + seqidList += itemArray[1]; + nresAlignList += itemArray[2]; + + if(i < il - 1) { + scoreList += ", "; + seqidList += ", "; + nresAlignList += ", "; + } } - return {'refpdbnameList': refpdbnameList, 'scoreList': scoreList}; + return {'refpdbnameList': refpdbnameList, 'scoreList': scoreList, 'seqidList': seqidList, 'nresAlignList': nresAlignList}; } async parseAlignData(dataArray, domainidpairArray, bRound1) { let ic = this.icn3d, me = ic.icn3dui; @@ -46906,28 +47036,15 @@ class LineGraph { if(!bRound1) { console.log("domainid: " + domainid); - - if(!ic.domainid2score.hasOwnProperty(domainid) || queryData[0].score >= ic.domainid2score[domainid]) { - ic.domainid2score[domainid] = queryData[0].score; - - ic.domainid2refpdbname[domainid] = refpdbname; - domainid2segs[domainid] = queryData[0].segs; - ic.domainid2ig2kabat[domainid] = queryData[0].ig2kabat; - ic.domainid2ig2imgt[domainid] = queryData[0].ig2imgt; - } } - else { - //let mixScore = 10 / queryData[0].super_rmsd + queryData[0].num_seg / 5; - let mixScore = queryData[0].score; - if(!ic.domainid2score.hasOwnProperty(domainid) || mixScore > ic.domainid2score[domainid]) { - ic.domainid2score[domainid] = mixScore; - - ic.domainid2refpdbname[domainid] = refpdbname; - domainid2segs[domainid] = queryData[0].segs; - ic.domainid2ig2kabat[domainid] = queryData[0].ig2kabat; - ic.domainid2ig2imgt[domainid] = queryData[0].ig2imgt; - } + if(!ic.domainid2score.hasOwnProperty(domainid) || queryData[0].score >= ic.domainid2score[domainid].split('_')[0]) { + ic.domainid2score[domainid] = queryData[0].score + '_' + queryData[0].frac_identical + '_' + queryData[0].num_res ; + + ic.domainid2refpdbname[domainid] = refpdbname; + domainid2segs[domainid] = queryData[0].segs; + ic.domainid2ig2kabat[domainid] = queryData[0].ig2kabat; + ic.domainid2ig2imgt[domainid] = queryData[0].ig2imgt; } } @@ -46998,7 +47115,7 @@ class LineGraph { // end of round 2 return; } - + // combine domainid into chainid let processedChainid = {}; for(let domainid in ic.domainid2refpdbname) { @@ -47046,8 +47163,10 @@ class LineGraph { let result = this.getTemplateList(chainid); let refpdbnameList = result.refpdbnameList; let scoreList = result.scoreList; + let seqidList = result.seqidList; + let nresAlignList = result.nresAlignList; - let message = "The reference PDBs for chain " + chainid + " are " + refpdbnameList + ". The TM-scores are " + scoreList + "."; + let message = "The reference PDB(s) for chain " + chainid + " is(are) " + refpdbnameList + ". The TM-score(s) is(are) " + scoreList + ". The sequence identitie(s) is(are) " + seqidList + ". The number of aligned residue(s) is(are) " + nresAlignList + "."; if(!me.bNode) { console.log(message); me.htmlCls.clickMenuCls.setLogCmd(message, true); @@ -48683,7 +48802,7 @@ class ViewInterPairs { if(ic.bD3 === undefined) { //let url = "https://d3js.org/d3.v4.min.js"; - let url = "https://www.ncbi.nlm.nih.gov/Structure/icn3d/script/d3v4-force-all.min.js"; + let url = "./script/d3v4-force-all.min.js"; await me.getAjaxPromise(url, 'script'); ic.bD3 = true; @@ -49958,7 +50077,7 @@ class AlignParser { for(let j = 0, jl = mmdbTmp.molecules.length; j < jl; ++j) { let molecule = mmdbTmp.molecules[j]; let molid = molecule.moleculeId; - let chainName = molecule.chain.trim(); + let chainName = molecule.chain.trim().replace(/_/g, ''); // change "A_1" to "A1" if(chainNameHash[chainName] === undefined) { chainNameHash[chainName] = 1; } @@ -51252,10 +51371,10 @@ class Dsn6Parser { // https://edmaps.rcsb.org/maps/1kq2_fofc.dsn6 let url = "https://edmaps.rcsb.org/maps/" + pdbid.toLowerCase() + "_" + type + ".dsn6"; - await this.dsn6ParserBase(url, type, sigma); + await this.dsn6ParserBase(url, type, sigma, 'url', true); } - async dsn6ParserBase(url, type, sigma) { let ic = this.icn3d, me = ic.icn3dui; + async dsn6ParserBase(url, type, sigma, location, bInputSigma) { let ic = this.icn3d, me = ic.icn3dui; let thisClass = this; //https://stackoverflow.com/questions/33902299/using-jquery-ajax-to-download-a-binary-file @@ -51269,7 +51388,7 @@ class Dsn6Parser { } else { let arrayBuffer = await me.getXMLHttpRqstPromise(url, 'GET', 'arraybuffer', 'rcsbEdmaps'); - thisClass.loadDsn6Data(arrayBuffer, type, sigma); + sigma = thisClass.loadDsn6Data(arrayBuffer, type, sigma, location, bInputSigma); if(type == '2fofc') { ic.bAjax2fofc = true; @@ -51280,9 +51399,11 @@ class Dsn6Parser { ic.setOptionCls.setOption('map', type); } + + return sigma; } - loadDsn6Data(dsn6data, type, sigma) { let ic = this.icn3d; ic.icn3dui; + loadDsn6Data(dsn6data, type, sigma, location, bInputSigma) { let ic = this.icn3d; ic.icn3dui; // DSN6 http://www.uoxray.uoregon.edu/tnt/manual/node104.html // BRIX http://svn.cgl.ucsf.edu/svn/chimera/trunk/libs/VolumeData/dsn6/brix-1.html @@ -51331,9 +51452,9 @@ class Dsn6Parser { } } - header.zStart = intView[ 2 ]; header.xStart = intView[ 0 ]; // NXSTART header.yStart = intView[ 1 ]; + header.zStart = intView[ 2 ]; header.xExtent = intView[ 3 ]; // NX header.yExtent = intView[ 4 ]; @@ -51369,6 +51490,7 @@ class Dsn6Parser { let zBlocks = Math.ceil(header.zExtent / 8); // loop over blocks + let maxValue = -999; for(let zz = 0; zz < zBlocks; ++zz) { for(let yy = 0; yy < yBlocks; ++yy) { for(let xx = 0; xx < xBlocks; ++xx) { @@ -51384,6 +51506,7 @@ class Dsn6Parser { if(x < header.xExtent && y < header.yExtent && z < header.zExtent) { let idx =((((x * header.yExtent) + y) * header.zExtent) + z); data[ idx ] =(byteView[ offset ] - summand) / divisor; + if(data[ idx ] > maxValue) maxValue = data[ idx ]; ++offset; } else { offset += 8 - i; @@ -51396,6 +51519,10 @@ class Dsn6Parser { } } + if(!bInputSigma) { + sigma = this.setSigma(maxValue, location, type, sigma); + } + if(type == '2fofc') { ic.mapData.header2 = header; ic.mapData.data2 = data; @@ -51410,6 +51537,32 @@ class Dsn6Parser { ic.mapData.type = type; ic.mapData.sigma = sigma; } + + return sigma; + } + + setSigma(maxValue, location, type, sigma) { let ic = this.icn3d, me = ic.icn3dui; + let inputId; + if(location == 'file') { + inputId = 'dsn6sigma' + type; + } + else if(location == 'url') { + inputId = 'dsn6sigmaurl' + type; + } + + let factor = (type == '2fofc') ? 0.5 : 0.3; + + if(inputId) { + if(!($("#" + me.pre + inputId).val())) { + sigma = (factor * maxValue).toFixed(2); + $("#" + me.pre + inputId).val(sigma); + } + else { + sigma = $("#" + me.pre + inputId).val(); + } + } + + return sigma; } getMatrix(header) { let ic = this.icn3d; ic.icn3dui; @@ -51470,7 +51623,7 @@ class Dsn6Parser { return matrix; } - loadDsn6File(type, bCcp4) {var ic = this.icn3d, me = ic.icn3dui; + loadDsn6File(type) {var ic = this.icn3d, me = ic.icn3dui; let thisClass = this; let file = $("#" + ic.pre + "dsn6file" + type)[0].files[0]; @@ -51483,12 +51636,8 @@ class Dsn6Parser { let reader = new FileReader(); reader.onload = function(e) { let ic = thisClass.icn3d; let arrayBuffer = e.target.result; // or = reader.result; - if(bCcp4) { - ic.densityCifParserCls.parseChannels(arrayBuffer, type, sigma); - } - else { - thisClass.loadDsn6Data(arrayBuffer, type, sigma); - } + + sigma = thisClass.loadDsn6Data(arrayBuffer, type, sigma, 'file'); if(type == '2fofc') { ic.bAjax2fofc = true; @@ -51497,21 +51646,1006 @@ class Dsn6Parser { ic.bAjaxfofc = true; } ic.setOptionCls.setOption('map', type); - me.htmlCls.clickMenuCls.setLogCmd('load map file ' + $("#" + ic.pre + "dsn6file" + type).val(), false); + me.htmlCls.clickMenuCls.setLogCmd('load map file ' + $("#" + ic.pre + "dsn6file" + type).val() + ' with sigma ' + sigma, false); }; reader.readAsArrayBuffer(file); } } loadDsn6FileUrl(type) {var ic = this.icn3d, me = ic.icn3dui; + let url = $("#" + ic.pre + "dsn6fileurl" + type).val(); + let sigma = $("#" + ic.pre + "dsn6sigmaurl" + type).val(); + if(!url) { + alert("Please input the file URL before clicking 'Load'"); + } + else { + sigma = this.dsn6ParserBase(url, type, sigma, 'url'); + me.htmlCls.clickMenuCls.setLogCmd('set map ' + type + ' sigma ' + sigma + ' file dsn6 | ' + encodeURIComponent(url), true); + } + } + +} + +/** + * @file Ccp4 Parser + * @author Marcin Wojdyr + * @private + * Modified by Jiyao Wang / https://github.com/ncbi/icn3d + */ + +class Ccp4Parser { + constructor(icn3d) { + this.icn3d = icn3d; + } + + async ccp4ParserBase(url, type, sigma, location) { let ic = this.icn3d, me = ic.icn3dui; + let thisClass = this; + + //https://stackoverflow.com/questions/33902299/using-jquery-ajax-to-download-a-binary-file + // if(type == '2fofc' && ic.bAjax2fofcccp4) { + // ic.mapData.sigma2 = sigma; + // ic.setOptionCls.setOption('map', type); + // } + // else if(type == 'fofc' && ic.bAjaxfofcccp4) { + // ic.mapData.sigma = sigma; + // ic.setOptionCls.setOption('map', type); + // } + // else { + let arrayBuffer = await me.getXMLHttpRqstPromise(url, 'GET', 'arraybuffer', ''); + let bInputSigma = true; + sigma = thisClass.load_map_from_buffer(arrayBuffer, type, sigma, location, bInputSigma); + + // if(type == '2fofc') { + // ic.bAjax2fofcccp4 = true; + // } + // else if(type == 'fofc') { + // ic.bAjaxfofcccp4 = true; + // } + + ic.setOptionCls.setOption('map', type); + + return sigma; + // } + } + + // modified from_ccp4() at https://github.com/uglymol/uglymol.github.io/blob/master/src/elmap.js + load_map_from_buffer(buf, type, sigma, location, bInputSigma) { let ic = this.icn3d; ic.icn3dui; + if (buf.byteLength < 1024) throw Error('File shorter than 1024 bytes.'); + + //console.log('buf type: ' + Object.prototype.toString.call(buf)); + // for now we assume both file and host are little endian + const iview = new Int32Array(buf, 0, 256); + // word 53 - character string 'MAP ' to identify file type + if (iview[52] !== 0x2050414d) throw Error('not a CCP4 map'); + + // map has 3 dimensions referred to as columns (fastest changing), rows + // and sections (c-r-s) + const n_crs = [iview[0], iview[1], iview[2]]; // 108, 108, 108 + const mode = iview[3]; //2 + let nb; + if (mode === 2) nb = 4; + else if (mode === 0) nb = 1; + else throw Error('Only Mode 2 and Mode 0 of CCP4 map is supported.'); + + const start = [iview[4], iview[5], iview[6]]; // 0,0,0 + const n_grid = [iview[7], iview[8], iview[9]]; // 108,108,108 + const nsymbt = iview[23]; // size of extended header in bytes + // nsymbt = 1920 + + if (1024 + nsymbt + nb*n_crs[0]*n_crs[1]*n_crs[2] !== buf.byteLength) { + throw Error('ccp4 file too short or too long'); + } + + const fview = new Float32Array(buf, 0, buf.byteLength / 4); + const grid = new GridArray(n_grid); + const unit_cell = new UnitCell(fview[10], fview[11], fview[12], fview[13], fview[14], fview[15]); // 79.1, 79.1, 79.1, 90, 90, 90 + + // MAPC, MAPR, MAPS - axis corresp to cols, rows, sections (1,2,3 for X,Y,Z) + const map_crs = [iview[16], iview[17], iview[18]]; // 2,1,3 + const ax = map_crs.indexOf(1); + const ay = map_crs.indexOf(2); + const az = map_crs.indexOf(3); + + const min = fview[19]; // -0.49 + const max = fview[20]; // 0.94 + //const sg_number = iview[22]; + //const lskflg = iview[24]; + + if (nsymbt % 4 !== 0) { + throw Error('CCP4 map with NSYMBT not divisible by 4 is not supported.'); + } + let data_view; + if (mode === 2) data_view = fview; + else /* mode === 0 */ data_view = new Int8Array(buf); + let idx = (1024 + nsymbt) / nb | 0; //736 + + // We assume that if DMEAN and RMS from the header are not clearly wrong + // they are what the user wants. Because the map can cover a small part + // of the asu and its rmsd may be different than the total rmsd. + // let stats = { mean: 0.0, rms: 1.0 }; + // stats.mean = fview[21]; //0 + // stats.rms = fview[54]; //0.15 + // if (stats.mean < min || stats.mean > max || stats.rms <= 0) { + // stats = this.calculate_stddev(data_view, idx); + // } + + let b1 = 1; + let b0 = 0; + // if the file was converted by mapmode2to0 - scale the data + if (mode === 0 && iview[39] === -128 && iview[40] === 127) { //39:0, 40:0 + // scaling f(x)=b1*x+b0 such that f(-128)=min and f(127)=max + b1 = (max - min) / 255.0; + b0 = 0.5 * (min + max + b1); + } + + const end = [start[0] + n_crs[0], start[1] + n_crs[1], start[2] + n_crs[2]]; + let it = [0, 0, 0]; + let maxValue = -999; + for (it[2] = start[2]; it[2] < end[2]; it[2]++) { // sections + for (it[1] = start[1]; it[1] < end[1]; it[1]++) { // rows + for (it[0] = start[0]; it[0] < end[0]; it[0]++) { // cols + let value = b1 * data_view[idx] + b0; + grid.set_grid_value(it[ax], it[ay], it[az], value); + + if(value > maxValue) maxValue = value; + idx++; + } + } + } + +/* + if (expand_symmetry && nsymbt > 0) { + const u8view = new Uint8Array(buf); + for (let i = 0; i+80 <= nsymbt; i += 80) { + let j; + let symop = ''; + for (j = 0; j < 80; ++j) { + symop += String.fromCharCode(u8view[1024 + i + j]); + } + if (/^\s*x\s*,\s*y\s*,\s*z\s*$/i.test(symop)) continue; // skip x,y,z + //console.log('sym ops', symop.trim()); + let mat = this.parse_symop(symop); + // Note: we apply here symops to grid points instead of coordinates. + // In the cases we came across it is equivalent, but in general not. + for (j = 0; j < 3; ++j) { + mat[j][3] = Math.round(mat[j][3] * n_grid[j]) | 0; + } + idx = (1024 + nsymbt) / nb | 0; + let xyz = [0, 0, 0]; + for (it[2] = start[2]; it[2] < end[2]; it[2]++) { // sections + for (it[1] = start[1]; it[1] < end[1]; it[1]++) { // rows + for (it[0] = start[0]; it[0] < end[0]; it[0]++) { // cols + for (j = 0; j < 3; ++j) { + xyz[j] = it[ax] * mat[j][0] + it[ay] * mat[j][1] + + it[az] * mat[j][2] + mat[j][3]; + } + let value = b1 * data_view[idx] + b0; + grid.set_grid_value(xyz[0], xyz[1], xyz[2], value); + + if(value > maxValue) maxValue = value; + idx++; + } + } + } + } + } +*/ + + if(!bInputSigma) { + sigma = ic.dsn6ParserCls.setSigma(maxValue, location, type, sigma); + } + + if(type == '2fofc') { + ic.mapData.ccp4 = 1; + ic.mapData.grid2 = grid; + ic.mapData.unit_cell2 = unit_cell; + ic.mapData.type2 = type; + ic.mapData.sigma2 = sigma; + } + else { + ic.mapData.ccp4 = 1; + ic.mapData.grid = grid; + ic.mapData.unit_cell = unit_cell; + ic.mapData.type = type; + ic.mapData.sigma = sigma; + } + + return sigma; + } + + load_maps_from_mtz_buffer(mtz, type, sigma, location, bInputSigma) { let ic = this.icn3d; ic.icn3dui; + let is_diff = (type == 'fofc'); // diff: fofc, non-diff: 2fofc + let dataArray = mtz.calculate_map(is_diff); + + let mc = mtz.cell; + const unit_cell = new UnitCell(mc.a, mc.b, mc.c, mc.alpha, mc.beta, mc.gamma); + + let maxValue = -999; + for(let i = 0, il = dataArray.length; i < il; ++i) { + if(dataArray[i] > maxValue) maxValue = dataArray[i]; + } + + if(!bInputSigma) { + sigma = ic.dsn6ParserCls.setSigma(maxValue, location, type, sigma); + } + + const grid = new GridArray([mtz.nx, mtz.ny, mtz.nz]); + grid.values.set(dataArray); + + if(type == '2fofc') { + ic.mapData.ccp4 = 1; + ic.mapData.grid2 = grid; + ic.mapData.unit_cell2 = unit_cell; + ic.mapData.type2 = type; + ic.mapData.sigma2 = sigma; + } + else { + ic.mapData.ccp4 = 1; + ic.mapData.grid = grid; + ic.mapData.unit_cell = unit_cell; + ic.mapData.type = type; + ic.mapData.sigma = sigma; + } + + mtz.delete(); + + return sigma; + } + + // calculate_stddev(a, offset) { + // let sum = 0; + // let sq_sum = 0; + // const alen = a.length; + // for (let i = offset; i < alen; i++) { + // sum += a[i]; + // sq_sum += a[i] * a[i]; + // } + // const mean = sum / (alen - offset); + // const variance = sq_sum / (alen - offset) - mean * mean; + // return {mean: mean, rms: Math.sqrt(variance)}; + // } + + parse_symop(symop) { + const ops = symop.toLowerCase().replace(/\s+/g, '').split(','); + if (ops.length !== 3) throw Error('Unexpected symop: ' + symop); + let mat = []; + for (let i = 0; i < 3; i++) { + const terms = ops[i].split(/(?=[+-])/); + let row = [0, 0, 0, 0]; + for (let j = 0; j < terms.length; j++) { + const term = terms[j]; + const sign = (term[0] === '-' ? -1 : 1); + let m = terms[j].match(/^[+-]?([xyz])$/); + if (m) { + const pos = {x: 0, y: 1, z: 2}[m[1]]; + row[pos] = sign; + } else { + m = terms[j].match(/^[+-]?(\d)\/(\d)$/); + if (!m) throw Error('What is ' + terms[j] + ' in ' + symop); + row[3] = sign * Number(m[1]) / Number(m[2]); + } + } + mat.push(row); + } + return mat; + } + + loadCcp4File(type) {let ic = this.icn3d, me = ic.icn3dui; + let thisClass = this; + + let file = $("#" + ic.pre + "dsn6file" + type)[0].files[0]; + let sigma = $("#" + ic.pre + "dsn6sigma" + type).val(); + if(!file) { + alert("Please select a file before clicking 'Load'"); + } + else { + me.utilsCls.checkFileAPI(); + let reader = new FileReader(); + reader.onload = function(e) { let ic = thisClass.icn3d; + let arrayBuffer = e.target.result; // or = reader.result; + sigma = thisClass.load_map_from_buffer(arrayBuffer, type, sigma, 'file'); + + // if(type == '2fofc') { + // ic.bAjax2fofcCcp4 = true; + // } + // else if(type == 'fofc') { + // ic.bAjaxfofcCcp4 = true; + // } + ic.setOptionCls.setOption('map', type); + me.htmlCls.clickMenuCls.setLogCmd('load map file ' + $("#" + ic.pre + "dsn6file" + type).val() + ' with sigma ' + sigma, false); + }; + reader.readAsArrayBuffer(file); + } + } + + async loadCcp4FileUrl(type) { let ic = this.icn3d, me = ic.icn3dui; + let url = $("#" + ic.pre + "dsn6fileurl" + type).val(); + let sigma = $("#" + ic.pre + "dsn6sigmaurl" + type).val(); + if(!url) { + alert("Please input the file URL before clicking 'Load'"); + } + else { + sigma = await this.ccp4ParserBase(url, type, sigma, 'file'); + + me.htmlCls.clickMenuCls.setLogCmd('set map ' + type + ' sigma ' + sigma + ' file ccp4 | ' + encodeURIComponent(url), true); + } + } + + // Extract a block of density for calculating an isosurface using the + // separate marching cubes implementation. + extract_block(grid, unit_cell, radius, center, typeDetail) { let ic = this.icn3d; ic.icn3dui; + // let grid = this.grid; + // let unit_cell = this.unit_cell; + if (grid == null || unit_cell == null) { return; } + let fc = unit_cell.fractionalize(center); + + let r = [radius / unit_cell.parameters[0], + radius / unit_cell.parameters[1], + radius / unit_cell.parameters[2]]; + let grid_min = grid.frac2grid([fc[0] - r[0], fc[1] - r[1], fc[2] - r[2]]); + let grid_max = grid.frac2grid([fc[0] + r[0], fc[1] + r[1], fc[2] + r[2]]); + + let size = [grid_max[0] - grid_min[0] + 1, + grid_max[1] - grid_min[1] + 1, + grid_max[2] - grid_min[2] + 1]; + let points = []; + let values = []; + let threshold = 1; + let bAtoms = ic.hAtoms && Object.keys(ic.hAtoms).length > 0; + for (let i = grid_min[0]; i <= grid_max[0]; i++) { + for (let j = grid_min[1]; j <= grid_max[1]; j++) { + for (let k = grid_min[2]; k <= grid_max[2]; k++) { + let frac = grid.grid2frac(i, j, k); + let orth = unit_cell.orthogonalize(frac); + points.push(orth); + + // get overlap between map and atoms + let positoin = new THREE.Vector3(orth[0], orth[1], orth[2]); + let atomsNear = ic.rayCls.getAtomsFromPosition(positoin, threshold, ic.hAtoms); + + let map_value = (atomsNear || !bAtoms) ? grid.get_grid_value(i, j, k) : 0; + + if(typeDetail == 'fofc_pos' && map_value < 0) map_value = 0; + if(typeDetail == 'fofc_neg') map_value = (map_value > 0) ? 0 : -map_value; + + values.push(map_value); + } + } + } + + return {size: size, values: values, points: points}; + // this.block.set(points, values, size); + }; + + marchingCubes(dims, values, points, isolevel, method) { let ic = this.icn3d; ic.icn3dui; + const edgeTable = new Int32Array([ + 0x0 , 0x0 , 0x202, 0x302, 0x406, 0x406, 0x604, 0x704, + 0x804, 0x805, 0xa06, 0xa06, 0xc0a, 0xd03, 0xe08, 0xf00, + 0x90 , 0x98 , 0x292, 0x292, 0x496, 0x49e, 0x694, 0x694, + 0x894, 0x894, 0xa96, 0xa96, 0xc9a, 0xc92, 0xe91, 0xe90, + 0x230, 0x230, 0x33 , 0x13a, 0x636, 0x636, 0x434, 0x43c, + 0xa34, 0xa35, 0x837, 0x936, 0xe3a, 0xf32, 0xc31, 0xd30, + 0x2a0, 0x2a8, 0xa3 , 0xaa , 0x6a6, 0x6af, 0x5a4, 0x4ac, + 0xaa4, 0xaa4, 0x9a6, 0x8a6, 0xfaa, 0xea3, 0xca1, 0xca0, + 0x460, 0x460, 0x662, 0x762, 0x66 , 0x66 , 0x265, 0x364, + 0xc64, 0xc65, 0xe66, 0xe66, 0x86a, 0x863, 0xa69, 0xa60, + 0x4f0, 0x4f8, 0x6f2, 0x6f2, 0xf6 , 0xfe , 0x2f5, 0x2fc, + 0xcf4, 0xcf4, 0xef6, 0xef6, 0x8fa, 0x8f3, 0xaf9, 0xaf0, + 0x650, 0x650, 0x453, 0x552, 0x256, 0x256, 0x54 , 0x154, + 0xe54, 0xf54, 0xc57, 0xd56, 0xa5a, 0xb52, 0x859, 0x950, + 0x7c0, 0x6c1, 0x5c2, 0x4c2, 0x3c6, 0x2ce, 0xc5 , 0xc4 , + 0xfc4, 0xec5, 0xdc6, 0xcc6, 0xbca, 0xac2, 0x8c1, 0x8c0, + 0x8c0, 0x8c0, 0xac2, 0xbc2, 0xcc6, 0xcc6, 0xec4, 0xfcc, + 0xc4 , 0xc5 , 0x2c6, 0x3c6, 0x4c2, 0x5c2, 0x6c1, 0x7c0, + 0x950, 0x859, 0xb52, 0xa5a, 0xd56, 0xc57, 0xe54, 0xe5c, + 0x154, 0x54 , 0x25e, 0x256, 0x552, 0x453, 0x658, 0x650, + 0xaf0, 0xaf0, 0x8f3, 0x8fa, 0xef6, 0xef6, 0xcf4, 0xcfc, + 0x2f4, 0x3f5, 0xff , 0x1f6, 0x6f2, 0x6f3, 0x4f9, 0x5f0, + 0xa60, 0xa69, 0x863, 0x86a, 0xe66, 0xe67, 0xd65, 0xc6c, + 0x364, 0x265, 0x166, 0x66 , 0x76a, 0x663, 0x460, 0x460, + 0xca0, 0xca0, 0xea2, 0xfa2, 0x8a6, 0x8a6, 0xaa4, 0xba4, + 0x4ac, 0x5a4, 0x6ae, 0x7a6, 0xaa , 0xa3 , 0x2a8, 0x2a0, + 0xd30, 0xc31, 0xf32, 0xe3a, 0x936, 0x837, 0xb35, 0xa34, + 0x43c, 0x434, 0x73e, 0x636, 0x13a, 0x33 , 0x339, 0x230, + 0xe90, 0xe90, 0xc92, 0xc9a, 0xa96, 0xa96, 0x894, 0x89c, + 0x694, 0x695, 0x49f, 0x496, 0x292, 0x392, 0x98 , 0x90 , + 0xf00, 0xe08, 0xd03, 0xc0a, 0xa06, 0xa0e, 0x805, 0x804, + 0x704, 0x604, 0x506, 0x406, 0x302, 0x202, 0x0 , 0x0]); + + const segTable = [ + [], + [], + [1, 9], + [1, 8, 1, 9], + [2, 10, 10, 1], + [2, 10, 10, 1], + [9, 2, 2, 10, 10, 9], + [2, 8, 2, 10, 10, 8, 10, 9], + [11, 2], + [0, 11, 11, 2], + [1, 9, 11, 2], + [1, 11, 11, 2, 1, 9, 9, 11], + [3, 10, 10, 1, 11, 10], + [0, 10, 10, 1, 8, 10, 11, 10], + [3, 9, 11, 9, 11, 10, 10, 9], + [8, 10, 10, 9, 11, 10], + [4, 7], + [4, 3, 4, 7], + [1, 9, 4, 7], + [4, 1, 1, 9, 4, 7, 7, 1], + [2, 10, 10, 1, 4, 7], + [3, 4, 4, 7, 2, 10, 10, 1], + [9, 2, 2, 10, 10, 9, 4, 7], + [2, 10, 10, 9, 9, 2, 9, 7, 7, 2, 4, 7], + [4, 7, 11, 2], + [11, 4, 4, 7, 11, 2, 2, 4], + [1, 9, 4, 7, 11, 2], + [4, 7, 11, 4, 11, 9, 11, 2, 2, 9, 1, 9], + [3, 10, 10, 1, 11, 10, 4, 7], + [1, 11, 11, 10, 10, 1, 1, 4, 4, 11, 4, 7], + [4, 7, 0, 11, 11, 9, 11, 10, 10, 9], + [4, 7, 11, 4, 11, 9, 11, 10, 10, 9], + [9, 5, 5, 4], + [9, 5, 5, 4], + [0, 5, 5, 4, 1, 5], + [8, 5, 5, 4, 3, 5, 1, 5], + [2, 10, 10, 1, 9, 5, 5, 4], + [2, 10, 10, 1, 9, 5, 5, 4], + [5, 2, 2, 10, 10, 5, 5, 4, 4, 2], + [2, 10, 10, 5, 5, 2, 5, 3, 5, 4, 4, 3], + [9, 5, 5, 4, 11, 2], + [0, 11, 11, 2, 9, 5, 5, 4], + [0, 5, 5, 4, 1, 5, 11, 2], + [1, 5, 5, 2, 5, 8, 8, 2, 11, 2, 5, 4], + [10, 3, 11, 10, 10, 1, 9, 5, 5, 4], + [9, 5, 5, 4, 8, 1, 8, 10, 10, 1, 11, 10], + [5, 4, 0, 5, 0, 11, 11, 5, 11, 10, 10, 5], + [5, 4, 8, 5, 8, 10, 10, 5, 11, 10], + [9, 7, 5, 7, 9, 5], + [9, 3, 9, 5, 5, 3, 5, 7], + [0, 7, 1, 7, 1, 5, 5, 7], + [1, 5, 5, 3, 5, 7], + [9, 7, 9, 5, 5, 7, 10, 1, 2, 10], + [10, 1, 2, 10, 9, 5, 5, 0, 5, 3, 5, 7], + [2, 8, 2, 5, 5, 8, 5, 7, 10, 5, 2, 10], + [2, 10, 10, 5, 5, 2, 5, 3, 5, 7], + [7, 9, 9, 5, 5, 7, 11, 2], + [9, 5, 5, 7, 7, 9, 7, 2, 2, 9, 11, 2], + [11, 2, 1, 8, 1, 7, 1, 5, 5, 7], + [11, 2, 1, 11, 1, 7, 1, 5, 5, 7], + [9, 5, 5, 8, 5, 7, 10, 1, 3, 10, 11, 10], + [5, 7, 7, 0, 0, 5, 9, 5, 11, 0, 0, 10, 10, 1, 11, 10], + [11, 10, 10, 0, 0, 11, 10, 5, 5, 0, 0, 7, 5, 7], + [11, 10, 10, 5, 5, 11, 5, 7], + [10, 6, 6, 5, 5, 10], + [5, 10, 10, 6, 6, 5], + [1, 9, 5, 10, 10, 6, 6, 5], + [1, 8, 1, 9, 5, 10, 10, 6, 6, 5], + [1, 6, 6, 5, 5, 1, 2, 6], + [1, 6, 6, 5, 5, 1, 2, 6], + [9, 6, 6, 5, 5, 9, 0, 6, 2, 6], + [5, 9, 8, 5, 8, 2, 2, 5, 2, 6, 6, 5], + [11, 2, 10, 6, 6, 5, 5, 10], + [11, 0, 11, 2, 10, 6, 6, 5, 5, 10], + [1, 9, 11, 2, 5, 10, 10, 6, 6, 5], + [5, 10, 10, 6, 6, 5, 1, 9, 9, 2, 9, 11, 11, 2], + [6, 3, 11, 6, 6, 5, 5, 3, 5, 1], + [11, 0, 11, 5, 5, 0, 5, 1, 11, 6, 6, 5], + [11, 6, 6, 3, 6, 0, 6, 5, 5, 0, 5, 9], + [6, 5, 5, 9, 9, 6, 9, 11, 11, 6], + [5, 10, 10, 6, 6, 5, 4, 7], + [4, 3, 4, 7, 6, 5, 5, 10, 10, 6], + [1, 9, 5, 10, 10, 6, 6, 5, 4, 7], + [10, 6, 6, 5, 5, 10, 1, 9, 9, 7, 7, 1, 4, 7], + [6, 1, 2, 6, 6, 5, 5, 1, 4, 7], + [2, 5, 5, 1, 2, 6, 6, 5, 4, 3, 4, 7], + [4, 7, 0, 5, 5, 9, 0, 6, 6, 5, 2, 6], + [3, 9, 9, 7, 4, 7, 2, 9, 5, 9, 9, 6, 6, 5, 2, 6], + [11, 2, 4, 7, 10, 6, 6, 5, 5, 10], + [5, 10, 10, 6, 6, 5, 4, 7, 7, 2, 2, 4, 11, 2], + [1, 9, 4, 7, 11, 2, 5, 10, 10, 6, 6, 5], + [9, 2, 1, 9, 9, 11, 11, 2, 4, 11, 4, 7, 5, 10, 10, 6, 6, 5], + [4, 7, 11, 5, 5, 3, 5, 1, 11, 6, 6, 5], + [5, 1, 1, 11, 11, 5, 11, 6, 6, 5, 0, 11, 11, 4, 4, 7], + [0, 5, 5, 9, 0, 6, 6, 5, 3, 6, 11, 6, 4, 7], + [6, 5, 5, 9, 9, 6, 9, 11, 11, 6, 4, 7, 7, 9], + [10, 4, 9, 10, 6, 4, 10, 6], + [4, 10, 10, 6, 6, 4, 9, 10], + [10, 0, 1, 10, 10, 6, 6, 0, 6, 4], + [1, 8, 1, 6, 6, 8, 6, 4, 1, 10, 10, 6], + [1, 4, 9, 1, 2, 4, 2, 6, 6, 4], + [2, 9, 9, 1, 2, 4, 2, 6, 6, 4], + [2, 4, 2, 6, 6, 4], + [2, 8, 2, 4, 2, 6, 6, 4], + [10, 4, 9, 10, 10, 6, 6, 4, 11, 2], + [8, 2, 11, 2, 9, 10, 10, 4, 10, 6, 6, 4], + [11, 2, 1, 6, 6, 0, 6, 4, 1, 10, 10, 6], + [6, 4, 4, 1, 1, 6, 1, 10, 10, 6, 8, 1, 1, 11, 11, 2], + [9, 6, 6, 4, 9, 3, 3, 6, 9, 1, 11, 6], + [11, 1, 1, 8, 11, 6, 6, 1, 9, 1, 1, 4, 6, 4], + [11, 6, 6, 3, 6, 0, 6, 4], + [6, 4, 8, 6, 11, 6], + [7, 10, 10, 6, 6, 7, 8, 10, 9, 10], + [0, 7, 0, 10, 10, 7, 9, 10, 6, 7, 10, 6], + [10, 6, 6, 7, 7, 10, 1, 10, 7, 1, 8, 1], + [10, 6, 6, 7, 7, 10, 7, 1, 1, 10], + [2, 6, 6, 1, 6, 8, 8, 1, 9, 1, 6, 7], + [2, 6, 6, 9, 9, 2, 9, 1, 6, 7, 7, 9, 9, 3], + [0, 7, 0, 6, 6, 7, 2, 6], + [2, 7, 6, 7, 2, 6], + [11, 2, 10, 6, 6, 8, 8, 10, 9, 10, 6, 7], + [0, 7, 7, 2, 11, 2, 9, 7, 6, 7, 7, 10, 10, 6, 9, 10], + [1, 8, 1, 7, 1, 10, 10, 7, 6, 7, 10, 6, 11, 2], + [11, 2, 1, 11, 1, 7, 10, 6, 6, 1, 1, 10, 6, 7], + [9, 6, 6, 8, 6, 7, 9, 1, 1, 6, 11, 6, 6, 3], + [9, 1, 11, 6, 6, 7], + [0, 7, 0, 6, 6, 7, 11, 0, 11, 6], + [11, 6, 6, 7], + [7, 6, 6, 11], + [7, 6, 6, 11], + [1, 9, 7, 6, 6, 11], + [8, 1, 1, 9, 7, 6, 6, 11], + [10, 1, 2, 10, 6, 11, 7, 6], + [2, 10, 10, 1, 6, 11, 7, 6], + [2, 9, 2, 10, 10, 9, 6, 11, 7, 6], + [6, 11, 7, 6, 2, 10, 10, 3, 10, 8, 10, 9], + [7, 2, 6, 2, 7, 6], + [7, 0, 7, 6, 6, 0, 6, 2], + [2, 7, 7, 6, 6, 2, 1, 9], + [1, 6, 6, 2, 1, 8, 8, 6, 1, 9, 7, 6], + [10, 7, 7, 6, 6, 10, 10, 1, 1, 7], + [10, 7, 7, 6, 6, 10, 1, 7, 10, 1, 1, 8], + [7, 0, 7, 10, 10, 0, 10, 9, 6, 10, 7, 6], + [7, 6, 6, 10, 10, 7, 10, 8, 10, 9], + [6, 8, 4, 6, 6, 11], + [3, 6, 6, 11, 0, 6, 4, 6], + [8, 6, 6, 11, 4, 6, 1, 9], + [4, 6, 6, 9, 6, 3, 3, 9, 1, 9, 6, 11], + [6, 8, 4, 6, 6, 11, 2, 10, 10, 1], + [2, 10, 10, 1, 0, 11, 0, 6, 6, 11, 4, 6], + [4, 11, 4, 6, 6, 11, 2, 9, 2, 10, 10, 9], + [10, 9, 9, 3, 3, 10, 2, 10, 4, 3, 3, 6, 6, 11, 4, 6], + [8, 2, 4, 2, 4, 6, 6, 2], + [4, 2, 4, 6, 6, 2], + [1, 9, 3, 4, 4, 2, 4, 6, 6, 2], + [1, 9, 4, 1, 4, 2, 4, 6, 6, 2], + [8, 1, 8, 6, 6, 1, 4, 6, 6, 10, 10, 1], + [10, 1, 0, 10, 0, 6, 6, 10, 4, 6], + [4, 6, 6, 3, 3, 4, 6, 10, 10, 3, 3, 9, 10, 9], + [10, 9, 4, 10, 6, 10, 4, 6], + [9, 5, 5, 4, 7, 6, 6, 11], + [9, 5, 5, 4, 7, 6, 6, 11], + [5, 0, 1, 5, 5, 4, 7, 6, 6, 11], + [7, 6, 6, 11, 3, 4, 3, 5, 5, 4, 1, 5], + [9, 5, 5, 4, 10, 1, 2, 10, 7, 6, 6, 11], + [6, 11, 7, 6, 2, 10, 10, 1, 9, 5, 5, 4], + [7, 6, 6, 11, 5, 4, 4, 10, 10, 5, 4, 2, 2, 10], + [3, 4, 3, 5, 5, 4, 2, 5, 10, 5, 2, 10, 7, 6, 6, 11], + [7, 2, 7, 6, 6, 2, 5, 4, 9, 5], + [9, 5, 5, 4, 8, 6, 6, 0, 6, 2, 7, 6], + [3, 6, 6, 2, 7, 6, 1, 5, 5, 0, 5, 4], + [6, 2, 2, 8, 8, 6, 7, 6, 1, 8, 8, 5, 5, 4, 1, 5], + [9, 5, 5, 4, 10, 1, 1, 6, 6, 10, 1, 7, 7, 6], + [1, 6, 6, 10, 10, 1, 1, 7, 7, 6, 0, 7, 9, 5, 5, 4], + [0, 10, 10, 4, 10, 5, 5, 4, 3, 10, 6, 10, 10, 7, 7, 6], + [7, 6, 6, 10, 10, 7, 10, 8, 5, 4, 4, 10, 10, 5], + [6, 9, 9, 5, 5, 6, 6, 11, 11, 9], + [3, 6, 6, 11, 0, 6, 0, 5, 5, 6, 9, 5], + [0, 11, 0, 5, 5, 11, 1, 5, 5, 6, 6, 11], + [6, 11, 3, 6, 3, 5, 5, 6, 1, 5], + [2, 10, 10, 1, 9, 5, 5, 11, 11, 9, 5, 6, 6, 11], + [0, 11, 0, 6, 6, 11, 9, 6, 5, 6, 9, 5, 2, 10, 10, 1], + [8, 5, 5, 11, 5, 6, 6, 11, 0, 5, 10, 5, 5, 2, 2, 10], + [6, 11, 3, 6, 3, 5, 5, 6, 2, 10, 10, 3, 10, 5], + [5, 8, 9, 5, 5, 2, 2, 8, 5, 6, 6, 2], + [9, 5, 5, 6, 6, 9, 6, 0, 6, 2], + [1, 5, 5, 8, 8, 1, 5, 6, 6, 8, 8, 2, 6, 2], + [1, 5, 5, 6, 6, 1, 6, 2], + [3, 6, 6, 1, 6, 10, 10, 1, 8, 6, 5, 6, 6, 9, 9, 5], + [10, 1, 0, 10, 0, 6, 6, 10, 9, 5, 5, 0, 5, 6], + [5, 6, 6, 10, 10, 5], + [10, 5, 5, 6, 6, 10], + [11, 5, 5, 10, 10, 11, 7, 5], + [11, 5, 5, 10, 10, 11, 7, 5], + [5, 11, 7, 5, 5, 10, 10, 11, 1, 9], + [10, 7, 7, 5, 5, 10, 10, 11, 8, 1, 1, 9], + [11, 1, 2, 11, 7, 1, 7, 5, 5, 1], + [2, 7, 7, 1, 7, 5, 5, 1, 2, 11], + [9, 7, 7, 5, 5, 9, 9, 2, 2, 7, 2, 11], + [7, 5, 5, 2, 2, 7, 2, 11, 5, 9, 9, 2, 2, 8], + [2, 5, 5, 10, 10, 2, 3, 5, 7, 5], + [8, 2, 8, 5, 5, 2, 7, 5, 10, 2, 5, 10], + [1, 9, 5, 10, 10, 3, 3, 5, 7, 5, 10, 2], + [8, 2, 2, 9, 1, 9, 7, 2, 10, 2, 2, 5, 5, 10, 7, 5], + [3, 5, 5, 1, 7, 5], + [7, 0, 7, 1, 7, 5, 5, 1], + [3, 9, 3, 5, 5, 9, 7, 5], + [7, 9, 5, 9, 7, 5], + [5, 8, 4, 5, 5, 10, 10, 8, 10, 11], + [5, 0, 4, 5, 5, 11, 11, 0, 5, 10, 10, 11], + [1, 9, 4, 10, 10, 8, 10, 11, 4, 5, 5, 10], + [10, 11, 11, 4, 4, 10, 4, 5, 5, 10, 3, 4, 4, 1, 1, 9], + [2, 5, 5, 1, 2, 8, 8, 5, 2, 11, 4, 5], + [4, 11, 11, 0, 4, 5, 5, 11, 2, 11, 11, 1, 5, 1], + [2, 5, 5, 0, 5, 9, 2, 11, 11, 5, 4, 5, 5, 8], + [4, 5, 5, 9, 2, 11], + [2, 5, 5, 10, 10, 2, 3, 5, 3, 4, 4, 5], + [5, 10, 10, 2, 2, 5, 2, 4, 4, 5], + [3, 10, 10, 2, 3, 5, 5, 10, 8, 5, 4, 5, 1, 9], + [5, 10, 10, 2, 2, 5, 2, 4, 4, 5, 1, 9, 9, 2], + [4, 5, 5, 8, 5, 3, 5, 1], + [4, 5, 5, 0, 5, 1], + [4, 5, 5, 8, 5, 3, 0, 5, 5, 9], + [4, 5, 5, 9], + [4, 11, 7, 4, 9, 11, 9, 10, 10, 11], + [9, 7, 7, 4, 9, 11, 9, 10, 10, 11], + [1, 10, 10, 11, 11, 1, 11, 4, 4, 1, 7, 4], + [1, 4, 4, 3, 1, 10, 10, 4, 7, 4, 4, 11, 10, 11], + [4, 11, 7, 4, 9, 11, 9, 2, 2, 11, 9, 1], + [9, 7, 7, 4, 9, 11, 9, 1, 1, 11, 2, 11], + [7, 4, 4, 11, 4, 2, 2, 11], + [7, 4, 4, 11, 4, 2, 2, 11, 3, 4], + [2, 9, 9, 10, 10, 2, 2, 7, 7, 9, 7, 4], + [9, 10, 10, 7, 7, 9, 7, 4, 10, 2, 2, 7, 7, 0], + [7, 10, 10, 3, 10, 2, 7, 4, 4, 10, 1, 10, 10, 0], + [1, 10, 10, 2, 7, 4], + [9, 1, 1, 4, 1, 7, 7, 4], + [9, 1, 1, 4, 1, 7, 7, 4, 8, 1], + [3, 4, 7, 4], + [7, 4], + [9, 10, 10, 8, 10, 11], + [9, 3, 9, 11, 9, 10, 10, 11], + [1, 10, 10, 0, 10, 8, 10, 11], + [1, 10, 10, 3, 10, 11], + [2, 11, 11, 1, 11, 9, 9, 1], + [9, 3, 9, 11, 2, 9, 9, 1, 2, 11], + [2, 11, 11, 0], + [2, 11], + [8, 2, 8, 10, 10, 2, 9, 10], + [9, 10, 10, 2, 2, 9], + [8, 2, 8, 10, 10, 2, 1, 8, 1, 10], + [1, 10, 10, 2], + [8, 1, 9, 1], + [9, 1], + [], + []]; + + const snap = (method === 'snapped MC'); + // const seg_table = (method === 'squarish' ? segTable2 : segTable); + const seg_table = segTable; + + let vlist = new Array(12); + const vert_offsets = this.calculateVertOffsets(dims); + + const edgeIndex = [[0,1], [1,2], [2,3], [3,0], [4,5], [5,6], + [6,7], [7,4], [0,4], [1,5], [2,6], [3,7]]; + + let vertex_values = new Float32Array(8); + let p0 = [0, 0, 0]; // unused initial value - to make Flow happy + let vertex_points = [p0, p0, p0, p0, p0, p0, p0, p0]; + const size_x = dims[0]; + const size_y = dims[1]; + const size_z = dims[2]; + if (values == null || points == null) return; + let vertices = []; + let segments = []; + let vertex_count = 0; + for (let x = 0; x < size_x - 1; x++) { + for (let y = 0; y < size_y - 1; y++) { + for (let z = 0; z < size_z - 1; z++) { + const offset0 = z + size_z * (y + size_y * x); + let cubeindex = 0; + let i; + let j; + for (i = 0; i < 8; ++i) { + j = offset0 + vert_offsets[i]; + cubeindex |= (values[j] < isolevel) ? 1 << i : 0; + } + if (cubeindex === 0 || cubeindex === 255) continue; + for (i = 0; i < 8; ++i) { + j = offset0 + vert_offsets[i]; + vertex_values[i] = values[j]; + vertex_points[i] = points[j]; + } + + // 12 bit number, indicates which edges are crossed by the isosurface + const edge_mask = edgeTable[cubeindex]; + + // check which edges are crossed, and estimate the point location + // using a weighted average of scalar values at edge endpoints. + for (i = 0; i < 12; ++i) { + if ((edge_mask & (1 << i)) !== 0) { + const e = edgeIndex[i]; + let mu = (isolevel - vertex_values[e[0]]) / + (vertex_values[e[1]] - vertex_values[e[0]]); + if (snap === true) { + if (mu > 0.85) mu = 1; + else if (mu < 0.15) mu = 0; + } + const p1 = vertex_points[e[0]]; + const p2 = vertex_points[e[1]]; + // The number of added vertices could be roughly halved + // if we avoided duplicates between neighbouring cells. + // Using a map for lookups is too slow, perhaps a big + // array would do? + vertices.push(p1[0] + (p2[0] - p1[0]) * mu, + p1[1] + (p2[1] - p1[1]) * mu, + p1[2] + (p2[2] - p1[2]) * mu); + vlist[i] = vertex_count++; + } + } + const t = seg_table[cubeindex]; + for (i = 0; i < t.length; i++) { + segments.push(vlist[t[i]]); + } + } + } + } + + return { vertices: vertices, segments: segments }; + } + + // return offsets relative to vertex [0,0,0] + calculateVertOffsets(dims) { let ic = this.icn3d; ic.icn3dui; + let vert_offsets = []; + const cubeVerts = [[0,0,0], [1,0,0], [1,1,0], [0,1,0], + [0,0,1], [1,0,1], [1,1,1], [0,1,1]]; + + for (let i = 0; i < 8; ++i) { + const v = cubeVerts[i]; + vert_offsets.push(v[0] + dims[2] * (v[1] + dims[1] * v[2])); + } + return vert_offsets; + } + + makeChickenWire(data, typeDetail) { let ic = this.icn3d, me = ic.icn3dui; + let geom = new THREE.BufferGeometry(); + let position = new Float32Array(data.vertices); + geom.setAttribute('position', new THREE.BufferAttribute(position, 3)); + + // Although almost all browsers support OES_element_index_uint nowadays, + // use Uint32 indexes only when needed. + let arr = (data.vertices.length < 3*65536 ? new Uint16Array(data.segments) : new Uint32Array(data.segments)); + + geom.setIndex(new THREE.BufferAttribute(arr, 1)); + + let colorFor2fofc = me.parasCls.thr('#00FFFF'); + let colorForfofcPos = me.parasCls.thr('#00FF00'); + let colorForfofcNeg = me.parasCls.thr('#ff0000'); + + let color = (typeDetail == '2fofc') ? colorFor2fofc : ((typeDetail == 'fofc_pos') ? colorForfofcPos : colorForfofcNeg); + let material = new THREE.LineBasicMaterial({ linewidth: 1, color: color }); + //return new THREE.LineSegments(geom, material); + + let mesh = new THREE.LineSegments(geom, material); + ic.mdl.add(mesh); + + ic.prevMaps.push(mesh); + } +} + + +class UnitCell { + /*:: + parameters: number[] + orth: number[] + frac: number[] + */ + // eslint-disable-next-line max-params + constructor(a /*:number*/, b /*:number*/, c /*:number*/, + alpha /*:number*/, beta /*:number*/, gamma /*:number*/) { + if (a <= 0 || b <= 0 || c <= 0 || alpha <= 0 || beta <= 0 || gamma <= 0) { + throw Error('Zero or negative unit cell parameter(s).'); + } + this.parameters = [a, b, c, alpha, beta, gamma]; + const deg2rad = Math.PI / 180.0; + const cos_alpha = Math.cos(deg2rad * alpha); + const cos_beta = Math.cos(deg2rad * beta); + const cos_gamma = Math.cos(deg2rad * gamma); + const sin_alpha = Math.sin(deg2rad * alpha); + const sin_beta = Math.sin(deg2rad * beta); + const sin_gamma = Math.sin(deg2rad * gamma); + if (sin_alpha === 0 || sin_beta === 0 || sin_gamma === 0) { + throw Error('Impossible angle - N*180deg.'); + } + const cos_alpha_star_sin_beta = (cos_beta * cos_gamma - cos_alpha) / + sin_gamma; + const cos_alpha_star = cos_alpha_star_sin_beta / sin_beta; + const s1rca2 = Math.sqrt(1.0 - cos_alpha_star * cos_alpha_star); + // The orthogonalization matrix we use is described in ITfC B p.262: + // "An alternative mode of orthogonalization, used by the Protein + // Data Bank and most programs, is to align the a1 axis of the unit + // cell with the Cartesian X_1 axis, and to align the a*_3 axis with the + // Cartesian X_3 axis." + // + // Zeros in the matrices below are kept to make matrix multiplication + // faster: they make extract_block() 2x (!) faster on V8 4.5.103, + // no difference on FF 50. + /* eslint-disable no-multi-spaces, comma-spacing */ + this.orth = [a, b * cos_gamma, c * cos_beta, + 0.0, b * sin_gamma, -c * cos_alpha_star_sin_beta, + 0.0, 0.0 , c * sin_beta * s1rca2]; + // based on xtal.js which is based on cctbx.uctbx + this.frac = [ + 1.0 / a, + -cos_gamma / (sin_gamma * a), + -(cos_gamma * cos_alpha_star_sin_beta + cos_beta * sin_gamma) / + (sin_beta * s1rca2 * sin_gamma * a), + 0.0, + 1.0 / (sin_gamma * b), + cos_alpha_star / (s1rca2 * sin_gamma * b), + 0.0, + 0.0, + 1.0 / (sin_beta * s1rca2 * c), + ]; + } + + // This function is only used with matrices frac and orth, which have 3 zeros. + // We skip these elements, but it doesn't affect performance (on FF50 and V8). + multiply(xyz, mat) { + /* eslint-disable indent */ + return [mat[0] * xyz[0] + mat[1] * xyz[1] + mat[2] * xyz[2], + /*mat[3] * xyz[0]*/+ mat[4] * xyz[1] + mat[5] * xyz[2], + /*mat[6] * xyz[0] + mat[7] * xyz[1]*/+ mat[8] * xyz[2]]; + } + + fractionalize(xyz /*:[number,number,number]*/) { + return this.multiply(xyz, this.frac); + } + + orthogonalize(xyz /*:[number,number,number]*/) { + return this.multiply(xyz, this.orth); + } +} + + +class GridArray { + /*:: + dim: number[] + values: Float32Array + */ + constructor(dim /*:number[]*/) { + this.dim = dim; // dimensions of the grid for the entire unit cell + this.values = new Float32Array(dim[0] * dim[1] * dim[2]); + } + + modulo(a, b) { + const reminder = a % b; + return reminder >= 0 ? reminder : reminder + b; + } + + grid2index(i/*:number*/, j/*:number*/, k/*:number*/) { + i = this.modulo(i, this.dim[0]); + j = this.modulo(j, this.dim[1]); + k = this.modulo(k, this.dim[2]); + return this.dim[2] * (this.dim[1] * i + j) + k; + } + + grid2index_unchecked(i/*:number*/, j/*:number*/, k/*:number*/) { + return this.dim[2] * (this.dim[1] * i + j) + k; + } + + grid2frac(i/*:number*/, j/*:number*/, k/*:number*/) { + return [i / this.dim[0], j / this.dim[1], k / this.dim[2]]; + } + + // return grid coordinates (rounded down) for the given fractional coordinates + frac2grid(xyz/*:number[]*/) { + // at one point "| 0" here made extract_block() 40% faster on V8 3.14, + // but I don't see any effect now + return [Math.floor(xyz[0] * this.dim[0]) | 0, + Math.floor(xyz[1] * this.dim[1]) | 0, + Math.floor(xyz[2] * this.dim[2]) | 0]; + } + + set_grid_value(i/*:number*/, j/*:number*/, k/*:number*/, value/*:number*/) { + const idx = this.grid2index(i, j, k); + this.values[idx] = value; + } + + get_grid_value(i/*:number*/, j/*:number*/, k/*:number*/) { + const idx = this.grid2index(i, j, k); + return this.values[idx]; + } +} + +/** + * @file Mtz Parser + * @author Marcin Wojdyr + * @private + * Modified by Jiyao Wang / https://github.com/ncbi/icn3d + */ + +class MtzParser { + constructor(icn3d) { + this.icn3d = icn3d; + } + + async mtzParserBase(url, type, sigma, location, bInputSigma) { let ic = this.icn3d, me = ic.icn3dui; + let thisClass = this; + + //https://stackoverflow.com/questions/33902299/using-jquery-ajax-to-download-a-binary-file + // if(type == '2fofc' && ic.bAjax2fofcccp4) { + // ic.mapData.sigma2 = sigma; + // ic.setOptionCls.setOption('map', type); + // } + // else if(type == 'fofc' && ic.bAjaxfofcccp4) { + // ic.mapData.sigma = sigma; + // ic.setOptionCls.setOption('map', type); + // } + // else { + let arrayBuffer = await me.getXMLHttpRqstPromise(url, 'GET', 'arraybuffer', ''); + sigma = await thisClass.loadMtzFileBase(arrayBuffer, type, sigma, location, bInputSigma, url); + + // if(type == '2fofc') { + // ic.bAjax2fofcccp4 = true; + // } + // else if(type == 'fofc') { + // ic.bAjaxfofcccp4 = true; + // } + + ic.setOptionCls.setOption('map', type); + + return sigma; + // } + } + + loadMtzFile(type) {var ic = this.icn3d, me = ic.icn3dui; + let thisClass = this; + + let file = $("#" + ic.pre + "dsn6file" + type)[0].files[0]; + let sigma = $("#" + ic.pre + "dsn6sigma" + type).val(); + if(!file) { + alert("Please select a file before clicking 'Load'"); + } + else { + me.utilsCls.checkFileAPI(); + let reader = new FileReader(); + reader.onload = async function(e) { let ic = thisClass.icn3d; + sigma = await thisClass.loadMtzFileBase(e.target.result, type, sigma, 'file'); + me.htmlCls.clickMenuCls.setLogCmd('load map file ' + $("#" + ic.pre + "dsn6file" + type).val() + ' with sigma ' + sigma, false); + }; + reader.readAsArrayBuffer(file); + } + } + + async loadMtzFileBase(data, type, sigma, location, bInputSigma, url) {var ic = this.icn3d, me = ic.icn3dui; + if(ic.bMtz === undefined) { + let url = "./script/mtz.js"; + await me.getAjaxPromise(url, 'script'); + + ic.bMtz = true; + } + + GemmiMtz().then(function(Gemmi) { + let mtz = Gemmi.readMtz(data); + + sigma = ic.ccp4ParserCls.load_maps_from_mtz_buffer(mtz, type, sigma, location, bInputSigma); + + // if(type == '2fofc') { + // ic.bAjax2fofcCcp4 = true; + // } + // else if(type == 'fofc') { + // ic.bAjaxfofcCcp4 = true; + // } + ic.setOptionCls.setOption('map', type); + if(url) me.htmlCls.clickMenuCls.setLogCmd('set map ' + type + ' sigma ' + sigma + ' file mtz | ' + encodeURIComponent(url), true); + + return sigma; + }); + } + + async loadMtzFileUrl(type) {var ic = this.icn3d; ic.icn3dui; let url = $("#" + ic.pre + "dsn6fileurl" + type).val(); let sigma = $("#" + ic.pre + "dsn6sigmaurl" + type).val(); if(!url) { alert("Please input the file URL before clicking 'Load'"); } else { - this.dsn6ParserBase(url, type, sigma); - me.htmlCls.clickMenuCls.setLogCmd('set map ' + type + ' sigma ' + sigma + ' | ' + encodeURIComponent(url), true); + sigma = await this.mtzParserBase(url, type, sigma, 'url'); + + console.log("### sigma " + sigma); + //me.htmlCls.clickMenuCls.setLogCmd('set map ' + type + ' sigma ' + sigma + ' file mtz | ' + encodeURIComponent(url), true); } } @@ -54345,6 +55479,9 @@ class DensityCifParser { ic.mapData.header2 = header; ic.mapData.data2 = density.data; + for(let i = 0; i < density.data.length; ++i) { + density.data[i]; + } let origin = density.box.origin; let dimensions = density.box.dimensions; @@ -54379,6 +55516,7 @@ class DensityCifParser { origin = density.box.origin; dimensions = density.box.dimensions; basis = density.spacegroup.basis; + scale = new THREE.Matrix4().makeScale( dimensions[0] / (sampleCount[0] ), dimensions[1] / (sampleCount[1] ), @@ -56007,7 +57145,10 @@ class ParserUtils { if(bAppend) { if(ic.bSetChainsAdvancedMenu) ic.definedSetsCls.showSets(); - if(ic.bAnnoShown) await ic.showAnnoCls.showAnnotations(); + if(ic.bAnnoShown) { + await ic.showAnnoCls.showAnnotations(); + ic.annotationCls.resetAnnoTabAll(); + } } // Realign by sequence alignment with the residues in "segment", i.e., transmembrane helix @@ -57337,12 +58478,12 @@ class SetSeqAlign { if(i > 0) { let index1 = alignIndex; - + for(let j = prevIndex1 + 1, jl = start1; j < jl; ++j) { - if(posChain1[j]) continue; + //if(posChain1[j]) continue; posChain1[j] = 1; - if(ic.chainsSeq[chainid1] === undefined || ic.chainsSeq[chainid1][j] === undefined) break; + //if(ic.chainsSeq[chainid1] === undefined || ic.chainsSeq[chainid1][j] === undefined) break; //let resi = this.getResiAferAlign(chainid1, bRealign, j + 1); let resi = this.getResiAferAlign(chainid1, bRealign, j); @@ -57353,18 +58494,19 @@ class SetSeqAlign { color = me.htmlCls.GREY8; classname = 'icn3d-nalign'; - + ic.nalignHash1[chainid1 + '_' + resi] = 1; this.setSeqPerResi(chainid1, chainid1, chainid2, resi, resn, false, color, undefined, classname, true, false, index1); ++index1; } let index2 = alignIndex; + for(let j = prevIndex2 + 1, jl = start2; j < jl; ++j) { - if(posChain2[j]) continue; + //if(posChain2[j]) continue; posChain2[j] = 1; - if(ic.chainsSeq[chainid2] === undefined || ic.chainsSeq[chainid2] === undefined) break; + //if(ic.chainsSeq[chainid2] === undefined || ic.chainsSeq[chainid2] === undefined) break; //let resi = this.getResiAferAlign(chainid2, bRealign, j + 1); let resi = this.getResiAferAlign(chainid2, bRealign, j); @@ -57410,7 +58552,7 @@ class SetSeqAlign { } for(let j = 0; j <= end1 - start1; ++j) { - if(ic.chainsSeq[chainid1] === undefined || ic.chainsSeq[chainid2] === undefined) break; + ///if(ic.chainsSeq[chainid1] === undefined || ic.chainsSeq[chainid2] === undefined) break; let resi1, resi2, resn1, resn2; /* @@ -57440,15 +58582,17 @@ class SetSeqAlign { if(resn1 == '?' || resn2 == '?') continue; } else { - if(ic.chainsSeq[chainid1][j + start1] === undefined || ic.chainsSeq[chainid2][j + start2] === undefined) continue; + ///if(ic.chainsSeq[chainid1][j + start1] === undefined || ic.chainsSeq[chainid2][j + start2] === undefined) continue; // resi1 = ic.chainsSeq[chainid1][j + start1].resi; // resi2 = ic.chainsSeq[chainid2][j + start2].resi; // resn1 = ic.chainsSeq[chainid1][j + start1].name.toUpperCase(); // resn2 = ic.chainsSeq[chainid2][j + start2].name.toUpperCase(); - resi1 = this.getResiAferAlign(chainid1, bRealign, j + start1 + 1); - resi2 = this.getResiAferAlign(chainid2, bRealign, j + start2 + 1); + // resi1 = this.getResiAferAlign(chainid1, bRealign, j + start1 + 1); + // resi2 = this.getResiAferAlign(chainid2, bRealign, j + start2 + 1); + resi1 = this.getResiAferAlign(chainid1, bRealign, j + start1); + resi2 = this.getResiAferAlign(chainid2, bRealign, j + start2); resn1 = this.getResnFromResi(chainid1, resi1).toUpperCase(); resn2 = this.getResnFromResi(chainid2, resi2).toUpperCase(); } @@ -62504,7 +63648,8 @@ class LoadScript { let strArray = ic.commands[i].split("|||"); let command = strArray[0].trim(); - if(ic.inputid) ic.bNotLoadStructure = true; + // sometimes URL has an ID input, then load a structure in commands + //if(ic.inputid) ic.bNotLoadStructure = true; if(command.indexOf('load') !== -1) { if(end === 0 && start === end) { @@ -62540,18 +63685,7 @@ class LoadScript { } } else if(command.indexOf('set map') == 0 && command.indexOf('set map wireframe') == -1) { - //set map 2fofc sigma 1.5 - let urlArray = strArray[0].trim().split(' | '); - - let str = urlArray[0].substr(8); - let paraArray = str.split(" "); - - if(paraArray.length == 3 && paraArray[1] == 'sigma') { - paraArray[2]; - paraArray[0]; - - await thisClass.applyCommandMap(strArray[0].trim()); - } + await thisClass.applyCommandMap(strArray[0].trim()); } else if(command.indexOf('set emmap') == 0 && command.indexOf('set emmap wireframe') == -1) { //set emmap percentage 70 @@ -63051,17 +64185,34 @@ class LoadScript { // ic.deferredMap = $.Deferred(function() { let ic = thisClass.icn3d; //"set map 2fofc sigma 1.5" // or "set map 2fofc sigma 1.5 | [url]" + + // added more para later + //"set map 2fofc sigma 1.5 file dsn6" + // or "set map 2fofc sigma 1.5 file dsn6 | [url]" let urlArray = command.split(" | "); let str = urlArray[0].substr(8); let paraArray = str.split(" "); - if(paraArray.length == 3 && paraArray[1] == 'sigma') { + //if(paraArray.length == 3 && paraArray[1] == 'sigma') { + if(paraArray[1] == 'sigma') { let sigma = paraArray[2]; let type = paraArray[0]; + let fileType = 'dsn6'; + if(paraArray.length == 5) fileType = paraArray[4]; + if(urlArray.length == 2) { - await ic.dsn6ParserCls.dsn6ParserBase(urlArray[1], type, sigma); + let bInputSigma = true; + if(fileType == 'dsn6') { + await ic.dsn6ParserCls.dsn6ParserBase(urlArray[1], type, sigma, 'url', bInputSigma); + } + else if(fileType == 'ccp4') { + await ic.ccp4ParserCls.ccp4ParserBase(urlArray[1], type, sigma, 'url', bInputSigma); + } + else if(fileType == 'mtz') { + await ic.mtzParserCls.mtzParserBase(urlArray[1], type, sigma, 'url', bInputSigma); + } } else { await ic.dsn6ParserCls.dsn6Parser(ic.inputid, type, sigma); @@ -72005,7 +73156,7 @@ class Ray { } // from iview (http://istar.cse.cuhk.edu.hk/iview/) - getAtomsFromPosition(point, threshold) { let ic = this.icn3d, me = ic.icn3dui; + getAtomsFromPosition(point, threshold, atoms) { let ic = this.icn3d, me = ic.icn3dui; let i; if(threshold === undefined || threshold === null) { @@ -72013,7 +73164,8 @@ class Ray { } //for (i in ic.atoms) { - for (i in ic.dAtoms) { + let atomHash = (atoms) ? atoms : ic.dAtoms; + for (i in atomHash) { let atom = ic.atoms[i]; if(ic.ions.hasOwnProperty(i) && ic.opts['ions'] === 'sphere') { @@ -73585,6 +74737,8 @@ class iCn3D { this.alignParserCls = new AlignParser(this); this.chainalignParserCls = new ChainalignParser(this); this.dsn6ParserCls = new Dsn6Parser(this); + this.ccp4ParserCls = new Ccp4Parser(this); + this.mtzParserCls = new MtzParser(this); this.mmcifParserCls = new MmcifParser(this); this.mmdbParserCls = new MmdbParser(this); this.mmtfParserCls = new MmtfParser(this); @@ -73847,7 +75001,7 @@ class iCn3DUI { //even when multiple iCn3D viewers are shown together. this.pre = this.cfg.divid + "_"; - this.REVISION = '3.28.4'; + this.REVISION = '3.29.0'; // In nodejs, iCn3D defines "window = {navigator: {}}" this.bNode = (Object.keys(window).length < 2) ? true : false; diff --git a/dist/CHANGELOG.md b/dist/CHANGELOG.md index 27ef4b28..67e8eba7 100644 --- a/dist/CHANGELOG.md +++ b/dist/CHANGELOG.md @@ -1,4 +1,6 @@ ## Change Log +[icn3d-3.29.0](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-3.29.0.zip) was release on December 13, 2023. Added the feature to load electron density maps from ccp4 or MTZ files either locally or via URLs. + [icn3d-3.28.4](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-3.28.4.zip) was release on November 7, 2023. Enabled to show DelPhi potential for multiple structures. [icn3d-3.28.3](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-3.28.3.zip) was release on October 5, 2023. Fixed the async/await issue for electron density maps and EM density maps. @@ -307,7 +309,7 @@ [icn3d-2.15.0](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-2.15.0.zip) was release on April 21, 2020. Enabled to show the same structure "Side by Side" in two views in the "View" menu. Each view has the same orientation, but can have independent 3D display. Enabled to add multiple sequence alignments as tracks when clicking "Add Track" in the "Sequences & Annotations" window. Added "Hide Selection" in the "View" menu. Improved selection on "H-Bonds & Interactions". Improved the UI for "Realign Selection" in the "File" menu. The gallery shows COVID-19-related structures at the top. -[icn3d-2.14.0](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-2.14.0.zip) was release on April 15, 2020. Added the features to load Electron Density data in the menu "File > Open File > Electron Density (DSN6)", resize the 3D window, realign two structures in the menu "File > Realign", color residues with custom colors in the menu "Color > Residue > Custom", and add custom colors when aligning a sequence to a structure. +[icn3d-2.14.0](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-2.14.0.zip) was release on April 15, 2020. Added the features to load Electron Density data in the menu "File > Open File > Electron Density", resize the 3D window, realign two structures in the menu "File > Realign", color residues with custom colors in the menu "Color > Residue > Custom", and add custom colors when aligning a sequence to a structure. [icn3d-2.13.1](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-2.13.1.zip) was release on March 26, 2020. Showed membranes for transmembrane proteins in VAST+ alignment. diff --git a/dist/README.md b/dist/README.md index a499f103..9b2afac9 100644 --- a/dist/README.md +++ b/dist/README.md @@ -123,6 +123,7 @@ iCn3D also accepts the following file types: PDB, mmCIF, Mol2, SDF, XYZ, and iCn * **[Orientations of Proteins in Membranes (OPM)](https://opm.phar.umich.edu/)**: The membrane data of transmembrane proteins are from OPM. * **[Membranome](https://membranome.org)**: For AlphaFold Structures, the membrane data of single-spanning transmembrane proteins are from Membranome. * **[Post-Translational Modification (PTM)](https://www.ebi.ac.uk/proteins/api/doc/#/features)**: The PTM data are from UniProt. +* **[UglyMol](https://github.com/uglymol/uglymol.github.io)**: The electron density maps from CCP4 map or MTZ format are based on UglyMol. ## Building diff --git a/dist/full.html b/dist/full.html index d836cc5a..7fdf1f01 100644 --- a/dist/full.html +++ b/dist/full.html @@ -19,11 +19,11 @@
    - + - + - + - + - + - +
    StructureChainResidue Number
    "+i[e].substr(0,t)+""+i[e].substr(t+1,s-t-1)+""+i[e].substr(s+1)+"