var $body=document.querySelector("body"),$progress_island=document.querySelector(".progress-island"),$help_island=document.querySelector(".help-island"),$notice_island=document.querySelector(".notice-island"),$page_bar_wrap=document.querySelector(".page-bar-wrap"),$page_bar_wrap_fake=document.querySelector(".page-bar-wrap-fake"),$processing_wrap=document.querySelector(".processing-wrap"),$processing_icon=document.querySelector(".processing-icon"),$processing_progress=document.querySelector(".processing-progress"),$preload_wrap=document.querySelector(".preload-wrap"),$results_switch=document.querySelector(".results-switch"),$neon_light=document.querySelector(".neon-light"),$results=document.querySelector("div#results"),$results_md=document.querySelector("div#results-md"),$drug_info_template=document.querySelector("div#drug-info-template"),$visualize_wrap_features_template=document.querySelector("div#visualize-wrap-features-template"),$visualize_wrap_docking_template=document.querySelector("div#visualize-wrap-docking-template"),$visualize_wrap_md_template=document.querySelector("div#visualize-wrap-md-template"),$feature_card_template=document.querySelector("div#feature-card-template"),tick_bodyscroll=!1,protocol=window.location.protocol,host=window.location.host + "/drdock",drug_rank=0,simulations_query=[],simulations_submit_flag=0,uuid=document.querySelector("div#job_uuid").getAttribute("value"),demo_flag=document.querySelector("div#demo_flag").getAttribute("value");function resetIslandPosition(){tick_bodyscroll||window.requestAnimationFrame(function(){$body.scrollTop>142?($progress_island.classList.add("sticky"),$page_bar_wrap.classList.add("sticky"),$page_bar_wrap_fake.style.display=""):($progress_island.classList.remove("sticky"),$page_bar_wrap.classList.remove("sticky"),$page_bar_wrap_fake.style.display="none"),tick_bodyscroll=!1}),tick_bodyscroll=!0}function onElementScrollHeightChange(e,t){var i,r=e.scrollHeight;!function s(){i=e.scrollHeight,r!=i&&t(i),r=i,e.onElementScrollHeightChangeeTimer&&clearTimeout(e.onElementScrollHeightChangeTimer),e.onElementScrollHeightChangeTimer=setTimeout(s,200)}()}history.replaceState(null,null," "),window.addEventListener("scroll",function(e){resetIslandPosition()}),window.addEventListener("resize",function(e){resetIslandPosition()}),onElementScrollHeightChange($body,function(e){resetIslandPosition()});const scrollToTop=()=>{const e=document.documentElement.scrollTop||document.body.scrollTop;e>0&&(window.requestAnimationFrame(scrollToTop),window.scrollTo(0,e-e/8))};$help_island.querySelector("#go-top").addEventListener("click",function(e){scrollToTop()});var results,druginfo,refreshId=setInterval(function(){if("none"==$processing_icon.style.display)clearInterval(refreshId);else{let e=parseInt($processing_icon.querySelector("span").textContent)+1;$processing_icon.querySelector("span").textContent=e}},1e3),num_loaded_results=0,pre_fetch_size=200;function page_bar_switch_to_info(){$page_bar_wrap.querySelector("#submit-simulation").classList.remove("open"),$page_bar_wrap.querySelector("#submit-simulation").classList.add("close"),$page_bar_wrap.querySelector("#info").classList.remove("close"),$page_bar_wrap.querySelector("#info").classList.add("open"),1!=simulations_submit_flag&&(simulations_query=[],reset_submit_simulations_checked(),call_submit_simulations_administrator())}function page_bar_switch_to_submit_simulation(){$page_bar_wrap.querySelector("#info").classList.remove("open"),$page_bar_wrap.querySelector("#info").classList.add("close"),$page_bar_wrap.querySelector("#submit-simulation").classList.remove("close"),$page_bar_wrap.querySelector("#submit-simulation").classList.add("open"),1!=simulations_submit_flag&&call_submit_simulations_administrator()}function light_up_submit_simulations(){let e=$results.querySelectorAll(".info-wrap .lower .buttons-wrap .button#submit-simulation");for(let t=0;te.split("-")[0]).map((e,t)=>e[0]).map(e=>results.Results.Ranking.indexOf(e)).value(),i=num_loaded_results,r=num_loaded_results+10;r>t.length&&(r=t.length);for(let s=i;s{let s,o,n=r;[s,o]=n.split("-");let l=[n,results.Results.MD_Docking[n]],a=results.Results.Rankings_MD_poses[n];t+=1;let u=$drug_info_template.cloneNode(!0),d=u.querySelector(".visualizations-wrap");u.id=n,u.querySelector(".header").id="md"+t,u.querySelector(".header").textContent="#"+t,u.querySelector(".info-wrap .upper .figure img").src=druginfo[s].figure2d_url,u.querySelector(".info-wrap .upper .figure img").title=druginfo[s].figure2d_url,u.querySelector(".info-wrap .upper .text .title").textContent=druginfo[s].name,u.querySelector(".info-wrap .upper .text .indicator .pose-id span:nth-child(2)").textContent="Pose "+a,u.querySelector(".info-wrap .upper .text .indicator .pose-id span:nth-child(1)").classList.add("unclickable"),u.querySelector(".info-wrap .upper .text .indicator .pose-id span:nth-child(3)").classList.add("unclickable"),u.querySelector(".info-wrap .upper .text .context").textContent=druginfo[s].desc,u.querySelector(".info-wrap .upper .text .link a").href=druginfo[s].desc_sourceurl,u.querySelector(".info-wrap .upper .text .link a").title=druginfo[s].desc_sourceurl,u.querySelector(".info-wrap .upper .text .link a").lastChild.textContent=druginfo[s].desc_sourcename,u.querySelector(".info-wrap .lower .basic-info-wrap .basic-info#mol-formula .value").textContent=druginfo[s].mol_formula,u.querySelector(".info-wrap .lower .basic-info-wrap .basic-info#mol-weight .value").textContent=druginfo[s].mol_weight+" g/mol",u.querySelector(".info-wrap .lower .basic-info-wrap .basic-info#cid .value").firstChild.textContent=druginfo[s].cid,u.querySelector(".info-wrap .lower .basic-info-wrap .basic-info#cid .value a").href=druginfo[s].pubchem_url,u.querySelector(".info-wrap .lower .basic-info-wrap .basic-info#cid .value a").title=druginfo[s].pubchem_url,"submitted"==l[1].info.md_status?(u.querySelector(".info-wrap .upper .text .simulation-light .light").classList.add("running"),u.querySelector(".info-wrap .upper .text .simulation-light .light").title="running"):"finished"==l[1].info.md_status&&(u.querySelector(".info-wrap .upper .text .simulation-light .light").classList.add("finish"),u.querySelector(".info-wrap .upper .text .simulation-light .light").title="finish"),"freeze"==l[1].info.md_status&&"true"==results.Progress.MD.allow_new_submission?u.querySelector(".info-wrap .lower .buttons-wrap .button#submit-simulation").classList.add("disable"):"submitted"==l[1].info.md_status?(u.querySelector(".info-wrap .lower .buttons-wrap .button#submit-simulation").style.display="none",u.querySelector(".info-wrap .lower .buttons-wrap .button#view-trajectory").style.display=""):"finished"==l[1].info.md_status&&(u.querySelector(".info-wrap .lower .buttons-wrap .button#submit-simulation").style.display="none",u.querySelector(".info-wrap .lower .buttons-wrap .button#view-trajectory").classList.remove("disable"),u.querySelector(".info-wrap .lower .buttons-wrap .button#view-trajectory").style.display=""),u.querySelector(".info-wrap .upper .text .indicator .pose-id span:nth-child(1)").addEventListener("click",function(){if(!this.classList.contains("unclickable")){u.style.display="none",u.previousSibling.style.display="";var e=window.document.createEvent("UIEvents");e.initUIEvent("resize",!0,!1,window,0),window.dispatchEvent(e)}}),u.querySelector(".info-wrap .upper .text .indicator .pose-id span:nth-child(3)").addEventListener("click",function(){if(!this.classList.contains("unclickable")){u.style.display="none",u.nextSibling.style.display="";var e=window.document.createEvent("UIEvents");e.initUIEvent("resize",!0,!1,window,0),window.dispatchEvent(e)}}),u.querySelector(".info-wrap .lower .buttons-wrap div#view-features").addEventListener("click",function(){if(d.querySelector(".visualize-wrap.features"))return void d.removeChild(d.firstChild);for(;d.firstChild;)d.removeChild(d.firstChild);let t,i,r=$visualize_wrap_features_template.cloneNode(!0);[t,i]=r.querySelectorAll(".feature-card-wrap");for(let r=0;rparseFloat(e))),color:new Float32Array([1,1,0]),radius:new Float32Array([1])});s.addBuffer(n),shapeComp=o.addComponentFromObject(s),shapeComp.addRepresentation("buffer",{opacity:.5}),r.addRepresentation("cartoon",{color:"residueindex",aspectRatio:7}),r.addRepresentation("spacefill",{radiusType:"size",radius:.5,color:"rgb( 153, 76, 0 )",sele:"ion"}),r.addRepresentation("ball+stick",{aspectRatio:1.2,radiusScale:2.5,colorValue:"grey",multipleBond:"symmetric",sele:"LIG and /1 and not hydrogen"});var l=r.structure.getAtomSetWithinSelection(new NGL.Selection("LIG and /1 and not hydrogen"),4),a=r.structure.getAtomSetWithinGroup(l);r.addRepresentation("ball+stick",{aspectRatio:1.1,colorValue:"lightgrey",multipleBond:"symmetric",sele:"(@"+a.toArray().join(",")+" and not ligand and not hydrogen)"}),r.addRepresentation("surface",{lazy:!0,visibility:!0,clipNear:0,opaqueBack:!1,opacity:.1,color:"hydrophobicity",roughness:1,surfaceType:"av",sele:"(@"+a.toArray().join(",")+" and not ligand and not hydrogen)"}),r.addRepresentation("label",{color:"#333333",yOffset:.2,zOffset:2,attachment:"bottom-center",showBorder:!0,borderColor:"lightgrey",borderWidth:.25,disablePicking:!0,radiusType:"size",radiusSize:1.4,labelType:"residue",labelGrouping:"residue",sele:"(@"+a.toArray().join(",")+" and not ligand and not hydrogen)"}),r.addRepresentation("contact",{masterModelIndex:0,hydrophobic:!0,hydrogenBond:!0,weakHydrogenBond:!0,waterHydrogenBond:!0,backboneHydrogenBond:!0,halogenBond:!0,metalComplex:!0,saltBridge:!0,cationPi:!0,piStacking:!0,radiusSize:.07,maxHbondDonPlaneAngle:35,sele:"(/0 and @"+a.toArray().join(",")+") or /1"}),r.autoView("ligand"),o.setFocus(0),console.log(l.toArray().join(",")),(s=new NGL.Shape("shape")).addSphere(new Float32Array(results.Meta.TargetSite.split(",").map(e=>parseFloat(e))),new Float32Array([1,1,0]),new Float32Array([1]),"Target site (COM)"),shapeComp=o.addComponentFromObject(s),shapeComp.addRepresentation("buffer",{opacity:.5})})}function ngl_md_pose(e,t,i,r){let s=protocol+"//"+host+"/download/"+uuid+"/md_top_"+t+"/",o=protocol+"//"+host+"/download/"+uuid+"/md_dcd_"+t+"/";var n=new NGL.Stage(e);return window.addEventListener("resize",function(e){n.handleResize()},!1),n.setParameters({backgroundColor:"#fff5ee"}),n.loadFile(s,{ext:"parm7"}).then(function(t){NGL.autoLoad(o,{ext:"dcd"}).then(function(r){e.parentElement.querySelector(".visualize-wrap.md .loadingio-spinner-dual-ball").style.display="none",t.addTrajectory(r,{initialFrame:0,deltaTime:200}),t.addRepresentation("cartoon",{color:"residueindex",aspectRatio:7}),t.addRepresentation("spacefill",{radiusType:"size",radius:.5,color:"rgb( 153, 76, 0 )",sele:"ion"}),t.addRepresentation("ball+stick",{aspectRatio:1.2,radiusScale:2.5,colorValue:"grey",multipleBond:"symmetric",sele:"ligand and not hydrogen"}),n.autoView(),n.setFocus(0);var s=new NGL.Shape("shape");s.addSphere(new Float32Array(results.Meta.TargetSite.split(",").map(e=>parseFloat(e))),new Float32Array([1,1,0]),new Float32Array([1]),"Target site (COM)"),shapeComp=n.addComponentFromObject(s),shapeComp.addRepresentation("buffer",{opacity:.5});var o=t.trajList[0].trajectory,l=new NGL.TrajectoryPlayer(o,{step:1,timeout:50,interpolateType:"linear",interpolateStep:5});o.setPlayer(l);var a=e.parentElement.querySelector(".visualize-wrap.md .play-bar"),u=e.parentElement.querySelector(".visualize-wrap.md .play-bar .button-wrap .button#play"),d=e.parentElement.querySelector(".visualize-wrap.md .play-bar .button-wrap .button#pause"),c=e.parentElement.querySelector(".visualize-wrap.md .play-bar .seek-bar"),p=e.parentElement.querySelector(".visualize-wrap.md .play-bar .seek-bar .pinpoint"),m=e.parentElement.querySelector(".visualize-wrap.md .play-bar .frame"),f=p.parentElement.offsetWidth;u.addEventListener("click",function(){u.classList.add("disable"),d.classList.remove("disable"),l.play()}),d.addEventListener("click",function(){d.classList.add("disable"),u.classList.remove("disable"),l.pause()}),c.addEventListener("mousedown",function(e){function t(e){e.preventDefault();var t=(e.clientX-p.parentElement.getBoundingClientRect().left)/f,i=o.frames.length,r=Math.ceil(i*t)-1;r<0&&(r=0),r>i-1&&(r=i-1),o.setFrame(r,function(){d.classList.add("disable"),u.classList.remove("disable"),o.player.pause()}),a.classList.add("hover")}t(e),document.addEventListener("mousemove",t),document.addEventListener("mouseup",function e(i){i.preventDefault(),document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",e),a.classList.remove("hover")})}),o.signals.frameChanged.add(function(e){m.textContent=e,p.style.left=.9*Math.ceil(e/(o.frames.length-1)*100)+"%"}),console.log(o.frames.length);let g=e.parentElement.querySelector(".feature-card-wrap"),y=["Binding Free Energy (kcal/mol)","Drug RMSD per Time Lag (Å)","Distance to Target Sites (Å)","Contact Number"];for(let e=0;e"));let h=["Mean Binding Free Energy (kcal/mol)","Drug Leaving Time (ns)","Largest Distance to Target Sites (Å)"];for(let e=0;ee.split("-")[0]).map((e,t)=>e[0]).map(e=>results.Results.Ranking.indexOf(e)).value(),t=Object.keys(Object.values(results.Results.Docking)[0].features),i=[],r=["Drug Rank","Pose Rank","Name","Formula","M.W. (g/mol)","PubChem CID"].concat(Object.keys(Object.values(results.Results.Docking)[0].features)).concat(["Description","Desc. Source","Desc. URL"]);i.push(r.join(","));for(let r=0;r  Protein structure used for docking'}Promise.all([(async()=>{let e=await fetch(protocol+"//"+host+"/api/v1/get_results?uuid="+uuid+"&docking_results_begidx=0&docking_results_number="+pre_fetch_size,{mode:"cors"});const t=e.body.getReader(),i=e.headers.has("Content-Length")?e.headers.get("Content-Length"):e.headers.get("My-Content-Length");let r=0,s=[];for(;;){const{done:e,value:o}=await t.read();if(e)break;s.push(o),r+=o.length,$processing_progress.querySelector(".progress-bar").style.width=Math.round(r/i*1e4)/100+"%"}let o=new Uint8Array(r),n=0;for(let e of s)o.set(e,n),n+=e.length;let l=new TextDecoder("utf-8").decode(o);return JSON.parse(l)})(),fetch(protocol+"//"+host+"/static/app/druginfo.json").then(function(e){return e.json()})]).then(function([e,t]){"docking"==demo_flag&&demo_mode_docking_html_modify();const i=fetch(protocol+"//"+host+"/api/v1/get_results?uuid="+uuid,{mode:"cors"}).then(function(e){return e.json()}).then(function(e){results=e,"docking"==demo_flag&&demo_mode_docking()});let r,s,o,n;results=e,druginfo=t,"docking"==demo_flag&&demo_mode_docking(),[r,s]=$progress_island.querySelectorAll(".info .content"),r.querySelector("span").textContent=results.Progress.Docking.finished+"/"+results.Progress.Docking.submitted,s.querySelector("span").textContent=results.Progress.MD.finished+"/"+results.Progress.MD.submitted,$progress_island.querySelector("a").href=protocol+"//"+host+"/progress/"+uuid+"/",results.Meta.AllowDelete&&$help_island.querySelector("#delete-job").classList.remove("disable"),$help_island.querySelector("#delete-job").addEventListener("click",function(){this.classList.contains("disable")||window.confirm("Do you really want to remove the current project?")&&(this.classList.contains("disable"),$help_island.querySelector(".delete-processing-icon").style.display="",fetch(protocol+"//"+host+"/api/v1/delete_job",{headers:{Accept:"application/json","Content-Type":"application/json"},method:"PATCH",body:JSON.stringify({uuid:uuid})}).then(function(e){window.location.replace(protocol+"//"+host)}))}),$processing_wrap.style.display="none",$help_island.style.display="",[o,n]=$page_bar_wrap.querySelectorAll(".progress .content"),o.querySelector("span").textContent=results.Progress.Docking.finished+"/"+results.Progress.Docking.submitted,n.querySelector("span").textContent=results.Progress.MD.finished+"/"+results.Progress.MD.submitted,$page_bar_wrap.querySelector("#view-progress a").href=protocol+"//"+host+"/progress/"+uuid+"/",$page_bar_wrap.querySelector("#info .text#text4 span").textContent=results.Meta.TargetSite,$page_bar_wrap.querySelector("#submit-simulation .text span:nth-child(2)").textContent=results.Progress.MD.remaining,"false"==results.Progress.MD.allow_new_submission&&$page_bar_wrap.querySelector("#submit-simulation .submit-button.submit").classList.add("disable"),$page_bar_wrap.querySelector("#page-refresh .button").addEventListener("click",function(){window.location.reload(!1)}),$page_bar_wrap.querySelector("#info .button").addEventListener("click",page_bar_switch_to_info),$page_bar_wrap.querySelector("#submit-simulation .button").addEventListener("click",page_bar_switch_to_submit_simulation),$page_bar_wrap.querySelector("#submit-simulation .close").addEventListener("click",page_bar_switch_to_info),$page_bar_wrap.querySelector("#submit-simulation .submit-button.auto").addEventListener("click",function(){let e=simulations_query.length,t=results.Progress.MD.remaining-e;$elements=$results.querySelectorAll(".drug-info .info-wrap .lower .buttons-wrap .button#submit-simulation"),$elements=Array.apply(null,$elements),$elements=_($elements).groupBy(e=>e.parentElement.parentElement.parentElement.parentElement.id.split("-")[0]).map((e,t)=>e[0]).value(),$elements=$elements.filter(e=>!e.classList.contains("disable")),$elements=$elements.filter(e=>!("none"===e.style.display)),$elements=$elements.slice(0,t),$elements.forEach((e,t)=>e.click())}),$page_bar_wrap.querySelector("#submit-simulation .submit-button.submit").addEventListener("click",function(){if(0==simulations_query.length)return;simulations_submit_flag=1;let e=this;if(e.style.display="none",e.nextElementSibling.style.display="",cloud_up_submit_simulations(),cloud_up_submit_simulations_checked(),"docking"==demo_flag){let t=e=>new Promise((t,i)=>{setTimeout(()=>{t()},e)});return void t(1e3).then(()=>(e.nextElementSibling.style.display="none",e.nextElementSibling.nextElementSibling.style.display="",t(1e3))).then(()=>{window.location.replace(protocol+"//"+host+"/example/")})}let t=simulations_query.join(",");fetch(protocol+"//"+host+"/do_simulations/"+uuid+"/"+t+"/").then(function(){e.nextElementSibling.style.display="none",e.nextElementSibling.nextElementSibling.style.display="",setTimeout(()=>{window.location.reload(!1)},1e3)})}),$page_bar_wrap.querySelector("#info .arrow-left").addEventListener("click",function(){let e=this.parentElement.querySelector('.text[style="opacity: 1;"]'),t=e.previousElementSibling;null===t&&(t=this.parentElement.querySelector(".slider").lastElementChild),e.classList.remove("page-bar-info-slider-left-out","page-bar-info-slider-left-in","page-bar-info-slider-right-out","page-bar-info-slider-right-in"),t.classList.remove("page-bar-info-slider-left-out","page-bar-info-slider-left-in","page-bar-info-slider-right-out","page-bar-info-slider-right-in"),e.classList.add("page-bar-info-slider-right-out"),t.classList.add("page-bar-info-slider-left-in"),e.style.opacity="0",t.style.opacity="1"}),$page_bar_wrap.querySelector("#info .arrow-right").addEventListener("click",function(){let e=this.parentElement.querySelector('.text[style="opacity: 1;"]'),t=e.nextElementSibling;null===t&&(t=this.parentElement.querySelector(".slider").firstElementChild),e.classList.remove("page-bar-info-slider-left-out","page-bar-info-slider-left-in","page-bar-info-slider-right-out","page-bar-info-slider-right-in"),t.classList.remove("page-bar-info-slider-left-out","page-bar-info-slider-left-in","page-bar-info-slider-right-out","page-bar-info-slider-right-in"),e.classList.add("page-bar-info-slider-left-out"),t.classList.add("page-bar-info-slider-right-in"),e.style.opacity="0",t.style.opacity="1"}),$page_bar_wrap.querySelector("#download .button").addEventListener("click",function(){download("results_"+uuid+".csv",get_screening_results_csv())}),setInterval(()=>{null===$page_bar_wrap.querySelector("#info:hover")&&$page_bar_wrap.querySelector("#info .arrow-right").click()},1e4),$page_bar_wrap.style.display="",results.Progress.Docking.finished===results.Progress.Docking.submitted&results.Progress.MD.finished===results.Progress.MD.submitted&0!=results.Progress.Docking.submitted&&($neon_light.classList.remove("running"),$neon_light.classList.add("complete"),$refresh_diag=$neon_light.querySelector("div#refresh-diag"),$refresh_checkbox=$neon_light.querySelector("input#refresh-checkbox"),$refresh_diag.style.display="none",$refresh_checkbox.checked=!1);let l=setInterval(function(){$refresh_checkbox=$neon_light.querySelector("input#refresh-checkbox"),$refresh_countdown=$neon_light.querySelector("span#refresh-countdown"),"0"==$refresh_countdown.textContent?(clearInterval(l),location.reload()):!$refresh_checkbox.checked|$body.scrollTop>202|1===simulations_submit_flag||($refresh_countdown.textContent=$refresh_countdown.textContent-1)},1e3);$neon_light.parentElement.style.display="",0==Object.keys(e.Results.Docking).length?($notice_island.textContent="Refresh this page to access the updated results!",$preload_wrap.style.display=""):($results_switch.querySelector(".button#docking").addEventListener("click",function(){this.classList.remove("inactive"),this.classList.add("active"),this.nextElementSibling.classList.remove("active"),this.nextElementSibling.classList.add("inactive"),$results.style.display="",$results_md.style.display="none"}),$results_switch.querySelector(".button#md").addEventListener("click",function(){this.classList.remove("inactive"),this.classList.add("active"),this.previousElementSibling.classList.remove("active"),this.previousElementSibling.classList.add("inactive"),$results.style.display="none",$results_md.style.display=""}),$results_switch.style.display="",render_results(),render_results(),window.addEventListener("scroll",function(e){if("none"==$results_md.style.display&&window.scrollY>$results.offsetHeight-1e3){let e=num_loaded_results;num_loaded_results>pre_fetch_size?i.then(function(){num_loaded_results==e&&render_results()}):render_results()}}),render_results_md(),window.addEventListener("hashchange",function(e){i.then(function(){if("none"!=document.getElementById("results").style.display){for(;window.location.hash.slice(1)>num_loaded_results;)render_results();window.scrollBy({top:document.getElementById(window.location.hash.slice(1)).getBoundingClientRect().top-100,behavior:"smooth"})}else"none"!=document.getElementById("results-md").style.display&&window.scrollBy({top:document.getElementById("md"+window.location.hash.slice(1)).getBoundingClientRect().top-100,behavior:"smooth"});history.replaceState(window.location.hash.slice(1),"",window.location.origin+window.location.pathname)})}))});