diff --git a/CHANGELOG.md b/CHANGELOG.md old mode 100644 new mode 100755 index 65410f83..1f34907f --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## Change Log -[icn3d-3.33.2](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-3.33.1.zip) was release on June 25, 2024. Enabled to measure angles between sets in the menu "Analysis > Angle". +[icn3d-3.33.3](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-3.33.3.zip) was release on July 15, 2024. Switch electron density data from RCSB DSN6 to PDBe Density Server. + +[icn3d-3.33.2](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-3.33.2.zip) was release on June 25, 2024. Enabled to measure angles between sets in the menu "Analysis > Angle". [icn3d-3.33.1](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-3.33.1.zip) was release on June 18, 2024. Draw coils for the whole structure with zero radius for the secondary structure parts. diff --git a/LICENSE.md b/LICENSE.md old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/SECURITY.md b/SECURITY.md old mode 100644 new mode 100755 diff --git a/build/icn3d.js b/build/icn3d.js index 9af17fb7..04138807 100644 --- a/build/icn3d.js +++ b/build/icn3d.js @@ -11304,8 +11304,8 @@ var icn3d = (function (exports) { //if(!me.cfg.notebook) dialog.dialog( "close" ); 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); + //await ic.dsn6ParserCls.dsn6Parser(ic.inputid, type, sigma2fofc); + await ic.densityCifParserCls.densityCifParser(ic.inputid, type, sigma2fofc); //ic.setOptionCls.setOption('map', '2fofc'); thisClass.setLogCmd('set map 2fofc sigma ' + sigma2fofc, true); @@ -11317,7 +11317,8 @@ var icn3d = (function (exports) { //if(!me.cfg.notebook) dialog.dialog( "close" ); let sigmafofc = parseFloat($("#" + me.pre + "sigmafofc" ).val()); let type = 'fofc'; - await ic.dsn6ParserCls.dsn6Parser(ic.inputid, type, sigmafofc); + //await ic.dsn6ParserCls.dsn6Parser(ic.inputid, type, sigmafofc); + await ic.densityCifParserCls.densityCifParser(ic.inputid, type, sigma2fofc); //ic.setOptionCls.setOption('map', 'fofc'); thisClass.setLogCmd('set map fofc sigma ' + sigmafofc, true); }); @@ -11866,6 +11867,18 @@ var icn3d = (function (exports) { me.htmlCls.dialogCls.openDlg('dl_contact', 'Set contact map'); }); + me.myEventCls.onIds(["#" + me.pre + "mn6_DSSP"], "click", async function(e) { let ic = me.icn3d; //e.preventDefault(); + thisClass.setLogCmd('set dssp sse', true); + await ic.pdbParserCls.applyCommandDssp(); + ic.bResetAnno = true; + + if(ic.bAnnoShown) { + await ic.showAnnoCls.showAnnotations(); + + ic.annotationCls.resetAnnoTabAll(); + } + }); + me.myEventCls.onIds("#" + me.pre + "mn6_hbondsNo", "click", function(e) { let ic = me.icn3d; //e.preventDefault(); ic.showInterCls.hideHbondsContacts(); @@ -13786,6 +13799,8 @@ var icn3d = (function (exports) { html += ""; html += ""; + html += this.getLink('mn6_DSSP', 'DSSP Secondary', undefined, 1); + let bOnePdb = me.cfg.mmtfid !== undefined || me.cfg.pdbid !== undefined || me.cfg.opmid !== undefined || me.cfg.mmcifid !== undefined || me.cfg.mmdbid !== undefined || me.cfg.mmdbafid !== undefined || me.cfg.gi !== undefined || me.cfg.blast_rep_id !== undefined; if(bOnePdb) { @@ -15086,14 +15101,14 @@ var icn3d = (function (exports) { html += "2fofc contour at default threshold or at: " + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6sigma2fofc' value='' size=8> σ
"; - //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: 6px 20px 0 0;'>Load CCP4" + me.htmlCls.buttonStr + "reload_mtzfile2fofc' style='margin: 6px 20px 0 0;'>Load MTZ" + me.htmlCls.buttonStr + "reload_rcsbmtzfile2fofc' style='margin-top: 6px;'>Load RCSB MTZ


"; + //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: 6px 20px 0 0;'>Load CCP4" + me.htmlCls.buttonStr + "reload_mtzfile2fofc' style='margin: 6px 20px 0 0;'>Load MTZ" + me.htmlCls.buttonStr + "reload_rcsbmtzfile2fofc' style='margin-top: 6px;'>Load RCSB MTZ


"; + html += me.htmlCls.inputFileStr + "id='" + me.pre + "dsn6file2fofc'>
" + me.htmlCls.buttonStr + "reload_ccp4file2fofc' style='margin: 6px 20px 0 0;'>Load CCP4" + me.htmlCls.buttonStr + "reload_mtzfile2fofc' style='margin: 6px 20px 0 0;'>Load MTZ" + me.htmlCls.buttonStr + "reload_rcsbmtzfile2fofc' style='margin-top: 6px;'>Load RCSB MTZ


"; html += "fofc contour at default threshold or at: " + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6sigmafofc' value='' size=8> σ
"; - //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: 6px 20px 0 0;'>Load MTZ" + me.htmlCls.buttonStr + "reload_rcsbmtzfilefofc' style='margin-top: 6px;'>Load RCSB MTZ


"; + //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: 6px 20px 0 0;'>Load MTZ" + me.htmlCls.buttonStr + "reload_rcsbmtzfilefofc' style='margin-top: 6px;'>Load RCSB MTZ


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


"; html += me.htmlCls.buttonStr + "elecmapNo4'>Remove Map
"; @@ -15107,12 +15122,16 @@ var icn3d = (function (exports) { html += "2fofc contour at default threshold or at: " + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6sigmaurl2fofc' value='' size=8> σ
"; - html += "URL in the same host: " + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6fileurl2fofc' size=20>
" + me.htmlCls.buttonStr + "reload_dsn6fileurl2fofc' style='margin: 6px 20px 0 0;'>Load DSN6" + me.htmlCls.buttonStr + "reload_ccp4fileurl2fofc' style='margin: 6px 20px 0 0;'>Load CCP4" + me.htmlCls.buttonStr + "reload_mtzfileurl2fofc' style='margin: 6px 20px 0 0;'>Load MTZ" + me.htmlCls.buttonStr + "reload_rcsbmtzfileurl2fofc' style='margin-top: 6px;'>Load RCSB MTZ


"; + //html += "URL in the same host: " + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6fileurl2fofc' size=20>
" + me.htmlCls.buttonStr + "reload_dsn6fileurl2fofc' style='margin: 6px 20px 0 0;'>Load DSN6" + me.htmlCls.buttonStr + "reload_ccp4fileurl2fofc' style='margin: 6px 20px 0 0;'>Load CCP4" + me.htmlCls.buttonStr + "reload_mtzfileurl2fofc' style='margin: 6px 20px 0 0;'>Load MTZ" + me.htmlCls.buttonStr + "reload_rcsbmtzfileurl2fofc' style='margin-top: 6px;'>Load RCSB MTZ


"; + + html += "URL in the same host: " + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6fileurl2fofc' size=20>
" + me.htmlCls.buttonStr + "reload_ccp4fileurl2fofc' style='margin: 6px 20px 0 0;'>Load CCP4" + me.htmlCls.buttonStr + "reload_mtzfileurl2fofc' style='margin: 6px 20px 0 0;'>Load MTZ" + me.htmlCls.buttonStr + "reload_rcsbmtzfileurl2fofc' style='margin-top: 6px;'>Load RCSB MTZ


"; html += "fofc contour at default threshold or at: " + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6sigmaurlfofc' value='' size=8> σ
"; - html += "URL in the same host: " + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6fileurlfofc' size=20>
" + 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: 6px 20px 0 0;'>Load MTZ" + me.htmlCls.buttonStr + "reload_rcsbmtzfileurlfofc' style='margin-top: 6px;'>Load RCSB MTZ


"; + //html += "URL in the same host: " + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6fileurlfofc' size=20>
" + 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: 6px 20px 0 0;'>Load MTZ" + me.htmlCls.buttonStr + "reload_rcsbmtzfileurlfofc' style='margin-top: 6px;'>Load RCSB MTZ


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


"; html += me.htmlCls.buttonStr + "elecmapNo5'>Remove Map
"; @@ -15661,8 +15680,9 @@ var icn3d = (function (exports) { html += ""; - html += me.htmlCls.divStr + "dl_anglemanysets' class='" + dialogClass + "'>"; + html += me.htmlCls.divStr + "dl_anglemanysets' class='" + dialogClass + "' style='max-width:500px'>"; html += this.addNotebookTitle('dl_anglemanysets', 'Measure angles among many sets'); + html += me.htmlCls.spanNowrapStr + "Note: Each set is represented by a vector, which is the X-axis of the principle axes. The angles between the vectors are then calculated.

"; html += me.htmlCls.spanNowrapStr + "1. Select sets for pairwise angles
"; html += "",t="regular",s="",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}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}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}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+="",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}setMenu5(){let e=this.icn3dui;if(e.bNode)return"";let t="";return t+="
",t+="",t+="

 Analysis

",t+="
",t+=this.setMenu5_base(),t+="
",t+="
",t+="
",t}setMenu5_base(){let e=this.icn3dui;if(e.bNode)return"";let 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}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="
"; @@ -15984,8 +16004,8 @@ var icn3d = (function (exports) { html += "Z: " + me.htmlCls.inputTextStr + "id='" + me.pre + "v2Z' value='' size=6>
"; html += "
"; - html += me.htmlCls.buttonStr + "measure_angle'>Measure Angle"; - html += "The angle is: " + me.htmlCls.inputTextStr + "id='" + me.pre + "angle_value' value='' size=6> degree."; + html += me.htmlCls.buttonStr + "measure_angle'>Measure Angle

"; + html += "The angle is: " + me.htmlCls.inputTextStr + "id='" + me.pre + "angle_value' value='' size=6> degree.

"; html += ""; html += me.htmlCls.divStr + "dl_matrix' class='" + dialogClass + "'>"; @@ -45430,7 +45450,7 @@ var icn3d = (function (exports) { } - showNewTrack(chnid, title, text, cssColorArray, inTarget2queryHash, type, color, bMsa, fromArray, toArray, seqStartLen, exonArray) { let ic = this.icn3d, me = ic.icn3dui; + showNewTrack(chnid, title, text, cssColorArray, inTarget2queryHash, type, color, bMsa, fromArray, toArray, seqStartLen, exonArray, offsetArray) { let ic = this.icn3d, me = ic.icn3dui; //if(ic.customTracks[chnid] === undefined) { // ic.customTracks[chnid] = {} //} @@ -45648,14 +45668,16 @@ var icn3d = (function (exports) { if(fromArray !== undefined) { htmlTmp2 = ''; - let fromArray2 = [], toArray2 = []; + let fromArray2 = [], toArray2 = [], offsetArray2 = []; for(let i = 0, il = fromArray.length; i < il; ++i) { fromArray2.push(fromArray[i]); + offsetArray2.push(offsetArray[i]); for(let j = parseInt(fromArray[i]); j <= parseInt(toArray[i]); ++j) { if(ic.targetGapHash !== undefined && ic.targetGapHash.hasOwnProperty(j)) { toArray2.push(j - 1); fromArray2.push(j); + offsetArray2.push(offsetArray[i]); } } @@ -45689,6 +45711,7 @@ var icn3d = (function (exports) { // determine how this range sits in the exon ranges in exonArray let startExon, endExon; + let offset = offsetArray2[i]; cnt = toArray[i] - fromArray[i] + 1; let from = prevCntTotal, to = prevCntTotal + cnt - 1; @@ -45717,26 +45740,26 @@ var icn3d = (function (exports) { endColorStr = this.getExonColor(startExon.rangeStart, startExon.rangeEnd, to); colorGradient = startColorStr + ' 0%, #FFF 50%, ' + endColorStr + ' 100%'; - htmlTmp2 += this.getExonHtml(startExon.exonIndex, colorGradient, startExon.from, endExon.to, startExon.genomeRange, chnid, simpTitle); + htmlTmp2 += this.getExonHtml(startExon.exonIndex, colorGradient, startExon.from, endExon.to, startExon.genomeRange, chnid, simpTitle, offset); } else { if(startExon) { startColorStr = this.getExonColor(startExon.rangeStart, startExon.rangeEnd, from); colorGradient = startColorStr + ' 0%, #FFF 50%, #00F 100%'; - htmlTmp2 += this.getExonHtml(startExon.exonIndex, colorGradient, startExon.from, startExon.rangeEnd, startExon.genomeRange, chnid, simpTitle); + htmlTmp2 += this.getExonHtml(startExon.exonIndex, colorGradient, startExon.from, startExon.rangeEnd, startExon.genomeRange, chnid, simpTitle, offset); } if(startExon && endExon) { for(let j = startExon.exonIndex + 1; j < endExon.exonIndex; ++j) { colorGradient = '#F00 0%, #FFF 50%, #00F 100%'; - htmlTmp2 += this.getExonHtml(j, colorGradient, exonArray[j].resStart, exonArray[j].resEnd, exonArray[j].genomeRange, chnid, simpTitle); + htmlTmp2 += this.getExonHtml(j, colorGradient, exonArray[j].resStart, exonArray[j].resEnd, exonArray[j].genomeRange, chnid, simpTitle, offset); } endColorStr = this.getExonColor(endExon.rangeStart, endExon.rangeEnd, to); colorGradient = '#F00 0%, #FFF 50%, ' + endColorStr + ' 100%'; - htmlTmp2 += this.getExonHtml(endExon.exonIndex, colorGradient, endExon.rangeStart, endExon.to, endExon.genomeRange, chnid, simpTitle); + htmlTmp2 += this.getExonHtml(endExon.exonIndex, colorGradient, endExon.rangeStart, endExon.to, endExon.genomeRange, chnid, simpTitle, offset); } } @@ -45770,8 +45793,8 @@ var icn3d = (function (exports) { } } - getExonHtml(exonIndex, colorGradient, from, to, genomeRange, chainid, simpTitle) { let ic = this.icn3d; ic.icn3dui; - return ''; + getExonHtml(exonIndex, colorGradient, from, to, genomeRange, chainid, simpTitle, offset) { let ic = this.icn3d; ic.icn3dui; + return ''; } getExonColor(start, end, pos) { let ic = this.icn3d; ic.icn3dui; @@ -46718,6 +46741,7 @@ var icn3d = (function (exports) { let fromArray = [], toArray = []; let bFound = false; let seqStartLen = 0; + let offset = 0, offsetArray = []; // for(let k = seqStart; k <= seqEnd; ++k) { for(let k = 0; k < seqLength; ++k) { //if(seqFirst[k] == '-') continue; @@ -46726,19 +46750,29 @@ var icn3d = (function (exports) { resn = trackSeqArray[j][k]; + if(resn != '-') { + if(!bFound) { + seqStartLen = k; + bFound = true; + + offset = ic.startposGiSeq - ic.seqStartLen[chainid] + seqStartLen; + } + } + if(prevResn == '-' && resn != '-') { fromArray.push(k); + offsetArray.push(offset); } if(prevResn != '-' && resn == '-') { toArray.push(k - 1); } - if(resn != '-') { - if(!bFound) { - seqStartLen = k; - bFound = true; - } + // use "offset" to adjut the residue numbers, e.g., P20138 + // some isoforms starts residues before the first residue in the template sequence + if(k >= ic.seqStartLen[chainid]) { + if(seqFirst[k] == '-') offset--; + if(resn == '-') offset++; } text += resn; //ic.giSeq[chainid][i]; @@ -46759,7 +46793,7 @@ var icn3d = (function (exports) { let title =(trackTitleArray[j].length < 20) ? trackTitleArray[j] : trackTitleArray[j].substr(0, 20) + '...'; let bMsa = true; let exonArray = (acc2exons) ? acc2exons[trackTitleArray[j]] : undefined; - this.showNewTrack(chainid, title, text, undefined, undefined, type, undefined, bMsa, fromArray, toArray, seqStartLen, exonArray); + this.showNewTrack(chainid, title, text, undefined, undefined, type, undefined, bMsa, fromArray, toArray, seqStartLen, exonArray, offsetArray); } // update exon color @@ -53567,8 +53601,10 @@ var icn3d = (function (exports) { //$.when(ic.pdbParserCls.applyCommandDssp(true)).then(function() { await ic.pdbParserCls.applyCommandDssp(true); + // original version ============= // align PDB chains for(let index in ic.pdbChainIndexHash) { + //ic.pdbChainIndexHash[index] = mmdbid_q_tmp + "_" + ic.chain_q + "_" + ic.mmdbid_t + "_" + ic.chain_t; let idArray = ic.pdbChainIndexHash[index].split('_'); mmdbid_q = idArray[0]; idArray[1]; @@ -53583,25 +53619,49 @@ var icn3d = (function (exports) { let urlalign = me.htmlCls.baseUrl + "vastdyn/vastdyn.cgi"; let urltmalign = me.htmlCls.baseUrl + "tmalign/tmalign.cgi"; + let resRangeArray = (me.cfg.resrange) ? me.cfg.resrange.split(' | ') : []; + for(let index in ic.afChainIndexHash) { let idArray = ic.afChainIndexHash[index].split('_'); mmdbid_q = idArray[0]; let chain_q = idArray[1]; + let chainid_q = mmdbid_q + '_' + chain_q; + mmdbid_t = idArray[2]; let chain_t = idArray[3]; + let chainid_t = mmdbid_t + '_' + chain_t; + + let atomSet_t = (me.cfg.resrange) ? ic.realignParserCls.getSeqCoorResid(resRangeArray[0].split(','), chainid_t).hAtoms : ic.chains[chainid_t]; + let atomSet_q = (me.cfg.resrange) ? ic.realignParserCls.getSeqCoorResid(resRangeArray[index].split(','), chainid_q).hAtoms : ic.chains[chainid_q]; + // end of original version ============= + + /* + // new version to be done for VASTsrv ============== + // dynamically align pairs in all chainids + let ajaxArray = [], indexArray = [], struArray = []; + let urlalign = me.htmlCls.baseUrl + "vastdyn/vastdyn.cgi"; + let urltmalign = me.htmlCls.baseUrl + "tmalign/tmalign.cgi"; + + let resRangeArray = (me.cfg.resrange) ? me.cfg.resrange.split(' | ') : []; + + // dynamically align pairs in all chainids + let atomSet_t = (me.cfg.resrange) ? ic.realignParserCls.getSeqCoorResid(resRangeArray[0].split(','), chainidArray[0]).hAtoms : ic.chains[chainidArray[0]]; + for(let index = 1, indexl = chainidArray.length; index < indexl; ++index) { + let atomSet_q = (me.cfg.resrange) ? ic.realignParserCls.getSeqCoorResid(resRangeArray[index].split(','), chainidArray[index]).hAtoms : ic.chains[chainidArray[index]]; + // end of new version to be done for VASTsrv ============== + */ let alignAjax; if(me.cfg.aligntool != 'tmalign') { - let jsonStr_q = ic.domain3dCls.getDomainJsonForAlign(ic.chains[mmdbid_q + '_' + chain_q]); - let jsonStr_t = ic.domain3dCls.getDomainJsonForAlign(ic.chains[mmdbid_t + '_' + chain_t]); + let jsonStr_q = ic.domain3dCls.getDomainJsonForAlign(atomSet_q); + let jsonStr_t = ic.domain3dCls.getDomainJsonForAlign(atomSet_t); let dataObj = {'domains1': jsonStr_q, 'domains2': jsonStr_t}; alignAjax = me.getAjaxPostPromise(urlalign, dataObj); } else { - let pdb_query = ic.saveFileCls.getAtomPDB(ic.chains[mmdbid_q + '_' + chain_q]); - - let pdb_target= ic.saveFileCls.getAtomPDB(ic.chains[mmdbid_t + '_' + chain_t]); + let pdb_query = ic.saveFileCls.getAtomPDB(atomSet_q); + let pdb_target= ic.saveFileCls.getAtomPDB(atomSet_t); let dataObj = {'pdb_query': pdb_query, 'pdb_target': pdb_target}; alignAjax = me.getAjaxPostPromise(urltmalign, dataObj); @@ -54004,7 +54064,7 @@ var icn3d = (function (exports) { return chainidArray; } - async downloadChainalignment(chainalign, resnum, resdef) { let ic = this.icn3d, me = ic.icn3dui; + async downloadChainalignment(chainalign) { let ic = this.icn3d, me = ic.icn3dui; let thisClass = this; ic.opts['proteins'] = 'c alpha trace'; @@ -54281,7 +54341,7 @@ var icn3d = (function (exports) { async loadOpmDataForChainalign(data1, data2, chainidArray, mmdbidArray) { let ic = this.icn3d, me = ic.icn3dui; let thisClass = this; - if(me.cfg.resnum || me.cfg.resdef) { + if(me.cfg.resnum || me.cfg.resdef || me.cfg.resrange) { if(!ic.bCommandLoad) ic.init(); // remove all previously loaded data await this.downloadChainalignmentPart2(data1, data2, undefined, chainidArray); @@ -59158,6 +59218,7 @@ var icn3d = (function (exports) { //https://www.ebi.ac.uk/pdbe/densities/doc.html if(type == '2fofc' || type == 'fofc') { + detail = 0; url = "https://www.ebi.ac.uk/pdbe/densities/x-ray/" + pdbid.toLowerCase() + "/cell?detail=" + detail; } else if(type == 'em') { @@ -59198,6 +59259,39 @@ var icn3d = (function (exports) { } } + async densityCifParserBase(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.bAjax2fofc) { + ic.mapData.sigma2 = sigma; + ic.setOptionCls.setOption('map', type); + } + else if(type == 'fofc' && ic.bAjaxfofc) { + ic.mapData.sigma = sigma; + ic.setOptionCls.setOption('map', type); + } + else { + let arrayBuffer = await me.getXMLHttpRqstPromise(url, 'GET', 'arraybuffer', type); + + thisClass.parseChannels(arrayBuffer, type, sigma); + + if(type == '2fofc' || type == 'fofc') { + ic.bAjax2fofc = true; + ic.bAjaxfofc = true; + + ic.setOptionCls.setOption('map', type); + } + else if(type == 'em') { + ic.bAjaxEm = true; + + ic.setOptionCls.setOption('emmap', type); + } + } + + // return sigma; + } + parseChannels(densitydata, type, sigma) { let ic = this.icn3d; ic.icn3dui; let cif = this.BinaryParse(densitydata); @@ -64190,7 +64284,7 @@ var icn3d = (function (exports) { let bFirstAtom = true; - let cifArray = bcifData.split('ENDMDL\n'); + let cifArray = (bText) ? bcifData.split('ENDMDL\n') : [bcifData]; for(let index = 0, indexl = cifArray.length; index < indexl; ++index) { ++moleculeNum; @@ -67181,6 +67275,16 @@ var icn3d = (function (exports) { ic.transformCls.rotateCoord(ic.hAtoms, mArrayFloat); ic.drawCls.draw(); } + else if(command.indexOf('set dssp sse') == 0) { + await ic.pdbParserCls.applyCommandDssp(); + ic.bResetAnno = true; + + if(ic.bAnnoShown) { + await ic.showAnnoCls.showAnnotations(); + + ic.annotationCls.resetAnnoTabAll(); + } + } // special, select ========== @@ -69163,20 +69267,23 @@ var icn3d = (function (exports) { } } else if(command.indexOf('load chainalignment') !== -1) { - //load chainalignment [id] | resnum [resnum] | resdef [resnum] | aligntool [aligntool] | parameters [inpara] + //load chainalignment [id] | resnum [resnum] | resdef [resdef] | aligntool [aligntool] | parameters [inpara] | resrange [resrange] let urlArray = command.split(" | "); if(urlArray.length > 1 && urlArray[1].indexOf('resnum') != -1) { me.cfg.resnum = urlArray[1].substr(urlArray[1].indexOf('resnum') + 7); } if(urlArray.length > 2 && urlArray[2].indexOf('resdef') != -1) { - me.cfg.resdef = urlArray[2].substr(urlArray[1].indexOf('resdef') + 7); + me.cfg.resdef = urlArray[2].substr(urlArray[2].indexOf('resdef') + 7); } if(urlArray.length > 3 && urlArray[3].indexOf('aligntool') != -1) { - me.cfg.aligntool = urlArray[3].substr(urlArray[1].indexOf('aligntool') + 10); + me.cfg.aligntool = urlArray[3].substr(urlArray[3].indexOf('aligntool') + 10); + } + if(urlArray.length > 5 && urlArray[5].indexOf('resrange') != -1) { + me.cfg.resrange = urlArray[5].substr(urlArray[5].indexOf('resrange') + 9); } me.cfg.chainalign = id; - await ic.chainalignParserCls.downloadChainalignment(id, me.cfg.resnum, me.cfg.resdef); + await ic.chainalignParserCls.downloadChainalignment(id); } else if(command.indexOf('load url') !== -1) { let typeStr = load_parameters[1]; // type pdb @@ -69225,7 +69332,8 @@ var icn3d = (function (exports) { if(urlArray.length == 2) { let bInputSigma = true; if(fileType == 'dsn6') { - await ic.dsn6ParserCls.dsn6ParserBase(urlArray[1], type, sigma, 'url', bInputSigma); + // await ic.dsn6ParserCls.dsn6ParserBase(urlArray[1], type, sigma, 'url', bInputSigma); + await ic.densityCifParserCls.densityCifParserBase(urlArray[1], type, sigma, 'url', bInputSigma); } else if(fileType == 'ccp4') { await ic.ccp4ParserCls.ccp4ParserBase(urlArray[1], type, sigma, 'url', bInputSigma); @@ -69238,7 +69346,8 @@ var icn3d = (function (exports) { } } else { - await ic.dsn6ParserCls.dsn6Parser(ic.inputid, type, sigma); + // await ic.dsn6ParserCls.dsn6Parser(ic.inputid, type, sigma); + await ic.densityCifParserCls.densityCifParser(ic.inputid, type, sigma); } } // }); // end of me.deferred = $.Deferred(function() { @@ -82040,7 +82149,7 @@ var icn3d = (function (exports) { //even when multiple iCn3D viewers are shown together. this.pre = this.cfg.divid + "_"; - this.REVISION = '3.33.2'; + this.REVISION = '3.33.3'; // In nodejs, iCn3D defines "window = {navigator: {}}" this.bNode = (Object.keys(window).length < 2) ? true : false; @@ -82483,9 +82592,9 @@ var icn3d = (function (exports) { ic.bChainAlign = true; ic.inputid = me.cfg.chainalign; - ic.loadCmd = 'load chainalignment ' + me.cfg.chainalign + ' | resnum ' + me.cfg.resnum + ' | resdef ' + me.cfg.resdef + ' | aligntool ' + me.cfg.aligntool + ' | parameters ' + me.cfg.inpara; + ic.loadCmd = 'load chainalignment ' + me.cfg.chainalign + ' | resnum ' + me.cfg.resnum + ' | resdef ' + me.cfg.resdef + ' | aligntool ' + me.cfg.aligntool + ' | parameters ' + me.cfg.inpara + ' | resrange ' + me.cfg.resrange; me.htmlCls.clickMenuCls.setLogCmd(ic.loadCmd, true); - await ic.chainalignParserCls.downloadChainalignment(me.cfg.chainalign, me.cfg.resnum, me.cfg.resdef); + await ic.chainalignParserCls.downloadChainalignment(me.cfg.chainalign); } else if(me.cfg.mmdbafid !== undefined) { // ic.bNCBI = true; diff --git a/build/icn3d.min.js b/build/icn3d.min.js index e6b17f1b..1df70b35 100644 --- a/build/icn3d.min.js +++ b/build/icn3d.min.js @@ -1,5 +1,5 @@ var CIFTools,$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,n,r,i,o,a,s,c,u,d,l=[],f=0,p=[],h=0,g=[],v=0,m=[],y=0,E=[],w=0,b={objects:[],lights:[],elements:[]},_=(new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3),T=new THREE.Vector4,S=new THREE.Box3(new THREE.Vector3(-1,-1,-1),new THREE.Vector3(1,1,1)),C=new THREE.Box3,x=new Array(3),R=(new Array(4),new THREE.Matrix4),A=new THREE.Matrix4,k=(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,u=null,l=new THREE.Matrix3,f=function(e){var t=e.position,n=e.positionWorld,r=e.positionScreen;n.copy(t).applyMatrix4(d),r.copy(n).applyMatrix4(A);var i=1/r.w;r.x*=i,r.y*=i,r.z*=i,e.visible=r.x>=-1&&r.x<=1&&r.y>=-1&&r.y<=1&&r.z>=-1&&r.z<=1},E=function(e,t,n){return!0===e.visible||!0===t.visible||!0===n.visible||(x[0]=e.positionScreen,x[1]=t.positionScreen,x[2]=n.positionScreen,S.isIntersectionBox(C.setFromPoints(x)))},w=function(e,t,n){return(n.positionScreen.x-e.positionScreen.x)*(t.positionScreen.y-e.positionScreen.y)-(n.positionScreen.y-e.positionScreen.y)*(t.positionScreen.x-e.positionScreen.x)<0};return{setObject:function(n){u=(c=n).material,l.getNormalMatrix(c.matrixWorld),e.length=0,t.length=0},projectVertex:f,checkTriangleVisibility:E,checkBackfaceCulling:w,pushVertex:function(e,t,i){(n=function(){if(r===h){var e=new THREE.RenderableVertex;return p.push(e),h++,r++,e}return p[r++]}()).position.set(e,t,i),f(n)},pushNormal:function(t,n,r){e.push(t,n,r)},pushUv:function(e,n){t.push(e,n)},pushLine:function(e,t){var n=p[e],r=p[t];(a=function(){if(s===y){var e=new THREE.RenderableLine;return m.push(e),y++,s++,e}return m[s++]}()).id=c.id,a.v1.copy(n),a.v2.copy(r),a.z=(n.positionScreen.z+r.positionScreen.z)/2,a.material=c.material,b.elements.push(a)},pushTriangle:function(n,r,a){var s=p[n],d=p[r],f=p[a];if(!1!==E(s,d,f)&&(u.side===THREE.DoubleSide||!0===w(s,d,f))){(i=function(){if(o===v){var e=new THREE.RenderableFace;return g.push(e),v++,o++,e}return g[o++]}()).id=c.id,i.v1.copy(s),i.v2.copy(d),i.v3.copy(f),i.z=(s.positionScreen.z+d.positionScreen.z+f.positionScreen.z)/3;for(var h=0;h<3;h++){var m=3*arguments[h],y=i.vertexNormalsModel[h];y.set(e[m],e[m+1],e[m+2]),y.applyMatrix3(l).normalize();var _=2*arguments[h];i.uvs[h].set(t[_],t[_+1])}i.vertexNormalsLength=3,i.material=c.material,b.elements.push(i)}}}};function P(){if(u===w){var e=new THREE.RenderableSprite;return E.push(e),w++,u++,e}return E[u++]}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(n,i,a,p){o=0,s=0,u=0,b.elements.length=0,!0===n.autoUpdate&&n.updateMatrixWorld(),void 0===i.parent&&i.updateMatrixWorld(),R.copy(i.matrixWorldInverse.copy(i.matrixWorld).invert()),A.multiplyMatrices(i.projectionMatrix,R),k.setFromMatrix(A),t=0,b.objects.length=0,b.lights.length=0,n.traverseVisible(function(n){if(n instanceof THREE.Light)b.lights.push(n);else if(n instanceof THREE.Mesh||n instanceof THREE.Line||n instanceof THREE.Sprite){if(!1===n.material.visible)return;!1!==n.frustumCulled&&!0!==k.intersectsObject(n)||((e=function(){if(t===f){var e=new THREE.RenderableObject;return l.push(e),f++,t++,e}return l[t++]}()).id=n.id,e.object=n,_.setFromMatrixPosition(n.matrixWorld),_.applyProjection(A),e.z=_.z,b.objects.push(e))}}),!0===a&&b.objects.sort(N);for(var h=0,g=b.objects.length;h0)for(h=0;h=-1&&T.z<=1&&((c=P()).id=v.id,c.x=T.x*H,c.y=T.y*H,c.z=T.z,c.object=v,c.rotation=v.rotation,c.scale.x=v.scale.x*Math.abs(c.x-(T.x+i.projectionMatrix.elements[0])/(T.w+i.projectionMatrix.elements[12])),c.scale.y=v.scale.y*Math.abs(c.y-(T.y+i.projectionMatrix.elements[5])/(T.w+i.projectionMatrix.elements[13])),c.material=v.material,b.elements.push(c))}}return!0===p&&b.elements.sort(N),b}},THREE.TrackballControls=function(e,t,n){"use strict";var r=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 i=new THREE.Vector3;this._state=this.STATE.NONE;var o=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 u={type:"change"},d={type:"start"},l={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 f,p,h,g,v,m,y,E,w,b=(f=new THREE.Vector2,function(e,t){return f.set((e-r.screen.left)/r.screen.width,(t-r.screen.top)/r.screen.height),f}),_=(p=new THREE.Vector3,h=new THREE.Vector3,g=new THREE.Vector3,function(e,t){g.set((e-.5*r.screen.width-r.screen.left)/(.5*r.screen.width),(.5*r.screen.height+r.screen.top-t)/(.5*r.screen.height),0);var n=g.length();return r.noRoll?n1?g.normalize():g.z=Math.sqrt(1-n*n),a.copy(r.object.position).sub(r.target),p.copy(r.object.up).setLength(g.y),p.add(h.copy(r.object.up).cross(a).setLength(g.x)),p.add(a.setLength(g.z)),p});function T(e){!1===r.enabled||Object.keys(window).length<2||(window.removeEventListener("keydown",T),o=r._state,r._state===r.STATE.NONE&&(e.keyCode!==r.keys[r.STATE.ROTATE]||r.noRotate?e.keyCode!==r.keys[r.STATE.ZOOM]||r.noZoom?e.keyCode!==r.keys[r.STATE.PAN]||r.noPan||(r._state=r.STATE.PAN):r._state=r.STATE.ZOOM:r._state=r.STATE.ROTATE))}function S(e){!1===r.enabled||Object.keys(window).length<2||(e.stopPropagation(),r._state!==r.STATE.ROTATE||r.noRotate?r._state!==r.STATE.ZOOM||r.noZoom?r._state!==r.STATE.PAN||r.noPan||r._panEnd.copy(b(e.pageX,e.pageY)):r._zoomEnd.copy(b(e.pageX,e.pageY)):r._rotateEnd.copy(_(e.pageX,e.pageY)))}function C(e){!1===r.enabled||Object.keys(window).length<2||(e.stopPropagation(),r._state=r.STATE.NONE,document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",C),r.dispatchEvent(l))}function x(e){if(!(!1===r.enabled||Object.keys(window).length<2)){e.stopPropagation();var t=0;e.wheelDelta?t=e.wheelDelta/40:e.detail&&(t=-e.detail/3),r._zoomStart.y=.005*t,r.dispatchEvent(d),r.dispatchEvent(l)}}this.rotateCamera=(v=new THREE.Vector3,m=new THREE.Quaternion,function(e,t){var i;void 0===e&&(i=Math.acos(r._rotateStart.dot(r._rotateEnd)/r._rotateStart.length()/r._rotateEnd.length())),(i||void 0!==e)&&(void 0===e?(v.crossVectors(r._rotateStart,r._rotateEnd).normalize(),i*=r.rotateSpeed,m.setFromAxisAngle(v,-i)):m.copy(e),void 0===n||void 0===n.quaternion||void 0!==t&&!0!==t||n.quaternion.multiplyQuaternions(m,n.quaternion),a.applyQuaternion(m),r.object.up.applyQuaternion(m),r._rotateEnd.applyQuaternion(m),r.staticMoving?r._rotateStart.copy(r._rotateEnd):(m.setFromAxisAngle(v,i*(r.dynamicDampingFactor-1)),r._rotateStart.applyQuaternion(m)))}),this.zoomCamera=function(e,t){var i;r._state===r.STATE.TOUCH_ZOOM_PAN?(void 0!==e?i=e:(i=s/c,s=c),a.multiplyScalar(i),void 0===n||void 0===n._zoomFactor||void 0!==t&&!0!==t||(n._zoomFactor*=i,n.fogCls.setFog())):(i=void 0!==e?e:1+(r._zoomEnd.y-r._zoomStart.y)*r.zoomSpeed,void 0===n||void 0===n._zoomFactor||void 0!==t&&!0!==t||(n._zoomFactor*=i,n.fogCls.setFog()),1!==i&&(a.multiplyScalar(i),r.staticMoving?r._zoomStart.copy(r._zoomEnd):r._zoomStart.y+=(r._zoomEnd.y-r._zoomStart.y)*this.dynamicDampingFactor))},this.panCamera=(y=new THREE.Vector2,E=new THREE.Vector3,w=new THREE.Vector3,function(e,t){void 0!==e?(y=e,void 0===n||void 0===n.mouseChange||void 0!==t&&!0!==t||n.mouseChange.add(e)):(y.copy(r._panEnd).sub(r._panStart),void 0===n||void 0===n.mouseChange||void 0!==t&&!0!==t||n.mouseChange.add(r._panEnd).sub(r._panStart)),y.lengthSq()&&(y.multiplyScalar(a.length()*r.panSpeed),w.copy(a).cross(r.object.up).setLength(y.x),w.add(E.copy(r.object.up).setLength(y.y)),r.object.position.add(w),r.target.add(w),r.staticMoving?r._panStart.copy(r._panEnd):r._panStart.add(y.subVectors(r._panEnd,r._panStart).multiplyScalar(r.dynamicDampingFactor)))}),this.checkDistances=function(){r.noZoom&&r.noPan||(a.lengthSq()>r.maxDistance*r.maxDistance&&r.object.position.addVectors(r.target,a.setLength(r.maxDistance)),a.lengthSq()1e-6&&(r.dispatchEvent(u),i.copy(r.object.position))},this.reset=function(){r._state=r.STATE.NONE,o=r.STATE.NONE,r.target.copy(r.target0),r.object.position.copy(r.position0),r.object.up.copy(r.up0),a.subVectors(r.object.position,r.target),r.object.lookAt(r.target),r.dispatchEvent(u),i.copy(r.object.position)},Object.keys(window).length>=2&&this.domElement&&(this.domElement.addEventListener("contextmn",function(e){},!1),this.domElement.addEventListener("mousedown",function(e){!1===r.enabled||Object.keys(window).length<2||(e.stopPropagation(),r._state===r.STATE.NONE&&(r._state=e.button),r._state!==r.STATE.ROTATE||r.noRotate?r._state!==r.STATE.ZOOM||r.noZoom?r._state!==r.STATE.PAN||r.noPan||(r._panStart.copy(b(e.pageX,e.pageY)),r._panEnd.copy(r._panStart)):(r._zoomStart.copy(b(e.pageX,e.pageY)),r._zoomEnd.copy(r._zoomStart)):(r._rotateStart.copy(_(e.pageX,e.pageY)),r._rotateEnd.copy(r._rotateStart)),document.addEventListener("mousemove",S,!1),document.addEventListener("mouseup",C,!1),r.dispatchEvent(d))},!1),this.domElement.addEventListener("mousewheel",x,!1),this.domElement.addEventListener("DOMMouseScroll",x,!1),this.domElement.addEventListener("touchstart",function(e){if(!(!1===r.enabled||Object.keys(window).length<2)){switch(e.touches.length){case 1:r._state=r.STATE.TOUCH_ROTATE,r._rotateStart.copy(_(e.touches[0].pageX,e.touches[0].pageY)),r._rotateEnd.copy(r._rotateStart);break;case 2:r._state=r.STATE.TOUCH_ZOOM_PAN;var t=e.touches[0].pageX-e.touches[1].pageX,n=e.touches[0].pageY-e.touches[1].pageY;c=s=Math.sqrt(t*t+n*n);var i=(e.touches[0].pageX+e.touches[1].pageX)/2,o=(e.touches[0].pageY+e.touches[1].pageY)/2;r._panStart.copy(b(i,o)),r._panEnd.copy(r._panStart);break;default:r._state=r.STATE.NONE}r.dispatchEvent(d)}},!1),this.domElement.addEventListener("touchend",function(e){if(!(!1===r.enabled||Object.keys(window).length<2)){switch(e.touches.length){case 1:r._rotateEnd.copy(_(e.touches[0].pageX,e.touches[0].pageY)),r._rotateStart.copy(r._rotateEnd);break;case 2:s=c=0;var t=(e.touches[0].pageX+e.touches[1].pageX)/2,n=(e.touches[0].pageY+e.touches[1].pageY)/2;r._panEnd.copy(b(t,n)),r._panStart.copy(r._panEnd)}r._state=r.STATE.NONE,r.dispatchEvent(l)}},!1),this.domElement.addEventListener("touchmove",function(e){if(!(!1===r.enabled||Object.keys(window).length<2))switch(e.stopPropagation(),e.touches.length){case 1:r._rotateEnd.copy(_(e.touches[0].pageX,e.touches[0].pageY));break;case 2:var t=e.touches[0].pageX-e.touches[1].pageX,n=e.touches[0].pageY-e.touches[1].pageY;c=Math.sqrt(t*t+n*n);var i=(e.touches[0].pageX+e.touches[1].pageX)/2,o=(e.touches[0].pageY+e.touches[1].pageY)/2;r._panEnd.copy(b(i,o));break;default:r._state=r.STATE.NONE}},!1),Object.keys(window).length>=2&&window.addEventListener("keydown",T,!1),Object.keys(window).length>=2&&window.addEventListener("keyup",function(e){!1===r.enabled||Object.keys(window).length<2||(r._state=o,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,n){this.icn3d;var r=this,i={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 o=new THREE.Vector3;this._state=i.NONE;var a=i.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,u=0,d=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 l={type:"change"},f={type:"start"},p={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 h,g,v,m,y,E,w,b,_,T=(h=new THREE.Vector2,function(e,t){return h.set((e-r.screen.left)/r.screen.width,(t-r.screen.top)/r.screen.height),h}),S=(g=new THREE.Vector3,v=new THREE.Vector3,m=new THREE.Vector3,function(e,t){m.set((e-.5*r.screen.width-r.screen.left)/(.5*r.screen.width),(.5*r.screen.height+r.screen.top-t)/(.5*r.screen.height),0);var n=m.length();return r.noRoll?n1?m.normalize():m.z=Math.sqrt(1-n*n),s.copy(r.object.position).sub(r.target),g.copy(r.object.up).setLength(m.y),g.add(v.copy(r.object.up).cross(s).setLength(m.x)),g.add(s.setLength(m.z)),g});function C(e){!1===r.enabled||Object.keys(window).length<2||(window.removeEventListener("keydown",C),a=r._state,r._state===i.NONE&&(e.keyCode!==r.keys[i.ROTATE]||r.noRotate?e.keyCode!==r.keys[i.ZOOM]||r.noZoom?e.keyCode!==r.keys[i.PAN]||r.noPan||(r._state=i.PAN):r._state=i.ZOOM:r._state=i.ROTATE))}function x(e){!1===r.enabled||Object.keys(window).length<2||(e.stopPropagation(),r._state!==i.ROTATE||r.noRotate?r._state!==i.ZOOM||r.noZoom?r._state!==i.PAN||r.noPan||r._panEnd.copy(T(e.pageX,e.pageY)):r._zoomEnd.copy(T(e.pageX,e.pageY)):r._rotateEnd.copy(S(e.pageX,e.pageY)))}function R(e){!1===r.enabled||Object.keys(window).length<2||(e.stopPropagation(),r._state=i.NONE,document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",R),r.dispatchEvent(p))}function A(e){if(!(!1===r.enabled||Object.keys(window).length<2)){e.stopPropagation();var t=0;e.wheelDelta?t=e.wheelDelta/40:e.detail&&(t=-e.detail/3),r._zoomStart.y=.01*t,r.dispatchEvent(f),r.dispatchEvent(p)}}this.rotateCamera=(y=new THREE.Vector3,E=new THREE.Quaternion,function(e,t){var i;void 0===e&&(i=Math.acos(r._rotateStart.dot(r._rotateEnd)/r._rotateStart.length()/r._rotateEnd.length())),(i||void 0!==e)&&(void 0===e?(y.crossVectors(r._rotateStart,r._rotateEnd).normalize(),i*=r.rotateSpeed,E.setFromAxisAngle(y,-i)):E.copy(e),void 0===n||void 0===n.quaternion||void 0!==t&&!0!==t||n.quaternion.multiplyQuaternions(E,n.quaternion),s.applyQuaternion(E),r.object.up.applyQuaternion(E),r._rotateEnd.applyQuaternion(E),r.staticMoving?r._rotateStart.copy(r._rotateEnd):(E.setFromAxisAngle(y,i*(r.dynamicDampingFactor-1)),r._rotateStart.applyQuaternion(E)))}),this.zoomCamera=function(e,t){var o;r._state===i.TOUCH_ZOOM_PAN?void 0!==e?o=e:(o=u/d,u=d):o=void 0!==e?e:1+(r._zoomEnd.y-r._zoomStart.y)*r.zoomSpeed/.01,void 0===n||void 0===n._zoomFactor||void 0!==t&&!0!==t||(n._zoomFactor*=o),1!==o&&(c=o,r.object.left=c*r.left0+(1-c)*r.center0.x,r.object.right=c*r.right0+(1-c)*r.center0.x,r.object.top=c*r.top0+(1-c)*r.center0.y,r.object.bottom=c*r.bottom0+(1-c)*r.center0.y,r.staticMoving?r._zoomStart.copy(r._zoomEnd):r._zoomStart.y+=(r._zoomEnd.y-r._zoomStart.y)*this.dynamicDampingFactor)},this.panCamera=(w=new THREE.Vector2,b=new THREE.Vector3,_=new THREE.Vector3,function(e,t){void 0!==e?(w=e,void 0===n||void 0===n.mouseChange||void 0!==t&&!0!==t||n.mouseChange.add(e)):(w.copy(r._panEnd).sub(r._panStart),void 0===n||void 0===n.mouseChange||void 0!==t&&!0!==t||n.mouseChange.add(r._panEnd).sub(r._panStart)),w.lengthSq()&&(w.multiplyScalar(s.length()*r.panSpeed),_.copy(s).cross(r.object.up).setLength(w.x),_.add(b.copy(r.object.up).setLength(w.y)),r.object.position.add(_),r.target.add(_),r.staticMoving?r._panStart.copy(r._panEnd):r._panStart.add(w.subVectors(r._panEnd,r._panStart).multiplyScalar(r.dynamicDampingFactor)))}),this.update=function(e){s.subVectors(r.object.position,r.target),r.noRotate||(void 0!==e&&void 0!==e.quaternion?r.rotateCamera(e.quaternion,e.update):r.rotateCamera()),r.noZoom||(void 0!==e&&void 0!==e._zoomFactor?r.zoomCamera(e._zoomFactor,e.update):r.zoomCamera(),r.object.updateProjectionMatrix()),r.noPan||(void 0!==e&&void 0!==e.mouseChange?r.panCamera(e.mouseChange,e.update):r.panCamera()),r.object.position.addVectors(r.target,s),r.object.lookAt(r.target),o.distanceToSquared(r.object.position)>1e-6&&(r.dispatchEvent(l),o.copy(r.object.position))},this.reset=function(){r._state=i.NONE,a=i.NONE,r.target.copy(r.target0),r.object.position.copy(r.position0),r.object.up.copy(r.up0),s.subVectors(r.object.position,r.target),r.object.left=r.left0,r.object.right=r.right0,r.object.top=r.top0,r.object.bottom=r.bottom0,r.object.lookAt(r.target),r.dispatchEvent(l),o.copy(r.object.position)},Object.keys(window).length>=2&&this.domElement&&(this.domElement.addEventListener("contextmn",function(e){},!1),this.domElement.addEventListener("mousedown",function(e){!1===r.enabled||Object.keys(window).length<2||(e.stopPropagation(),r._state===i.NONE&&(r._state=e.button),r._state!==i.ROTATE||r.noRotate?r._state!==i.ZOOM||r.noZoom?r._state!==i.PAN||r.noPan||(r._panStart.copy(T(e.pageX,e.pageY)),r._panEnd.copy(r._panStart)):(r._zoomStart.copy(T(e.pageX,e.pageY)),r._zoomEnd.copy(r._zoomStart)):(r._rotateStart.copy(S(e.pageX,e.pageY)),r._rotateEnd.copy(r._rotateStart)),document.addEventListener("mousemove",x,!1),document.addEventListener("mouseup",R,!1),r.dispatchEvent(f))},!1),this.domElement.addEventListener("mousewheel",A,!1),this.domElement.addEventListener("DOMMouseScroll",A,!1),this.domElement.addEventListener("touchstart",function(e){if(!(!1===r.enabled||Object.keys(window).length<2)){switch(e.touches.length){case 1:r._state=i.TOUCH_ROTATE,r._rotateStart.copy(S(e.touches[0].pageX,e.touches[0].pageY)),r._rotateEnd.copy(r._rotateStart);break;case 2:r._state=i.TOUCH_ZOOM_PAN;var t=e.touches[0].pageX-e.touches[1].pageX,n=e.touches[0].pageY-e.touches[1].pageY;d=u=Math.sqrt(t*t+n*n);var o=(e.touches[0].pageX+e.touches[1].pageX)/2,a=(e.touches[0].pageY+e.touches[1].pageY)/2;r._panStart.copy(T(o,a)),r._panEnd.copy(r._panStart);break;default:r._state=i.NONE}r.dispatchEvent(f)}},!1),this.domElement.addEventListener("touchend",function(e){if(!(!1===r.enabled||Object.keys(window).length<2)){switch(e.touches.length){case 1:r._rotateEnd.copy(S(e.touches[0].pageX,e.touches[0].pageY)),r._rotateStart.copy(r._rotateEnd);break;case 2:u=d=0;var t=(e.touches[0].pageX+e.touches[1].pageX)/2,n=(e.touches[0].pageY+e.touches[1].pageY)/2;r._panEnd.copy(T(t,n)),r._panStart.copy(r._panEnd)}r._state=i.NONE,r.dispatchEvent(p)}},!1),this.domElement.addEventListener("touchmove",function(e){if(!(!1===r.enabled||Object.keys(window).length<2))switch(e.stopPropagation(),e.touches.length){case 1:r._rotateEnd.copy(S(e.touches[0].pageX,e.touches[0].pageY));break;case 2:var t=e.touches[0].pageX-e.touches[1].pageX,n=e.touches[0].pageY-e.touches[1].pageY;d=Math.sqrt(t*t+n*n);var o=(e.touches[0].pageX+e.touches[1].pageX)/2,a=(e.touches[0].pageY+e.touches[1].pageY)/2;r._panEnd.copy(T(o,a));break;default:r._state=i.NONE}},!1),window.addEventListener("keydown",C,!1),window.addEventListener("keyup",function(e){!1===r.enabled||Object.keys(window).length<2||(r._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,function(e){var t,n,r,i;e.VERSION={number:"1.1.7",date:"Oct 30 2018"},function(e){function t(e,t,n){(t|=0)<=0&&(t=1);var r=t*n,i=e(r);return{elementSize:n,chunkSize:r,creator:e,current:i,parts:[i],currentIndex:0,elementCount:0}}e.is=function(e){return e.creator&&e.chunkSize},e.add4=function(e,t,n,r,i){return e.currentIndex>=e.chunkSize&&(e.currentIndex=0,e.current=e.creator(e.chunkSize),e.parts[e.parts.length]=e.current),e.current[e.currentIndex++]=t,e.current[e.currentIndex++]=n,e.current[e.currentIndex++]=r,e.current[e.currentIndex++]=i,e.elementCount++},e.add3=function(e,t,n,r){return e.currentIndex>=e.chunkSize&&(e.currentIndex=0,e.current=e.creator(e.chunkSize),e.parts[e.parts.length]=e.current),e.current[e.currentIndex++]=t,e.current[e.currentIndex++]=n,e.current[e.currentIndex++]=r,e.elementCount++},e.add2=function(e,t,n){return e.currentIndex>=e.chunkSize&&(e.currentIndex=0,e.current=e.creator(e.chunkSize),e.parts[e.parts.length]=e.current),e.current[e.currentIndex++]=t,e.current[e.currentIndex++]=n,e.elementCount++},e.add=function(e,t){return e.currentIndex>=e.chunkSize&&(e.currentIndex=0,e.current=e.creator(e.chunkSize),e.parts[e.parts.length]=e.current),e.current[e.currentIndex++]=t,e.elementCount++},e.compact=function(e){var t,n=e.creator(e.elementSize*e.elementCount),r=(e.parts.length-1)*e.chunkSize,i=0;if(e.parts.length>1)if(e.parts[0].buffer)for(var o=0;o=e.chunkSize)n.set(e.current,e.chunkSize*(e.parts.length-1));else for(o=0;o9||o<0)return i*r|0;r=10*r+o|0}return i*r}function n(e,n,r,i){return 43===n.charCodeAt(r)&&r++,e*Math.pow(10,t(n,r,i))}function r(e,t,r){var i=1,o=0,a=0,s=1;for(45===e.charCodeAt(t)&&(i=-1,++t);t=0&&c<10)){if(-2===c){for(++t;t=0&&c<10))return 53===c||21===c?n(i*(o+a/s),e,t+1,r):i*(o+a/s);a=10*a+c,s*=10,++t}return i*(o+a/s)}if(53===c||21===c)return n(i*o,e,t+1,r);break}o=10*o+c,++t}return i*o}e.parseIntSkipTrailingWhitespace=function(e,n,r){for(;n0&&(e.data[e.data.length]=e.chunkData.splice(0,e.chunkOffset).join("")),e.data.join("")):e.chunkData.length===e.chunkOffset?e.chunkData.join(""):e.chunkData.splice(0,e.chunkOffset).join("")},e.writeTo=function(e,t){var n;(n=e).chunkOffset>0&&(n.chunkData.length===n.chunkOffset?n.data[n.data.length]=n.chunkData.join(""):n.data[n.data.length]=n.chunkData.splice(0,n.chunkOffset).join(""),n.chunkOffset=0);for(var r=0,i=e.data;r0&&t(e,i[o]),t(e,n)},e.writePadRight=function(e,n,r){void 0!==n&&null!==n||t(e,i[r]);var o=r-n.length;t(e,n),o>0&&t(e,i[o])},e.writeInteger=function(e,n){t(e,""+n)},e.writeIntegerPadLeft=function(e,n,r){var o=""+n,a=r-o.length;a>0&&t(e,i[a]),t(e,o)},e.writeIntegerPadRight=function(e,n,r){var o=""+n,a=r-o.length;t(e,o),a>0&&t(e,i[a])},e.writeFloat=function(e,n,r){t(e,""+Math.round(r*n)/r)},e.writeFloatPadLeft=function(e,n,r,o){var a=""+Math.round(r*n)/r,s=o-a.length;s>0&&t(e,i[s]),t(e,a)},e.writeFloatPadRight=function(e,n,r,o){var a=""+Math.round(r*n)/r,s=o-a.length;t(e,a),s>0&&t(e,i[s])}}(r.StringWriter||(r.StringWriter={}));var o=function(){function e(){this.isDefined=!1}return e.prototype.getString=function(e){return null},e.prototype.getInteger=function(e){return 0},e.prototype.getFloat=function(e){return 0},e.prototype.getValuePresence=function(e){return 1},e.prototype.areValuesEqual=function(e,t){return!0},e.prototype.stringEquals=function(e,t){return null===t},e}();e.UndefinedColumn=new o,function(e){e.getMatrix=function(e,t,n,r,i){for(var o=[],a=1;a<=n;a++){for(var s=[],c=1;c<=r;c++)s[c-1]=e.getColumn(t+"["+a+"]["+c+"]").getFloat(i);o[a-1]=s}return o},e.getVector=function(e,t,n,r,i){for(var o=[],a=1;a<=n;a++)o[a-1]=e.getColumn(t+"["+a+"]").getFloat(i);return o}}(e.Category||(e.Category={})),function(e){e.error=function(e,t){return void 0===t&&(t=-1),new a(e,t)},e.success=function(e,t){return void 0===t&&(t=[]),new l(e,t)}}(e.ParserResult||(e.ParserResult={}));var a=function(){function e(e,t){this.message=e,this.line=t,this.isError=!0}return e.prototype.toString=function(){return this.line>=0?"[Line "+this.line+"] "+this.message:this.message},e}();e.ParserError=a;var s,c,u,d,l=function(){return function(e,t){this.result=e,this.warnings=t,this.isError=!1}}();e.ParserSuccess=l,function(t){"use strict";var n;!function(e){e.create=function(){return Object.create(null)},e.get=function(e,t){if(t.length>6)return t;var n=e[t];return void 0!==n?n:(e[t]=t,t)}}(n||(n={}));var r=function(){function e(e){this.dataBlocks=[],this.data=e}return e.prototype.toJSON=function(){return this.dataBlocks.map(function(e){return e.toJSON()})},e}();t.File=r;var i=function(){function e(e,t){this.header=t,this.data=e,this.categoryList=[],this.additionalData={},this.categoryMap=new Map}return Object.defineProperty(e.prototype,"categories",{get:function(){return this.categoryList},enumerable:!0,configurable:!0}),e.prototype.getCategory=function(e){return this.categoryMap.get(e)},e.prototype.addCategory=function(e){this.categoryList[this.categoryList.length]=e,this.categoryMap.set(e.name,e)},e.prototype.toJSON=function(){return{id:this.header,categories:this.categoryList.map(function(e){return e.toJSON()}),additionalData:this.additionalData}},e}();t.DataBlock=i;var o=function(){function t(e,t,n,r,i,o,a){this.name=t,this.tokens=o,this.data=e,this.startIndex=n,this.endIndex=r,this.columnCount=i.length,this.rowCount=a/i.length|0,this.columnIndices=new Map,this.columnNameList=[];for(var s=0;s=e.length)e.currentTokenType=6;else{e.currentTokenStart=e.position,e.currentTokenEnd=e.position,e.isEscaped=!1;var n,i,o,a,s=e.data.charCodeAt(e.position);switch(s){case 35:!function(e){for(;e.position=5&&95===e.data.charCodeAt(e.currentTokenStart+4)?68!==(a=(o=e).data.charCodeAt(o.currentTokenStart))&&100!==a||65!==(a=o.data.charCodeAt(o.currentTokenStart+1))&&97!==a||84!==(a=o.data.charCodeAt(o.currentTokenStart+2))&&116!==a||65!==(a=o.data.charCodeAt(o.currentTokenStart+3))&&97!==a?83!==(i=(n=e).data.charCodeAt(n.currentTokenStart))&&115!==i||65!==(i=n.data.charCodeAt(n.currentTokenStart+1))&&97!==i||86!==(i=n.data.charCodeAt(n.currentTokenStart+2))&&118!==i||69!==(i=n.data.charCodeAt(n.currentTokenStart+3))&&101!==i?!function(e){if(e.currentTokenEnd-e.currentTokenStart!=5)return!1;var t=e.data.charCodeAt(e.currentTokenStart);return!(76!==t&&108!==t||79!==(t=e.data.charCodeAt(e.currentTokenStart+1))&&111!==t||79!==(t=e.data.charCodeAt(e.currentTokenStart+2))&&111!==t||80!==(t=e.data.charCodeAt(e.currentTokenStart+3))&&112!==t)}(e)?e.currentTokenType=3:e.currentTokenType=2:e.currentTokenType=1:e.currentTokenType=0:e.currentTokenType=3}}}function u(e){for(c(e);5===e.currentTokenType;)c(e)}function d(e,r){for(var c,d=e.currentTokenStart,l=o(e),f=a(e,l),p=[],h=n.create(512),g=0,v=!0;v;){if(4!==e.currentTokenType||!i(e,d,l)){v=!1;break}if(c=s(e),u(e),3!==e.currentTokenType)return{hasError:!0,errorLine:e.currentLineNumber,errorMessage:"Expected value."};p[p.length]=c,n.addToken(h,e.currentTokenStart,e.currentTokenEnd),g++,u(e)}return r.addCategory(new t.Category(r.data,f,d,e.currentTokenStart,p,h.tokens,g)),{hasError:!1,errorLine:0,errorMessage:""}}function l(e,r){var i=e.currentTokenStart,c=e.currentLineNumber;u(e);for(var d=a(e,o(e)),l=[],f=n.create("_atom_site"===d?r.data.length/1.85|0:1024),p=0;4===e.currentTokenType;)l[l.length]=s(e),u(e);for(;3===e.currentTokenType;)n.addToken(f,e.currentTokenStart,e.currentTokenEnd),p++,u(e);return p%l.length!=0?{hasError:!0,errorLine:e.currentLineNumber,errorMessage:"The number of values for loop starting at line "+c+" is not a multiple of the number of columns."}:(r.addCategory(new t.Category(r.data,d,i,e.currentTokenStart,l,f.tokens,p)),{hasError:!1,errorLine:0,errorMessage:""})}function f(t,n){return e.ParserResult.error(n,t)}function p(n){var r,i,o,a,s,c={data:a=n,length:a.length,position:0,currentTokenStart:0,currentTokenEnd:0,currentTokenType:6,currentLineNumber:1,isEscaped:!1},p=new t.File(n),h=new t.DataBlock(n,"default"),g=new t.DataBlock(n,"empty"),v=!1;for(u(c);6!==c.currentTokenType;){var m=c.currentTokenType;if(0===m){if(v)return f(c.currentLineNumber,"Unexpected data block inside a save frame.");h.categories.length>0&&p.dataBlocks.push(h),h=new t.DataBlock(n,n.substring(c.currentTokenStart+5,c.currentTokenEnd)),u(c)}else if(1===m){if(0===(i=n.substring(c.currentTokenStart+5,c.currentTokenEnd)).length)g.categories.length>0&&((o=h.additionalData.saveFrames)||(o=[],h.additionalData.saveFrames=o),o[o.length]=g),v=!1;else{if(v)return f(c.currentLineNumber,"Save frames cannot be nested.");v=!0,g=new t.DataBlock(n,i)}u(c)}else if(2===m){if((r=l(c,v?g:h)).hasError)return f(r.errorLine,r.errorMessage)}else{if(4!==m)return f(c.currentLineNumber,"Unexpected token. Expected data_, loop_, or data name.");if((r=d(c,v?g:h)).hasError)return f(r.errorLine,r.errorMessage)}}return v?f(c.currentLineNumber,"Unfinished save frame (`"+g.header+"`)."):(h.categories.length>0&&p.dataBlocks.push(h),s=p,e.ParserResult.success(s))}!function(e){e.addToken=function(e,t,n){var r,i;e.count>=e.tokensLenMinus2&&(r=e,(i=new Int32Array(1.61*r.tokens.length|0)).set(r.tokens),r.tokens=i,r.tokensLenMinus2=i.length-2|0),e.tokens[e.count++]=t,e.tokens[e.count++]=n},e.create=function(e){return{tokensLenMinus2:e-2|0,count:0,tokens:new Int32Array(e)}}}(n||(n={})),t.parse=function(e){return p(e)}}(e.Text||(e.Text={})),function(t){"use strict";var n=e.Utils.StringWriter,r=function(){function e(){this.writer=n.create(),this.encoded=!1,this.dataBlockCreated=!1}return e.prototype.startDataBlock=function(e){this.dataBlockCreated=!0,n.write(this.writer,"data_"+(e||"").replace(/[ \n\t]/g,"").toUpperCase()+"\n#\n")},e.prototype.writeCategory=function(e,t){if(this.encoded)throw new Error("The writer contents have already been encoded, no more writing.");if(!this.dataBlockCreated)throw new Error("No data block created.");var r=(t&&t.length?t.map(function(t){return e(t)}):[e(void 0)]).filter(function(e){return e&&e.count>0});if(r.length){var d=r.reduce(function(e,t){return e+(void 0===t.count?1:t.count)},0);d&&(1===d?function(e,t){for(var r=e.desc.fields,o=e.data,d=r.reduce(function(e,t){return Math.max(e,t.name.length)},0)+e.desc.name.length+5,l=0,f=r;l=0}function o(e,t){n.write(e,t),n.newline(e)}function a(e){n.writeSafe(e,". ")}function s(e){n.writeSafe(e,"? ")}function c(e,t){if(t){for(var r=!1,i="'",o="' ",a=!1,s=!1,c=!1,u=0,d=t.length-1;u=0){if(t<128)return 1;if(t<256)return 2;if(t<65536)return 3;if(t<4294967296)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"===n||null===t||void 0===t)return 1;if("object"===n){var o,a=0;if(Array.isArray(t)){o=t.length;for(var s=0;s=0){if(t<128)return n.setUint8(i,t),1;if(t<256)return n.setUint8(i,204),n.setUint8(i+1,t),2;if(t<65536)return n.setUint8(i,205),n.setUint16(i+1,t),3;if(t<4294967296)return n.setUint8(i,206),n.setUint32(i+1,t),5;throw new Error("Number too big 0x"+t.toString(16))}if(t>=-32)return n.setInt8(i,t),1;if(t>=-128)return n.setUint8(i,208),n.setInt8(i+1,t),2;if(t>=-32768)return n.setUint8(i,209),n.setInt16(i+1,t),3;if(t>=-2147483648)return n.setUint8(i,210),n.setInt32(i+1,t),5;throw new Error("Number too small -0x"+(-t).toString(16).substr(1))}if(null===t||void 0===t)return n.setUint8(i,192),1;if("boolean"===o)return n.setUint8(i,t?195:194),1;if("object"===o){var d,l=0,f=Array.isArray(t),p=void 0;if(f?d=t.length:(p=Object.keys(t),d=p.length),d<16?(n.setUint8(i,d|(f?144:128)),l=1):d<65536?(n.setUint8(i,f?220:222),n.setUint16(i+1,d),l=3):d<4294967296&&(n.setUint8(i,f?221:223),n.setUint32(i+1,d),l=5),f)for(var h=0;h>>0&127|0;else if(o<2048)e[t++]=o>>>6&31|192,e[t++]=o>>>0&63|128;else if(o<65536)e[t++]=o>>>12&15|224,e[t++]=o>>>6&63|128,e[t++]=o>>>0&63|128;else{if(!(o<1114112))throw new Error("bad codepoint "+o);e[t++]=o>>>18&7|240,e[t++]=o>>>12&63|128,e[t++]=o>>>6&63|128,e[t++]=o>>>0&63|128}}};var t=function(){for(var e=[],t=0;t<1024;t++)e[t]=String.fromCharCode(t);return e}();function n(e){throw new Error(e)}e.utf8Read=function(e,r,i){for(var o=t,a=void 0,s=[],c=0,u=r,d=r+i;u0&&(a[a.length]=s.slice(0,c).join("")),a.join("")):s.slice(0,c).join("")},e.utf8ByteCount=function(e){for(var t=0,r=0,i=e.length;r=0;r--)t=n.decodeStep(t,e.encoding[r]);return t}var n;e.decode=t,function(e){function r(e,t){switch(e){case 1:return new Int8Array(t);case 2:return new Int16Array(t);case 3:return new Int32Array(t);case 4:return new Uint8Array(t);case 5:return new Uint16Array(t);case 6:return new Uint32Array(t);default:throw new Error("Unsupported integer data type.")}}function i(e,t){switch(e){case 32:return new Float32Array(t);case 33:return new Float64Array(t);default:throw new Error("Unsupported floating data type.")}}(n||(n={})).decodeStep=function(e,n){switch(n.kind){case"ByteArray":switch(n.type){case 4:return e;case 1:return s=e,new Int8Array(s.buffer,s.byteOffset);case 2:return u(e,2,Int16Array);case 5:return u(e,2,Uint16Array);case 3:return u(e,4,Int32Array);case 6:return u(e,4,Uint32Array);case 32:return u(e,4,Float32Array);case 33:return u(e,8,Float64Array);default:throw new Error("Unsupported ByteArray type.")}case"FixedPoint":return function(e,t){for(var n=e.length,r=i(t.srcType,n),o=1/t.factor,a=0;a0?(r+=Math.ceil(a/t),a%t==0&&(r+=1)):(r+=Math.ceil(a/n),a%n==0&&(r+=1))}return r}function l(e){if(!(e instanceof Int32Array))throw new Error("Integer packing can only be applied to Int32 data.");var t,n,r,i,o=(n=function(e){for(var t=0,n=e.length;t=0)for(;u>=n;)o[a]=n,++a,u-=n;else for(;u<=r;)o[a]=r,++a,u-=r;o[a]=u,++a}var d=s(o);return{encodings:[{kind:"IntegerPacking",byteCount:t.bytesPerElement,isUnsigned:!t.isSigned,srcSize:i},d.encodings[0]],data:d.data}}(e,o)}n.byteArray=s,n.fixedPoint=function(e){return function(n){return function(e,n){for(var r=t.Encoding.getDataType(e),i=new Int32Array(e.length),o=0,a=e.length;o=r?i:0|Math.round((f-n)/c)}return{encodings:[{kind:"IntervalQuantization",min:n,max:r,numSteps:i,srcType:a}],data:u}}(o,e,n,r,i)}},n.runLength=c,n.delta=u,n.integerPacking=l,n.stringArray=function(t){var r=Object.create(null),i=[],o=0,a=e.Utils.ChunkedArray.create(function(e){return new Int32Array(e)},1024,1),s=new Int32Array(t.length);e.Utils.ChunkedArray.add(a,0);for(var d=0,f=0,p=t;ft[n])return!1;return!0}(r,o.version.match(/(\d)\.(\d)\.\d/).slice(1)))return e.ParserResult.error("Unsupported format version. Current "+o.version+", required "+r.join(".")+".");var a=new t.File(o);return e.ParserResult.success(a)}catch(t){return e.ParserResult.error(""+t)}}}(e.Binary||(e.Binary={})),function(e){"use strict";function t(t,n,r){var i,o=!1;t.typedArray?i=new t.typedArray(r):(o=!0,i=new Array(r));for(var a=new Uint8Array(r),s=t.presence,c=t.number?t.number:t.string,u=!0,d=0,l=0,f=n;l0});if(r.length){var i=r.reduce(function(e,t){return e+t.count},0);if(i){for(var o=r[0],a={name:o.desc.name,columns:[],rowCount:i},s=r.map(function(e){return{data:e.data,count:e.count}}),c=0,u=o.desc.fields;cn?n:e}function l(e,t){return parseInt(e,t||10)}function f(e){return Math.round(e)}function p(e){var t,n,r,i,o,a,s,c,u=+e[0],d=+e[1],l=+e[2];switch(a=l*(1-d),s=l*(1-(o=6*u-(i=Math.floor(6*u)))*d),c=l*(1-(1-o)*d),i=i||0,s=s||0,c=c||0,i%6){case 0:t=l,n=c,r=a;break;case 1:t=s,n=l,r=a;break;case 2:t=a,n=l,r=c;break;case 3:t=a,n=s,r=l;break;case 4:t=c,n=a,r=l;break;case 5:t=l,n=a,r=s}return[f(255*t),f(255*n),f(255*r)]}function h(e){return v(p(e))}function g(e){var t,n=+e[0],r=+e[1],i=+e[2],o=Math.max(n,r,i),a=Math.min(n,r,i),s=o-a,c=0===o?0:s/o,u=o/255;switch(o){case a:t=0;break;case n:t=r-i+s*(r';var z,D=w[o].children,M=N([0,1,1]),H=D[0],F=D[1],V=H[o],j=F[o],U=0,B=0,G=0,q=0,X=0,W=0,Y=0,Z=0,Q=h(M);function K(e,t){e&&"h"!==e||L("change:h",t),e&&"sv"!==e||L("change:sv",t),L("change",t)}function $(){return w.parentNode}function J(i,o){i||((l||o||f).appendChild(w),v.visible=!0),Y=P(w).w,Z=P(w).h;var a=P(F),s=P(j),c=P(H).h,u=a.w,g=a.h,m=P(V).h,y=s.w,E=s.h;if(i){function A(e){var t=e.target,r=t===n||k(t,n)===n;r?J():v.exit(),L(r?"enter":"exit",[v])}w.style.left=w.style.top="-9999px",!1!==r&&C(r,n,A),v.create=function(){return J(1),L("create",[v]),v},v.destroy=function(){return!1!==r&&x(r,n,A),v.exit(),O(!1),L("destroy",[v]),v}}else ee();function D(e){p(M);var t=p([M[0],1,1]);F.style.backgroundColor="rgb("+t.join(",")+")",O(M),I(e)}function X(e){var t,n,r,i,o,a;G&&(n=d(R(H,t=e).y,0,c),M[0]=(c-n)/c,V.style.top=n-m/2+"px",D(t),Q=h(M),U||(L("drag:h",[Q,v]),L("drag",[Q,v]),K("h",[Q,v]))),q&&(i=R(F,r=e),o=d(i.x,0,u),a=d(i.y,0,g),M[1]=1-(u-o)/u,M[2]=(g-a)/g,j.style.right=u-o-y/2+"px",j.style.top=a-E/2+"px",D(r),Q=h(M),B||(L("drag:sv",[Q,v]),L("drag",[Q,v]),K("sv",[Q,v]))),U=0,B=0}function W(e){var t=e.target,i=G?"h":"sv",o=[h(M),v],a=t===n||k(t,n)===n,s=t===w||k(t,w)===w;a||s?s&&(L("stop:"+i,o),L("stop",o),K(i,o)):$()&&!1!==r&&(v.exit(),L("exit",[v]),K(0,o)),G=0,q=0}function te(e){U=1,G=1,X(e),I(e),L("start:h",[Q,v]),L("start",[Q,v]),K("h",[Q,v])}function ne(e){B=1,q=1,X(e),I(e),L("start:sv",[Q,v]),L("start",[Q,v]),K("sv",[Q,v])}z=function(){M=N(M),D(),V.style.top=c-m/2-c*+M[0]+"px",j.style.right=u-y/2-u*+M[1]+"px",j.style.top=g-E/2-g*+M[2]+"px"},v.exit=function(n){return $()&&($().removeChild(w),v.visible=!1),x(b,H,te),x(b,F,ne),x(_,t,X),x(T,t,W),x(S,e,ee),v},z(),i||(C(b,H,te),C(b,F,ne),C(_,t,X),C(T,t,W),C(S,e,ee))}function ee(){return v.fit()}return J(1),a(function(){var e=[h(M),v];L("create",e),K(0,e)},0),v.fit=function(t){var r=P(e),i=P(g),o=r.w-i.w,a=r.h-g.clientHeight,u=A(e),l=A(n);if(X=l.l+u.l,W=l.t+u.t+P(n).h,c(t))s(t[0])&&(X=t[0]),s(t[1])&&(W=t[1]);else{var f=u.l,p=u.t,h=u.l+r.w-Y-o,m=u.t+r.h-Z-a;X=d(X,f,h)>>0,W=d(W,p,m)>>0}return w.style.left=X+"px",w.style.top=W+"px",L("fit",[v]),v},v.set=function(e){return s(e)?("string"==typeof e&&(e=m.parse(e)),O(e),z(),v):N()},v.get=function(e){return N(e)},v.target=n,v.picker=w,v.visible=!1,v.on=function(e,t,n){return s(e)?s(t)?(s(E[e])||(E[e]={}),s(n)||(n=u(E[e])),E[e][n]=t,v):E[e]:E},v.off=function(e,t){return s(e)?s(t)?(delete E[e][t],v):(E[e]={},v):(E={},v)},v.fire=L,v.hooks=E,v.enter=function(e){return J(0,e)},v}).version="1.3.9",r[i]={},r.each=function(e,t){return a(function(){var t,n=r[i];for(t in n)e(n[t],t,n)},0===t?0:t||1),r},r.parse=b,r._HSV2RGB=p,r._HSV2HEX=h,r._RGB2HSV=g,r._HEX2HSV=m,r._HEX2RGB=function(e){return[+(t=y(e))[0]/255,+t[1]/255,+t[2]/255];var t},r.HSV2RGB=function(e){return p(E(e))},r.HSV2HEX=function(e){return h(E(e))},r.RGB2HSV=function(e){return w(g(e))},r.RGB2HEX=v,r.HEX2HSV=function(e){return w(m(e))},r.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},n=e.document.createElementNS("http://www.w3.org/1999/xhtml","a"),r="download"in n,i=/constructor/i.test(e.HTMLElement)||e.safari,o=/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)},u=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},d=function(d,l,f){f||(d=u(d));var p,h=this,g="application/octet-stream"===(d?d.type:void 0),v=function(){!function(e,t,n){for(var r=(t=[].concat(t)).length;r--;){var i=e["on"+t[r]];if("function"==typeof i)try{i.call(e,n||e)}catch(e){s(e)}}}(h,"writestart progress write writeend".split(" "))};if(h.readyState=h.INIT,r)return p||(p=t().createObjectURL(d)),void a(function(){var e,t;n.href=p,n.download=l,e=n,t=new MouseEvent("click"),e.dispatchEvent(t),v(),c(p),h.readyState=h.DONE},0);!function(){if((o||g&&i)&&e.FileReader){var n=new FileReader;return n.onloadend=function(){var t=o?n.result:n.result.replace(/^data:[^;]*;/,"data:attachment/file;");e.open(t,"_blank")||(e.location.href=t),t=void 0,h.readyState=h.DONE,v()},n.readAsDataURL(d),void(h.readyState=h.INIT)}p||(p=t().createObjectURL(d)),g?e.location.href=p:e.open(p,"_blank")||(e.location.href=p);h.readyState=h.DONE,v(),c(p)}()},l=d.prototype;return"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(e,t,n){return t=t||e.name||"download",n||(e=u(e)),navigator.msSaveOrOpenBlob(e,t)}:(l.abort=function(){},l.readyState=l.INIT=0,l.WRITING=1,l.DONE=2,l.error=l.onwritestart=l.onprogress=l.onwrite=l.onabort=l.onerror=l.onwriteend=null,function(e,t,n){return new d(e,t||e.name||"download",n)})}}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this);!function(e){"use strict";var t=e.HTMLCanvasElement&&e.HTMLCanvasElement.prototype,n=e.Blob&&function(){try{return Boolean(new Blob)}catch(e){return!1}}(),r=n&&e.Uint8Array&&function(){try{return 100===new Blob([new Uint8Array(100)]).size}catch(e){return!1}}(),i=e.BlobBuilder||e.WebKitBlobBuilder||e.MozBlobBuilder||e.MSBlobBuilder,o=/^data:((.*?)(;charset=.*?)?)(;base64)?,/,a=(n||i)&&e.atob&&e.ArrayBuffer&&e.Uint8Array&&function(e){var t,a,s,c,u,d,l,f,p;if(!(t=e.match(o)))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),u=s?atob(c):decodeURIComponent(c),d=new ArrayBuffer(u.length),l=new Uint8Array(d),f=0;f0||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;if(!s)continue;s=s.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,C=new Array(9),b=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?(C[0]=x[0]*w[0]+k[0]*S[0]+O[0]*A[0],C[1]=x[0]*w[1]+k[0]*S[1]+O[0]*A[1],C[2]=x[0]*w[2]+k[0]*S[2]+O[0]*A[2],C[3]=x[1]*w[0]+k[1]*S[0]+O[1]*A[0],C[4]=x[1]*w[1]+k[1]*S[1]+O[1]*A[1],C[5]=x[1]*w[2]+k[1]*S[2]+O[1]*A[2],C[6]=x[2]*w[0]+k[2]*S[0]+O[2]*A[0],C[7]=x[2]*w[1]+k[2]*S[1]+O[2]*A[1],C[8]=x[2]*w[2]+k[2]*S[2]+O[2]*A[2]):(C[0]=x[0]*w[0]+k[0]*S[0]-O[0]*A[0],C[1]=x[0]*w[1]+k[0]*S[1]-O[0]*A[1],C[2]=x[0]*w[2]+k[0]*S[2]-O[0]*A[2],C[3]=x[1]*w[0]+k[1]*S[0]-O[1]*A[0],C[4]=x[1]*w[1]+k[1]*S[1]-O[1]*A[1],C[5]=x[1]*w[2]+k[1]*S[2]-O[1]*A[2],C[6]=x[2]*w[0]+k[2]*S[0]-O[2]*A[0],C[7]=x[2]*w[1]+k[2]*S[1]-O[2]*A[1],C[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:C,trans1:I,trans2:E,rmsd:i})}eigen_values(e){let t,s,i,n,l,r,o,a,d,c,h,p,m,u,g,f,C,b,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),b=2*Math.cbrt(e)*Math.cos(t/3)}else f=Math.cbrt(-.5*u+Math.sqrt(g)),C=Math.cbrt(-.5*u-Math.sqrt(g)),b=f+C;return b-=c/3,c+=b,p/=-b,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=_),C=p-h*d/a,b=m-h*c/a,y=g-u*d/a,v=f-u*c/a,Math.abs(C)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=[],C=[],b=[];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(C),h=h.concat(b)),f=[],C=[],b=[];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)),C.push(i[y+2]),b.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(C),h=h.concat(b),d.push(p[p.length-1-g]),c.push(p.length-1-g),h.push(t[p.length-1-g])),f=[],C=[],b=[],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)}async setIgTemplate(e){let t=this.icn3dui.icn3d;t.bRunRefnumAgain=!0;let s=t.resid2specCls.atoms2residues(Object.keys(t.hAtoms));for(let e=0,i=s.length;e0?"_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 append 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 Compound")})),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_collection","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_selectCollections","Select Collections")})),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;i.bRunRefnumAgain=!0,s.setLogCmd("ig refnum on",!0),i.bAnnoShown||await i.showAnnoCls.showAnnotations();await i.annotationCls.setAnnoTabIg(!0),i.bRunRefnumAgain=!1})),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){e.icn3d,e.cfg.notebook||dialog.dialog("close");let i=$("#"+e.pre+"refTpl").val();await s.setIgTemplate(i),s.setLogCmd("ig template "+i,!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_alignrefTpl","click",(async function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_alignrefTpl","Align with an Ig template")})),e.myEventCls.onIds("#"+e.pre+"mn6_alignrefTpl_apply","click",(async function(t){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"refTpl2").val(),l=e.hashUtilsCls.cloneHash(i.hAtoms),r=e.htmlCls.baseUrl+"icn3d/refpdb/"+n+".pdb";await i.pdbParserCls.downloadUrl(r,"pdb",void 0,n),s.setLogCmd("load url "+r+" | type pdb",!0);let o=n.replace(/_/g,"").substr(0,4),a=i.structures[o][0];i.hAtoms=e.hashUtilsCls.unionHash(l,i.chains[a]),e.cfg.aligntool="tmalign",await i.realignParserCls.realignOnStructAlign(),s.setLogCmd("realign on tmalign",!0)})),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()})),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_addlabelIg","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addIgLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add ig 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 distances among many sets"),s.setSetsMenus("atomsCustomDistTable"),i.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_angleManySets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_anglemanysets","Measure the pairwise angles among many sets"),s.setSetsMenus("atomsCustomAngleTable"),i.bMeasureAngle=!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+"mn2_translate",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_translate","Translate the X,Y,Z coordinates of the structure")})),$(document).on("click","#"+e.pre+"mn6_angleTwoSets",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_angle","Measure the angle between two vectors")})),$(document).on("click","#"+e.pre+"mn2_matrix",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_matrix","Apply matrix to the X,Y,Z coordinates of the structure")})),$(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(" ")[1];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="
    ",i="";return e+=s+this.setIcon(t,"tool_mmdbafid","Input PDB/MMDB/AlphaFold IDs","id",void 0,!0)+"
    ",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_anglemanysets' class='"+n+"'>",s+=this.addNotebookTitle("dl_anglemanysets","Measure angles among many sets"),s+=e.htmlCls.spanNowrapStr+"1. Select sets for pairwise angles
    ",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+"applyangletable'>Angles 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;return 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_angletable' class='"+n+"'>",s+=this.addNotebookTitle("dl_angletable","Angle Table",!0),s+="",s+=e.htmlCls.divStr+"dl_translate' class='"+n+"'>",s+=this.addNotebookTitle("dl_translate","Translate the X,Y,Z coordinates of the structure"),s+="X: "+e.htmlCls.inputTextStr+"id='"+e.pre+"translateX' value='' size=4> ",s+="Y: "+e.htmlCls.inputTextStr+"id='"+e.pre+"translateY' value='' size=4> ",s+="Z: "+e.htmlCls.inputTextStr+"id='"+e.pre+"translateZ' value='' size=4> ",s+=e.htmlCls.buttonStr+"translate_pdb'>Translate",s+="",s+=e.htmlCls.divStr+"dl_angle' class='"+n+"'>",s+=this.addNotebookTitle("dl_angle","Measure the angle between two vectors"),s+="Vector 1, X: "+e.htmlCls.inputTextStr+"id='"+e.pre+"v1X' value='' size=6> ",s+="Y: "+e.htmlCls.inputTextStr+"id='"+e.pre+"v1Y' value='' size=6> ",s+="Z: "+e.htmlCls.inputTextStr+"id='"+e.pre+"v1Z' value='' size=6>
    ",s+="Vector 2, X: "+e.htmlCls.inputTextStr+"id='"+e.pre+"v2X' value='' size=6> ",s+="Y: "+e.htmlCls.inputTextStr+"id='"+e.pre+"v2Y' value='' size=6> ",s+="Z: "+e.htmlCls.inputTextStr+"id='"+e.pre+"v2Z' value='' size=6>
    ",s+="
    ",s+=e.htmlCls.buttonStr+"measure_angle'>Measure Angle",s+="The angle is: "+e.htmlCls.inputTextStr+"id='"+e.pre+"angle_value' value='' size=6> degree.",s+="",s+=e.htmlCls.divStr+"dl_matrix' class='"+n+"'>",s+=this.addNotebookTitle("dl_matrix","Apply matrix to the X,Y,Z coordinates of the structure"),s+="0: "+e.htmlCls.inputTextStr+"id='"+e.pre+"matrix0' value='1' size=2> ",s+="4: "+e.htmlCls.inputTextStr+"id='"+e.pre+"matrix4' value='0' size=2> ",s+="8: "+e.htmlCls.inputTextStr+"id='"+e.pre+"matrix8' value='0' size=2> ",s+="12: "+e.htmlCls.inputTextStr+"id='"+e.pre+"matrix12' value='0' size=2>
    ",s+="1: "+e.htmlCls.inputTextStr+"id='"+e.pre+"matrix1' value='0' size=2> ",s+="5: "+e.htmlCls.inputTextStr+"id='"+e.pre+"matrix5' value='1' size=2> ",s+="9: "+e.htmlCls.inputTextStr+"id='"+e.pre+"matrix9' value='0' size=2> ",s+="13: "+e.htmlCls.inputTextStr+"id='"+e.pre+"matrix13' value='0' size=2>
    ",s+="2: "+e.htmlCls.inputTextStr+"id='"+e.pre+"matrix2' value='0' size=2> ",s+="6: "+e.htmlCls.inputTextStr+"id='"+e.pre+"matrix6' value='0' size=2> ",s+="10: "+e.htmlCls.inputTextStr+"id='"+e.pre+"matrix10' value='1' size=2> ",s+="14: "+e.htmlCls.inputTextStr+"id='"+e.pre+"matrix14' value='0' size=2>
    ",s+="3: "+e.htmlCls.inputTextStr+"id='"+e.pre+"matrix3' value='0' size=2> ",s+="7: "+e.htmlCls.inputTextStr+"id='"+e.pre+"matrix7' value='0' size=2> ",s+="11: "+e.htmlCls.inputTextStr+"id='"+e.pre+"matrix11' value='0' size=2> ",s+="15: "+e.htmlCls.inputTextStr+"id='"+e.pre+"matrix15' value='1' size=2>
    ",s+=e.htmlCls.buttonStr+"matrix_pdb'>Rotate with Matrix",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+=e.htmlCls.divStr+"dl_alignrefTpl' class='"+n+"'>",s+=this.addNotebookTitle("dl_alignrefTpl","Align with an Ig template"),s+="Choose an Ig template to align with selected residues:



    "+e.htmlCls.buttonStr+"mn6_alignrefTpl_apply'>Align Template with Selection",s+="",s+="",s+="\x3c!--/form--\x3e",s}setTemplateMenu(){let e=this.icn3dui;e.icn3d;let t={IgV:["CD28_1yjdC_human_V","CD2_1hnfA_human_V-n1","CD8a_1cd8A_human_V","FAB-HEAVY_5esv_V-n1","FAB-LIGHT_5esv_V-n1","ICOS_6x4gA_human_V","LAG3_7tzgD_human_V-n1","PD1_4zqkB_human_V","PDL1_4z18B_human_V-n1","TCRa_6jxrm_human_V-n1","VISTA_6oilA_human_V","VNAR_1t6vN_shark_V"],IgC1:["B2Microglobulin_7phrL_human_C1","CD3d_6jxrd_human_C1","CD3e_6jxrf_human_C1","FAB-LIGHT_5esv_C1-n2","FAB-HEAVY_5esv_C1-n2","GHR_1axiB_human_C1-n1","LAG3_7tzgD_human_C1-n2","MHCIa_7phrH_human_C1","Siglec3_5j0bB_human_C1-n2","TCRa_6jxrm_human_C1-n2","VTCN1_Q7Z7D3_human_C1-n2"],IgC2:["CD2_1hnfA_human_C2-n2","CD3g_6jxrg_human_C2"],IgI:["BTLA_2aw2A_human_Iset","Contactin1_3s97C_human_Iset-n2","JAM1_1nbqA_human_Iset-n2","Palladin_2dm3A_human_Iset-n1","Titin_4uowM_human_Iset-n152"],IgE:["CoAtomerGamma1_1r4xA_human","Endo-1,4-BetaXylanase10A_1i8aA_bacteria_n4","IsdA_2iteA_bacteria","NaKATPaseTransporterBeta_2zxeB_spurdogshark","TP34_2o6cA_bacteria","TP47_1o75A_bacteria"],IgFN3:["Contactin1_2ee2A_human_FN3-n9","IL6Rb_1bquB_human_FN3-n2","IL6Rb_1bquB_human_FN3-n3","InsulinR_8guyE_human_FN3-n1","InsulinR_8guyE_human_FN3-n2","Sidekick2_1wf5A_human_FN3-n7"],"IgFN3-like":["ASF1A_2iijA_human","BArrestin1_4jqiA_rat_n1","C3_2qkiD_human_n1","MPT63_1lmiA_bacteria","NaCaExchanger_2fwuA_dog_n2","RBPJ_6py8C_human_Unk-n1","RBPJ_6py8C_human_Unk-n2","TEAD1_3kysC_human"],"Other Ig":["CD19_6al5A_human-n1","CuZnSuperoxideDismutase_1hl5C_human","ECadherin_4zt1A_human_n2","LaminAC_1ifrA_human","ORF7a_1xakA_virus"]},s={ASF1A_2iijA_human:"A A' B C C' E F G G+",B2Microglobulin_7phrL_human_C1:"A B C C' D E F G",BArrestin1_4jqiA_rat_n1:"A- A A' B C C' E F G",BTLA_2aw2A_human_Iset:"A A' B C C' D E F G",C3_2qkiD_human_n1:"A A' B C C' E F G","CD19_6al5A_human-n1":"A' B C C' D E F G",CD28_1yjdC_human_V:"A A' B C C' C'' D E F G","CD2_1hnfA_human_C2-n2":"A B C C' E F G","CD2_1hnfA_human_V-n1":"A' B C C' C'' D E F G",CD3d_6jxrd_human_C1:"A B C D E F G",CD3e_6jxrf_human_C1:"A B C C' D E F G",CD3g_6jxrg_human_C2:"A B C C' E F G G+",CD8a_1cd8A_human_V:"A A' B C C' C'' D E F G",CoAtomerGamma1_1r4xA_human:"A- A B C D E F G","Contactin1_2ee2A_human_FN3-n9":"A A' B C C' E F G","Contactin1_3s97C_human_Iset-n2":"A A' B C D E F G",CuZnSuperoxideDismutase_1hl5C_human:"A- A B C C' E F G",ECadherin_4zt1A_human_n2:"A' B C D E F G","Endo-1,4-BetaXylanase10A_1i8aA_bacteria_n4":"A--- A-- A- A B C C' C'' D E F G","FAB-HEAVY_5esv_C1-n2":"A B C D E F G","FAB-HEAVY_5esv_V-n1":"A B C C' C'' D E F G","FAB-LIGHT_5esv_C1-n2":"A B C C' D E F G","FAB-LIGHT_5esv_V-n1":"A A' B C C' C'' D E F G","GHR_1axiB_human_C1-n1":"A B C C' D E F G",ICOS_6x4gA_human_V:"A B C C' C'' D E F G","IL6Rb_1bquB_human_FN3-n2":"A B C C' E F G","IL6Rb_1bquB_human_FN3-n3":"A B C C' E F G","InsulinR_8guyE_human_FN3-n1":"A B C C' E F G","InsulinR_8guyE_human_FN3-n2":"A B C C' E F G",IsdA_2iteA_bacteria:"A- A B C C' D E F G","JAM1_1nbqA_human_Iset-n2":"A A' B C C' D E F G","LAG3_7tzgD_human_C1-n2":"A A' B C C' D E F G","LAG3_7tzgD_human_V-n1":"A' B C C' D E F G",LaminAC_1ifrA_human:"A- A B C C' E E+ F G",MHCIa_7phrH_human_C1:"A B C C' D E F G",MPT63_1lmiA_bacteria:"A-- A- A BC C' E F G",NaCaExchanger_2fwuA_dog_n2:"A A' B C C' E F G",NaKATPaseTransporterBeta_2zxeB_spurdogshark:"A A' B C D E F G",ORF7a_1xakA_virus:"A' B C D E F G",PD1_4zqkB_human_V:"A A' B C C' D E F G","PDL1_4z18B_human_V-n1":"A A' B C C' C'' D E F G","Palladin_2dm3A_human_Iset-n1":"A A' B C C' D E F G","RBPJ_6py8C_human_Unk-n1":"A A' B C C' E F G","RBPJ_6py8C_human_Unk-n2":"A B C D E F G","Sidekick2_1wf5A_human_FN3-n7":"A B C C' E F G","Siglec3_5j0bB_human_C1-n2":"A A' B C D E F G","TCRa_6jxrm_human_C1-n2":"A B C D E F G","TCRa_6jxrm_human_V-n1":"A A' B C C' C'' D E F G",TEAD1_3kysC_human:"A A+ A' B C C' E F G G+",TP34_2o6cA_bacteria:"A- A B C C' D E F G",TP47_1o75A_bacteria:"A B C C' D E F G","Titin_4uowM_human_Iset-n152":"A A' B C C' D E F G",VISTA_6oilA_human_V:"A A' B C C' C'' D E F G G+",VNAR_1t6vN_shark_V:"A A' B C C' D E F G","VTCN1_Q7Z7D3_human_C1-n2":"A B C C' D E F G G+"},i="";for(let n in t){i+="";for(let l=0,r=t[n].length;l"+r+", Strands: "+s[r]+""}i+=""}return i}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+="",t+=s+e.htmlCls.inputCheckStr+"id='"+e.pre+"anno_ig'>Ig Domains"+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,n){let l=this.icn3dui.icn3d,r=this,o=t[s],a=e?"append":"load";a+=n?" mmcif file ":" pdb file ";let d=new FileReader;d.onload=async function(d){let c=d.target.result;r.setLogCmd(a+o.name,!1),e?(l.resetConfig(),l.bResetAnno=!0,l.bResetSets=!0):l.init(),l.bInputfile=!0,l.InputfileType=n?"mmcif":"pdb",l.InputfileData=l.InputfileData?l.InputfileData+"\nENDMDL\n"+c:c,i=s>0?i+"\nENDMDL\n"+c:c,Object.keys(t).length==s+1?(e&&(l.hAtoms={},l.dAtoms={}),n?await l.mmcifParserCls.loadMultipleMmcifData(i,void 0,e):await l.pdbParserCls.loadPdbData(i,void 0,void 0,e)):await r.readFile(e,t,s+1,i,n),e&&(l.bSetChainsAdvancedMenu&&l.definedSetsCls.showSets(),l.bResetAnno=!0,l.bAnnoShown&&(await l.showAnnoCls.showAnnotations(),l.annotationCls.resetAnnoTabAll()))},"object"==typeof o&&d.readAsText(o)}async loadPdbFile(e,t,s){let i=this.icn3dui,n=i.icn3d;n.bInitial=!0,i.cfg.notebook||dialog.dialog("close"),i.cfg.notebook?n.resizeCanvasCls.closeDialogs():$(".ui-dialog-content").dialog("close");let l=$("#"+i.pre+t)[0].files;l[0]?(i.htmlCls.setHtmlCls.fileSupport(),n.molTitle="",n.dataStrAll="",await this.readFile(e,l,0,"",s)):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 bcif "+$("#"+e.pre+"mmtfid").val(),!1);let l=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?bcifid="+$("#"+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+"translate_pdb","click",(function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"translateX").val(),l=$("#"+e.pre+"translateY").val(),r=$("#"+e.pre+"translateZ").val();i.transformCls.translateCoord(i.hAtoms,parseFloat(n),parseFloat(l),parseFloat(r)),i.drawCls.draw(),s.setLogCmd("translate pdb "+n+" "+l+" "+r,!0)})),e.myEventCls.onIds("#"+e.pre+"measure_angle","click",(function(t){e.icn3d,t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let i=$("#"+e.pre+"v1X").val(),n=$("#"+e.pre+"v1Y").val(),l=$("#"+e.pre+"v1Z").val(),r=$("#"+e.pre+"v2X").val(),o=$("#"+e.pre+"v2Y").val(),a=$("#"+e.pre+"v2Z").val(),d=new THREE.Vector3(parseFloat(i),parseFloat(n),parseFloat(l)).angleTo(new THREE.Vector3(parseFloat(r),parseFloat(o),parseFloat(a)))/3.1416*180;d=Math.abs(d).toFixed(0),d>180&&(d-=180),d>90&&(d=180-d),s.setLogCmd("The angle is "+d+" degree",!1),$("#"+e.pre+"angle_value").val(d)})),e.myEventCls.onIds("#"+e.pre+"matrix_pdb","click",(function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let n=[];for(let t=0;t<16;++t)n.push(parseFloat($("#"+e.pre+"matrix"+t).val()));i.transformCls.rotateCoord(i.hAtoms,n),i.drawCls.draw(),s.setLogCmd("rotate pdb "+n,!0)})),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_collectionfile","click",(function(t){let s=e.icn3d;t.preventDefault();let i=$("#"+e.pre+"collectionfile")[0].files[0];if(i){e.cfg.notebook||dialog.dialog("close"),e.cfg.notebook?s.resizeCanvasCls.closeDialogs():$(".ui-dialog-content").dialog("close"),e.htmlCls.setHtmlCls.fileSupport();let t=new FileReader;t.onload=async function(t){let i=JSON.parse(t.target.result),n=[i.structures.map((({id:e})=>e)),i.structures.map((({title:e})=>e))],l=s.selectCollectionsCls.setAtomMenu(n[0],n[1]);$("#"+s.pre+"collections_menu").html(l),s.selectCollectionsCls.clickStructure(),$("#"+s.pre+"collections_menu").trigger("change"),e.htmlCls.clickMenuCls.setLogCmd("load collection file "+$("#"+e.pre+"collectionfile").val(),!1)},t.readAsText(i),Object.keys(e.utilsCls.getStructures(s.dAtoms))?($("#"+e.pre+"dl_collection_file").hide(),$("#"+e.pre+"dl_collection_structures").show(),$("#"+e.pre+"dl_collection_file_expand").show(),$("#"+e.pre+"dl_collection_file_shrink").hide(),$("#"+e.pre+"dl_collection_structures_expand").hide(),$("#"+e.pre+"dl_collection_structures_shrink").show()):($("#"+e.pre+"dl_collection_file").show(),$("#"+e.pre+"dl_collection_structures").hide(),$("#"+e.pre+"dl_collection_file_expand").hide(),$("#"+e.pre+"dl_collection_file_shrink").hide(),$("#"+e.pre+"dl_collection_structures_expand").show(),$("#"+e.pre+"dl_collection_structures_shrink").hide()),e.htmlCls.dialogCls.openDlg("dl_selectCollections","Select Collections")}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_rcsbmtzfile2fofc","click",(function(t){let s=e.icn3d;t.preventDefault(),s.mtzParserCls.loadMtzFile("2fofc",!0)})),e.myEventCls.onIds("#"+e.pre+"reload_rcsbmtzfilefofc","click",(function(t){let s=e.icn3d;t.preventDefault(),s.mtzParserCls.loadMtzFile("fofc",!0)})),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_rcsbmtzfileurl2fofc","click",(async function(t){let s=e.icn3d;t.preventDefault(),await s.mtzParserCls.loadMtzFileUrl("2fofc",!0)})),e.myEventCls.onIds("#"+e.pre+"reload_rcsbmtzfileurlfofc","click",(async function(t){let s=e.icn3d;t.preventDefault(),await s.mtzParserCls.loadMtzFileUrl("fofc",!0)})),e.myEventCls.onIds("#"+e.pre+"reload_pdbfile","click",(async function(t){e.icn3d,t.preventDefault();await s.loadPdbFile(!1,"pdbfile")})),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,"pdbfile_app")})),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",(async function(t){let i=e.icn3d;t.preventDefault(),i.bAppend=!0;await s.loadPdbFile(i.bAppend,"mmciffile",!0)})),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+"applyangletable","click",(function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),i.bMeasureAngle=!1;let n=$("#"+e.pre+"atomsCustomAngleTable").val(),l=$("#"+e.pre+"atomsCustomAngleTable2").val();i.analysisCls.measureAngleManySets(n,l),e.htmlCls.dialogCls.openDlg("dl_angletable","Angles among the sets"),s.setLogCmd("angletable | "+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",C="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(C,!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 | "+n+" | color "+c+" | opacity "+h+" | radius "+d):(i.boxCls.createBox_base(o,d,m,void 0,void 0,void 0,h),p="add cube | "+n+" | 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 C=[],b="",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}b+=""+v+"",h=!(void 0===e||!c.hasOwnProperty(u));for(let e=0,t=y;e"}""!==a?-1!=o.alnChainsSeq[l][e].resi?b+=""+o.alnChainsSeq[l][e].resn+"":b+=""+o.alnChainsSeq[l][e].resn+"":b+=""+o.alnChainsSeq[l][e].resn+""}b+=""+_+"";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?C[t]+=' ':C[t]+=' '}else C[t]+=' '}else C[t]+=' ';else C[t]+="c"==i?' ':"o"==i?' ':"";else C[t]+=""+i+""}C[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+"
    "+C[e]+"
    "}a+=''+b+"
    ",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,C=0,b=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")&&(C=parseFloat(this.getCookie("glycan"))),""!=this.getCookie("membrane")&&(b=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='"+C+"' size=4>"+t.htmlCls.space3+"(0: hide, 1: show, default 0)
    ",i+="
    5. Show Membrane: "+t.htmlCls.inputTextStr+"id='"+t.pre+"membrane' value='"+b+"' 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.tmalignUrl=this.baseUrl+"tmalign/tmalign.cgi",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 C(){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 b={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=b.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=b.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=b.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 E="glTF",T=1313821514,D=5130562;class P{constructor(e){this.name=b.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!==E)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=b.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 H}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 H(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=b.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,C=1-g,b=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]=C*t+b*s+g*i+f*a}return n};const U=new THREE.Quaternion;class B extends q{interpolate_(e,t,s,i){const n=super.interpolate_(e,t,s,i);return U.fromArray(n).normalize().toArray(n),n}}const j=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},Z={33071:THREE.ClampToEdgeWrapping,33648:THREE.MirroredRepeatWrapping,10497:THREE.RepeatWrapping},Q={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=Z[s.wrapS]||RepeatWrapping,t.wrapT=Z[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[b.KHR_TEXTURE_TRANSFORM]){const e=void 0!==s.extensions?s.extensions[b.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=n.associations.get(l);l=n.extensions[b.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[b.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=i[b.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];l=e.getMaterialType(),a.push(e.extendParams(r,n,t))}else if(o[b.KHR_MATERIALS_UNLIT]){const e=i[b.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===H?i[b.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[b.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 Ce(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&&be(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,C=void 0!==l.fontFamily?l.fontFamily:void 0!==this.config.body.fontFamily?this.config.body.fontFamily:"Arial",b=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 '${C}'`,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+b>0&&y.fillText(e,w,S),S+=b}))}}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";be(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 Ee{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 Te{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 De{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 Pe{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 Me{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=[],C=[];f.push(e),f.push(t),C.push(o),C.push(a),this.prepareStrand(f,C,void 0,s,i,n,l,void 0,r,d,c,!0,h,p,m,u,g),f=[],C=[]}prepareStrand(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g,f){let C=this.icn3d,b=C.icn3dui;if(1===d.length)return;let y=i,v=!u,_=[];_.push(i[i.length-2]),_.push(i[i.length-1]),n=n||C.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[j[j.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random()))):U[m]&&"CA"===p.name&&(j.length>o+1?(s=k.clone(),i=d.atoms[j[j.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(C),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((g!==p.chain||p.ssbegin||p.ssend||z||B==W&&"coil"!=p.ss)&&u[0].length>0){let c="CA",g=[],f=[];if(isNaN(d.atoms[P].resi))g=[];else{let e=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)-1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);g=void 0!==t?[t]:[]}if(!isNaN(d.atoms[P].resi)){let e=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)+1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);void 0!==t&&f.push(t);let s=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)+2).toString(),i=d.firstAtomObjCls.getAtomCoordFromResi(s,c);void 0!==i&&f.push(i)}if(!z){1===a||2===a?w.push(d.hColor):w.push(R),C=p.ssend&&"sheet"===p.ss?0:"coil"===E&&p.ssbegin||T&&p.ssbegin||"coil"===p.ss?n:l;let s,i,o=4;"O"===p.name?(s=A.clone(),s.sub(S)):U[m]&&"CA"===p.name&&(j.length>o?(s=S.clone(),i=d.atoms[j[j.length-1-o]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(C),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[P].resi))n=[];else{let t=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)-1).toString();d.firstAtomObjCls.getAtomCoordFromResi(t,e)}for(let e=0;!i&&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 C=r.firstAtomObjCls.getAtomCoordFromResi(l,t);void 0!==C&&f.push(C);let b=r.firstAtomObjCls.getAtomCoordFromResi(o,t);void 0!==b&&f.push(b)}b.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}p=[],m=[],u=[],g=[],f=[],d=c,C=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),l||"coil"==c.ss||c.ssbegin||c.ssend||(e=0),u.push(e),m.push(c.color),1===C&&(m[m.length-2]=c.color),o=c.chain,a=c.resi;let y=1.2;2!==i||c.ssbegin||r.boxCls.createBox(c,void 0,void 0,y,void 0,i),++C,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)}b.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}for(let e=0,t=b.length;e0&&(c=n);else if(g%1==0)n=s[g],n>0&&(c=n);else{let e=Math.floor(g),t=g-e;n=s[e]*(1-t)+s[e+1]*t,r||n<1*c&&(n=0)}e1?a.parasCls.thr(t[t.length-2]):a.parasCls.thr(t[e]),C[v++]=d.r,C[v++]=d.g,C[v++]=d.b}}let k,O=0;for(let e=0,t=S.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=b:b=y);let v=.8*C/y;if(g.width=b,g.height=y,f.clearRect(0,0,b,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*b;this.circle(f,0,0,b,y,e)}else{let e=0;this.roundRect(f,0,0,b,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*b,.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(e){let t=this.icn3d,s=t.icn3dui;if(s.bNode)return;let i=s.hashUtilsCls.intHash(t.hAtoms,t.dAtoms),n=[],l=Object.keys(i).length<100;for(let e in i){let s=t.atoms[e],i=s.structure+"_"+s.chain+"_"+s.resi;(l||""!=i)&&n.push(s.coord.clone())}let r=s.rmsdSuprCls.getEigenForSelection(n,n.length),o=new THREE.Vector3(r.h1[0],r.h1[1],r.h1[2]);if(0==r.k&&t.bRender)return void alert("Can't determine the first principal component. Please select a subset and try it again.");let a=t.applyCenterCls.centerAtoms(i),d=a.maxD,c=a.center,h=c.clone().add(o.normalize().multiplyScalar(.4*d)),p=o.normalize();if(s.htmlCls.clickMenuCls.setLogCmd("Principle X-Axis: "+p.x.toFixed(3)+" "+p.y.toFixed(3)+" "+p.z.toFixed(3),!1),e)return p;let m=new THREE.Vector3(r.h2[0],r.h2[1],r.h2[2]),u=c.clone().add(m.normalize().multiplyScalar(.3*d)),g=new THREE.Vector3(r.h3[0],r.h3[1],r.h3[2]),f=c.clone().add(g.normalize().multiplyScalar(.3*d));this.buildAxes(void 0,c,h,u,f,!0);let C=[c,h,u,f];return t.axes.push(C),t.drawCls.draw(),C}}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),b>h&&(b=h),v>p&&(v=p);let _,w=g[o*m+d*u+y],S=g[a*m+d*u+y],A=g[o*m+b*u+y],x=g[o*m+d*u+v],k=g[a*m+b*u+y],O=g[o*m+b*u+v],R=g[a*m+d*u+v],I=g[a*m+b*u+v],E=r.x-o,T=r.y-d,D=r.z-y,P=((w*(1-E)+S*E)*(1-T)+(A*(1-E)+k*E)*T)*(1-D)+((x*(1-E)+R*E)*(1-T)+(O*(1-E)+I*E)*T)*D,M=s*f+i*C+n;this.vpPot[M]=P,P>this.isovalue&&(P=this.isovalue),P<-this.isovalue&&(P=-this.isovalue),P>0?(P/=1*this.isovalue,_=new THREE.Color(1-P,1-P,1)):(P/=-1*this.isovalue,_=new THREE.Color(1,1-P,1-P)),this.vpColor[M]=_}}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.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),C>this.pHeight&&(C=this.pHeight);let b,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+C],S=l[o*a+p*d+f],A=l[r*a+p*d+C],x=l[o*a+h*d+C],k=l[o*a+p*d+C],O=n.x-r,R=n.y-h,I=n.z-f,E=((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;E>this.isovalue&&(E=this.isovalue),E<-this.isovalue&&(E=-this.isovalue),E>0?(E/=1*this.isovalue,b=new THREE.Color(1-E,1-E,1)):(E/=-1*this.isovalue,b=new THREE.Color(1,1-E,1-E)),this.icn3d.atoms[t[s]].color=b,this.icn3d.atomPrevColors[t[s]]=b}}else{for(let p in t){let f,C=e[t[p]];if("DUM"!==C.resn){if(void 0!==this.rmsd_supr&&void 0!==this.rmsd_supr.rot){f=this.transformMemPro(C.coord,g,u,m).applyMatrix4(c)}else f=C.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,C=r.parasCls.thr("#00FFFF"),b=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(b.z):parseInt(b.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 Qe{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(),C=new THREE.Vector3(0,0,1),b=new THREE.Quaternion;b.setFromUnitVectors(f,C);let y=-9999;for(let t in e){let e=i.atoms[t].coord.clone();c.add(e),e.sub(a).applyQuaternion(b);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),E=a.clone().add(h.clone().sub(a).multiplyScalar(.83)).add(R),T=2*Math.PI/o;for(let e=0;et&&(i.sphereCls.createSphereBase(r,m,d,1,0),i.cylinderCls.createCylinder(e,r,d,m,0),i.cylinderCls.createCylinder(s,r,d,m,0),void 0!==n&&i.cylinderCls.createCylinder(c[n],r,d,m,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()}addIgLabels(e){let t=this.icn3d;if(t.icn3dui.bNode)return;t.labels.ig=[];let s=t.firstAtomObjCls.getChainsFromAtoms(e);for(let e in t.igLabel2Pos)if(s.hasOwnProperty(e))for(let s in t.igLabel2Pos[e]){let i={};i.position=t.igLabel2Pos[e][s],i.text=s,i.size=60,i.color="#00FFFF",t.labels.ig.push(i)}t.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),C=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(C),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,C=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 C=this.calcPlaneAngle(l,n);return!(void 0!==C&&C>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 C=t[e],b=i?"LYS"===C.resn&&"N"===C.elem&&"N"!==C.name||"ARG"===C.resn&&("NH1"===C.name||"NH2"===C.name)||("GLU"===C.resn||"ASP"===C.resn)&&"O"===C.elem&&"O"!==C.name||C.het&&("N"===C.elem||"O"===C.elem||"S"===C.elem):"N"===C.elem||"O"===C.elem||"S"===C.elem&&(C.het||"Cys"===C.resn||"Met"===C.resn);if(b=r.bOpm?b&&"DUM"!==C.resn:b,b){a=C.structure+"_"+C.chain+"_"+C.resi,d=a+"_"+C.name;let e=C.resn+" $"+C.structure+"."+C.chain+":"+C.resi+"@"+C.name;void 0===r.resid2Residhash[e]&&(r.resid2Residhash[e]={});for(let t in c){if(i&&!(("LYS"!==C.resn&&"ARG"!==C.resn||"LYS"!==c[t].resn&&"ARG"!==c[t].resn)&&("GLU"!==C.resn&&"ASP"!==C.resn||"GLU"!==c[t].resn&&"ASP"!==c[t].resn)))continue;if(!r.crossstrucinter&&C.structure!=c[t].structure)continue;if(a==t.substr(0,t.lastIndexOf("_")))continue;let d=Math.abs(C.coord.x-c[t].coord.x);if(d>s)continue;let b=Math.abs(C.coord.y-c[t].coord.y);if(b>s)continue;let y=Math.abs(C.coord.z-c[t].coord.z);if(y>s)continue;let v=d*d+b*b+y*y;if(v>h)continue;if(!r.proteins.hasOwnProperty(C.serial)||!r.proteins.hasOwnProperty(c[t].serial)||"N"!==C.name&&"O"!==C.name||"O"!==c[t].name&&"N"!==c[t].name){if(!this.isValidHbond(C,c[t],s))continue}else{if(C.name===c[t].name)continue;if(C.structure==c[t].structure&&C.chain==c[t].chain&&Math.abs(C.resi-c[t].resi)<=1)continue;let e,i="N"===C.name?C:c[t],n="O"===C.name?C:c[t];if("Pro"===i.resn)continue;if(void 0===i.hcoord){if(!this.isValidHbond(C,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),b=o.distanceTo(h);e=p2||f[c[t].serial]>2)continue;void 0===f[C.serial]?f[C.serial]=1:++f[C.serial],void 0===f[c[t].serial]?f[c[t].serial]=1:++f[c[t].serial],"graph"!==n&&(i?(r.saltbridgepnts.push({serial:C.serial,coord:C.coord}),r.saltbridgepnts.push({serial:c[t].serial,coord:c[t].coord})):(r.hbondpnts.push({serial:C.serial,coord:C.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+"_"+C.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 C=Object.keys(m);if("graph"!==n)for(let e=0,t=C.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 C,b=i.structure+"_"+i.chain+"_"+i.resi;g&&"ARG"===i.resn&&"NH1"===i.name?C=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[b],"NH2"):f&&"GLU"===i.resn&&"OE1"===i.name?C=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[b],"OE2"):f&&"ASP"===i.resn&&"OD1"===i.name&&(C=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[b],"OD2"));let y=void 0===C?i.coord:i.coord.clone().add(C.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 C=void 0===c?t[d].coord:t[d].coord.clone().add(c.coord).multiplyScalar(.5),b=Math.abs(y.x-C.x);if(b>s)continue;let v=Math.abs(y.y-C.y);if(v>s)continue;let _=Math.abs(y.z-C.z);if(_>s)continue;let w=b*b+v*v+_*_;if(w>p)continue;"graph"!==n&&(r.saltbridgepnts.push({serial:i.serial,coord:y}),r.saltbridgepnts.push({serial:t[d].serial,coord:C}));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":case"secondary structure":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":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=[],C=-9999;for(let e in t){if(!i.proteins.hasOwnProperty(e))continue;let t=i.atoms[e];-9999==C&&(u=parseInt(e)),-9999!=C&&(t.ss!=g.ss||Math.abs(t.resi-g.resi)>1||t.ssbegin&&g.ssend)&&("coil"==g.ss||f.push([u,C]),u=e),C=parseInt(e),g=t}"coil"==g.ss||f.push([u,C]),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)/b;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,"domain",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 C=d.motifs;n.bNode&&!i.resid2site[c]&&(i.resid2site[c]=[]),g=l.setDomainFeature(C,c,"feat",h,p,m,f),h=g.html,p=g.html2,m=g.html3;let b=a.data[e].sites,y=void 0!==b?b.length:0;for(let e=0;e17&&(s=s.substr(0,17)+"...");let l,r=b[e].title,o=[];for(let t=0,s=b[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(),C=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: "+b[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)-C-y):Math.round(i.seqAnnWidth*t/i.maxAnnoLength-C-y);o>=0&&(p+='
     
    ',p+='
     
    ',C+=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,o,a){let d,c,h,p=this.icn3d,m=p.icn3dui,u="domain"!=s&&"feat"!=s;"domain"==s&&(r={},d={},c={},h={}),void 0===e&&(e=[]);let g=e.length,f="domain"==s?14:19,C="domain"==s?100:120;e.sort((function(e,t){let i=e.locs,n="domain"==s||"ig"==s?i[0].segs:[i[0]],l=Math.round(n[0].from);return i=t.locs,n="domain"==s||"ig"==s?i[0].segs:[i[0]],l-Math.round(n[0].from)}));for(let b=0;bf&&(w=w.substr(0,f)+"...");let S=u?a[b]:s+": "+v;"domain"==s&&(d[g]=v);let A=e[b].locs;if(A)for(let e=0,r=A.length;e'+w+" ",I=''+u.toString()+" Res";l+=R+I+"
    ";let E='';i+=R+I+E,"domain"==s&&(n+='
    '),n+='
    '+w+"
    ",n+=I+E;let T=s+b.toString();p.seqStartLen&&p.seqStartLen[t]&&(i+=p.showSeqCls.insertMulGap(p.seqStartLen[t],"-"));for(let e=0,n=p.giSeq[t].length;e1&&(l=n[0]+"..");let r=p.ParserUtilsCls.getResi(t,e);if(i+=''+n+"",m.bNode){let e={};e[t+"_"+r]=S,"domain"==s?p.resid2cdd[t].push(e):p.resid2site[t].push(e)}}else i+="-";if(p.seqStartLen&&p.seqStartLen[t]&&(i+=p.showSeqCls.insertMulGap(p.seqEndLen[t],"-")),p.seqStartLen&&p.seqStartLen[t]&&(n+=p.showSeqCls.insertMulGapOverview(t,p.seqStartLen[t])),m.cfg.blast_rep_id!=t){let i;for(let l=0,d=r.length;l ',n+='
    '+v+"
    "}}else{let i=[],l=[];for(let e=0,t=r.length;e ',n+='
    '+v+"
    "}}E=' '+u.toString()+" Residues",E+="
    ",E+="
    ",i+=E,n+=E,"domain"==s&&(n+='')}}return{html:i,html2:n,html3:l,acc2domain:r,pssmid2name:d,pssmid2fromArray:c,pssmid2toArray:h}}getColorFromPos(e,t,s){let i,n=this.icn3d;n.icn3dui;let l=e+"_"+n.ParserUtilsCls.getResi(e,t),r=n.firstAtomObjCls.getFirstAtomObj(n.residues[l]),o=r&&void 0!==r.color&&"FFFFFF"!==r.color.getHexString()?r.color.getHexString():"DDDDDD";return i=r&&void 0!==r.color?o:"CCCCCC",i}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 C='';a+=g+f+C,d+=g+f+C;let b=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],"-")),C=' '+m.toString()+" Residues",C+="",C+="
    ",a+=C,d+=C,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 C="inter"+c.toString(),b=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)-b-y):Math.round(s.seqAnnWidth*t/s.maxAnnoLength-b-y);h>=0&&(a+='
     
    ',a+='
     
    ',b+=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,s.substr(0,s.indexOf("_"));for(let d in t){let c=t[d],h=[],p=!1;for(let e=0,t=c.length;e5?h.push(e-1):i.UPResi2ResiPosPerChain&&i.UPResi2ResiPosPerChain[s][e]&&h.push(i.UPResi2ResiPosPerChain[s][e]),!p&&i.residues.hasOwnProperty(s+"_"+e)&&(p=!0)}if(0==h.length)continue;let m=h.length,u="ptm"==e?"PTM: "+d:"Transmembrane";u.length>17&&(u=u.substr(0,17)+"...");let g=d,f='
    '+u+"
    ",C=''+m.toString()+" Res",b='';a+=f+C+"
    ",r+=f+C+b,o+=f+C+b;let y=e+l.toString(),v=0,_=0,w=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]=u,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)-v-_):Math.round(i.seqAnnWidth*e/i.maxAnnoLength-v-_);d>=0&&(o+='
     
    ',o+='
     
    ',v+=d,_+=w)}else r+="-";i.seqStartLen&&i.seqStartLen[s]&&(r+=i.showSeqCls.insertMulGap(i.seqEndLen[s],"-")),b=' '+m.toString()+" Residues",b+="
    ",b+="
    ",r+=b,o+=b,++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}async showIg(e,t){let s=this.icn3d;s.icn3dui,s.bRunRefnumAgain&&await s.refnumCls.showIgRefNum(t);let i="",n="",l="";if(s.bShowRefnum&&s.chainid2refpdbname.hasOwnProperty(e)&&s.chainid2refpdbname[e].length>0){let t=s.showSeqCls.getSeq(e),r=s.annoIgCls.showAllRefNum(t,e);i+=r.html,n+=r.html2,l+=r.html3}$("#"+s.pre+"dt_"+"ig_"+e).html(i),$("#"+s.pre+"ov_"+"ig_"+e).html(n),$("#"+s.pre+"tt_"+"ig_"+e).html(l)}showAllRefNum(e,t){let s=this.icn3d;s.icn3dui;let i="",n="",l="",r=!1;for(let i=0,n=e.length;i0){r=!0;break}}let o=!1;for(let i=0,n=e.length;i0){o=!0;break}}let a=this.showRefNum(e,t);i+=a.html,n+=a.html2,l+=a.html3;let d=1;return r&&(a=this.showRefNum(e,t,d),i+=a.html,n+=a.html2,l+=a.html3),d=2,o&&(a=this.showRefNum(e,t,d),i+=a.html,n+=a.html2,l+=a.html3),{html:i,html2:n,html3:l}}showRefNum(e,t,s,i){let n=this.icn3d;if(n.icn3dui,n.chainid2igtrack){if(!n.chainid2igtrack[t])return{html:"",html2:"",html3:""}}let l=this.getIgAnnoHtml(t,e,i,s);return n.bShowRefnum&&(n.opts.color="ig strand",n.setColorCls.setColorByOptions(n.opts,n.chains[t])),l}setChain2igArray(e,t,s){let i,n=this.icn3d;n.icn3dui;let l={};for(let r=0,o=t.length;r0&&s!=i+1&&(a.push(i),o.push(s)),i=s;a.push(s);let d={};d.domainid=t,d.startPosArray=o,d.endPosArray=a,n.chain2igArray[e].push(d)}}getIgAnnoHtml(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r="",o="",a="";n.chain2igArray||(n.chain2igArray={});let d,c,h,p=!1,m="";n.chain2igArray[e]=[],this.setChain2igArray(e,t,s);let u=n.chain2igArray[e];for(let t=0,s=u.length;t=0;--t){let s=e+"_"+n.chainsSeq[e][t].resi;if(!n.residIgLoop.hasOwnProperty(s))break;delete n.resid2refnum[s],delete n.residIgLoop[s],delete n.resid2domainid[s]}}}n.chain2igArray[e]=[],this.setChain2igArray(e,t,s);let g="";for(let l=0,r=t.length;l'+h+"":' '}else g+="";else if(1==i||2==i)if(h){let e=parseInt(h).toString(),t='style="color:'+this.getRefnumColor(m,!0)+'"';g+=parseInt(e.substr(e.length-2,2))%2==0?"'+h+"":" '}else g+="";else" "!=m?(p=n.residIgLoop[t],g+=this.getRefnumHtml(t,h,c,d,m,p,o)):g+="";else g+=""}if(l.bNode)return{html:r,html2:o,html3:a};let f="icn3d-link icn3d-blue",C="IgStRAnD Ref. No.",b=n.chain2igArray[e].length,y=[],v=[],_={};n.igLabel2Pos||(n.igLabel2Pos={}),n.igLabel2Pos[e]={};for(let t=0;t",S='
    ';s&&(S='
    ');let A='
    '+C+"
    ";if(S+='
    ',s?(S+='
    Custom Ref. No.
    ',S+=''):1==i?(S+='
    Kabat Ref. No.
    ',S+=''):2==i?(S+='
    IMGT Ref. No.
    ',S+=''):(S+=A,S+=w),a+=S+"
    ",r+=S+'',n.seqStartLen&&n.seqStartLen[e]&&(r+=n.showSeqCls.insertMulGap(n.seqStartLen[e],"-")),r+=g,n.seqStartLen&&n.seqStartLen[e]&&(r+=n.showSeqCls.insertMulGap(n.seqEndLen[e],"-")),s||(r+=w),r+="",r+="
    ",r+="
    ",r+="
    ",u=n.chain2igArray[e],0==u.length)return{html:r,html2:o,html3:a};let x=[],k=[],O=[],R=[],I=e.substr(e.lastIndexOf("_")+1);for(let e=0,t=u.length;e',n.seqStartLen&&n.seqStartLen[e]&&(o+=n.showSeqCls.insertMulGapOverview(e,n.seqStartLen[e]));for(let i=0,l=y.length;i 
    ',o+='
    '+R[r]+"
    ",t=r}o+=w,o+="",a+="",S='
    ';let i=S,l=S,d=n.annoCddSiteCls.setDomainFeature(x,e,"ig",S,i,l,void 0,k,O);r+=d.html+"
    ",o+=d.html2+"",a+=d.html3+""}return{html:r,html2:o,html3:a}}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 C="";return!i||50!=f||p||l?i&&f%2==0&&52!=f&&!r?(g=isNaN(t)?g+t.substr(t.length-1,1):g,C+="'+g+""):C+=" ':(o.hAtomsRefnum=a.hashUtilsCls.unionHash(o.hAtomsRefnum,o.residues[e]),C+="'+i.substr(0,1)+""+i.substr(1)+""),C}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}}class At{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);h.length>1&&"1"==h.substr(h.length-1)&&(h=h.substr(0,h.length-1)),n=e,i=t.domains[e]?t.domains[e].domains:[];for(let t=0,s=i.length;t17?s.substr(0,17)+"...":s,h=i[t].intervals,p=[],m=[],u={},g=0;for(let t=0,s=h.length;t'+c+" ",C=''+g.toString()+" Res";d+=f+C+"
    ";let b='';o+=f+C+b,a+=f+C+b;let y="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 v=l.firstAtomObjCls.getFirstCalphaAtomObj(l.chains[e]),_=void 0===v.color||"FFFFFF"===v.color.getHexString()?"DDDDDD":v.color.getHexString(),w=void 0!==v.color?_:"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=p.length;i ',a+='"}else{let i=[],n=[];for(let e=0,t=p.length;e ',a+='"}}b=' '+g.toString()+" Residues",b+="",b+="
    ",o+=b,a+=b}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 kt{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,C=f.icn3dui,b="",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)"),b+=m?'":'"}else if(2==e&&m){let e=C.utilsCls.isMobile()?"none":"button";b+='
    ',b+='
    '}else b+='
    ';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 b+"
    ";b+='';let O="",R=0,I=0;p?f.seqStartLen&&f.seqStartLen[h]&&(b+=f.showSeqCls.insertMulGapOverview(h,f.seqStartLen[h])):f.seqStartLen&&f.seqStartLen[h]&&(b+=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&&(b+='
     
    ',b+='
     
    ',R+=r,I+=1):r>0&&(b+='
     
    ',b+='
     
    ',R+=r,I+=1)}}else if(b+=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,b&&!C.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)b&&!C.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,b&&!C.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]+")"):(b&&!C.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]?b+=1==e?"":""==p||" "==p?"-":''+p+"":b+="-":b+=""==p||" "==p?"-":g?''+p+"":''+p+""}else b+="";else b+="-";return p||f.seqStartLen&&f.seqStartLen[h]&&(b+=f.showSeqCls.insertMulGap(f.seqEndLen[h],"-")),b+=1==e?' '+k+" Residues":'',b+="
    ",b+="
    ",b}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 C={},b={},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===b[d]&&(b[d]=[]),b[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===C[d]&&(C[d]=[]),C[d].push(A)}let S=Object.keys(v),A=Object.keys(_);if(i){let e=!1;o+=this.getSnpLine(1,2,u,b,y,f,g,C,S,A,1,t,!1,e,void 0,i),o+=this.getSnpLine(2,2,u,b,y,f,g,C,S,A,0,t,!1,e,void 0,i),d+=this.getSnpLine(1,2,u,b,y,f,g,C,S,A,1,t,!1,e,!0,i),d+=this.getSnpLine(2,2,u,b,y,f,g,C,S,A,0,t,!1,e,!0,i),a+=this.getSnpLine(1,2,u,b,y,f,g,C,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,b,y,f,g,C,S,A,1,t,!1,e,void 0,i),c+=this.getSnpLine(2,2,u,b,y,f,g,C,S,A,0,t,!1,e,void 0,i),p+=this.getSnpLine(1,2,u,b,y,f,g,C,S,A,1,t,!1,e,!0,i),p+=this.getSnpLine(2,2,u,b,y,f,g,C,S,A,0,t,!1,e,!0,i),h+=this.getSnpLine(1,2,u,b,y,f,g,C,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 Ot{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 It{constructor(e){this.icn3d=e,this.init3ddomain()}init3ddomain(){this.icn3d.icn3dui,this.dcut=8,this.min_contacts=2,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 o=this.standardizeSubstruct(p,o,u),{subdomains:a,substruct:o};let f=h.length,C=f,b=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((function(e,t){return e-t}));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){D.push(t);break}t.push(s)}}}D.sort((function(e,t){return e[0]-t[0]}));let P=[];for(let e=0,t=D.length;e=this.min_sse&&P.push(D[e])}if(D=P,0==D.length){let e={},t={},s=0;for(let i=0,n=this.group_num.length;i=3&&(s=n)):e[n]=1)}if(0!=s){let e=[s].concat(t[s]);D.push(e)}}for(let e=0,t=D.length;e=o.length)return o=this.standardizeSubstruct(p,o,u),{subdomains:a,substruct:o};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;ec&&(c=p),i.ssend&&(o.To=e+1,o.x2=i.coord.x,o.y2=i.coord.y,o.z2=i.coord.z,o.Sheet="sheet"==i.ss,r.push(o),o={}),i.ssbegin&&(o.From=e+1,o.x1=i.coord.x,o.y1=i.coord.y,o.z1=i.coord.z)}r=this.standardizeSubstruct(l,r,a);let h='{"data": [';h+='{"ss": [';let p=0;for(let e=0,s=r.length;e0&&(h+=", "),h+="["+s+","+i+","+n+","+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)+"]",++p)}h+="]",h+=', "domain": [';let m=0;for(let e=d;e<=c;++e){let n=l+"_"+e,r=t.ncbi2resid[n],o=e;if(m>0&&(h+=", "),i.hasOwnProperty(r)){let e=t.firstAtomObjCls.getFirstCalphaAtomObj(t.residues[r]);h+="["+o+","+(s.parasCls.resn2restype[e.resn]?s.parasCls.resn2restype[e.resn]:0)+","+e.coord.x.toFixed(2)+","+e.coord.y.toFixed(2)+","+e.coord.z.toFixed(2)+"]"}else h+="["+o+",0,0,0,0]";++m}return h+="]}",h+="]}",h}}class Et{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 C="",b=[];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 C=m.htmlCls.RESIDUE_WIDTH*s.length+200;$("#"+p.pre+"dt_custom_"+e).append("
    "),$("#"+p.pre+"dt_custom_"+e+"_"+f).width(C),$("#"+p.pre+"ov_custom_"+e).append("
    "),$("#"+p.pre+"ov_custom_"+e+"_"+f).width(C),$("#"+p.pre+"tt_custom_"+e).append("
    "),$("#"+p.pre+"tt_custom_"+e+"_"+f).width(C);let b='
    ',y=b,v=b,_=b,w=b,S=parseInt(10*Math.random()),A='",x='
    Exons
    ',k=''+g.toString()+" Pos";_+=A+k+"
    ",w+=x+k+"
    ";let O='';b+=A+k+O,y+=x+k+O,v+=A+k+O;let R=e.indexOf("_"),I="cst"+e.substr(R+1),E=0,T=0,D=(void 0===l||"seq"===l||"custom"===l)&&-1==s.indexOf("cannot-be-aligned")&&-1==s.indexOf("cannot be aligned"),P="identity"===l&&-1==s.indexOf("cannot-be-aligned")&&-1==s.indexOf("cannot be aligned"),M={},F=0;A="";let H={},L={},N={},q=0;if(h)for(let e=0,t=h.length;e"+d+"",h){let t='style="background-color:'+H[q]+'"';y+=' ";for(let t in p.residues[e+"_"+g]){let e=p.atoms[t];e.color=m.parasCls.thr(H[q]),p.atomPrevColors[t]=e.color}}A+=p.showSeqCls.insertGapOverview(e,t);let f=Math.round(p.seqAnnWidth*t/(p.maxAnnoLength+p.nTotalGap)-E-T);f<0&&(f=0),A+='
     
    ',s=void 0!==i&&""!=i[t]?i[t]:r?"rgb("+r+")":D?"#"+c:"#333",A+='
     
    ',E+=f,T+=1,++q}else u?b+=""+d+"":(b+="-",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+="",b+=O,v+=A+O,y+=O,_+="",w+="",h?($("#"+p.pre+"dt_custom_"+e+"_"+f).html(y+b),$("#"+p.pre+"ov_custom_"+e+"_"+f).html(v),$("#"+p.pre+"tt_custom_"+e+"_"+f).html(w+_)):($("#"+p.pre+"dt_custom_"+e+"_"+f).html(b),$("#"+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=!1,r=!0;if(s.hAtoms={},"igdomain"==t){let t=s.chain2igArray[e];if(t&&t.length>0)for(let i=0,o=t.length;i1e3&&"50"==C.substr(C.length-2,2)&&(n[y]=1):(d=s.residIgLoop.hasOwnProperty(y)?"igloop":"igstrand",u&&d!=c&&Object.keys(n).length>0&&("igstrand"==c?(++h,i="Strand-"+a+"-"+e+"-"+h.toString().padStart(3,"0"),i=i.replace(/'/g,"`"),"igstrand"==t&&(s.selectionCls.selectResidueList(n,i,i,l,r),l||(l=!0)),m=a):"igloop"==c&&(++p,i="Loop-"+m+"_"+o+"-"+e+"-"+p.toString().padStart(3,"0"),i=i.replace(/'/g,"`"),"igloop"==t&&(s.selectionCls.selectResidueList(n,i,i,l,r),l||(l=!0))),n={}),n[y]=1,a=o,c=d,u=!0)))}"iganchor"==t?(i="Anchor-"+e,s.selectionCls.selectResidueList(n,i,i,l,r)):"igstrand"==c?(++h,i="Strand-"+a+"-"+e+"-"+h.toString().padStart(3,"0"),i=i.replace(/'/g,"`"),"igstrand"==t&&s.selectionCls.selectResidueList(n,i,i,l,r)):"igloop"==c&&(++p,o="CT",i="Loop-"+m+"_"+o+"-"+e+"-"+p.toString().padStart(3,"0"),i=i.replace(/'/g,"`"),"igloop"==t&&s.selectionCls.selectResidueList(n,i,i,l,r))}}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},C=await n.getAjaxPostPromise(o,f);if(!C.data)return void console.log("The protein accessions "+u+","+g+" can not be aligned...");let b=[];i.qt_start_end={};let y=[],v=[],_=Object.keys(C.targets)[0],w=C.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]=C-1-f,u||(g=s,o.seqStartLen[e]=g,u=!0)):++m;o.maxAnnoLength0&&(b+=" "),b+=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","ig"];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}async updateIg(e,t){let s=this.icn3d,i=s.icn3dui;if(s.opts.color="ig strand",!e){s.hAtoms={};for(let e in s.protein_chainid)s.hAtoms=i.hashUtilsCls.unionHash(s.hAtoms,s.chains[e])}let n=s.firstAtomObjCls.getResiduesFromAtoms(s.hAtoms);for(let e in n)s.resid2refnum&&delete s.resid2refnum[e],s.residIgLoop&&delete s.residIgLoop[e],s.resid2domainid&&delete s.resid2domainid[e];s.bRunRefnumAgain=!0;let l=e?s.firstAtomObjCls.getChainsFromAtoms(s.hAtoms):s.protein_chainid;for(let e in l)await s.annoIgCls.showIg(e,t),s.bRunRefnumAgain=!1;s.bShowRefnum&&(s.hlUpdateCls.updateHlAll(),s.drawCls.draw())}}class Dt{constructor(e){this.icn3d=e}showAnnotations_part1(e){let t=this.icn3d,s=t.icn3dui;if(s.htmlCls.dialogCls.openDlg("dl_selectannotations","Sequences and Annotations"),(void 0===t.bAssemblyNote||!t.bAssemblyNote)&&void 0!==t.asuCnt){let e="
    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("+t.asuCnt+" asymmetric unit).
    ";$("#"+t.pre+"dl_annotations_tabs").append(e),t.bAssemblyNote=!0}t.bResetAnno&&(t.giSeq={},t.currClin={},t.resi2disease_nonempty={},t.baseResi={},t.matchedPos={},$("#"+s.pre+"dl_annotations").empty(),t.annotationCls.setAnnoView("overview"));let i={},n={},l={};if(void 0===t.bAnnoShown||!t.bAnnoShown||t.bResetAnno){t.protein_chainid={};let r,o=Object.keys(t.chains);if(e){let s=t.resid2specCls.atoms2structureArray(e);o=[];for(let e=0,i=s.length;e1&&"1"==d.substr(d.length-1)?(d=d.substr(0,d.length-1),a=o[e].substr(0,o[e].indexOf("_"))+"_"+d):a=o[e],t.proteins.hasOwnProperty(r.serial)&&t.chainsSeq[o[e]].length>1)t.protein_chainid[o[e]]=a;else if(t.nucleotides.hasOwnProperty(r.serial)&&t.chainsSeq[o[e]].length>1)i[o[e]]=a;else if(t.chainsSeq[o[e]].length>1)n[o[e]]=a;else{let s=t.chainsSeq[o[e]][0].name,i=o[e]+"_"+t.chainsSeq[o[e]][0].resi;void 0===l[s]&&(l[s]=[]),l[s].push(i)}if((void 0!==s.cfg.pdbid||void 0!==s.cfg.opmid||void 0!==s.cfg.mmcifid||void 0!==s.cfg.mmtfid)&&(t.proteins.hasOwnProperty(r.serial)||t.nucleotides.hasOwnProperty(r.serial)))for(let s=0,i=t.chainsSeq[o[e]].length;st.maxAnnoLengthOri&&(t.protein_chainid.hasOwnProperty(e)||i.hasOwnProperty(e))&&(t.maxAnnoLengthOri=t.chainsSeq[e].length);t.maxAnnoLength=t.maxAnnoLengthOri}return{nucleotide_chainid:i,chemical_chainid:n,chemical_set:l}}async showAnnotations(e){let t=this.icn3d,s=t.icn3dui,i=this,n=this.showAnnotations_part1(e),l=n.nucleotide_chainid,r=n.chemical_chainid,o=n.chemical_set;if(!t.bAnnoShown||t.bResetAnno)if(t.bAnnoShown=!0,void 0===s.cfg.blast_rep_id){if(t.bFullUi){if(void 0!==s.cfg.mmtfid){let e=Object.keys(t.structures)[0];await t.mmcifParserCls.downloadMmcifSymmetry(e,"mmtfid")}await this.showAnnoSeqData(l,r,o)}}else if(void 0===s.cfg.blast_rep_id||t.bSmithwm||t.bLocalSmithwm){if(void 0!==s.cfg.blast_rep_id&&(t.bSmithwm||t.bLocalSmithwm)){let e,n,a=[s.cfg.blast_rep_id];if(-1!=s.cfg.query_id.indexOf(">")?n=s.cfg.query_id.substr(s.cfg.query_id.indexOf("\n")+1):!/\d/.test(s.cfg.query_id)||s.cfg.query_id.length>50?n=s.cfg.query_id:a.push(s.cfg.query_id),t.blastAcxn){let i=s.cfg.afid+"_A",n="";for(let e=0,s=t.chainsSeq[i].length;e5){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),h+="   "+this.addButton(s,"icn3d-iganchorsets","Ig Anchor Set",'Define the set for all Ig anchors in this chain and add them to the menu of "Defined Sets"',80,i)+" "+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)+" "+this.addButton(s,"icn3d-igdomainsets","Ig Domain Sets",'Define sets for each Ig domain 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","ig"];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}getSeq(e){let t,s=this.icn3d,i=s.icn3dui;if(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&&void 0===i.cfg.mmdbafid){t=[];for(let i=0;i10){m='
    ';let t=o.firstAtomObjCls.getFirstCalphaAtomObj(o.chains[e]);void 0===a.cfg.mmdbid&&void 0===a.cfg.gi&&void 0===a.cfg.blast_rep_id&&void 0===a.cfg.align&&void 0===a.cfg.chainalign&&void 0===a.cfg.mmdbafid||void 0===t.resi_ori||t.resi_ori==t.resi||-1!=e.indexOf("Misc")?m+='
    ':m+='
    NCBI Residue Numbers
    ',m+='',f+=m+"
    ",u+=m+'';let s=0,i=0,n="";o.seqStartLen&&o.seqStartLen[e]&&(u+=this.insertMulGap(o.seqStartLen[e]," "));for(let t=0,l=d.length;t",l%10==0&&(u+=l);let r=e+"_"+l,a=l%10!=0&&l%10!=1&&l%10!=9;if(o.residues.hasOwnProperty(r)){let e=o.firstAtomObjCls.getFirstCalphaAtomObj(o.residues[r]);"H"==o.secondaries[r]&&e.ssbegin?(++s,n='H'+s+"",a&&(u+=n,n="")):"E"==o.secondaries[r]&&e.ssbegin?(++i,"green"==o.sheetcolor?n='S'+i+"":"yellow"==o.sheetcolor&&(n='S'+i+""),a&&(u+=n,n="")):e.ssend&&(n=""),""!=n&&a&&(u+=n,n="")}u+=""}o.seqStartLen&&o.seqStartLen[e]&&(u+=this.insertMulGap(o.seqEndLen[e]," ")),u+='',u+="",u+="
    ",u+="
    ",f+=""}m='
    ',m+='
    ',m+='',f+=m+"
    ",u+=m+'',o.seqStartLen&&o.seqStartLen[e]&&(u+=this.insertMulGap(o.seqStartLen[e],"-"));for(let t=0,s=d.length;t':'',u+=" ";else if("E"==o.secondaries[s]){o.firstAtomObjCls.getFirstCalphaAtomObj(o.residues[s]).ssend?"green"==o.sheetcolor?u+='':"yellow"==o.sheetcolor&&(u+=''):"green"==o.sheetcolor?u+='':"yellow"==o.sheetcolor&&(u+=''),u+=" "}else"c"==o.secondaries[s]?u+=' ':"o"==o.secondaries[s]&&(u+=' ');else u+="-"}o.seqStartLen&&o.seqStartLen[e]&&(u+=this.insertMulGap(o.seqEndLen[e],"-")),u+='',u+="",u+="
    ",u+="
    ",u+="",f+="",m=a.cfg.blast_rep_id===e?'
    ':'
    ';let C="Protein",b="Protein";void 0!==s&&("nucleotide"==s?(C="Nucl.",b="Nucleotide"):"chemical"==s&&(C="Chem.",b="Chemical")),m+='",m+=''+(o.baseResi[e]+1).toString()+"",f+=m+"
    ";let y='';u+=m+y,g+=m+y;let v,_=0;o.seqStartLen&&o.seqStartLen[e]&&(u+=this.insertMulGap(o.seqStartLen[e],"-"));for(let t=0,s=d.length;t1&&(i=s[0]+".."),v=o.ParserUtilsCls.getResi(e,t),o.residues.hasOwnProperty(e+"_"+v)){let n="333333";if(a.cfg.blast_rep_id==e&&void 0!==o.fullpos2ConsTargetpos&&void 0!==o.fullpos2ConsTargetpos[t+_])n=o.fullpos2ConsTargetpos[t+_].color;else{let t=o.firstAtomObjCls.getFirstCalphaAtomObj(o.residues[e+"_"+v]),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"}u+=''+i+""}else i=i.toLowerCase(),u+=''+i+""}o.seqStartLen&&o.seqStartLen[e]&&(u+=this.insertMulGap(o.seqEndLen[e],"-")),a.cfg.blast_rep_id==e&&(o.opts.color=o.blastAcxn?"confidence":"conservation",o.setColorCls.setColorByOptions(o.opts,o.atoms));let w=o.firstAtomObjCls.getFirstCalphaAtomObj(o.chains[e]),S=w.color?w.color.getHexString():"CCCCCC",A=Math.round(o.seqAnnWidth*d.length/(o.maxAnnoLength+o.nTotalGap));if(A<1&&(A=1),o.seqStartLen&&o.seqStartLen[e]&&(g+=this.insertMulGapOverview(e,o.seqStartLen[e])),a.cfg.blast_rep_id!=e)g+='";else{let t=[],s=[];t.push(0);for(let e=0,i=d.length;e';for(let i=0,n=t.length;i'+e+"
    ";g+="
    "}if(m=''+v+"",m+="",m+="
    ",u+=m,g+=m,a.cfg.blast_rep_id==e){if(void 0!==r&&""!==r){m='",m+='',f+=m+"
    ";let t='';u+=m+t,g+=m+t;let s=0,i=0,l=1;o.queryStart;for(let t=0,n=r.length;t-";else if(" "==n)u+=" ";else{let r=o.fullpos2ConsTargetpos[t].pos;if(o.residues.hasOwnProperty(e+"_"+r)){let s=o.fullpos2ConsTargetpos[t].color;u+=''+n+""}else n=n.toLowerCase(),u+=''+n+"";g+=this.insertGapOverview(e,t);let a=Math.round(o.seqAnnWidth*t/(o.maxAnnoLength+o.nTotalGap)-s-i);a>=0&&(g+='
     
    ',g+='
     
    ',s+=a,i+=l)}}m='',m+="",m+="
    ",u+=m,g+=m}m='
    '+i+"
    ",m+=''+o.queryStart+"",f+=m+"
    ";let t='';u+=m+t,g+=m+t;let s=o.queryStart;for(let t=0,i=l.length;t-":(void 0===o.fullpos2ConsTargetpos||void 0===o.fullpos2ConsTargetpos[t]||o.residues.hasOwnProperty(e+"_"+o.fullpos2ConsTargetpos[t].pos)||(i=i.toLowerCase()),u+=''+i+"",++s)}let a=o.firstAtomObjCls.getFirstCalphaAtomObj(o.chains[e]),d=void 0===a.color||"FFFFFF"===a.color.getHexString()?"DDDDDD":a.color.getHexString(),c=void 0!==a.color?d:"CCCCCC",h=[],p=[],C="-";for(let e=0,t=l.length;e ',g+='
    '+i+"
    "}m=''+o.queryEnd+"",m+="",m+="
    ",u+=m,g+=m}if(u+="",g+="",f+="",d.length>10){let t=o.firstAtomObjCls.getFirstCalphaAtomObj(o.chains[e]);if((void 0!==a.cfg.mmdbid||void 0!==a.cfg.gi||void 0!==a.cfg.blast_rep_id||void 0!==a.cfg.align||void 0!==a.cfg.chainalign||void 0!==a.cfg.mmdbafid)&&void 0!==t.resi_ori&&t.resi_ori!=t.resi&&-1==e.indexOf("Misc")){m='
    ',m+='
    ',m+='
    PDB Residue Numbers
    ',m+='',f+=m+"
    ",u+=m+'',o.seqStartLen&&o.seqStartLen[e]&&(u+=this.insertMulGap(o.seqStartLen[e],"-"));for(let t=0,s=d.length;t",e%10==0&&(u+=e+" "),u+=""}else u+=""}o.seqStartLen&&o.seqStartLen[e]&&(u+=this.insertMulGap(o.seqEndLen[e],"-")),u+='',u+="",u+="
    ",u+="
    ",u+="
    ",f+=""}if(o.bShowCustomRefnum&&o.chainsMapping.hasOwnProperty(e)){let t=!0,s=o.annoIgCls.showRefNum(d,e,void 0,t);u+=s.html,f+=s.html3}}o.bShowRefnum&&o.hlUpdateCls.updateHlAll(),$("#"+o.pre+"dt_giseq_"+e).html(u),$("#"+o.pre+"ov_giseq_"+e).html(g),$("#"+o.pre+"tt_giseq_"+e).html(f)}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")||void 0!==$(e).attr("ig")){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 Ft{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&&($("#"+t.pre+"dl_2ddgm svg line").attr("stroke","#000000"),$("#"+t.pre+"dl_2ddgm line").attr("stroke-width",1)),e||($("#"+t.pre+"dl_linegraph circle").attr("stroke","#000000"),$("#"+t.pre+"dl_linegraph circle").attr("stroke-width",1),$("#"+t.pre+"dl_scatterplot rect").attr("stroke","#000000"),$("#"+t.pre+"dl_scatterplot circle").attr("stroke","#000000"),$("#"+t.pre+"dl_scatterplot rect").attr("stroke-width",1),$("#"+t.pre+"dl_scatterplot circle").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=[],C=[],b=[],y=[],v={},_={},w={};for(let t=0,s=p.length;t4&&!isNaN(parseInt(e.substr(-4,4)))||t.length>4&&!isNaN(parseInt(t.substr(-4,4))),c=e+"_"+t+"_"+s.c,h=n.hashUtilsCls.cloneHash(s);h.source+=S+i.chainsMapping[r][d],h.target+=S+i.chainsMapping[o][C];let m=n.hashUtilsCls.cloneHash(s);m.source+=A+i.chainsMapping[r][d],m.target+=A+i.chainsMapping[o][C],v[c]!=p.length||!a&&0!=w[c]?b[f].push(m):u[f].push(h),g[f][s.source]=i.chainsMapping[r][d],g[f][s.target]=i.chainsMapping[o][C],y[f][s.source]=i.chainsMapping[r][d],y[f][s.target]=i.chainsMapping[o][C]}else{let e=n.hashUtilsCls.cloneHash(s);e.source+=i.chainsMapping[r]&&i.chainsMapping[r][d]?A+i.chainsMapping[r][d]:A+k,e.target+=i.chainsMapping[o]&&i.chainsMapping[o][C]?A+i.chainsMapping[o][C]:A+k,b[f].push(e),g[f][s.source]=i.chainsMapping[r]&&i.chainsMapping[r][d]?i.chainsMapping[r][d]:x,g[f][s.target]=i.chainsMapping[o]&&i.chainsMapping[o][C]?i.chainsMapping[o][C]:x,y[f][s.source]=i.chainsMapping[r]&&i.chainsMapping[r][d]?i.chainsMapping[r][d]:k,y[f][s.target]=i.chainsMapping[o]&&i.chainsMapping[o][C]?i.chainsMapping[o][C]:k}}}let O=[],R=[],I=0,E=[],T=1;for(let e=0,t=p.length;e0&&(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,C[e]=t.nodeArray2,d=n.hashUtilsCls.unionHash(d,t.name2node)),O[e]=l[e].length,R[e]=o[e].length,I=Math.max(I,R[e]),E.push(p[e])}let D,P,M,F,H,L=1,N=3*L,q=7*L,U=10,B=10,$=30,j=20;t?(M=(n.utilsCls.sumArray(O)+2*E.length)*(N+q)+4*B+2*$+j*E.length,P=(I+2)*(N+q)+2*U+$):(D=110+j,M=D*E.length,P=(I+2)*(N+q)+2*U,P+=20),Object.keys(i.chainsMapping).length>0&&(M*=3),t?(i.scatterplotWidth=2*P,H=i.scatterplotWidth,F=n.scatterplotid):(i.linegraphWidth=2*P,H=i.linegraphWidth,F=n.linegraphid),s=0==E.length?"No interactions found for each structure

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

    ",s+="";let z,G=0;T=0,z=this.drawGraphPerType(T,p,t,l,o,a,d,G,D,j,O,N,q,B),G=z.heightFinal,s+=z.html,Object.keys(i.chainsMapping).length>0&&(T=1,z=this.drawGraphPerType(T,p,t,h,m,u,d,G,D,j,O,N,q,B),G=z.heightFinal,s+=z.html,T=2,z=this.drawGraphPerType(T,p,t,f,C,b,d,G,D,j,O,N,q,B),G=z.heightFinal,s+=z.html),s+=""}else if(t){let e,t,l,c,h=p[0],m=o.length,u=a.length,g=1,f=3*g,C=7*g,b=30;t=(m+2)*(f+C)+2*10+b,e=(u+2)*(f+C)+2*10+b,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,C="",b=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:C}}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="",C={},b={};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),C="",b={},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",b=e.id;return c.resid2refnum[p]&&(b+="=>"+c.resid2refnum[p]),C+=""+b+"",o?(C+="",C+=""+g+""):(C+="",C+=""+g+""),C+="",C}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(){this.icn3d.icn3dui}handleForce(){let e=this.icn3d;0==e.icn3dui.htmlCls.force&&void 0!==e.simulation?(e.simulation.stop(),e.simulation.force("charge",null),e.simulation.force("x",null),e.simulation.force("y",null),e.simulation.force("r",null),e.simulation.force("link",null)):e.drawGraphCls.drawGraph(e.graphStr,e.pre+"dl_graph")}getNodesLinksForSet(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=[],o=[],a=0,d=l.htmlCls.coilValue,c="",h="",p=0,m={};for(let u in e){let e=n.atoms[u];if("DUM"!=e.chain&&(i||e.het||"CA"==e.name&&"C"==e.elem||"O3'"==e.name||"O3*"==e.name||"P"==e.name)){let i=e.structure+"_"+e.chain+"_"+e.resi;if(m.hasOwnProperty(i))continue;m[i]=1;let u=l.utilsCls.residueName2Abbr(e.resn)+e.resi;"chain"!=t&&"structure"!=t||(u+="."+e.chain),"structure"==t&&(u+="."+e.structure);let g="1_1_"+i,f=e.color?e.color.getHexString().toUpperCase():"000";r.push('{"id": "'+u+'", "r": "'+g+'", "s": "'+s+'", "x": '+e.coord.x.toFixed(0)+', "y": '+e.coord.y.toFixed(0)+', "c": "'+f+'"}'),a>0&&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}} +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;if(!s)continue;s=s.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,C=new Array(9),b=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?(C[0]=x[0]*w[0]+k[0]*S[0]+O[0]*A[0],C[1]=x[0]*w[1]+k[0]*S[1]+O[0]*A[1],C[2]=x[0]*w[2]+k[0]*S[2]+O[0]*A[2],C[3]=x[1]*w[0]+k[1]*S[0]+O[1]*A[0],C[4]=x[1]*w[1]+k[1]*S[1]+O[1]*A[1],C[5]=x[1]*w[2]+k[1]*S[2]+O[1]*A[2],C[6]=x[2]*w[0]+k[2]*S[0]+O[2]*A[0],C[7]=x[2]*w[1]+k[2]*S[1]+O[2]*A[1],C[8]=x[2]*w[2]+k[2]*S[2]+O[2]*A[2]):(C[0]=x[0]*w[0]+k[0]*S[0]-O[0]*A[0],C[1]=x[0]*w[1]+k[0]*S[1]-O[0]*A[1],C[2]=x[0]*w[2]+k[0]*S[2]-O[0]*A[2],C[3]=x[1]*w[0]+k[1]*S[0]-O[1]*A[0],C[4]=x[1]*w[1]+k[1]*S[1]-O[1]*A[1],C[5]=x[1]*w[2]+k[1]*S[2]-O[1]*A[2],C[6]=x[2]*w[0]+k[2]*S[0]-O[2]*A[0],C[7]=x[2]*w[1]+k[2]*S[1]-O[2]*A[1],C[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:C,trans1:I,trans2:E,rmsd:i})}eigen_values(e){let t,s,i,n,l,r,o,a,d,c,h,p,m,u,g,f,C,b,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),b=2*Math.cbrt(e)*Math.cos(t/3)}else f=Math.cbrt(-.5*u+Math.sqrt(g)),C=Math.cbrt(-.5*u-Math.sqrt(g)),b=f+C;return b-=c/3,c+=b,p/=-b,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=_),C=p-h*d/a,b=m-h*c/a,y=g-u*d/a,v=f-u*c/a,Math.abs(C)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=[],C=[],b=[];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(C),h=h.concat(b)),f=[],C=[],b=[];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)),C.push(i[y+2]),b.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(C),h=h.concat(b),d.push(p[p.length-1-g]),c.push(p.length-1-g),h.push(t[p.length-1-g])),f=[],C=[],b=[],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)}async setIgTemplate(e){let t=this.icn3dui.icn3d;t.bRunRefnumAgain=!0;let s=t.resid2specCls.atoms2residues(Object.keys(t.hAtoms));for(let e=0,i=s.length;e0?"_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 append 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 Compound")})),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_collection","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_selectCollections","Select Collections")})),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.densityCifParserCls.densityCifParser(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.densityCifParserCls.densityCifParser(i.inputid,"fofc",sigma2fofc),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;i.bRunRefnumAgain=!0,s.setLogCmd("ig refnum on",!0),i.bAnnoShown||await i.showAnnoCls.showAnnotations();await i.annotationCls.setAnnoTabIg(!0),i.bRunRefnumAgain=!1})),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){e.icn3d,e.cfg.notebook||dialog.dialog("close");let i=$("#"+e.pre+"refTpl").val();await s.setIgTemplate(i),s.setLogCmd("ig template "+i,!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_alignrefTpl","click",(async function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_alignrefTpl","Align with an Ig template")})),e.myEventCls.onIds("#"+e.pre+"mn6_alignrefTpl_apply","click",(async function(t){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"refTpl2").val(),l=e.hashUtilsCls.cloneHash(i.hAtoms),r=e.htmlCls.baseUrl+"icn3d/refpdb/"+n+".pdb";await i.pdbParserCls.downloadUrl(r,"pdb",void 0,n),s.setLogCmd("load url "+r+" | type pdb",!0);let o=n.replace(/_/g,"").substr(0,4),a=i.structures[o][0];i.hAtoms=e.hashUtilsCls.unionHash(l,i.chains[a]),e.cfg.aligntool="tmalign",await i.realignParserCls.realignOnStructAlign(),s.setLogCmd("realign on tmalign",!0)})),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()})),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_addlabelIg","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addIgLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add ig 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 distances among many sets"),s.setSetsMenus("atomsCustomDistTable"),i.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_angleManySets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_anglemanysets","Measure the pairwise angles among many sets"),s.setSetsMenus("atomsCustomAngleTable"),i.bMeasureAngle=!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+"mn2_translate",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_translate","Translate the X,Y,Z coordinates of the structure")})),$(document).on("click","#"+e.pre+"mn6_angleTwoSets",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_angle","Measure the angle between two vectors")})),$(document).on("click","#"+e.pre+"mn2_matrix",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_matrix","Apply matrix to the X,Y,Z coordinates of the structure")})),$(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(" ")[1];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_DSSP"],"click",(async function(t){let i=e.icn3d;s.setLogCmd("set dssp sse",!0),await i.pdbParserCls.applyCommandDssp(),i.bResetAnno=!0,i.bAnnoShown&&(await i.showAnnoCls.showAnnotations(),i.annotationCls.resetAnnoTabAll())})),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 BCIF/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/Name/InchI "+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 Files (appendable)",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.getLink("mn1_collection","Collection 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.getLink("mn2_translate","Translate XYZ",void 0,1),t+=this.getLink("mn2_matrix","Rotate with Matrix",void 0,1),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),t+=this.getRadio("mn4_clr","mn4_clrIgstrand","Ig Strand",void 0,void 0,2),t+=this.getRadio("mn4_clr","mn4_clrIgproto","Ig Protodomain",void 0,void 0,2)):t+=this.getRadio("mn4_clr","mn4_clrAtom","Atom",!0,1,1),t+=this.getMenuSep(),t+=this.getLink("mn4_clrSave","Save Color",void 0,1),t+=this.getLink("mn4_clrApplySave","Apply Saved Color",void 0,1),t+="

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

     Analysis

    ",t+="
    ",t+=this.setMenu5_base(),t+="
    ",t+="
    ",t+="
    ",t}setMenu5_base(){let e=this.icn3dui;if(e.bNode)return"";let t="";t+="
      ",void 0===e.cfg.cid&&(t+=this.getLink("mn6_selectannotations","Seq. & Annotations "+e.htmlCls.wifiStr,1,1),t+=this.getLink("mn2_alignment","Aligned Seq. "+e.htmlCls.wifiStr,void 0,1),void 0===e.cfg.mmdbid&&void 0===e.cfg.gi&&void 0===e.cfg.blast_rep_id&&void 0===e.cfg.align&&void 0===e.cfg.chainalign||(t+=this.getLink("mn2_2ddgm","2D Diagram "+e.htmlCls.wifiStr,1,1)),t+=this.getMenuText("2dctnwrap","2D Cartoon",void 0,void 0,1),t+="
        ",t+=this.getLink("2dctn_chain","Chain Level",void 0,2),t+=this.getLink("2dctn_domain","Domain Level",void 0,2),t+=this.getLink("2dctn_secondary","Helix/Sheet Level",void 0,2),t+="
      ",t+="",t+=this.getLink("definedsets2","Defined Sets",1,1),t+=this.getMenuSep(),t+=this.getLink("mn6_hbondsYes","Interactions",1,1),t+=this.getMenuText("mn1_window","Bring to Front",void 0,void 0,1),t+="
        ",t+=this.getLink("mn1_window_table","Interaction Table",void 0,2),t+=this.getLink("mn1_window_linegraph","2D Interaction Network",void 0,2),t+=this.getLink("mn1_window_scatterplot","2D Interaction Map",void 0,2),t+=this.getLink("mn1_window_graph","2D Graph(Force-Directed)",void 0,2),t+="
      ",t+="",t+=this.getLink("mn6_contactmap","Contact Map",void 0,1),t+=this.getLink("mn1_mutation","Mutation "+e.htmlCls.wifiStr,1,1)),e.cfg.hidelicense||(t+=this.getMenuText("mn1_delphiwrap","DelPhi Potential",void 0,1,1),t+="
        ",t+=this.getLink("mn1_delphi","DelPhi Potential "+e.htmlCls.licenseStr,1,2),t+=this.getMenuText("mn1_phiwrap","Load PQR/Phi",void 0,void 0,2),t+="
          ",t+=this.getLink("mn1_phi","Local PQR/Phi/Cube File",void 0,3),t+=this.getLink("mn1_phiurl","URL PQR/Phi/Cube File",void 0,3),t+="
        ",t+="",t+=this.getLink("delphipqr","Download PQR",void 0,2),t+="
      ",t+=""),t+=this.getMenuSep(),t+=this.getMenuText("mn6_distancewrap","Distance",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_distance","mn6_distanceYes","between Two Atoms",void 0,1,2),t+=this.getRadio("mn6_distance","mn6_distTwoSets","between Two Sets",void 0,void 0,2),t+=this.getRadio("mn6_distance","mn6_distManySets","among Many Sets",void 0,void 0,2),t+=this.getRadio("mn6_distance","mn6_distanceNo","Hide",!0,1,2),t+="
      ",t+="",t+=this.getMenuText("mn6_anglewrap","Angle",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_angle","mn6_angleManySets","among Many Sets",void 0,1,2),t+=this.getRadio("mn6_angle","mn6_angleTwoSets","b/w Two Vectors",void 0,void 0,2),t+="
      ",t+="",t+=this.getLink("mn6_area","Surface Area",1,1),t+=this.getMenuText("mn6_addlabelwrap","Label",void 0,1,1),t+="
        ",t+=this.getRadio("mn6_addlabel","mn6_addlabelYes","by Picking Atoms",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelSelection","per Selection",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelAtoms","per Atom",void 0,void 0,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelElements","per Atom Element",void 0,1,2),void 0===e.cfg.cid&&(t+=this.getRadio("mn6_addlabel","mn6_addlabelResidues","per Residue",void 0,1,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelResnum","per Residue & Number",void 0,1,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelRefnum","per Reference Number",void 0,1,2),t+=this.getRadio("mn6_addlabel","mn6_addlabelIg","per Ig Domain",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=2;e<=10;++e){let s=(e/2).toFixed(1);t+=2==e?this.getRadio("mn6_labelscale","mn6_labelscale"+e+"0",s,!0,1,2):this.getRadio("mn6_labelscale","mn6_labelscale"+e+"0",s,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+="",t+=this.getLink("mn6_DSSP","DSSP Secondary",void 0,1);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 for Selection",void 0,2),t+=this.getLink("mn6_igrefTpl","Ig w/ Specified Template",void 0,2),t+=this.getLink("mn6_alignrefTpl","Align w/ Specified Template",void 0,2),t+=this.getLink("mn6_igrefNo","Reset 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_batchanal",e.htmlCls.baseUrl+"icn3d/icn3d.html#igrefnum","Assign Ig Ref. Numbers",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="";for(let l=0,r=t[n].length;l"+r+", Strands: "+s[r]+""}i+=""}return i}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+="",t+=s+e.htmlCls.inputCheckStr+"id='"+e.pre+"anno_ig'>Ig Domains"+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,n){let l=this.icn3dui.icn3d,r=this,o=t[s],a=e?"append":"load";a+=n?" mmcif file ":" pdb file ";let d=new FileReader;d.onload=async function(d){let c=d.target.result;r.setLogCmd(a+o.name,!1),e?(l.resetConfig(),l.bResetAnno=!0,l.bResetSets=!0):l.init(),l.bInputfile=!0,l.InputfileType=n?"mmcif":"pdb",l.InputfileData=l.InputfileData?l.InputfileData+"\nENDMDL\n"+c:c,i=s>0?i+"\nENDMDL\n"+c:c,Object.keys(t).length==s+1?(e&&(l.hAtoms={},l.dAtoms={}),n?await l.mmcifParserCls.loadMultipleMmcifData(i,void 0,e):await l.pdbParserCls.loadPdbData(i,void 0,void 0,e)):await r.readFile(e,t,s+1,i,n),e&&(l.bSetChainsAdvancedMenu&&l.definedSetsCls.showSets(),l.bResetAnno=!0,l.bAnnoShown&&(await l.showAnnoCls.showAnnotations(),l.annotationCls.resetAnnoTabAll()))},"object"==typeof o&&d.readAsText(o)}async loadPdbFile(e,t,s){let i=this.icn3dui,n=i.icn3d;n.bInitial=!0,i.cfg.notebook||dialog.dialog("close"),i.cfg.notebook?n.resizeCanvasCls.closeDialogs():$(".ui-dialog-content").dialog("close");let l=$("#"+i.pre+t)[0].files;l[0]?(i.htmlCls.setHtmlCls.fileSupport(),n.molTitle="",n.dataStrAll="",await this.readFile(e,l,0,"",s)):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 bcif "+$("#"+e.pre+"mmtfid").val(),!1);let l=n.structures&&Object.keys(n.structures).length>0?"_blank":"_self";window.open(i+"?bcifid="+$("#"+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+"translate_pdb","click",(function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"translateX").val(),l=$("#"+e.pre+"translateY").val(),r=$("#"+e.pre+"translateZ").val();i.transformCls.translateCoord(i.hAtoms,parseFloat(n),parseFloat(l),parseFloat(r)),i.drawCls.draw(),s.setLogCmd("translate pdb "+n+" "+l+" "+r,!0)})),e.myEventCls.onIds("#"+e.pre+"measure_angle","click",(function(t){e.icn3d,t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let i=$("#"+e.pre+"v1X").val(),n=$("#"+e.pre+"v1Y").val(),l=$("#"+e.pre+"v1Z").val(),r=$("#"+e.pre+"v2X").val(),o=$("#"+e.pre+"v2Y").val(),a=$("#"+e.pre+"v2Z").val(),d=new THREE.Vector3(parseFloat(i),parseFloat(n),parseFloat(l)).angleTo(new THREE.Vector3(parseFloat(r),parseFloat(o),parseFloat(a)))/3.1416*180;d=Math.abs(d).toFixed(0),d>180&&(d-=180),d>90&&(d=180-d),s.setLogCmd("The angle is "+d+" degree",!1),$("#"+e.pre+"angle_value").val(d)})),e.myEventCls.onIds("#"+e.pre+"matrix_pdb","click",(function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close");let n=[];for(let t=0;t<16;++t)n.push(parseFloat($("#"+e.pre+"matrix"+t).val()));i.transformCls.rotateCoord(i.hAtoms,n),i.drawCls.draw(),s.setLogCmd("rotate pdb "+n,!0)})),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_collectionfile","click",(function(t){let s=e.icn3d;t.preventDefault();let i=$("#"+e.pre+"collectionfile")[0].files[0];if(i){e.cfg.notebook||dialog.dialog("close"),e.cfg.notebook?s.resizeCanvasCls.closeDialogs():$(".ui-dialog-content").dialog("close"),e.htmlCls.setHtmlCls.fileSupport();let t=new FileReader;t.onload=async function(t){let i=JSON.parse(t.target.result),n=[i.structures.map((({id:e})=>e)),i.structures.map((({title:e})=>e))],l=s.selectCollectionsCls.setAtomMenu(n[0],n[1]);$("#"+s.pre+"collections_menu").html(l),s.selectCollectionsCls.clickStructure(),$("#"+s.pre+"collections_menu").trigger("change"),e.htmlCls.clickMenuCls.setLogCmd("load collection file "+$("#"+e.pre+"collectionfile").val(),!1)},t.readAsText(i),Object.keys(e.utilsCls.getStructures(s.dAtoms))?($("#"+e.pre+"dl_collection_file").hide(),$("#"+e.pre+"dl_collection_structures").show(),$("#"+e.pre+"dl_collection_file_expand").show(),$("#"+e.pre+"dl_collection_file_shrink").hide(),$("#"+e.pre+"dl_collection_structures_expand").hide(),$("#"+e.pre+"dl_collection_structures_shrink").show()):($("#"+e.pre+"dl_collection_file").show(),$("#"+e.pre+"dl_collection_structures").hide(),$("#"+e.pre+"dl_collection_file_expand").hide(),$("#"+e.pre+"dl_collection_file_shrink").hide(),$("#"+e.pre+"dl_collection_structures_expand").show(),$("#"+e.pre+"dl_collection_structures_shrink").hide()),e.htmlCls.dialogCls.openDlg("dl_selectCollections","Select Collections")}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_rcsbmtzfile2fofc","click",(function(t){let s=e.icn3d;t.preventDefault(),s.mtzParserCls.loadMtzFile("2fofc",!0)})),e.myEventCls.onIds("#"+e.pre+"reload_rcsbmtzfilefofc","click",(function(t){let s=e.icn3d;t.preventDefault(),s.mtzParserCls.loadMtzFile("fofc",!0)})),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_rcsbmtzfileurl2fofc","click",(async function(t){let s=e.icn3d;t.preventDefault(),await s.mtzParserCls.loadMtzFileUrl("2fofc",!0)})),e.myEventCls.onIds("#"+e.pre+"reload_rcsbmtzfileurlfofc","click",(async function(t){let s=e.icn3d;t.preventDefault(),await s.mtzParserCls.loadMtzFileUrl("fofc",!0)})),e.myEventCls.onIds("#"+e.pre+"reload_pdbfile","click",(async function(t){e.icn3d,t.preventDefault();await s.loadPdbFile(!1,"pdbfile")})),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,"pdbfile_app")})),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",(async function(t){let i=e.icn3d;t.preventDefault(),i.bAppend=!0;await s.loadPdbFile(i.bAppend,"mmciffile",!0)})),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+"applyangletable","click",(function(t){let i=e.icn3d;t.preventDefault(),e.cfg.notebook||dialog.dialog("close"),i.bMeasureAngle=!1;let n=$("#"+e.pre+"atomsCustomAngleTable").val(),l=$("#"+e.pre+"atomsCustomAngleTable2").val();i.analysisCls.measureAngleManySets(n,l),e.htmlCls.dialogCls.openDlg("dl_angletable","Angles among the sets"),s.setLogCmd("angletable | "+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",C="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(C,!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 | "+n+" | color "+c+" | opacity "+h+" | radius "+d):(i.boxCls.createBox_base(o,d,m,void 0,void 0,void 0,h),p="add cube | "+n+" | 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 C=[],b="",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}b+=""+v+"",h=!(void 0===e||!c.hasOwnProperty(u));for(let e=0,t=y;e"}""!==a?-1!=o.alnChainsSeq[l][e].resi?b+=""+o.alnChainsSeq[l][e].resn+"":b+=""+o.alnChainsSeq[l][e].resn+"":b+=""+o.alnChainsSeq[l][e].resn+""}b+=""+_+"";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?C[t]+=' ':C[t]+=' '}else C[t]+=' '}else C[t]+=' ';else C[t]+="c"==i?' ':"o"==i?' ':"";else C[t]+=""+i+""}C[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+"
    "+C[e]+"
    "}a+=''+b+"
    ",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,C=0,b=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")&&(C=parseFloat(this.getCookie("glycan"))),""!=this.getCookie("membrane")&&(b=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='"+C+"' size=4>"+t.htmlCls.space3+"(0: hide, 1: show, default 0)
    ",i+="
    5. Show Membrane: "+t.htmlCls.inputTextStr+"id='"+t.pre+"membrane' value='"+b+"' 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.tmalignUrl=this.baseUrl+"tmalign/tmalign.cgi",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 C(){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 b={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=b.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=b.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=b.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 E="glTF",T=1313821514,P=5130562;class D{constructor(e){this.name=b.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!==E)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=b.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 H}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 H(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=b.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,C=1-g,b=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]=C*t+b*s+g*i+f*a}return n};const U=new THREE.Quaternion;class B extends q{interpolate_(e,t,s,i){const n=super.interpolate_(e,t,s,i);return U.fromArray(n).normalize().toArray(n),n}}const j=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},Z={33071:THREE.ClampToEdgeWrapping,33648:THREE.MirroredRepeatWrapping,10497:THREE.RepeatWrapping},Q={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=Z[s.wrapS]||RepeatWrapping,t.wrapT=Z[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[b.KHR_TEXTURE_TRANSFORM]){const e=void 0!==s.extensions?s.extensions[b.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=n.associations.get(l);l=n.extensions[b.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[b.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=i[b.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];l=e.getMaterialType(),a.push(e.extendParams(r,n,t))}else if(o[b.KHR_MATERIALS_UNLIT]){const e=i[b.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===H?i[b.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[b.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 Ce(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&&be(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,C=void 0!==l.fontFamily?l.fontFamily:void 0!==this.config.body.fontFamily?this.config.body.fontFamily:"Arial",b=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 '${C}'`,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+b>0&&y.fillText(e,w,S),S+=b}))}}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";be(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 Ee{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 Te{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 De{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 Me{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=[],C=[];f.push(e),f.push(t),C.push(o),C.push(a),this.prepareStrand(f,C,void 0,s,i,n,l,void 0,r,d,c,!0,h,p,m,u,g),f=[],C=[]}prepareStrand(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g,f){let C=this.icn3d,b=C.icn3dui;if(1===d.length)return;let y=i,v=!u,_=[];_.push(i[i.length-2]),_.push(i[i.length-1]),n=n||C.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[j[j.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random()))):U[m]&&"CA"===p.name&&(j.length>o+1?(s=k.clone(),i=d.atoms[j[j.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(C),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((g!==p.chain||p.ssbegin||p.ssend||z||B==W&&"coil"!=p.ss)&&u[0].length>0){let c="CA",g=[],f=[];if(isNaN(d.atoms[D].resi))g=[];else{let e=d.atoms[D].structure+"_"+d.atoms[D].chain+"_"+(parseInt(d.atoms[D].resi)-1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);g=void 0!==t?[t]:[]}if(!isNaN(d.atoms[D].resi)){let e=d.atoms[D].structure+"_"+d.atoms[D].chain+"_"+(parseInt(d.atoms[D].resi)+1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);void 0!==t&&f.push(t);let s=d.atoms[D].structure+"_"+d.atoms[D].chain+"_"+(parseInt(d.atoms[D].resi)+2).toString(),i=d.firstAtomObjCls.getAtomCoordFromResi(s,c);void 0!==i&&f.push(i)}if(!z){1===a||2===a?w.push(d.hColor):w.push(R),C=p.ssend&&"sheet"===p.ss?0:"coil"===E&&p.ssbegin||T&&p.ssbegin||"coil"===p.ss?n:l;let s,i,o=4;"O"===p.name?(s=A.clone(),s.sub(S)):U[m]&&"CA"===p.name&&(j.length>o?(s=S.clone(),i=d.atoms[j[j.length-1-o]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(C),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[D].resi))n=[];else{let t=d.atoms[D].structure+"_"+d.atoms[D].chain+"_"+(parseInt(d.atoms[D].resi)-1).toString();d.firstAtomObjCls.getAtomCoordFromResi(t,e)}for(let e=0;!i&&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 C=r.firstAtomObjCls.getAtomCoordFromResi(l,t);void 0!==C&&f.push(C);let b=r.firstAtomObjCls.getAtomCoordFromResi(o,t);void 0!==b&&f.push(b)}b.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}p=[],m=[],u=[],g=[],f=[],d=c,C=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),l||"coil"==c.ss||c.ssbegin||c.ssend||(e=0),u.push(e),m.push(c.color),1===C&&(m[m.length-2]=c.color),o=c.chain,a=c.resi;let y=1.2;2!==i||c.ssbegin||r.boxCls.createBox(c,void 0,void 0,y,void 0,i),++C,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)}b.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}for(let e=0,t=b.length;e0&&(c=n);else if(g%1==0)n=s[g],n>0&&(c=n);else{let e=Math.floor(g),t=g-e;n=s[e]*(1-t)+s[e+1]*t,r||n<1*c&&(n=0)}e1?a.parasCls.thr(t[t.length-2]):a.parasCls.thr(t[e]),C[v++]=d.r,C[v++]=d.g,C[v++]=d.b}}let k,O=0;for(let e=0,t=S.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=b:b=y);let v=.8*C/y;if(g.width=b,g.height=y,f.clearRect(0,0,b,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*b;this.circle(f,0,0,b,y,e)}else{let e=0;this.roundRect(f,0,0,b,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*b,.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(e){let t=this.icn3d,s=t.icn3dui;if(s.bNode)return;let i=s.hashUtilsCls.intHash(t.hAtoms,t.dAtoms),n=[],l=Object.keys(i).length<100;for(let e in i){let s=t.atoms[e],i=s.structure+"_"+s.chain+"_"+s.resi;(l||""!=i)&&n.push(s.coord.clone())}let r=s.rmsdSuprCls.getEigenForSelection(n,n.length),o=new THREE.Vector3(r.h1[0],r.h1[1],r.h1[2]);if(0==r.k&&t.bRender)return void alert("Can't determine the first principal component. Please select a subset and try it again.");let a=t.applyCenterCls.centerAtoms(i),d=a.maxD,c=a.center,h=c.clone().add(o.normalize().multiplyScalar(.4*d)),p=o.normalize();if(s.htmlCls.clickMenuCls.setLogCmd("Principle X-Axis: "+p.x.toFixed(3)+" "+p.y.toFixed(3)+" "+p.z.toFixed(3),!1),e)return p;let m=new THREE.Vector3(r.h2[0],r.h2[1],r.h2[2]),u=c.clone().add(m.normalize().multiplyScalar(.3*d)),g=new THREE.Vector3(r.h3[0],r.h3[1],r.h3[2]),f=c.clone().add(g.normalize().multiplyScalar(.3*d));this.buildAxes(void 0,c,h,u,f,!0);let C=[c,h,u,f];return t.axes.push(C),t.drawCls.draw(),C}}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),b>h&&(b=h),v>p&&(v=p);let _,w=g[o*m+d*u+y],S=g[a*m+d*u+y],A=g[o*m+b*u+y],x=g[o*m+d*u+v],k=g[a*m+b*u+y],O=g[o*m+b*u+v],R=g[a*m+d*u+v],I=g[a*m+b*u+v],E=r.x-o,T=r.y-d,P=r.z-y,D=((w*(1-E)+S*E)*(1-T)+(A*(1-E)+k*E)*T)*(1-P)+((x*(1-E)+R*E)*(1-T)+(O*(1-E)+I*E)*T)*P,M=s*f+i*C+n;this.vpPot[M]=D,D>this.isovalue&&(D=this.isovalue),D<-this.isovalue&&(D=-this.isovalue),D>0?(D/=1*this.isovalue,_=new THREE.Color(1-D,1-D,1)):(D/=-1*this.isovalue,_=new THREE.Color(1,1-D,1-D)),this.vpColor[M]=_}}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.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),C>this.pHeight&&(C=this.pHeight);let b,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+C],S=l[o*a+p*d+f],A=l[r*a+p*d+C],x=l[o*a+h*d+C],k=l[o*a+p*d+C],O=n.x-r,R=n.y-h,I=n.z-f,E=((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;E>this.isovalue&&(E=this.isovalue),E<-this.isovalue&&(E=-this.isovalue),E>0?(E/=1*this.isovalue,b=new THREE.Color(1-E,1-E,1)):(E/=-1*this.isovalue,b=new THREE.Color(1,1-E,1-E)),this.icn3d.atoms[t[s]].color=b,this.icn3d.atomPrevColors[t[s]]=b}}else{for(let p in t){let f,C=e[t[p]];if("DUM"!==C.resn){if(void 0!==this.rmsd_supr&&void 0!==this.rmsd_supr.rot){f=this.transformMemPro(C.coord,g,u,m).applyMatrix4(c)}else f=C.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,C=r.parasCls.thr("#00FFFF"),b=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(b.z):parseInt(b.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 Qe{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(),C=new THREE.Vector3(0,0,1),b=new THREE.Quaternion;b.setFromUnitVectors(f,C);let y=-9999;for(let t in e){let e=i.atoms[t].coord.clone();c.add(e),e.sub(a).applyQuaternion(b);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),E=a.clone().add(h.clone().sub(a).multiplyScalar(.83)).add(R),T=2*Math.PI/o;for(let e=0;et&&(i.sphereCls.createSphereBase(r,m,d,1,0),i.cylinderCls.createCylinder(e,r,d,m,0),i.cylinderCls.createCylinder(s,r,d,m,0),void 0!==n&&i.cylinderCls.createCylinder(c[n],r,d,m,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()}addIgLabels(e){let t=this.icn3d;if(t.icn3dui.bNode)return;t.labels.ig=[];let s=t.firstAtomObjCls.getChainsFromAtoms(e);for(let e in t.igLabel2Pos)if(s.hasOwnProperty(e))for(let s in t.igLabel2Pos[e]){let i={};i.position=t.igLabel2Pos[e][s],i.text=s,i.size=60,i.color="#00FFFF",t.labels.ig.push(i)}t.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),C=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(C),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,C=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 C=this.calcPlaneAngle(l,n);return!(void 0!==C&&C>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 C=t[e],b=i?"LYS"===C.resn&&"N"===C.elem&&"N"!==C.name||"ARG"===C.resn&&("NH1"===C.name||"NH2"===C.name)||("GLU"===C.resn||"ASP"===C.resn)&&"O"===C.elem&&"O"!==C.name||C.het&&("N"===C.elem||"O"===C.elem||"S"===C.elem):"N"===C.elem||"O"===C.elem||"S"===C.elem&&(C.het||"Cys"===C.resn||"Met"===C.resn);if(b=r.bOpm?b&&"DUM"!==C.resn:b,b){a=C.structure+"_"+C.chain+"_"+C.resi,d=a+"_"+C.name;let e=C.resn+" $"+C.structure+"."+C.chain+":"+C.resi+"@"+C.name;void 0===r.resid2Residhash[e]&&(r.resid2Residhash[e]={});for(let t in c){if(i&&!(("LYS"!==C.resn&&"ARG"!==C.resn||"LYS"!==c[t].resn&&"ARG"!==c[t].resn)&&("GLU"!==C.resn&&"ASP"!==C.resn||"GLU"!==c[t].resn&&"ASP"!==c[t].resn)))continue;if(!r.crossstrucinter&&C.structure!=c[t].structure)continue;if(a==t.substr(0,t.lastIndexOf("_")))continue;let d=Math.abs(C.coord.x-c[t].coord.x);if(d>s)continue;let b=Math.abs(C.coord.y-c[t].coord.y);if(b>s)continue;let y=Math.abs(C.coord.z-c[t].coord.z);if(y>s)continue;let v=d*d+b*b+y*y;if(v>h)continue;if(!r.proteins.hasOwnProperty(C.serial)||!r.proteins.hasOwnProperty(c[t].serial)||"N"!==C.name&&"O"!==C.name||"O"!==c[t].name&&"N"!==c[t].name){if(!this.isValidHbond(C,c[t],s))continue}else{if(C.name===c[t].name)continue;if(C.structure==c[t].structure&&C.chain==c[t].chain&&Math.abs(C.resi-c[t].resi)<=1)continue;let e,i="N"===C.name?C:c[t],n="O"===C.name?C:c[t];if("Pro"===i.resn)continue;if(void 0===i.hcoord){if(!this.isValidHbond(C,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),b=o.distanceTo(h);e=p2||f[c[t].serial]>2)continue;void 0===f[C.serial]?f[C.serial]=1:++f[C.serial],void 0===f[c[t].serial]?f[c[t].serial]=1:++f[c[t].serial],"graph"!==n&&(i?(r.saltbridgepnts.push({serial:C.serial,coord:C.coord}),r.saltbridgepnts.push({serial:c[t].serial,coord:c[t].coord})):(r.hbondpnts.push({serial:C.serial,coord:C.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+"_"+C.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 C=Object.keys(m);if("graph"!==n)for(let e=0,t=C.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 C,b=i.structure+"_"+i.chain+"_"+i.resi;g&&"ARG"===i.resn&&"NH1"===i.name?C=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[b],"NH2"):f&&"GLU"===i.resn&&"OE1"===i.name?C=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[b],"OE2"):f&&"ASP"===i.resn&&"OD1"===i.name&&(C=r.firstAtomObjCls.getFirstAtomObjByName(r.residues[b],"OD2"));let y=void 0===C?i.coord:i.coord.clone().add(C.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 C=void 0===c?t[d].coord:t[d].coord.clone().add(c.coord).multiplyScalar(.5),b=Math.abs(y.x-C.x);if(b>s)continue;let v=Math.abs(y.y-C.y);if(v>s)continue;let _=Math.abs(y.z-C.z);if(_>s)continue;let w=b*b+v*v+_*_;if(w>p)continue;"graph"!==n&&(r.saltbridgepnts.push({serial:i.serial,coord:y}),r.saltbridgepnts.push({serial:t[d].serial,coord:C}));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":case"secondary structure":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":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=[],C=-9999;for(let e in t){if(!i.proteins.hasOwnProperty(e))continue;let t=i.atoms[e];-9999==C&&(u=parseInt(e)),-9999!=C&&(t.ss!=g.ss||Math.abs(t.resi-g.resi)>1||t.ssbegin&&g.ssend)&&("coil"==g.ss||f.push([u,C]),u=e),C=parseInt(e),g=t}"coil"==g.ss||f.push([u,C]),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)/b;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,"domain",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 C=d.motifs;n.bNode&&!i.resid2site[c]&&(i.resid2site[c]=[]),g=l.setDomainFeature(C,c,"feat",h,p,m,f),h=g.html,p=g.html2,m=g.html3;let b=a.data[e].sites,y=void 0!==b?b.length:0;for(let e=0;e17&&(s=s.substr(0,17)+"...");let l,r=b[e].title,o=[];for(let t=0,s=b[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(),C=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: "+b[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)-C-y):Math.round(i.seqAnnWidth*t/i.maxAnnoLength-C-y);o>=0&&(p+='
     
    ',p+='
     
    ',C+=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,o,a){let d,c,h,p=this.icn3d,m=p.icn3dui,u="domain"!=s&&"feat"!=s;"domain"==s&&(r={},d={},c={},h={}),void 0===e&&(e=[]);let g=e.length,f="domain"==s?14:19,C="domain"==s?100:120;e.sort((function(e,t){let i=e.locs,n="domain"==s||"ig"==s?i[0].segs:[i[0]],l=Math.round(n[0].from);return i=t.locs,n="domain"==s||"ig"==s?i[0].segs:[i[0]],l-Math.round(n[0].from)}));for(let b=0;bf&&(w=w.substr(0,f)+"...");let S=u?a[b]:s+": "+v;"domain"==s&&(d[g]=v);let A=e[b].locs;if(A)for(let e=0,r=A.length;e'+w+" ",I=''+u.toString()+" Res";l+=R+I+"
    ";let E='';i+=R+I+E,"domain"==s&&(n+='
    '),n+='
    '+w+"
    ",n+=I+E;let T=s+b.toString();p.seqStartLen&&p.seqStartLen[t]&&(i+=p.showSeqCls.insertMulGap(p.seqStartLen[t],"-"));for(let e=0,n=p.giSeq[t].length;e1&&(l=n[0]+"..");let r=p.ParserUtilsCls.getResi(t,e);if(i+=''+n+"",m.bNode){let e={};e[t+"_"+r]=S,"domain"==s?p.resid2cdd[t].push(e):p.resid2site[t].push(e)}}else i+="-";if(p.seqStartLen&&p.seqStartLen[t]&&(i+=p.showSeqCls.insertMulGap(p.seqEndLen[t],"-")),p.seqStartLen&&p.seqStartLen[t]&&(n+=p.showSeqCls.insertMulGapOverview(t,p.seqStartLen[t])),m.cfg.blast_rep_id!=t){let i;for(let l=0,d=r.length;l ',n+='
    '+v+"
    "}}else{let i=[],l=[];for(let e=0,t=r.length;e ',n+='
    '+v+"
    "}}E=' '+u.toString()+" Residues",E+="
    ",E+="
    ",i+=E,n+=E,"domain"==s&&(n+='')}}return{html:i,html2:n,html3:l,acc2domain:r,pssmid2name:d,pssmid2fromArray:c,pssmid2toArray:h}}getColorFromPos(e,t,s){let i,n=this.icn3d;n.icn3dui;let l=e+"_"+n.ParserUtilsCls.getResi(e,t),r=n.firstAtomObjCls.getFirstAtomObj(n.residues[l]),o=r&&void 0!==r.color&&"FFFFFF"!==r.color.getHexString()?r.color.getHexString():"DDDDDD";return i=r&&void 0!==r.color?o:"CCCCCC",i}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 C='';a+=g+f+C,d+=g+f+C;let b=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],"-")),C=' '+m.toString()+" Residues",C+="",C+="
    ",a+=C,d+=C,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 C="inter"+c.toString(),b=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)-b-y):Math.round(s.seqAnnWidth*t/s.maxAnnoLength-b-y);h>=0&&(a+='
     
    ',a+='
     
    ',b+=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,s.substr(0,s.indexOf("_"));for(let d in t){let c=t[d],h=[],p=!1;for(let e=0,t=c.length;e5?h.push(e-1):i.UPResi2ResiPosPerChain&&i.UPResi2ResiPosPerChain[s][e]&&h.push(i.UPResi2ResiPosPerChain[s][e]),!p&&i.residues.hasOwnProperty(s+"_"+e)&&(p=!0)}if(0==h.length)continue;let m=h.length,u="ptm"==e?"PTM: "+d:"Transmembrane";u.length>17&&(u=u.substr(0,17)+"...");let g=d,f='
    '+u+"
    ",C=''+m.toString()+" Res",b='';a+=f+C+"
    ",r+=f+C+b,o+=f+C+b;let y=e+l.toString(),v=0,_=0,w=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]=u,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)-v-_):Math.round(i.seqAnnWidth*e/i.maxAnnoLength-v-_);d>=0&&(o+='
     
    ',o+='
     
    ',v+=d,_+=w)}else r+="-";i.seqStartLen&&i.seqStartLen[s]&&(r+=i.showSeqCls.insertMulGap(i.seqEndLen[s],"-")),b=' '+m.toString()+" Residues",b+="
    ",b+="
    ",r+=b,o+=b,++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}async showIg(e,t){let s=this.icn3d;s.icn3dui,s.bRunRefnumAgain&&await s.refnumCls.showIgRefNum(t);let i="",n="",l="";if(s.bShowRefnum&&s.chainid2refpdbname.hasOwnProperty(e)&&s.chainid2refpdbname[e].length>0){let t=s.showSeqCls.getSeq(e),r=s.annoIgCls.showAllRefNum(t,e);i+=r.html,n+=r.html2,l+=r.html3}$("#"+s.pre+"dt_"+"ig_"+e).html(i),$("#"+s.pre+"ov_"+"ig_"+e).html(n),$("#"+s.pre+"tt_"+"ig_"+e).html(l)}showAllRefNum(e,t){let s=this.icn3d;s.icn3dui;let i="",n="",l="",r=!1;for(let i=0,n=e.length;i0){r=!0;break}}let o=!1;for(let i=0,n=e.length;i0){o=!0;break}}let a=this.showRefNum(e,t);i+=a.html,n+=a.html2,l+=a.html3;let d=1;return r&&(a=this.showRefNum(e,t,d),i+=a.html,n+=a.html2,l+=a.html3),d=2,o&&(a=this.showRefNum(e,t,d),i+=a.html,n+=a.html2,l+=a.html3),{html:i,html2:n,html3:l}}showRefNum(e,t,s,i){let n=this.icn3d;if(n.icn3dui,n.chainid2igtrack){if(!n.chainid2igtrack[t])return{html:"",html2:"",html3:""}}let l=this.getIgAnnoHtml(t,e,i,s);return n.bShowRefnum&&(n.opts.color="ig strand",n.setColorCls.setColorByOptions(n.opts,n.chains[t])),l}setChain2igArray(e,t,s){let i,n=this.icn3d;n.icn3dui;let l={};for(let r=0,o=t.length;r0&&s!=i+1&&(a.push(i),o.push(s)),i=s;a.push(s);let d={};d.domainid=t,d.startPosArray=o,d.endPosArray=a,n.chain2igArray[e].push(d)}}getIgAnnoHtml(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r="",o="",a="";n.chain2igArray||(n.chain2igArray={});let d,c,h,p=!1,m="";n.chain2igArray[e]=[],this.setChain2igArray(e,t,s);let u=n.chain2igArray[e];for(let t=0,s=u.length;t=0;--t){let s=e+"_"+n.chainsSeq[e][t].resi;if(!n.residIgLoop.hasOwnProperty(s))break;delete n.resid2refnum[s],delete n.residIgLoop[s],delete n.resid2domainid[s]}}}n.chain2igArray[e]=[],this.setChain2igArray(e,t,s);let g="";for(let l=0,r=t.length;l'+h+"":' '}else g+="";else if(1==i||2==i)if(h){let e=parseInt(h).toString(),t='style="color:'+this.getRefnumColor(m,!0)+'"';g+=parseInt(e.substr(e.length-2,2))%2==0?"'+h+"":" '}else g+="";else" "!=m?(p=n.residIgLoop[t],g+=this.getRefnumHtml(t,h,c,d,m,p,o)):g+="";else g+=""}if(l.bNode)return{html:r,html2:o,html3:a};let f="icn3d-link icn3d-blue",C="IgStRAnD Ref. No.",b=n.chain2igArray[e].length,y=[],v=[],_={};n.igLabel2Pos||(n.igLabel2Pos={}),n.igLabel2Pos[e]={};for(let t=0;t",S='
    ';s&&(S='
    ');let A='
    '+C+"
    ";if(S+='
    ',s?(S+='
    Custom Ref. No.
    ',S+=''):1==i?(S+='
    Kabat Ref. No.
    ',S+=''):2==i?(S+='
    IMGT Ref. No.
    ',S+=''):(S+=A,S+=w),a+=S+"
    ",r+=S+'',n.seqStartLen&&n.seqStartLen[e]&&(r+=n.showSeqCls.insertMulGap(n.seqStartLen[e],"-")),r+=g,n.seqStartLen&&n.seqStartLen[e]&&(r+=n.showSeqCls.insertMulGap(n.seqEndLen[e],"-")),s||(r+=w),r+="",r+="
    ",r+="
    ",r+="
    ",u=n.chain2igArray[e],0==u.length)return{html:r,html2:o,html3:a};let x=[],k=[],O=[],R=[],I=e.substr(e.lastIndexOf("_")+1);for(let e=0,t=u.length;e',n.seqStartLen&&n.seqStartLen[e]&&(o+=n.showSeqCls.insertMulGapOverview(e,n.seqStartLen[e]));for(let i=0,l=y.length;i 
    ',o+='
    '+R[r]+"
    ",t=r}o+=w,o+="",a+="",S='
    ';let i=S,l=S,d=n.annoCddSiteCls.setDomainFeature(x,e,"ig",S,i,l,void 0,k,O);r+=d.html+"
    ",o+=d.html2+"",a+=d.html3+""}return{html:r,html2:o,html3:a}}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 C="";return!i||50!=f||p||l?i&&f%2==0&&52!=f&&!r?(g=isNaN(t)?g+t.substr(t.length-1,1):g,C+="'+g+""):C+=" ':(o.hAtomsRefnum=a.hashUtilsCls.unionHash(o.hAtomsRefnum,o.residues[e]),C+="'+i.substr(0,1)+""+i.substr(1)+""),C}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}}class At{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);h.length>1&&"1"==h.substr(h.length-1)&&(h=h.substr(0,h.length-1)),n=e,i=t.domains[e]?t.domains[e].domains:[];for(let t=0,s=i.length;t17?s.substr(0,17)+"...":s,h=i[t].intervals,p=[],m=[],u={},g=0;for(let t=0,s=h.length;t'+c+" ",C=''+g.toString()+" Res";d+=f+C+"
    ";let b='';o+=f+C+b,a+=f+C+b;let y="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 v=l.firstAtomObjCls.getFirstCalphaAtomObj(l.chains[e]),_=void 0===v.color||"FFFFFF"===v.color.getHexString()?"DDDDDD":v.color.getHexString(),w=void 0!==v.color?_:"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=p.length;i ',a+='"}else{let i=[],n=[];for(let e=0,t=p.length;e ',a+='"}}b=' '+g.toString()+" Residues",b+="",b+="
    ",o+=b,a+=b}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 kt{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,C=f.icn3dui,b="",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)"),b+=m?'":'"}else if(2==e&&m){let e=C.utilsCls.isMobile()?"none":"button";b+='
    ',b+='
    '}else b+='
    ';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 b+"
    ";b+='';let O="",R=0,I=0;p?f.seqStartLen&&f.seqStartLen[h]&&(b+=f.showSeqCls.insertMulGapOverview(h,f.seqStartLen[h])):f.seqStartLen&&f.seqStartLen[h]&&(b+=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&&(b+='
     
    ',b+='
     
    ',R+=r,I+=1):r>0&&(b+='
     
    ',b+='
     
    ',R+=r,I+=1)}}else if(b+=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,b&&!C.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)b&&!C.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,b&&!C.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]+")"):(b&&!C.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]?b+=1==e?"":""==p||" "==p?"-":''+p+"":b+="-":b+=""==p||" "==p?"-":g?''+p+"":''+p+""}else b+="";else b+="-";return p||f.seqStartLen&&f.seqStartLen[h]&&(b+=f.showSeqCls.insertMulGap(f.seqEndLen[h],"-")),b+=1==e?' '+k+" Residues":'',b+="
    ",b+="
    ",b}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 C={},b={},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===b[d]&&(b[d]=[]),b[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===C[d]&&(C[d]=[]),C[d].push(A)}let S=Object.keys(v),A=Object.keys(_);if(i){let e=!1;o+=this.getSnpLine(1,2,u,b,y,f,g,C,S,A,1,t,!1,e,void 0,i),o+=this.getSnpLine(2,2,u,b,y,f,g,C,S,A,0,t,!1,e,void 0,i),d+=this.getSnpLine(1,2,u,b,y,f,g,C,S,A,1,t,!1,e,!0,i),d+=this.getSnpLine(2,2,u,b,y,f,g,C,S,A,0,t,!1,e,!0,i),a+=this.getSnpLine(1,2,u,b,y,f,g,C,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,b,y,f,g,C,S,A,1,t,!1,e,void 0,i),c+=this.getSnpLine(2,2,u,b,y,f,g,C,S,A,0,t,!1,e,void 0,i),p+=this.getSnpLine(1,2,u,b,y,f,g,C,S,A,1,t,!1,e,!0,i),p+=this.getSnpLine(2,2,u,b,y,f,g,C,S,A,0,t,!1,e,!0,i),h+=this.getSnpLine(1,2,u,b,y,f,g,C,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 Ot{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 It{constructor(e){this.icn3d=e,this.init3ddomain()}init3ddomain(){this.icn3d.icn3dui,this.dcut=8,this.min_contacts=2,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 o=this.standardizeSubstruct(p,o,u),{subdomains:a,substruct:o};let f=h.length,C=f,b=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((function(e,t){return e-t}));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){P.push(t);break}t.push(s)}}}P.sort((function(e,t){return e[0]-t[0]}));let D=[];for(let e=0,t=P.length;e=this.min_sse&&D.push(P[e])}if(P=D,0==P.length){let e={},t={},s=0;for(let i=0,n=this.group_num.length;i=3&&(s=n)):e[n]=1)}if(0!=s){let e=[s].concat(t[s]);P.push(e)}}for(let e=0,t=P.length;e=o.length)return o=this.standardizeSubstruct(p,o,u),{subdomains:a,substruct:o};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;ec&&(c=p),i.ssend&&(o.To=e+1,o.x2=i.coord.x,o.y2=i.coord.y,o.z2=i.coord.z,o.Sheet="sheet"==i.ss,r.push(o),o={}),i.ssbegin&&(o.From=e+1,o.x1=i.coord.x,o.y1=i.coord.y,o.z1=i.coord.z)}r=this.standardizeSubstruct(l,r,a);let h='{"data": [';h+='{"ss": [';let p=0;for(let e=0,s=r.length;e0&&(h+=", "),h+="["+s+","+i+","+n+","+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)+"]",++p)}h+="]",h+=', "domain": [';let m=0;for(let e=d;e<=c;++e){let n=l+"_"+e,r=t.ncbi2resid[n],o=e;if(m>0&&(h+=", "),i.hasOwnProperty(r)){let e=t.firstAtomObjCls.getFirstCalphaAtomObj(t.residues[r]);h+="["+o+","+(s.parasCls.resn2restype[e.resn]?s.parasCls.resn2restype[e.resn]:0)+","+e.coord.x.toFixed(2)+","+e.coord.y.toFixed(2)+","+e.coord.z.toFixed(2)+"]"}else h+="["+o+",0,0,0,0]";++m}return h+="]}",h+="]}",h}}class Et{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 C="",b=[];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,p){let m=this.icn3d,u=m.icn3dui,g=!1;"cannot be aligned"==s&&(g=!0);let f=s.replace(/-/g,"").length;if(!o)if(s.length>m.giSeq[e].length)s=s.substr(0,m.giSeq[e].length);else if(s.length20&&(C=C.substr(0,20));let b=u.htmlCls.RESIDUE_WIDTH*s.length+200;$("#"+m.pre+"dt_custom_"+e).append("
    "),$("#"+m.pre+"dt_custom_"+e+"_"+C).width(b),$("#"+m.pre+"ov_custom_"+e).append("
    "),$("#"+m.pre+"ov_custom_"+e+"_"+C).width(b),$("#"+m.pre+"tt_custom_"+e).append("
    "),$("#"+m.pre+"tt_custom_"+e+"_"+C).width(b);let y='
    ',v=y,_=y,w=y,S=y,A=parseInt(10*Math.random()),x='",k='
    Exons
    ',O=''+f.toString()+" Pos";w+=x+O+"
    ",S+=k+O+"
    ";let R='';y+=x+O+R,v+=k+O+R,_+=x+O+R;let I=e.indexOf("_"),E="cst"+e.substr(I+1),T=0,P=0,D=(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"),F={},H=0;x="";let L={},N={},q={},U=0;if(h)for(let e=0,t=h.length;e"+d+"",h){let t='style="background-color:'+L[U]+'"';v+=' ";for(let t in m.residues[e+"_"+g]){let e=m.atoms[t];e.color=u.parasCls.thr(L[U]),m.atomPrevColors[t]=e.color}}x+=m.showSeqCls.insertGapOverview(e,t);let f=Math.round(m.seqAnnWidth*t/(m.maxAnnoLength+m.nTotalGap)-T-P);f<0&&(f=0),x+='
     
    ',s=void 0!==i&&""!=i[t]?i[t]:r?"rgb("+r+")":D?"#"+c:"#333",x+='
     
    ',T+=f,P+=1,++U}else g?y+=""+d+"":(y+="-",v+="")}if(void 0!==a){x="";let s=[],i=[],n=[];for(let e=0,t=a.length;e 
    ',h){let t,s,i=n[r];l=d[r]-a[r]+1;let o,c,p,m=g,u=g+l-1;g+=l;for(let e=0,i=h.length;e=i&&m<=n&&(t={exonIndex:e,rangeStart:i,rangeEnd:n,from:m,genomeRange:h[e].genomeRange}),u>=i&&u<=n&&(s={exonIndex:e,rangeStart:i,rangeEnd:n,to:u,genomeRange:h[e].genomeRange})}if(t&&s&&t.exonIndex==s.exonIndex)o=this.getExonColor(t.rangeStart,t.rangeEnd,m),c=this.getExonColor(t.rangeStart,t.rangeEnd,u),p=o+" 0%, #FFF 50%, "+c+" 100%",x+=this.getExonHtml(t.exonIndex,p,t.from,s.to,t.genomeRange,e,C,i);else if(t&&(o=this.getExonColor(t.rangeStart,t.rangeEnd,m),p=o+" 0%, #FFF 50%, #00F 100%",x+=this.getExonHtml(t.exonIndex,p,t.from,t.rangeEnd,t.genomeRange,e,C,i)),t&&s){for(let n=t.exonIndex+1;n'+t+""}}R=''+f.toString()+" Pos",R+="",R+="
    ",R+="",y+=R,_+=x+R,v+=R,w+="",S+="",h?($("#"+m.pre+"dt_custom_"+e+"_"+C).html(v+y),$("#"+m.pre+"ov_custom_"+e+"_"+C).html(_),$("#"+m.pre+"tt_custom_"+e+"_"+C).html(S+w)):($("#"+m.pre+"dt_custom_"+e+"_"+C).html(y),$("#"+m.pre+"ov_custom_"+e+"_"+C).html(_),$("#"+m.pre+"tt_custom_"+e+"_"+C).html(w))}getExonHtml(e,t,s,i,n,l,r,o){let a=this.icn3d;return a.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=!1,r=!0;if(s.hAtoms={},"igdomain"==t){let t=s.chain2igArray[e];if(t&&t.length>0)for(let i=0,o=t.length;i1e3&&"50"==C.substr(C.length-2,2)&&(n[y]=1):(d=s.residIgLoop.hasOwnProperty(y)?"igloop":"igstrand",u&&d!=c&&Object.keys(n).length>0&&("igstrand"==c?(++h,i="Strand-"+a+"-"+e+"-"+h.toString().padStart(3,"0"),i=i.replace(/'/g,"`"),"igstrand"==t&&(s.selectionCls.selectResidueList(n,i,i,l,r),l||(l=!0)),m=a):"igloop"==c&&(++p,i="Loop-"+m+"_"+o+"-"+e+"-"+p.toString().padStart(3,"0"),i=i.replace(/'/g,"`"),"igloop"==t&&(s.selectionCls.selectResidueList(n,i,i,l,r),l||(l=!0))),n={}),n[y]=1,a=o,c=d,u=!0)))}"iganchor"==t?(i="Anchor-"+e,s.selectionCls.selectResidueList(n,i,i,l,r)):"igstrand"==c?(++h,i="Strand-"+a+"-"+e+"-"+h.toString().padStart(3,"0"),i=i.replace(/'/g,"`"),"igstrand"==t&&s.selectionCls.selectResidueList(n,i,i,l,r)):"igloop"==c&&(++p,o="CT",i="Loop-"+m+"_"+o+"-"+e+"-"+p.toString().padStart(3,"0"),i=i.replace(/'/g,"`"),"igloop"==t&&s.selectionCls.selectResidueList(n,i,i,l,r))}}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},C=await n.getAjaxPostPromise(o,f);if(!C.data)return void console.log("The protein accessions "+u+","+g+" can not be aligned...");let b=[];i.qt_start_end={};let y=[],v=[],_=Object.keys(C.targets)[0],w=C.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]=C-1-f,u||(g=s,o.seqStartLen[e]=g,u=!0)):++m;o.maxAnnoLength0&&(b+=" "),b+=e+"_"+o.targetGapHash[e].from+"_"+o.targetGapHash[e].to,++y;let v={};for(let a=0,d=i.length;a=o.seqStartLen[e]&&("-"==t[s]&&b--,"-"==h&&b++),c+=h,"-"!=t[s]&&(t[s]==i[a][s]&&++v[d],++d),p=h;"-"!=p&&u.push(C-1);let _=s[a].length<20?s[a]:s[a].substr(0,20)+"...",w=!0,S=r?r[s[a]]:void 0;this.showNewTrack(e,_,c,void 0,void 0,l,void 0,w,m,u,f,S,y)}o.opts.color="exon",o.legendTableCls.showColorLegend(o.opts.color),o.hlUpdateCls.updateHlAll(),o.drawCls.draw()}processAccList(e){this.icn3d.icn3dui;let t=e.split(","),s={},i="";for(let e=0,n=t.length;e5?(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","ig"];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}async updateIg(e,t){let s=this.icn3d,i=s.icn3dui;if(s.opts.color="ig strand",!e){s.hAtoms={};for(let e in s.protein_chainid)s.hAtoms=i.hashUtilsCls.unionHash(s.hAtoms,s.chains[e])}let n=s.firstAtomObjCls.getResiduesFromAtoms(s.hAtoms);for(let e in n)s.resid2refnum&&delete s.resid2refnum[e],s.residIgLoop&&delete s.residIgLoop[e],s.resid2domainid&&delete s.resid2domainid[e];s.bRunRefnumAgain=!0;let l=e?s.firstAtomObjCls.getChainsFromAtoms(s.hAtoms):s.protein_chainid;for(let e in l)await s.annoIgCls.showIg(e,t),s.bRunRefnumAgain=!1;s.bShowRefnum&&(s.hlUpdateCls.updateHlAll(),s.drawCls.draw())}}class Pt{constructor(e){this.icn3d=e}showAnnotations_part1(e){let t=this.icn3d,s=t.icn3dui;if(s.htmlCls.dialogCls.openDlg("dl_selectannotations","Sequences and Annotations"),(void 0===t.bAssemblyNote||!t.bAssemblyNote)&&void 0!==t.asuCnt){let e="
    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("+t.asuCnt+" asymmetric unit).
    ";$("#"+t.pre+"dl_annotations_tabs").append(e),t.bAssemblyNote=!0}t.bResetAnno&&(t.giSeq={},t.currClin={},t.resi2disease_nonempty={},t.baseResi={},t.matchedPos={},$("#"+s.pre+"dl_annotations").empty(),t.annotationCls.setAnnoView("overview"));let i={},n={},l={};if(void 0===t.bAnnoShown||!t.bAnnoShown||t.bResetAnno){t.protein_chainid={};let r,o=Object.keys(t.chains);if(e){let s=t.resid2specCls.atoms2structureArray(e);o=[];for(let e=0,i=s.length;e1&&"1"==d.substr(d.length-1)?(d=d.substr(0,d.length-1),a=o[e].substr(0,o[e].indexOf("_"))+"_"+d):a=o[e],t.proteins.hasOwnProperty(r.serial)&&t.chainsSeq[o[e]].length>1)t.protein_chainid[o[e]]=a;else if(t.nucleotides.hasOwnProperty(r.serial)&&t.chainsSeq[o[e]].length>1)i[o[e]]=a;else if(t.chainsSeq[o[e]].length>1)n[o[e]]=a;else{let s=t.chainsSeq[o[e]][0].name,i=o[e]+"_"+t.chainsSeq[o[e]][0].resi;void 0===l[s]&&(l[s]=[]),l[s].push(i)}if((void 0!==s.cfg.pdbid||void 0!==s.cfg.opmid||void 0!==s.cfg.mmcifid||void 0!==s.cfg.mmtfid)&&(t.proteins.hasOwnProperty(r.serial)||t.nucleotides.hasOwnProperty(r.serial)))for(let s=0,i=t.chainsSeq[o[e]].length;st.maxAnnoLengthOri&&(t.protein_chainid.hasOwnProperty(e)||i.hasOwnProperty(e))&&(t.maxAnnoLengthOri=t.chainsSeq[e].length);t.maxAnnoLength=t.maxAnnoLengthOri}return{nucleotide_chainid:i,chemical_chainid:n,chemical_set:l}}async showAnnotations(e){let t=this.icn3d,s=t.icn3dui,i=this,n=this.showAnnotations_part1(e),l=n.nucleotide_chainid,r=n.chemical_chainid,o=n.chemical_set;if(!t.bAnnoShown||t.bResetAnno)if(t.bAnnoShown=!0,void 0===s.cfg.blast_rep_id){if(t.bFullUi){if(void 0!==s.cfg.mmtfid){let e=Object.keys(t.structures)[0];await t.mmcifParserCls.downloadMmcifSymmetry(e,"mmtfid")}await this.showAnnoSeqData(l,r,o)}}else if(void 0===s.cfg.blast_rep_id||t.bSmithwm||t.bLocalSmithwm){if(void 0!==s.cfg.blast_rep_id&&(t.bSmithwm||t.bLocalSmithwm)){let e,n,a=[s.cfg.blast_rep_id];if(-1!=s.cfg.query_id.indexOf(">")?n=s.cfg.query_id.substr(s.cfg.query_id.indexOf("\n")+1):!/\d/.test(s.cfg.query_id)||s.cfg.query_id.length>50?n=s.cfg.query_id:a.push(s.cfg.query_id),t.blastAcxn){let i=s.cfg.afid+"_A",n="";for(let e=0,s=t.chainsSeq[i].length;e5){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),h+="   "+this.addButton(s,"icn3d-iganchorsets","Ig Anchor Set",'Define the set for all Ig anchors in this chain and add them to the menu of "Defined Sets"',80,i)+" "+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)+" "+this.addButton(s,"icn3d-igdomainsets","Ig Domain Sets",'Define sets for each Ig domain 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","ig"];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 Dt{constructor(e){this.icn3d=e}getSeq(e){let t,s=this.icn3d,i=s.icn3dui;if(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&&void 0===i.cfg.mmdbafid){t=[];for(let i=0;i10){m='
    ';let t=o.firstAtomObjCls.getFirstCalphaAtomObj(o.chains[e]);void 0===a.cfg.mmdbid&&void 0===a.cfg.gi&&void 0===a.cfg.blast_rep_id&&void 0===a.cfg.align&&void 0===a.cfg.chainalign&&void 0===a.cfg.mmdbafid||void 0===t.resi_ori||t.resi_ori==t.resi||-1!=e.indexOf("Misc")?m+='
    ':m+='
    NCBI Residue Numbers
    ',m+='',f+=m+"
    ",u+=m+'';let s=0,i=0,n="";o.seqStartLen&&o.seqStartLen[e]&&(u+=this.insertMulGap(o.seqStartLen[e]," "));for(let t=0,l=d.length;t",l%10==0&&(u+=l);let r=e+"_"+l,a=l%10!=0&&l%10!=1&&l%10!=9;if(o.residues.hasOwnProperty(r)){let e=o.firstAtomObjCls.getFirstCalphaAtomObj(o.residues[r]);"H"==o.secondaries[r]&&e.ssbegin?(++s,n='H'+s+"",a&&(u+=n,n="")):"E"==o.secondaries[r]&&e.ssbegin?(++i,"green"==o.sheetcolor?n='S'+i+"":"yellow"==o.sheetcolor&&(n='S'+i+""),a&&(u+=n,n="")):e.ssend&&(n=""),""!=n&&a&&(u+=n,n="")}u+=""}o.seqStartLen&&o.seqStartLen[e]&&(u+=this.insertMulGap(o.seqEndLen[e]," ")),u+='',u+="",u+="
    ",u+="
    ",f+=""}m='
    ',m+='
    ',m+='',f+=m+"
    ",u+=m+'',o.seqStartLen&&o.seqStartLen[e]&&(u+=this.insertMulGap(o.seqStartLen[e],"-"));for(let t=0,s=d.length;t':'',u+=" ";else if("E"==o.secondaries[s]){o.firstAtomObjCls.getFirstCalphaAtomObj(o.residues[s]).ssend?"green"==o.sheetcolor?u+='':"yellow"==o.sheetcolor&&(u+=''):"green"==o.sheetcolor?u+='':"yellow"==o.sheetcolor&&(u+=''),u+=" "}else"c"==o.secondaries[s]?u+=' ':"o"==o.secondaries[s]&&(u+=' ');else u+="-"}o.seqStartLen&&o.seqStartLen[e]&&(u+=this.insertMulGap(o.seqEndLen[e],"-")),u+='',u+="",u+="
    ",u+="
    ",u+="",f+="",m=a.cfg.blast_rep_id===e?'
    ':'
    ';let C="Protein",b="Protein";void 0!==s&&("nucleotide"==s?(C="Nucl.",b="Nucleotide"):"chemical"==s&&(C="Chem.",b="Chemical")),m+='",m+=''+(o.baseResi[e]+1).toString()+"",f+=m+"
    ";let y='';u+=m+y,g+=m+y;let v,_=0;o.seqStartLen&&o.seqStartLen[e]&&(u+=this.insertMulGap(o.seqStartLen[e],"-"));for(let t=0,s=d.length;t1&&(i=s[0]+".."),v=o.ParserUtilsCls.getResi(e,t),o.residues.hasOwnProperty(e+"_"+v)){let n="333333";if(a.cfg.blast_rep_id==e&&void 0!==o.fullpos2ConsTargetpos&&void 0!==o.fullpos2ConsTargetpos[t+_])n=o.fullpos2ConsTargetpos[t+_].color;else{let t=o.firstAtomObjCls.getFirstCalphaAtomObj(o.residues[e+"_"+v]),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"}u+=''+i+""}else i=i.toLowerCase(),u+=''+i+""}o.seqStartLen&&o.seqStartLen[e]&&(u+=this.insertMulGap(o.seqEndLen[e],"-")),a.cfg.blast_rep_id==e&&(o.opts.color=o.blastAcxn?"confidence":"conservation",o.setColorCls.setColorByOptions(o.opts,o.atoms));let w=o.firstAtomObjCls.getFirstCalphaAtomObj(o.chains[e]),S=w.color?w.color.getHexString():"CCCCCC",A=Math.round(o.seqAnnWidth*d.length/(o.maxAnnoLength+o.nTotalGap));if(A<1&&(A=1),o.seqStartLen&&o.seqStartLen[e]&&(g+=this.insertMulGapOverview(e,o.seqStartLen[e])),a.cfg.blast_rep_id!=e)g+='";else{let t=[],s=[];t.push(0);for(let e=0,i=d.length;e';for(let i=0,n=t.length;i'+e+"
    ";g+="
    "}if(m=''+v+"",m+="",m+="
    ",u+=m,g+=m,a.cfg.blast_rep_id==e){if(void 0!==r&&""!==r){m='",m+='',f+=m+"
    ";let t='';u+=m+t,g+=m+t;let s=0,i=0,l=1;o.queryStart;for(let t=0,n=r.length;t-";else if(" "==n)u+=" ";else{let r=o.fullpos2ConsTargetpos[t].pos;if(o.residues.hasOwnProperty(e+"_"+r)){let s=o.fullpos2ConsTargetpos[t].color;u+=''+n+""}else n=n.toLowerCase(),u+=''+n+"";g+=this.insertGapOverview(e,t);let a=Math.round(o.seqAnnWidth*t/(o.maxAnnoLength+o.nTotalGap)-s-i);a>=0&&(g+='
     
    ',g+='
     
    ',s+=a,i+=l)}}m='',m+="",m+="
    ",u+=m,g+=m}m='
    '+i+"
    ",m+=''+o.queryStart+"",f+=m+"
    ";let t='';u+=m+t,g+=m+t;let s=o.queryStart;for(let t=0,i=l.length;t-":(void 0===o.fullpos2ConsTargetpos||void 0===o.fullpos2ConsTargetpos[t]||o.residues.hasOwnProperty(e+"_"+o.fullpos2ConsTargetpos[t].pos)||(i=i.toLowerCase()),u+=''+i+"",++s)}let a=o.firstAtomObjCls.getFirstCalphaAtomObj(o.chains[e]),d=void 0===a.color||"FFFFFF"===a.color.getHexString()?"DDDDDD":a.color.getHexString(),c=void 0!==a.color?d:"CCCCCC",h=[],p=[],C="-";for(let e=0,t=l.length;e ',g+='
    '+i+"
    "}m=''+o.queryEnd+"",m+="",m+="
    ",u+=m,g+=m}if(u+="",g+="",f+="",d.length>10){let t=o.firstAtomObjCls.getFirstCalphaAtomObj(o.chains[e]);if((void 0!==a.cfg.mmdbid||void 0!==a.cfg.gi||void 0!==a.cfg.blast_rep_id||void 0!==a.cfg.align||void 0!==a.cfg.chainalign||void 0!==a.cfg.mmdbafid)&&void 0!==t.resi_ori&&t.resi_ori!=t.resi&&-1==e.indexOf("Misc")){m='
    ',m+='
    ',m+='
    PDB Residue Numbers
    ',m+='',f+=m+"
    ",u+=m+'',o.seqStartLen&&o.seqStartLen[e]&&(u+=this.insertMulGap(o.seqStartLen[e],"-"));for(let t=0,s=d.length;t",e%10==0&&(u+=e+" "),u+=""}else u+=""}o.seqStartLen&&o.seqStartLen[e]&&(u+=this.insertMulGap(o.seqEndLen[e],"-")),u+='',u+="",u+="
    ",u+="
    ",u+="
    ",f+=""}if(o.bShowCustomRefnum&&o.chainsMapping.hasOwnProperty(e)){let t=!0,s=o.annoIgCls.showRefNum(d,e,void 0,t);u+=s.html,f+=s.html3}}o.bShowRefnum&&o.hlUpdateCls.updateHlAll(),$("#"+o.pre+"dt_giseq_"+e).html(u),$("#"+o.pre+"ov_giseq_"+e).html(g),$("#"+o.pre+"tt_giseq_"+e).html(f)}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")||void 0!==$(e).attr("ig")){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 Ft{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&&($("#"+t.pre+"dl_2ddgm svg line").attr("stroke","#000000"),$("#"+t.pre+"dl_2ddgm line").attr("stroke-width",1)),e||($("#"+t.pre+"dl_linegraph circle").attr("stroke","#000000"),$("#"+t.pre+"dl_linegraph circle").attr("stroke-width",1),$("#"+t.pre+"dl_scatterplot rect").attr("stroke","#000000"),$("#"+t.pre+"dl_scatterplot circle").attr("stroke","#000000"),$("#"+t.pre+"dl_scatterplot rect").attr("stroke-width",1),$("#"+t.pre+"dl_scatterplot circle").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=[],C=[],b=[],y=[],v={},_={},w={};for(let t=0,s=p.length;t4&&!isNaN(parseInt(e.substr(-4,4)))||t.length>4&&!isNaN(parseInt(t.substr(-4,4))),c=e+"_"+t+"_"+s.c,h=n.hashUtilsCls.cloneHash(s);h.source+=S+i.chainsMapping[r][d],h.target+=S+i.chainsMapping[o][C];let m=n.hashUtilsCls.cloneHash(s);m.source+=A+i.chainsMapping[r][d],m.target+=A+i.chainsMapping[o][C],v[c]!=p.length||!a&&0!=w[c]?b[f].push(m):u[f].push(h),g[f][s.source]=i.chainsMapping[r][d],g[f][s.target]=i.chainsMapping[o][C],y[f][s.source]=i.chainsMapping[r][d],y[f][s.target]=i.chainsMapping[o][C]}else{let e=n.hashUtilsCls.cloneHash(s);e.source+=i.chainsMapping[r]&&i.chainsMapping[r][d]?A+i.chainsMapping[r][d]:A+k,e.target+=i.chainsMapping[o]&&i.chainsMapping[o][C]?A+i.chainsMapping[o][C]:A+k,b[f].push(e),g[f][s.source]=i.chainsMapping[r]&&i.chainsMapping[r][d]?i.chainsMapping[r][d]:x,g[f][s.target]=i.chainsMapping[o]&&i.chainsMapping[o][C]?i.chainsMapping[o][C]:x,y[f][s.source]=i.chainsMapping[r]&&i.chainsMapping[r][d]?i.chainsMapping[r][d]:k,y[f][s.target]=i.chainsMapping[o]&&i.chainsMapping[o][C]?i.chainsMapping[o][C]:k}}}let O=[],R=[],I=0,E=[],T=1;for(let e=0,t=p.length;e0&&(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,C[e]=t.nodeArray2,d=n.hashUtilsCls.unionHash(d,t.name2node)),O[e]=l[e].length,R[e]=o[e].length,I=Math.max(I,R[e]),E.push(p[e])}let P,D,M,F,H,L=1,N=3*L,q=7*L,U=10,B=10,$=30,j=20;t?(M=(n.utilsCls.sumArray(O)+2*E.length)*(N+q)+4*B+2*$+j*E.length,D=(I+2)*(N+q)+2*U+$):(P=110+j,M=P*E.length,D=(I+2)*(N+q)+2*U,D+=20),Object.keys(i.chainsMapping).length>0&&(M*=3),t?(i.scatterplotWidth=2*D,H=i.scatterplotWidth,F=n.scatterplotid):(i.linegraphWidth=2*D,H=i.linegraphWidth,F=n.linegraphid),s=0==E.length?"No interactions found for each structure

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

    ",s+="";let z,G=0;T=0,z=this.drawGraphPerType(T,p,t,l,o,a,d,G,P,j,O,N,q,B),G=z.heightFinal,s+=z.html,Object.keys(i.chainsMapping).length>0&&(T=1,z=this.drawGraphPerType(T,p,t,h,m,u,d,G,P,j,O,N,q,B),G=z.heightFinal,s+=z.html,T=2,z=this.drawGraphPerType(T,p,t,f,C,b,d,G,P,j,O,N,q,B),G=z.heightFinal,s+=z.html),s+=""}else if(t){let e,t,l,c,h=p[0],m=o.length,u=a.length,g=1,f=3*g,C=7*g,b=30;t=(m+2)*(f+C)+2*10+b,e=(u+2)*(f+C)+2*10+b,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,C="",b=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:C}}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="",C={},b={};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),C="",b={},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",b=e.id;return c.resid2refnum[p]&&(b+="=>"+c.resid2refnum[p]),C+=""+b+"",o?(C+="",C+=""+g+""):(C+="",C+=""+g+""),C+="",C}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(){this.icn3d.icn3dui}handleForce(){let e=this.icn3d;0==e.icn3dui.htmlCls.force&&void 0!==e.simulation?(e.simulation.stop(),e.simulation.force("charge",null),e.simulation.force("x",null),e.simulation.force("y",null),e.simulation.force("r",null),e.simulation.force("link",null)):e.drawGraphCls.drawGraph(e.graphStr,e.pre+"dl_graph")}getNodesLinksForSet(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=[],o=[],a=0,d=l.htmlCls.coilValue,c="",h="",p=0,m={};for(let u in e){let e=n.atoms[u];if("DUM"!=e.chain&&(i||e.het||"CA"==e.name&&"C"==e.elem||"O3'"==e.name||"O3*"==e.name||"P"==e.name)){let i=e.structure+"_"+e.chain+"_"+e.resi;if(m.hasOwnProperty(i))continue;m[i]=1;let u=l.utilsCls.residueName2Abbr(e.resn)+e.resi;"chain"!=t&&"structure"!=t||(u+="."+e.chain),"structure"==t&&(u+="."+e.structure);let g="1_1_"+i,f=e.color?e.color.getHexString().toUpperCase():"000";r.push('{"id": "'+u+'", "r": "'+g+'", "s": "'+s+'", "x": '+e.coord.x.toFixed(0)+', "y": '+e.coord.y.toFixed(0)+', "c": "'+f+'"}'),a>0&&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}} //!!!ic.bShowHighlight = false; -}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=C?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(C){let e=!0,t=p.showInterCls.pickCustomSphere_base(n,b,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 b){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,u="interactions "+n+" | sets "+e+" "+t+" | true";p.opts.contact="yes";for(let e=0;e
    ",T=p.resid2specCls.atoms2residues(Object.keys(b)),D=p.resid2specCls.atoms2residues(Object.keys(y)),P="select "+p.resid2specCls.residueids2spec(T),M="select "+p.resid2specCls.residueids2spec(D);E+="Set 1: "+e+'
    ',E+="Set 2: "+t+'

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

    ',E+='
    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=E;if(("graph"==i||"linegraph"==i||"scatterplot"==i||C)&&(E=""),E+=O,"save1"==i||"save2"==i){E=q;let e="";"save1"==i?e="Set 1":"save2"==i&&(e="Set 2"),E+='

    Interactions Sorted on '+e+':
    ';let t=this.getAllInteractionTable(i);E+=t.html,h=t.bondCnt,$("#"+p.pre+"dl_interactionsorted_html").html(E),m.htmlCls.dialogCls.openDlg("dl_interactionsorted","Show sorted interactions")}else if("view"==i)$("#"+p.pre+"dl_allinteraction_html").html(E),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(b,y,e,t,E,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(b,y,e,t,E,u),p.bScatterplot=!0;let s=p.lineGraphCls.drawLineGraph(p.graphStr,!0);$("#"+p.pre+"scatterplotDiv").html(s)}else if(C){m.htmlCls.dialogCls.openDlg("dl_contactmap","Show contact map");let s=!0,i=p.getGraphCls.getGraphData(b,y,e,t,E,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(b,y,e,t,E,u),p.bGraph=!0,Object.keys(y).length+Object.keys(b).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,C=0,b=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:C,cntContact:b,cntHalegen:y,cntPication:v,cntPistacking:_}),o+=this.getInteractionPerResidue(d,c,h,p,m,u,g,f,C,b,y,v,_),c="",h="",p="",m="",u="",g="",f=0,C=0,b=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,C+=k.cnt,k.cnt>0&&(w+=r+":ionic_"+k.cnt+" "),x=t.resids2inter[S].contact,k=this.getContactPairDetails(x,e,"contact"),p+=k.html,b+=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:C,cntContact:b,cntHalegen:y,cntPication:v,cntPistacking:_}),o+=this.getInteractionPerResidue(d,c,h,p,m,u,g,f,C,b,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]),C=f.color?f.color.getHexString():"",b=Math.sqrt(e[a]).toFixed(1);n+=' '+c+r+u+o+' '+h+r+C+o+''+b+"",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():"",C=e[o].split("_"),b=C[0],y=C[1],v=C[2],_=C[3],w=C[4];i+=' '+d+"@"+v+l+m+r+' '+c+"@"+_+l+f+r+''+w+''+b+''+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],C=g[1];c=g[2],m=g[3];let b=g[4];e?(l+=' '+s+"@"+c+a+h+d+' '+n+"@"+m+a+u+d+''+b+''+f+''+C+"","view"==t&&(l+=''),l+=""):l+=""+s+""+n+''+b+''+f+''+C+"",++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 Bt{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 C=[],b={},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 jt{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&&(d+="TM-score: "+n+"

    ",r.tmscore=n),$("#"+r.pre+"dl_rmsd_html").html(d),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,i){let n=this.icn3d,l=n.icn3dui;n.structArray=n.structures?Object.keys(n.structures):[],0==n.structArray.length?n.init():(n.bResetAnno=!0,n.bResetSets=!0);let r=e.split(","),o=[];for(let e=0,t=r.length;e5)t="https://alphafold.ebi.ac.uk/files/AF-"+i+"-F1-model_"+n.AFUniprotVersion+".pdb",s=l.getAjaxPromise(t,"text");else{let e=i;5==i.length&&(e=i.substr(0,4)),t=l.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+l.cfg.bu+"&uid="+e,void 0!==l.cfg.inpara&&(t+=l.cfg.inpara),s=l.getAjaxPromise(t,"jsonp")}a.push(s)}n.ParserUtilsCls.setYourNote(n.structArray+" in iCn3D"),n.ParserUtilsCls.showLoading();let d=Promise.allSettled(a),c=await d;await this.parseMMdbAfData(c,o,t,s),void 0===s&&n.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=!1;for(let e=0,i=t.length;e5){let s=!1;await n.pdbParserCls.loadPdbData(r[e],t[e],!1,l,i,o,s)}else{let s=!0,l=t[e];await n.mmdbParserCls.parseMmdbData(r[e],i,void 0,void 0,o,s,l)}}let a=Object.keys(n.structures);if(n.opts.color=a.length>1?"structure":a[0].length>5?"confidence":"chain",n.setColorCls.setColorByOptions(n.opts,{}),await n.ParserUtilsCls.renderStructure(),n.bAnnoShown&&(await n.showAnnoCls.showAnnotations(),n.annotationCls.resetAnnoTabAll()),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);2==i&&(l.cfg.aligntool="tmalign"),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,r,o=this.icn3d,a=o.icn3dui,d={},c=e.buffer&&e.buffer instanceof ArrayBuffer?e.buffer:e,h=new Int16Array(c),p=new Uint8Array(c),m=String.fromCharCode.apply(null,p.subarray(0,512));if(0==m.indexOf(":-)"))d.xStart=parseInt(m.substr(10,5)),d.yStart=parseInt(m.substr(15,5)),d.zStart=parseInt(m.substr(20,5)),d.xExtent=parseInt(m.substr(32,5)),d.yExtent=parseInt(m.substr(38,5)),d.zExtent=parseInt(m.substr(42,5)),d.xRate=parseInt(m.substr(52,5)),d.yRate=parseInt(m.substr(58,5)),d.zRate=parseInt(m.substr(62,5)),d.xlen=1*parseFloat(m.substr(73,10)),d.ylen=1*parseFloat(m.substr(83,10)),d.zlen=1*parseFloat(m.substr(93,10)),d.alpha=parseFloat(m.substr(103,10)),d.beta=parseFloat(m.substr(113,10)),d.gamma=parseFloat(m.substr(123,10)),l=parseFloat(m.substr(138,12))/100,r=parseInt(m.substr(155,8)),d.sigma=100*parseFloat(m.substr(170,12));else{if(100!==h[18])for(let e=0,t=h.length;e>8&255}d.xStart=h[0],d.yStart=h[1],d.zStart=h[2],d.xExtent=h[3],d.yExtent=h[4],d.zExtent=h[5],d.xRate=h[6],d.yRate=h[7],d.zRate=h[8];let e=1/h[17],t=1*e;d.xlen=h[9]*t,d.ylen=h[10]*t,d.zlen=h[11]*t,d.alpha=h[12]*e,d.beta=h[13]*e,d.gamma=h[14]*e,l=h[15]/h[18],r=h[16]}a.bNode||console.log("header: "+JSON.stringify(d));let u=new Float32Array(d.xExtent*d.yExtent*d.zExtent),g=512,f=Math.ceil(d.xExtent/8),C=Math.ceil(d.yExtent/8),b=Math.ceil(d.zExtent/8),y=-999;for(let e=0;ey&&(y=u[e]),++g}}}}return n||(s=this.setSigma(y,i,t,s)),"2fofc"==t?(o.mapData.header2=d,o.mapData.data2=u,o.mapData.matrix2=this.getMatrix(d),o.mapData.type2=t,o.mapData.sigma2=s):(o.mapData.header=d,o.mapData.data=u,o.mapData.matrix=this.getMatrix(d),o.mapData.type=t,o.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);return n&&($("#"+l.pre+n).val()?i=$("#"+l.pre+n).val():(i=(.2*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]],C=f.indexOf(1),b=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,l){let r=this.icn3d;r.icn3dui;let o="fofc"==t,a=e.calculate_map(o),d=e.cell;const c=new Wt(d.a,d.b,d.c,d.alpha,d.beta,d.gamma);let h=-999;for(let e=0,t=a.length;eh&&(h=a[e]);if(n||(s=r.dsn6ParserCls.setSigma(h,i,t,s)),l){r.mapData.ccp4=0;let i={xExtent:e.nx,yExtent:e.ny,zExtent:e.nz,mean:void 0,sigma:s,ccp4:1,xStart:0,yStart:0,zStart:0};i.xRate=e.nx,i.yRate=e.ny,i.zRate=e.nz,i.xlen=d.a,i.ylen=d.b,i.zlen=d.c,i.alpha=d.alpha,i.beta=d.beta,i.gamma=d.gamma,"2fofc"==t?(r.mapData.header2=i,r.mapData.data2=a,r.mapData.matrix2=r.dsn6ParserCls.getMatrix(i),r.mapData.type2=t,r.mapData.sigma2=s):(r.mapData.header=i,r.mapData.data=a,r.mapData.matrix=r.dsn6ParserCls.getMatrix(i),r.mapData.type=t,r.mapData.sigma=s)}else{const i=new Yt([e.nx,e.ny,e.nz]);i.values.set(a),"2fofc"==t?(r.mapData.ccp4=1,r.mapData.grid2=i,r.mapData.unit_cell2=c,r.mapData.type2=t,r.mapData.sigma2=s):(r.mapData.ccp4=1,r.mapData.grid=i,r.mapData.unit_cell=c,r.mapData.type=t,r.mapData.sigma=s)}return 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 C=[],b=[],y=0;for(let e=0;e.85?t=1:t<.15&&(t=0));const s=m[e[0]],n=m[e[1]];C.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,l){let r=this.icn3d,o=r.icn3dui,a=await o.getXMLHttpRqstPromise(e,"GET","arraybuffer","");return s=await this.loadMtzFileBase(a,t,s,i,n,e,l),r.setOptionCls.setOption("map",t),s}loadMtzFile(e,t){var s=this.icn3d,i=s.icn3dui;let n=this,l=$("#"+s.pre+"dsn6file"+e)[0].files[0],r=$("#"+s.pre+"dsn6sigma"+e).val();if(l){i.utilsCls.checkFileAPI();let s=new FileReader;s.onload=async function(s){let l=n.icn3d;r=await n.loadMtzFileBase(s.target.result,e,r,"file",void 0,void 0,t),i.htmlCls.clickMenuCls.setLogCmd("load map file "+$("#"+l.pre+"dsn6file"+e).val()+" with sigma "+r,!1)},s.readAsArrayBuffer(l)}else alert("Please select a file before clicking 'Load'")}async loadMtzFileBase(e,t,s,i,n,l,r){var o=this.icn3d,a=o.icn3dui;if(void 0===o.bMtz){let e="./script/mtz.js";await a.getAjaxPromise(e,"script"),o.bMtz=!0}GemmiMtz().then((function(d){let c=d.readMtz(e);s=o.ccp4ParserCls.load_maps_from_mtz_buffer(c,t,s,i,n,r),o.setOptionCls.setOption("map",t);let h=r?"rcsbmtz":"mtz";return l&&a.htmlCls.clickMenuCls.setLogCmd("set map "+t+" sigma "+s+" file "+h+" | "+encodeURIComponent(l),!0),s}))}async loadMtzFileUrl(e,t){var s=this.icn3d;s.icn3dui;let i=$("#"+s.pre+"dsn6fileurl"+e).val(),n=$("#"+s.pre+"dsn6sigmaurl"+e).val();i?n=await this.mtzParserBase(i,e,n,"url",void 0,t):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/download/"+e+".cif",n=await s.getAjaxPromise(i,"text",!0);await t.opmParserCls.loadOpmData(n,e,void 0,"mmcif",void 0,!0)}async downloadMmcifSymmetry(e,t){let s=this.icn3d,i=s.icn3dui;try{let n="https://models.rcsb.org/"+e+".bcif",l=await i.getXMLHttpRqstPromise(n,"GET","arraybuffer","bcif"),r=!1,o=!0,a=s.bcifParserCls.getBcifJson(l,e,r,o),d=JSON.parse(a);if(void 0!==d.emd&&(s.emd=d.emd),void 0!==d.organism&&(s.organism=d.organism),s.bAssemblyUseAsu){for(let e=0,t=d.assembly.length;es.maxatomcnt&&(s.bAssembly=!0)}if("mmtfid"===t&&void 0!==d.missingseq){let t=0,n="";for(let l=0,r=d.missingseq.length;lt)&&(s.chainMissingResidueArray[c].push(h),t=a,n=o)}s.loadPDBCls.adjustSeq(s.chainMissingResidueArray)}}catch(e){return void(i.bNode||console.log("mmcifparser.cgi issues: "+e))}}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),await s.opmParserCls.loadOpmData(e,t,void 0,"mmcif"),s.opmParserCls.modifyUIMapAssembly()}async loadMultipleMmcifData(e,t,s){let i=this.icn3d;i.icn3dui;i.loadCIFCls.loadCIF(e,t,!0,s),Object.keys(i.structures).length>1&&(i.opts.color="structure"),i.opmParserCls.modifyUIMapAssembly(),i.pdbParserCls.addSecondary(s)}}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.bcifParserCls.downloadBcif(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,(void 0===t||i.cfg.mmdbafid)&&(s.chainsColor[p]=i.parasCls.thr(c));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 Zt{constructor(e){this.icn3d=e,this.mElem2Radius={},this.mElem2Radius.H=.31,this.mElem2Radius.HE=.28,this.mElem2Radius.LI=1.28,this.mElem2Radius.BE=.96,this.mElem2Radius.B=.84,this.mElem2Radius.C=.76,this.mElem2Radius.N=.71,this.mElem2Radius.O=.66,this.mElem2Radius.F=.57,this.mElem2Radius.NE=.58,this.mElem2Radius.NA=1.66,this.mElem2Radius.MG=1.41,this.mElem2Radius.AL=1.21,this.mElem2Radius.SI=1.11,this.mElem2Radius.P=1.07,this.mElem2Radius.S=1.05,this.mElem2Radius.CL=1.02,this.mElem2Radius.AR=1.06,this.mElem2Radius.K=2.03,this.mElem2Radius.CA=1.76,this.mElem2Radius.SC=1.7,this.mElem2Radius.TI=1.6,this.mElem2Radius.V=1.53,this.mElem2Radius.CR=1.39,this.mElem2Radius.MN=1.39,this.mElem2Radius.FE=1.32,this.mElem2Radius.CO=1.26,this.mElem2Radius.NI=1.24,this.mElem2Radius.CU=1.32,this.mElem2Radius.ZN=1.22,this.mElem2Radius.GA=1.22,this.mElem2Radius.GE=1.2,this.mElem2Radius.AS=1.19,this.mElem2Radius.SE=1.2,this.mElem2Radius.BR=1.2,this.mElem2Radius.KR=1.16,this.mElem2Radius.RB=2.2,this.mElem2Radius.SR=1.95,this.mElem2Radius.Y=1.9,this.mElem2Radius.ZR=1.75,this.mElem2Radius.NB=1.64,this.mElem2Radius.MO=1.54,this.mElem2Radius.TC=1.47,this.mElem2Radius.RU=1.46,this.mElem2Radius.RH=1.42,this.mElem2Radius.PD=1.39,this.mElem2Radius.AG=1.45,this.mElem2Radius.CD=1.44,this.mElem2Radius.IN=1.42,this.mElem2Radius.SN=1.39,this.mElem2Radius.SB=1.39,this.mElem2Radius.TE=1.38,this.mElem2Radius.I=1.39,this.mElem2Radius.XE=1.4,this.mElem2Radius.CS=2.44,this.mElem2Radius.BA=2.15,this.mElem2Radius.LA=2.07,this.mElem2Radius.CE=2.04,this.mElem2Radius.PR=2.03,this.mElem2Radius.ND=2.01,this.mElem2Radius.PM=1.99,this.mElem2Radius.SM=1.98,this.mElem2Radius.EU=1.98,this.mElem2Radius.GD=1.96,this.mElem2Radius.TB=1.94,this.mElem2Radius.DY=1.92,this.mElem2Radius.HO=1.92,this.mElem2Radius.ER=1.89,this.mElem2Radius.TM=1.9,this.mElem2Radius.YB=1.87,this.mElem2Radius.LU=1.87,this.mElem2Radius.HF=1.75,this.mElem2Radius.TA=1.7,this.mElem2Radius.W=1.62,this.mElem2Radius.RE=1.51,this.mElem2Radius.OS=1.44,this.mElem2Radius.IR=1.41,this.mElem2Radius.PT=1.36,this.mElem2Radius.AU=1.36,this.mElem2Radius.HG=1.32,this.mElem2Radius.TL=1.45,this.mElem2Radius.PB=1.46,this.mElem2Radius.BI=1.48,this.mElem2Radius.PO=1.4,this.mElem2Radius.AT=1.5,this.mElem2Radius.RN=1.5,this.mElem2Radius.FR=2.6,this.mElem2Radius.RA=2.21,this.mElem2Radius.AC=2.15,this.mElem2Radius.TH=2.06,this.mElem2Radius.PA=2,this.mElem2Radius.U=1.96,this.mElem2Radius.NP=1.9,this.mElem2Radius.PU=1.87,this.mElem2Radius.AM=1.8,this.mElem2Radius.CM=1.69}async downloadBcif(e){let t=this.icn3d,s=t.icn3dui;t.ParserUtilsCls.setYourNote(e.toUpperCase()+"(BCIF) in iCn3D");let i="https://models.rcsb.org/"+e+".bcif",n=await s.getXMLHttpRqstPromise(i,"GET","arraybuffer","bcif");if(0==n.length)return void alert("This PDB structure is not found at RCSB...");await t.opmParserCls.loadOpmData(n,e,void 0,"bcif",void 0,!1)}getBcifJson(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r="",o="",a="",d="",c="",h="",p=s?CIFTools.Text.parse(e):CIFTools.Binary.parse(e);if(p.isError)return void alert("The Binary CIF data can NOT be parsed: "+p.toString());let m=p.result.dataBlocks[0];t||(m.getCategory("_entry")&&(t=m.getCategory("_entry").getColumn("id").getString(0)),""==t&&(t="stru")),m.getCategory("_citation")&&(o=m.getCategory("_citation").getColumn("pdbx_database_id_PubMed").getString(0)),m.getCategory("_struct")&&(a=m.getCategory("_struct").getColumn("title").getString(0),a=a.replace(/"/,"'")),m.getCategory("_struct_keywords")&&(d=m.getCategory("_struct_keywords").getColumn("pdbx_keywords").getString(0)),m.getCategory("_entity_src_gen")&&(h=m.getCategory("_entity_src_gen").getColumn("gene_src_common_name").getString(0));let u={},g={},f={};if(m.getCategory("_database_2")){let e=m.getCategory("_database_2"),t=e.rowCount;for(let s=0;sn.maxatomcnt),j=[];if(!i){_=P.getColumn("group_PDB"),w=P.getColumn("label_comp_id"),S=P.getColumn("type_symbol"),A=P.getColumn("label_atom_id"),x=P.getColumn("auth_asym_id"),k=P.getColumn("label_seq_id"),O=P.getColumn("auth_seq_id"),R=P.getColumn("label_alt_id"),I=P.getColumn("B_iso_or_equiv"),E=P.getColumn("Cartn_x"),T=P.getColumn("Cartn_y"),D=P.getColumn("Cartn_z"),j=P.getColumn("label_asym_id");let e={},t="";for(let s=0;s0&&(r=r.substr(0,r.length-2)),r+="], ",f.hasOwnProperty(M)){r+='"ss":"'+f[M]+'", '}else r+='"ss":"coil", ';u.hasOwnProperty(M)?r+='"ssbegin":1, ':r+='"ssbegin":0, ',g.hasOwnProperty(M)?r+='"ssend":1, ':r+='"ssend":0, ',r+='"mt":"'+s+'"',r+="}",r+=",\n",q=a+"_"+n,prevAutochain=p,++B}B>1&&(r=r.substr(0,r.length-2)),r+="]"}_=w=S=A=x=k=O=R=I=E=T=D=j=[];let z={};if(m.getCategory("_pdbx_poly_seq_scheme")){let e=m.getCategory("_pdbx_poly_seq_scheme"),t=e.getColumn("seq_id"),s=e.getColumn("pdb_seq_num"),i=e.getColumn("mon_id"),n=e.getColumn("pdb_strand_id"),l=e.rowCount,r="",o="";for(let e=0;e0){r+=', "disulfides":[';for(let e=0;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&&($("#"+e.pre+"assemblyWrapper").show(),e.asuCnt=e.biomtMatrices.length))}async parseAtomData(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;"mmcif"===i||"bcif"===i?(r.loadCIFCls.loadCIF(e,t,l),this.modifyUIMapAssembly(),r.setStyleCls.setAtomStyleByOptions(r.opts),r.setColorCls.setColorByOptions(r.opts,r.atoms),await r.ParserUtilsCls.renderStructure(),void 0!==o.cfg.rotate&&r.resizeCanvasCls.rotStruc(o.cfg.rotate,!0)):"pdb"===i?await r.pdbParserCls.loadPdbData(e,t):"align"===i&&(r.bOpm?await r.alignParserCls.downloadAlignmentPart2(t):void 0!==n?await this.loadOpmData(e,n,s,i):await r.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/download/"+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,i){let n=this.icn3d,l=n.icn3dui,r=e.lastIndexOf("/");if(-1!=r){let t=e.lastIndexOf(".");n.filename=e.substr(r+1,t-r-1)}else{let t=e.lastIndexOf(".");n.filename=e.substr(0,t)}let o=await l.getAjaxPromise(e,"text",!0);if(n.InputfileData=n.InputfileData?n.InputfileData+"\nENDMDL\n"+o:o,n.InputfileType=t,n.hAtoms={},n.dAtoms={},n.resetConfig(),n.bResetAnno=!0,n.bResetSets=!0,"pdb"===t){let e=!0,t=i?i.replace(/_/g,"").substr(0,4):void 0;await this.loadPdbData(o,t,void 0,e)}else if("mmcif"===t){let e=!0;await n.opmParserCls.loadOpmData(o,void 0,void 0,"mmcif",void 0,e)}else if("mol2"===t)await n.mol2ParserCls.loadMol2Data(o);else if("sdf"===t)await n.sdfParserCls.loadSdfData(o);else if("xyz"===t)await n.xyzParserCls.loadXyzData(o);else if("mmcif"===t)await n.mmcifParserCls.loadMmcifData(o);else if("icn3dpng"===t)await l.htmlCls.setHtmlCls.loadPng(o,s);else if("pae"===t){l.htmlCls.dialogCls.openDlg("dl_alignerrormap","Show Predicted Aligned Error (PAE) map");let e=!0;n.contactMapCls.processAfErrorMap(JSON.parse(o),e)}n.bSetChainsAdvancedMenu&&n.definedSetsCls.showSets(),n.bResetAnno=!0,n.bAnnoShown&&(await n.showAnnoCls.showAnnotations(),n.annotationCls.resetAnnoTabAll())}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);return 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())),await this.addSecondary(i,r),c}async addSecondary(e,t){let s=this.icn3d,i=s.icn3dui,n=!1;s.bSecondaryStructure&&1==Object.keys(s.structures).length?n=!1:i.cfg.mmtfid||i.cfg.pdbid||i.cfg.opmid||i.cfg.mmdbid||i.cfg.gi||i.cfg.uniprotid||i.cfg.blast_rep_id||i.cfg.cid||i.cfg.mmcifid||i.cfg.align||i.cfg.chainalign||(n=!0),(!s.bSecondaryStructure||n)&&Object.keys(s.proteins).length>0&&!t?await this.applyCommandDssp(e):(await this.loadPdbDataRender(e),i.bNode||await s.ParserUtilsCls.checkMemProteinAndRotate())}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 parent 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+Object.keys(e.defNames2Residues).length+1);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){console.log("RMSD from VAST is larger than 5. Realign the chains with TM-align.");let e=Object.keys(d);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&&b.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 b(s,t):new C(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}(),C=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}(),b=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(s.bNode)return;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 C,b,y,v,_,w={},S="",A="",x="",k="",O="",R="",I=0,E=0,T="",D=!0,P=!1,M="",F=c.utilsCls.isCalphaPhosOnly(h),H=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(C=n.ids.m,void 0!==d.molid2chain[C]){let e=d.molid2chain[C].indexOf("_");n.chain=d.molid2chain[C].substr(e+1)}else{let e="Misc";("protein"===g[O]&&"nucleotide"===g[O]&&n.resi!=E||"protein"!==g[O]&&"nucleotide"!==g[O]&&(n.resn.substr(0,3)!=T.substr(0,3)||n.resi!=E||"solvent"===g[O]||"HOH"===n.resn))&&++H,n.resi_ori=n.resi,n.resi=H,l=!0,n.chain=e}else if("align"===s)if(C=n.ids.m,void 0!==d.pdbid_molid2chain[i+"_"+C])n.chain=d.pdbid_molid2chain[i+"_"+C];else{let e="Misc";("protein"===g[O]&&"nucleotide"===g[O]&&n.resi!=E||"protein"!==g[O]&&"nucleotide"!==g[O]&&(n.resn.substr(0,3)!=T.substr(0,3)||n.resi!=E||"solvent"===g[O]||"HOH"===n.resn))&&(++H,n.resi_ori=n.resi,n.resi=H,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=b,_=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="protein"===g[O],a="nucleotide"===g[O],u="solvent"===g[O],N="ligand"===g[O]||void 0!==g[O]&&-1!==g[O].indexOf("other")||void 0===g[O];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||F&&"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||(b=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&&(D=!0,""!==S&&(void 0===d.structures[S]&&(d.structures[S]=[]),d.structures[S].push(A))),d.residueId2Name[U]=r;let B="-";if("helix"===n.ss?B="H":"sheet"===n.ss?B="E":n.het||a?B="o":(!n.het&&c.parasCls.residueColors.hasOwnProperty(n.resn.toUpperCase())||"coil"===n.ss)&&(B="c"),d.secondaries[n.structure+"_"+n.chain+"_"+n.resi]=B,(n.resi!=I||C!=M)&&d.bFullUi&&(void 0===d.chainsSeq[q]&&(d.chainsSeq[q]=[],D=!1),!isNaN(n.resi)&&null!==n.resi))if(D&&!P&&void 0!==d.chainsSeq[q][n.resi-1])d.chainsSeq[q][n.resi-1].name=r;else if(!D||!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),P=!0}I=n.resi,E=n.resi_ori,T=n.resn,S=k,A=O,x=R,M=C}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||F&&"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 C=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],b=r.sequence[e][3]?1:0,y=c[e].aligned+b;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=".";C%5==0&&(x="*"),C%10==0&&(x="|"),s.alnChainsAnno[d][2].push(x);let k="";C%10==0&&(k=C.toString()),s.alnChainsAnno[d][3].push(k),++C}}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;return t&&"tmalign"==l.cfg.aligntool?i=s:(s>n.chainsSeq[e].length-1&&(console.log("Error: the position "+s+" exceeds the max index "+(n.chainsSeq[e].length-1)),s=n.chainsSeq[e].length-1),i=n.chainsSeq[e][s].resi),i}setSeqAlignChain(e,t,s){let i,n,l,r,o,a,d,c,h,p,m,u=this.icn3d,g=u.icn3dui,f={},C=!!s;if(C){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 b=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=b+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.split("_")[2])-parseInt(t.split("_")[2])}));let m=-999,u=0,g=0,f=[],C=0;for(let e=0,t=p.length;e0&&i.resid2ncbi[s]!=i.resid2ncbi[m]+1&&i.resid2ncbi[s]!=i.resid2ncbi[m]){g=m;for(let e=0,t=f.length;ec)continue;let p={},m=r.indexOf("_");p.mmdbid=r.substr(0,m),p.chain=r.substr(m+1),p.resi=t,p.resn=a[s]?i.chainsSeq[r][e].name.toUpperCase():i.chainsSeq[r][e].name.toLowerCase(),p.aligned=!!a[s],p.color=a[s]?"#FF0000":n.htmlCls.GREYC,p.color2=a[s]?"#FF0000":n.htmlCls.GREYC,p.class=a[s]?"icn3d-align":"icn3d-nalign",i.alnChainsSeq[r].push(p),a[s]&&($.extend(i.alnChains[r],i.residues[r+"_"+p.resi]),l=n.hashUtilsCls.unionHash(l,i.residues[r+"_"+p.resi]))}let b=[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 C,b,y,v,_,w,S,A,x,k=[],O=[],R=[],I=[],E=[],T=[],D="",P="",M="",F={},H=t||c.defaultPdbId,L=H,N="",q=!1,U=!0;for(let e in u){let r=u[e],B=r.substr(0,6);if("HEADER"!==B||q||t)if("TITLE "===B){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[L]=c.molTitle}else if("HELIX "===B){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=L+"_"+e+"_"+i;I.push(n),i===t&&E.push(n),i===s&&T.push(n)}}else if("SHEET "===B){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=L+"_"+e+"_"+s;k.push(n),s===t&&O.push(n),s===i&&R.push(n)}}else if("HBOND "===B)void 0!==s&&s||(c.bSecondaryStructure=!0);else if("SSBOND"===B){c.bSsbondProvided=!0;let e=L+"_"+(" "==r.substr(15,1)?"A":r.substr(15,1))+"_"+r.substr(17,4).trim(),t=L+"_"+(" "==r.substr(29,1)?"A":r.substr(29,1))+"_"+r.substr(31,4).trim();void 0===c.ssbondpnts[L]&&(c.ssbondpnts[L]=[]),c.ssbondpnts[L].push(e),c.ssbondpnts[L].push(t)}else if("REMARK"===B){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=H+"_"+t;void 0===c.chainMissingResidueArray[i]&&(c.chainMissingResidueArray[i]=[]);let n={};n.resi=s,n.name=h.utilsCls.residueName2Abbr(e).toLowerCase(),""!=N&&t==N&&t!=N||(c.chainMissingResidueArray[i].push(n),N=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"===B&&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"===B)++d,H=c.defaultPdbId,L=this.getStructureId(H,d,n),m||(k=[],O=[],R=[],I=[],E=[],T=[]),q=!1;else if("JRNL "===B)"PMID"===r.substr(12,4)&&(c.pmid=r.substr(19).trim());else if("ATOM "===B||"HETATM"===B){A=r.substr(72,4).trim(),U?(L=this.getStructureId(H,d,n),U=!1):A!=x&&(++d,H=c.defaultPdbId,L=this.getStructureId(H,d,n),m||(k=[],O=[],R=[],I=[],E=[],T=[]),q=!1),x=A;let e=r.substr(16,1);++a,F[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),N=r.substr(20,2).trim();""===N&&(N="A");let $=r.substr(22,5).trim(),j=$;if(s&&"DUM"===u&&(t=l,N="MEM",j=1,$=1),i&&"DUM"===u)break;C=L+"_"+N,y=C+"_"+$,b=C+"_"+j;let z=parseFloat(r.substr(30,8)),G=parseFloat(r.substr(38,8)),V=parseFloat(r.substr(46,8)),W=new THREE.Vector3(z,G,V),Y=parseFloat(r.substr(60,8));o&&(Y*=100);let X={het:"H"===B[0],serial:a,name:l,alt:e,resn:u,structure:L,chain:N,resi:j,coord:W,b:Y,elem:t,bonds:[],ss:"coil",ssbegin:!1,ssend:!1};if(X.het||"C"!==X.name||(v=a),X.het||"O"!==X.name||(w=a),!X.het&&"N"===X.name&&void 0!==_&&void 0!==S){let e=c.atoms[_].coord.distanceTo(c.atoms[S].coord),t=X.coord.x+(c.atoms[_].coord.x-c.atoms[S].coord.x)/e,s=X.coord.y+(c.atoms[_].coord.y-c.atoms[S].coord.y)/e,i=X.coord.z+(c.atoms[_].coord.z-c.atoms[S].coord.z)/e;X.hcoord=new THREE.Vector3(t,s,i)}c.atoms[a]=X,c.dAtoms[a]=1,c.hAtoms[a]=1,p[a]=1,this.isSecondary(b,k,m)?(c.atoms[a].ss="sheet",this.isSecondary(b,O,m)&&(c.atoms[a].ssbegin=!0),this.isSecondary(b,R,m)&&(c.atoms[a].ssend=!0)):this.isSecondary(b,I,m)&&(c.atoms[a].ss="helix",this.isSecondary(b,E,m)&&(c.atoms[a].ssbegin=!0),this.isSecondary(b,T,m)&&(c.atoms[a].ssend=!0));let K="-";if(K="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[b]=K,y!==M){let e=h.utilsCls.residueName2Abbr(u);if(c.residueId2Name[b]=e,1!==a&&""!==P&&(c.residues[P]=f),b!==P&&(f={}),C!==D){_=void 0,S=void 0,1!==a&&""!==D&&(void 0===c.chains[D]&&(c.chains[D]={}),c.chains[D]=h.hashUtilsCls.unionHash(c.chains[D],g)),g={},void 0===c.structures[L.toString()]&&(c.structures[L.toString()]=[]),c.structures[L.toString()].includes(C)||c.structures[L.toString()].push(C),void 0===c.chainsSeq[C]&&(c.chainsSeq[C]=[]);let t={};t.resi=j,t.name=e,c.chainsSeq[C].push(t)}else{_=v,S=w;let t={};t.resi=j,t.name=e,c.chainsSeq[C].push(t)}}g[a]=1,f[a]=1,D=C,P=b,M=y}else if("CONECT"===B){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[F[e]]&&c.atoms[F[e]].bonds.push(F[s])}}else B.substr(0,3);else H=r.substr(62).trim(),""==H&&(H=l?c.defaultPdbId:c.inputid&&-1==c.inputid.indexOf("/")?c.inputid.substr(0,10):c.defaultPdbId),L=this.getStructureId(H,d,n),c.molTitle="",c.molTitleHash={},q=!0}c.residues[b]=f,void 0===c.chains[C]&&(c.chains[C]={}),c.chains[C]=h.hashUtilsCls.unionHash2Atoms(c.chains[C],g,c.atoms),this.adjustSeq(c.chainMissingResidueArray);let B=Object.keys(c.structures);for(let e=0,t=B.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,i){if(this.icn3d.icn3dui,i)return!1;if(s){let s=e.substr(e.indexOf("_")+1),i=!1;for(let e=0,n=t.length;er.maxatomcnt);T||(r.opts.proteins="c alpha trace",r.opts.nucleotides="o3 trace");let D,P=I.getColumn("group_PDB"),M=I.getColumn("label_comp_id"),F=I.getColumn("type_symbol"),H=I.getColumn("label_atom_id"),L=I.getColumn("auth_asym_id"),N=I.getColumn("label_seq_id"),q=I.getColumn("auth_seq_id"),U=I.getColumn("label_alt_id"),B=I.getColumn("B_iso_or_equiv"),$=I.getColumn("Cartn_x"),j=I.getColumn("Cartn_y"),z=I.getColumn("Cartn_z"),G=I.getColumn("label_asym_id"),V={},W="",Y={};for(let e=0;e0&&(X[r]=a,a=[]),a.push({resi:l,name:o.utilsCls.residueName2Abbr(d)}),r=c}X[r]=a,t=s=i=n=[]}this.setSeq(x,Y,X,V)}let R=Object.keys(r.structures);for(let e=0,t=R.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 ps{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("set annotation ig"==n)t.bRunRefnumAgain=!0,await t.annotationCls.setAnnoTabIg(),t.bRunRefnumAgain=!1;else if("ig refnum on"==n)t.bRunRefnumAgain=!0,t.bAnnoShown||await t.showAnnoCls.showAnnotations(),await t.annotationCls.setAnnoTabIg(!0),t.bRunRefnumAgain=!1;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 ig labels"==n)t.residueLabelsCls.addIgLabels(t.hAtoms),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.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(),t.bDefinedSets=!0;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 iganchor sets")){let e=i.split(" | ")[1].split(" ")[1];t.addTrackCls.defineIgstrand(e,"iganchor")}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"),t.bDefinedSets||(t.definedSetsCls.setPredefinedInMenu(),t.bDefinedSets=!0);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(i,"sphere"),t.shapeCmdHash[i]=1;else if(0==n.indexOf("add cube"))this.addShape(i,"cube"),t.shapeCmdHash[i]=1;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","Distances among the sets")}}}else if(0==i.indexOf("angletable")){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.measureAngleManySets(e,n),s.htmlCls.dialogCls.openDlg("dl_angletable","Angles 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()}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(0==n.indexOf("translate pdb")){let e=n.substr(14).split(" ");t.transformCls.translateCoord(t.hAtoms,parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2])),t.drawCls.draw()}else if(0==n.indexOf("rotate pdb")){let e=n.substr(11).split(","),s=[];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,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,c=i.parasCls.thr(r);if("x1"==l[0])d=new THREE.Vector3(parseFloat(l[1]),parseFloat(l[3]),parseFloat(l[5]));else{let e=n[1].split(","),t=s.definedSetsCls.getAtomsFromNameArray(e),i=s.contactCls.getExtent(t);d=new THREE.Vector3(i[2][0],i[2][1],i[2][2])}"sphere"==t?s.sphereCls.createSphereBase(d,c,parseFloat(a),void 0,void 0,void 0,parseFloat(o)):s.boxCls.createBox_base(d,parseFloat(a),c,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':"set annotation ig"==e?t+': "Ig Domains" 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 Ig domain labels"==e?o+"per Ig Domain":"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 ms{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&&s.atoms[e[0]]}else if(void 0!==s.defNames2Residues&&s.defNames2Residues.hasOwnProperty(o)){let e=s.defNames2Residues[o];e.length>0&&(r=s.residues[e[0]],r&&s.atoms[Object.keys(r)[0]])}-1!=n.indexOf(o)?i+="":i+=""}return i}reset(){let e=this.icn3d;e.atoms={},e.proteins={},e.nucleotides={},e.chemicals={},e.ions={},e.water={},e.structures={},e.chains={},e.chainsSeq={},e.residues={},e.defNames2Atoms={},e.defNames2Residues={},e.ssbondpnts={},e.bShowHighlight=void 0,e.bResetSets=!0}dictionaryDifference(e,t){const s={};for(let i in t)i in e||(s[i]=t[i]);return s}clickStructure(){let e=this.icn3d,t=e.icn3dui,s=this;null==e.allData&&(e.allData={},e.allData.all={atoms:{},proteins:{},nucleotides:{},chemicals:{},ions:{},water:{},structures:{},ssbondpnts:{},residues:{},chains:{},chainsSeq:{},defNames2Atoms:{},defNames2Residues:{}},e.allData.prev={}),$("#"+e.pre+"collections_menu").change((async function(e){let i=s.icn3d,n=$(this).val(),l=$(this).find("option:selected").text();if(i.nameArray=n,null!==n){let e=!0;s.reset();for(const t of n)t in i.allData||(i.allData.prev=JSON.parse(JSON.stringify(i.allData.all)),i.atoms=i.allData.all.atoms,i.proteins=i.allData.all.proteins,i.nucleotides=i.allData.all.nucleotides,i.chemicals=i.allData.all.chemicals,i.ions=i.allData.all.ions,i.water=i.allData.all.water,i.structures=i.allData.all.structures,i.ssbondpnts=i.allData.all.ssbondpnts,i.residues=i.allData.all.residues,i.chains=i.allData.all.chains,i.chainsSeq=i.allData.all.chainsSeq,i.defalls2Atoms=i.allData.all.defalls2Atoms,i.defalls2Residues=i.allData.all.defalls2Residues,await i.chainalignParserCls.downloadMmdbAf(t,void 0,void 0,e).then((()=>{i.allData.all={atoms:i.atoms,proteins:i.proteins,nucleotides:i.nucleotides,chemicals:i.chemicals,ions:i.ions,water:i.water,structures:i.structures,ssbondpnts:i.ssbondpnts,residues:i.residues,chains:i.chains,chainsSeq:i.chainsSeq,defNames2Atoms:i.defNames2Atoms,defNames2Residues:i.defNames2Residues},i.allData[t]={atoms:s.dictionaryDifference(i.allData.prev.atoms,i.atoms),proteins:s.dictionaryDifference(i.allData.prev.proteins,i.proteins),nucleotides:s.dictionaryDifference(i.allData.prev.nucleotides,i.nucleotides),chemicals:s.dictionaryDifference(i.allData.prev.chemicals,i.chemicals),ions:s.dictionaryDifference(i.allData.prev.ions,i.ions),water:s.dictionaryDifference(i.allData.prev.water,i.water),structures:s.dictionaryDifference(i.allData.prev.structures,i.structures),ssbondpnts:s.dictionaryDifference(i.allData.prev.ssbondpnts,i.ssbondpnts),residues:s.dictionaryDifference(i.allData.prev.residues,i.residues),chains:s.dictionaryDifference(i.allData.prev.chains,i.chains),chainsSeq:s.dictionaryDifference(i.allData.prev.chainsSeq,i.chainsSeq),defNames2Atoms:s.dictionaryDifference(i.allData.prev.defNames2Atoms,i.defNames2Atoms),defNames2Residues:s.dictionaryDifference(i.allData.prev.defNames2Residues,i.defNames2Residues)},s.reset()})));for(const e of n)i.atoms=Object.assign(i.atoms,i.allData[e].atoms),i.proteins=Object.assign(i.proteins,i.allData[e].proteins),i.nucleotides=Object.assign(i.nucleotides,i.allData[e].nucleotides),i.chemicals=Object.assign(i.chemicals,i.allData[e].chemicals),i.ions=Object.assign(i.ions,i.allData[e].ions),i.water=Object.assign(i.water,i.allData[e].water),i.structures=Object.assign(i.structures,i.allData[e].structures),i.ssbondpnts=Object.assign(i.ssbondpnts,i.allData[e].ssbondpnts),i.residues=Object.assign(i.residues,i.allData[e].residues),i.chains=Object.assign(i.chains,i.allData[e].chains),i.chainsSeq=Object.assign(i.chainsSeq,i.allData[e].chainsSeq),i.defNames2Atoms=Object.assign(i.defNames2Atoms,i.allData[e].defNames2Atoms),i.defNames2Residues=Object.assign(i.defNames2Residues,i.allData[e].defNames2Residues),i.dAtoms=t.hashUtilsCls.cloneHash(i.atoms),i.hAtoms=t.hashUtilsCls.cloneHash(i.atoms);i.opts.color=1==Object.keys(i.structures).length?"chain":"structure",i.setColorCls.setColorByOptions(i.opts,i.atoms),i.transformCls.zoominSelection(),i.definedSetsCls.showSets(),i.bResetAnno=!0,i.bAnnoShown&&(await i.showAnnoCls.showAnnotations(),i.hlUpdateCls.updateHlAll(n),i.annotationCls.showAnnoSelectedChains()),await i.drawCls.draw(),i.saveFileCls.showTitle(),t.htmlCls.clickMenuCls.setLogCmd("select structure ["+l+"]",!0)}})),t.myEventCls.onIds("#"+e.pre+"collections_menu","focus",(function(e){let i=s.icn3d;t.utilsCls.isMobile()&&$("#"+i.pre+"collections_menu").val("")}))}}class gs{constructor(e){this.icn3d=e}async loadScript(e,t,s){let i=this.icn3d;if(i.icn3dui,!e)return;i.bCommandLoad=!0,i.bRender=!1,i.bStopRotate=!0,e=t?e.replace(/\+/g," "):e.replace(/\+/g," ").replace(/;/g,"\n");let n=[];!s&&i.commands.length>0&&(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}updateTransformation(e){let t=this.icn3d;t.icn3dui;let s=t.commands[e-1]?t.commands[e-1].split("|||"):[];if(2==s.length){let e=JSON.parse(s[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}t.drawCls.draw()}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 template")){let e=d.substr(d.lastIndexOf(" ")+1);await r.htmlCls.clickMenuCls.setIgTemplate(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"))l.bRender=!0,o.updateTransformation(s),await o.applyCommandCartoon2d(d),l.bRender=!1;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);l.bRender=!0,o.updateTransformation(s),await l.cartoon2dCls.draw2Dcartoon(t),l.bRender=!1}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);4==l.length&&(l=l.toUpperCase());let r=l.split(","),o="";for(let e=0,s=r.length;e1&&-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):"rcsbmtz"==l&&await t.mtzParserCls.mtzParserBase(s[1],n,e,"url",i,!0)}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 fs{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 b,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 Cs{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==i.pk){let l=!0;this.selectResidueList(i.hAtoms,e,t,void 0,void 0,l),this.updateSelectionNameDesc(),s?n.htmlCls.clickMenuCls.setLogCmd("select "+i.resid2specCls.atoms2spec(i.hAtoms),!0):n.htmlCls.clickMenuCls.setLogCmd("select "+i.resid2specCls.atoms2spec(i.hAtoms)+" | name "+e,!0)}else this.selectResidueList(i.selectedResidues,e,t,void 0,void 0,void 0),this.updateSelectionNameDesc(),s?n.htmlCls.clickMenuCls.setLogCmd("select "+i.resid2specCls.residueids2spec(Object.keys(i.selectedResidues)),!0):n.htmlCls.clickMenuCls.setLogCmd("select "+i.resid2specCls.residueids2spec(Object.keys(i.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 bs{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}resi2range(e){this.icn3d.icn3dui;let t,s,i=[],n=e.sort((function(e,t){return parseInt(e)-parseInt(t)})),l=n[0];for(let e=0,r=n.length;e0&&(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;e=1)for(let t=0,l=r.length;t2540&&u<2560?e=!0:u>3540&&u<3560?t=!0:u>7540&&u<7560?s=!0:u>8540&&u<8560&&(l=!0),2550==u){"helix"==i.firstAtomObjCls.getFirstAtomObj(i.residues[h]).ss&&(r=!1)}else if(3550==u){"helix"==i.firstAtomObjCls.getFirstAtomObj(i.residues[h]).ss&&(o=!1)}else if(7550==u){"helix"==i.firstAtomObjCls.getFirstAtomObj(i.residues[h]).ss&&(d=!1)}else if(8550==u){"helix"==i.firstAtomObjCls.getFirstAtomObj(i.residues[h]).ss&&(p=!1)}if(e&&t&&s&&l)break}if(!(e&&t&&s&&l&&r&&o&&d&&p)){n.bNode||e&&t&&s&&l||console.log("Some of the Ig strands B, C, E, F are missing in the domain "+c+"..."),n.bNode||r&&o&&d&&p||console.log("Some of the Ig strands B, C, E, F are not beta sheets..."),i.domainid2refpdbname[c][0]==h&&(delete i.domainid2refpdbname[c],delete i.domainid2score[c]);continue}}s||n.bNode||console.log("domainid: "+c),(!l.hasOwnProperty(c)||d>=parseFloat(i.domainid2score[c].split("_")[0]))&&(i.domainid2score[c]=a[0].score+"_"+a[0].frac_identical+"_"+a[0].num_res,i.domainid2refpdbname[c]=s?d>=this.TMThresholdIgType?[h]:["all_templates"]:[h],l[c]=a[0].segs,i.domainid2ig2kabat[c]=a[0].ig2kabat,i.domainid2ig2imgt[c]=a[0].ig2imgt)}if(s)for(let e in r)if(!n.bNode&&"all_templates"==i.domainid2refpdbname[e][0]){let t=r[e],s=Object.keys(t);s.sort((function(e,s){return t[s]-t[e]})),i.domainid2refpdbname[e]=s.slice(0,this.topClusters)}return l}async parseAlignData(e,t,s){let i=this.icn3d,n=i.icn3dui,l=!1,r=this.parseAlignData_part1(e,t,s);if(0==Object.keys(r).length)return l=!0,l;if(s){n.bNode||console.log("Start round 2 alignment with the reference culsters "+JSON.stringify(i.domainid2refpdbname));let e=[],t=[],s=n.htmlCls.tmalignUrl;for(let l in i.domainid2refpdbname){let r=[],o=i.domainid2refpdbname[l],a=l.substr(0,l.indexOf(","));i.refpdbHash.hasOwnProperty(a)&&(o=[a],n.bNode||console.log("Adjusted refpdbname for domainid "+l+": "+a));let d=[];for(let e=0,t=o.length;e=3545&&i.q_start<=3555){let e=t.firstAtomObjCls.getFirstCalphaAtomObj(t.residues[r]);e&&w.push(e)}else if(i.q_start>=7545&&i.q_start<=7555){let e=t.firstAtomObjCls.getFirstCalphaAtomObj(t.residues[r]);e&&S.push(e)}if(-1!=i.q_start.indexOf("8550")&&1==g&&h&&u&&(p||m)){let e=999,t=999;for(let t=0,s=w.length;tt+l||e==t+l&&i>n+l)&&(A.push(p.resi),s.bNode||console.log("Rename strand C' to D: distToC "+e+" distToE "+t+" resiDistToC "+i+" resiDistToE "+n)):v&&(e+l0){for(let e=0,t=A.length;eparseInt(A[e])-10){h="D";break}}else if("D"==f&&x.length>0)for(let e=0,t=x.length;eparseInt(x[e])-10){h="C'";break}f!=h&&(c=this.getLabelFromRefnum(d,o,h)),"helix"!=t.firstAtomObjCls.getFirstAtomObj(t.residues[a]).ss&&(t.resid2refnum[a]=c,t.resid2domainid[a]=i)}}Object.keys(t.resid2refnum).length>0?t.bShowRefnum=!0:s.bNode||t.bNoIg||(console.log("No Ig reference numbers are assigned based on the reference structures in iCn3D..."),t.bNoIg=!0),t.chainid2igtrack||(t.chainid2igtrack={});for(let e in t.chains){let s=t.firstAtomObjCls.getFirstAtomObj(t.chains[e]);if(t.proteins.hasOwnProperty(s.serial)){let s=t.showSeqCls.getSeq(e);t.chainid2igtrack[e]=this.ajdustRefnum(s,e)}}}getStrandFromRefnum(e,t){this.icn3d.icn3dui;let s,i=parseInt(e);return s=i<1e3?void 0:i>=1200&&i<1320?"A---":i>=1320&&i<1420?"A--":i>=1420&&i<1520?"A-":i>=1520&&i<1620?"A":i>=1620&&i<1720?"A+":i>=1720&&i<1820?"A++":i>=1820&&i<2e3?"A'":i>=2e3&&i<3e3?"B":i>=3e3&&i<3420?"C--":i>=3420&&i<3520?"C-":i>=3520&&i<4e3?"C":i>=4e3&&i<5e3?"C'":i>=5e3&&i<6e3?"C''":i>=6e3&&i<7e3?"D":i>=7e3&&i<7620?"E":i>=7620&&i<8e3?"E+":i>=8e3&&i<9e3?"F":i>=9e3&&i<9620?"G":i>=9620&&i<9720?"G+":i>=9720&&i<9820?"G++":i>=9820&&i<9900?"G+++":i>9900?void 0:" ",t&&(s=t),s}getLabelFromRefnum(e,t,s){this.icn3d.icn3dui;let i=this.getStrandFromRefnum(e,s),n=e.toString();return"C'"==s&&"6"==n.substr(0,1)?n="4"+n.substr(1):"D"==s&&"4"==n.substr(0,1)&&(n="6"+n.substr(1)),i?i+n+t:void 0}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;e0){l+='{"'+r+'": {\n';for(let t=0,n=o.length;t=46&&t<=54){let e=t-50;y[_].anchorRefnum=d-e,y[_].resCntBfAnchor=S-e,A=e,x=!0}g&&(y[_].anchorRefnum=0),y[_].strandPostfix=a,y[_].strand=p,y[_].postfix=o,y[_].loopResCnt=w-1,++_,w=0}else if(v[p+o]){if(50==t&&(y[_-1].anchorRefnum=d,y[_-1].resCntBfAnchor=S,y[_-1].startRefnum=y[_-1].anchorRefnum-y[_-1].resCntBfAnchor,A=0,x=!0),!x&&(51==t||52==t||53==t||54==t)){let e=t-50;y[_-1].anchorRefnum=d-e,y[_-1].resCntBfAnchor=S-e,y[_-1].startRefnum=y[_-1].anchorRefnum-y[_-1].resCntBfAnchor,A=e,x=!0}g&&(y[_-1].anchorRefnum=0),y[_-1].domainid=e,y[_-1].endResi=k,y[_-1].endRefnum=d,y[_-1].resCntAtAnchor=A,y[_-1].anchorRefnum&&(y[_-1].endRefnum=y[_-1].anchorRefnum+y[_-1].resCntAtAnchor),w=0}}u=p}}m=p}for(let e=0,i=y.length;e0&&parseInt(l)<=parseInt(y[e-1].endResi))break;let o=t+"_"+l,a=s.firstAtomObjCls.getFirstAtomObj(s.residues[o]),d=s.resid2domainid[o];if(a.ssbegin){let o=y[e].startRefnum;y[e].startResi=l,y[e].startRefnum-=i,y[e].loopResCnt-=i,y[e].loopResCnt<0&&(y[e].loopResCnt=0),y[e].resCntBfAnchor+=i;for(let a=1;a<=i;++a){n=r-a,l=s.ParserUtilsCls.getResi(t,n);let i=t+"_"+l;delete s.residIgLoop[i],s.resid2refnum[i]=y[e].strand+(o-a).toString(),s.resid2domainid[i]=d}break}}if("sheet"==l.ss&&!l.ssend)for(let n=1;n<=8;++n){let l=o+n,r=s.ParserUtilsCls.getResi(t,l);if(e=parseInt(y[e+1].startResi))break;let a=t+"_"+r,d=s.firstAtomObjCls.getFirstAtomObj(s.residues[a]),c=s.resid2domainid[a];if(d.ssend){let a=y[e].endRefnum;y[e].endResi=r,y[e].endRefnum+=n,e=0;--e){"G"!=y[e].strand&&y[e].endRefnum-y[e].startRefnum+1<3&&(y[e+1]&&(y[e+1].loopResCnt+=y[e].loopResCnt+parseInt(y[e].endResi)-parseInt(y[e].startResi)+1),y[e].startResi,y.splice(e,1))}_=0;let O,R,I=0,E=!0,T=!0,D=0;b=!1;let P=0;if(y.length>0)for(let i=0,l=e.length;iy[_].endResi:parseInt(l)>parseInt(y[_].endResi),i=!t&&!r,t)if(s.residIgLoop[o]=1,E)b?(R=y[_].startRefnum-y[_].loopResCnt+I,O=y[_].strand+R,n=O+y[_].strandPostfix,e=y[_].domainid):(O=void 0,n=void 0);else if(D>=0&&("G"==y[D].strand.substr(0,1)||"F"==y[D].strand.substr(0,1)&&"G"!=y[_].strand.substr(0,1)))T?b&&s.resid2refnum[o]?(T=!0,R=y[D].endRefnum+I,O=y[D].strand+R,n=O+y[D].strandPostfix,e=y[D].domainid):(b=!1,E=!0,T=!1,O=void 0,n=void 0):(O=void 0,n=void 0);else{T=!0;let t=y[_].loopResCnt;I<=parseInt(t/2+.5)?y[D]&&(R=y[D].endRefnum+I,O=y[D].strand+R,n=O+y[D].strandPostfix,e=y[D].domainid):(R=y[_].startRefnum-t+I-1,O=y[_].strand+R,n=O+y[_].strandPostfix,e=y[_].domainid)}else i?(E=!1,y[_].anchorRefnum&&(l==y[_].startResi?(P=y[_].anchorRefnum-y[_].resCntBfAnchor,y[_].startRefnum=P):l==y[_].endResi&&(y[_].endRefnum=P),O=y[_].strand+P,n=O+y[_].strandPostfix,e=y[_].domainid),l==y[_].endResi&&(++_,I=0,y[_]||--_)):r&&(s.residIgLoop[o]=1,T?s.resid2refnum[o]?(T=!0,R=y[_].endRefnum+I,O=y[_].strand+R,n=O+y[_].strandPostfix,e=y[_].domainid):(T=!1,O=void 0,n=void 0):(O=void 0,n=void 0))}else n=void 0;m=p,D=_-1,k.hasOwnProperty(e)?(delete s.resid2refnum[o],delete s.residIgLoop[o],delete s.resid2domainid[o]):(s.resid2refnum[o]=n,s.resid2domainid[o]=e,r=s.refnumCls.rmStrandFromRefnumlabel(n),s.refnum2residArray.hasOwnProperty(r)?s.refnum2residArray[r].push(o):s.refnum2residArray[r]=[o],s.chainsMapping.hasOwnProperty(t)||(s.chainsMapping[t]={}),s.chainsMapping[t][o]=O||l)}return!0}}class Ss{constructor(e){this.icn3d=e}async applyCommandScap(e){this.icn3d.icn3dui;let t=e.substr(e.lastIndexOf(" ")+1);0==e.indexOf("scap 3d")?await this.retrieveScap(t):0==e.indexOf("scap interaction")?await this.retrieveScap(t,!0):0==e.indexOf("scap pdb")&&await this.retrieveScap(t,void 0,!0)}adjust2DWidth(e){let t,s,i,n=this.icn3d;if(n.icn3dui,e=n.pre+e,$("#"+n.pre+"dl_selectannotations").hasClass("ui-dialog-content")){t=$("#"+n.pre+"dl_selectannotations").dialog("option","width"),s=.5*$("#"+n.pre+"dl_selectannotations").dialog("option","height"),i=s,$("#"+n.pre+"dl_selectannotations").dialog("option","height",s),$("#"+e).dialog("option","width",t),$("#"+e).dialog("option","height",s);let l={my:"left top",at:"right top+"+i,of:"#"+n.pre+"viewer",collision:"none"};$("#"+e).dialog("option","position",l)}}async retrieveScap(e,t,s){let i=this.icn3d,n=i.icn3dui,l=this;i.bScap=!0;let r="",o=e.split(","),a={},d=[],c={};for(let e=0,t=o.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,C=0,b={};for(let e=0,s=n[0].length;et&&(t=b[s].length,e=s);let s=Object.keys(p),i=Object.keys(m);for(let t=0,n=b[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 xs{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,C=[],b=[],y=[],v=0,_=-1,w=-1;if(e)for(let e=0;e<=d;++e)C[e]=b[e]=0;else{C[0]=0,b[0]=-g-g;for(let e=1;e<=d;++e)e>=l?C[e]=b[e]=f:(C[e]=-(g+p*(e-1)),b[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,b[t]=o,n-=p,l|=n>a?32:0,n=n>a?n:a,s[t]=l}C[u]=i,b[u]=e?0:f,r>v&&(v=r,_=t,w=c)}if(e&&0==v)return null;u=e?v:C[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 ks{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 C=(parseFloat(d)+parseFloat(o)-parseFloat(h)).toFixed(2),b="
    Calculate solvent accessible surface area in the interface:

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

    ",$("#"+s.pre+"dl_buriedarea_html").html(b),i.htmlCls.dialogCls.openDlg("dl_buriedarea","Buried solvent accessible surface area in the interface"),i.htmlCls.clickMenuCls.setLogCmd("buried surface "+C,!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)}}measureAngleManySets(e,t){var s=this.icn3d,i=s.icn3dui;if(0==e.length||0==t.length)alert("Please select sets for angleance calculation...");else{let n={};for(let i=0,l=e.length;i180&&(d-=180),d>90&&(d=180-d),n[l][i]=d}}let l="";for(let e=0,s=t.length;e"+t[e]+" (°)"}l+="";for(let s=0,i=e.length;s";for(let e=0,s=t.length;e"+n[i][s]+"":l+=""}l+=""}l+="
    "+i+" (°)0


    ",$("#"+i.pre+"dl_angletable_html").html(l)}}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 Os{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="",C={};if(i)for(let e in n.dAtoms){let t=n.atoms[e];C[c[t.structure+"_"+t.chain]]=1}let b=Object.keys(e.moleculeInfor),y=Object.keys(e.intrac),v=[];for(let e=0,t=b.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,C,b,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,C=t+i,b=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,C=t,b=e,y=t-i}let _=p-e,w=m-t,S=u-e,A=g-t,x=f-e,k=C-t,O=b-e,R=y-t,I="";return I+="Chain "+i+": "+l+"",I+="",I+="",I+=""+n+"",""!==r&&(I+=""+r+""),I+="",I}}class Rs{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,C=!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],C=r.atoms[f];l=d,c=this.projectTo2d(c);let b=c.x,y=c.y;bn&&(n=b),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:b,y:y,rx:m,ry:u,ang:g,c:C.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,C=!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:b,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[C],w=f[C];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 E=A.x,T=A.y;Ec&&(c=E),Th&&(h=T);let D=.5;x=D*s.htmlCls.width2d*x/(o[1][0]-o[0][0]),k=D*s.htmlCls.width2d*k/(o[1][1]-o[0][1]),x>p&&(p=x),k>p&&(p=k),void 0!==b&&n.push('{"source": "'+b+'", "target": "'+v+'", "v": '+l+', "c": "'+y.color.getHexString().toUpperCase()+'"}'),m.push({id:v,from:_+"",to:w+"",x:E,y:T,rx:x,ry:k,ang:O,c:I.color.getHexString()}),b=v,y=I}}let g=p+2,f=c-a,C=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","dl_translate"];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 Es{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;if(!e)return;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()}translateCoord(e,t,s,i){let n=this.icn3d;n.icn3dui;for(let l in e){let e=n.atoms[l];e.coord.x+=t,e.coord.y+=s,e.coord.z+=i}}rotateCoord(e,t){let s=this.icn3d;s.icn3dui;const i=new THREE.Matrix4;i.elements=t;for(let t in e){let e=s.atoms[t];e.coord=e.coord.applyMatrix4(i)}}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 Ts{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 C,b,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 C=e.resi;!isNaN(C)&&e.chain.length>3&&!isNaN(e.chain.substr(3))&&(C=C-1+parseInt(e.chain.substr(3)));let b=parseInt(C);m+=b.toString().length<=4?b.toString().padStart(4," "):b.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 Ds{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 C,b=c+1,y="";for(let e=s.commands.length;b0&&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&&(C=Object.keys(s.structures)[0],n=n.replace(new RegExp(C+"_","g"),"!"),l=l.replace(new RegExp(C+"_","g"),"!")),void 0!==i.cfg.blast_rep_id&&(n=n.replace(new RegExp("blast_rep_id=!","g"),"blast_rep_id="+C+"_")),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+="pdb\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 Ps{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 Hs{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 Ls{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 Ns{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 qs{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 Us{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 Ee(this),this.fogCls=new Te(this),this.boxCls=new De(this),this.brickCls=new Pe(this),this.curveStripArrowCls=new Me(this),this.curveCls=new Fe(this),this.cylinderCls=new He(this),this.lineCls=new Le(this),this.reprSubCls=new Ne(this),this.sphereCls=new qe(this),this.stickCls=new Ue(this),this.strandCls=new Be(this),this.stripCls=new $e(this),this.tubeCls=new je(this),this.cartoonNuclCls=new ze(this),this.surfaceCls=new Ze(this),this.labelCls=new Ve(this),this.axesCls=new We(this),this.glycanCls=new Ye(this),this.applyCenterCls=new Qe(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 ys(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.loadCIFCls=new cs(this),this.vastplusCls=new hs(this),this.transformCls=new Es(this),this.setStyleCls=new ft(this),this.setColorCls=new Ct(this),this.threeDPrintCls=new Ps(this),this.export3DCls=new Ms(this),this.annoCddSiteCls=new vt(this),this.annoContactCls=new _t(this),this.annoPTMCls=new wt(this),this.annoIgCls=new St(this),this.annoCrossLinkCls=new At(this),this.annoDomainCls=new xt(this),this.annoSnpClinVarCls=new kt(this),this.annoSsbondCls=new Ot(this),this.annoTransMemCls=new Rt(this),this.domain3dCls=new It(this),this.addTrackCls=new Et(this),this.annotationCls=new Tt(this),this.showAnnoCls=new Dt(this),this.showSeqCls=new Pt(this),this.hlSeqCls=new Mt(this),this.hlUpdateCls=new Ft(this),this.lineGraphCls=new Lt(this),this.getGraphCls=new Nt(this),this.showInterCls=new qt(this),this.viewInterPairsCls=new Ut(this),this.drawGraphCls=new Bt(this),this.contactMapCls=new $t(this),this.alignParserCls=new jt(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.bcifParserCls=new Zt(this),this.mol2ParserCls=new Qt(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 ps(this),this.definedSetsCls=new ms(this),this.selectCollectionsCls=new us(this),this.legendTableCls=new yt(this),this.loadScriptCls=new gs(this),this.selByCommCls=new fs(this),this.selectionCls=new Cs(this),this.resid2specCls=new bs(this),this.delphiCls=new vs(this),this.dsspCls=new _s(this),this.refnumCls=new ws(this),this.scapCls=new Ss(this),this.symdCls=new As(this),this.alignSWCls=new xs(this),this.analysisCls=new ks(this),this.resizeCanvasCls=new Is(this),this.saveFileCls=new Ts(this),this.setOptionCls=new bt(this),this.shareLinkCls=new Ds(this),this.diagram2dCls=new Os(this),this.cartoon2dCls=new Rs(this),this.rayCls=new Fs(this),this.controlCls=new Hs(this),this.pickingCls=new Ls(this),this.VRButtonCls=new Ns(this),this.ARButtonCls=new qs(this),this.matShader=this.setColorCls.setOutlineColor("yellow")}}Us.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=[]},Us.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},Us.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},Us.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 Bs{constructor(e){this.cfg=e,this.pre=this.cfg.divid+"_",this.REVISION="3.33.2",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(){}}Bs.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,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.bcifid||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.bcifParserCls.downloadBcif(t.cfg.mmtfid);else if(void 0!==t.cfg.bcifid)s.inputid=t.cfg.bcifid,s.loadCmd="load bcif "+t.cfg.bcifid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.bcifParserCls.downloadBcif(t.cfg.bcifid);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 Us(e),e.icn3d.controlCls.setControl(),e.setDialogAjax()},Bs.prototype.getMmtfPromise=function(e){return new Promise((function(t,s){MMTF.fetch(e,(async function(e){t(e)}),(function(e){s("error")}))}))},Bs.prototype.getMmtfReducedPromise=function(e){return new Promise((function(t,s){MMTF.fetchReduced(e,(async function(e){t(e)}),(function(e){s("error")}))}))},Bs.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 electron density map for this structure."):alert("The "+i+" file is unavailable..."),r("error");else n.icn3d.ParserUtilsCls.showLoading()},o.send()}))},Bs.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")}})}))},Bs.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(){!a.bNode&&i&&console.log(i),!a.bNode&&n&&console.log(n),o("error")}})}))},Bs.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=qs,e.AddTrack=Et,e.AlignParser=jt,e.AlignSW=xs,e.AlignSeq=m,e.Alternate=ct,e.Analysis=ks,e.AnnoCddSite=vt,e.AnnoContact=_t,e.AnnoCrossLink=At,e.AnnoDomain=xt,e.AnnoSnpClinVar=kt,e.AnnoSsbond=Ot,e.AnnoTransMem=Rt,e.Annotation=Tt,e.ApplyCenter=Qe,e.ApplyClbonds=et,e.ApplyCommand=ps,e.ApplyDisplay=st,e.ApplyMap=rt,e.ApplyOther=it,e.ApplySsbonds=nt,e.ApplySymd=lt,e.Axes=We,e.Box=De,e.Brick=Pe,e.Camera=Ee,e.CartoonNucl=ze,e.ChainalignParser=zt,e.ClickMenu=a,e.Contact=pt,e.Control=Hs,e.ConvertTypeCls=o,e.Curve=Fe,e.CurveStripArrow=Me,e.Cylinder=He,e.DefinedSets=ms,e.Delphi=vs,e.DensityCifParser=ls,e.Diagram2d=Os,e.Dialog=c,e.Domain3d=It,e.Draw=ht,e.DrawGraph=Bt,e.Dsn6Parser=Gt,e.Dssp=_s,e.ElectronMap=Je,e.Events=p,e.Export3D=Ms,e.FirstAtomObj=ys,e.Fog=Te,e.GetGraph=Nt,e.Glycan=Ye,e.HBond=mt,e.HashUtilsCls=t,e.HlObjects=Ht,e.HlSeq=Mt,e.HlUpdate=Ft,e.Html=g,e.Impostor=at,e.Instancing=dt,e.Label=Ve,e.Line=Le,e.LineGraph=Lt,e.LoadAtomData=os,e.LoadCIF=cs,e.LoadPDB=ds,e.LoadScript=gs,e.MarchingCube=Xe,e.MmcifParser=Kt,e.MmdbParser=Jt,e.Mol2Parser=Qt,e.MyEventCls=n,e.OpmParser=es,e.ParasCls=i,e.ParserUtils=rs,e.PdbParser=ts,e.PiHalogen=ut,e.Picking=Ls,e.ProteinSurface=Ke,e.Ray=Fs,e.RealignParser=ns,e.Refnum=ws,e.ReprSub=Ne,e.Resid2spec=bs,e.ResidueLabels=ot,e.ResizeCanvas=Is,e.RmsdSuprCls=l,e.Saltbridge=gt,e.SaveFile=Ts,e.Scap=Ss,e.Scene=Ie,e.SdfParser=ss,e.SelectByCommand=fs,e.Selection=Cs,e.SetColor=Ct,e.SetDialog=h,e.SetHtml=u,e.SetMenu=d,e.SetOption=bt,e.SetSeqAlign=as,e.SetStyle=ft,e.ShareLink=Ds,e.ShowAnno=Dt,e.ShowInter=qt,e.ShowSeq=Pt,e.Sphere=qe,e.Stick=Ue,e.Strand=Be,e.Strip=$e,e.SubdivideCls=r,e.Surface=Ze,e.Symd=As,e.ThreeDPrint=Ps,e.Transform=Es,e.Tube=je,e.UtilsCls=s,e.VRButton=Ns,e.Vastplus=hs,e.ViewInterPairs=Ut,e.XyzParser=is,e.iCn3D=Us,e.iCn3DUI=Bs,e.printMsg=class{constructor(){console.log("This is a message from the icn3d package")}},Object.defineProperty(e,"__esModule",{value:!0}),e}({}); +}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=C?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(C){let e=!0,t=p.showInterCls.pickCustomSphere_base(n,b,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 b){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,u="interactions "+n+" | sets "+e+" "+t+" | true";p.opts.contact="yes";for(let e=0;e
    ",T=p.resid2specCls.atoms2residues(Object.keys(b)),P=p.resid2specCls.atoms2residues(Object.keys(y)),D="select "+p.resid2specCls.residueids2spec(T),M="select "+p.resid2specCls.residueids2spec(P);E+="Set 1: "+e+'
    ',E+="Set 2: "+t+'

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

    ',E+='
    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=E;if(("graph"==i||"linegraph"==i||"scatterplot"==i||C)&&(E=""),E+=O,"save1"==i||"save2"==i){E=q;let e="";"save1"==i?e="Set 1":"save2"==i&&(e="Set 2"),E+='

    Interactions Sorted on '+e+':
    ';let t=this.getAllInteractionTable(i);E+=t.html,h=t.bondCnt,$("#"+p.pre+"dl_interactionsorted_html").html(E),m.htmlCls.dialogCls.openDlg("dl_interactionsorted","Show sorted interactions")}else if("view"==i)$("#"+p.pre+"dl_allinteraction_html").html(E),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(b,y,e,t,E,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(b,y,e,t,E,u),p.bScatterplot=!0;let s=p.lineGraphCls.drawLineGraph(p.graphStr,!0);$("#"+p.pre+"scatterplotDiv").html(s)}else if(C){m.htmlCls.dialogCls.openDlg("dl_contactmap","Show contact map");let s=!0,i=p.getGraphCls.getGraphData(b,y,e,t,E,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(b,y,e,t,E,u),p.bGraph=!0,Object.keys(y).length+Object.keys(b).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,C=0,b=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:C,cntContact:b,cntHalegen:y,cntPication:v,cntPistacking:_}),o+=this.getInteractionPerResidue(d,c,h,p,m,u,g,f,C,b,y,v,_),c="",h="",p="",m="",u="",g="",f=0,C=0,b=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,C+=k.cnt,k.cnt>0&&(w+=r+":ionic_"+k.cnt+" "),x=t.resids2inter[S].contact,k=this.getContactPairDetails(x,e,"contact"),p+=k.html,b+=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:C,cntContact:b,cntHalegen:y,cntPication:v,cntPistacking:_}),o+=this.getInteractionPerResidue(d,c,h,p,m,u,g,f,C,b,y,v,_);let S="";if(n.length>0){S+='
    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+="";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]),C=f.color?f.color.getHexString():"",b=Math.sqrt(e[a]).toFixed(1);n+=' '+c+r+u+o+' '+h+r+C+o+''+b+"",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():"",C=e[o].split("_"),b=C[0],y=C[1],v=C[2],_=C[3],w=C[4];i+=' '+d+"@"+v+l+m+r+' '+c+"@"+_+l+f+r+''+w+''+b+''+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],C=g[1];c=g[2],m=g[3];let b=g[4];e?(l+=' '+s+"@"+c+a+h+d+' '+n+"@"+m+a+u+d+''+b+''+f+''+C+"","view"==t&&(l+=''),l+=""):l+=""+s+""+n+''+b+''+f+''+C+"",++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 Bt{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 C=[],b={},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 jt{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",m=o.cfg.resrange?o.cfg.resrange.split(" | "):[];for(let s in r.afChainIndexHash){let i=r.afChainIndexHash[s].split("_");l=i[0];let a=l+"_"+i[1];n=i[2];let d,u=n+"_"+i[3],g=o.cfg.resrange?r.realignParserCls.getSeqCoorResid(m[0].split(","),u).hAtoms:r.chains[u],f=o.cfg.resrange?r.realignParserCls.getSeqCoorResid(m[s].split(","),a).hAtoms:r.chains[a];if("tmalign"!=o.cfg.aligntool){let e={domains1:r.domain3dCls.getDomainJsonForAlign(f),domains2:r.domain3dCls.getDomainJsonForAlign(g)};d=o.getAjaxPostPromise(h,e)}else{let e={pdb_query:r.saveFileCls.getAtomPDB(f),pdb_target:r.saveFileCls.getAtomPDB(g)};d=o.getAjaxPostPromise(p,e)}e.push(d),t.push(s-1),c.push(l)}let u=Promise.allSettled(e),g=await u;await a.downloadChainalignmentPart2b(s,i,d,g,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?(o="https://alphafold.ebi.ac.uk/files/AF-"+t.mmdbid_t+"-F1-model_"+t.AFUniprotVersion+".pdb",r=s.getAjaxPromise(o,"text")):(o=s.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+s.cfg.bu+"&uid="+t.mmdbid_t,void 0!==s.cfg.inpara&&(o+=s.cfg.inpara),r=s.getAjaxPromise(o,"jsonp")),a.push(r),t.ParserUtilsCls.setYourNote(e.toUpperCase()+" in iCn3D"),t.pdbid_chain2title={},void 0===t.chainids2resids&&(t.chainids2resids={}),t.afChainIndexHash={},t.pdbChainIndexHash={};for(let e=1,n=i.length;e5?(n="https://alphafold.ebi.ac.uk/files/AF-"+t.mmdbid_q+"-F1-model_"+t.AFUniprotVersion+".pdb",l=s.getAjaxPromise(n,"text")):(n=s.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+s.cfg.bu+"&uid="+t.mmdbid_q,void 0!==s.cfg.inpara&&(n+=s.cfg.inpara),l=s.getAjaxPromise(n,"jsonp")),a.push(l)}for(let e=1,l=i.length;e0?n[e]+","+n[0]:void 0;if("tmalign"!=s.cfg.aligntool&&4==t.mmdbid_t.length&&4==t.mmdbid_q.length){let o;o=n.length>0?s.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?domainpairs="+l:s.htmlCls.baseUrl+"vastdyn/vastdyn.cgi?chainpairs="+i;let d=s.getAjaxPromise(o,"jsonp");a.push(d),t.pdbChainIndexHash[e]=r+"_"+t.chain_q+"_"+t.mmdbid_t+"_"+t.chain_t}else t.afChainIndexHash[e]=t.mmdbid_q+"_"+t.chain_q+"_"+t.mmdbid_t+"_"+t.chain_t}}let d=Promise.allSettled(a),c=await d;await this.parseChainAlignData(c,i,t.mmdbid_t,t.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&&(d+="TM-score: "+n+"

    ",r.tmscore=n),$("#"+r.pre+"dl_rmsd_html").html(d),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||l.cfg.resrange)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,i){let n=this.icn3d,l=n.icn3dui;n.structArray=n.structures?Object.keys(n.structures):[],0==n.structArray.length?n.init():(n.bResetAnno=!0,n.bResetSets=!0);let r=e.split(","),o=[];for(let e=0,t=r.length;e5)t="https://alphafold.ebi.ac.uk/files/AF-"+i+"-F1-model_"+n.AFUniprotVersion+".pdb",s=l.getAjaxPromise(t,"text");else{let e=i;5==i.length&&(e=i.substr(0,4)),t=l.htmlCls.baseUrl+"mmdb/mmdb_strview.cgi?v=2&program=icn3d&b=1&s=1&ft=1&bu="+l.cfg.bu+"&uid="+e,void 0!==l.cfg.inpara&&(t+=l.cfg.inpara),s=l.getAjaxPromise(t,"jsonp")}a.push(s)}n.ParserUtilsCls.setYourNote(n.structArray+" in iCn3D"),n.ParserUtilsCls.showLoading();let d=Promise.allSettled(a),c=await d;await this.parseMMdbAfData(c,o,t,s),void 0===s&&n.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=!1;for(let e=0,i=t.length;e5){let s=!1;await n.pdbParserCls.loadPdbData(r[e],t[e],!1,l,i,o,s)}else{let s=!0,l=t[e];await n.mmdbParserCls.parseMmdbData(r[e],i,void 0,void 0,o,s,l)}}let a=Object.keys(n.structures);if(n.opts.color=a.length>1?"structure":a[0].length>5?"confidence":"chain",n.setColorCls.setColorByOptions(n.opts,{}),await n.ParserUtilsCls.renderStructure(),n.bAnnoShown&&(await n.showAnnoCls.showAnnotations(),n.annotationCls.resetAnnoTabAll()),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);2==i&&(l.cfg.aligntool="tmalign"),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,r,o=this.icn3d,a=o.icn3dui,d={},c=e.buffer&&e.buffer instanceof ArrayBuffer?e.buffer:e,h=new Int16Array(c),p=new Uint8Array(c),m=String.fromCharCode.apply(null,p.subarray(0,512));if(0==m.indexOf(":-)"))d.xStart=parseInt(m.substr(10,5)),d.yStart=parseInt(m.substr(15,5)),d.zStart=parseInt(m.substr(20,5)),d.xExtent=parseInt(m.substr(32,5)),d.yExtent=parseInt(m.substr(38,5)),d.zExtent=parseInt(m.substr(42,5)),d.xRate=parseInt(m.substr(52,5)),d.yRate=parseInt(m.substr(58,5)),d.zRate=parseInt(m.substr(62,5)),d.xlen=1*parseFloat(m.substr(73,10)),d.ylen=1*parseFloat(m.substr(83,10)),d.zlen=1*parseFloat(m.substr(93,10)),d.alpha=parseFloat(m.substr(103,10)),d.beta=parseFloat(m.substr(113,10)),d.gamma=parseFloat(m.substr(123,10)),l=parseFloat(m.substr(138,12))/100,r=parseInt(m.substr(155,8)),d.sigma=100*parseFloat(m.substr(170,12));else{if(100!==h[18])for(let e=0,t=h.length;e>8&255}d.xStart=h[0],d.yStart=h[1],d.zStart=h[2],d.xExtent=h[3],d.yExtent=h[4],d.zExtent=h[5],d.xRate=h[6],d.yRate=h[7],d.zRate=h[8];let e=1/h[17],t=1*e;d.xlen=h[9]*t,d.ylen=h[10]*t,d.zlen=h[11]*t,d.alpha=h[12]*e,d.beta=h[13]*e,d.gamma=h[14]*e,l=h[15]/h[18],r=h[16]}a.bNode||console.log("header: "+JSON.stringify(d));let u=new Float32Array(d.xExtent*d.yExtent*d.zExtent),g=512,f=Math.ceil(d.xExtent/8),C=Math.ceil(d.yExtent/8),b=Math.ceil(d.zExtent/8),y=-999;for(let e=0;ey&&(y=u[e]),++g}}}}return n||(s=this.setSigma(y,i,t,s)),"2fofc"==t?(o.mapData.header2=d,o.mapData.data2=u,o.mapData.matrix2=this.getMatrix(d),o.mapData.type2=t,o.mapData.sigma2=s):(o.mapData.header=d,o.mapData.data=u,o.mapData.matrix=this.getMatrix(d),o.mapData.type=t,o.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);return n&&($("#"+l.pre+n).val()?i=$("#"+l.pre+n).val():(i=(.2*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]],C=f.indexOf(1),b=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,l){let r=this.icn3d;r.icn3dui;let o="fofc"==t,a=e.calculate_map(o),d=e.cell;const c=new Wt(d.a,d.b,d.c,d.alpha,d.beta,d.gamma);let h=-999;for(let e=0,t=a.length;eh&&(h=a[e]);if(n||(s=r.dsn6ParserCls.setSigma(h,i,t,s)),l){r.mapData.ccp4=0;let i={xExtent:e.nx,yExtent:e.ny,zExtent:e.nz,mean:void 0,sigma:s,ccp4:1,xStart:0,yStart:0,zStart:0};i.xRate=e.nx,i.yRate=e.ny,i.zRate=e.nz,i.xlen=d.a,i.ylen=d.b,i.zlen=d.c,i.alpha=d.alpha,i.beta=d.beta,i.gamma=d.gamma,"2fofc"==t?(r.mapData.header2=i,r.mapData.data2=a,r.mapData.matrix2=r.dsn6ParserCls.getMatrix(i),r.mapData.type2=t,r.mapData.sigma2=s):(r.mapData.header=i,r.mapData.data=a,r.mapData.matrix=r.dsn6ParserCls.getMatrix(i),r.mapData.type=t,r.mapData.sigma=s)}else{const i=new Yt([e.nx,e.ny,e.nz]);i.values.set(a),"2fofc"==t?(r.mapData.ccp4=1,r.mapData.grid2=i,r.mapData.unit_cell2=c,r.mapData.type2=t,r.mapData.sigma2=s):(r.mapData.ccp4=1,r.mapData.grid=i,r.mapData.unit_cell=c,r.mapData.type=t,r.mapData.sigma=s)}return 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 C=[],b=[],y=0;for(let e=0;e.85?t=1:t<.15&&(t=0));const s=m[e[0]],n=m[e[1]];C.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,l){let r=this.icn3d,o=r.icn3dui,a=await o.getXMLHttpRqstPromise(e,"GET","arraybuffer","");return s=await this.loadMtzFileBase(a,t,s,i,n,e,l),r.setOptionCls.setOption("map",t),s}loadMtzFile(e,t){var s=this.icn3d,i=s.icn3dui;let n=this,l=$("#"+s.pre+"dsn6file"+e)[0].files[0],r=$("#"+s.pre+"dsn6sigma"+e).val();if(l){i.utilsCls.checkFileAPI();let s=new FileReader;s.onload=async function(s){let l=n.icn3d;r=await n.loadMtzFileBase(s.target.result,e,r,"file",void 0,void 0,t),i.htmlCls.clickMenuCls.setLogCmd("load map file "+$("#"+l.pre+"dsn6file"+e).val()+" with sigma "+r,!1)},s.readAsArrayBuffer(l)}else alert("Please select a file before clicking 'Load'")}async loadMtzFileBase(e,t,s,i,n,l,r){var o=this.icn3d,a=o.icn3dui;if(void 0===o.bMtz){let e="./script/mtz.js";await a.getAjaxPromise(e,"script"),o.bMtz=!0}GemmiMtz().then((function(d){let c=d.readMtz(e);s=o.ccp4ParserCls.load_maps_from_mtz_buffer(c,t,s,i,n,r),o.setOptionCls.setOption("map",t);let h=r?"rcsbmtz":"mtz";return l&&a.htmlCls.clickMenuCls.setLogCmd("set map "+t+" sigma "+s+" file "+h+" | "+encodeURIComponent(l),!0),s}))}async loadMtzFileUrl(e,t){var s=this.icn3d;s.icn3dui;let i=$("#"+s.pre+"dsn6fileurl"+e).val(),n=$("#"+s.pre+"dsn6sigmaurl"+e).val();i?n=await this.mtzParserBase(i,e,n,"url",void 0,t):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/download/"+e+".cif",n=await s.getAjaxPromise(i,"text",!0);await t.opmParserCls.loadOpmData(n,e,void 0,"mmcif",void 0,!0)}async downloadMmcifSymmetry(e,t){let s=this.icn3d,i=s.icn3dui;try{let n="https://models.rcsb.org/"+e+".bcif",l=await i.getXMLHttpRqstPromise(n,"GET","arraybuffer","bcif"),r=!1,o=!0,a=s.bcifParserCls.getBcifJson(l,e,r,o),d=JSON.parse(a);if(void 0!==d.emd&&(s.emd=d.emd),void 0!==d.organism&&(s.organism=d.organism),s.bAssemblyUseAsu){for(let e=0,t=d.assembly.length;es.maxatomcnt&&(s.bAssembly=!0)}if("mmtfid"===t&&void 0!==d.missingseq){let t=0,n="";for(let l=0,r=d.missingseq.length;lt)&&(s.chainMissingResidueArray[c].push(h),t=a,n=o)}s.loadPDBCls.adjustSeq(s.chainMissingResidueArray)}}catch(e){return void(i.bNode||console.log("mmcifparser.cgi issues: "+e))}}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),await s.opmParserCls.loadOpmData(e,t,void 0,"mmcif"),s.opmParserCls.modifyUIMapAssembly()}async loadMultipleMmcifData(e,t,s){let i=this.icn3d;i.icn3dui;i.loadCIFCls.loadCIF(e,t,!0,s),Object.keys(i.structures).length>1&&(i.opts.color="structure"),i.opmParserCls.modifyUIMapAssembly(),i.pdbParserCls.addSecondary(s)}}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.bcifParserCls.downloadBcif(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,(void 0===t||i.cfg.mmdbafid)&&(s.chainsColor[p]=i.parasCls.thr(c));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 Zt{constructor(e){this.icn3d=e,this.mElem2Radius={},this.mElem2Radius.H=.31,this.mElem2Radius.HE=.28,this.mElem2Radius.LI=1.28,this.mElem2Radius.BE=.96,this.mElem2Radius.B=.84,this.mElem2Radius.C=.76,this.mElem2Radius.N=.71,this.mElem2Radius.O=.66,this.mElem2Radius.F=.57,this.mElem2Radius.NE=.58,this.mElem2Radius.NA=1.66,this.mElem2Radius.MG=1.41,this.mElem2Radius.AL=1.21,this.mElem2Radius.SI=1.11,this.mElem2Radius.P=1.07,this.mElem2Radius.S=1.05,this.mElem2Radius.CL=1.02,this.mElem2Radius.AR=1.06,this.mElem2Radius.K=2.03,this.mElem2Radius.CA=1.76,this.mElem2Radius.SC=1.7,this.mElem2Radius.TI=1.6,this.mElem2Radius.V=1.53,this.mElem2Radius.CR=1.39,this.mElem2Radius.MN=1.39,this.mElem2Radius.FE=1.32,this.mElem2Radius.CO=1.26,this.mElem2Radius.NI=1.24,this.mElem2Radius.CU=1.32,this.mElem2Radius.ZN=1.22,this.mElem2Radius.GA=1.22,this.mElem2Radius.GE=1.2,this.mElem2Radius.AS=1.19,this.mElem2Radius.SE=1.2,this.mElem2Radius.BR=1.2,this.mElem2Radius.KR=1.16,this.mElem2Radius.RB=2.2,this.mElem2Radius.SR=1.95,this.mElem2Radius.Y=1.9,this.mElem2Radius.ZR=1.75,this.mElem2Radius.NB=1.64,this.mElem2Radius.MO=1.54,this.mElem2Radius.TC=1.47,this.mElem2Radius.RU=1.46,this.mElem2Radius.RH=1.42,this.mElem2Radius.PD=1.39,this.mElem2Radius.AG=1.45,this.mElem2Radius.CD=1.44,this.mElem2Radius.IN=1.42,this.mElem2Radius.SN=1.39,this.mElem2Radius.SB=1.39,this.mElem2Radius.TE=1.38,this.mElem2Radius.I=1.39,this.mElem2Radius.XE=1.4,this.mElem2Radius.CS=2.44,this.mElem2Radius.BA=2.15,this.mElem2Radius.LA=2.07,this.mElem2Radius.CE=2.04,this.mElem2Radius.PR=2.03,this.mElem2Radius.ND=2.01,this.mElem2Radius.PM=1.99,this.mElem2Radius.SM=1.98,this.mElem2Radius.EU=1.98,this.mElem2Radius.GD=1.96,this.mElem2Radius.TB=1.94,this.mElem2Radius.DY=1.92,this.mElem2Radius.HO=1.92,this.mElem2Radius.ER=1.89,this.mElem2Radius.TM=1.9,this.mElem2Radius.YB=1.87,this.mElem2Radius.LU=1.87,this.mElem2Radius.HF=1.75,this.mElem2Radius.TA=1.7,this.mElem2Radius.W=1.62,this.mElem2Radius.RE=1.51,this.mElem2Radius.OS=1.44,this.mElem2Radius.IR=1.41,this.mElem2Radius.PT=1.36,this.mElem2Radius.AU=1.36,this.mElem2Radius.HG=1.32,this.mElem2Radius.TL=1.45,this.mElem2Radius.PB=1.46,this.mElem2Radius.BI=1.48,this.mElem2Radius.PO=1.4,this.mElem2Radius.AT=1.5,this.mElem2Radius.RN=1.5,this.mElem2Radius.FR=2.6,this.mElem2Radius.RA=2.21,this.mElem2Radius.AC=2.15,this.mElem2Radius.TH=2.06,this.mElem2Radius.PA=2,this.mElem2Radius.U=1.96,this.mElem2Radius.NP=1.9,this.mElem2Radius.PU=1.87,this.mElem2Radius.AM=1.8,this.mElem2Radius.CM=1.69}async downloadBcif(e){let t=this.icn3d,s=t.icn3dui;t.ParserUtilsCls.setYourNote(e.toUpperCase()+"(BCIF) in iCn3D");let i="https://models.rcsb.org/"+e+".bcif",n=await s.getXMLHttpRqstPromise(i,"GET","arraybuffer","bcif");if(0==n.length)return void alert("This PDB structure is not found at RCSB...");await t.opmParserCls.loadOpmData(n,e,void 0,"bcif",void 0,!1)}getBcifJson(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r="",o="",a="",d="",c="",h="",p=s?CIFTools.Text.parse(e):CIFTools.Binary.parse(e);if(p.isError)return void alert("The Binary CIF data can NOT be parsed: "+p.toString());let m=p.result.dataBlocks[0];t||(m.getCategory("_entry")&&(t=m.getCategory("_entry").getColumn("id").getString(0)),""==t&&(t="stru")),m.getCategory("_citation")&&(o=m.getCategory("_citation").getColumn("pdbx_database_id_PubMed").getString(0)),m.getCategory("_struct")&&(a=m.getCategory("_struct").getColumn("title").getString(0),a=a.replace(/"/,"'")),m.getCategory("_struct_keywords")&&(d=m.getCategory("_struct_keywords").getColumn("pdbx_keywords").getString(0)),m.getCategory("_entity_src_gen")&&(h=m.getCategory("_entity_src_gen").getColumn("gene_src_common_name").getString(0));let u={},g={},f={};if(m.getCategory("_database_2")){let e=m.getCategory("_database_2"),t=e.rowCount;for(let s=0;sn.maxatomcnt),j=[];if(!i){_=D.getColumn("group_PDB"),w=D.getColumn("label_comp_id"),S=D.getColumn("type_symbol"),A=D.getColumn("label_atom_id"),x=D.getColumn("auth_asym_id"),k=D.getColumn("label_seq_id"),O=D.getColumn("auth_seq_id"),R=D.getColumn("label_alt_id"),I=D.getColumn("B_iso_or_equiv"),E=D.getColumn("Cartn_x"),T=D.getColumn("Cartn_y"),P=D.getColumn("Cartn_z"),j=D.getColumn("label_asym_id");let e={},t="";for(let s=0;s0&&(r=r.substr(0,r.length-2)),r+="], ",f.hasOwnProperty(M)){r+='"ss":"'+f[M]+'", '}else r+='"ss":"coil", ';u.hasOwnProperty(M)?r+='"ssbegin":1, ':r+='"ssbegin":0, ',g.hasOwnProperty(M)?r+='"ssend":1, ':r+='"ssend":0, ',r+='"mt":"'+s+'"',r+="}",r+=",\n",q=a+"_"+n,prevAutochain=p,++B}B>1&&(r=r.substr(0,r.length-2)),r+="]"}_=w=S=A=x=k=O=R=I=E=T=P=j=[];let z={};if(m.getCategory("_pdbx_poly_seq_scheme")){let e=m.getCategory("_pdbx_poly_seq_scheme"),t=e.getColumn("seq_id"),s=e.getColumn("pdb_seq_num"),i=e.getColumn("mon_id"),n=e.getColumn("pdb_strand_id"),l=e.rowCount,r="",o="";for(let e=0;e0){r+=', "disulfides":[';for(let e=0;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&&($("#"+e.pre+"assemblyWrapper").show(),e.asuCnt=e.biomtMatrices.length))}async parseAtomData(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;"mmcif"===i||"bcif"===i?(r.loadCIFCls.loadCIF(e,t,l),this.modifyUIMapAssembly(),r.setStyleCls.setAtomStyleByOptions(r.opts),r.setColorCls.setColorByOptions(r.opts,r.atoms),await r.ParserUtilsCls.renderStructure(),void 0!==o.cfg.rotate&&r.resizeCanvasCls.rotStruc(o.cfg.rotate,!0)):"pdb"===i?await r.pdbParserCls.loadPdbData(e,t):"align"===i&&(r.bOpm?await r.alignParserCls.downloadAlignmentPart2(t):void 0!==n?await this.loadOpmData(e,n,s,i):await r.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/download/"+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,i){let n=this.icn3d,l=n.icn3dui,r=e.lastIndexOf("/");if(-1!=r){let t=e.lastIndexOf(".");n.filename=e.substr(r+1,t-r-1)}else{let t=e.lastIndexOf(".");n.filename=e.substr(0,t)}let o=await l.getAjaxPromise(e,"text",!0);if(n.InputfileData=n.InputfileData?n.InputfileData+"\nENDMDL\n"+o:o,n.InputfileType=t,n.hAtoms={},n.dAtoms={},n.resetConfig(),n.bResetAnno=!0,n.bResetSets=!0,"pdb"===t){let e=!0,t=i?i.replace(/_/g,"").substr(0,4):void 0;await this.loadPdbData(o,t,void 0,e)}else if("mmcif"===t){let e=!0;await n.opmParserCls.loadOpmData(o,void 0,void 0,"mmcif",void 0,e)}else if("mol2"===t)await n.mol2ParserCls.loadMol2Data(o);else if("sdf"===t)await n.sdfParserCls.loadSdfData(o);else if("xyz"===t)await n.xyzParserCls.loadXyzData(o);else if("mmcif"===t)await n.mmcifParserCls.loadMmcifData(o);else if("icn3dpng"===t)await l.htmlCls.setHtmlCls.loadPng(o,s);else if("pae"===t){l.htmlCls.dialogCls.openDlg("dl_alignerrormap","Show Predicted Aligned Error (PAE) map");let e=!0;n.contactMapCls.processAfErrorMap(JSON.parse(o),e)}n.bSetChainsAdvancedMenu&&n.definedSetsCls.showSets(),n.bResetAnno=!0,n.bAnnoShown&&(await n.showAnnoCls.showAnnotations(),n.annotationCls.resetAnnoTabAll())}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);return 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())),await this.addSecondary(i,r),c}async addSecondary(e,t){let s=this.icn3d,i=s.icn3dui,n=!1;s.bSecondaryStructure&&1==Object.keys(s.structures).length?n=!1:i.cfg.mmtfid||i.cfg.pdbid||i.cfg.opmid||i.cfg.mmdbid||i.cfg.gi||i.cfg.uniprotid||i.cfg.blast_rep_id||i.cfg.cid||i.cfg.mmcifid||i.cfg.align||i.cfg.chainalign||(n=!0),(!s.bSecondaryStructure||n)&&Object.keys(s.proteins).length>0&&!t?await this.applyCommandDssp(e):(await this.loadPdbDataRender(e),i.bNode||await s.ParserUtilsCls.checkMemProteinAndRotate())}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 parent 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+Object.keys(e.defNames2Residues).length+1);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){console.log("RMSD from VAST is larger than 5. Realign the chains with TM-align.");let e=Object.keys(d);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&&b.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 b(s,t):new C(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}(),C=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}(),b=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(s.bNode)return;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 C,b,y,v,_,w={},S="",A="",x="",k="",O="",R="",I=0,E=0,T="",P=!0,D=!1,M="",F=c.utilsCls.isCalphaPhosOnly(h),H=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(C=n.ids.m,void 0!==d.molid2chain[C]){let e=d.molid2chain[C].indexOf("_");n.chain=d.molid2chain[C].substr(e+1)}else{let e="Misc";("protein"===g[O]&&"nucleotide"===g[O]&&n.resi!=E||"protein"!==g[O]&&"nucleotide"!==g[O]&&(n.resn.substr(0,3)!=T.substr(0,3)||n.resi!=E||"solvent"===g[O]||"HOH"===n.resn))&&++H,n.resi_ori=n.resi,n.resi=H,l=!0,n.chain=e}else if("align"===s)if(C=n.ids.m,void 0!==d.pdbid_molid2chain[i+"_"+C])n.chain=d.pdbid_molid2chain[i+"_"+C];else{let e="Misc";("protein"===g[O]&&"nucleotide"===g[O]&&n.resi!=E||"protein"!==g[O]&&"nucleotide"!==g[O]&&(n.resn.substr(0,3)!=T.substr(0,3)||n.resi!=E||"solvent"===g[O]||"HOH"===n.resn))&&(++H,n.resi_ori=n.resi,n.resi=H,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=b,_=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="protein"===g[O],a="nucleotide"===g[O],u="solvent"===g[O],N="ligand"===g[O]||void 0!==g[O]&&-1!==g[O].indexOf("other")||void 0===g[O];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||F&&"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||(b=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 B="-";if("helix"===n.ss?B="H":"sheet"===n.ss?B="E":n.het||a?B="o":(!n.het&&c.parasCls.residueColors.hasOwnProperty(n.resn.toUpperCase())||"coil"===n.ss)&&(B="c"),d.secondaries[n.structure+"_"+n.chain+"_"+n.resi]=B,(n.resi!=I||C!=M)&&d.bFullUi&&(void 0===d.chainsSeq[q]&&(d.chainsSeq[q]=[],P=!1),!isNaN(n.resi)&&null!==n.resi))if(P&&!D&&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),D=!0}I=n.resi,E=n.resi_ori,T=n.resn,S=k,A=O,x=R,M=C}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||F&&"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 C=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],b=r.sequence[e][3]?1:0,y=c[e].aligned+b;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=".";C%5==0&&(x="*"),C%10==0&&(x="|"),s.alnChainsAnno[d][2].push(x);let k="";C%10==0&&(k=C.toString()),s.alnChainsAnno[d][3].push(k),++C}}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;return t&&"tmalign"==l.cfg.aligntool?i=s:(s>n.chainsSeq[e].length-1&&(console.log("Error: the position "+s+" exceeds the max index "+(n.chainsSeq[e].length-1)),s=n.chainsSeq[e].length-1),i=n.chainsSeq[e][s].resi),i}setSeqAlignChain(e,t,s){let i,n,l,r,o,a,d,c,h,p,m,u=this.icn3d,g=u.icn3dui,f={},C=!!s;if(C){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 b=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=b+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.split("_")[2])-parseInt(t.split("_")[2])}));let m=-999,u=0,g=0,f=[],C=0;for(let e=0,t=p.length;e0&&i.resid2ncbi[s]!=i.resid2ncbi[m]+1&&i.resid2ncbi[s]!=i.resid2ncbi[m]){g=m;for(let e=0,t=f.length;ec)continue;let p={},m=r.indexOf("_");p.mmdbid=r.substr(0,m),p.chain=r.substr(m+1),p.resi=t,p.resn=a[s]?i.chainsSeq[r][e].name.toUpperCase():i.chainsSeq[r][e].name.toLowerCase(),p.aligned=!!a[s],p.color=a[s]?"#FF0000":n.htmlCls.GREYC,p.color2=a[s]?"#FF0000":n.htmlCls.GREYC,p.class=a[s]?"icn3d-align":"icn3d-nalign",i.alnChainsSeq[r].push(p),a[s]&&($.extend(i.alnChains[r],i.residues[r+"_"+p.resi]),l=n.hashUtilsCls.unionHash(l,i.residues[r+"_"+p.resi]))}let b=[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 C,b,y,v,_,w,S,A,x,k=[],O=[],R=[],I=[],E=[],T=[],P="",D="",M="",F={},H=t||c.defaultPdbId,L=H,N="",q=!1,U=!0;for(let e in u){let r=u[e],B=r.substr(0,6);if("HEADER"!==B||q||t)if("TITLE "===B){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[L]=c.molTitle}else if("HELIX "===B){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=L+"_"+e+"_"+i;I.push(n),i===t&&E.push(n),i===s&&T.push(n)}}else if("SHEET "===B){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=L+"_"+e+"_"+s;k.push(n),s===t&&O.push(n),s===i&&R.push(n)}}else if("HBOND "===B)void 0!==s&&s||(c.bSecondaryStructure=!0);else if("SSBOND"===B){c.bSsbondProvided=!0;let e=L+"_"+(" "==r.substr(15,1)?"A":r.substr(15,1))+"_"+r.substr(17,4).trim(),t=L+"_"+(" "==r.substr(29,1)?"A":r.substr(29,1))+"_"+r.substr(31,4).trim();void 0===c.ssbondpnts[L]&&(c.ssbondpnts[L]=[]),c.ssbondpnts[L].push(e),c.ssbondpnts[L].push(t)}else if("REMARK"===B){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=H+"_"+t;void 0===c.chainMissingResidueArray[i]&&(c.chainMissingResidueArray[i]=[]);let n={};n.resi=s,n.name=h.utilsCls.residueName2Abbr(e).toLowerCase(),""!=N&&t==N&&t!=N||(c.chainMissingResidueArray[i].push(n),N=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"===B&&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"===B)++d,H=c.defaultPdbId,L=this.getStructureId(H,d,n),m||(k=[],O=[],R=[],I=[],E=[],T=[]),q=!1;else if("JRNL "===B)"PMID"===r.substr(12,4)&&(c.pmid=r.substr(19).trim());else if("ATOM "===B||"HETATM"===B){A=r.substr(72,4).trim(),U?(L=this.getStructureId(H,d,n),U=!1):A!=x&&(++d,H=c.defaultPdbId,L=this.getStructureId(H,d,n),m||(k=[],O=[],R=[],I=[],E=[],T=[]),q=!1),x=A;let e=r.substr(16,1);++a,F[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),N=r.substr(20,2).trim();""===N&&(N="A");let $=r.substr(22,5).trim(),j=$;if(s&&"DUM"===u&&(t=l,N="MEM",j=1,$=1),i&&"DUM"===u)break;C=L+"_"+N,y=C+"_"+$,b=C+"_"+j;let z=parseFloat(r.substr(30,8)),G=parseFloat(r.substr(38,8)),V=parseFloat(r.substr(46,8)),W=new THREE.Vector3(z,G,V),Y=parseFloat(r.substr(60,8));o&&(Y*=100);let X={het:"H"===B[0],serial:a,name:l,alt:e,resn:u,structure:L,chain:N,resi:j,coord:W,b:Y,elem:t,bonds:[],ss:"coil",ssbegin:!1,ssend:!1};if(X.het||"C"!==X.name||(v=a),X.het||"O"!==X.name||(w=a),!X.het&&"N"===X.name&&void 0!==_&&void 0!==S){let e=c.atoms[_].coord.distanceTo(c.atoms[S].coord),t=X.coord.x+(c.atoms[_].coord.x-c.atoms[S].coord.x)/e,s=X.coord.y+(c.atoms[_].coord.y-c.atoms[S].coord.y)/e,i=X.coord.z+(c.atoms[_].coord.z-c.atoms[S].coord.z)/e;X.hcoord=new THREE.Vector3(t,s,i)}c.atoms[a]=X,c.dAtoms[a]=1,c.hAtoms[a]=1,p[a]=1,this.isSecondary(b,k,m)?(c.atoms[a].ss="sheet",this.isSecondary(b,O,m)&&(c.atoms[a].ssbegin=!0),this.isSecondary(b,R,m)&&(c.atoms[a].ssend=!0)):this.isSecondary(b,I,m)&&(c.atoms[a].ss="helix",this.isSecondary(b,E,m)&&(c.atoms[a].ssbegin=!0),this.isSecondary(b,T,m)&&(c.atoms[a].ssend=!0));let K="-";if(K="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[b]=K,y!==M){let e=h.utilsCls.residueName2Abbr(u);if(c.residueId2Name[b]=e,1!==a&&""!==D&&(c.residues[D]=f),b!==D&&(f={}),C!==P){_=void 0,S=void 0,1!==a&&""!==P&&(void 0===c.chains[P]&&(c.chains[P]={}),c.chains[P]=h.hashUtilsCls.unionHash(c.chains[P],g)),g={},void 0===c.structures[L.toString()]&&(c.structures[L.toString()]=[]),c.structures[L.toString()].includes(C)||c.structures[L.toString()].push(C),void 0===c.chainsSeq[C]&&(c.chainsSeq[C]=[]);let t={};t.resi=j,t.name=e,c.chainsSeq[C].push(t)}else{_=v,S=w;let t={};t.resi=j,t.name=e,c.chainsSeq[C].push(t)}}g[a]=1,f[a]=1,P=C,D=b,M=y}else if("CONECT"===B){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[F[e]]&&c.atoms[F[e]].bonds.push(F[s])}}else B.substr(0,3);else H=r.substr(62).trim(),""==H&&(H=l?c.defaultPdbId:c.inputid&&-1==c.inputid.indexOf("/")?c.inputid.substr(0,10):c.defaultPdbId),L=this.getStructureId(H,d,n),c.molTitle="",c.molTitleHash={},q=!0}c.residues[b]=f,void 0===c.chains[C]&&(c.chains[C]={}),c.chains[C]=h.hashUtilsCls.unionHash2Atoms(c.chains[C],g,c.atoms),this.adjustSeq(c.chainMissingResidueArray);let B=Object.keys(c.structures);for(let e=0,t=B.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,i){if(this.icn3d.icn3dui,i)return!1;if(s){let s=e.substr(e.indexOf("_")+1),i=!1;for(let e=0,n=t.length;er.maxatomcnt);T||(r.opts.proteins="c alpha trace",r.opts.nucleotides="o3 trace");let P,D=I.getColumn("group_PDB"),M=I.getColumn("label_comp_id"),F=I.getColumn("type_symbol"),H=I.getColumn("label_atom_id"),L=I.getColumn("auth_asym_id"),N=I.getColumn("label_seq_id"),q=I.getColumn("auth_seq_id"),U=I.getColumn("label_alt_id"),B=I.getColumn("B_iso_or_equiv"),$=I.getColumn("Cartn_x"),j=I.getColumn("Cartn_y"),z=I.getColumn("Cartn_z"),G=I.getColumn("label_asym_id"),V={},W="",Y={};for(let e=0;e0&&(X[r]=a,a=[]),a.push({resi:l,name:o.utilsCls.residueName2Abbr(d)}),r=c}X[r]=a,t=s=i=n=[]}this.setSeq(x,Y,X,V)}let R=Object.keys(r.structures);for(let e=0,t=R.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 ps{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("set annotation ig"==n)t.bRunRefnumAgain=!0,await t.annotationCls.setAnnoTabIg(),t.bRunRefnumAgain=!1;else if("ig refnum on"==n)t.bRunRefnumAgain=!0,t.bAnnoShown||await t.showAnnoCls.showAnnotations(),await t.annotationCls.setAnnoTabIg(!0),t.bRunRefnumAgain=!1;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 ig labels"==n)t.residueLabelsCls.addIgLabels(t.hAtoms),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.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(),t.bDefinedSets=!0;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 iganchor sets")){let e=i.split(" | ")[1].split(" ")[1];t.addTrackCls.defineIgstrand(e,"iganchor")}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"),t.bDefinedSets||(t.definedSetsCls.setPredefinedInMenu(),t.bDefinedSets=!0);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(i,"sphere"),t.shapeCmdHash[i]=1;else if(0==n.indexOf("add cube"))this.addShape(i,"cube"),t.shapeCmdHash[i]=1;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","Distances among the sets")}}}else if(0==i.indexOf("angletable")){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.measureAngleManySets(e,n),s.htmlCls.dialogCls.openDlg("dl_angletable","Angles 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()}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(0==n.indexOf("translate pdb")){let e=n.substr(14).split(" ");t.transformCls.translateCoord(t.hAtoms,parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2])),t.drawCls.draw()}else if(0==n.indexOf("rotate pdb")){let e=n.substr(11).split(","),s=[];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,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,c=i.parasCls.thr(r);if("x1"==l[0])d=new THREE.Vector3(parseFloat(l[1]),parseFloat(l[3]),parseFloat(l[5]));else{let e=n[1].split(","),t=s.definedSetsCls.getAtomsFromNameArray(e),i=s.contactCls.getExtent(t);d=new THREE.Vector3(i[2][0],i[2][1],i[2][2])}"sphere"==t?s.sphereCls.createSphereBase(d,c,parseFloat(a),void 0,void 0,void 0,parseFloat(o)):s.boxCls.createBox_base(d,parseFloat(a),c,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':"set annotation ig"==e?t+': "Ig Domains" 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 Ig domain labels"==e?o+"per Ig Domain":"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 ms{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&&s.atoms[e[0]]}else if(void 0!==s.defNames2Residues&&s.defNames2Residues.hasOwnProperty(o)){let e=s.defNames2Residues[o];e.length>0&&(r=s.residues[e[0]],r&&s.atoms[Object.keys(r)[0]])}-1!=n.indexOf(o)?i+="":i+=""}return i}reset(){let e=this.icn3d;e.atoms={},e.proteins={},e.nucleotides={},e.chemicals={},e.ions={},e.water={},e.structures={},e.chains={},e.chainsSeq={},e.residues={},e.defNames2Atoms={},e.defNames2Residues={},e.ssbondpnts={},e.bShowHighlight=void 0,e.bResetSets=!0}dictionaryDifference(e,t){const s={};for(let i in t)i in e||(s[i]=t[i]);return s}clickStructure(){let e=this.icn3d,t=e.icn3dui,s=this;null==e.allData&&(e.allData={},e.allData.all={atoms:{},proteins:{},nucleotides:{},chemicals:{},ions:{},water:{},structures:{},ssbondpnts:{},residues:{},chains:{},chainsSeq:{},defNames2Atoms:{},defNames2Residues:{}},e.allData.prev={}),$("#"+e.pre+"collections_menu").change((async function(e){let i=s.icn3d,n=$(this).val(),l=$(this).find("option:selected").text();if(i.nameArray=n,null!==n){let e=!0;s.reset();for(const t of n)t in i.allData||(i.allData.prev=JSON.parse(JSON.stringify(i.allData.all)),i.atoms=i.allData.all.atoms,i.proteins=i.allData.all.proteins,i.nucleotides=i.allData.all.nucleotides,i.chemicals=i.allData.all.chemicals,i.ions=i.allData.all.ions,i.water=i.allData.all.water,i.structures=i.allData.all.structures,i.ssbondpnts=i.allData.all.ssbondpnts,i.residues=i.allData.all.residues,i.chains=i.allData.all.chains,i.chainsSeq=i.allData.all.chainsSeq,i.defalls2Atoms=i.allData.all.defalls2Atoms,i.defalls2Residues=i.allData.all.defalls2Residues,await i.chainalignParserCls.downloadMmdbAf(t,void 0,void 0,e).then((()=>{i.allData.all={atoms:i.atoms,proteins:i.proteins,nucleotides:i.nucleotides,chemicals:i.chemicals,ions:i.ions,water:i.water,structures:i.structures,ssbondpnts:i.ssbondpnts,residues:i.residues,chains:i.chains,chainsSeq:i.chainsSeq,defNames2Atoms:i.defNames2Atoms,defNames2Residues:i.defNames2Residues},i.allData[t]={atoms:s.dictionaryDifference(i.allData.prev.atoms,i.atoms),proteins:s.dictionaryDifference(i.allData.prev.proteins,i.proteins),nucleotides:s.dictionaryDifference(i.allData.prev.nucleotides,i.nucleotides),chemicals:s.dictionaryDifference(i.allData.prev.chemicals,i.chemicals),ions:s.dictionaryDifference(i.allData.prev.ions,i.ions),water:s.dictionaryDifference(i.allData.prev.water,i.water),structures:s.dictionaryDifference(i.allData.prev.structures,i.structures),ssbondpnts:s.dictionaryDifference(i.allData.prev.ssbondpnts,i.ssbondpnts),residues:s.dictionaryDifference(i.allData.prev.residues,i.residues),chains:s.dictionaryDifference(i.allData.prev.chains,i.chains),chainsSeq:s.dictionaryDifference(i.allData.prev.chainsSeq,i.chainsSeq),defNames2Atoms:s.dictionaryDifference(i.allData.prev.defNames2Atoms,i.defNames2Atoms),defNames2Residues:s.dictionaryDifference(i.allData.prev.defNames2Residues,i.defNames2Residues)},s.reset()})));for(const e of n)i.atoms=Object.assign(i.atoms,i.allData[e].atoms),i.proteins=Object.assign(i.proteins,i.allData[e].proteins),i.nucleotides=Object.assign(i.nucleotides,i.allData[e].nucleotides),i.chemicals=Object.assign(i.chemicals,i.allData[e].chemicals),i.ions=Object.assign(i.ions,i.allData[e].ions),i.water=Object.assign(i.water,i.allData[e].water),i.structures=Object.assign(i.structures,i.allData[e].structures),i.ssbondpnts=Object.assign(i.ssbondpnts,i.allData[e].ssbondpnts),i.residues=Object.assign(i.residues,i.allData[e].residues),i.chains=Object.assign(i.chains,i.allData[e].chains),i.chainsSeq=Object.assign(i.chainsSeq,i.allData[e].chainsSeq),i.defNames2Atoms=Object.assign(i.defNames2Atoms,i.allData[e].defNames2Atoms),i.defNames2Residues=Object.assign(i.defNames2Residues,i.allData[e].defNames2Residues),i.dAtoms=t.hashUtilsCls.cloneHash(i.atoms),i.hAtoms=t.hashUtilsCls.cloneHash(i.atoms);i.opts.color=1==Object.keys(i.structures).length?"chain":"structure",i.setColorCls.setColorByOptions(i.opts,i.atoms),i.transformCls.zoominSelection(),i.definedSetsCls.showSets(),i.bResetAnno=!0,i.bAnnoShown&&(await i.showAnnoCls.showAnnotations(),i.hlUpdateCls.updateHlAll(n),i.annotationCls.showAnnoSelectedChains()),await i.drawCls.draw(),i.saveFileCls.showTitle(),t.htmlCls.clickMenuCls.setLogCmd("select structure ["+l+"]",!0)}})),t.myEventCls.onIds("#"+e.pre+"collections_menu","focus",(function(e){let i=s.icn3d;t.utilsCls.isMobile()&&$("#"+i.pre+"collections_menu").val("")}))}}class gs{constructor(e){this.icn3d=e}async loadScript(e,t,s){let i=this.icn3d;if(i.icn3dui,!e)return;i.bCommandLoad=!0,i.bRender=!1,i.bStopRotate=!0,e=t?e.replace(/\+/g," "):e.replace(/\+/g," ").replace(/;/g,"\n");let n=[];!s&&i.commands.length>0&&(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}updateTransformation(e){let t=this.icn3d;t.icn3dui;let s=t.commands[e-1]?t.commands[e-1].split("|||"):[];if(2==s.length){let e=JSON.parse(s[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}t.drawCls.draw()}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 template")){let e=d.substr(d.lastIndexOf(" ")+1);await r.htmlCls.clickMenuCls.setIgTemplate(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"))l.bRender=!0,o.updateTransformation(s),await o.applyCommandCartoon2d(d),l.bRender=!1;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);l.bRender=!0,o.updateTransformation(s),await l.cartoon2dCls.draw2Dcartoon(t),l.bRender=!1}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);4==l.length&&(l=l.toUpperCase());let r=l.split(","),o="";for(let e=0,s=r.length;e1&&-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[2].indexOf("resdef")+7)),e.length>3&&-1!=e[3].indexOf("aligntool")&&(s.cfg.aligntool=e[3].substr(e[3].indexOf("aligntool")+10)),e.length>5&&-1!=e[5].indexOf("resrange")&&(s.cfg.resrange=e[5].substr(e[5].indexOf("resrange")+9)),s.cfg.chainalign=l,await t.chainalignParserCls.downloadChainalignment(l)}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.densityCifParserCls.densityCifParserBase(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):"rcsbmtz"==l&&await t.mtzParserCls.mtzParserBase(s[1],n,e,"url",i,!0)}else await t.densityCifParserCls.densityCifParser(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 fs{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 b,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 Cs{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==i.pk){let l=!0;this.selectResidueList(i.hAtoms,e,t,void 0,void 0,l),this.updateSelectionNameDesc(),s?n.htmlCls.clickMenuCls.setLogCmd("select "+i.resid2specCls.atoms2spec(i.hAtoms),!0):n.htmlCls.clickMenuCls.setLogCmd("select "+i.resid2specCls.atoms2spec(i.hAtoms)+" | name "+e,!0)}else this.selectResidueList(i.selectedResidues,e,t,void 0,void 0,void 0),this.updateSelectionNameDesc(),s?n.htmlCls.clickMenuCls.setLogCmd("select "+i.resid2specCls.residueids2spec(Object.keys(i.selectedResidues)),!0):n.htmlCls.clickMenuCls.setLogCmd("select "+i.resid2specCls.residueids2spec(Object.keys(i.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 bs{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}resi2range(e){this.icn3d.icn3dui;let t,s,i=[],n=e.sort((function(e,t){return parseInt(e)-parseInt(t)})),l=n[0];for(let e=0,r=n.length;e0&&(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;e=1)for(let t=0,l=r.length;t2540&&u<2560?e=!0:u>3540&&u<3560?t=!0:u>7540&&u<7560?s=!0:u>8540&&u<8560&&(l=!0),2550==u){"helix"==i.firstAtomObjCls.getFirstAtomObj(i.residues[h]).ss&&(r=!1)}else if(3550==u){"helix"==i.firstAtomObjCls.getFirstAtomObj(i.residues[h]).ss&&(o=!1)}else if(7550==u){"helix"==i.firstAtomObjCls.getFirstAtomObj(i.residues[h]).ss&&(d=!1)}else if(8550==u){"helix"==i.firstAtomObjCls.getFirstAtomObj(i.residues[h]).ss&&(p=!1)}if(e&&t&&s&&l)break}if(!(e&&t&&s&&l&&r&&o&&d&&p)){n.bNode||e&&t&&s&&l||console.log("Some of the Ig strands B, C, E, F are missing in the domain "+c+"..."),n.bNode||r&&o&&d&&p||console.log("Some of the Ig strands B, C, E, F are not beta sheets..."),i.domainid2refpdbname[c][0]==h&&(delete i.domainid2refpdbname[c],delete i.domainid2score[c]);continue}}s||n.bNode||console.log("domainid: "+c),(!l.hasOwnProperty(c)||d>=parseFloat(i.domainid2score[c].split("_")[0]))&&(i.domainid2score[c]=a[0].score+"_"+a[0].frac_identical+"_"+a[0].num_res,i.domainid2refpdbname[c]=s?d>=this.TMThresholdIgType?[h]:["all_templates"]:[h],l[c]=a[0].segs,i.domainid2ig2kabat[c]=a[0].ig2kabat,i.domainid2ig2imgt[c]=a[0].ig2imgt)}if(s)for(let e in r)if(!n.bNode&&"all_templates"==i.domainid2refpdbname[e][0]){let t=r[e],s=Object.keys(t);s.sort((function(e,s){return t[s]-t[e]})),i.domainid2refpdbname[e]=s.slice(0,this.topClusters)}return l}async parseAlignData(e,t,s){let i=this.icn3d,n=i.icn3dui,l=!1,r=this.parseAlignData_part1(e,t,s);if(0==Object.keys(r).length)return l=!0,l;if(s){n.bNode||console.log("Start round 2 alignment with the reference culsters "+JSON.stringify(i.domainid2refpdbname));let e=[],t=[],s=n.htmlCls.tmalignUrl;for(let l in i.domainid2refpdbname){let r=[],o=i.domainid2refpdbname[l],a=l.substr(0,l.indexOf(","));i.refpdbHash.hasOwnProperty(a)&&(o=[a],n.bNode||console.log("Adjusted refpdbname for domainid "+l+": "+a));let d=[];for(let e=0,t=o.length;e=3545&&i.q_start<=3555){let e=t.firstAtomObjCls.getFirstCalphaAtomObj(t.residues[r]);e&&w.push(e)}else if(i.q_start>=7545&&i.q_start<=7555){let e=t.firstAtomObjCls.getFirstCalphaAtomObj(t.residues[r]);e&&S.push(e)}if(-1!=i.q_start.indexOf("8550")&&1==g&&h&&u&&(p||m)){let e=999,t=999;for(let t=0,s=w.length;tt+l||e==t+l&&i>n+l)&&(A.push(p.resi),s.bNode||console.log("Rename strand C' to D: distToC "+e+" distToE "+t+" resiDistToC "+i+" resiDistToE "+n)):v&&(e+l0){for(let e=0,t=A.length;eparseInt(A[e])-10){h="D";break}}else if("D"==f&&x.length>0)for(let e=0,t=x.length;eparseInt(x[e])-10){h="C'";break}f!=h&&(c=this.getLabelFromRefnum(d,o,h)),"helix"!=t.firstAtomObjCls.getFirstAtomObj(t.residues[a]).ss&&(t.resid2refnum[a]=c,t.resid2domainid[a]=i)}}Object.keys(t.resid2refnum).length>0?t.bShowRefnum=!0:s.bNode||t.bNoIg||(console.log("No Ig reference numbers are assigned based on the reference structures in iCn3D..."),t.bNoIg=!0),t.chainid2igtrack||(t.chainid2igtrack={});for(let e in t.chains){let s=t.firstAtomObjCls.getFirstAtomObj(t.chains[e]);if(t.proteins.hasOwnProperty(s.serial)){let s=t.showSeqCls.getSeq(e);t.chainid2igtrack[e]=this.ajdustRefnum(s,e)}}}getStrandFromRefnum(e,t){this.icn3d.icn3dui;let s,i=parseInt(e);return s=i<1e3?void 0:i>=1200&&i<1320?"A---":i>=1320&&i<1420?"A--":i>=1420&&i<1520?"A-":i>=1520&&i<1620?"A":i>=1620&&i<1720?"A+":i>=1720&&i<1820?"A++":i>=1820&&i<2e3?"A'":i>=2e3&&i<3e3?"B":i>=3e3&&i<3420?"C--":i>=3420&&i<3520?"C-":i>=3520&&i<4e3?"C":i>=4e3&&i<5e3?"C'":i>=5e3&&i<6e3?"C''":i>=6e3&&i<7e3?"D":i>=7e3&&i<7620?"E":i>=7620&&i<8e3?"E+":i>=8e3&&i<9e3?"F":i>=9e3&&i<9620?"G":i>=9620&&i<9720?"G+":i>=9720&&i<9820?"G++":i>=9820&&i<9900?"G+++":i>9900?void 0:" ",t&&(s=t),s}getLabelFromRefnum(e,t,s){this.icn3d.icn3dui;let i=this.getStrandFromRefnum(e,s),n=e.toString();return"C'"==s&&"6"==n.substr(0,1)?n="4"+n.substr(1):"D"==s&&"4"==n.substr(0,1)&&(n="6"+n.substr(1)),i?i+n+t:void 0}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;e0){l+='{"'+r+'": {\n';for(let t=0,n=o.length;t=46&&t<=54){let e=t-50;y[_].anchorRefnum=d-e,y[_].resCntBfAnchor=S-e,A=e,x=!0}g&&(y[_].anchorRefnum=0),y[_].strandPostfix=a,y[_].strand=p,y[_].postfix=o,y[_].loopResCnt=w-1,++_,w=0}else if(v[p+o]){if(50==t&&(y[_-1].anchorRefnum=d,y[_-1].resCntBfAnchor=S,y[_-1].startRefnum=y[_-1].anchorRefnum-y[_-1].resCntBfAnchor,A=0,x=!0),!x&&(51==t||52==t||53==t||54==t)){let e=t-50;y[_-1].anchorRefnum=d-e,y[_-1].resCntBfAnchor=S-e,y[_-1].startRefnum=y[_-1].anchorRefnum-y[_-1].resCntBfAnchor,A=e,x=!0}g&&(y[_-1].anchorRefnum=0),y[_-1].domainid=e,y[_-1].endResi=k,y[_-1].endRefnum=d,y[_-1].resCntAtAnchor=A,y[_-1].anchorRefnum&&(y[_-1].endRefnum=y[_-1].anchorRefnum+y[_-1].resCntAtAnchor),w=0}}u=p}}m=p}for(let e=0,i=y.length;e0&&parseInt(l)<=parseInt(y[e-1].endResi))break;let o=t+"_"+l,a=s.firstAtomObjCls.getFirstAtomObj(s.residues[o]),d=s.resid2domainid[o];if(a.ssbegin){let o=y[e].startRefnum;y[e].startResi=l,y[e].startRefnum-=i,y[e].loopResCnt-=i,y[e].loopResCnt<0&&(y[e].loopResCnt=0),y[e].resCntBfAnchor+=i;for(let a=1;a<=i;++a){n=r-a,l=s.ParserUtilsCls.getResi(t,n);let i=t+"_"+l;delete s.residIgLoop[i],s.resid2refnum[i]=y[e].strand+(o-a).toString(),s.resid2domainid[i]=d}break}}if("sheet"==l.ss&&!l.ssend)for(let n=1;n<=8;++n){let l=o+n,r=s.ParserUtilsCls.getResi(t,l);if(e=parseInt(y[e+1].startResi))break;let a=t+"_"+r,d=s.firstAtomObjCls.getFirstAtomObj(s.residues[a]),c=s.resid2domainid[a];if(d.ssend){let a=y[e].endRefnum;y[e].endResi=r,y[e].endRefnum+=n,e=0;--e){"G"!=y[e].strand&&y[e].endRefnum-y[e].startRefnum+1<3&&(y[e+1]&&(y[e+1].loopResCnt+=y[e].loopResCnt+parseInt(y[e].endResi)-parseInt(y[e].startResi)+1),y[e].startResi,y.splice(e,1))}_=0;let O,R,I=0,E=!0,T=!0,P=0;b=!1;let D=0;if(y.length>0)for(let i=0,l=e.length;iy[_].endResi:parseInt(l)>parseInt(y[_].endResi),i=!t&&!r,t)if(s.residIgLoop[o]=1,E)b?(R=y[_].startRefnum-y[_].loopResCnt+I,O=y[_].strand+R,n=O+y[_].strandPostfix,e=y[_].domainid):(O=void 0,n=void 0);else if(P>=0&&("G"==y[P].strand.substr(0,1)||"F"==y[P].strand.substr(0,1)&&"G"!=y[_].strand.substr(0,1)))T?b&&s.resid2refnum[o]?(T=!0,R=y[P].endRefnum+I,O=y[P].strand+R,n=O+y[P].strandPostfix,e=y[P].domainid):(b=!1,E=!0,T=!1,O=void 0,n=void 0):(O=void 0,n=void 0);else{T=!0;let t=y[_].loopResCnt;I<=parseInt(t/2+.5)?y[P]&&(R=y[P].endRefnum+I,O=y[P].strand+R,n=O+y[P].strandPostfix,e=y[P].domainid):(R=y[_].startRefnum-t+I-1,O=y[_].strand+R,n=O+y[_].strandPostfix,e=y[_].domainid)}else i?(E=!1,y[_].anchorRefnum&&(l==y[_].startResi?(D=y[_].anchorRefnum-y[_].resCntBfAnchor,y[_].startRefnum=D):l==y[_].endResi&&(y[_].endRefnum=D),O=y[_].strand+D,n=O+y[_].strandPostfix,e=y[_].domainid),l==y[_].endResi&&(++_,I=0,y[_]||--_)):r&&(s.residIgLoop[o]=1,T?s.resid2refnum[o]?(T=!0,R=y[_].endRefnum+I,O=y[_].strand+R,n=O+y[_].strandPostfix,e=y[_].domainid):(T=!1,O=void 0,n=void 0):(O=void 0,n=void 0))}else n=void 0;m=p,P=_-1,k.hasOwnProperty(e)?(delete s.resid2refnum[o],delete s.residIgLoop[o],delete s.resid2domainid[o]):(s.resid2refnum[o]=n,s.resid2domainid[o]=e,r=s.refnumCls.rmStrandFromRefnumlabel(n),s.refnum2residArray.hasOwnProperty(r)?s.refnum2residArray[r].push(o):s.refnum2residArray[r]=[o],s.chainsMapping.hasOwnProperty(t)||(s.chainsMapping[t]={}),s.chainsMapping[t][o]=O||l)}return!0}}class Ss{constructor(e){this.icn3d=e}async applyCommandScap(e){this.icn3d.icn3dui;let t=e.substr(e.lastIndexOf(" ")+1);0==e.indexOf("scap 3d")?await this.retrieveScap(t):0==e.indexOf("scap interaction")?await this.retrieveScap(t,!0):0==e.indexOf("scap pdb")&&await this.retrieveScap(t,void 0,!0)}adjust2DWidth(e){let t,s,i,n=this.icn3d;if(n.icn3dui,e=n.pre+e,$("#"+n.pre+"dl_selectannotations").hasClass("ui-dialog-content")){t=$("#"+n.pre+"dl_selectannotations").dialog("option","width"),s=.5*$("#"+n.pre+"dl_selectannotations").dialog("option","height"),i=s,$("#"+n.pre+"dl_selectannotations").dialog("option","height",s),$("#"+e).dialog("option","width",t),$("#"+e).dialog("option","height",s);let l={my:"left top",at:"right top+"+i,of:"#"+n.pre+"viewer",collision:"none"};$("#"+e).dialog("option","position",l)}}async retrieveScap(e,t,s){let i=this.icn3d,n=i.icn3dui,l=this;i.bScap=!0;let r="",o=e.split(","),a={},d=[],c={};for(let e=0,t=o.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,C=0,b={};for(let e=0,s=n[0].length;et&&(t=b[s].length,e=s);let s=Object.keys(p),i=Object.keys(m);for(let t=0,n=b[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 xs{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,C=[],b=[],y=[],v=0,_=-1,w=-1;if(e)for(let e=0;e<=d;++e)C[e]=b[e]=0;else{C[0]=0,b[0]=-g-g;for(let e=1;e<=d;++e)e>=l?C[e]=b[e]=f:(C[e]=-(g+p*(e-1)),b[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,b[t]=o,n-=p,l|=n>a?32:0,n=n>a?n:a,s[t]=l}C[u]=i,b[u]=e?0:f,r>v&&(v=r,_=t,w=c)}if(e&&0==v)return null;u=e?v:C[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 ks{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 C=(parseFloat(d)+parseFloat(o)-parseFloat(h)).toFixed(2),b="
    Calculate solvent accessible surface area in the interface:

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

    ",$("#"+s.pre+"dl_buriedarea_html").html(b),i.htmlCls.dialogCls.openDlg("dl_buriedarea","Buried solvent accessible surface area in the interface"),i.htmlCls.clickMenuCls.setLogCmd("buried surface "+C,!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)}}measureAngleManySets(e,t){var s=this.icn3d,i=s.icn3dui;if(0==e.length||0==t.length)alert("Please select sets for angleance calculation...");else{let n={};for(let i=0,l=e.length;i180&&(d-=180),d>90&&(d=180-d),n[l][i]=d}}let l="";for(let e=0,s=t.length;e"+t[e]+" (°)"}l+="";for(let s=0,i=e.length;s";for(let e=0,s=t.length;e"+n[i][s]+"":l+=""}l+=""}l+="
    "+i+" (°)0


    ",$("#"+i.pre+"dl_angletable_html").html(l)}}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 Os{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="",C={};if(i)for(let e in n.dAtoms){let t=n.atoms[e];C[c[t.structure+"_"+t.chain]]=1}let b=Object.keys(e.moleculeInfor),y=Object.keys(e.intrac),v=[];for(let e=0,t=b.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,C,b,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,C=t+i,b=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,C=t,b=e,y=t-i}let _=p-e,w=m-t,S=u-e,A=g-t,x=f-e,k=C-t,O=b-e,R=y-t,I="";return I+="Chain "+i+": "+l+"",I+="",I+="",I+=""+n+"",""!==r&&(I+=""+r+""),I+="",I}}class Rs{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,C=!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],C=r.atoms[f];l=d,c=this.projectTo2d(c);let b=c.x,y=c.y;bn&&(n=b),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:b,y:y,rx:m,ry:u,ang:g,c:C.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,C=!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:b,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[C],w=f[C];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 E=A.x,T=A.y;Ec&&(c=E),Th&&(h=T);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!==b&&n.push('{"source": "'+b+'", "target": "'+v+'", "v": '+l+', "c": "'+y.color.getHexString().toUpperCase()+'"}'),m.push({id:v,from:_+"",to:w+"",x:E,y:T,rx:x,ry:k,ang:O,c:I.color.getHexString()}),b=v,y=I}}let g=p+2,f=c-a,C=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","dl_translate"];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 Es{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;if(!e)return;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()}translateCoord(e,t,s,i){let n=this.icn3d;n.icn3dui;for(let l in e){let e=n.atoms[l];e.coord.x+=t,e.coord.y+=s,e.coord.z+=i}}rotateCoord(e,t){let s=this.icn3d;s.icn3dui;const i=new THREE.Matrix4;i.elements=t;for(let t in e){let e=s.atoms[t];e.coord=e.coord.applyMatrix4(i)}}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 Ts{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 C,b,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 C=e.resi;!isNaN(C)&&e.chain.length>3&&!isNaN(e.chain.substr(3))&&(C=C-1+parseInt(e.chain.substr(3)));let b=parseInt(C);m+=b.toString().length<=4?b.toString().padStart(4," "):b.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 Ps{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 C,b=c+1,y="";for(let e=s.commands.length;b0&&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&&(C=Object.keys(s.structures)[0],n=n.replace(new RegExp(C+"_","g"),"!"),l=l.replace(new RegExp(C+"_","g"),"!")),void 0!==i.cfg.blast_rep_id&&(n=n.replace(new RegExp("blast_rep_id=!","g"),"blast_rep_id="+C+"_")),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+="pdb\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 Ds{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 Hs{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 Ls{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 Ns{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 qs{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 Us{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 Ee(this),this.fogCls=new Te(this),this.boxCls=new Pe(this),this.brickCls=new De(this),this.curveStripArrowCls=new Me(this),this.curveCls=new Fe(this),this.cylinderCls=new He(this),this.lineCls=new Le(this),this.reprSubCls=new Ne(this),this.sphereCls=new qe(this),this.stickCls=new Ue(this),this.strandCls=new Be(this),this.stripCls=new $e(this),this.tubeCls=new je(this),this.cartoonNuclCls=new ze(this),this.surfaceCls=new Ze(this),this.labelCls=new Ve(this),this.axesCls=new We(this),this.glycanCls=new Ye(this),this.applyCenterCls=new Qe(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 ys(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.loadCIFCls=new cs(this),this.vastplusCls=new hs(this),this.transformCls=new Es(this),this.setStyleCls=new ft(this),this.setColorCls=new Ct(this),this.threeDPrintCls=new Ds(this),this.export3DCls=new Ms(this),this.annoCddSiteCls=new vt(this),this.annoContactCls=new _t(this),this.annoPTMCls=new wt(this),this.annoIgCls=new St(this),this.annoCrossLinkCls=new At(this),this.annoDomainCls=new xt(this),this.annoSnpClinVarCls=new kt(this),this.annoSsbondCls=new Ot(this),this.annoTransMemCls=new Rt(this),this.domain3dCls=new It(this),this.addTrackCls=new Et(this),this.annotationCls=new Tt(this),this.showAnnoCls=new Pt(this),this.showSeqCls=new Dt(this),this.hlSeqCls=new Mt(this),this.hlUpdateCls=new Ft(this),this.lineGraphCls=new Lt(this),this.getGraphCls=new Nt(this),this.showInterCls=new qt(this),this.viewInterPairsCls=new Ut(this),this.drawGraphCls=new Bt(this),this.contactMapCls=new $t(this),this.alignParserCls=new jt(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.bcifParserCls=new Zt(this),this.mol2ParserCls=new Qt(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 ps(this),this.definedSetsCls=new ms(this),this.selectCollectionsCls=new us(this),this.legendTableCls=new yt(this),this.loadScriptCls=new gs(this),this.selByCommCls=new fs(this),this.selectionCls=new Cs(this),this.resid2specCls=new bs(this),this.delphiCls=new vs(this),this.dsspCls=new _s(this),this.refnumCls=new ws(this),this.scapCls=new Ss(this),this.symdCls=new As(this),this.alignSWCls=new xs(this),this.analysisCls=new ks(this),this.resizeCanvasCls=new Is(this),this.saveFileCls=new Ts(this),this.setOptionCls=new bt(this),this.shareLinkCls=new Ps(this),this.diagram2dCls=new Os(this),this.cartoon2dCls=new Rs(this),this.rayCls=new Fs(this),this.controlCls=new Hs(this),this.pickingCls=new Ls(this),this.VRButtonCls=new Ns(this),this.ARButtonCls=new qs(this),this.matShader=this.setColorCls.setOutlineColor("yellow")}}Us.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=[]},Us.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},Us.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},Us.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 Bs{constructor(e){this.cfg=e,this.pre=this.cfg.divid+"_",this.REVISION="3.33.3",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(){}}Bs.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,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.bcifid||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.bcifParserCls.downloadBcif(t.cfg.mmtfid);else if(void 0!==t.cfg.bcifid)s.inputid=t.cfg.bcifid,s.loadCmd="load bcif "+t.cfg.bcifid,t.htmlCls.clickMenuCls.setLogCmd(s.loadCmd,!0),await s.bcifParserCls.downloadBcif(t.cfg.bcifid);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 Us(e),e.icn3d.controlCls.setControl(),e.setDialogAjax()},Bs.prototype.getMmtfPromise=function(e){return new Promise((function(t,s){MMTF.fetch(e,(async function(e){t(e)}),(function(e){s("error")}))}))},Bs.prototype.getMmtfReducedPromise=function(e){return new Promise((function(t,s){MMTF.fetchReduced(e,(async function(e){t(e)}),(function(e){s("error")}))}))},Bs.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 electron density map for this structure."):alert("The "+i+" file is unavailable..."),r("error");else n.icn3d.ParserUtilsCls.showLoading()},o.send()}))},Bs.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")}})}))},Bs.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(){!a.bNode&&i&&console.log(i),!a.bNode&&n&&console.log(n),o("error")}})}))},Bs.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=qs,e.AddTrack=Et,e.AlignParser=jt,e.AlignSW=xs,e.AlignSeq=m,e.Alternate=ct,e.Analysis=ks,e.AnnoCddSite=vt,e.AnnoContact=_t,e.AnnoCrossLink=At,e.AnnoDomain=xt,e.AnnoSnpClinVar=kt,e.AnnoSsbond=Ot,e.AnnoTransMem=Rt,e.Annotation=Tt,e.ApplyCenter=Qe,e.ApplyClbonds=et,e.ApplyCommand=ps,e.ApplyDisplay=st,e.ApplyMap=rt,e.ApplyOther=it,e.ApplySsbonds=nt,e.ApplySymd=lt,e.Axes=We,e.Box=Pe,e.Brick=De,e.Camera=Ee,e.CartoonNucl=ze,e.ChainalignParser=zt,e.ClickMenu=a,e.Contact=pt,e.Control=Hs,e.ConvertTypeCls=o,e.Curve=Fe,e.CurveStripArrow=Me,e.Cylinder=He,e.DefinedSets=ms,e.Delphi=vs,e.DensityCifParser=ls,e.Diagram2d=Os,e.Dialog=c,e.Domain3d=It,e.Draw=ht,e.DrawGraph=Bt,e.Dsn6Parser=Gt,e.Dssp=_s,e.ElectronMap=Je,e.Events=p,e.Export3D=Ms,e.FirstAtomObj=ys,e.Fog=Te,e.GetGraph=Nt,e.Glycan=Ye,e.HBond=mt,e.HashUtilsCls=t,e.HlObjects=Ht,e.HlSeq=Mt,e.HlUpdate=Ft,e.Html=g,e.Impostor=at,e.Instancing=dt,e.Label=Ve,e.Line=Le,e.LineGraph=Lt,e.LoadAtomData=os,e.LoadCIF=cs,e.LoadPDB=ds,e.LoadScript=gs,e.MarchingCube=Xe,e.MmcifParser=Kt,e.MmdbParser=Jt,e.Mol2Parser=Qt,e.MyEventCls=n,e.OpmParser=es,e.ParasCls=i,e.ParserUtils=rs,e.PdbParser=ts,e.PiHalogen=ut,e.Picking=Ls,e.ProteinSurface=Ke,e.Ray=Fs,e.RealignParser=ns,e.Refnum=ws,e.ReprSub=Ne,e.Resid2spec=bs,e.ResidueLabels=ot,e.ResizeCanvas=Is,e.RmsdSuprCls=l,e.Saltbridge=gt,e.SaveFile=Ts,e.Scap=Ss,e.Scene=Ie,e.SdfParser=ss,e.SelectByCommand=fs,e.Selection=Cs,e.SetColor=Ct,e.SetDialog=h,e.SetHtml=u,e.SetMenu=d,e.SetOption=bt,e.SetSeqAlign=as,e.SetStyle=ft,e.ShareLink=Ps,e.ShowAnno=Pt,e.ShowInter=qt,e.ShowSeq=Dt,e.Sphere=qe,e.Stick=Ue,e.Strand=Be,e.Strip=$e,e.SubdivideCls=r,e.Surface=Ze,e.Symd=As,e.ThreeDPrint=Ds,e.Transform=Es,e.Tube=je,e.UtilsCls=s,e.VRButton=Ns,e.Vastplus=hs,e.ViewInterPairs=Ut,e.XyzParser=is,e.iCn3D=Us,e.iCn3DUI=Bs,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 7fcabe2d..42cd7f31 100644 --- a/build/icn3d.module.js +++ b/build/icn3d.module.js @@ -11301,8 +11301,8 @@ class ClickMenu { //if(!me.cfg.notebook) dialog.dialog( "close" ); 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); + //await ic.dsn6ParserCls.dsn6Parser(ic.inputid, type, sigma2fofc); + await ic.densityCifParserCls.densityCifParser(ic.inputid, type, sigma2fofc); //ic.setOptionCls.setOption('map', '2fofc'); thisClass.setLogCmd('set map 2fofc sigma ' + sigma2fofc, true); @@ -11314,7 +11314,8 @@ class ClickMenu { //if(!me.cfg.notebook) dialog.dialog( "close" ); let sigmafofc = parseFloat($("#" + me.pre + "sigmafofc" ).val()); let type = 'fofc'; - await ic.dsn6ParserCls.dsn6Parser(ic.inputid, type, sigmafofc); + //await ic.dsn6ParserCls.dsn6Parser(ic.inputid, type, sigmafofc); + await ic.densityCifParserCls.densityCifParser(ic.inputid, type, sigma2fofc); //ic.setOptionCls.setOption('map', 'fofc'); thisClass.setLogCmd('set map fofc sigma ' + sigmafofc, true); }); @@ -11863,6 +11864,18 @@ class ClickMenu { me.htmlCls.dialogCls.openDlg('dl_contact', 'Set contact map'); }); + me.myEventCls.onIds(["#" + me.pre + "mn6_DSSP"], "click", async function(e) { let ic = me.icn3d; //e.preventDefault(); + thisClass.setLogCmd('set dssp sse', true); + await ic.pdbParserCls.applyCommandDssp(); + ic.bResetAnno = true; + + if(ic.bAnnoShown) { + await ic.showAnnoCls.showAnnotations(); + + ic.annotationCls.resetAnnoTabAll(); + } + }); + me.myEventCls.onIds("#" + me.pre + "mn6_hbondsNo", "click", function(e) { let ic = me.icn3d; //e.preventDefault(); ic.showInterCls.hideHbondsContacts(); @@ -13783,6 +13796,8 @@ class SetMenu { html += ""; html += ""; + html += this.getLink('mn6_DSSP', 'DSSP Secondary', undefined, 1); + let bOnePdb = me.cfg.mmtfid !== undefined || me.cfg.pdbid !== undefined || me.cfg.opmid !== undefined || me.cfg.mmcifid !== undefined || me.cfg.mmdbid !== undefined || me.cfg.mmdbafid !== undefined || me.cfg.gi !== undefined || me.cfg.blast_rep_id !== undefined; if(bOnePdb) { @@ -15083,14 +15098,14 @@ class SetDialog { html += "2fofc contour at default threshold or at: " + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6sigma2fofc' value='' size=8> σ
    "; - //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: 6px 20px 0 0;'>Load CCP4" + me.htmlCls.buttonStr + "reload_mtzfile2fofc' style='margin: 6px 20px 0 0;'>Load MTZ" + me.htmlCls.buttonStr + "reload_rcsbmtzfile2fofc' style='margin-top: 6px;'>Load RCSB MTZ


    "; + //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: 6px 20px 0 0;'>Load CCP4" + me.htmlCls.buttonStr + "reload_mtzfile2fofc' style='margin: 6px 20px 0 0;'>Load MTZ" + me.htmlCls.buttonStr + "reload_rcsbmtzfile2fofc' style='margin-top: 6px;'>Load RCSB MTZ


    "; + html += me.htmlCls.inputFileStr + "id='" + me.pre + "dsn6file2fofc'>
    " + me.htmlCls.buttonStr + "reload_ccp4file2fofc' style='margin: 6px 20px 0 0;'>Load CCP4" + me.htmlCls.buttonStr + "reload_mtzfile2fofc' style='margin: 6px 20px 0 0;'>Load MTZ" + me.htmlCls.buttonStr + "reload_rcsbmtzfile2fofc' style='margin-top: 6px;'>Load RCSB MTZ


    "; html += "fofc contour at default threshold or at: " + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6sigmafofc' value='' size=8> σ
    "; - //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: 6px 20px 0 0;'>Load MTZ" + me.htmlCls.buttonStr + "reload_rcsbmtzfilefofc' style='margin-top: 6px;'>Load RCSB MTZ


    "; + //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: 6px 20px 0 0;'>Load MTZ" + me.htmlCls.buttonStr + "reload_rcsbmtzfilefofc' style='margin-top: 6px;'>Load RCSB MTZ


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


    "; html += me.htmlCls.buttonStr + "elecmapNo4'>Remove Map
    "; @@ -15104,12 +15119,16 @@ class SetDialog { html += "2fofc contour at default threshold or at: " + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6sigmaurl2fofc' value='' size=8> σ
    "; - html += "URL in the same host: " + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6fileurl2fofc' size=20>
    " + me.htmlCls.buttonStr + "reload_dsn6fileurl2fofc' style='margin: 6px 20px 0 0;'>Load DSN6" + me.htmlCls.buttonStr + "reload_ccp4fileurl2fofc' style='margin: 6px 20px 0 0;'>Load CCP4" + me.htmlCls.buttonStr + "reload_mtzfileurl2fofc' style='margin: 6px 20px 0 0;'>Load MTZ" + me.htmlCls.buttonStr + "reload_rcsbmtzfileurl2fofc' style='margin-top: 6px;'>Load RCSB MTZ


    "; + //html += "URL in the same host: " + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6fileurl2fofc' size=20>
    " + me.htmlCls.buttonStr + "reload_dsn6fileurl2fofc' style='margin: 6px 20px 0 0;'>Load DSN6" + me.htmlCls.buttonStr + "reload_ccp4fileurl2fofc' style='margin: 6px 20px 0 0;'>Load CCP4" + me.htmlCls.buttonStr + "reload_mtzfileurl2fofc' style='margin: 6px 20px 0 0;'>Load MTZ" + me.htmlCls.buttonStr + "reload_rcsbmtzfileurl2fofc' style='margin-top: 6px;'>Load RCSB MTZ


    "; + + html += "URL in the same host: " + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6fileurl2fofc' size=20>
    " + me.htmlCls.buttonStr + "reload_ccp4fileurl2fofc' style='margin: 6px 20px 0 0;'>Load CCP4" + me.htmlCls.buttonStr + "reload_mtzfileurl2fofc' style='margin: 6px 20px 0 0;'>Load MTZ" + me.htmlCls.buttonStr + "reload_rcsbmtzfileurl2fofc' style='margin-top: 6px;'>Load RCSB MTZ


    "; html += "fofc contour at default threshold or at: " + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6sigmaurlfofc' value='' size=8> σ
    "; - html += "URL in the same host: " + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6fileurlfofc' size=20>
    " + 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: 6px 20px 0 0;'>Load MTZ" + me.htmlCls.buttonStr + "reload_rcsbmtzfileurlfofc' style='margin-top: 6px;'>Load RCSB MTZ


    "; + //html += "URL in the same host: " + me.htmlCls.inputTextStr + "id='" + me.pre + "dsn6fileurlfofc' size=20>
    " + 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: 6px 20px 0 0;'>Load MTZ" + me.htmlCls.buttonStr + "reload_rcsbmtzfileurlfofc' style='margin-top: 6px;'>Load RCSB MTZ


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


    "; html += me.htmlCls.buttonStr + "elecmapNo5'>Remove Map
    "; @@ -15658,8 +15677,9 @@ class SetDialog { html += ""; - html += me.htmlCls.divStr + "dl_anglemanysets' class='" + dialogClass + "'>"; + html += me.htmlCls.divStr + "dl_anglemanysets' class='" + dialogClass + "' style='max-width:500px'>"; html += this.addNotebookTitle('dl_anglemanysets', 'Measure angles among many sets'); + html += me.htmlCls.spanNowrapStr + "Note: Each set is represented by a vector, which is the X-axis of the principle axes. The angles between the vectors are then calculated.

    "; html += me.htmlCls.spanNowrapStr + "1. Select sets for pairwise angles
    "; html += "
    StructureChainResidue Number
    "+i[e].substr(0,t)+""+i[e].substr(t+1,s-t-1)+""+i[e].substr(s+1)+"
    "; @@ -15981,8 +16001,8 @@ class SetDialog { html += "Z: " + me.htmlCls.inputTextStr + "id='" + me.pre + "v2Z' value='' size=6>
    "; html += "
    "; - html += me.htmlCls.buttonStr + "measure_angle'>Measure Angle"; - html += "The angle is: " + me.htmlCls.inputTextStr + "id='" + me.pre + "angle_value' value='' size=6> degree."; + html += me.htmlCls.buttonStr + "measure_angle'>Measure Angle

    "; + html += "The angle is: " + me.htmlCls.inputTextStr + "id='" + me.pre + "angle_value' value='' size=6> degree.

    "; html += ""; html += me.htmlCls.divStr + "dl_matrix' class='" + dialogClass + "'>"; @@ -45427,7 +45447,7 @@ class AddTrack { } - showNewTrack(chnid, title, text, cssColorArray, inTarget2queryHash, type, color, bMsa, fromArray, toArray, seqStartLen, exonArray) { let ic = this.icn3d, me = ic.icn3dui; + showNewTrack(chnid, title, text, cssColorArray, inTarget2queryHash, type, color, bMsa, fromArray, toArray, seqStartLen, exonArray, offsetArray) { let ic = this.icn3d, me = ic.icn3dui; //if(ic.customTracks[chnid] === undefined) { // ic.customTracks[chnid] = {} //} @@ -45645,14 +45665,16 @@ class AddTrack { if(fromArray !== undefined) { htmlTmp2 = ''; - let fromArray2 = [], toArray2 = []; + let fromArray2 = [], toArray2 = [], offsetArray2 = []; for(let i = 0, il = fromArray.length; i < il; ++i) { fromArray2.push(fromArray[i]); + offsetArray2.push(offsetArray[i]); for(let j = parseInt(fromArray[i]); j <= parseInt(toArray[i]); ++j) { if(ic.targetGapHash !== undefined && ic.targetGapHash.hasOwnProperty(j)) { toArray2.push(j - 1); fromArray2.push(j); + offsetArray2.push(offsetArray[i]); } } @@ -45686,6 +45708,7 @@ class AddTrack { // determine how this range sits in the exon ranges in exonArray let startExon, endExon; + let offset = offsetArray2[i]; cnt = toArray[i] - fromArray[i] + 1; let from = prevCntTotal, to = prevCntTotal + cnt - 1; @@ -45714,26 +45737,26 @@ class AddTrack { endColorStr = this.getExonColor(startExon.rangeStart, startExon.rangeEnd, to); colorGradient = startColorStr + ' 0%, #FFF 50%, ' + endColorStr + ' 100%'; - htmlTmp2 += this.getExonHtml(startExon.exonIndex, colorGradient, startExon.from, endExon.to, startExon.genomeRange, chnid, simpTitle); + htmlTmp2 += this.getExonHtml(startExon.exonIndex, colorGradient, startExon.from, endExon.to, startExon.genomeRange, chnid, simpTitle, offset); } else { if(startExon) { startColorStr = this.getExonColor(startExon.rangeStart, startExon.rangeEnd, from); colorGradient = startColorStr + ' 0%, #FFF 50%, #00F 100%'; - htmlTmp2 += this.getExonHtml(startExon.exonIndex, colorGradient, startExon.from, startExon.rangeEnd, startExon.genomeRange, chnid, simpTitle); + htmlTmp2 += this.getExonHtml(startExon.exonIndex, colorGradient, startExon.from, startExon.rangeEnd, startExon.genomeRange, chnid, simpTitle, offset); } if(startExon && endExon) { for(let j = startExon.exonIndex + 1; j < endExon.exonIndex; ++j) { colorGradient = '#F00 0%, #FFF 50%, #00F 100%'; - htmlTmp2 += this.getExonHtml(j, colorGradient, exonArray[j].resStart, exonArray[j].resEnd, exonArray[j].genomeRange, chnid, simpTitle); + htmlTmp2 += this.getExonHtml(j, colorGradient, exonArray[j].resStart, exonArray[j].resEnd, exonArray[j].genomeRange, chnid, simpTitle, offset); } endColorStr = this.getExonColor(endExon.rangeStart, endExon.rangeEnd, to); colorGradient = '#F00 0%, #FFF 50%, ' + endColorStr + ' 100%'; - htmlTmp2 += this.getExonHtml(endExon.exonIndex, colorGradient, endExon.rangeStart, endExon.to, endExon.genomeRange, chnid, simpTitle); + htmlTmp2 += this.getExonHtml(endExon.exonIndex, colorGradient, endExon.rangeStart, endExon.to, endExon.genomeRange, chnid, simpTitle, offset); } } @@ -45767,8 +45790,8 @@ class AddTrack { } } - getExonHtml(exonIndex, colorGradient, from, to, genomeRange, chainid, simpTitle) { let ic = this.icn3d; ic.icn3dui; - return ''; + getExonHtml(exonIndex, colorGradient, from, to, genomeRange, chainid, simpTitle, offset) { let ic = this.icn3d; ic.icn3dui; + return ''; } getExonColor(start, end, pos) { let ic = this.icn3d; ic.icn3dui; @@ -46715,6 +46738,7 @@ class AddTrack { let fromArray = [], toArray = []; let bFound = false; let seqStartLen = 0; + let offset = 0, offsetArray = []; // for(let k = seqStart; k <= seqEnd; ++k) { for(let k = 0; k < seqLength; ++k) { //if(seqFirst[k] == '-') continue; @@ -46723,19 +46747,29 @@ class AddTrack { resn = trackSeqArray[j][k]; + if(resn != '-') { + if(!bFound) { + seqStartLen = k; + bFound = true; + + offset = ic.startposGiSeq - ic.seqStartLen[chainid] + seqStartLen; + } + } + if(prevResn == '-' && resn != '-') { fromArray.push(k); + offsetArray.push(offset); } if(prevResn != '-' && resn == '-') { toArray.push(k - 1); } - if(resn != '-') { - if(!bFound) { - seqStartLen = k; - bFound = true; - } + // use "offset" to adjut the residue numbers, e.g., P20138 + // some isoforms starts residues before the first residue in the template sequence + if(k >= ic.seqStartLen[chainid]) { + if(seqFirst[k] == '-') offset--; + if(resn == '-') offset++; } text += resn; //ic.giSeq[chainid][i]; @@ -46756,7 +46790,7 @@ class AddTrack { let title =(trackTitleArray[j].length < 20) ? trackTitleArray[j] : trackTitleArray[j].substr(0, 20) + '...'; let bMsa = true; let exonArray = (acc2exons) ? acc2exons[trackTitleArray[j]] : undefined; - this.showNewTrack(chainid, title, text, undefined, undefined, type, undefined, bMsa, fromArray, toArray, seqStartLen, exonArray); + this.showNewTrack(chainid, title, text, undefined, undefined, type, undefined, bMsa, fromArray, toArray, seqStartLen, exonArray, offsetArray); } // update exon color @@ -53564,8 +53598,10 @@ class ChainalignParser { //$.when(ic.pdbParserCls.applyCommandDssp(true)).then(function() { await ic.pdbParserCls.applyCommandDssp(true); + // original version ============= // align PDB chains for(let index in ic.pdbChainIndexHash) { + //ic.pdbChainIndexHash[index] = mmdbid_q_tmp + "_" + ic.chain_q + "_" + ic.mmdbid_t + "_" + ic.chain_t; let idArray = ic.pdbChainIndexHash[index].split('_'); mmdbid_q = idArray[0]; idArray[1]; @@ -53580,25 +53616,49 @@ class ChainalignParser { let urlalign = me.htmlCls.baseUrl + "vastdyn/vastdyn.cgi"; let urltmalign = me.htmlCls.baseUrl + "tmalign/tmalign.cgi"; + let resRangeArray = (me.cfg.resrange) ? me.cfg.resrange.split(' | ') : []; + for(let index in ic.afChainIndexHash) { let idArray = ic.afChainIndexHash[index].split('_'); mmdbid_q = idArray[0]; let chain_q = idArray[1]; + let chainid_q = mmdbid_q + '_' + chain_q; + mmdbid_t = idArray[2]; let chain_t = idArray[3]; + let chainid_t = mmdbid_t + '_' + chain_t; + + let atomSet_t = (me.cfg.resrange) ? ic.realignParserCls.getSeqCoorResid(resRangeArray[0].split(','), chainid_t).hAtoms : ic.chains[chainid_t]; + let atomSet_q = (me.cfg.resrange) ? ic.realignParserCls.getSeqCoorResid(resRangeArray[index].split(','), chainid_q).hAtoms : ic.chains[chainid_q]; + // end of original version ============= + +/* + // new version to be done for VASTsrv ============== + // dynamically align pairs in all chainids + let ajaxArray = [], indexArray = [], struArray = []; + let urlalign = me.htmlCls.baseUrl + "vastdyn/vastdyn.cgi"; + let urltmalign = me.htmlCls.baseUrl + "tmalign/tmalign.cgi"; + + let resRangeArray = (me.cfg.resrange) ? me.cfg.resrange.split(' | ') : []; + + // dynamically align pairs in all chainids + let atomSet_t = (me.cfg.resrange) ? ic.realignParserCls.getSeqCoorResid(resRangeArray[0].split(','), chainidArray[0]).hAtoms : ic.chains[chainidArray[0]]; + for(let index = 1, indexl = chainidArray.length; index < indexl; ++index) { + let atomSet_q = (me.cfg.resrange) ? ic.realignParserCls.getSeqCoorResid(resRangeArray[index].split(','), chainidArray[index]).hAtoms : ic.chains[chainidArray[index]]; + // end of new version to be done for VASTsrv ============== +*/ let alignAjax; if(me.cfg.aligntool != 'tmalign') { - let jsonStr_q = ic.domain3dCls.getDomainJsonForAlign(ic.chains[mmdbid_q + '_' + chain_q]); - let jsonStr_t = ic.domain3dCls.getDomainJsonForAlign(ic.chains[mmdbid_t + '_' + chain_t]); + let jsonStr_q = ic.domain3dCls.getDomainJsonForAlign(atomSet_q); + let jsonStr_t = ic.domain3dCls.getDomainJsonForAlign(atomSet_t); let dataObj = {'domains1': jsonStr_q, 'domains2': jsonStr_t}; alignAjax = me.getAjaxPostPromise(urlalign, dataObj); } else { - let pdb_query = ic.saveFileCls.getAtomPDB(ic.chains[mmdbid_q + '_' + chain_q]); - - let pdb_target= ic.saveFileCls.getAtomPDB(ic.chains[mmdbid_t + '_' + chain_t]); + let pdb_query = ic.saveFileCls.getAtomPDB(atomSet_q); + let pdb_target= ic.saveFileCls.getAtomPDB(atomSet_t); let dataObj = {'pdb_query': pdb_query, 'pdb_target': pdb_target}; alignAjax = me.getAjaxPostPromise(urltmalign, dataObj); @@ -54001,7 +54061,7 @@ class ChainalignParser { return chainidArray; } - async downloadChainalignment(chainalign, resnum, resdef) { let ic = this.icn3d, me = ic.icn3dui; + async downloadChainalignment(chainalign) { let ic = this.icn3d, me = ic.icn3dui; let thisClass = this; ic.opts['proteins'] = 'c alpha trace'; @@ -54278,7 +54338,7 @@ class ChainalignParser { async loadOpmDataForChainalign(data1, data2, chainidArray, mmdbidArray) { let ic = this.icn3d, me = ic.icn3dui; let thisClass = this; - if(me.cfg.resnum || me.cfg.resdef) { + if(me.cfg.resnum || me.cfg.resdef || me.cfg.resrange) { if(!ic.bCommandLoad) ic.init(); // remove all previously loaded data await this.downloadChainalignmentPart2(data1, data2, undefined, chainidArray); @@ -59155,6 +59215,7 @@ class DensityCifParser { //https://www.ebi.ac.uk/pdbe/densities/doc.html if(type == '2fofc' || type == 'fofc') { + detail = 0; url = "https://www.ebi.ac.uk/pdbe/densities/x-ray/" + pdbid.toLowerCase() + "/cell?detail=" + detail; } else if(type == 'em') { @@ -59195,6 +59256,39 @@ class DensityCifParser { } } + async densityCifParserBase(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.bAjax2fofc) { + ic.mapData.sigma2 = sigma; + ic.setOptionCls.setOption('map', type); + } + else if(type == 'fofc' && ic.bAjaxfofc) { + ic.mapData.sigma = sigma; + ic.setOptionCls.setOption('map', type); + } + else { + let arrayBuffer = await me.getXMLHttpRqstPromise(url, 'GET', 'arraybuffer', type); + + thisClass.parseChannels(arrayBuffer, type, sigma); + + if(type == '2fofc' || type == 'fofc') { + ic.bAjax2fofc = true; + ic.bAjaxfofc = true; + + ic.setOptionCls.setOption('map', type); + } + else if(type == 'em') { + ic.bAjaxEm = true; + + ic.setOptionCls.setOption('emmap', type); + } + } + + // return sigma; + } + parseChannels(densitydata, type, sigma) { let ic = this.icn3d; ic.icn3dui; let cif = this.BinaryParse(densitydata); @@ -64187,7 +64281,7 @@ class LoadCIF { let bFirstAtom = true; - let cifArray = bcifData.split('ENDMDL\n'); + let cifArray = (bText) ? bcifData.split('ENDMDL\n') : [bcifData]; for(let index = 0, indexl = cifArray.length; index < indexl; ++index) { ++moleculeNum; @@ -67178,6 +67272,16 @@ class ApplyCommand { ic.transformCls.rotateCoord(ic.hAtoms, mArrayFloat); ic.drawCls.draw(); } + else if(command.indexOf('set dssp sse') == 0) { + await ic.pdbParserCls.applyCommandDssp(); + ic.bResetAnno = true; + + if(ic.bAnnoShown) { + await ic.showAnnoCls.showAnnotations(); + + ic.annotationCls.resetAnnoTabAll(); + } + } // special, select ========== @@ -69160,20 +69264,23 @@ class LoadScript { } } else if(command.indexOf('load chainalignment') !== -1) { - //load chainalignment [id] | resnum [resnum] | resdef [resnum] | aligntool [aligntool] | parameters [inpara] + //load chainalignment [id] | resnum [resnum] | resdef [resdef] | aligntool [aligntool] | parameters [inpara] | resrange [resrange] let urlArray = command.split(" | "); if(urlArray.length > 1 && urlArray[1].indexOf('resnum') != -1) { me.cfg.resnum = urlArray[1].substr(urlArray[1].indexOf('resnum') + 7); } if(urlArray.length > 2 && urlArray[2].indexOf('resdef') != -1) { - me.cfg.resdef = urlArray[2].substr(urlArray[1].indexOf('resdef') + 7); + me.cfg.resdef = urlArray[2].substr(urlArray[2].indexOf('resdef') + 7); } if(urlArray.length > 3 && urlArray[3].indexOf('aligntool') != -1) { - me.cfg.aligntool = urlArray[3].substr(urlArray[1].indexOf('aligntool') + 10); + me.cfg.aligntool = urlArray[3].substr(urlArray[3].indexOf('aligntool') + 10); + } + if(urlArray.length > 5 && urlArray[5].indexOf('resrange') != -1) { + me.cfg.resrange = urlArray[5].substr(urlArray[5].indexOf('resrange') + 9); } me.cfg.chainalign = id; - await ic.chainalignParserCls.downloadChainalignment(id, me.cfg.resnum, me.cfg.resdef); + await ic.chainalignParserCls.downloadChainalignment(id); } else if(command.indexOf('load url') !== -1) { let typeStr = load_parameters[1]; // type pdb @@ -69222,7 +69329,8 @@ class LoadScript { if(urlArray.length == 2) { let bInputSigma = true; if(fileType == 'dsn6') { - await ic.dsn6ParserCls.dsn6ParserBase(urlArray[1], type, sigma, 'url', bInputSigma); + // await ic.dsn6ParserCls.dsn6ParserBase(urlArray[1], type, sigma, 'url', bInputSigma); + await ic.densityCifParserCls.densityCifParserBase(urlArray[1], type, sigma, 'url', bInputSigma); } else if(fileType == 'ccp4') { await ic.ccp4ParserCls.ccp4ParserBase(urlArray[1], type, sigma, 'url', bInputSigma); @@ -69235,7 +69343,8 @@ class LoadScript { } } else { - await ic.dsn6ParserCls.dsn6Parser(ic.inputid, type, sigma); + // await ic.dsn6ParserCls.dsn6Parser(ic.inputid, type, sigma); + await ic.densityCifParserCls.densityCifParser(ic.inputid, type, sigma); } } // }); // end of me.deferred = $.Deferred(function() { @@ -82037,7 +82146,7 @@ class iCn3DUI { //even when multiple iCn3D viewers are shown together. this.pre = this.cfg.divid + "_"; - this.REVISION = '3.33.2'; + this.REVISION = '3.33.3'; // In nodejs, iCn3D defines "window = {navigator: {}}" this.bNode = (Object.keys(window).length < 2) ? true : false; @@ -82480,9 +82589,9 @@ iCn3DUI.prototype.show3DStructure = async function(pdbStr) { let me = this; ic.bChainAlign = true; ic.inputid = me.cfg.chainalign; - ic.loadCmd = 'load chainalignment ' + me.cfg.chainalign + ' | resnum ' + me.cfg.resnum + ' | resdef ' + me.cfg.resdef + ' | aligntool ' + me.cfg.aligntool + ' | parameters ' + me.cfg.inpara; + ic.loadCmd = 'load chainalignment ' + me.cfg.chainalign + ' | resnum ' + me.cfg.resnum + ' | resdef ' + me.cfg.resdef + ' | aligntool ' + me.cfg.aligntool + ' | parameters ' + me.cfg.inpara + ' | resrange ' + me.cfg.resrange; me.htmlCls.clickMenuCls.setLogCmd(ic.loadCmd, true); - await ic.chainalignParserCls.downloadChainalignment(me.cfg.chainalign, me.cfg.resnum, me.cfg.resdef); + await ic.chainalignParserCls.downloadChainalignment(me.cfg.chainalign); } else if(me.cfg.mmdbafid !== undefined) { // ic.bNCBI = true; diff --git a/dist/CHANGELOG.md b/dist/CHANGELOG.md index 65410f83..1f34907f 100644 --- a/dist/CHANGELOG.md +++ b/dist/CHANGELOG.md @@ -1,5 +1,7 @@ ## Change Log -[icn3d-3.33.2](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-3.33.1.zip) was release on June 25, 2024. Enabled to measure angles between sets in the menu "Analysis > Angle". +[icn3d-3.33.3](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-3.33.3.zip) was release on July 15, 2024. Switch electron density data from RCSB DSN6 to PDBe Density Server. + +[icn3d-3.33.2](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-3.33.2.zip) was release on June 25, 2024. Enabled to measure angles between sets in the menu "Analysis > Angle". [icn3d-3.33.1](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-3.33.1.zip) was release on June 18, 2024. Draw coils for the whole structure with zero radius for the secondary structure parts. diff --git a/dist/full.html b/dist/full.html index e0219f57..8af000e9 100644 --- a/dist/full.html +++ b/dist/full.html @@ -19,11 +19,11 @@
    - + - + - + - + - + - +