User:Jiywang3/icn3d.js

var Detector={canvas:!!window.CanvasRenderingContext2D,webgl:function{try{var e=document.createElement("canvas");return!(!window.WebGLRenderingContext||!e.getContext("webgl")&&!e.getContext("experimental-webgl"))}catch(i){return!1}},workers:!!window.Worker,fileapi:window.File&&window.FileReader&&window.FileList&&window.Blob,getWebGLErrorMessage:function{var e=document.createElement("div");return e.id="webgl-error-message",e.style.fontFamily="monospace",e.style.fontSize="13px",e.style.fontWeight="normal",e.style.textAlign="center",e.style.background="#fff",e.style.color="#000",e.style.padding="1.5em",e.style.width="400px",e.style.margin="5em auto 0",this.webgl||(e.innerHTML=window.WebGLRenderingContext?['Your graphics card does not seem to support WebGL. ','Find out how to get it here.'].join("\n"):['Your browser does not seem to support WebGL. ','Find out how to get it here.'].join("\n")),e},addGetWebGLMessage:function(e){var i,t,n;e=e||{},i=void 0!==e.parent?e.parent:document.body,t=void 0!==e.id?e.id:"oldie",n=Detector.getWebGLErrorMessage,n.id=t,i.appendChild(n)}};if("object"==typeof module&&(module.exports=Detector),THREE.SpriteCanvasMaterial=function(e){THREE.Material.call(this),this.type="SpriteCanvasMaterial",this.color=new THREE.Color(16777215),this.program=function(e,i){},this.setValues(e)},THREE.SpriteCanvasMaterial.prototype=Object.create(THREE.Material.prototype),THREE.SpriteCanvasMaterial.prototype.constructor=THREE.SpriteCanvasMaterial,THREE.SpriteCanvasMaterial.prototype.clone=function{var e=new THREE.SpriteCanvasMaterial;return e.copy(this),e.color.copy(this.color),e.program=this.program,e},THREE.CanvasRenderer=function(e){function i{be.setRGB(0,0,0),ye.setRGB(0,0,0),Ee.setRGB(0,0,0);for(var e=0,i=C.length;i>e;e++){var t=C[e],n=t.color;t instanceof THREE.AmbientLight?be.add(n):t instanceof THREE.DirectionalLight?ye.add(n):t instanceof THREE.PointLight&&Ee.add(n)}}function t(e,i,t){for(var n=0,o=C.length;o>n;n++){var s=C[n];if(pe.copy(s.color),s instanceof THREE.DirectionalLight){var r=_e.setFromMatrixPosition(s.matrixWorld).normalize,a=i.dot(r);if(0>=a)continue;a*=s.intensity,t.add(pe.multiplyScalar(a))}else if(s instanceof THREE.PointLight){var r=_e.setFromMatrixPosition(s.matrixWorld),a=i.dot(_e.subVectors(r,e).normalize);if(0>=a)continue;if(a*=0==s.distance?1:1-Math.min(e.distanceTo(r)/s.distance,1),0==a)continue;a*=s.intensity,t.add(pe.multiplyScalar(a))}}}function n(e,i,t){u(t.opacity),p(t.blending);var n=i.scale.x*U,o=i.scale.y*W,s=.5*Math.sqrt(n*n+o*o);if(ve.min.set(e.x-s,e.y-s),ve.max.set(e.x+s,e.y+s),t instanceof THREE.SpriteMaterial){var r=t.map;if(null!==r){var a=me[r.id];if((void 0===a||a.version!==r.version)&&(a=l(r),me[r.id]=a),void 0!==a.canvas){b(a.canvas);var c=r.image,d=c.width*r.offset.x,h=c.height*r.offset.y,m=c.width*r.repeat.x,g=c.height*r.repeat.y,f=n/m,y=o/g;J.save,J.translate(e.x,e.y),0!==t.rotation&&J.rotate(t.rotation),J.translate(-n/2,-o/2),J.scale(f,y),J.translate(-d,-h),J.fillRect(d,h,m,g),J.restore}}else b(t.color.getStyle),J.save,J.translate(e.x,e.y),0!==t.rotation&&J.rotate(t.rotation),J.scale(n,-o),J.fillRect(-.5,-.5,1,1),J.restore}else t instanceof THREE.SpriteCanvasMaterial&&(v(t.color.getStyle),b(t.color.getStyle),J.save,J.translate(e.x,e.y),0!==t.rotation&&J.rotate(t.rotation),J.scale(n,o),t.program(J),J.restore)}function o(e,i,t,n){if(u(n.opacity),p(n.blending),J.beginPath,J.moveTo(e.positionScreen.x,e.positionScreen.y),J.lineTo(i.positionScreen.x,i.positionScreen.y),n instanceof THREE.LineBasicMaterial){if(m(n.linewidth),g(n.linecap),f(n.linejoin),n.vertexColors!==THREE.VertexColors)v(n.color.getStyle);else{var o=t.vertexColors[0].getStyle,s=t.vertexColors[1].getStyle;if(o===s)v(o);else{try{var r=J.createLinearGradient(e.positionScreen.x,e.positionScreen.y,i.positionScreen.x,i.positionScreen.y);r.addColorStop(0,o),r.addColorStop(1,s)}catch(a){r=o}v(r)}}J.stroke,ve.expandByScalar(2*n.linewidth)}else n instanceof THREE.LineDashedMaterial&&(m(n.linewidth),g(n.linecap),f(n.linejoin),v(n.color.getStyle),y([n.dashSize,n.gapSize]),J.stroke,ve.expandByScalar(2*n.linewidth),y([]))}function s(e,i,n,o,s,l,h,m){if(P.info.render.vertices+=3,P.info.render.faces++,u(m.opacity),p(m.blending),H=e.positionScreen.x,A=e.positionScreen.y,x=i.positionScreen.x,O=i.positionScreen.y,$=n.positionScreen.x,M=n.positionScreen.y,r(H,A,x,O,$,M),(m instanceof THREE.MeshLambertMaterial||m instanceof THREE.MeshPhongMaterial)&&null===m.map)he.copy(m.color),ue.copy(m.emissive),m.vertexColors===THREE.FaceColors&&he.multiply(h.color),de.copy(be),we.copy(e.positionWorld).add(i.positionWorld).add(n.positionWorld).divideScalar(3),t(we,h.normalModel,de),de.multiply(he).add(ue),m.wireframe===!0?a(de,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):c(de);else if(m instanceof THREE.MeshBasicMaterial||m instanceof THREE.MeshLambertMaterial||m instanceof THREE.MeshPhongMaterial)if(null!==m.map){var g=m.map.mapping;g===THREE.UVMapping&&(L=h.uvs,d(H,A,x,O,$,M,L[o].x,L[o].y,L[s].x,L[s].y,L[l].x,L[l].y,m.map))}else null!==m.envMap?m.envMap.mapping===THREE.SphericalReflectionMapping&&(Ce.copy(h.vertexNormalsModel[o]).applyMatrix3(Se),I=.5*Ce.x+.5,D=.5*Ce.y+.5,Ce.copy(h.vertexNormalsModel[s]).applyMatrix3(Se),z=.5*Ce.x+.5,N=.5*Ce.y+.5,Ce.copy(h.vertexNormalsModel[l]).applyMatrix3(Se),q=.5*Ce.x+.5,j=.5*Ce.y+.5,d(H,A,x,O,$,M,I,D,z,N,q,j,m.envMap)):(de.copy(m.color),m.vertexColors===THREE.FaceColors&&de.multiply(h.color),m.wireframe===!0?a(de,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):c(de));else m instanceof THREE.MeshDepthMaterial?(de.r=de.g=de.b=1-E(e.positionScreen.z*e.positionScreen.w,S.near,S.far),m.wireframe===!0?a(de,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):c(de)):m instanceof THREE.MeshNormalMaterial?(Ce.copy(h.normalModel).applyMatrix3(Se),de.setRGB(Ce.x,Ce.y,Ce.z).multiplyScalar(.5).addScalar(.5),m.wireframe===!0?a(de,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):c(de)):(de.setRGB(1,1,1),m.wireframe===!0?a(de,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):c(de))}function r(e,i,t,n,o,s){J.beginPath,J.moveTo(e,i),J.lineTo(t,n),J.lineTo(o,s),J.closePath}function a(e,i,t,n){m(i),g(t),f(n),v(e.getStyle),J.stroke,ve.expandByScalar(2*i)}function c(e){b(e.getStyle),J.fill}function l(e){if(0===e.version||e instanceof THREE.CompressedTexture||e instanceof THREE.DataTexture)return{canvas:void 0,version:e.version};var i=e.image,t=document.createElement("canvas");t.width=i.width,t.height=i.height;var n=t.getContext("2d");n.setTransform(1,0,0,-1,0,i.height),n.drawImage(i,0,0);var o=e.wrapS===THREE.RepeatWrapping,s=e.wrapT===THREE.RepeatWrapping,r="no-repeat";return o===!0&&s===!0?r="repeat":o===!0?r="repeat-x":s===!0&&(r="repeat-y"),{canvas:J.createPattern(t,r),version:e.version}}function d(e,i,t,n,o,s,r,a,c,d,h,u,p){var m=me[p.id];if((void 0===m||m.version!==p.version)&&(m=l(p),me[p.id]=m),void 0===m.canvas)return b("rgba( 0, 0, 0, 1)"),void J.fill;b(m.canvas);var g,f,v,y,E,_,w,C,S=p.offset.x/p.repeat.x,k=p.offset.y/p.repeat.y,R=p.image.width*p.repeat.x,T=p.image.height*p.repeat.y;r=(r+S)*R,a=(a+k)*T,c=(c+S)*R,d=(d+k)*T,h=(h+S)*R,u=(u+k)*T,t-=e,n-=i,o-=e,s-=i,c-=r,d-=a,h-=r,u-=a,w=c*u-h*d,0!==w&&(C=1/w,g=(u*t-d*o)*C,f=(u*n-d*s)*C,v=(c*o-h*t)*C,y=(c*s-h*n)*C,E=e-g*r-v*a,_=i-f*r-y*a,J.save,J.transform(g,f,v,y,E,_),J.fill,J.restore)}function h(e,i,t){var n,o=i.x-e.x,s=i.y-e.y,r=o*o+s*s;0!==r&&(n=t/Math.sqrt(r),o*=n,s*=n,i.x+=o,i.y+=s,e.x-=o,e.y-=s)}function u(e){te!==e&&(J.globalAlpha=e,te=e)}function p(e){ne!==e&&(e===THREE.NormalBlending?J.globalCompositeOperation="source-over":e===THREE.AdditiveBlending?J.globalCompositeOperation="lighter":e===THREE.SubtractiveBlending&&(J.globalCompositeOperation="darker"),ne=e)}function m(e){re!==e&&(J.lineWidth=e,re=e)}function g(e){ae!==e&&(J.lineCap=e,ae=e)}function f(e){ce!==e&&(J.lineJoin=e,ce=e)}function v(e){oe!==e&&(J.strokeStyle=e,oe=e)}function b(e){se!==e&&(J.fillStyle=e,se=e)}function y(e){le.length!==e.length&&(J.setLineDash(e),le=e)}console.log("THREE.CanvasRenderer",THREE.REVISION);var E=THREE.Math.smoothstep;e=e||{};var _,w,C,S,k,R,T,H,A,x,O,$,M,L,I,D,z,N,q,j,P=this,F=new THREE.Projector,B=void 0!==e.canvas?e.canvas:document.createElement("canvas"),V=B.width,G=B.height,U=Math.floor(V/2),W=Math.floor(G/2),Y=0,X=0,Z=V,K=G,Q=1,J=B.getContext("2d",{alpha:e.alpha===!0}),ee=new THREE.Color(0),ie=e.alpha===!0?0:1,te=1,ne=0,oe=null,se=null,re=null,ae=null,ce=null,le=[],de=(new THREE.RenderableVertex,new THREE.RenderableVertex,new THREE.Color),he=(new THREE.Color,new THREE.Color,new THREE.Color,new THREE.Color,new THREE.Color),ue=new THREE.Color,pe=new THREE.Color,me={},ge=new THREE.Box2,fe=new THREE.Box2,ve=new THREE.Box2,be=new THREE.Color,ye=new THREE.Color,Ee=new THREE.Color,_e=new THREE.Vector3,we=new THREE.Vector3,Ce=new THREE.Vector3,Se=new THREE.Matrix3;void 0===J.setLineDash&&(J.setLineDash=function{}),this.domElement=B,this.autoClear=!0,this.sortObjects=!0,this.sortElements=!0,this.info={render:{vertices:0,faces:0}},this.supportsVertexTextures=function{},this.setFaceCulling=function{},this.getContext=function{return J},this.getContextAttributes=function{return J.getContextAttributes},this.getPixelRatio=function{return Q},this.setPixelRatio=function(e){void 0!==e&&(Q=e)},this.setSize=function(e,i,t){V=e*Q,G=i*Q,B.width=V,B.height=G,U=Math.floor(V/2),W=Math.floor(G/2),t!==!1&&(B.style.width=e+"px",B.style.height=i+"px"),ge.min.set(-U,-W),ge.max.set(U,W),fe.min.set(-U,-W),fe.max.set(U,W),te=1,ne=0,oe=null,se=null,re=null,ae=null,ce=null,this.setViewport(0,0,e,i)},this.setViewport=function(e,i,t,n){Y=e*Q,X=i*Q,Z=t*Q,K=n*Q},this.setScissor=function{},this.enableScissorTest=function{},this.setClearColor=function(e,i){ee.set(e),ie=void 0!==i?i:1,fe.min.set(-U,-W),fe.max.set(U,W)},this.setClearColorHex=function(e,i){console.warn("THREE.CanvasRenderer: .setClearColorHex is being removed. Use .setClearColor instead."),this.setClearColor(e,i)},this.getClearColor=function{return ee},this.getClearAlpha=function{return ie},this.getMaxAnisotropy=function{return 0},this.clear=function{fe.empty===!1&&(fe.intersect(ge),fe.expandByScalar(2),fe.min.x=fe.min.x+U,fe.min.y=-fe.min.y+W,fe.max.x=fe.max.x+U,fe.max.y=-fe.max.y+W,1>ie&&J.clearRect(0|fe.min.x,0|fe.max.y,fe.max.x-fe.min.x|0,fe.min.y-fe.max.y|0),ie>0&&(p(THREE.NormalBlending),u(1),b("rgba("+Math.floor(255*ee.r)+","+Math.floor(255*ee.g)+","+Math.floor(255*ee.b)+","+ie+")"),J.fillRect(0|fe.min.x,0|fe.max.y,fe.max.x-fe.min.x|0,fe.min.y-fe.max.y|0)),fe.makeEmpty)},this.clearColor=function{},this.clearDepth=function{},this.clearStencil=function{},this.render=function(e,t){if(t instanceof THREE.Camera==!1)return void console.error("THREE.CanvasRenderer.render: camera is not an instance of THREE.Camera.");this.autoClear===!0&&this.clear,P.info.render.vertices=0,P.info.render.faces=0,J.setTransform(Z/V,0,0,-K/G,Y,G-X),J.translate(U,W),_=F.projectScene(e,t,this.sortObjects,this.sortElements),w=_.elements,C=_.lights,S=t,Se.getNormalMatrix(t.matrixWorldInverse),i;for(var r=0,a=w.length;a>r;r++){var c=w[r],l=c.material;if(void 0!==l&&0!==l.opacity){if(ve.makeEmpty,c instanceof THREE.RenderableSprite)k=c,k.x*=U,k.y*=W,n(k,c,l);else if(c instanceof THREE.RenderableLine)k=c.v1,R=c.v2,k.positionScreen.x*=U,k.positionScreen.y*=W,R.positionScreen.x*=U,R.positionScreen.y*=W,ve.setFromPoints([k.positionScreen,R.positionScreen]),ge.isIntersectionBox(ve)===!0&&o(k,R,c,l);else if(c instanceof THREE.RenderableFace){if(k=c.v1,R=c.v2,T=c.v3,k.positionScreen.z<-1||k.positionScreen.z>1)continue;if(R.positionScreen.z<-1||R.positionScreen.z>1)continue;if(T.positionScreen.z<-1||T.positionScreen.z>1)continue;k.positionScreen.x*=U,k.positionScreen.y*=W,R.positionScreen.x*=U,R.positionScreen.y*=W,T.positionScreen.x*=U,T.positionScreen.y*=W,l.overdraw>0&&(h(k.positionScreen,R.positionScreen,l.overdraw),h(R.positionScreen,T.positionScreen,l.overdraw),h(T.positionScreen,k.positionScreen,l.overdraw)),ve.setFromPoints([k.positionScreen,R.positionScreen,T.positionScreen]),ge.isIntersectionBox(ve)===!0&&s(k,R,T,0,1,2,c,l)}fe.union(ve)}}J.setTransform(1,0,0,1,0,0)}},THREE.TrackballControls=function(e,i,t){function n(e){u.enabled!==!1&&(window.removeEventListener("keydown",n),g=u._state,u._state===u.STATE.NONE&&(e.keyCode!==u.keys[u.STATE.ROTATE]||u.noRotate?e.keyCode!==u.keys[u.STATE.ZOOM]||u.noZoom?e.keyCode!==u.keys[u.STATE.PAN]||u.noPan||(u._state=u.STATE.PAN):u._state=u.STATE.ZOOM:u._state=u.STATE.ROTATE))}function o(e){u.enabled!==!1&&(u._state=g,window.addEventListener("keydown",n,!1))}function s(e){u.enabled!==!1&&(e.preventDefault,e.stopPropagation,u._state===u.STATE.NONE&&(u._state=e.button),u._state!==u.STATE.ROTATE||u.noRotate?u._state!==u.STATE.ZOOM||u.noZoom?u._state!==u.STATE.PAN||u.noPan||(u._panStart.copy(w(e.pageX,e.pageY)),u._panEnd.copy(u._panStart)):(u._zoomStart.copy(w(e.pageX,e.pageY)),u._zoomEnd.copy(u._zoomStart)):(u._rotateStart.copy(C(e.pageX,e.pageY)),u._rotateEnd.copy(u._rotateStart)),document.addEventListener("mousemove",r,!1),document.addEventListener("mouseup",a,!1),u.dispatchEvent(E))}function r(e){u.enabled!==!1&&(e.preventDefault,e.stopPropagation,u._state!==u.STATE.ROTATE||u.noRotate?u._state!==u.STATE.ZOOM||u.noZoom?u._state!==u.STATE.PAN||u.noPan||u._panEnd.copy(w(e.pageX,e.pageY)):u._zoomEnd.copy(w(e.pageX,e.pageY)):u._rotateEnd.copy(C(e.pageX,e.pageY)))}function a(e){u.enabled!==!1&&(e.preventDefault,e.stopPropagation,u._state=u.STATE.NONE,document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",a),u.dispatchEvent(_))}function c(e){if(u.enabled!==!1){e.preventDefault,e.stopPropagation;var i=0;e.wheelDelta?i=e.wheelDelta/40:e.detail&&(i=-e.detail/3),u._zoomStart.y=.01*i,u.dispatchEvent(E),u.dispatchEvent(_)}}function l(e){if(u.enabled!==!1){switch(e.touches.length){case 1:u._state=u.STATE.TOUCH_ROTATE,u._rotateStart.copy(C(e.touches[0].pageX,e.touches[0].pageY)),u._rotateEnd.copy(u._rotateStart);break;case 2:u._state=u.STATE.TOUCH_ZOOM_PAN;var i=e.touches[0].pageX-e.touches[1].pageX,t=e.touches[0].pageY-e.touches[1].pageY;b=v=Math.sqrt(i*i+t*t);var n=(e.touches[0].pageX+e.touches[1].pageX)/2,o=(e.touches[0].pageY+e.touches[1].pageY)/2;u._panStart.copy(w(n,o)),u._panEnd.copy(u._panStart);break;default:u._state=u.STATE.NONE}u.dispatchEvent(E)}}function d(e){if(u.enabled!==!1)switch(e.preventDefault,e.stopPropagation,e.touches.length){case 1:u._rotateEnd.copy(C(e.touches[0].pageX,e.touches[0].pageY));break;case 2:var i=e.touches[0].pageX-e.touches[1].pageX,t=e.touches[0].pageY-e.touches[1].pageY;b=Math.sqrt(i*i+t*t);var n=(e.touches[0].pageX+e.touches[1].pageX)/2,o=(e.touches[0].pageY+e.touches[1].pageY)/2;u._panEnd.copy(w(n,o));break;default:u._state=u.STATE.NONE}}function h(e){if(u.enabled!==!1){switch(e.touches.length){case 1:u._rotateEnd.copy(C(e.touches[0].pageX,e.touches[0].pageY)),u._rotateStart.copy(u._rotateEnd);break;case 2:v=b=0;var i=(e.touches[0].pageX+e.touches[1].pageX)/2,t=(e.touches[0].pageY+e.touches[1].pageY)/2;u._panEnd.copy(w(i,t)),u._panStart.copy(u._panEnd)}u._state=u.STATE.NONE,u.dispatchEvent(_)}}var u=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!==i?i: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 p=1e-6,m=new THREE.Vector3;this._state=this.STATE.NONE;var g=this.STATE.NONE,f=new THREE.Vector3;this._rotateStart=new THREE.Vector3,this._rotateEnd=new THREE.Vector3,this._zoomStart=new THREE.Vector2,this._zoomEnd=new THREE.Vector2;var v=0,b=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 y={type:"change"},E={type:"start"},_={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{var e=this.domElement.getBoundingClientRect,i=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-i.clientLeft,this.screen.top=e.top+window.pageYOffset-i.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 w=function{var e=new THREE.Vector2;return function(i,t){return e.set((i-u.screen.left)/u.screen.width,(t-u.screen.top)/u.screen.height),e}},C=function{var e=new THREE.Vector3,i=new THREE.Vector3,t=new THREE.Vector3;return function(n,o){t.set((n-.5*u.screen.width-u.screen.left)/(.5*u.screen.width),(.5*u.screen.height+u.screen.top-o)/(.5*u.screen.height),0);var s=t.length;return u.noRoll?s1?t.normalize:t.z=Math.sqrt(1-s*s),f.copy(u.object.position).sub(u.target),e.copy(u.object.up).setLength(t.y),e.add(i.copy(u.object.up).cross(f).setLength(t.x)),e.add(f.setLength(t.z)),e}};this.rotateCamera=function(e,i){var n=new THREE.Vector3,o=new THREE.Quaternion;return function(e,i){var s;void 0===e&&(s=Math.acos(u._rotateStart.dot(u._rotateEnd)/u._rotateStart.length/u._rotateEnd.length)),(s||void 0!==e)&&(void 0===e?(n.crossVectors(u._rotateStart,u._rotateEnd).normalize,s*=u.rotateSpeed,o.setFromAxisAngle(n,-s)):o.copy(e),(void 0===i||i===!0)&&t.quaternion.multiplyQuaternions(o,t.quaternion),f.applyQuaternion(o),u.object.up.applyQuaternion(o),u._rotateEnd.applyQuaternion(o),u.staticMoving?u._rotateStart.copy(u._rotateEnd):(o.setFromAxisAngle(n,s*(u.dynamicDampingFactor-1)),u._rotateStart.applyQuaternion(o)))}},this.zoomCamera=function(e,i){if(u._state===u.STATE.TOUCH_ZOOM_PAN){var n;void 0!==e?n=e:(n=v/b,v=b),f.multiplyScalar(n),(void 0===i||i===!0)&&(t._zoomFactor*=n)}else{var n;n=void 0!==e?e:1+(u._zoomEnd.y-u._zoomStart.y)*u.zoomSpeed,(void 0===i||i===!0)&&(t._zoomFactor*=n),1!==n&&(f.multiplyScalar(n),u.staticMoving?u._zoomStart.copy(u._zoomEnd):u._zoomStart.y+=(u._zoomEnd.y-u._zoomStart.y)*this.dynamicDampingFactor)}},this.panCamera=function(e,i){var n=new THREE.Vector2,o=new THREE.Vector3,s=new THREE.Vector3;return function(e,i){void 0!==e?(n=e,(void 0===i||i===!0)&&t.mouseChange.add(e)):(n.copy(u._panEnd).sub(u._panStart),(void 0===i||i===!0)&&t.mouseChange.add(u._panEnd).sub(u._panStart)),n.lengthSq&&(n.multiplyScalar(f.length*u.panSpeed),s.copy(f).cross(u.object.up).setLength(n.x),s.add(o.copy(u.object.up).setLength(n.y)),u.object.position.add(s),u.target.add(s),u.staticMoving?u._panStart.copy(u._panEnd):u._panStart.add(n.subVectors(u._panEnd,u._panStart).multiplyScalar(u.dynamicDampingFactor)))}},this.checkDistances=function{u.noZoom&&u.noPan||(f.lengthSq>u.maxDistance*u.maxDistance&&u.object.position.addVectors(u.target,f.setLength(u.maxDistance)),f.lengthSq<u.minDistance*u.minDistance&&u.object.position.addVectors(u.target,f.setLength(u.minDistance)))},this.update=function(e){f.subVectors(u.object.position,u.target),u.noRotate||(void 0!==e&&void 0!==e.quaternion?u.rotateCamera(e.quaternion,e.update):u.rotateCamera),u.noZoom||(void 0!==e&&void 0!==e._zoomFactor?u.zoomCamera(e._zoomFactor,e.update):u.zoomCamera),u.noPan||(void 0!==e&&void 0!==e.mouseChange?u.panCamera(e.mouseChange,e.update):u.panCamera),u.object.position.addVectors(u.target,f),u.checkDistances,u.object.lookAt(u.target),m.distanceToSquared(u.object.position)>p&&(u.dispatchEvent(y),m.copy(u.object.position))},this.reset=function{u._state=u.STATE.NONE,g=u.STATE.NONE,u.target.copy(u.target0),u.object.position.copy(u.position0),u.object.up.copy(u.up0),f.subVectors(u.object.position,u.target),u.object.lookAt(u.target),u.dispatchEvent(y),m.copy(u.object.position)},this.domElement.addEventListener("contextmenu",function(e){e.preventDefault},!1),this.domElement.addEventListener("mousedown",s,!1),this.domElement.addEventListener("mousewheel",c,!1),this.domElement.addEventListener("DOMMouseScroll",c,!1),this.domElement.addEventListener("touchstart",l,!1),this.domElement.addEventListener("touchend",h,!1),this.domElement.addEventListener("touchmove",d,!1),window.addEventListener("keydown",n,!1),window.addEventListener("keyup",o,!1),this.handleResize,this.update},THREE.TrackballControls.prototype=Object.create(THREE.EventDispatcher.prototype),THREE.TrackballControls.prototype.constructor=THREE.TrackballControls,THREE.OrthographicTrackballControls=function(e,i,t){function n(e){u.enabled!==!1&&(window.removeEventListener("keydown",n),v=u._state,u._state===p.NONE&&(e.keyCode!==u.keys[p.ROTATE]||u.noRotate?e.keyCode!==u.keys[p.ZOOM]||u.noZoom?e.keyCode!==u.keys[p.PAN]||u.noPan||(u._state=p.PAN):u._state=p.ZOOM:u._state=p.ROTATE))}function o(e){u.enabled!==!1&&(u._state=v,window.addEventListener("keydown",n,!1))}function s(e){u.enabled!==!1&&(e.preventDefault,e.stopPropagation,u._state===p.NONE&&(u._state=e.button),u._state!==p.ROTATE||u.noRotate?u._state!==p.ZOOM||u.noZoom?u._state!==p.PAN||u.noPan||(u._panStart.copy(k(e.pageX,e.pageY)),u._panEnd.copy(u._panStart)):(u._zoomStart.copy(k(e.pageX,e.pageY)),u._zoomEnd.copy(u._zoomStart)):(u._rotateStart.copy(R(e.pageX,e.pageY)),u._rotateEnd.copy(u._rotateStart)),document.addEventListener("mousemove",r,!1),document.addEventListener("mouseup",a,!1),u.dispatchEvent(C))}function r(e){u.enabled!==!1&&(e.preventDefault,e.stopPropagation,u._state!==p.ROTATE||u.noRotate?u._state!==p.ZOOM||u.noZoom?u._state!==p.PAN||u.noPan||u._panEnd.copy(k(e.pageX,e.pageY)):u._zoomEnd.copy(k(e.pageX,e.pageY)):u._rotateEnd.copy(R(e.pageX,e.pageY)))}function a(e){u.enabled!==!1&&(e.preventDefault,e.stopPropagation,u._state=p.NONE,document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",a),u.dispatchEvent(S))}function c(e){if(u.enabled!==!1){e.preventDefault,e.stopPropagation;var i=0;e.wheelDelta?i=e.wheelDelta/40:e.detail&&(i=-e.detail/3),u._zoomStart.y=.01*i,u.dispatchEvent(C),u.dispatchEvent(S)}}function l(e){if(u.enabled!==!1){switch(e.touches.length){case 1:u._state=p.TOUCH_ROTATE,u._rotateStart.copy(R(e.touches[0].pageX,e.touches[0].pageY)),u._rotateEnd.copy(u._rotateStart);break;case 2:u._state=p.TOUCH_ZOOM_PAN;var i=e.touches[0].pageX-e.touches[1].pageX,t=e.touches[0].pageY-e.touches[1].pageY;_=E=Math.sqrt(i*i+t*t);var n=(e.touches[0].pageX+e.touches[1].pageX)/2,o=(e.touches[0].pageY+e.touches[1].pageY)/2;u._panStart.copy(k(n,o)),u._panEnd.copy(u._panStart);break;default:u._state=p.NONE}u.dispatchEvent(C)}}function d(e){if(u.enabled!==!1)switch(e.preventDefault,e.stopPropagation,e.touches.length){case 1:u._rotateEnd.copy(R(e.touches[0].pageX,e.touches[0].pageY));break;case 2:var i=e.touches[0].pageX-e.touches[1].pageX,t=e.touches[0].pageY-e.touches[1].pageY;_=Math.sqrt(i*i+t*t);var n=(e.touches[0].pageX+e.touches[1].pageX)/2,o=(e.touches[0].pageY+e.touches[1].pageY)/2;u._panEnd.copy(k(n,o));break;default:u._state=p.NONE}}function h(e){if(u.enabled!==!1){switch(e.touches.length){case 1:u._rotateEnd.copy(R(e.touches[0].pageX,e.touches[0].pageY)),u._rotateStart.copy(u._rotateEnd);break;case 2:E=_=0;var i=(e.touches[0].pageX+e.touches[1].pageX)/2,t=(e.touches[0].pageY+e.touches[1].pageY)/2;u._panEnd.copy(k(i,t)),u._panStart.copy(u._panEnd)}u._state=p.NONE,u.dispatchEvent(S)}}var u=this,p={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4};this.object=e,this.domElement=void 0!==i?i:document,this.enabled=!0,this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=.5,this.zoomSpeed=1.2;var m=.01;this.zoomSpeed*=m,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 g=1e-6,f=new THREE.Vector3;this._state=p.NONE;var v=p.NONE,b=new THREE.Vector3;this._rotateStart=new THREE.Vector3,this._rotateEnd=new THREE.Vector3,this._zoomStart=new THREE.Vector2,this._zoomEnd=new THREE.Vector2;var y=1,E=0,_=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 w={type:"change"},C={type:"start"},S={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{var e=this.domElement.getBoundingClientRect,i=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-i.clientLeft,this.screen.top=e.top+window.pageYOffset-i.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 k=function{var e=new THREE.Vector2;return function(i,t){return e.set((i-u.screen.left)/u.screen.width,(t-u.screen.top)/u.screen.height),e}},R=function{var e=new THREE.Vector3,i=new THREE.Vector3,t=new THREE.Vector3;return function(n,o){t.set((n-.5*u.screen.width-u.screen.left)/(.5*u.screen.width),(.5*u.screen.height+u.screen.top-o)/(.5*u.screen.height),0);var s=t.length;return u.noRoll?s1?t.normalize:t.z=Math.sqrt(1-s*s),b.copy(u.object.position).sub(u.target),e.copy(u.object.up).setLength(t.y),e.add(i.copy(u.object.up).cross(b).setLength(t.x)),e.add(b.setLength(t.z)),e}};this.rotateCamera=function(e,i){var n=new THREE.Vector3,o=new THREE.Quaternion;return function(e,i){var s;void 0===e&&(s=Math.acos(u._rotateStart.dot(u._rotateEnd)/u._rotateStart.length/u._rotateEnd.length)),(s||void 0!==e)&&(void 0===e?(n.crossVectors(u._rotateStart,u._rotateEnd).normalize,s*=u.rotateSpeed,o.setFromAxisAngle(n,-s)):o.copy(e),(void 0===i||i===!0)&&t.quaternion.multiplyQuaternions(o,t.quaternion),b.applyQuaternion(o),u.object.up.applyQuaternion(o),u._rotateEnd.applyQuaternion(o),u.staticMoving?u._rotateStart.copy(u._rotateEnd):(o.setFromAxisAngle(n,s*(u.dynamicDampingFactor-1)),u._rotateStart.applyQuaternion(o)))}},this.zoomCamera=function(e,i){var n;u._state===p.TOUCH_ZOOM_PAN?void 0!==e?n=e:(n=E/_,E=_):n=void 0!==e?e:1+(u._zoomEnd.y-u._zoomStart.y)*u.zoomSpeed/m,(void 0===i||i===!0)&&(t._zoomFactor*=n),1!==n&&(y=n,u.object.left=y*u.left0+(1-y)*u.center0.x,u.object.right=y*u.right0+(1-y)*u.center0.x,u.object.top=y*u.top0+(1-y)*u.center0.y,u.object.bottom=y*u.bottom0+(1-y)*u.center0.y,u.staticMoving?u._zoomStart.copy(u._zoomEnd):u._zoomStart.y+=(u._zoomEnd.y-u._zoomStart.y)*this.dynamicDampingFactor)},this.panCamera=function(e,i){var n=new THREE.Vector2,o=new THREE.Vector3,s=new THREE.Vector3;return function(e,i){void 0!==e?(n=e,(void 0===i||i===!0)&&t.mouseChange.add(e)):(n.copy(u._panEnd).sub(u._panStart),(void 0===i||i===!0)&&t.mouseChange.add(u._panEnd).sub(u._panStart)),n.lengthSq&&(n.multiplyScalar(b.length*u.panSpeed),s.copy(b).cross(u.object.up).setLength(n.x),s.add(o.copy(u.object.up).setLength(n.y)),u.object.position.add(s),u.target.add(s),u.staticMoving?u._panStart.copy(u._panEnd):u._panStart.add(n.subVectors(u._panEnd,u._panStart).multiplyScalar(u.dynamicDampingFactor)))}},this.update=function(e){b.subVectors(u.object.position,u.target),u.noRotate||(void 0!==e&&void 0!==e.quaternion?u.rotateCamera(e.quaternion,e.update):u.rotateCamera),u.noZoom||(void 0!==e&&void 0!==e._zoomFactor?u.zoomCamera(e._zoomFactor,e.update):u.zoomCamera,u.object.updateProjectionMatrix),u.noPan||(void 0!==e&&void 0!==e.mouseChange?u.panCamera(e.mouseChange,e.update):u.panCamera),u.object.position.addVectors(u.target,b),u.object.lookAt(u.target),f.distanceToSquared(u.object.position)>g&&(u.dispatchEvent(w),f.copy(u.object.position))},this.reset=function{u._state=p.NONE,v=p.NONE,u.target.copy(u.target0),u.object.position.copy(u.position0),u.object.up.copy(u.up0),b.subVectors(u.object.position,u.target),u.object.left=u.left0,u.object.right=u.right0,u.object.top=u.top0,u.object.bottom=u.bottom0,u.object.lookAt(u.target),u.dispatchEvent(w),f.copy(u.object.position)},this.domElement.addEventListener("contextmenu",function(e){e.preventDefault},!1),this.domElement.addEventListener("mousedown",s,!1),this.domElement.addEventListener("mousewheel",c,!1),this.domElement.addEventListener("DOMMouseScroll",c,!1),this.domElement.addEventListener("touchstart",l,!1),this.domElement.addEventListener("touchend",h,!1),this.domElement.addEventListener("touchmove",d,!1),window.addEventListener("keydown",n,!1),window.addEventListener("keyup",o,!1),this.handleResize,this.update},THREE.OrthographicTrackballControls.prototype=Object.create(THREE.EventDispatcher.prototype),THREE.OrthographicTrackballControls.prototype.constructor=THREE.OrthographicTrackballControls,THREE.RenderableObject=function{this.id=0,this.object=null,this.z=0},THREE.RenderableFace=function{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{this.position=new THREE.Vector3,this.positionWorld=new THREE.Vector3,this.positionScreen=new THREE.Vector4,this.visible=!0},THREE.RenderableVertex.prototype.copy=function(e){this.positionWorld.copy(e.positionWorld),this.positionScreen.copy(e.positionScreen)},THREE.RenderableLine=function{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{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{function e{if(c===y){var e=new THREE.RenderableObject;return b.push(e),y++,c++,e}return b[c++]}function i{if(d===_){var e=new THREE.RenderableVertex;return E.push(e),_++,d++,e}return E[d++]}function t{if(u===C){var e=new THREE.RenderableFace;return w.push(e),C++,u++,e}return w[u++]}function n{if(m===k){var e=new THREE.RenderableLine;return S.push(e),k++,m++,e}return S[m++]}function o{if(f===T){var e=new THREE.RenderableSprite;return R.push(e),T++,f++,e}return R[f++]}function s(e,i){return e.z!==i.z?i.z-e.z:e.id!==i.id?e.id-i.id:0}function r(e,i){var t=0,n=1,o=e.z+e.w,s=i.z+i.w,r=-e.z+e.w,a=-i.z+i.w;return o>=0&&s>=0&&r>=0&&a>=0?!0:0>o&&0>s||0>r&&0>a?!1:(0>o?t=Math.max(t,o/(o-s)):0>s&&(n=Math.min(n,o/(o-s))),0>r?t=Math.max(t,r/(r-a)):0>a&&(n=Math.min(n,r/(r-a))),t>n?!1:(e.lerp(i,t),i.lerp(e,1-n),!0))}var a,c,l,d,h,u,p,m,g,f,v,b=[],y=0,E=[],_=0,w=[],C=0,S=[],k=0,R=[],T=0,H={objects:[],lights:[],elements:[]},A=new THREE.Vector3,x=new THREE.Vector3,O=new THREE.Vector3,$=new THREE.Vector3,M=new THREE.Vector4,L=new THREE.Box3(new THREE.Vector3(-1,-1,-1),new THREE.Vector3(1,1,1)),I=new THREE.Box3,D=new Array(3),z=(new Array(4),new THREE.Matrix4),N=new THREE.Matrix4,q=new THREE.Matrix4,j=new THREE.Matrix3,P=new THREE.Frustum,F=new THREE.Vector4,B=new THREE.Vector4; this.projectVector=function(e,i){console.warn("THREE.Projector: .projectVector is now vector.project."),e.project(i)},this.unprojectVector=function(e,i){console.warn("THREE.Projector: .unprojectVector is now vector.unproject."),e.unproject(i)},this.pickingRay=function(e,i){console.error("THREE.Projector: .pickingRay is now raycaster.setFromCamera.")};var V=function{var e=[],o=[],s=null,r=null,a=new THREE.Matrix3,c=function(i){s=i,r=s.material,a.getNormalMatrix(s.matrixWorld),e.length=0,o.length=0},d=function(e){var i=e.position,t=e.positionWorld,n=e.positionScreen;t.copy(i).applyMatrix4(v),n.copy(t).applyMatrix4(N);var o=1/n.w;n.x*=o,n.y*=o,n.z*=o,e.visible=n.x>=-1&&n.x<=1&&n.y>=-1&&n.y<=1&&n.z>=-1&&n.z<=1},u=function(e,t,n){l=i,l.position.set(e,t,n),d(l)},m=function(i,t,n){e.push(i,t,n)},g=function(e,i){o.push(e,i)},f=function(e,i,t){return e.visible===!0||i.visible===!0||t.visible===!0?!0:(D[0]=e.positionScreen,D[1]=i.positionScreen,D[2]=t.positionScreen,L.isIntersectionBox(I.setFromPoints(D)))},b=function(e,i,t){return(t.positionScreen.x-e.positionScreen.x)*(i.positionScreen.y-e.positionScreen.y)-(t.positionScreen.y-e.positionScreen.y)*(i.positionScreen.x-e.positionScreen.x)<0},y=function(e,i){var t=E[e],o=E[i];p=n,p.id=s.id,p.v1.copy(t),p.v2.copy(o),p.z=(t.positionScreen.z+o.positionScreen.z)/2,p.material=s.material,H.elements.push(p)},_=function(i,n,c){var l=E[i],d=E[n],u=E[c];if(f(l,d,u)!==!1&&(r.side===THREE.DoubleSide||b(l,d,u)===!0)){h=t,h.id=s.id,h.v1.copy(l),h.v2.copy(d),h.v3.copy(u),h.z=(l.positionScreen.z+d.positionScreen.z+u.positionScreen.z)/3;for(var p=0;3>p;p++){var m=3*arguments[p],g=h.vertexNormalsModel[p];g.set(e[m],e[m+1],e[m+2]),g.applyMatrix3(a).normalize;var v=2*arguments[p],y=h.uvs[p];y.set(o[v],o[v+1])}h.vertexNormalsLength=3,h.material=s.material,H.elements.push(h)}};return{setObject:c,projectVertex:d,checkTriangleVisibility:f,checkBackfaceCulling:b,pushVertex:u,pushNormal:m,pushUv:g,pushLine:y,pushTriangle:_}},G=new V;this.projectScene=function(l,b,y,_){u=0,m=0,f=0,H.elements.length=0,l.autoUpdate===!0&&l.updateMatrixWorld,void 0===b.parent&&b.updateMatrixWorld,z.copy(b.matrixWorldInverse.getInverse(b.matrixWorld)),N.multiplyMatrices(b.projectionMatrix,z),P.setFromMatrix(N),c=0,H.objects.length=0,H.lights.length=0,l.traverseVisible(function(i){if(i instanceof THREE.Light)H.lights.push(i);else if(i instanceof THREE.Mesh||i instanceof THREE.Line||i instanceof THREE.Sprite){if(i.material.visible===!1)return;(i.frustumCulled===!1||P.intersectsObject(i)===!0)&&(a=e,a.id=i.id,a.object=i,$.setFromMatrixPosition(i.matrixWorld),$.applyProjection(N),a.z=$.z,H.objects.push(a))}}),y===!0&&H.objects.sort(s);for(var w=0,C=H.objects.length;C>w;w++){var S=H.objects[w].object,k=S.geometry;if(G.setObject(S),v=S.matrixWorld,d=0,S instanceof THREE.Mesh){if(k instanceof THREE.BufferGeometry){var R=k.attributes,T=k.offsets;if(void 0===R.position)continue;for(var L=R.position.array,I=0,D=L.length;D>I;I+=3)G.pushVertex(L[I],L[I+1],L[I+2]);if(void 0!==R.normal)for(var V=R.normal.array,I=0,D=V.length;D>I;I+=3)G.pushNormal(V[I],V[I+1],V[I+2]);if(void 0!==R.uv)for(var U=R.uv.array,I=0,D=U.length;D>I;I+=2)G.pushUv(U[I],U[I+1]);if(void 0!==R.index){var W=R.index.array;if(T.length>0)for(var w=0;wI;I+=3)G.pushTriangle(W[I]+X,W[I+1]+X,W[I+2]+X);else for(var I=0,D=W.length;D>I;I+=3)G.pushTriangle(W[I],W[I+1],W[I+2])}else for(var I=0,D=L.length/3;D>I;I+=3)G.pushTriangle(I,I+1,I+2)}else if(k instanceof THREE.Geometry){var Z=k.vertices,K=k.faces,Q=k.faceVertexUvs[0];j.getNormalMatrix(v);for(var J=S.material instanceof THREE.MeshFaceMaterial,ee=J===!0?S.material:null,ie=0,te=Z.length;te>ie;ie++){var ne=Z[ie];G.pushVertex(ne.x,ne.y,ne.z)}for(var oe=0,se=K.length;se>oe;oe++){var re=K[oe],ae=J===!0?ee.materials[re.materialIndex]:S.material;if(void 0!==ae){var ce=ae.side,le=E[re.a],de=E[re.b],he=E[re.c];if(ae.morphTargets===!0){var ue=k.morphTargets,pe=S.morphTargetInfluences,me=le.position,ge=de.position,fe=he.position;A.set(0,0,0),x.set(0,0,0),O.set(0,0,0);for(var ve=0,be=ue.length;be>ve;ve++){var ye=pe[ve];if(0!==ye){var Ee=ue[ve].vertices;A.x+=(Ee[re.a].x-me.x)*ye,A.y+=(Ee[re.a].y-me.y)*ye,A.z+=(Ee[re.a].z-me.z)*ye,x.x+=(Ee[re.b].x-ge.x)*ye,x.y+=(Ee[re.b].y-ge.y)*ye,x.z+=(Ee[re.b].z-ge.z)*ye,O.x+=(Ee[re.c].x-fe.x)*ye,O.y+=(Ee[re.c].y-fe.y)*ye,O.z+=(Ee[re.c].z-fe.z)*ye}}le.position.add(A),de.position.add(x),he.position.add(O),G.projectVertex(le),G.projectVertex(de),G.projectVertex(he)}if(G.checkTriangleVisibility(le,de,he)!==!1){var _e=G.checkBackfaceCulling(le,de,he);if(ce!==THREE.DoubleSide){if(ce===THREE.FrontSide&&_e===!1)continue;if(ce===THREE.BackSide&&_e===!0)continue}h=t,h.id=S.id,h.v1.copy(le),h.v2.copy(de),h.v3.copy(he),h.normalModel.copy(re.normal),_e!==!1||ce!==THREE.BackSide&&ce!==THREE.DoubleSide||h.normalModel.negate,h.normalModel.applyMatrix3(j).normalize;for(var we=re.vertexNormals,Ce=0,Se=Math.min(we.length,3);Se>Ce;Ce++){var ke=h.vertexNormalsModel[Ce];ke.copy(we[Ce]),_e!==!1||ce!==THREE.BackSide&&ce!==THREE.DoubleSide||ke.negate,ke.applyMatrix3(j).normalize}h.vertexNormalsLength=we.length;var Re=Q[oe];if(void 0!==Re)for(var Te=0;3>Te;Te++)h.uvs[Te].copy(Re[Te]);h.color=re.color,h.material=ae,h.z=(le.positionScreen.z+de.positionScreen.z+he.positionScreen.z)/3,H.elements.push(h)}}}}}else if(S instanceof THREE.Line){if(k instanceof THREE.BufferGeometry){var R=k.attributes;if(void 0!==R.position){for(var L=R.position.array,I=0,D=L.length;D>I;I+=3)G.pushVertex(L[I],L[I+1],L[I+2]);if(void 0!==R.index)for(var W=R.index.array,I=0,D=W.length;D>I;I+=2)G.pushLine(W[I],W[I+1]);else for(var He=S.mode===THREE.LinePieces?2:1,I=0,D=L.length/3-1;D>I;I+=He)G.pushLine(I,I+1)}}else if(k instanceof THREE.Geometry){q.multiplyMatrices(N,v);var Z=S.geometry.vertices;if(0===Z.length)continue;le=i,le.positionScreen.copy(Z[0]).applyMatrix4(q);for(var He=S.mode===THREE.LinePieces?2:1,ie=1,te=Z.length;te>ie;ie++)le=i,le.positionScreen.copy(Z[ie]).applyMatrix4(q),(ie+1)%He>0||(de=E[d-2],F.copy(le.positionScreen),B.copy(de.positionScreen),r(F,B)===!0&&(F.multiplyScalar(1/F.w),B.multiplyScalar(1/B.w),p=n,p.id=S.id,p.v1.positionScreen.copy(F),p.v2.positionScreen.copy(B),p.z=Math.max(F.z,B.z),p.material=S.material,S.material.vertexColors===THREE.VertexColors&&(p.vertexColors[0].copy(S.geometry.colors[ie]),p.vertexColors[1].copy(S.geometry.colors[ie-1])),H.elements.push(p)))}}else if(S instanceof THREE.Sprite){M.set(v.elements[12],v.elements[13],v.elements[14],1),M.applyMatrix4(N);var Ae=1/M.w;M.z*=Ae,M.z>=-1&&M.z<=1&&(g=o,g.id=S.id,g.x=M.x*Ae,g.y=M.y*Ae,g.z=M.z,g.object=S,g.rotation=S.rotation,g.scale.x=S.scale.x*Math.abs(g.x-(M.x+b.projectionMatrix.elements[0])/(M.w+b.projectionMatrix.elements[12])),g.scale.y=S.scale.y*Math.abs(g.y-(M.y+b.projectionMatrix.elements[5])/(M.w+b.projectionMatrix.elements[13])),g.material=S.material,H.elements.push(g))}}return _===!0&&H.elements.sort(s),H}},$3Dmol={},$3Dmol.MarchingCubeInitializer=function{var e=2,i={};i.march=function(i,r,a,c){var l=!!c.fulltable,d=c.hasOwnProperty("origin")&&c.origin.hasOwnProperty("x")?c.origin:{x:0,y:0,z:0},h=!!c.voxel,u=c.nX||0,p=c.nY||0,m=c.nZ||0,g=c.scale||1,f=null;f=c.unitCube?c.unitCube:{x:g,y:g,z:g};var v,b,y=new Int32Array(u*p*m);for(v=0,b=y.length;b>v;++v)y[v]=-1;var E=function(e,i,t,n,o,s){var a={x:d.x,y:d.y,z:d.z},c=!!(n&1<v;++v)for(var S=0;p-1>S;++S)for(var k=0;m-1>k;++k){for(var R=0,T=0;8>T;++T){var H=(p*(v+((4&T)>>2))+S+((2&T)>>1))*m+k+(1&T),A=!!(i[H]&e);R|=A<=3&&(r.push(r[M]),M=r.length-1,r.push(r[L]),L=r.length-1,r.push(r[I]),I=r.length-1),a.push(M),a.push(L),a.push(I)}}}}y=null},i.laplacianSmooth=function(e,i,t){var n,o,s,r,a,c=new Array(i.length);for(n=0,o=i.length;o>n;n++)c[n]={x:0,y:0,z:0};var l,d=new Array(20);for(n=0;20>n;n++)d[n]=new Array(i.length);for(n=0,o=i.length;o>n;n++)d[0][n]=0;for(n=0,o=t.length/3;o>n;n++){var h=3*n,u=3*n+1,p=3*n+2;for(l=!0,s=0,r=d[0][t[h]];r>s;s++)if(t[u]==d[s+1][t[h]]){l=!1;break}for(l&&(d[0][t[h]]++,d[d[0][t[h]]][t[h]]=t[u]),l=!0,s=0,r=d[0][t[h]];r>s;s++)if(t[p]==d[s+1][t[h]]){l=!1;break}for(l&&(d[0][t[h]]++,d[d[0][t[h]]][t[h]]=t[p]),l=!0,s=0,r=d[0][t[u]];r>s;s++)if(t[h]==d[s+1][t[u]]){l=!1;break}for(l&&(d[0][t[u]]++,d[d[0][t[u]]][t[u]]=t[h]),l=!0,s=0,r=d[0][t[u]];r>s;s++)if(t[p]==d[s+1][t[u]]){l=!1;break}for(l&&(d[0][t[u]]++,d[d[0][t[u]]][t[u]]=t[p]),l=!0,s=0;ss;s++)if(t[u]==d[s+1][t[p]]){l=!1;break}l&&(d[0][t[p]]++,d[d[0][t[p]]][t[p]]=t[u])}var m=1,g=.5;for(a=0;e>a;a++){for(n=0,o=i.length;o>n;n++)if(d[0][n]<3)c[n].x=i[n].x,c[n].y=i[n].y,c[n].z=i[n].z;else if(3==d[0][n]||4==d[0][n]){for(c[n].x=0,c[n].y=0,c[n].z=0,s=0,r=d[0][n];r>s;s++)c[n].x+=i[d[s+1][n]].x,c[n].y+=i[d[s+1][n]].y,c[n].z+=i[d[s+1][n]].z;c[n].x+=g*i[n].x,c[n].y+=g*i[n].y,c[n].z+=g*i[n].z,c[n].x/=g+d[0][n],c[n].y/=g+d[0][n],c[n].z/=g+d[0][n]}else{for(c[n].x=0,c[n].y=0,c[n].z=0,s=0,r=d[0][n];r>s;s++)c[n].x+=i[d[s+1][n]].x,c[n].y+=i[d[s+1][n]].y,c[n].z+=i[d[s+1][n]].z;c[n].x+=m*i[n].x,c[n].y+=m*i[n].y,c[n].z+=m*i[n].z,c[n].x/=m+d[0][n],c[n].y/=m+d[0][n],c[n].z/=m+d[0][n]}for(n=0,o=i.length;o>n;n++)i[n].x=c[n].x,i[n].y=c[n].y,i[n].z=c[n].z}d=null,c=null},i.edgeTable=[0,0,0,0,0,0,0,2816,0,0,0,1792,0,3328,3584,3840,0,0,0,138,0,21,0,134,0,0,0,652,0,2067,3865,3600,0,0,0,42,0,0,0,294,0,0,21,28,0,3875,1049,3360,0,168,162,170,0,645,2475,2210,0,687,293,172,4010,3747,3497,3232,0,0,0,0,0,69,0,900,0,0,0,1792,138,131,1608,1920,0,81,0,2074,84,85,84,86,0,81,0,3676,330,1105,1881,1616,0,0,0,42,0,69,0,502,0,0,21,3580,138,2035,1273,1520,2816,104,2337,106,840,581,367,102,2816,3695,3429,3180,1898,1635,1385,1120,0,0,0,0,0,0,0,3910,0,0,69,588,42,2083,41,2880,0,0,0,1722,0,2293,4095,3830,0,255,757,764,2538,2291,3065,2800,0,0,81,338,0,3925,1119,3414,84,855,85,340,2130,2899,89,2384,1792,712,194,1162,4036,3781,3535,3270,708,719,197,204,3018,2755,2505,2240,0,0,0,0,168,420,168,1958,162,162,676,2988,170,163,680,928,3328,3096,3328,3642,52,53,1855,1590,2340,2111,2869,2620,298,51,825,560,3584,3584,3090,3482,1668,1941,1183,1430,146,2975,2069,2460,154,915,153,400,3840,3592,3329,3082,1796,1541,1295,1030,2818,2575,2309,2060,778,515,265,0];var t=new Uint32Array(i.edgeTable),n=i.triTable=[[],[],[],[],[],[],[],[11,9,8],[],[],[],[8,10,9],[],[10,8,11],[9,11,10],[8,10,9,8,11,10],[],[],[],[1,7,3],[],[4,2,0],[],[2,1,7],[],[],[],[2,7,3,2,9,7],[],[1,4,11,1,0,4],[3,8,0,11,9,4,11,10,9],[4,11,9,11,10,9],[],[],[],[5,3,1],[],[],[],[2,5,8,2,1,5],[],[],[2,4,0],[3,2,4],[],[0,9,1,8,10,5,8,11,10],[3,4,0,3,10,4],[5,8,10,8,11,10],[],[3,5,7],[7,1,5],[1,7,3,1,5,7],[],[9,2,0,9,7,2],[0,3,8,1,7,11,1,5,7],[11,1,7,1,5,7],[],[9,1,0,5,3,2,5,7,3],[8,2,5,8,0,2],[2,5,3,5,7,3],[3,9,1,3,8,9,7,11,10,7,10,5],[9,1,0,10,7,11,10,5,7],[3,8,0,7,10,5,7,11,10],[11,5,7,11,10,5],[],[],[],[],[],[0,6,2],[],[7,2,9,7,9,8],[],[],[],[8,10,9],[7,1,3],[7,1,0],[6,9,3,6,10,9],[7,10,8,10,9,8],[],[6,0,4],[],[11,1,4,11,3,1],[2,4,6],[2,0,4,2,4,6],[2,4,6],[1,4,2,4,6,2],[],[6,0,4],[],[2,11,3,6,9,4,6,10,9],[8,6,1,8,1,3],[10,0,6,0,4,6],[8,0,3,9,6,10,9,4,6],[10,4,6,10,9,4],[],[],[],[5,3,1],[],[0,6,2],[],[7,4,8,5,2,1,5,6,2],[],[],[2,4,0],[7,4,8,2,11,3,10,5,6],[7,1,3],[5,6,10,0,9,1,8,7,4],[5,6,10,7,0,3,7,4,0],[10,5,6,4,8,7],[9,11,8],[3,5,6],[0,5,11,0,11,8],[6,3,5,3,1,5],[3,9,6,3,8,9],[9,6,0,6,2,0],[0,3,8,2,5,6,2,1,5],[1,6,2,1,5,6],[9,11,8],[1,0,9,6,10,5,11,3,2],[6,10,5,2,8,0,2,11,8],[3,2,11,10,5,6],[10,5,6,9,3,8,9,1,3],[0,9,1,5,6,10],[8,0,3,10,5,6],[10,5,6],[],[],[],[],[],[],[],[1,10,2,9,11,6,9,8,11],[],[],[6,0,2],[3,6,9,3,2,6],[3,5,1],[0,5,1,0,11,5],[0,3,5],[6,9,11,9,8,11],[],[],[],[4,5,9,7,1,10,7,3,1],[],[11,6,7,2,4,5,2,0,4],[11,6,7,8,0,3,1,10,2,9,4,5],[6,7,11,1,10,2,9,4,5],[],[4,1,0,4,5,1,6,7,3,6,3,2],[9,4,5,0,6,7,0,2,6],[4,5,9,6,3,2,6,7,3],[6,7,11,5,3,8,5,1,3],[6,7,11,4,1,0,4,5,1],[4,5,9,3,8,0,11,6,7],[9,4,5,7,11,6],[],[],[0,6,4],[8,6,4,8,1,6],[],[0,10,2,0,9,10,4,8,11,4,11,6],[10,2,1,6,0,3,6,4,0],[10,2,1,11,4,8,11,6,4],[4,2,6],[1,0,9,2,4,8,2,6,4],[2,4,0,2,6,4],[8,2,4,2,6,4],[11,4,1,11,6,4],[0,9,1,4,11,6,4,8,11],[3,6,0,6,4,0],[8,6,4,8,11,6],[10,8,9],[6,3,9,6,7,3],[6,7,1],[10,7,1,7,3,1],[7,11,6,8,10,2,8,9,10],[11,6,7,10,0,9,10,2,0],[2,1,10,7,11,6,8,0,3],[1,10,2,6,7,11],[7,2,6,7,9,2],[1,0,9,3,6,7,3,2,6],[7,0,6,0,2,6],[2,7,3,2,6,7],[7,11,6,3,9,1,3,8,9],[9,1,0,11,6,7],[0,3,8,11,6,7],[11,6,7],[],[],[],[],[5,3,7],[8,5,2,8,7,5],[5,3,7],[1,10,2,5,8,7,5,9,8],[1,7,5],[1,7,5],[9,2,7,9,7,5],[11,3,2,8,5,9,8,7,5],[1,3,7,1,7,5],[0,7,1,7,5,1],[9,3,5,3,7,5],[9,7,5,9,8,7],[8,10,11],[3,4,10,3,10,11],[8,10,11],[5,9,4,1,11,3,1,10,11],[2,4,5],[5,2,4,2,0,4],[0,3,8,5,9,4,10,2,1],[2,1,10,9,4,5],[2,8,5,2,11,8],[3,2,11,1,4,5,1,0,4],[9,4,5,8,2,11,8,0,2],[11,3,2,9,4,5],[8,5,3,5,1,3],[5,0,4,5,1,0],[3,8,0,4,5,9],[9,4,5],[11,9,10],[11,9,10],[1,11,4,1,10,11],[8,7,4,11,1,10,11,3,1],[2,7,9,2,9,10],[4,8,7,0,10,2,0,9,10],[2,1,10,0,7,4,0,3,7],[10,2,1,8,7,4],[1,7,4],[3,2,11,4,8,7,9,1,0],[11,4,2,4,0,2],[2,11,3,7,4,8],[4,1,7,1,3,7],[1,0,9,8,7,4],[3,4,0,3,7,4],[8,7,4],[8,9,10,8,10,11],[3,9,11,9,10,11],[0,10,8,10,11,8],[10,3,1,10,11,3],[2,8,10,8,9,10],[9,2,0,9,10,2],[8,0,3,1,10,2],[10,2,1],[1,11,9,11,8,9],[11,3,2,0,9,1],[11,0,2,11,8,0],[11,3,2],[8,1,3,8,9,1],[9,1,0],[8,0,3],[]],o=[0,265,515,778,2060,2309,2575,2822,1030,1295,1541,1804,3082,3331,3593,3840,400,153,915,666,2460,2197,2975,2710,1430,1183,1941,1692,3482,3219,3993,3728,560,825,51,314,2620,2869,2111,2358,1590,1855,1077,1340,3642,3891,3129,3376,928,681,419,170,2988,2725,2479,2214,1958,1711,1445,1196,4010,3747,3497,3232,2240,2505,2755,3018,204,453,719,966,3270,3535,3781,4044,1226,1475,1737,1984,2384,2137,2899,2650,348,85,863,598,3414,3167,3925,3676,1370,1107,1881,1616,2800,3065,2291,2554,764,1013,255,502,3830,4095,3317,3580,1786,2035,1273,1520,2912,2665,2403,2154,876,613,367,102,3942,3695,3429,3180,1898,1635,1385,1120,1120,1385,1635,1898,3180,3429,3695,3942,102,367,613,876,2154,2403,2665,2912,1520,1273,2035,1786,3580,3317,4095,3830,502,255,1013,764,2554,2291,3065,2800,1616,1881,1107,1370,3676,3925,3167,3414,598,863,85,348,2650,2899,2137,2384,1984,1737,1475,1226,4044,3781,3535,3270,966,719,453,204,3018,2755,2505,2240,3232,3497,3747,4010,1196,1445,1711,1958,2214,2479,2725,2988,170,419,681,928,3376,3129,3891,3642,1340,1077,1855,1590,2358,2111,2869,2620,314,51,825,560,3728,3993,3219,3482,1692,1941,1183,1430,2710,2975,2197,2460,666,915,153,400,3840,3593,3331,3082,1804,1541,1295,1030,2822,2575,2309,2060,778,515,265,0],s=[[],[8,3,0],[9,0,1],[8,3,1,8,1,9],[11,2,3],[11,2,0,11,0,8],[11,2,3,0,1,9],[2,1,11,1,9,11,11,9,8],[10,1,2],[8,3,0,1,2,10],[9,0,2,9,2,10],[3,2,8,2,10,8,8,10,9],[10,1,3,10,3,11],[1,0,10,0,8,10,10,8,11],[0,3,9,3,11,9,9,11,10],[8,10,9,8,11,10],[8,4,7],[3,0,4,3,4,7],[1,9,0,8,4,7],[9,4,1,4,7,1,1,7,3],[2,3,11,7,8,4],[7,11,4,11,2,4,4,2,0],[3,11,2,4,7,8,9,0,1],[2,7,11,2,1,7,1,4,7,1,9,4],[10,1,2,8,4,7],[2,10,1,0,4,7,0,7,3],[4,7,8,0,2,10,0,10,9],[2,7,3,2,9,7,7,9,4,2,10,9],[8,4,7,11,10,1,11,1,3],[11,4,7,1,4,11,1,11,10,1,0,4],[3,8,0,7,11,4,11,9,4,11,10,9],[7,11,4,4,11,9,11,10,9],[9,5,4],[3,0,8,4,9,5],[5,4,0,5,0,1],[4,8,5,8,3,5,5,3,1],[11,2,3,9,5,4],[9,5,4,8,11,2,8,2,0],[3,11,2,1,5,4,1,4,0],[8,5,4,2,5,8,2,8,11,2,1,5],[2,10,1,9,5,4],[0,8,3,5,4,9,10,1,2],[10,5,2,5,4,2,2,4,0],[3,4,8,3,2,4,2,5,4,2,10,5],[5,4,9,1,3,11,1,11,10],[0,9,1,4,8,5,8,10,5,8,11,10],[3,4,0,3,10,4,4,10,5,3,11,10],[4,8,5,5,8,10,8,11,10],[9,5,7,9,7,8],[0,9,3,9,5,3,3,5,7],[8,0,7,0,1,7,7,1,5],[1,7,3,1,5,7],[11,2,3,8,9,5,8,5,7],[9,2,0,9,7,2,2,7,11,9,5,7],[0,3,8,2,1,11,1,7,11,1,5,7],[2,1,11,11,1,7,1,5,7],[1,2,10,5,7,8,5,8,9],[9,1,0,10,5,2,5,3,2,5,7,3],[5,2,10,8,2,5,8,5,7,8,0,2],[10,5,2,2,5,3,5,7,3],[3,9,1,3,8,9,7,11,10,7,10,5],[9,1,0,10,7,11,10,5,7],[3,8,0,7,10,5,7,11,10],[11,5,7,11,10,5],[11,7,6],[0,8,3,11,7,6],[9,0,1,11,7,6],[7,6,11,3,1,9,3,9,8],[2,3,7,2,7,6],[8,7,0,7,6,0,0,6,2],[1,9,0,3,7,6,3,6,2],[7,6,2,7,2,9,2,1,9,7,9,8],[1,2,10,6,11,7],[2,10,1,7,6,11,8,3,0],[11,7,6,10,9,0,10,0,2],[7,6,11,3,2,8,8,2,10,8,10,9],[6,10,7,10,1,7,7,1,3],[6,10,1,6,1,7,7,1,0,7,0,8],[9,0,3,6,9,3,6,10,9,6,3,7],[6,10,7,7,10,8,10,9,8],[8,4,6,8,6,11],[11,3,6,3,0,6,6,0,4],[0,1,9,4,6,11,4,11,8],[1,9,4,11,1,4,11,3,1,11,4,6],[3,8,2,8,4,2,2,4,6],[2,0,4,2,4,6],[1,9,0,3,8,2,2,8,4,2,4,6],[9,4,1,1,4,2,4,6,2],[10,1,2,11,8,4,11,4,6],[10,1,2,11,3,6,6,3,0,6,0,4],[0,2,10,0,10,9,4,11,8,4,6,11],[2,11,3,6,9,4,6,10,9],[8,4,6,8,6,1,6,10,1,8,1,3],[1,0,10,10,0,6,0,4,6],[8,0,3,9,6,10,9,4,6],[10,4,6,10,9,4],[9,5,4,7,6,11],[4,9,5,3,0,8,11,7,6],[6,11,7,4,0,1,4,1,5],[6,11,7,4,8,5,5,8,3,5,3,1],[4,9,5,6,2,3,6,3,7],[9,5,4,8,7,0,0,7,6,0,6,2],[4,0,1,4,1,5,6,3,7,6,2,3],[7,4,8,5,2,1,5,6,2],[6,11,7,1,2,10,9,5,4],[11,7,6,8,3,0,1,2,10,9,5,4],[11,7,6,10,5,2,2,5,4,2,4,0],[7,4,8,2,11,3,10,5,6],[4,9,5,6,10,7,7,10,1,7,1,3],[5,6,10,0,9,1,8,7,4],[5,6,10,7,0,3,7,4,0],[10,5,6,4,8,7],[5,6,9,6,11,9,9,11,8],[0,9,5,0,5,3,3,5,6,3,6,11],[0,1,5,0,5,11,5,6,11,0,11,8],[11,3,6,6,3,5,3,1,5],[9,5,6,3,9,6,3,8,9,3,6,2],[5,6,9,9,6,0,6,2,0],[0,3,8,2,5,6,2,1,5],[1,6,2,1,5,6],[1,2,10,5,6,9,9,6,11,9,11,8],[1,0,9,6,10,5,11,3,2],[6,10,5,2,8,0,2,11,8],[3,2,11,10,5,6],[10,5,6,9,3,8,9,1,3],[0,9,1,5,6,10],[8,0,3,10,5,6],[10,5,6],[10,6,5],[8,3,0,10,6,5],[0,1,9,5,10,6],[10,6,5,9,8,3,9,3,1],[3,11,2,10,6,5],[6,5,10,2,0,8,2,8,11],[1,9,0,6,5,10,11,2,3],[1,10,2,5,9,6,9,11,6,9,8,11],[1,2,6,1,6,5],[0,8,3,2,6,5,2,5,1],[5,9,6,9,0,6,6,0,2],[9,6,5,3,6,9,3,9,8,3,2,6],[11,6,3,6,5,3,3,5,1],[0,5,1,0,11,5,5,11,6,0,8,11],[0,5,9,0,3,5,3,6,5,3,11,6],[5,9,6,6,9,11,9,8,11],[10,6,5,4,7,8],[5,10,6,7,3,0,7,0,4],[5,10,6,0,1,9,8,4,7],[4,5,9,6,7,10,7,1,10,7,3,1],[7,8,4,2,3,11,10,6,5],[11,6,7,10,2,5,2,4,5,2,0,4],[11,6,7,8,0,3,1,10,2,9,4,5],[6,7,11,1,10,2,9,4,5],[7,8,4,5,1,2,5,2,6],[4,1,0,4,5,1,6,7,3,6,3,2],[9,4,5,8,0,7,0,6,7,0,2,6],[4,5,9,6,3,2,6,7,3],[6,7,11,4,5,8,5,3,8,5,1,3],[6,7,11,4,1,0,4,5,1],[4,5,9,3,8,0,11,6,7],[9,4,5,7,11,6],[10,6,4,10,4,9],[8,3,0,9,10,6,9,6,4],[1,10,0,10,6,0,0,6,4],[8,6,4,8,1,6,6,1,10,8,3,1],[2,3,11,6,4,9,6,9,10],[0,10,2,0,9,10,4,8,11,4,11,6],[10,2,1,11,6,3,6,0,3,6,4,0],[10,2,1,11,4,8,11,6,4],[9,1,4,1,2,4,4,2,6],[1,0,9,3,2,8,2,4,8,2,6,4],[2,4,0,2,6,4],[3,2,8,8,2,4,2,6,4],[1,4,9,11,4,1,11,1,3,11,6,4],[0,9,1,4,11,6,4,8,11],[11,6,3,3,6,0,6,4,0],[8,6,4,8,11,6],[6,7,10,7,8,10,10,8,9],[9,3,0,6,3,9,6,9,10,6,7,3],[6,1,10,6,7,1,7,0,1,7,8,0],[6,7,10,10,7,1,7,3,1],[7,11,6,3,8,2,8,10,2,8,9,10],[11,6,7,10,0,9,10,2,0],[2,1,10,7,11,6,8,0,3],[1,10,2,6,7,11],[7,2,6,7,9,2,2,9,1,7,8,9],[1,0,9,3,6,7,3,2,6],[8,0,7,7,0,6,0,2,6],[2,7,3,2,6,7],[7,11,6,3,9,1,3,8,9],[9,1,0,11,6,7],[0,3,8,11,6,7],[11,6,7],[11,7,5,11,5,10],[3,0,8,7,5,10,7,10,11],[9,0,1,10,11,7,10,7,5],[3,1,9,3,9,8,7,10,11,7,5,10],[10,2,5,2,3,5,5,3,7],[5,10,2,8,5,2,8,7,5,8,2,0],[9,0,1,10,2,5,5,2,3,5,3,7],[1,10,2,5,8,7,5,9,8],[2,11,1,11,7,1,1,7,5],[0,8,3,2,11,1,1,11,7,1,7,5],[9,0,2,9,2,7,2,11,7,9,7,5],[11,3,2,8,5,9,8,7,5],[1,3,7,1,7,5],[8,7,0,0,7,1,7,5,1],[0,3,9,9,3,5,3,7,5],[9,7,5,9,8,7],[4,5,8,5,10,8,8,10,11],[3,0,4,3,4,10,4,5,10,3,10,11],[0,1,9,4,5,8,8,5,10,8,10,11],[5,9,4,1,11,3,1,10,11],[3,8,4,3,4,2,2,4,5,2,5,10],[10,2,5,5,2,4,2,0,4],[0,3,8,5,9,4,10,2,1],[2,1,10,9,4,5],[8,4,5,2,8,5,2,11,8,2,5,1],[3,2,11,1,4,5,1,0,4],[9,4,5,8,2,11,8,0,2],[11,3,2,9,4,5],[4,5,8,8,5,3,5,1,3],[5,0,4,5,1,0],[3,8,0,4,5,9],[9,4,5],[7,4,11,4,9,11,11,9,10],[3,0,8,7,4,11,11,4,9,11,9,10],[11,7,4,1,11,4,1,10,11,1,4,0],[8,7,4,11,1,10,11,3,1],[2,3,7,2,7,9,7,4,9,2,9,10],[4,8,7,0,10,2,0,9,10],[2,1,10,0,7,4,0,3,7],[10,2,1,8,7,4],[2,11,7,2,7,1,1,7,4,1,4,9],[3,2,11,4,8,7,9,1,0],[7,4,11,11,4,2,4,0,2],[2,11,3,7,4,8],[9,1,4,4,1,7,1,3,7],[1,0,9,8,7,4],[3,4,0,3,7,4],[8,7,4],[8,9,10,8,10,11],[0,9,3,3,9,11,9,10,11],[1,10,0,0,10,8,10,11,8],[10,3,1,10,11,3],[3,8,2,2,8,10,8,9,10],[9,2,0,9,10,2],[8,0,3,1,10,2],[10,2,1],[2,11,1,1,11,9,11,8,9],[11,3,2,0,9,1],[11,0,2,11,8,0],[11,3,2],[8,1,3,8,9,1],[9,1,0],[8,0,3],[]];return i},$3Dmol.MarchingCube=$3Dmol.MarchingCubeInitializer,"undefined"==typeof console&&(console={log:function{}}),$3Dmol.ProteinSurface=function{var e,t,n,o=1,s=2,r=4,a=0,c=0,l=0,d=1.4,h=2,u=h,p=0,m=0,g=0,f=0,v=null,b=null,y=null,E=0,_=0,w=0,C=0,S=0,R=0,T={H:1.2,Li:1.82,Na:2.27,K:2.75,C:1.7,N:1.55,O:1.52,F:1.47,P:1.8,S:1.8,CL:1.75,BR:1.85,SE:1.9,ZN:1.39,CU:1.4,NI:1.63,X:2},H=function(e){return e.elem&&"undefined"!=typeof T[e.elem]?e.elem:"X"},A={},x={},O=[new Int32Array([1,0,0]),new Int32Array([-1,0,0]),new Int32Array([0,1,0]),new Int32Array([0,-1,0]),new Int32Array([0,0,1]),new Int32Array([0,0,-1]),new Int32Array([1,1,0]),new Int32Array([1,-1,0]),new Int32Array([-1,1,0]),new Int32Array([-1,-1,0]),new Int32Array([1,0,1]),new Int32Array([1,0,-1]),new Int32Array([-1,0,1]),new Int32Array([-1,0,-1]),new Int32Array([0,1,1]),new Int32Array([0,1,-1]),new Int32Array([0,-1,1]),new Int32Array([0,-1,-1]),new Int32Array([1,1,1]),new Int32Array([1,1,-1]),new Int32Array([1,-1,1]),new Int32Array([-1,1,1]),new Int32Array([1,-1,-1]),new Int32Array([-1,-1,1]),new Int32Array([-1,1,-1]),new Int32Array([-1,-1,-1])];this.getFacesAndVertices=function(i){var n,o,s={};for(n=0,o=i.length;o>n;n++)s[i[n]]=!0;var r=t;for(n=0,o=r.length;o>n;n++)r[n].x=r[n].x/u-a,r[n].y=r[n].y/u-c,r[n].z=r[n].z/u-l;var d=[];for(n=0,o=e.length;o>n;n+=3){var h=e[n],p=e[n+1],m=e[n+2],g=r[h].atomid,f=r[p].atomid,E=r[m].atomid,_=g;if(_>f&&(_=f),_>E&&(_=E),s[_]){r[e[n]],r[e[n+1]],r[e[n+2]];h!==p&&p!==m&&h!==m&&d.push({a:h,b:p,c:m})}}return v=null,b=null,y=null,{vertices:r,faces:d}},this.initparm=function(e,i,t){var o=1/u*5.5;n=e,E=e[0][0],C=e[1][0],_=e[0][1],S=e[1][1],w=e[0][2],R=e[1][2],i?(E-=d+o,_-=d+o,w-=d+o,C+=d+o,S+=d+o,R+=d+o):(E-=o,_-=o,w-=o,C+=o,S+=o,R+=o),E=Math.floor(E*u)/u,_=Math.floor(_*u)/u,w=Math.floor(w*u)/u,C=Math.ceil(C*u)/u,S=Math.ceil(S*u)/u,R=Math.ceil(R*u)/u,a=-E,c=-_,l=-w;var s=128;u=C-E,S-_>u&&(u=S-_),R-w>u&&(u=R-w),u=(s-1)/u,s=Math.floor(s*h/u),u=h;var r=180;if(s>r){var k=r/s;s=Math.floor(r),u*=k}g=Math.ceil(u*(C-E))+1,m=Math.ceil(u*(S-_))+1,p=Math.ceil(u*(R-w))+1,this.boundingatom(i),f=d*u,v=new Uint8Array(g*m*p),b=new Float64Array(g*m*p),y=new Int32Array(g*m*p)},this.boundingatom=function(e){var i,t,n,o=[];flagradius=e;for(var s in T)if(T.hasOwnProperty(s)){var r=T[s];for(e?o[s]=(r+d)*u+.5:o[s]=r*u+.5,n=o[s]*o[s],x[s]=Math.floor(o[s])+1,A[s]=new Int32Array(x[s]*x[s]),indx=0,j=0;jn?A[s][indx]=-1:(t=Math.sqrt(n-i),A[s][indx]=Math.floor(t)),indx++}},this.fillvoxels=function(e,i){var t,n;for(t=0,n=v.length;n>t;t++)v[t]=0,b[t]=-1,y[t]=-1;for(t in i){var r=e[i[t]];void 0!==r&&this.fillAtom(r,e)}for(t=0,n=v.length;n>t;t++)v[t]&o&&(v[t]|=s)},this.fillAtom=function(e,i){var t,n,s,r,d,h,f,b,E,_,w,C,S,k,R,T,O,$,M;t=Math.floor(.5+u*(e.coord.x+a)),n=Math.floor(.5+u*(e.coord.y+c)),s=Math.floor(.5+u*(e.coord.z+l));var L=H(e),I=0,D=m*p;for(_=0,M=x[L];M>_;_++)for(w=0;M>w;w++){if(-1!=A[L][I])for(T=-1;2>T;T++)for(O=-1;2>O;O++)for($=-1;2>$;$++)if(0!==T&&0!==O&&0!==$)for(f=T*_,E=$*w,C=0;C<=A[L][I];C++)if(b=C*O,S=t+f,k=n+b,R=s+E,!(0>S||0>k||0>R||S>=g||k>=m||R>=p)){var z=S*D+k*p+R;if(v[z]&o){var N=i[y[z]];N.serial!=e.serial&&(r=t+f-Math.floor(.5+u*(N.x+a)),d=n+b-Math.floor(.5+u*(N.y+c)),h=s+E-Math.floor(.5+u*(N.z+l)),r*r+d*d+h*h>f*f+b*b+E*E&&(y[z]=e.serial))}else v[z]|=o,y[z]=e.serial}I++}},this.fillvoxelswaals=function(e,i){var t,n;for(t=0,n=v.length;n>t;t++)v[t]&=~s;for(t in i){var o=e[i[t]];void 0!==o&&this.fillAtomWaals(o,e)}},this.fillAtomWaals=function(e,i){var t,n,o,r,d,h,f,b,E,_,w,C,S,k,R,T,O,$,M,L=0;t=Math.floor(.5+u*(e.coord.x+a)),n=Math.floor(.5+u*(e.coord.y+c)),o=Math.floor(.5+u*(e.coord.z+l));var I=H(e),D=m*p;for(S=0,M=x[I];M>S;S++)for(k=0;M>k;k++){if(-1!=A[I][L])for(T=-1;2>T;T++)for(O=-1;2>O;O++)for($=-1;2>$;$++)if(0!==T&&0!==O&&0!==$)for(f=T*S,E=$*k,R=0;R<=A[I][L];R++)if(b=R*O,_=t+f,w=n+b,C=o+E,!(0>_||0>w||0>C||_>=g||w>=m||C>=p)){var z=_*D+w*p+C;if(v[z]&s){var N=i[y[z]];N.serial!=e.serial&&(r=t+f-Math.floor(.5+u*(N.x+a)),d=n+b-Math.floor(.5+u*(N.y+c)),h=o+E-Math.floor(.5+u*(N.z+l)),r*r+d*d+h*h>f*f+b*b+E*E&&(y[z]=e.serial))}else v[z]|=s,y[z]=e.serial}L++}},this.buildboundary=function{var e=m*p;for(i=0;in;){var s=i+O[n][0],a=j+O[n][2],c=k+O[n][1];if(s>-1&&g>s&&c>-1&&m>c&&a>-1&&p>a&&!(v[s*e+c*p+a]&o)){v[t]|=r;break}n++}}};var $=function(e,i,t){var n=new Int32Array(e*i*t*3);this.set=function(e,o,s,r){var a=3*((e*i+o)*t+s);n[a]=r.ix,n[a+1]=r.iy,n[a+2]=r.iz},this.get=function(e,o,s){var r=3*((e*i+o)*t+s);return{ix:n[r],iy:n[r+1],iz:n[r+2]}}};this.fastdistancemap=function{var e,i,t,n,a,c=new $(g,m,p),l=m*p,d=f*f,h=[],y=[];for(e=0;g>e;e++)for(i=0;m>i;i++)for(t=0;p>t;t++)if(a=e*l+i*p+t,v[a]&=~s,v[a]&o&&v[a]&r){var E={ix:e,iy:i,iz:t};c.set(e,i,t,E),h.push(E),b[a]=0,v[a]|=s,v[a]&=~r}do for(y=this.fastoneshell(h,c),h=[],e=0,n=y.length;n>e;e++)a=l*y[e].ix+p*y[e].iy+y[e].iz,v[a]&=~r,b[a]<=1.0404*d&&h.push({ix:y[e].ix,iy:y[e].iy,iz:y[e].iz});while(0!==h.length);h=[],y=[],c=null;var _=u-.5;0>_&&(_=0);var w=d-.5/(.1+_);for(e=0;g>e;e++)for(i=0;m>i;i++)for(t=0;p>t;t++)a=e*l+i*p+t,v[a]&=~r,v[a]&o&&(!(v[a]&s)||v[a]&s&&b[a]>=w)&&(v[a]|=r)},this.fastoneshell=function(e,i){var t,n,a,c,l,d,h,u,f,y,E,_,w=[];if(0===e.length)return w;tnv={ix:-1,iy:-1,iz:-1};var C=m*p;for(h=0,f=e.length;f>h;h++)for(t=e[h].ix,n=e[h].iy,a=e[h].iz,E=i.get(t,n,a),u=0;6>u;u++)tnv.ix=t+O[u][0],tnv.iy=n+O[u][1],tnv.iz=a+O[u][2],tnv.ix<g&&tnv.ix>-1&&tnv.iy<m&&tnv.iy>-1&&tnv.iz<p&&tnv.iz>-1&&(_=tnv.ix*C+p*tnv.iy+tnv.iz,v[_]&o&&!(v[_]&s)?(i.set(tnv.ix,tnv.iy,a+O[u][2],E),c=tnv.ix-E.ix,l=tnv.iy-E.iy,d=tnv.iz-E.iz,y=c*c+l*l+d*d,b[_]=y,v[_]|=s,v[_]|=r,w.push({ix:tnv.ix,iy:tnv.iy,iz:tnv.iz})):v[_]&o&&v[_]&s&&(c=tnv.ix-E.ix,l=tnv.iy-E.iy,d=tnv.iz-E.iz,y=c*c+l*l+d*d,y<b[_]&&(i.set(tnv.ix,tnv.iy,tnv.iz,E),b[_]=y,v[_]&r||(v[_]|=r,w.push({ix:tnv.ix,iy:tnv.iy,iz:tnv.iz})))));for(h=0,f=e.length;f>h;h++)for(t=e[h].ix,n=e[h].iy,a=e[h].iz,E=i.get(t,n,a),u=6;18>u;u++)tnv.ix=t+O[u][0],tnv.iy=n+O[u][1],tnv.iz=a+O[u][2],tnv.ix<g&&tnv.ix>-1&&tnv.iy<m&&tnv.iy>-1&&tnv.iz<p&&tnv.iz>-1&&(_=tnv.ix*C+p*tnv.iy+tnv.iz,v[_]&o&&!(v[_]&s)?(i.set(tnv.ix,tnv.iy,a+O[u][2],E),c=tnv.ix-E.ix,l=tnv.iy-E.iy,d=tnv.iz-E.iz,y=c*c+l*l+d*d,b[_]=y,v[_]|=s,v[_]|=r,w.push({ix:tnv.ix,iy:tnv.iy,iz:tnv.iz})):v[_]&o&&v[_]&s&&(c=tnv.ix-E.ix,l=tnv.iy-E.iy,d=tnv.iz-E.iz,y=c*c+l*l+d*d,y<b[_]&&(i.set(tnv.ix,tnv.iy,tnv.iz,E),b[_]=y,v[_]&r||(v[_]|=r,w.push({ix:tnv.ix,iy:tnv.iy,iz:tnv.iz})))));for(h=0,f=e.length;f>h;h++)for(t=e[h].ix,n=e[h].iy,a=e[h].iz,E=i.get(t,n,a),u=18;26>u;u++)tnv.ix=t+O[u][0],tnv.iy=n+O[u][1],tnv.iz=a+O[u][2],tnv.ix<g&&tnv.ix>-1&&tnv.iy<m&&tnv.iy>-1&&tnv.iz<p&&tnv.iz>-1&&(_=tnv.ix*C+p*tnv.iy+tnv.iz,v[_]&o&&!(v[_]&s)?(i.set(tnv.ix,tnv.iy,a+O[u][2],E),c=tnv.ix-E.ix,l=tnv.iy-E.iy,d=tnv.iz-E.iz,y=c*c+l*l+d*d,b[_]=y,v[_]|=s,v[_]|=r,w.push({ix:tnv.ix,iy:tnv.iy,iz:tnv.iz})):v[_]&o&&v[_]&s&&(c=tnv.ix-E.ix,l=tnv.iy-E.iy,d=tnv.iz-E.iz,y=c*c+l*l+d*d,y<b[_]&&(i.set(tnv.ix,tnv.iy,tnv.iz,E),b[_]=y,v[_]&r||(v[_]|=r,w.push({ix:tnv.ix,iy:tnv.iy,iz:tnv.iz})))));return w},this.marchingcubeinit=function(e){for(var i=0,t=v.length;t>i;i++)1==e?v[i]&=~r:4==e?(v[i]&=~s,v[i]&r&&(v[i]|=s),v[i]&=~r):2==e?v[i]&r&&v[i]&s?v[i]&=~r:v[i]&r&&!(v[i]&s)&&(v[i]|=s):3==e&&(v[i]&=~r)};this.marchingcube=function(i){this.marchingcubeinit(i),t=[],e=[],$3Dmol.MarchingCube.march(v,t,e,{smooth:1,nX:g,nY:m,nZ:p});for(var n=m*p,o=0,s=t.length;s>o;o++)t[o].atomid=y[t[o].x*n+p*t[o].y+t[o].z];$3Dmol.MarchingCube.laplacianSmooth(1,t,e)}},$3Dmol.SetupSurface=function(e){var i=void 0,t=new $3Dmol.ProteinSurface;return t.initparm(e.extent,1===e.type?!1:!0,i),t.fillvoxels(e.allatoms,e.extendedAtoms),t.buildboundary,2===e.type&&(t.fastdistancemap,t.boundingatom(!1),t.fillvoxelswaals(e.allatoms,e.extendedAtoms)),t.marchingcube(e.type),t.vpBits=null,t.vpDistance=null,t.vpAtomID=null,t.faces=null,t.verts=null,t.getFacesAndVertices(e.atomsToShow)},"undefined"==typeof jQuery)throw new Error("iCn3D requires jQuery");var iCn3D=function(e){this.REVISION="1",this.id=e,this.container=$("#"+e),this.overdraw=0,this.bHighlight=1,Detector.webgl?(this.renderer=new THREE.WebGLRenderer({canvas:this.container.get(0),antialias:!0,preserveDrawingBuffer:!0}),this.overdraw=0):(alert("Currently your web browser has a problem on WebGL, and CanvasRenderer instead of WebGLRenderer is used. If you are using Chrome, open a new tab for the same URL and WebGL may work again."),this.renderer=new THREE.CanvasRenderer({canvas:this.container.get(0)}),this.overdraw=.5,this.bHighlight=2),this.matShader=this.setOutlineColor("yellow"),this.fractionOfColor=new THREE.Color(.1,.1,.1),this.WIDTH=this.container.width,this.HEIGHT=this.container.height,this.setWidthHeight(this.WIDTH,this.HEIGHT),this.axis=!1,this.picking=1,this.highlightlevel=1,this.pickpair=!1,this.pickedatomNum=0,this.pickedatom=void 0,this.pickedatom2=void 0,this.bCtrlKey=!1,this.bShiftKey=!1,this.bStopRotate=!1,this.bCalphaOnly=!1,this.bSSOnly=!1,this.bAllAtoms=!0,this.bConsiderNeighbors=!1,this.effects={none:this.renderer},this.maxD=500,this.oriMaxD=this.maxD,this.camera_z=2*-this.maxD,this.commands=[],this.optionsHistory=[],this.logs=[],this.bRender=!0,this.highlightColor=new THREE.Color(16776960),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.sphereRadius=1.5,this.cylinderRadius=.4,this.linewidth=1,this.curveWidth=3,this.helixSheetWidth=1.3,this.coilWidth=.3,this.thickness=.4,this.axisDIV=5,this.strandDIV=6,this.tubeDIV=8,this.LABELSIZE=40,this.nucleicAcidStrandDIV=6,this.nucleicAcidWidth=.8,this.options={camera:"perspective",background:"black",color:"spectrum",sidechains:"nothing",proteins:"cylinder and plate",surface:"nothing",wireframe:"no",opacity:"0.8",ligands:"stick",water:"nothing",ions:"sphere",hbonds:"no",labels:"no",lines:"no",rotationcenter:"molecule center",axis:"no",fog:"no",slab:"no",picking:"residue",nucleotides:"nucleotide cartoon"},this._zoomFactor=1,this.mouseChange=new THREE.Vector2(0,0),this.quaternion=new THREE.Quaternion(0,0,0,1);var i=this;this.container.bind("contextmenu",function(e){e.preventDefault}),i.switchHighlightLevel,i.typetext=!1,$(document).bind("keyup",function(e){16===e.keyCode&&(i.bShiftKey=!1),(17===e.keyCode||224===e.keyCode||91===e.keyCode)&&(i.bCtrlKey=!1)}),$(document).bind("keydown",function(e){if((e.shiftKey||16===e.keyCode)&&(i.bShiftKey=!0),(e.ctrlKey||17===e.keyCode||224===e.keyCode||91===e.keyCode)&&(i.bCtrlKey=!0),i.controls&&(i.bStopRotate=!0,$("input, textarea").focus(function{i.typetext=!0}),$("input, textarea").blur(function{i.typetext=!1}),!i.typetext)){if(90===e.keyCode){var t={};i.camera===i.perspectiveCamera?t._zoomFactor=.9:i.camera===i.orthographicCamera&&(i._zoomFactor<.1?i._zoomFactor=.1:i._zoomFactor>1&&(i._zoomFactor=1),t._zoomFactor=.9*i._zoomFactor,t._zoomFactor<.1&&(t._zoomFactor=.1)),t.update=!0,i.controls.update(t)}else if(88===e.keyCode){var t={};i.camera===i.perspectiveCamera?t._zoomFactor=1.1:i.camera===i.orthographicCamera&&(i._zoomFactor>20?i._zoomFactor=20:i._zoomFactor<1&&(i._zoomFactor=1),t._zoomFactor=1.03*i._zoomFactor,t._zoomFactor>20&&(t._zoomFactor=20)),t.update=!0,i.controls.update(t)}else if(76===e.keyCode){var n=new THREE.Vector3(0,1,0),o=-5/180*Math.PI;n.applyQuaternion(i.camera.quaternion).normalize;var s=new THREE.Quaternion;s.setFromAxisAngle(n,-o);var t={}; t.quaternion=s,t.update=!0,i.controls.update(t)}else if(74===e.keyCode){var n=new THREE.Vector3(0,1,0),o=5/180*Math.PI;n.applyQuaternion(i.camera.quaternion).normalize;var s=new THREE.Quaternion;s.setFromAxisAngle(n,-o);var t={};t.quaternion=s,t.update=!0,i.controls.update(t)}else if(73===e.keyCode){var n=new THREE.Vector3(1,0,0),o=-5/180*Math.PI;n.applyQuaternion(i.camera.quaternion).normalize;var s=new THREE.Quaternion;s.setFromAxisAngle(n,-o);var t={};t.quaternion=s,t.update=!0,i.controls.update(t)}else if(77===e.keyCode){var n=new THREE.Vector3(1,0,0),o=5/180*Math.PI;n.applyQuaternion(i.camera.quaternion).normalize;var s=new THREE.Quaternion;s.setFromAxisAngle(n,-o);var t={};t.quaternion=s,t.update=!0,i.controls.update(t)}i.render}}),this.container.bind("mouseup touchend",function(e){i.isDragging=!1}),this.container.bind("mousedown touchstart",function(e){if(e.preventDefault,i.scene){i.bStopRotate=!0;var t=e.pageX,n=e.pageY;if(e.originalEvent.targetTouches&&e.originalEvent.targetTouches[0]&&(t=e.originalEvent.targetTouches[0].pageX,n=e.originalEvent.targetTouches[0].pageY),i.isDragging=!0,i.picking&&(e.altKey||e.ctrlKey||e.shiftKey||16===e.keyCode||17===e.keyCode||224===e.keyCode||91===e.keyCode)){i.highlightlevel=i.picking,i.mouse.x=(t-i.container.offset.left)/i.container.width*2-1,i.mouse.y=2*-((n-i.container.offset.top)/i.container.height)+1;var o=new THREE.Vector3;o.x=i.mouse.x,o.y=i.mouse.y,this.camera_z>0?o.z=-1:o.z=1,i.camera===i.perspectiveCamera?(this.camera_z>0?o.z=-1:o.z=1,o.unproject(i.camera),i.raycaster.set(i.camera.position,o.sub(i.camera.position).normalize)):i.camera===i.orthographicCamera&&(this.camera_z>0?o.z=1:o.z=-1,o.unproject(i.camera),i.raycaster.set(o,new THREE.Vector3(0,0,-1).transformDirection(i.camera.matrixWorld)));var s=i.raycaster.intersectObjects(i.objects);if(s.length>0){s[0].point.sub(i.mdl.position);for(var r=1,a=i.getAtomsFromPosition(s[0].point,r);!a&&10>r;)++r,a=i.getAtomsFromPosition(s[0].point,r);a?(i.pickpair?(i.pickedatomNum%2===0?i.pickedatom=a:i.pickedatom2=a,++i.pickedatomNum):i.pickedatom=a,i.showPicking(a)):console.log("No atoms were found in 10 andstrom range")}}i.controls.handleResize,i.controls.update,i.render}}),this.container.bind("mousemove touchmove",function(e){e.preventDefault,i.scene&&i.isDragging&&(i.controls.handleResize,i.controls.update,i.render)}),this.container.bind("mousewheel",function(e){e.preventDefault,i.scene&&(i.bStopRotate=!0,i.controls.handleResize,i.controls.update,i.render)}),this.container.bind("DOMMouseScroll",function(e){e.preventDefault,i.scene&&(i.bStopRotate=!0,i.controls.handleResize,i.controls.update,i.render)})};if(iCn3D.prototype={constructor:iCn3D,setOutlineColor:function(e){var i={outline:{vertex_shader:["uniform float offset;","void main {","vec4 pos = modelViewMatrix * vec4( position + normal * offset, 1.0 );","gl_Position = projectionMatrix * pos;","}"].join("\n"),fragment_shader:["void main{","gl_FragColor = vec4( 1.0, 1.0, 0.0, 1.0 );","}"].join("\n")}};"yellow"===e?i.outline.fragment_shader=["void main{","gl_FragColor = vec4( 1.0, 1.0, 0.0, 1.0 );","}"].join("\n"):"green"===e?i.outline.fragment_shader=["void main{","gl_FragColor = vec4( 0.0, 1.0, 0.0, 1.0 );","}"].join("\n"):"red"===e&&(i.outline.fragment_shader=["void main{","gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );","}"].join("\n"));var t={offset:{type:"f",value:.5}},n=i.outline,o=new THREE.ShaderMaterial({uniforms:t,vertexShader:n.vertex_shader,fragmentShader:n.fragment_shader,depthTest:!1,depthWrite:!1,needsUpdate:!0});return o},setWidthHeight:function(e,i){this.renderer.setSize(e,i),this.container.widthInv=1/e,this.container.heightInv=1/i,this.container.whratio=e/i},nucleotidesArray:[" G","  A","  T","  C","  U"," DG"," DA"," DT"," DC"," DU"],ionsArray:[" NA"," MG"," AL"," CA"," TI"," MN"," FE"," NI"," CU"," ZN"," AG"," BA","  F"," CL"," BR","  I"],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},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},atomColors:{H:new THREE.Color(16777215),He:new THREE.Color(16761035),HE:new THREE.Color(16761035),Li:new THREE.Color(11674146),LI:new THREE.Color(11674146),B:new THREE.Color(65280),C:new THREE.Color(13158600),N:new THREE.Color(9408511),O:new THREE.Color(15728640),F:new THREE.Color(14329120),Na:new THREE.Color(255),NA:new THREE.Color(255),Mg:new THREE.Color(2263842),MG:new THREE.Color(2263842),Al:new THREE.Color(8421520),AL:new THREE.Color(8421520),Si:new THREE.Color(14329120),SI:new THREE.Color(14329120),P:new THREE.Color(16753920),S:new THREE.Color(16762930),Cl:new THREE.Color(65280),CL:new THREE.Color(65280),Ca:new THREE.Color(8421520),CA:new THREE.Color(8421520),Ti:new THREE.Color(8421520),TI:new THREE.Color(8421520),Cr:new THREE.Color(8421520),CR:new THREE.Color(8421520),Mn:new THREE.Color(8421520),MN:new THREE.Color(8421520),Fe:new THREE.Color(16753920),FE:new THREE.Color(16753920),Ni:new THREE.Color(10824234),NI:new THREE.Color(10824234),Cu:new THREE.Color(10824234),CU:new THREE.Color(10824234),Zn:new THREE.Color(10824234),ZN:new THREE.Color(10824234),Br:new THREE.Color(10824234),BR:new THREE.Color(10824234),Ag:new THREE.Color(8421520),AG:new THREE.Color(8421520),I:new THREE.Color(10494192),Ba:new THREE.Color(16753920),BA:new THREE.Color(16753920),Au:new THREE.Color(14329120),AU:new THREE.Color(14329120)},defaultAtomColor:new THREE.Color(13421772),stdChainColors:[new THREE.Color(3329330),new THREE.Color(2003199),new THREE.Color(16416882),new THREE.Color(16753920),new THREE.Color(52945),new THREE.Color(16738740),new THREE.Color(65280),new THREE.Color(255),new THREE.Color(16711680),new THREE.Color(16776960),new THREE.Color(65535),new THREE.Color(16711935),new THREE.Color(3978097),new THREE.Color(4620980),new THREE.Color(13458524),new THREE.Color(16770229),new THREE.Color(11529966),new THREE.Color(15631086),new THREE.Color(25600),new THREE.Color(139),new THREE.Color(9109504),new THREE.Color(13468991),new THREE.Color(35723),new THREE.Color(9699539)],backgroundColors:{black:new THREE.Color(0),grey:new THREE.Color(13421772),white:new THREE.Color(16777215)},residueColors:{ALA:new THREE.Color(13158600),ARG:new THREE.Color(1334015),ASN:new THREE.Color(56540),ASP:new THREE.Color(15075850),CYS:new THREE.Color(15132160),GLN:new THREE.Color(56540),GLU:new THREE.Color(15075850),GLY:new THREE.Color(15461355),HIS:new THREE.Color(8553170),ILE:new THREE.Color(1016335),LEU:new THREE.Color(1016335),LYS:new THREE.Color(1334015),MET:new THREE.Color(15132160),PHE:new THREE.Color(3289770),PRO:new THREE.Color(14456450),SER:new THREE.Color(16422400),THR:new THREE.Color(16422400),TRP:new THREE.Color(11819700),TYR:new THREE.Color(3289770),VAL:new THREE.Color(1016335),ASX:new THREE.Color(16738740),GLX:new THREE.Color(16738740)},defaultResidueColor:new THREE.Color(12492910),chargeColors:{"  G":new THREE.Color(16711680),"  A":new THREE.Color(16711680),"  T":new THREE.Color(16711680),"  C":new THREE.Color(16711680),"  U":new THREE.Color(16711680)," DG":new THREE.Color(16711680)," DA":new THREE.Color(16711680)," DT":new THREE.Color(16711680)," DC":new THREE.Color(16711680)," DU":new THREE.Color(16711680),G:new THREE.Color(16711680),A:new THREE.Color(16711680),T:new THREE.Color(16711680),C:new THREE.Color(16711680),U:new THREE.Color(16711680),DG:new THREE.Color(16711680),DA:new THREE.Color(16711680),DT:new THREE.Color(16711680),DC:new THREE.Color(16711680),DU:new THREE.Color(16711680),ARG:new THREE.Color(255),LYS:new THREE.Color(255),ASP:new THREE.Color(16711680),GLU:new THREE.Color(16711680),GLY:new THREE.Color(8947848),PRO:new THREE.Color(8947848),ALA:new THREE.Color(8947848),VAL:new THREE.Color(8947848),LEU:new THREE.Color(8947848),ILE:new THREE.Color(8947848),PHE:new THREE.Color(8947848),HIS:new THREE.Color(8947848),SER:new THREE.Color(8947848),THR:new THREE.Color(8947848),ASN:new THREE.Color(8947848),GLN:new THREE.Color(8947848),TYR:new THREE.Color(8947848),MET:new THREE.Color(8947848),CYS:new THREE.Color(8947848),TRP:new THREE.Color(8947848)},hydrophobicColors:{"  G":new THREE.Color(8947848),"  A":new THREE.Color(8947848),"  T":new THREE.Color(8947848),"  C":new THREE.Color(8947848),"  U":new THREE.Color(8947848)," DG":new THREE.Color(8947848)," DA":new THREE.Color(8947848)," DT":new THREE.Color(8947848)," DC":new THREE.Color(8947848)," DU":new THREE.Color(8947848),G:new THREE.Color(8947848),A:new THREE.Color(8947848),T:new THREE.Color(8947848),C:new THREE.Color(8947848),U:new THREE.Color(8947848),DG:new THREE.Color(8947848),DA:new THREE.Color(8947848),DT:new THREE.Color(8947848),DC:new THREE.Color(8947848),DU:new THREE.Color(8947848),ARG:new THREE.Color(8947848),LYS:new THREE.Color(8947848),ASP:new THREE.Color(8947848),GLU:new THREE.Color(8947848),GLY:new THREE.Color(65280),PRO:new THREE.Color(65280),ALA:new THREE.Color(65280),VAL:new THREE.Color(65280),LEU:new THREE.Color(65280),ILE:new THREE.Color(65280),PHE:new THREE.Color(65280),HIS:new THREE.Color(8947848),SER:new THREE.Color(8947848),THR:new THREE.Color(8947848),ASN:new THREE.Color(8947848),GLN:new THREE.Color(8947848),TYR:new THREE.Color(8947848),MET:new THREE.Color(8947848),CYS:new THREE.Color(8947848),TRP:new THREE.Color(8947848)},ssColors:{helix:new THREE.Color(16711808),sheet:new THREE.Color(16762880),coil:new THREE.Color(6324479)},defaultBondColor:new THREE.Color(2200790),surfaces:{1:void 0,2:void 0,3:void 0,4:void 0},hasCovalentBond:function(e,i){var t=this.covalentRadii[e.elem]+this.covalentRadii[i.elem];return e.coord.distanceToSquared(i.coord)<1.3*t*t},init:function{this.structures={},this.chains={},this.residues={},this.secondaries={},this.alignChains={},this.chainsSeq={},this.chainsColor={},this.chainsAnno={},this.chainsAnnoTitle={},this.alignChainsSeq={},this.alignChainsAnno={},this.alignChainsAnnoTitle={},this.displayAtoms={},this.highlightAtoms={},this.pickedAtomList={},this.prevHighlightObjects=[],this.prevSurfaces=[],this.definedNames2Residues={},this.definedNames2Atoms={},this.definedNames2Descr={},this.definedNames2Command={},this.residueId2Name={},this.moleculeTitle="",this.atoms={},this.displayAtoms={},this.highlightAtoms={},this.proteins={},this.sidechains={},this.nucleotides={},this.nucleotidesP={},this.ligands={},this.ions={},this.water={},this.calphas={},this.hbondpoints=[],this.doublebonds={},this.triplebonds={},this.aromaticbonds={},this.atomPrevColors={},this.style2atoms={},this.labels={},this.lines={},this.inputid={idtype:void 0,id:void 0},this.biomtMatrices=[],this.bAssembly=!1,this.rotateCount=0,this.rotateCountMax=30},reinitAfterLoad:function{this.displayAtoms=this.cloneHash(this.atoms),this.highlightAtoms=this.cloneHash(this.atoms),this.prevHighlightObjects=[],this.prevSurfaces=[],this.hbondpoints=[],this.labels={},this.lines={},this.biomtMatrices=[],this.bAssembly=!1},loadPDB:function(e){var i=[],t=[],n=e.split("\n"),o={},s={};this.init;var r,a,c=[],l=[],d=[],h=[],u=[],p=[],m=0,g=1,f="",v="",b="",y={},E={},_="P_ID";for(var w in n){var C=n[w],S=C.substr(0,6);if("HEADER"===S)_=C.substr(62,4),this.moleculeTitle="";else if("TITLE "===S){var k=C.substr(10);this.moleculeTitle+=k.trim+" "}else if("HELIX "===S){for(var R,T=C.substr(19,1),H=parseInt(C.substr(21,4)),A=parseInt(C.substr(33,4)),x=H;A>=x;++x)R=T+"_"+x,h.push(R),x===H&&u.push(R),x===A&&p.push(R);i.push({chain:T,initialResidue:H,initialInscode:C.substr(25,1),terminalResidue:A,terminalInscode:C.substr(37,1)})}else if("SHEET "===S){for(var T=C.substr(21,1),H=parseInt(C.substr(22,4)),A=parseInt(C.substr(33,4)),x=H;A>=x;++x){var R=T+"_"+x;c.push(R),x===H&&l.push(R),x===A&&d.push(R)}t.push({chain:T,initialResidue:H,initialInscode:C.substr(26,1),terminalResidue:A,terminalInscode:C.substr(37,1)})}else if("HBOND "===S){bCalculateHbond=!1;var O=(C.substr(6,1),C.substr(8,4).replace(/ /g,""),C.substr(14,4).replace(/ /g,""),C.substr(18,1),C.substr(20,4).replace(/ /g,""),C.substr(25,4).replace(/ /g,""),parseFloat(C.substr(30,8))),M=parseFloat(C.substr(38,8)),L=parseFloat(C.substr(46,8)),I=parseFloat(C.substr(54,8)),D=parseFloat(C.substr(62,8)),z=parseFloat(C.substr(70,8));C.substr(78,8).replace(/ /g,"");this.hbondpoints.push(new THREE.Vector3(O,M,L)),this.hbondpoints.push(new THREE.Vector3(I,D,z))}else if("REMARK"===S){var N=parseInt(C.substr(7,3));if(350==N&&"BIOMT"==C.substr(13,5)){var q=parseInt(C[18])-1,j=parseInt(C.substr(21,2));void 0==this.biomtMatrices[j]&&(this.biomtMatrices[j]=(new THREE.Matrix4).identity),this.biomtMatrices[j].elements[q]=parseFloat(C.substr(24,9)),this.biomtMatrices[j].elements[q+4]=parseFloat(C.substr(34,9)),this.biomtMatrices[j].elements[q+8]=parseFloat(C.substr(44,9)),this.biomtMatrices[j].elements[q+12]=parseFloat(C.substr(54,10))}else if(465==N&&" "==C.substr(18,1)&&" "==C.substr(20,1)&&"S"!=C.substr(21,1)){var P=C.substr(15,3),F=C.substr(19,1),B=parseInt(C.substr(21,5)),V=parseInt(C.substr(13,1));" "==C.substr(13,1)&&(V=1);var r=V+"_"+F;void 0===E[r]&&(E[r]=[]);var G={};G.resi=B,G.name=this.residueName2Abbr(P).toLowerCase,E[r].push(G)}}else if("ENDMDL"===S)++g;else if("JRNL  "===S)"PMID"===C.substr(12,4)&&(this.pmid=C.substr(19).trim);else if("ATOM  "===S||"HETATM"===S){var U=C.substr(16,1);if("B"===U)continue;++m;var W=parseInt(C.substr(6,5));y[W]=m;var Y=C.substr(76,2).replace(/ /g,"");""===Y&&(Y=C.substr(12,2).replace(/ /g,""));var F=C.substr(21,1);""===F&&(F=1);var B=parseInt(C.substr(22,4)),X=C.substr(12,4).replace(/ /g,""),R=F+"_"+B,Z=parseFloat(C.substr(30,8)),K=parseFloat(C.substr(38,8)),Q=parseFloat(C.substr(46,8)),P=C.substr(17,3),J=new THREE.Vector3(Z,K,Q),V=1===g?_:_+g.toString,ee={het:"H"===S[0],serial:m,name:X,alt:U,resn:P,structure:V,chain:F,resi:B,coord:J,b:parseFloat(C.substr(60,8)),elem:Y,bonds:[],ss:"coil",ssbegin:!1,ssend:!1};this.atoms[m]=ee,this.displayAtoms[m]=1,this.highlightAtoms[m]=1,-1!==$.inArray(R,h)?(this.atoms[m].ss="helix",-1!==$.inArray(R,u)&&(this.atoms[m].ssbegin=!0),-1!==$.inArray(R,p)&&(this.atoms[m].ssend=!0)):-1!==$.inArray(R,c)&&(this.atoms[m].ss="sheet",-1!==$.inArray(R,l)&&(this.atoms[m].ssbegin=!0),-1!==$.inArray(R,d)&&(this.atoms[m].ssend=!0)),r=V+"_"+F,a=r+"_"+B;var ie="-";if("helix"===this.atoms[m].ss?ie="H":"sheet"===this.atoms[m].ss?ie="E":"coil"===this.atoms[m].ss?ie="c":!this.atoms[m].het&&this.residueColors.hasOwnProperty(this.atoms[m].resn.toUpperCase)&&(ie="c"),this.secondaries[a]=ie,a!==v){var te=this.residueName2Abbr(P);if(this.residueId2Name[a]=te,1!==m&&(this.residues[v]=s),s={},r!==f){1!==m&&(this.chains[f]=this.unionHash2Atoms(this.chains[f],o)),o={},void 0===this.structures[V.toString]&&(this.structures[V.toString]=[]),this.structures[V.toString].push(r),void 0===this.chainsSeq[r]&&(this.chainsSeq[r]=[]),void 0===this.chainsAnno[r]&&(this.chainsAnno[r]=[]),void 0===this.chainsAnno[r][0]&&(this.chainsAnno[r][0]=[]),void 0===this.chainsAnno[r][1]&&(this.chainsAnno[r][1]=[]),void 0===this.chainsAnnoTitle[r]&&(this.chainsAnnoTitle[r]=[]),void 0===this.chainsAnnoTitle[r][0]&&(this.chainsAnnoTitle[r][0]=[]),void 0===this.chainsAnnoTitle[r][1]&&(this.chainsAnnoTitle[r][1]=[]);var G={};G.resi=B,G.name=te,this.chainsSeq[r].push(G);var ne="";B%10===0&&(ne=B.toString),this.chainsAnno[r][0].push(ne),this.chainsAnno[r][1].push(ie),this.chainsAnnoTitle[r][0].push(""),this.chainsAnnoTitle[r][1].push("SS")}else{var G={};G.resi=B,G.name=te,this.chainsSeq[r].push(G);var ne="";B%10===0&&(ne=B.toString),this.chainsAnno[r][0].push(ne),this.chainsAnno[r][1].push(ie)}}o[m]=1,s[m]=1,b=S,f=r,v=a}else if("CONECT"===S)for(var oe=parseInt(C.substr(6,5)),x=0;4>x;++x){var se=parseInt(C.substr([11,16,21,26][x],5));isNaN(se)||void 0!==this.atoms[y[oe]]&&this.atoms[y[oe]].bonds.push(y[se])}else"TER   "===S&&++m}for(var r in this.chainsSeq)if(void 0!==E[r]){var w,x,re,ae=this.chainsSeq[r],ce=this.chainsAnno[r][0],le=this.chainsAnno[r][1],de=E[r],j=ae.length,q=de.length,he=new Array(j+q),ue=new Array(j+q),pe=new Array(j+q);for(w=0,x=0,re=0;j>w&&q>x;)ae[w].resi<=de[x].resi?(he[re]=ae[w],ue[re]=ce[w],pe[re]=le[w],w++):(he[re]=de[x],de[x].resi%10===0?ue[re]=de[x].resi.toString:ue[re]="",pe[re]="-",x++),re++;if(j>w)for(var me=w;j>me;me++)he[re]=ae[me],ue[re]=ce[me],pe[re]=le[me],re++;else for(var me=x;q>me;me++)he[re]=de[me],de[me].resi%10===0?ue[re]=de[me].resi.toString:ue[re]="",pe[re]="-",re++;this.chainsSeq[r]=he,this.chainsAnno[r][0]=ue,this.chainsAnno[r][1]=pe}n=null,this.residues[a]=s,this.chains[r]=this.unionHash2Atoms(this.chains[r],o);var ge,fe,ve=[],be=this,ye=function(e){for(var i=ve.length,t=0;i>t;++t){for(var n=ve[t],o=t+1;i>o;++o){var s=ve[o];n.alt===s.alt&&be.hasCovalentBond(n,s)&&(n.bonds.push(s.serial),s.bonds.push(n.serial))}e&&e(n)}},Ee=new THREE.Vector3(9999,9999,9999),_e=new THREE.Vector3(-9999,-9999,-9999),we=new THREE.Vector3,Ce=0;for(var w in this.atoms){var X=this.atoms[w],J=X.coord;we.add(J),Ee.min(J),_e.max(J),++Ce,X.het?X.het&&("HOH"===X.resn||"WAT"===X.resn?this.water[X.serial]=1:-1!==$.inArray(X.resn,this.ionsArray)?this.ions[X.serial]=1:this.ligands[X.serial]=1):-1!==$.inArray(X.resn,this.nucleotidesArray)?(this.nucleotides[X.serial]=1,"P"===X.name&&(this.nucleotidesP[X.serial]=1)):(this.proteins[X.serial]=1,"CA"===X.name&&(this.calphas[X.serial]=1),"N"!==X.name&&"CA"!==X.name&&"C"!==X.name&&"O"!==X.name&&(this.sidechains[X.serial]=1)),(ge!==X.chain||fe!==X.resi)&&(ye(function(e){("C"===e.name&&"N"===X.name||"O3'"===e.name&&"P"===X.name)&&be.hasCovalentBond(e,X)&&(e.bonds.push(X.serial),X.bonds.push(e.serial))}),ge=X.chain,fe=X.resi,ve.length=0),ve.push(X)}ye,this.pmin=Ee,this.pmax=_e,this.cnt=Ce,this.maxD=this.pmax.distanceTo(this.pmin),this.center=we.multiplyScalar(1/this.cnt),this.maxD<25&&(this.maxD=25),this.oriMaxD=this.maxD,this.oriCenter=this.center.clone},cloneHash:function(e){var i={};for(var t in e)i[t]=e[t];return i},residueName2Abbr:function(e){switch(void 0!==e&&" "!==e.charAt(0)&&" "===e.charAt(1)&&(e=e.charAt(0)),e){case"  A":return"A";case"  C":return"C";case"  G":return"G";case"  T":return"T";case"  U":return"U";case"  I":return"I";case" DA":return"A";case" DC":return"C";case" DG":return"G";case" DT":return"T";case" DU":return"U";case" DI":return"I";case"ALA":return"A";case"ARG":return"R";case"ASN":return"N";case"ASP":return"D";case"CYS":return"C";case"GLU":return"E";case"GLN":return"Q";case"GLY":return"G";case"HIS":return"H";case"ILE":return"I";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"THR":return"T";case"TRP":return"W";case"TYR":return"Y";case"VAL":return"V";case"SEC":return"U";case"HOH":return"O";case"WAT":return"O";default:return e}},calculateLigandHbonds:function(e,i,t){if(0!==Object.keys(e).length&&0!==Object.keys(i).length){var n,o={},s=t*t;for(var r in e){var a=e[r];("N"===a.elem||"O"===a.elem||"F"===a.elem)&&(n=a.structure+"_"+a.chain+"_"+a.resi+"_"+a.name,o[n]=a)}this.highlightAtoms={};for(var r in i){var a=i[r];if("N"===a.elem||"O"===a.elem||"F"===a.elem){n=a.structure+"_"+a.chain+"_"+a.resi+"_"+a.name;for(var c in o){var l=Math.abs(a.coord.x-o[c].coord.x);if(!(l>t)){var d=Math.abs(a.coord.y-o[c].coord.y);if(!(d>t)){var h=Math.abs(a.coord.z-o[c].coord.z);if(!(h>t)){var u=l*l+d*d+h*h;if(!(u>s)){var p=c.indexOf("_"),m=c.lastIndexOf("_"),g=c.substr(0,p),f=c.substr(p+1,m-p-1);m=f.lastIndexOf("_");var v=f.substr(0,m),b=f.substr(m+1);this.hbondpoints.push(a.coord),this.hbondpoints.push(o[c].coord),this.highlightAtoms=this.unionHash(this.highlightAtoms,this.residues[g+"_"+v+"_"+b])}}}}}}}}},createSphere:function(e,i,t,n,o){var s;if(void 0===i&&(i=.8),void 0===t&&(t=!1),void 0===n&&(n=1),2===o){n>.9?n=1.5:.5>n&&(n=1);var r=this.highlightColor;s=new THREE.Mesh(this.sphereGeometry,new THREE.MeshPhongMaterial({transparent:!0,opacity:.5,overdraw:this.overdraw,specular:this.fractionOfColor,shininess:30,emissive:0,color:r}))}else if(1===o)s=new THREE.Mesh(this.sphereGeometry,this.matShader);else{var r=e.color;s=new THREE.Mesh(this.sphereGeometry,new THREE.MeshPhongMaterial({overdraw:this.overdraw,specular:this.fractionOfColor,shininess:30,emissive:0,color:r}))}s.scale.x=s.scale.y=s.scale.z=t?i:(this.vdwRadii[e.elem]||i)*(n?n:1),s.position.copy(e.coord),this.mdl.add(s),1===o||2===o?this.prevHighlightObjects.push(s):this.objects.push(s)},createBox:function(e,i,t,n,o,s){var r;void 0===i&&(i=.8),void 0===t&&(t=!1),void 0===n&&(n=.8),s?(void 0===o&&(o=this.highlightColor),r=new THREE.Mesh(this.boxGeometry,new THREE.MeshPhongMaterial({transparent:!0,opacity:.5,overdraw:this.overdraw,specular:this.fractionOfColor,shininess:30,emissive:0,color:o}))):(void 0===o&&(o=e.color),r=new THREE.Mesh(this.boxGeometry,new THREE.MeshPhongMaterial({overdraw:this.overdraw,specular:this.fractionOfColor,shininess:30,emissive:0,color:o}))),r.scale.x=r.scale.y=r.scale.z=t?i:(this.vdwRadii[e.elem]||i)*(n?n:1),r.position.copy(e.coord),this.mdl.add(r),s?this.prevHighlightObjects.push(r):this.objects.push(r)},createCylinder:function(e,i,t,n,o){var s;if(1===o){if(this.maxD<50)s=new THREE.Mesh(this.cylinderGeometryOutline,this.matShader),s.position.copy(e).add(i).multiplyScalar(.5),s.matrixAutoUpdate=!1,s.lookAt(e),s.updateMatrix,s.matrix.multiply((new THREE.Matrix4).makeScale(t,t,e.distanceTo(i))).multiply((new THREE.Matrix4).makeRotationX(.5*Math.PI));else{var t=.5*this.coilWidth,r=8,a=!1,c=[e,i],l=new THREE.TubeGeometry(new THREE.SplineCurve3(c),c.length,t,r,a);s=new THREE.Mesh(l,this.matShader)}this.mdl.add(s),this.prevHighlightObjects.push(s)}else 2===o?(s=new THREE.Mesh(this.cylinderGeometry,new THREE.MeshPhongMaterial({transparent:!0,opacity:.5,overdraw:this.overdraw,specular:this.fractionOfColor,shininess:30,emissive:0,color:n})),t*=1.5):s=new THREE.Mesh(this.cylinderGeometry,new THREE.MeshPhongMaterial({overdraw:this.overdraw,specular:this.fractionOfColor,shininess:30,emissive:0,color:n})),s.position.copy(e).add(i).multiplyScalar(.5),s.matrixAutoUpdate=!1,s.lookAt(e),s.updateMatrix,s.matrix.multiply((new THREE.Matrix4).makeScale(t,t,e.distanceTo(i))).multiply((new THREE.Matrix4).makeRotationX(.5*Math.PI)),this.mdl.add(s),2===o?this.prevHighlightObjects.push(s):this.objects.push(s)},createRepresentationSub:function(e,i,t){new THREE.Geometry;for(var n in e){var o=e[n];i&&i(o);for(var s in o.bonds){var r=this.atoms[o.bonds[s]];void 0===r||r.serial<o.serial||t&&t(o,r)}}},createSphereRepresentation:function(e,i,t,n,o){var s=this;this.createRepresentationSub(e,function(e){s.createSphere(e,i,t,n,o)})},createBoxRepresentation_P_CA:function(e,i,t){var n=this;this.createRepresentationSub(e,function(e){("CA"===e.name||"P"===e.name)&&n.createBox(e,void 0,void 0,i,void 0,t)})},createStickRepresentation:function(e,i,t,n,o,s){var r=this,a=void 0!==s&&s?i/r.cylinderRadius:1;2!==o?this.createRepresentationSub(e,function(e){r.createSphere(e,i,!n,n,o)},function(e,i){var n=e.coord.clone.add(i.coord).multiplyScalar(.5),s=e.serial+"_"+i.serial;if(r.doublebonds.hasOwnProperty(s)){var c,l,d;e.bonds.length>i.bonds.length?(c=e.serial,l=e.bonds[0],d=e.bonds[1]):(c=i.serial,l=i.bonds[0],d=i.bonds[1]);var h=r.atoms[c].coord.clone;h.sub(r.atoms[l].coord);var u=r.atoms[c].coord.clone;u.sub(r.atoms[d].coord),h.cross(u);var p=i.coord.clone;p.sub(e.coord),p.cross(h).normalize.multiplyScalar(.2*a),e.color===i.color?(r.createCylinder(e.coord.clone.add(p),i.coord.clone.add(p),r.cylinderRadius*a*.3,e.color,o),r.createCylinder(e.coord.clone.sub(p),i.coord.clone.sub(p),r.cylinderRadius*a*.3,e.color,o)):(r.createCylinder(e.coord.clone.add(p),n.clone.add(p),r.cylinderRadius*a*.3,e.color,o),r.createCylinder(i.coord.clone.add(p),n.clone.add(p),r.cylinderRadius*a*.3,i.color,o),r.createCylinder(e.coord.clone.sub(p),n.clone.sub(p),r.cylinderRadius*a*.3,e.color,o),r.createCylinder(i.coord.clone.sub(p),n.clone.sub(p),r.cylinderRadius*a*.3,i.color,o))}else if(r.aromaticbonds.hasOwnProperty(s)){var c,l,d;e.bonds.length>i.bonds.length?(c=e.serial,l=e.bonds[0],d=e.bonds[1]):(c=i.serial,l=i.bonds[0],d=i.bonds[1]);var h=r.atoms[c].coord.clone;h.sub(r.atoms[l].coord);var u=r.atoms[c].coord.clone;u.sub(r.atoms[d].coord),h.cross(u);var p=i.coord.clone;p.sub(e.coord),p.cross(h).normalize.multiplyScalar(.2*a);for(var m=0,g=0,f=e.bondOrder.length;f>g;++g)"1.5"===e.bondOrder[g]&&e.bonds[g]!==i.serial&&(m=e.bonds[g]);var v="add";if(0===m)v="add";else{var b=e.coord.clone.add(p),y=e.coord.clone.sub(p),E=i.coord.clone.sub(b).normalize,_=r.atoms[m].coord.clone.sub(b).normalize,w=i.coord.clone.sub(y).normalize,C=r.atoms[m].coord.clone.sub(y).normalize,S=Math.acos(E.dot(_)),k=Math.acos(w.dot(C));v=k>S?"sub":"add"}if(e.color===i.color){var R,T;"add"===v?(r.createCylinder(e.coord.clone.sub(p),i.coord.clone.sub(p),r.cylinderRadius*a*.3,e.color,o),R=e.coord.clone.add(p),T=i.coord.clone.add(p).sub(R).multiplyScalar(1/11)):(r.createCylinder(e.coord.clone.add(p),i.coord.clone.add(p),r.cylinderRadius*a*.3,e.color,o),R=e.coord.clone.sub(p),T=i.coord.clone.sub(p).sub(R).multiplyScalar(1/11));for(var g=0;10>=g;++g)if(g%2==0){var H=R.clone.add(T.clone.multiplyScalar(g)),A=R.clone.add(T.clone.multiplyScalar(g+1));r.createCylinder(H,A,r.cylinderRadius*a*.3,e.color,o)}}else{var R,T;"add"===v?(r.createCylinder(e.coord.clone.sub(p),n.clone.sub(p),r.cylinderRadius*a*.3,e.color,o),r.createCylinder(i.coord.clone.sub(p),n.clone.sub(p),r.cylinderRadius*a*.3,i.color,o),R=e.coord.clone.add(p),T=i.coord.clone.add(p).sub(R).multiplyScalar(1/11)):(r.createCylinder(e.coord.clone.add(p),n.clone.add(p),r.cylinderRadius*a*.3,e.color,o),r.createCylinder(i.coord.clone.add(p),n.clone.add(p),r.cylinderRadius*a*.3,i.color,o),R=e.coord.clone.sub(p),T=i.coord.clone.sub(p).sub(R).multiplyScalar(1/11));for(var g=0;10>=g;++g)if(g%2==0){var H=R.clone.add(T.clone.multiplyScalar(g)),A=R.clone.add(T.clone.multiplyScalar(g+1));5>g?r.createCylinder(H,A,r.cylinderRadius*a*.3,e.color,o):r.createCylinder(H,A,r.cylinderRadius*a*.3,i.color,o)}}}else if(r.triplebonds.hasOwnProperty(s)){var x=new THREE.Vector3(Math.random,Math.random,Math.random),O=i.coord.clone;O.sub(e.coord);var w=x.clone;w.cross(O).normalize.multiplyScalar(.3*a),e.color===i.color?(r.createCylinder(e.coord,i.coord,r.cylinderRadius*a*.2,e.color,o),r.createCylinder(e.coord.clone.add(w),i.coord.clone.add(w),r.cylinderRadius*a*.2,e.color,o),r.createCylinder(e.coord.clone.sub(w),i.coord.clone.sub(w),r.cylinderRadius*a*.2,e.color,o)):(r.createCylinder(e.coord,n,r.cylinderRadius*a*.2,e.color,o),r.createCylinder(i.coord,n,r.cylinderRadius*a*.2,i.color,o),r.createCylinder(e.coord.clone.add(w),n.clone.add(w),r.cylinderRadius*a*.2,e.color,o),r.createCylinder(i.coord.clone.add(w),n.clone.add(w),r.cylinderRadius*a*.2,i.color,o),r.createCylinder(e.coord.clone.sub(w),n.clone.sub(w),r.cylinderRadius*a*.2,e.color,o),r.createCylinder(i.coord.clone.sub(w),n.clone.sub(w),r.cylinderRadius*a*.2,i.color,o))}else e.color===i.color?r.createCylinder(e.coord,i.coord,t,e.color,o):(r.createCylinder(e.coord,n,t,e.color,o),r.createCylinder(i.coord,n,t,i.color,o))}):2===o&&this.createBoxRepresentation_P_CA(e,1.2,o)},createLineRepresentation:function(e,i){var t=new THREE.Geometry;if(this.createRepresentationSub(e,void 0,function(e,i){if(e.color===i.color)t.vertices.push(e.coord),t.vertices.push(i.coord),t.colors.push(e.color),t.colors.push(i.color);else{var n=e.coord.clone.add(i.coord).multiplyScalar(.5);t.vertices.push(e.coord),t.vertices.push(n),t.vertices.push(i.coord),t.vertices.push(n),t.colors.push(e.color),t.colors.push(e.color),t.colors.push(i.color),t.colors.push(i.color)}}),2!==i){var n;1===i||(n=new THREE.Line(t,new THREE.LineBasicMaterial({linewidth:this.linewidth,vertexColors:!0}),THREE.LinePieces)),this.mdl.add(n),1===i?this.prevHighlightObjects.push(n):this.objects.push(n)}else 2===i&&this.createBoxRepresentation_P_CA(e,.8,i)},subdivide:function(e,i,t,n){var o=[],s=[],r=new Array;r.push(e[0]);for(var a=1,c=e.length-1;c>a;++a){var l=e[a],d=e[a+1];r.push(l.smoothen?l.clone.add(d).multiplyScalar(.5):l)}r.push(e[e.length-1]);for(var h=[],u=[],a=-1,p=r.length,m=1/i;p-3>=a;++a){var l=r[-1===a?0:a],d=r[a+1],g=r[a+2],f=r[a===p-3?p-1:a+3],v=g.clone.sub(l).multiplyScalar(.5),b=f.clone.sub(d).multiplyScalar(.5);a>-1&&void 0!==t&&t[a+1]&&(o=o.concat(h),s=s.concat(u)),h=[],u=[];for(var y=0;i>y;++y){var E=m*y,_=d.x+E*v.x+E*E*(-3*d.x+3*g.x-2*v.x-b.x)+E*E*E*(2*d.x-2*g.x+v.x+b.x),w=d.y+E*v.y+E*E*(-3*d.y+3*g.y-2*v.y-b.y)+E*E*E*(2*d.y-2*g.y+v.y+b.y),C=d.z+E*v.z+E*E*(-3*d.z+3*g.z-2*v.z-b.z)+E*E*E*(2*d.z-2*g.z+v.z+b.z);t?(t[a+1]&&y<=parseInt(i/2)&&(o.push(new THREE.Vector3(_,w,C)),s.push(t[a+1])),t[a+2]&&y>parseInt(i/2)&&(h.push(new THREE.Vector3(_,w,C)),u.push(t[a+2]))):(o.push(new THREE.Vector3(_,w,C)),s.push(a+1))}}return(!t||t[a+1])&&(o=o.concat(h),s=s.concat(u),o.push(r[r.length-1]),s.push(r.length-1)),h=[],u=[],r=[],points_positions=[],points_positions.push(o),points_positions.push(s),points_positions},createCurveSubArrow:function(e,i,t,n,o,s,r,a,c,l,d){var h=[],u=[];h.push(e),u.push(a),this.prepareStrand(h,u,i,t,n,void 0,o,s,r,c,l,!1,d),h=[],u=[]},createCurveSub:function(e,i,t,n,o,s,r,a,c){if(0!==e.length){n=n||5;var l;if(l=r?e:this.subdivide(e,n,a,o)[0],0!==l.length){if(1===o){var d=this.coilWidth/2,h=4,u=!1;if(l.length>1)if(void 0!==c){for(var p,m,g=[],f=0,v=l.length;v>f;++f){if(p=c[f],p!==m&&p!==m+1&&void 0!==m||f===v-1){var b=new THREE.TubeGeometry(new THREE.SplineCurve3(g),g.length,d,h,u);mesh=new THREE.Mesh(b,this.matShader),this.mdl.add(mesh),this.prevHighlightObjects.push(mesh),b=null,g=[]}g.push(l[f]),m=p}g=[]}else{var b=new THREE.TubeGeometry(new THREE.SplineCurve3(l),l.length,d,h,u);mesh=new THREE.Mesh(b,this.matShader),this.mdl.add(mesh),this.prevHighlightObjects.push(mesh),b=null}}else{var y=new THREE.Geometry;if(2===o&&s)for(var f=0,E=1/n;f<l.length;++f)l[f].addScalar(.6),y.vertices.push(l[f]),y.colors.push(new THREE.Color(t[0===f?0:Math.round((f-1)*E)]));else for(var f=0,E=1/n;f<l.length;++f)y.vertices.push(l[f]),y.colors.push(new THREE.Color(t[0===f?0:Math.round((f-1)*E)]));var _=new THREE.Line(y,new THREE.LineBasicMaterial({linewidth:i,vertexColors:!0}),THREE.LineStrip);this.mdl.add(_),2===o?this.prevHighlightObjects.push(_):this.objects.push(_)}l=null}}},createLines:function(e){if(void 0!==e)for(var i in e)for(var t=e[i],n=0,o=t.length;o>n;++n){var s,r=t[n],a=r.position1,c=r.position2;if(r.color){var l=/^\#([0-9a-f]{6})$/i.exec(r.color);s=parseInt(l[1],16)}else s=16776960;var d=r.dashed?r.dashed:!1,h=.3;this.mdl.add(this.createSingleLine(a,c,s,d,h))}},createCylinderCurve:function(e,i,t,n,o){var s,r,a,c=null;for(a in e){var l=e[a]; if(!l.het&&l.name===i){if(null!==c&&s===l.chain&&r+1===l.resi){var d=c.coord.clone.add(l.coord).multiplyScalar(.5);if(o)1===o&&(this.createCylinder(c.coord,d,t,c.color,o),this.createCylinder(d,l.coord,t,l.color,o),this.createSphere(l,t,!0,1,o));else if(n){var h=this.createSingleLine(c.coord,d,c.color,!1);this.mdl.add(h),this.objects.push(h),h=this.createSingleLine(d,l.coord,l.color,!1),this.mdl.add(h),this.objects.push(h)}else this.createCylinder(c.coord,d,t,c.color),this.createCylinder(d,l.coord,t,l.color),this.createSphere(l,t,!0,1)}c=l,s=l.chain,r=l.resi,2===o&&this.createBox(l,void 0,void 0,void 0,void 0,o)}}if(null!==c&&s===l.chain&&r+1===l.resi){var d=c.coord.add(l.coord).multiplyScalar(.5);if(o)1===o&&(this.createCylinder(c.coord,d,t,c.color,o),this.createCylinder(d,l.coord,t,l.color,o),this.createSphere(l,t,!0,1,o));else if(n){var h=this.createSingleLine(c.coord,d,c.color,!1);this.mdl.add(h),this.objects.push(h),h=this.createSingleLine(d,l.coord,l.color,!1),this.mdl.add(h),this.objects.push(h)}else this.createCylinder(c.coord,d,t,c.color),this.createCylinder(d,l.coord,t,l.color)}},prepareStrand:function(e,i,t,n,o,s,r,a,c,l,d,h,u){if(1!==l.length){o=o||this.axisDIV;for(var p,m,g,f,v=2/(c-1),b={},y=[],E=0,_=i.length;_>E;++E)b[E]=[];var w=this.subdivide(l,o)[0];if(1!==w.length){for(var E=0,_=l.length-2;_>E;++E){for(var C=0,S=i.length;S>C;++C)b[C].push(e[C][E]);y.push(n[E])}y.push(n[E]);for(var E=0,_=i.length;_>E;++E)p=-1+v*i[E],m=w.length-1-o,g=l.length-2,f=new THREE.Vector3(w[m].x+d[g].x*p,w[m].y+d[g].y*p,w[m].z+d[g].z*p),b[E].push(f);for(var k=[],E=0,_=i.length;_>E;++E){var R=this.subdivide(b[E],o,u,r);b[E]=R[0],0===E&&(k=R[1])}h?this.createStrip(b[0],b[1],y,o,s,r,!0,void 0,k):this.createCurveSub(b[0],t,y,o,r,a,!0,void 0,k);for(var E in b){for(var T=0,H=b[E].length;H>T;++T)b[E][T]=null;b[E]=[]}y=[],k=[];for(var C=0,S=i.length;S>C;++C){b[C]=[];for(var E=o*(l.length-2),_=o*(l.length-1);u[parseInt(E/o)]&&_>E;E+=o)for(var A=parseInt(E/o),T=0;o>T;++T){var p=-1+v*i[C],x=1.8;p=p*x*(o-T)/o;var O=parseInt(E/o),f=new THREE.Vector3(w[E+T].x+d[O].x*p,w[E+T].y+d[O].y*p,w[E+T].z+d[O].z*p);f.smoothen=!0,b[C].push(f),0===C&&k.push(A)}var p=0,m=w.length-1,g=l.length-1,f=new THREE.Vector3(w[m].x+d[g].x*p,w[m].y+d[g].y*p,w[m].z+d[g].z*p);f.smoothen=!0,b[C].push(f),0===C&&k.push(m)}w=[],y.push(n[n.length-2]),y.push(n[n.length-1]),h?this.createStrip(b[0],b[1],y,o,s,r,!0,void 0,k):this.createCurveSub(b[0],t,y,o,r,a,!0,void 0,k);for(var E in b){for(var T=0,H=b[E].length;H>T;++T)b[E][T]=null;b[E]=[]}b={}}}},createStripArrow:function(e,i,t,n,o,s,r,a,c,l,d,h){var u=[],p=[];u.push(e),u.push(i),p.push(a),p.push(c),this.prepareStrand(u,p,void 0,t,n,o,s,void 0,r,l,d,!0,h),u=[],p=[]},createStrip:function(e,i,t,n,o,s,r,a,c){if(!(e.length<2||(n=n||this.axisDIV,r||(e=this.subdivide(e,n,a,s)[0],i=this.subdivide(i,n,a,s)[0]),e.length<2))){if(1===s){var l=this.coilWidth/2,d=4,h=!1;if(void 0!==c){for(var u,p,m=[],g=[],f=0,v=e.length;v>f;++f){if(u=c[f],u!==p&&u!==p+1&&void 0!==p||f===v-1){var b=new THREE.TubeGeometry(new THREE.SplineCurve3(m),m.length,l,d,h);I=new THREE.Mesh(b,this.matShader),this.mdl.add(I),this.prevHighlightObjects.push(I),b=null;var y=new THREE.TubeGeometry(new THREE.SplineCurve3(g),g.length,l,d,h);I=new THREE.Mesh(y,this.matShader),this.mdl.add(I),this.prevHighlightObjects.push(I),y=null,m=[],g=[]}m.push(e[f]),g.push(i[f]),p=u}m=[],g=[]}else{var b=new THREE.TubeGeometry(new THREE.SplineCurve3(e),e.length,l,d,h);I=new THREE.Mesh(b,this.matShader),this.mdl.add(I),this.prevHighlightObjects.push(I),b=null;var y=new THREE.TubeGeometry(new THREE.SplineCurve3(i),i.length,l,d,h);I=new THREE.Mesh(y,this.matShader),this.mdl.add(I),this.prevHighlightObjects.push(I),y=null}}else{for(var E,_,w,C,S,k=new THREE.Geometry,R=k.vertices,T=k.faces,f=0,H=e.length;H>f;++f)R.push(_=e[f]),R.push(_),R.push(w=i[f]),R.push(w),H-1>f&&(E=i[f].clone.sub(e[f]).cross(e[f+1].clone.sub(e[f])).normalize.multiplyScalar(o)),R.push(C=e[f].clone.add(E)),R.push(C),R.push(S=i[f].clone.add(E)),R.push(S);for(var A=0,2,-6,-8],[-4,-2,6,4],[7,3,-5,-1],[-3,-7,1,5,f=1,H=e.length,x=1/n;H>f;++f)for(var O=8*f,$=new THREE.Color(t[Math.round((f-1)*x)]),M=0;4>M;++M)T.push(new THREE.Face3(O+A[M][0],O+A[M][1],O+A[M][2],void 0,$)),T.push(new THREE.Face3(O+A[M][3],O+A[M][0],O+A[M][2],void 0,$));for(var L=R.length-8,f=0;4>f;++f)R.push(R[2*f]),R.push(R[L+2*f]);L+=8,T.push(new THREE.Face3(L,L+2,L+6,void 0,T[0].color)),T.push(new THREE.Face3(L+4,L,L+6,void 0,T[0].color)),T.push(new THREE.Face3(L+1,L+5,L+7,void 0,T[T.length-3].color)),T.push(new THREE.Face3(L+3,L+1,L+7,void 0,T[T.length-3].color)),k.computeFaceNormals,k.computeVertexNormals(!1);var I;2===s?(I=new THREE.Mesh(k,new THREE.MeshPhongMaterial({transparent:!0,opacity:.5,overdraw:this.overdraw,specular:this.fractionOfColor,shininess:30,emissive:0,vertexColors:THREE.FaceColors,side:THREE.DoubleSide})),this.mdl.add(I),this.prevHighlightObjects.push(I)):(I=new THREE.Mesh(k,new THREE.MeshPhongMaterial({overdraw:this.overdraw,specular:this.fractionOfColor,shininess:30,emissive:0,vertexColors:THREE.FaceColors,side:THREE.DoubleSide})),this.mdl.add(I),this.objects.push(I))}e=null,i=null}},getFirstAtomObj:function(e){var i=Object.keys(e),t=i[0];return this.atoms[t]},getLastAtomObj:function(e){var i=Object.keys(e),t=i[i.length-1];return this.atoms[t]},getResiduesFromAtoms:function(e){var i={};for(var t in e){var n=this.atoms[t].structure+"_"+this.atoms[t].chain+"_"+this.atoms[t].resi;i[n]=1}return i},createStrand:function(e,i,t,n,o,s,r,a,c){var l=n?!0:!1,d={};if(1!==c&&2!==c||this.bAllAtoms)d=e;else{var h,u,p,m,g,f,v,b,y=0,E=Object.keys(e).length;d=this.cloneHash(e);for(var _ in e){if(h=e[_].structure+"_"+e[_].chain,u=parseInt(e[_].resi),p=e[_],void 0===m&&(v=e[_]),h!==m&&void 0!==m||u!==g&&u!==g+1&&void 0!==g||y===E-1){h!==m&&void 0!==m||u!==g&&u!==g+1&&void 0!==g?b=f:y===E-1&&(b=p);var w=v.resi;if("coil"!==v.ss&&!v.ssbegin){for(var C=v.resi-1;C>0;--C){var S=v.structure+"_"+v.chain+"_"+C;if(!this.residues.hasOwnProperty(S))break;var k=this.getFirstAtomObj(this.residues[S]);if(k.ss===v.ss&&k.ssbegin){w=k.resi;break}}for(var C=w;C<v.resi;++C){var S=v.structure+"_"+v.chain+"_"+C;d=this.unionHash(d,this.hash2Atoms(this.residues[S]))}}if(3===this.picking&&1===c&&"coil"===v.ss){var S=v.structure+"_"+v.chain+"_"+(v.resi-1);this.residues.hasOwnProperty(S)&&(d=this.unionHash(d,this.hash2Atoms(this.residues[S])),e=this.unionHash(e,this.hash2Atoms(this.residues[S])))}var R=b.resi;if("coil"!==b.ss&&!b.ssend&&!b.notshow){for(var T=this.getLastAtomObj(this.chains[b.structure+"_"+b.chain]).resi,C=b.resi+1;T>=C;++C){var S=b.structure+"_"+b.chain+"_"+C;if(!this.residues.hasOwnProperty(S))break;var k=this.getFirstAtomObj(this.residues[S]);if(k.ss===b.ss&&k.ssend){R=k.resi;break}}for(var C=b.resi+1;R>=C;++C){var S=b.structure+"_"+b.chain+"_"+C;d=this.unionHash(d,this.hash2Atoms(this.residues[S]))}}if(3===this.picking&&1===c&&"coil"===b.ss){var S=b.structure+"_"+b.chain+"_"+(b.resi+1);this.residues.hasOwnProperty(S)&&(d=this.unionHash(d,this.hash2Atoms(this.residues[S])),e=this.unionHash(e,this.hash2Atoms(this.residues[S])))}b.notshow&&(b.notshow=void 0),v=p}m=h,g=u,f=p,++y}}2===c&&(n?(n=!1,i=null,t=null,o=null,s=null,a=void 0):(n=!0,i=2,t=void 0,o=void 0,s=void 0,a=this.thickness)),i=i||this.strandDIV,t=t||this.axisDIV,o=o||this.coilWidth,r=r||!1,s=s||this.helixSheetWidth;for(var H={},A=0;i>A;++A)H[A]=[];var x,O,$,k,M=[],L=[],I=[],D=[],z=null,N=null,q=null,j=null,P=null,F=null,B=null,V=null,G=!1,U=null,W=null,g=null,Y=!1,X=!1,Z={};this.bCalphaOnly=!1;var y=0,K=30,Q=!1;for(var C in d){if(!(K>y))break;if("CA"!==d[C].name){Q=!0;break}++y}Q||(this.bCalphaOnly=!0);var J={};for(var C in d){var k=d[C];S=k.structure+"_"+k.chain+"_"+k.resi,J[S]=1}var ee=Object.keys(J).length,ie=0,te=0;for(var C in d){k=d[C];if(("O"===k.name||"CA"===k.name)&&!k.het&&("CA"===k.name&&(e.hasOwnProperty(C)&&("coil"===k.ss||k.ssend||k.ssbegin)&&(Z[C]=k),z=k.coord,q=k.color),"O"===k.name||this.bCalphaOnly&&"CA"===k.name)){"O"===k.name&&(N=k.coord);var ne=!0;if((x!==k.chain||O+1!==k.resi)&&(ne=!1),k.ssend&&"sheet"===k.ss?Y=!0:k.ssend&&"helix"===k.ss&&(X=!0),P){1===c||2===c?D.push(this.highlightColor):D.push(F),$="coil"!==V&&"coil"===k.ss?o:G&&k.ssbegin?o:"coil"===V?o:s;var oe;"O"===k.name?(oe=P.clone,null!==j&&void 0!==j?oe.sub(j):(j=P.clone,oe=new THREE.Vector3(Math.random,Math.random,Math.random))):this.bCalphaOnly&&"CA"===k.name&&(oe=new THREE.Vector3(Math.random,Math.random,Math.random)),oe.normalize,oe.multiplyScalar($),null!==B&&oe.dot(B)<0&&oe.negate,B=oe;for(var se=0,re=2/(i-1);i>se;++se){var ae=-1+re*se,ce=new THREE.Vector3(j.x+B.x*ae,j.y+B.y*ae,j.z+B.z*ae);r||"sheet"!==V||(ce.smoothen=!0),H[se].push(ce)}M.push(j),L.push(B),e.hasOwnProperty(W)?(I.push(g),++te):I.push(0),++ie}if((k.ssbegin||k.ssend||ie===ee-1)&&H[0].length>0&&ne){1===c||2===c?D.push(this.highlightColor):D.push(k.color),$=k.ssend&&"sheet"===k.ss?0:"coil"===V&&k.ssbegin?o:G&&k.ssbegin?o:"coil"===k.ss?o:s;var oe;"O"===k.name?(oe=N.clone,oe.sub(z)):this.bCalphaOnly&&"CA"===k.name&&(oe=new THREE.Vector3(Math.random,Math.random,Math.random)),oe.normalize,oe.multiplyScalar($),null!==B&&oe.dot(B)<0&&oe.negate,B=oe;for(var se=0,re=2/(i-1);i>se;++se){var ae=-1+re*se,ce=new THREE.Vector3(z.x+B.x*ae,z.y+B.y*ae,z.z+B.z*ae);r||"sheet"!==V||(ce.smoothen=!0),H[se].push(ce)}U=k.serial,M.push(z),L.push(B),e.hasOwnProperty(U)?I.push(k.resi):I.push(0);for(var se=0;!n&&i>se;++se)Y?this.createCurveSubArrow(H[se],1,D,t,c,l,i,se,M,L,I):this.createCurveSub(H[se],1,D,t,c,l,!1,I);if(n)if(Y){var le=0,de=i-1;this.createStripArrow(H[0],H[i-1],D,t,a,c,i,le,de,M,L,I)}else X?this.createStrip(H[0],H[i-1],D,t,a,c,!1,I):2===c&&this.createStrip(H[0],H[i-1],D,t,a,c,!1,I);for(var A=0;i>A;++A)H[A]=[];D=[],M=[],L=[],I=[],Y=!1,X=!1}if((x!==k.chain||O+1!==k.resi)&&H[0].length>0){for(var se=0;!n&&i>se;++se)Y?this.createCurveSubArrow(H[se],1,D,t,c,l,i,se,M,L,I):X&&this.createCurveSub(H[se],1,D,t,c,l,!1,I);if(n)if(Y){var le=0,de=i-1;this.createStripArrow(H[0],H[i-1],D,t,a,c,i,le,de,M,L,I)}else X&&this.createStrip(H[0],H[i-1],D,t,a,c,!1,I);for(var A=0;i>A;++A)H[A]=[];D=[],M=[],L=[],I=[],Y=!1,X=!1}x=k.chain,O=k.resi,V=k.ss,G=k.ssend,W=k.serial,g=k.resi,j=z,P=k.coord,F=q}}this.createTube(Z,"CA",.3,c),Z={},H={}},createStrandBrick:function(e,i,t,n){var o=this.strandDIV,s=this.axisDIV,r=!1,a=this.helixSheetWidth;2===n&&(t*=1.5,a*=1.5);for(var c={},l=0;o>l;++l)c[l]=[];for(var d=[],h=null,u=0;2>u;++u){var p=e.coords[u];d.push(new THREE.Color(i));var m=new THREE.Vector3(e.coords[2].x,e.coords[2].y,e.coords[2].z);m.normalize,m.multiplyScalar(a),null!==h&&m.dot(h)<0&&m.negate,h=m;for(var g=0,f=2/(o-1);o>g;++g){var v=-1+f*g,b=new THREE.Vector3(p.x+h.x*v,p.y+h.y*v,p.z+h.z*v);r||(b.smoothen=!0),c[g].push(b)}}this.createStrip(c[0],c[o-1],d,s,t,n)},createTubeSub:function(e,i,t,n){if(!(e.length<2)){for(var o,s=this.tubeDIV,r=this.axisDIV,a=1/s,c=1/r,l=new THREE.Geometry,d=this.subdivide(e,r)[0],h=new THREE.Vector3,u=0,p=d.length;p>u;++u){var m,g=(u-1)*c;if(0===u)m=t[0];else if(g%1===0)m=t[g];else{var f=Math.floor(g),v=g-f;m=t[f]*v+t[f+1]*(1-v)}var b,y,E;p-1>u?(b=d[u].clone.sub(d[u+1]),y=new THREE.Vector3(0,-b.z,b.y).normalize.multiplyScalar(m),E=b.clone.cross(y).normalize.multiplyScalar(m),h.dot(y)<0&&(y.negate,E.negate),h=y,o=E):(y=h,E=o);for(var _=0;s>_;++_){var w=2*Math.PI*a*_;l.vertices.push(d[u].clone.add(y.clone.multiplyScalar(Math.cos(w))).add(E.clone.multiplyScalar(Math.sin(w))))}}for(var C=0,u=0,p=d.length-1;p>u;++u){var S=new THREE.Color(i[Math.round((u-1)*c)]),k=0,R=l.vertices[C].clone.sub(l.vertices[C+s]).lengthSq,T=l.vertices[C].clone.sub(l.vertices[C+s+1]).lengthSq;R>T&&(R=T,k=1);for(var _=0;s>_;++_)l.faces.push(new THREE.Face3(C+_,C+(_+k)%s+s,C+(_+1)%s,void 0,S)),l.faces.push(new THREE.Face3(C+(_+1)%s,C+(_+k)%s+s,C+(_+k+1)%s+s,void 0,S));C+=s}l.computeFaceNormals,l.computeVertexNormals(!1);var H;H=2===n?new THREE.Mesh(l,new THREE.MeshPhongMaterial({transparent:!0,opacity:.5,overdraw:this.overdraw,specular:this.fractionOfColor,shininess:30,emissive:0,vertexColors:THREE.FaceColors,side:THREE.DoubleSide})):1===n?new THREE.Mesh(l,this.matShader):new THREE.Mesh(l,new THREE.MeshPhongMaterial({overdraw:this.overdraw,specular:this.fractionOfColor,shininess:30,emissive:0,vertexColors:THREE.FaceColors,side:THREE.DoubleSide})),this.mdl.add(H),1===n||2===n?this.prevHighlightObjects.push(H):this.objects.push(H)}},createTube:function(e,i,t,n){var o,s,r=[],a=[],c=[];for(var l in e){var d=e[l];if(d.name===i&&!d.het){(o!==d.chain||s+1!==d.resi)&&(2!==n&&this.createTubeSub(r,a,c,n),r=[],a=[],c=[]),r.push(d.coord),c.push(t||(d.b>0?.01*d.b:.3)),a.push(d.color),o=d.chain,s=d.resi;var h=1.2;2!==n||d.ssbegin||this.createBox(d,void 0,void 0,h,void 0,n)}}2!==n&&this.createTubeSub(r,a,c,n)},createCylinderHelix:function(e,i,t){var n,o,s,r=null,a={},c={};for(s in e){var l=e[s];l.het||(("helix"!==l.ss&&"sheet"!==l.ss||l.ssend||l.ssbegin)&&(a[l.serial]=l),"sheet"===l.ss&&(c[l.serial]=l),"CA"===l.name&&("helix"===l.ss&&l.ssend&&(null!==r&&n===l.chain&&o<l.resi&&(1===t||2===t?this.createCylinder(r.coord,l.coord,i,this.highlightColor,t):this.createCylinder(r.coord,l.coord,i,l.color)),r=null),null===r&&"helix"===l.ss&&l.ssbegin&&(r=l,n=l.chain,o=l.resi)))}1===t||2===t?(Object.keys(a).length>0&&this.createTube(a,"CA",.3,t),Object.keys(c).length>0&&this.createStrand(c,void 0,void 0,!0,0,this.helixSheetWidth,!1,2*this.thickness,t)):(Object.keys(a).length>0&&this.createTube(a,"CA",.3),Object.keys(c).length>0&&this.createStrand(c,void 0,void 0,!0,0,this.helixSheetWidth,!1,2*this.thickness))},createSurfaceRepresentation:function(e,i,t,n){var o,s=this.getExtent(e),r=5,a=[];a=this.bConsiderNeighbors?Object.keys(this.unionHash(e,this.getAtomsWithinAtom(this.atoms,e,r))):Object.keys(e);var c=$3Dmol.SetupSurface({extent:s,allatoms:this.atoms,atomsToShow:Object.keys(e),extendedAtoms:a,type:i}),l=c.vertices,d=c.faces,h=this;o=new THREE.Geometry,o.vertices=l.map(function(e){var i=new THREE.Vector3(e.x,e.y,e.z);return i.atomid=e.atomid,i}),o.faces=d.map(function(e){return new THREE.Face3(e.a,e.b,e.c)}),c=null,l=null,d=null,o.computeFaceNormals,o.computeVertexNormals(!1),o.colorsNeedUpdate=!0,o.faces.forEach(function(e){e.vertexColors=["a","b","c"].map(function(i){var t=o.vertices[e[i]].atomid;return h.atoms[t].color})});var u=new THREE.Mesh(o,new THREE.MeshLambertMaterial({overdraw:h.overdraw,vertexColors:THREE.VertexColors,wireframe:t,opacity:n,transparent:!0}));h.mdl.add(u),this.prevSurfaces.push(u),o=null},drawNucleicAcidStick:function(e,i){var t,n,o,s=null,r=null;for(o in e){var a=e[o];void 0===a||a.het||((a.resi!==n||a.chain!==t)&&(null!==s&&null!==r&&this.createCylinder(new THREE.Vector3(s.coord.x,s.coord.y,s.coord.z),new THREE.Vector3(r.coord.x,r.coord.y,r.coord.z),.3,s.color,i),s=null,r=null),("O3'"===a.name||"O3*"===a.name)&&(s=a)," A"===a.resn||"  G"===a.resn||" DA"===a.resn||" DG"===a.resn?"N1"===a.name&&(r=a):"N3"===a.name&&(r=a),n=a.resi,t=a.chain)}null!==s&&null!==r&&this.createCylinder(new THREE.Vector3(s.coord.x,s.coord.y,s.coord.z),new THREE.Vector3(r.coord.x,r.coord.y,r.coord.z),.3,s.color,i)},drawCartoonNucleicAcid:function(e,i,t,n){this.drawStrandNucleicAcid(e,2,i,!0,void 0,t,n)},drawStrandNucleicAcid:function(e,i,t,n,o,s,r){2===r&&(i=void 0,s=void 0),o=o||this.nucleicAcidWidth,t=t||this.axisDIV,i=i||this.nucleicAcidStrandDIV;var a,c,l,d=[];for(l=0;i>l;l++)d[l]=[];var h,u,p,m=[],g=null;for(a in e){var f=e[a];if(void 0!==f&&("O3'"===f.name||"OP2"===f.name||"O3*"===f.name||"O2P"===f.name)&&!f.het)if("O3'"===f.name||"O3*"===f.name){if(h!==f.chain||u+1!==f.resi){if(p&&g)for(c=0;i>c;c++){var v=-1+2/(i-1)*c;d[c].push(new THREE.Vector3(p.x+g.x*v,p.y+g.y*v,p.z+g.z*v))}for(n&&this.createStrip(d[0],d[1],m,t,s,r),c=0;!s&&i>c;c++)this.createCurveSub(d[c],1,m,t,r);var d=[];for(l=0;i>l;l++)d[l]=[];m=[],g=null}p=new THREE.Vector3(f.coord.x,f.coord.y,f.coord.z),h=f.chain,u=f.resi,1===r||2===r?m.push(this.highlightColor):m.push(f.color)}else if("OP2"===f.name||"O2P"===f.name){if(!p){g=null;continue}var b=new THREE.Vector3(f.coord.x,f.coord.y,f.coord.z);for(b.sub(p),b.normalize.multiplyScalar(o),null!==g&&b.dot(g)<0&&b.negate,g=b,c=0;i>c;c++){var v=-1+2/(i-1)*c;d[c].push(new THREE.Vector3(p.x+g.x*v,p.y+g.y*v,p.z+g.z*v))}p=null}}if(p&&g)for(c=0;i>c;c++){var v=-1+2/(i-1)*c;d[c].push(new THREE.Vector3(p.x+g.x*v,p.y+g.y*v,p.z+g.z*v))}for(n&&this.createStrip(d[0],d[1],m,t,s,r),c=0;!s&&i>c;c++)this.createCurveSub(d[c],1,m,t,r)},drawSymmetryMates2:function{if(void 0!==this.biomtMatrices){for(var e=1,i=this.center.clone,t=0;t<this.biomtMatrices.length;t++){var n=this.biomtMatrices[t];if(void 0!==n){for(var o=n.toArray,s=1,r=0,a=o.length;a>r;++r)0==r||5==r||10==r?1e3!=parseInt(1e3*o[r])&&(s=0):0!=r&&5!=r&&10!=r&&15!=r&&0!=parseInt(1e3*o[r])&&(s=0);if(!s){var c=this.mdl.clone;c.applyMatrix(n);var l=this.center.clone;l.applyMatrix4(n),i.add(l),this.mdl.add(c),++e}}}this.maxD*=Math.sqrt(e),this.mdl.position.add(this.center).sub(i.multiplyScalar(1/e)),this.setCamera}},makeTextSprite:function(e,i){void 0===i&&(i={});var t=i.hasOwnProperty("fontface")?i.fontface:"Arial",n=i.hasOwnProperty("fontsize")?i.fontsize:18,o=i.hasOwnProperty("alpha")?i.alpha:1,s=!0,r=!1;i.hasOwnProperty("bSchematic")&&i.bSchematic&&(r=!0,n=40);var a,c,l;i.hasOwnProperty("backgroundColor")&&void 0!==i.backgroundColor?(a=this.hexToRgb(i.backgroundColor,o),c=i.hasOwnProperty("borderColor")?this.hexToRgb(i.borderColor,o):{r:0,g:0,b:0,a:1},l=i.hasOwnProperty("borderThickness")?i.borderThickness:4):(s=!1,a=void 0,c=void 0,l=0);var d=1,h=i.hasOwnProperty("textColor")&&void 0!==i.textColor?this.hexToRgb(i.textColor,d):{r:255,g:255,b:0,a:1},u=document.createElement("canvas"),p=u.getContext("2d");p.font="Bold "+n+"px "+t;var m=p.measureText(e),g=m.width,f=g+2*l,v=n+2*l;r&&(f>v?v=f:f=v);var b=6,y=15*this.maxD/100;(r||e.length<=b)&&(u.width=f,u.height=v,y=3*this.maxD/100),p.clearRect(0,0,f,v);p.measureText("M").width;if(s)if(p.fillStyle="rgba("+a.r+","+a.g+","+a.b+","+a.a+")",p.strokeStyle="rgba("+c.r+","+c.g+","+c.b+","+c.a+")",p.lineWidth=l,r){var E=.35*f;this.circle(p,0,0,f,v,E)}else{var E=e.length<=b?.5*v:0;this.roundRect(p,0,0,f,v,E)}p.font="Bold "+n+"px "+t,p.textAlign="center",p.textBaseline="middle",p.fillStyle="rgba("+h.r+", "+h.g+", "+h.b+", 1.0)",p.strokeStyle="rgba("+h.r+", "+h.g+", "+h.b+", 1.0)",p.fillText(e,.5*f,.5*v);var _=new THREE.Texture(u);_.needsUpdate=!0;var w=!0,C=new THREE.SpriteMaterial({map:_,useScreenCoordinates:!1,depthTest:!w,depthWrite:!w}),S=new THREE.Sprite(C),k=1.5;return r?S.scale.set(y,y,1):S.scale.set(k*y,y,1),S},hexToRgb:function(e,i){var t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16),a:i}:null},roundRect:function(e,i,t,n,o,s){e.beginPath,e.moveTo(i+s,t),e.lineTo(i+n-s,t),e.quadraticCurveTo(i+n,t,i+n,t+s),e.lineTo(i+n,t+o-s),e.quadraticCurveTo(i+n,t+o,i+n-s,t+o),e.lineTo(i+s,t+o),e.quadraticCurveTo(i,t+o,i,t+o-s),e.lineTo(i,t+s),e.quadraticCurveTo(i,t,i+s,t),e.closePath,e.fill,e.stroke},circle:function(e,i,t,n,o,s){e.beginPath,e.arc(i+n/2,t+o/2,s,0,2*Math.PI,!0),e.closePath,e.fill,e.stroke},createLabelRepresentation:function(e){for(var i in e)for(var t=e[i],n=0,o=t.length;o>n;++n){var s=t[n],r=void 0!==s.size?s.size:this.LABELSIZE,a=void 0!==s.color?s.color:"#ffff00",c=void 0!==s.background?s.background:"#cccccc",l=void 0!==s.alpha?s.alpha:1;c=s.background,void 0!==a&&void 0!==c&&a.toLowerCase===c.toLowerCase&&(a="#888888");var d;if(void 0!==s.bSchematic&&s.bSchematic){var h=!1;if(Object.keys(this.proteins).length+Object.keys(this.nucleotides).length>0){var u=this.getFirstAtomObj(this.highlightAtoms);this.ligands.hasOwnProperty(u.serial)&&(h=!0)}var p=this.maxD;h&&(this.maxD=50,this.setCamera),d=this.makeTextSprite(s.text,{fontsize:parseInt(r),textColor:a,borderColor:c,backgroundColor:c,alpha:l,bSchematic:1}),h&&(this.maxD=p,this.setCamera)}else d=this.makeTextSprite(s.text,{fontsize:parseInt(r),textColor:a,borderColor:c,backgroundColor:c,alpha:l,bSchematic:0});d.position.set(s.position.x,s.position.y,s.position.z),this.mdl.add(d)}},getAtomsWithinAtom:function(e,i,t){var n=this.getExtent(i),o=(n[2][0]-n[0][0])*(n[2][0]-n[0][0])+(n[2][1]-n[0][1])*(n[2][1]-n[0][1])+(n[2][2]-n[0][2])*(n[2][2]-n[0][2]),s=(n[2][0]-n[1][0])*(n[2][0]-n[1][0])+(n[2][1]-n[1][1])*(n[2][1]-n[1][1])+(n[2][2]-n[1][2])*(n[2][2]-n[1][2]),r=o>s?o:s,a=Math.sqrt(r),c=(a+t)*(a+t),l={};for(var d in e){var h=e[d];if(!(h.serial in i||h.coord.x<n[0][0]-t||h.coord.x>n[1][0]+t||h.coord.y<n[0][1]-t||h.coord.y>n[1][1]+t||h.coord.z<n[0][2]-t||h.coord.z>n[1][2]+t)){var u=(h.coord.x-n[2][0])*(h.coord.x-n[2][0])+(h.coord.y-n[2][1])*(h.coord.y-n[2][1])+(h.coord.z-n[2][2])*(h.coord.z-n[2][2]);c>u&&(l[h.serial]=h)}}var p={};for(var d in i){var m=i[d],g=this.vdwRadii[m.elem]||this.defaultRadius;for(var f in l){var h=l[f],u=(h.coord.x-m.coord.x)*(h.coord.x-m.coord.x)+(h.coord.y-m.coord.y)*(h.coord.y-m.coord.y)+(h.coord.z-m.coord.z)*(h.coord.z-m.coord.z);c=(g+t)*(g+t),c>u&&(p[h.serial]=h)}}return p},getExtent:function(e){var i,t=ymin=zmin=9999,n=ymax=zmax=-9999,o=ysum=zsum=cnt=0;for(i in e){var s=e[i];cnt++,o+=s.coord.x,ysum+=s.coord.y,zsum+=s.coord.z,t=t<s.coord.x?t:s.coord.x,ymin=ymin<s.coord.y?ymin:s.coord.y,zmin=zmin<s.coord.z?zmin:s.coord.z,n=n>s.coord.x?n:s.coord.x,ymax=ymax>s.coord.y?ymax:s.coord.y,zmax=zmax>s.coord.z?zmax:s.coord.z}returnt,ymin,zmin],[n,ymax,zmax],[o/cnt,ysum/cnt,zsum/cnt},getAtomsFromPosition:function(e,i){var t,n;(void 0===i||null===i)&&(i=1);for(t in this.atoms){var n=this.atoms[t];if(!(n.coord.x<e.x-i||n.coord.x>e.x+i||n.coord.y<e.y-i||n.coord.y>e.y+i||n.coord.z<e.z-i||n.coord.z>e.z+i))return n}return null},buildAxes:function(e){var i=new THREE.Object3D;i.add(this.createSingleLine(new THREE.Vector3(0,0,0),new THREE.Vector3(0+e,0,0),16711680,!1,.5)),i.add(this.createSingleLine(new THREE.Vector3(0,0,0),new THREE.Vector3(0-e,0,0),8388608,!0,.5)),i.add(this.createSingleLine(new THREE.Vector3(0,0,0),new THREE.Vector3(0,0+e,0),65280,!1,.5)),i.add(this.createSingleLine(new THREE.Vector3(0,0,0),new THREE.Vector3(0,0-e,0),32768,!0,.5)),i.add(this.createSingleLine(new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,0+e),255,!1,.5)),i.add(this.createSingleLine(new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,0-e),128,!0,.5)),this.scene.add(i)},createSingleLine:function(e,i,t,n,o){var s,r=new THREE.Geometry;s=n?new THREE.LineDashedMaterial({linewidth:1,color:t,dashSize:o,gapSize:o}):new THREE.LineBasicMaterial({linewidth:1,color:t}),r.vertices.push(e),r.vertices.push(i),n&&r.computeLineDistances;var a=new THREE.Line(r,s,THREE.LinePieces);return a},intersectHash:function(e,i){var t={};if(Object.keys(e).length<Object.keys(i).length)for(var n in e)void 0!==i&&i[n]&&(t[n]=e[n]);else for(var n in i)void 0!==e&&e[n]&&(t[n]=i[n]);return e={},i={},t},excludeHash:function(e,i){var t={};for(var n in e)n in i||(t[n]=e[n]);return e={},i={},t},unionHash:function(e,i){var t=jQuery.extend({},e,i);return e={},i={},t},intersectHash2Atoms:function(e,i){return this.hash2Atoms(this.intersectHash(e,i))},excludeHash2Atoms:function(e,i){return this.hash2Atoms(this.excludeHash(e,i))},unionHash2Atoms:function(e,i){return this.hash2Atoms(this.unionHash(e,i))},hash2Atoms:function(e){var i={};for(var t in e)i[t]=this.atoms[t];return e={},i},centerAtoms:function(e){var i=new THREE.Vector3(9999,9999,9999),t=new THREE.Vector3(-9999,-9999,-9999),n=new THREE.Vector3,o=0;for(var s in e){var r=this.atoms[s],a=r.coord;n.add(a),i.min(a),t.max(a),++o}var c=t.distanceTo(i);return{center:n.multiplyScalar(1/o),maxD:c}},exportCanvas:function{this.render,window.open(this.renderer.domElement.toDataURL("image/png"))},applyPrevColor:function{for(var e in this.atoms){var i=this.atoms[e];i.color=this.atomPrevColors[e]}},applyOriginalColor:function{for(var e in this.atoms){var i=this.atoms[e],t=i.structure+"_"+i.chain;this.chainsColor.hasOwnProperty(t)?i.color=this.chainsColor[t]:i.color=this.atomColors[i.elem]}},setColorByOptions:function(e,i,t){if(void 0!==e)if(void 0!==t&&t)for(var n in i){var o=this.atoms[n];this.atomPrevColors[n]=o.color}else if(0===e.color.indexOf("#"))for(var n in i){var o=this.atoms[n];o.color=(new THREE.Color).setStyle(e.color.toLowerCase),this.atomPrevColors[n]=o.color}else switch(e.color.toLowerCase){case"spectrum":var s=0,r=1/this.cnt;for(var n in i){var o=this.atoms[n];o.color=o.het?this.atomColors[o.elem]||this.defaultAtomColor:(new THREE.Color).setHSL(2/3*(1-s++*r),1,.45),this.atomPrevColors[n]=o.color}break;case"chain":var a=-1,c="",l=this.stdChainColors.length;for(var n in i){var o=this.atoms[n];o.chain!=c&&(++a,a%=l),o.color=this.stdChainColors[a],Object.keys(this.chainsColor).length>0&&this.updateChainsColor(o),this.atomPrevColors[n]=o.color,c=o.chain}break;case"secondary structure":for(var n in i){var o=this.atoms[n];o.color=o.het?this.atomColors[o.elem]||this.defaultAtomColor:this.ssColors[o.ss],this.atomPrevColors[n]=o.color}break;case"residue":for(var n in i){var o=this.atoms[n];o.color=o.het?this.atomColors[o.elem]||this.defaultAtomColor:this.residueColors[o.resn]||this.defaultResidueColor,this.atomPrevColors[n]=o.color}break;case"charge":for(var n in i){var o=this.atoms[n];o.color=o.het?this.defaultAtomColor:this.chargeColors[o.resn]||this.defaultResidueColor,this.atomPrevColors[n]=o.color}break;case"hydrophobic":for(var n in i){var o=this.atoms[n];o.color=o.het?this.defaultAtomColor:this.hydrophobicColors[o.resn]||this.defaultResidueColor,this.atomPrevColors[n]=o.color}break;case"atom":for(var n in i){var o=this.atoms[n];o.color=this.atomColors[o.elem]||this.defaultAtomColor,this.atomPrevColors[n]=o.color}break;case"conserved":for(var n in i){var o=this.atoms[n];o.color=this.defaultAtomColor,this.atomPrevColors[n]=o.color}for(var d in this.alignChainsSeq)for(var h=this.alignChainsSeq[d],n=0,u=h.length;u>n;++n){var p=d+"_"+h[n].resi;for(var m in this.residues[p])if(i.hasOwnProperty(m)){var g=new THREE.Color(h[n].color);this.atoms[m].color=g,this.atomPrevColors[m]=g}}break;case"white":for(var n in i){var o=this.atoms[n];o.color=(new THREE.Color).setHex(16777215),this.atomPrevColors[n]=o.color}break;case"grey":for(var n in i){var o=this.atoms[n];o.color=(new THREE.Color).setHex(8947848),this.atomPrevColors[n]=o.color}break;case"red":for(var n in i){var o=this.atoms[n];o.color=(new THREE.Color).setHex(16711680),this.atomPrevColors[n]=o.color}break;case"green":for(var n in i){var o=this.atoms[n];o.color=(new THREE.Color).setHex(65280),this.atomPrevColors[n]=o.color}break;case"blue":for(var n in i){var o=this.atoms[n];o.color=(new THREE.Color).setHex(255),this.atomPrevColors[n]=o.color}break;case"magenta":for(var n in i){var o=this.atoms[n];o.color=(new THREE.Color).setHex(16711935),this.atomPrevColors[n]=o.color}break;case"yellow":for(var n in i){var o=this.atoms[n];o.color=(new THREE.Color).setHex(16776960),this.atomPrevColors[n]=o.color}break;case"cyan":for(var n in i){var o=this.atoms[n];o.color=(new THREE.Color).setHex(65535),this.atomPrevColors[n]=o.color}break;case"custom":}},updateChainsColor:function(e){var i=e.structure+"_"+e.chain;void 0!==this.chainsColor[i]&&(this.chainsColor[i]=e.color)},drawHelixBrick:function(e,i,t){for(var n in e)for(var o=0,s=e[n].length;s>o;++o)if("helix"===e[n][o].type){var r=1.6,a=new THREE.Color(i[n]),c=new THREE.Vector3(e[n][o].coords[0].x,e[n][o].coords[0].y,e[n][o].coords[0].z),l=new THREE.Vector3(e[n][o].coords[1].x,e[n][o].coords[1].y,e[n][o].coords[1].z);this.createCylinder(c,l,r,a,t)}else if("brick"===e[n][o].type){var d=e[n][o],a=i[n];this.createStrandBrick(d,a,this.thickness,t)}else if("coil"===e[n][o].type){var c=new THREE.Vector3(e[n][o].coords[0].x,e[n][o].coords[0].y,e[n][o].coords[0].z),l=new THREE.Vector3(e[n][o].coords[1].x,e[n][o].coords[1].y,e[n][o].coords[1].z),a=new THREE.Color(i[n]),h=this.createSingleLine(c,l,a,!1);this.mdl.add(h),this.objects.push(h)}},applyOtherOptions:function(e){if(void 0===e&&(e=this.options),this.createLabelRepresentation(this.labels),"yes"===e.hbonds.toLowerCase){var i="#FFFFFF";"black"!==e.background.toLowerCase&&(i="#000000");for(var t=0,n=Math.floor(this.hbondpoints.length/2);n>t;t++){var o=(this.hbondpoints[2*t],this.hbondpoints[2*t+1],{});o.position1=this.hbondpoints[2*t],o.position2=this.hbondpoints[2*t+1],o.color=i,o.dashed=!0,void 0===this.lines.hbond&&(this.lines.hbond=[]),this.lines.hbond.push(o)}this.createLines(this.lines)}else this.createLines(this.lines);for(var t=0,s=this.prevSurfaces.length;s>t;++t)this.mdl.add(this.prevSurfaces[t]);switch(e.rotationcenter.toLowerCase){case"molecule center":void 0!==this.center&&this.mdl.position.sub(this.center);break;case"pick center":void 0!==this.pickedatom&&this.mdl.position.sub(this.pickedatom.coord);break;case"display center":var r=this.centerAtoms(this.displayAtoms).center;this.mdl.position.sub(r);break;case"highlight center":var r=this.centerAtoms(this.highlightAtoms).center;this.mdl.position.sub(r)}switch(e.axis.toLowerCase){case"yes":this.axis=!0,this.buildAxes(this.maxD/2);break;case"no":this.axis=!1}switch(e.picking.toLowerCase){case"atom":this.picking=1;break;case"no":this.picking=0;break;case"residue":this.picking=2;break;case"strand":this.picking=3}},applySurfaceOptions:function(e){switch(void 0===e&&(e=this.options),e.wireframe){case"yes":e.wireframe=!0;break;case"no":e.wireframe=!1}e.opacity=parseFloat(e.opacity);var i={};switch(i=this.hash2Atoms(this.highlightAtoms),e.surface.toLowerCase){case"van der waals surface":this.createSurfaceRepresentation(i,1,e.wireframe,e.opacity);break;case"solvent accessible surface":this.createSurfaceRepresentation(i,3,e.wireframe,e.opacity);break;case"molecular surface":this.createSurfaceRepresentation(i,2,e.wireframe,e.opacity);break;case"nothing":this.removeSurfaces}},applyDisplayOptions:function(e,i,t){void 0===e&&(e=this.options);var n,o={},s={},r={};if(1===t&&Object.keys(i).length<Object.keys(this.atoms).length){r=this.hash2Atoms(i);for(var a in r){var c=r[a];n=c.structure+"_"+c.chain+"_"+c.resi,o[n]=1}for(var a in o){var l=a.lastIndexOf("_"),d=a.substr(0,l+1),h=parseInt(a.substr(l+1)),u=d+(h-1).toString,p=d+(h+1).toString;o.hasOwnProperty(u)||o.hasOwnProperty(u)||(s[a]=1)}if(1===Object.keys(r).length&&Object.keys(this.residues[n]).length>1&&"sphere"!==r[Object.keys(r)[0]].style&&"dot"!==r[Object.keys(r)[0]].style){if(void 0===this.bCid||!this.bCid)for(var a in r){var c=r[a],m=1;this.createBox(c,void 0,void 0,m,void 0,t)}}else for(var n in s){var c=this.getFirstAtomObj(this.residues[n]),u=c.structure+"_"+c.chain+"_"+parseInt(c.resi-1),p=c.structure+"_"+c.chain+"_"+parseInt(c.resi+1);if("cylinder and plate"===c.style&&"helix"===c.ss)for(var a in this.residues[n]){var c=this.atoms[a],m=1;this.createBox(c,void 0,void 0,m,void 0,t)}else if("ribbon"===c.style&&"coil"===c.ss||"strand"===c.style&&"coil"===c.ss||"phosphorus trace"===c.style||"schematic"===c.style||"c alpha trace"===c.style||"b factor tube"===c.style||"cylinder and plate"===c.style&&"helix"!==c.ss){var g=!1;if(!g&&this.residues.hasOwnProperty(p)){var f=Object.keys(this.residues[p])[0],v=this.hash2Atoms(this.residues[p])[f];if(c.style===v.style&&!v.ssbegin||v.ssbegin){var b=this.residues[p];if(i=this.unionHash(i,b),g=!0,v.ssbegin)for(var a in b)this.atoms[a].notshow=!0}}if(!g&&this.residues.hasOwnProperty(u)){var f=Object.keys(this.residues[u])[0],v=this.hash2Atoms(this.residues[u])[f];c.style===v.style&&(i=this.unionHash(i,this.residues[u]),g=!0)}}else if("ribbon"===c.style&&"coil"!==c.ss&&c.ssend||"strand"===c.style&&"coil"!==c.ss&&c.ssend){var g=!1;if(!g&&this.residues.hasOwnProperty(p)){var f=Object.keys(this.residues[p])[0],v=this.hash2Atoms(this.residues[p])[f];i=this.unionHash(i,this.residues[p]),g=!0}}}r={}}this.setStyle2Atoms(i),this.bAllAtoms=Object.keys(i).length===Object.keys(this.atoms).length;var y={};"nothing"!==this.options.sidechains&&(y=this.intersectHash(i,this.calphas)), this.labels.schematic=[];var E=.5*this.cylinderRadius;for(var _ in this.style2atoms)if(atomHash=this.style2atoms[_],"ribbon"===_)this.createStrand(this.hash2Atoms(atomHash),2,void 0,!0,void 0,void 0,!1,this.thickness,t);else if("strand"===_)this.createStrand(this.hash2Atoms(atomHash),null,null,null,null,null,!1,void 0,t);else if("cylinder and plate"===_)this.createCylinderHelix(this.hash2Atoms(atomHash),1.6,t);else if("nucleotide cartoon"===_)this.drawCartoonNucleicAcid(this.hash2Atoms(atomHash),null,this.thickness,t),2!==t&&this.drawNucleicAcidStick(this.hash2Atoms(atomHash),t);else if("phosphorus trace"===_)this.createCylinderCurve(this.hash2Atoms(atomHash),"P",.2,!1,t);else if("phosphorus lines"===_)this.createCylinderCurve(this.hash2Atoms(atomHash),"P",.2,!0,t);else if("schematic"===_){var w=this.getFirstAtomObj(atomHash);this.ligands.hasOwnProperty(w.serial)?(this.addNonCarbonAtomLabels(this.hash2Atoms(atomHash)),bSchematic=!0,this.createStickRepresentation(this.hash2Atoms(atomHash),E,E,void 0,t,bSchematic)):(this.addResiudeLabels(this.hash2Atoms(atomHash),!0),this.createCylinderCurve(this.hash2Atoms(atomHash),"P",.2,!1,t),this.createCylinderCurve(this.hash2Atoms(atomHash),"CA",.2,!1,t))}else"c alpha trace"===_?this.createCylinderCurve(this.hash2Atoms(atomHash),"CA",.2,!1,t):"b factor tube"===_?this.createTube(this.hash2Atoms(atomHash),"CA",null,t):"lines"===_?("lines"===this.options.sidechains&&(atomHash=this.unionHash(atomHash,y)),1===t?this.createStickRepresentation(this.hash2Atoms(atomHash),.1,.1,void 0,t):this.createLineRepresentation(this.hash2Atoms(atomHash),t)):"stick"===_?("stick"===this.options.sidechains&&(atomHash=this.unionHash(atomHash,y)),this.createStickRepresentation(this.hash2Atoms(atomHash),this.cylinderRadius,this.cylinderRadius,void 0,t)):"ball and stick"===_?("ball and stick"===this.options.sidechains&&(atomHash=this.unionHash(atomHash,y)),this.createStickRepresentation(this.hash2Atoms(atomHash),this.cylinderRadius,.5*this.cylinderRadius,.3,t)):"sphere"===_?this.createSphereRepresentation(this.hash2Atoms(atomHash),this.sphereRadius,void 0,void 0,t):"dot"===_&&this.createSphereRepresentation(this.hash2Atoms(atomHash),this.sphereRadius,!1,.3,t)},setStyle2Atoms:function(e){this.style2atoms={};for(var i in e)void 0===this.style2atoms[this.atoms[i].style]&&(this.style2atoms[this.atoms[i].style]={}),this.style2atoms[this.atoms[i].style][i]=1},setAtomStyleByOptions:function(e){void 0===e&&(e=this.options);var i;if(void 0!==e.proteins){i=this.intersectHash(this.highlightAtoms,this.proteins);for(var t in i)this.atoms[t].style=e.proteins.toLowerCase}if(void 0!==e.sidechains){i=this.intersectHash(this.highlightAtoms,this.sidechains);for(var t in i)this.atoms[t].style=e.sidechains.toLowerCase}if(void 0!==e.ligands){i=this.intersectHash(this.highlightAtoms,this.ligands);for(var t in i)this.atoms[t].style=e.ligands.toLowerCase}if(void 0!==e.ions){i=this.intersectHash(this.highlightAtoms,this.ions);for(var t in i)this.atoms[t].style=e.ions.toLowerCase}if(void 0!==e.water){i=this.intersectHash(this.highlightAtoms,this.water);for(var t in i)this.atoms[t].style=e.water.toLowerCase}if(void 0!==e.nucleotides){i=this.intersectHash(this.highlightAtoms,this.nucleotides);for(var t in i)this.atoms[t].style=e.nucleotides.toLowerCase}},rebuildScene:function(e){var i=this;if(jQuery.extend(i.options,e),this.camera_z=2*-this.maxD,void 0!==this.scene)for(var t=this.scene.children.length-1;t>=0;t--){var n=this.scene.children[t];this.scene.remove(n)}else this.scene=new THREE.Scene;this.directionalLight=new THREE.DirectionalLight(16777215,1.2),this.camera_z>0?this.directionalLight.position.set(0,0,1):this.directionalLight.position.set(0,0,-1);var o=new THREE.AmbientLight(2105376);this.scene.add(this.directionalLight),this.scene.add(o),this.mdl=new THREE.Object3D,this.scene.add(this.mdl),this.objects=[],this.raycaster=new THREE.Raycaster,this.projector=new THREE.Projector,this.mouse=new THREE.Vector2;var s=this.backgroundColors[this.options.background.toLowerCase];this.renderer.setClearColor(s),"yes"===this.options.fog?"perspective"===this.options.camera?this.scene.fog=new THREE.Fog(s,2*this.maxD,2.4*this.maxD):"orthographic"===this.options.camera&&(this.scene.fog=new THREE.FogExp2(s,2),this.scene.fog.near=2*this.maxD,this.scene.fog.far=2.4*this.maxD):this.scene.fog=void 0,this.perspectiveCamera=new THREE.PerspectiveCamera(20,this.container.whratio,.1,1e4),this.perspectiveCamera.position.set(0,0,this.camera_z),this.perspectiveCamera.lookAt(new THREE.Vector3(0,0,0)),this.orthographicCamera=new THREE.OrthographicCamera,this.orthographicCamera.position.set(0,0,this.camera_z),this.orthographicCamera.lookAt(new THREE.Vector3(0,0,0)),this.cameras={perspective:this.perspectiveCamera,orthographic:this.orthographicCamera},this.setCamera,this.applyDisplayOptions(this.options,this.displayAtoms),this.applyOtherOptions},setCamera:function{this.camera=this.cameras[this.options.camera.toLowerCase],this.camera===this.perspectiveCamera?(this.camera_z>0?this.camera.position.z=2*this.maxD:this.camera.position.z=2*-this.maxD,"yes"===this.options.slab?this.camera.near=2*this.maxD:this.camera.near=.1,this.camera.far=1e4,this.controls=new THREE.TrackballControls(this.camera,document.getElementById(this.id),this)):this.camera===this.orthographicCamera&&(this.camera.right=this.maxD/2*2.5,this.camera.left=-this.camera.right,this.camera.top=this.camera.right/this.container.whratio,this.camera.bottom=-this.camera.right/this.container.whratio,this.camera_z>0?("yes"===this.options.slab?this.camera.near=2*-this.maxD:this.camera.near=0,this.camera.far=-1e4):("yes"===this.options.slab?this.camera.near=2*this.maxD:this.camera.near=0,this.camera.far=1e4),this.controls=new THREE.OrthographicTrackballControls(this.camera,document.getElementById(this.id),this)),this.camera.updateProjectionMatrix},applyTransformation:function(e,i,t){var n={};n.update=!1,n._zoomFactor=e,n.mouseChange=new THREE.Vector2,n.mouseChange.copy(i),n.quaternion=new THREE.Quaternion,n.quaternion.copy(t),this.controls.update(n)},render:function{this.directionalLight.position.copy(this.camera.position),this.renderer.gammaInput=!0,this.renderer.gammaOutput=!0,this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.render(this.scene,this.camera)},setRotationCenter:function(e){this.mdl.position.sub(e)},draw:function(e,i){this.rebuildScene(e),(void 0===i||i)&&this.applyPrevColor,this.bSSOnly&&this.drawHelixBrick(this.molid2ss,this.molid2color),this.bAssembly&&this.drawSymmetryMates2,void 0!==this.highlightAtoms&&Object.keys(this.highlightAtoms).length>0&&Object.keys(this.highlightAtoms).length<Object.keys(this.atoms).length&&(this.removeHighlightObjects,(void 0===this.bShowHighlight||this.bShowHighlight)&&this.addHighlightObjects),this.bRender===!0&&(this.applyTransformation(this._zoomFactor,this.mouseChange,this.quaternion),this.render)},zoomIn:function(e){var i={};i._zoomFactor=1-e,i.update=!0,this.controls.update(i),this.render},zoomOut:function(e){var i={};i._zoomFactor=1+e,i.update=!0,this.controls.update(i),this.render},rotateLeft:function(e){var i=new THREE.Vector3(0,1,0),t=-e/180*Math.PI;i.applyQuaternion(this.camera.quaternion).normalize;var n=new THREE.Quaternion;n.setFromAxisAngle(i,-t);var o={};o.quaternion=n,o.update=!0,this.controls.update(o),this.render},rotateRight:function(e){var i=new THREE.Vector3(0,1,0),t=e/180*Math.PI;i.applyQuaternion(this.camera.quaternion).normalize;var n=new THREE.Quaternion;n.setFromAxisAngle(i,-t);var o={};o.quaternion=n,o.update=!0,this.controls.update(o),this.render},rotateUp:function(e){var i=new THREE.Vector3(1,0,0),t=-e/180*Math.PI;i.applyQuaternion(this.camera.quaternion).normalize;var n=new THREE.Quaternion;n.setFromAxisAngle(i,-t);var o={};o.quaternion=n,o.update=!0,this.controls.update(o),this.render},rotateDown:function(e){var i=new THREE.Vector3(1,0,0),t=e/180*Math.PI;i.applyQuaternion(this.camera.quaternion).normalize;var n=new THREE.Quaternion;n.setFromAxisAngle(i,-t);var o={};o.quaternion=n,o.update=!0,this.controls.update(o),this.render},translateLeft:function(e){var i=new THREE.Vector2(0,0);i.x-=e/100;var t={};t.mouseChange=i,t.update=!0,this.controls.update(t),this.render},translateRight:function(e){var i=new THREE.Vector2(0,0);i.x+=e/100;var t={};t.mouseChange=i,t.update=!0,this.controls.update(t),this.render},translateUp:function(e){var i=new THREE.Vector2(0,0);i.y-=e/100;var t={};t.mouseChange=i,t.update=!0,this.controls.update(t),this.render},translateDown:function(e){var i=new THREE.Vector2(0,0);i.y+=e/100;var t={};t.mouseChange=i,t.update=!0,this.controls.update(t),this.render},selectStrandHelixFromAtom:function(e){for(var i=e,t=e,n={},o=i.resi,s=i.resi-1;s>0;--s){var r=i.structure+"_"+i.chain+"_"+s;if(!this.residues.hasOwnProperty(r))break;var e=this.getFirstAtomObj(this.residues[r]);if(o=e.resi,"coil"!==i.ss&&e.ss===i.ss&&e.ssbegin||"coil"===i.ss&&e.ss!==i.ss){"coil"===i.ss&&e.ss!==i.ss&&(o=e.resi+1);break}}for(var s=o;s<=i.resi;++s){var r=i.structure+"_"+i.chain+"_"+s;n=this.unionHash(n,this.hash2Atoms(this.residues[r]))}for(var a=t.resi,c=this.getLastAtomObj(this.chains[t.structure+"_"+t.chain]).resi,s=t.resi+1;c>=s;++s){var r=t.structure+"_"+t.chain+"_"+s;if(!this.residues.hasOwnProperty(r))break;var e=this.getFirstAtomObj(this.residues[r]);if(a=e.resi,"coil"!==t.ss&&e.ss===t.ss&&e.ssend||"coil"===t.ss&&e.ss!==t.ss){"coil"===t.ss&&e.ss!==t.ss&&(a=e.resi-1);break}}for(var s=t.resi+1;a>=s;++s){var r=t.structure+"_"+t.chain+"_"+s;n=this.unionHash(n,this.hash2Atoms(this.residues[r]))}return n},showPickingBase:function(e){if(this.bShiftKey||this.bCtrlKey||this.removeHighlightObjects,this.pickedAtomList={},1===this.picking)this.pickedAtomList[e.serial]=1;else if(2===this.picking){var i=e.structure+"_"+e.chain+"_"+e.resi;this.pickedAtomList=this.residues[i]}else 3===this.picking&&(this.pickedAtomList=this.selectStrandHelixFromAtom(e));if(0===this.picking?this.bShowHighlight=!1:this.bShowHighlight=!0,this.bShiftKey||this.bCtrlKey){if(this.bShiftKey){var t=this.getFirstAtomObj(this.highlightAtoms).serial,n=this.getLastAtomObj(this.highlightAtoms).serial,o=this.getFirstAtomObj(this.pickedAtomList).serial,s=this.getLastAtomObj(this.pickedAtomList).serial,r=o>n?n:s,a=o>n?s+1:t,c="";if(o>n)for(var l=r+1;a>l;++l){var d=this.atoms[l].structure+"_"+this.atoms[l].chain;if(l!==r+1&&d!==c)break;this.highlightAtoms[l]=1,c=d}else for(var l=a-1;l>r;--l){var d=this.atoms[l].structure+"_"+this.atoms[l].chain;if(l!==a-1&&d!==c)break;this.highlightAtoms[l]=1,c=d}}this.bCtrlKey&&(this.highlightAtoms=this.unionHash(this.highlightAtoms,this.pickedAtomList))}else this.highlightAtoms=this.cloneHash(this.pickedAtomList);this.addHighlightObjects},showPicking:function(e){this.showPickingBase(e);var i="."+e.chain+":"+e.resi,t=i+"@"+e.name,n=[],o={};o.position=e.coord,1===this.picking?o.text=t:2===this.picking?o.text=i:3===this.picking&&(o.text=i),n.push(o),this.createLabelRepresentation(n)},removeHighlightObjects:function{for(var e in this.prevHighlightObjects)this.mdl.remove(this.prevHighlightObjects[e]);this.prevHighlightObjects=[]},addHighlightObjects:function(e,i,t){void 0===e&&(e=this.highlightColor),void 0===t&&(t=this.highlightAtoms),this.applyDisplayOptions(this.options,this.intersectHash(t,this.displayAtoms),this.bHighlight),(void 0===i||i)&&this.render},removeSurfaces:function{for(var e=0,i=this.prevSurfaces.length;i>e;++e)this.mdl.remove(this.prevSurfaces[e]);this.prevSurfaces=[]},removeLastSurface:function{this.prevSurfaces.length>0&&(this.mdl.remove(this.prevSurfaces[this.prevSurfaces.length-1]),this.prevSurfaces.slice(this.prevSurfaces.length-1,1))},zoominSelection:function{if(Object.keys(this.highlightAtoms).length>1){var e=this.centerAtoms(this.hash2Atoms(this.highlightAtoms));this.maxD=e.maxD,this.maxD<25&&(this.maxD=25),this.mdl.position.add(this.center).sub(e.center),this.center=e.center,this.setCamera}this.draw},centerSelection:function{if(Object.keys(this.highlightAtoms).length>1){var e=this.centerAtoms(this.hash2Atoms(this.highlightAtoms));this.mdl.position.add(this.center).sub(e.center),this.center=e.center,this.setCamera}this.draw},resetOrientation:function{if(this.commands.length>0){var e=this.commands[0].split("|||");if(2==e.length){var i=JSON.parse(e[1]);this._zoomFactor=i.factor,this.mouseChange.x=i.mouseChange.x,this.mouseChange.y=i.mouseChange.y,this.quaternion._x=i.quaternion._x,this.quaternion._y=i.quaternion._y,this.quaternion._z=i.quaternion._z,this.quaternion._w=i.quaternion._w,this.maxD=this.oriMaxD,this.center=this.oriCenter.clone,this.draw}}},addNonCarbonAtomLabels:function(e){var i=18,t="#FFFFFF",n=this.intersectHash(this.highlightAtoms,e);void 0===this.labels.schematic&&(this.labels.schematic=[]);for(var o in n){var s=this.atoms[o];if(this.residues.hasOwnProperty(s.structure+"_"+s.chain+"_"+s.resi)&&"C"!==s.elem){var r={};r.position=s.coord,r.bSchematic=1,r.text=s.elem,r.size=i,r.color="#"+s.color.getHexString,r.background=t,this.labels.schematic.push(r)}}this.removeHighlightObjects},addResiudeLabels:function(e,i){var t=18,n="#CCCCCC",o=this.intersectHash(this.highlightAtoms,e);i?void 0===this.labels.schematic&&(this.labels.schematic=[]):void 0===this.labels.residue&&(this.labels.residue=[]);var s="";for(var r in o){var a=this.atoms[r];if(!a.het){var c={},l=a.structure+"_"+a.chain+"_"+a.resi;if("CA"===a.name||"P"===a.name||this.water.hasOwnProperty(a.serial)||this.ions.hasOwnProperty(a.serial)||this.ligands.hasOwnProperty(a.serial)&&l!==s){c.position=a.coord,c.bSchematic=0,i&&(c.bSchematic=1),c.text=this.residueName2Abbr(a.resn),c.size=t;var d=a.color.getHexString.toUpperCase;c.color="CCCCCC"===d||"C8C8C8"===d?"#888888":"#"+d,c.background=n,i?this.labels.schematic.push(c):this.labels.residue.push(c)}s=l}}this.removeHighlightObjects},switchHighlightLevelBase:function{var e=this;$(document).bind("keydown",function(i){if(38===i.keyCode){if(i.preventDefault,e.bShiftKey||e.bCtrlKey||e.removeHighlightObjects,1===e.highlightlevel){e.highlightlevel=2;var t=e.getFirstAtomObj(e.pickedAtomList);e.bShiftKey||e.bCtrlKey?e.highlightAtoms=e.unionHash(e.highlightAtoms,e.residues[t.structure+"_"+t.chain+"_"+t.resi]):e.highlightAtoms=e.cloneHash(e.residues[t.structure+"_"+t.chain+"_"+t.resi])}else if(2===e.highlightlevel){e.highlightlevel=3;var t=e.getFirstAtomObj(e.pickedAtomList);e.bShiftKey||e.bCtrlKey?e.highlightAtoms=e.unionHash(e.highlightAtoms,e.selectStrandHelixFromAtom(t)):e.highlightAtoms=e.cloneHash(e.selectStrandHelixFromAtom(t))}else if(3===e.highlightlevel){e.highlightlevel=4;var t=e.getFirstAtomObj(e.pickedAtomList);e.bShiftKey||e.bCtrlKey?e.highlightAtoms=e.unionHash(e.highlightAtoms,e.chains[t.structure+"_"+t.chain]):e.highlightAtoms=e.cloneHash(e.chains[t.structure+"_"+t.chain])}else if(4===e.highlightlevel||5===e.highlightlevel){e.highlightlevel=5;var t=e.getFirstAtomObj(e.pickedAtomList);e.bShiftKey||e.bCtrlKey||(e.highlightAtoms={});for(var n=e.structures[t.structure],o=0,s=n.length;s>o;++o)e.highlightAtoms=e.unionHash(e.highlightAtoms,e.chains[n[o]])}e.addHighlightObjects}else if(40===i.keyCode){if(i.preventDefault,e.removeHighlightObjects,2!==e.highlightlevel&&1!==e.highlightlevel||1!==Object.keys(e.pickedAtomList).length){if(3===e.highlightlevel){var r={};for(var o in e.pickedAtomList)residueid=e.atoms[o].structure+"_"+e.atoms[o].chain+"_"+e.atoms[o].resi,r[residueid]=1;if(1===Object.keys(r).length){e.highlightlevel=2;var t=e.getFirstAtomObj(e.pickedAtomList);e.bShiftKey||e.bCtrlKey?e.highlightAtoms=e.unionHash(e.highlightAtoms,e.residues[t.structure+"_"+t.chain+"_"+t.resi]):e.highlightAtoms=e.cloneHash(e.residues[t.structure+"_"+t.chain+"_"+t.resi])}}else if(4===e.highlightlevel){e.highlightlevel=3;var t=e.getFirstAtomObj(e.pickedAtomList);e.bShiftKey||e.bCtrlKey?e.highlightAtoms=e.unionHash(e.highlightAtoms,e.selectStrandHelixFromAtom(t)):e.highlightAtoms=e.cloneHash(e.selectStrandHelixFromAtom(t))}else if(5===e.highlightlevel){e.highlightlevel=4;var t=e.getFirstAtomObj(e.pickedAtomList);e.bShiftKey||e.bCtrlKey?e.highlightAtoms=e.unionHash(e.highlightAtoms,e.chains[t.structure+"_"+t.chain]):e.highlightAtoms=e.cloneHash(e.chains[t.structure+"_"+t.chain])}}else e.highlightlevel=1,e.highlightAtoms=e.cloneHash(e.pickedAtomList),e.bShiftKey||e.bCtrlKey?e.highlightAtoms=e.unionHash(e.highlightAtoms,e.pickedAtomList):e.highlightAtoms=e.cloneHash(e.pickedAtomList);e.addHighlightObjects}})},switchHighlightLevel:function{this.switchHighlightLevelBase}},"undefined"==typeof jQuery)throw new Error("iCn3DUI requires jQuery");if("undefined"==typeof iCn3D)throw new Error("iCn3DUI requires iCn3D");$.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)});var iCn3DUI=function(e){var i=this;i.bFullUi=!0,i.cfg=e,i.divid=i.cfg.divid,i.pre=i.divid+"_",i.inputid="",i.WIDTH=400,i.HEIGHT=400,i.RESIDUE_WIDTH=10,i.MENU_HEIGHT=40,i.MENU_WIDTH=750,i.LESSWIDTH=0,i.LESSWIDTH_RESIZE=20,i.LESSHEIGHT=20,i.ROTATION_DIRECTION="right",i.bHideSelection=!0,i.ALTERNATE_STRUCTURE=-1,i.EXTRAHEIGHT=2.8*i.MENU_HEIGHT,void 0!=i.cfg.showmenu&&0==i.cfg.showmenu&&(i.EXTRAHEIGHT=.8*i.MENU_HEIGHT),i.GREY8="#888888",i.GREYB="#BBBBBB",i.GREYC="#CCCCCC",i.GREYD="#DDDDDD",i.bSelectResidue=!1,i.bSelectAlignResidue=!1,i.selectedResidues={},i.bCrashed=!1,i.prevCommands="",i.options={},i.options.camera="perspective",i.options.background="black",i.options.color="spectrum",i.options.sidechains="nothing",i.options.proteins="ribbon",i.options.surface="nothing",i.options.opacity="0.8",i.options.wireframe="no",i.options.ligands="stick",i.options.water="nothing",i.options.ions="sphere",i.options.hbonds="no",i.options.rotationcenter="molecule center",i.options.axis="no",i.options.fog="no",i.options.slab="no",i.options.picking="residue",i.options.nucleotides="nucleotide cartoon",i.modifyIcn3d,i.bAddCommands=!0,i.bAddLogs=!0,i.bNotLoadStructure=!1,i.bInitial=!0};iCn3DUI.prototype={constructor:iCn3DUI,modifyIcn3d:function{var e=this;e.modifyIcn3dShowPicking,e.modifySwitchHighlightLevel},modifyIcn3dShowPicking:function{var e=this;iCn3D.prototype.showPicking=function(i){if(this.showPickingBase(i),1===this.picking||2===this.picking){var t=this.id.split("_");e.pre=t[0]+"_";var n=i.structure+"_"+i.chain+"_"+i.resi;e.clearSelection,e.icn3d.bShiftKey||(e.removeSeqChainBkgd,e.removeSeqResidueBkgd),0!==$("#"+e.pre+n).length&&$("#"+e.pre+n).addClass("icn3d-highlightSeq"),0!==$("#align"+e.pre+n).length&&$("#align"+e.pre+n).addClass("icn3d-highlightSeq")}else if(3===this.picking){var t=this.id.split("_");e.pre=t[0]+"_";var o=this.getFirstAtomObj(this.highlightAtoms),s=this.getLastAtomObj(this.highlightAtoms);e.clearSelection,e.icn3d.bShiftKey||(e.removeSeqChainBkgd,e.removeSeqResidueBkgd);for(var r=o.resi;r<=s.resi;++r){var n=i.structure+"_"+i.chain+"_"+r;0!==$("#"+e.pre+n).length&&$("#"+e.pre+n).addClass("icn3d-highlightSeq"),0!==$("#align"+e.pre+n).length&&$("#align"+e.pre+n).addClass("icn3d-highlightSeq")}}var a={};a.factor=this._zoomFactor,a.mouseChange=this.mouseChange,a.quaternion={},a.quaternion._x=parseInt(1e3*this.quaternion._x)/1e3,a.quaternion._y=parseInt(1e3*this.quaternion._y)/1e3,a.quaternion._z=parseInt(1e3*this.quaternion._z)/1e3,a.quaternion._w=parseInt(1e3*this.quaternion._w)/1e3,e.bAddCommands&&(this.commands.push("pickatom "+i.serial+"|||"+JSON.stringify(a)),this.optionsHistory.push(this.cloneHash(this.options)),this.optionsHistory[this.optionsHistory.length-1].hlatomcount=Object.keys(this.highlightAtoms).length,e.isSessionStorageSupported&&e.saveCommandsToSession,e.STATENUMBER=this.commands.length),this.logs.push("pickatom "+i.serial+" (chain: "+i.structure+"_"+i.chain+", residue: "+i.resn+", number: "+i.resi+", atom: "+i.name+")"),$("#"+e.pre+"logtext").length&&$("#"+e.pre+"logtext").val("> "+this.logs.join("\n> ")+"\n> ").scrollTop($("#"+e.pre+"logtext")[0].scrollHeight)}},modifySwitchHighlightLevel:function{var e=this;iCn3D.prototype.switchHighlightLevel=function{this.switchHighlightLevelBase,$(document).bind("keydown",function(i){38===i.keyCode?e.updateSeqWinForCurrentAtoms:40===i.keyCode&&e.updateSeqWinForCurrentAtoms})}},show3DStructure:function{var e=this;return e.deferred=$.Deferred(function{e.isSessionStorageSupported&&e.getCommandsBeforeCrash,e.setTopMenusHtml(e.divid),e.setViewerWidthHeight;var i,t;i=-1!==e.cfg.width.toString.indexOf("%")?e.WIDTH*e.cfg.width.substr(0,e.cfg.width.toString.indexOf("%"))/100-e.LESSWIDTH:e.cfg.width,t=-1!==e.cfg.height.toString.indexOf("%")?e.HEIGHT*e.cfg.height.substr(0,e.cfg.height.toString.indexOf("%"))/100-e.EXTRAHEIGHT-e.LESSHEIGHT:e.cfg.height,e.allEventFunctions,e.allCustomEvents,void 0!=e.cfg.showmenu&&0==e.cfg.showmenu?(e.EXTRAHEIGHT=0,e.hideMenu(i,t)):(e.EXTRAHEIGHT=2.8*e.MENU_HEIGHT,e.showMenu(i,t)),e.icn3d=new iCn3D(e.pre+"canvas"),$("#"+e.pre+"canvas").width(i).height(t);var n=parseInt(t)+e.EXTRAHEIGHT;if($("#"+e.pre+"viewer").width(i).height(n),e.icn3d.setWidthHeight(i,t),void 0!==e.cfg.bCalphaOnly&&(e.icn3d.bCalphaOnly=e.cfg.bCalphaOnly),e.icn3d.options=e.icn3d.cloneHash(e.options),e.STATENUMBER=e.icn3d.commands.length,e.isSessionStorageSupported&&e.bCrashed){e.bCrashed=!1;var o=e.commandsBeforeCrash.split("|||")[0],s=o.substr(o.lastIndexOf(" ")+1);if(s===e.cfg.pdbid||s===e.cfg.mmdbid||s===e.cfg.gi||s===e.cfg.cid||s===e.cfg.mmcifid||s===e.cfg.align)return void e.loadScript(e.commandsBeforeCrash,!0)}if(e.icn3d.moleculeTitle="",void 0!==e.cfg.pdbid)e.inputid=e.cfg.pdbid,e.setLogCommand("load pdb "+e.cfg.pdbid,!0),e.downloadPdb(e.cfg.pdbid);else if(void 0!==e.cfg.mmdbid)e.inputid=e.cfg.mmdbid,e.setLogCommand("load mmdb "+e.cfg.mmdbid+" | parameters "+e.cfg.inpara,!0),e.downloadMmdb(e.cfg.mmdbid);else if(void 0!==e.cfg.gi)e.setLogCommand("load gi "+e.cfg.gi,!0),e.downloadGi(e.cfg.gi);else if(void 0!==e.cfg.cid){e.inputid=e.cfg.cid;var r="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+e.inputid+"/description/jsonp";$.ajax({url:r,dataType:"jsonp",success:function(i){void 0!==i.InformationList&&void 0!==i.InformationList.Information&&(e.icn3d.moleculeTitle=i.InformationList.Information[0].Title)}}),e.setLogCommand("load cid "+e.cfg.cid,!0),e.downloadCid(e.cfg.cid)}else if(void 0!==e.cfg.mmcifid)e.inputid=e.cfg.mmcifid,e.setLogCommand("load mmcif "+e.cfg.mmcifid,!0),e.downloadMmcif(e.cfg.mmcifid);else if(void 0!==e.cfg.align){var a=e.cfg.align.split(",");6===a.length?e.inputid=a[0]+"_"+a[3]:2===a.length&&(e.inputid=a[0]+"_"+a[1]),e.setLogCommand("load alignment "+e.cfg.align+" | parameters "+e.cfg.inpara,!0),e.downloadAlignment(e.cfg.align)}else alert("Please input a gi, MMDB ID, PDB ID, CID, or mmCIF ID...")}),e.deferred},clearSelection:function{var e=this;$("#"+e.pre+"chainid").val(""),$("#"+e.pre+"structureid").val(""),$("#"+e.pre+"alignChainid").val(""),$("#"+e.pre+"customResidues").val(""),$("#"+e.pre+"chainid2").val(""),$("#"+e.pre+"structureid2").val(""),$("#"+e.pre+"alignChainid2").val(""),$("#"+e.pre+"customResidues2").val(""),$("#"+e.pre+"customAtoms").val("")},removeSeqChainBkgd:function(e){$(".icn3d-seqTitle").each(function(i){void 0===e?$(this).removeClass("icn3d-highlightSeq"):$(this).attr("chain")!==e&&$(this).removeClass("icn3d-highlightSeq")})},removeSeqResidueBkgd:function{$(".icn3d-residue").each(function(e){$(this).removeClass("icn3d-highlightSeq")})},hideMenu:function(e,i){var t=this;void 0!==$("#"+t.pre+"menulist")[0]&&($("#"+t.pre+"menulist")[0].style.display="none"),void 0!==$("#"+t.pre+"menuLogSection")[0]&&($("#"+t.pre+"menuLogSection")[0].style.display="none"),void 0!==$("#"+t.pre+"commandlog")[0]&&($("#"+t.pre+"commandlog")[0].style.display="none"),void 0!==$("#"+t.pre+"selection")[0]&&($("#"+t.pre+"selection")[0].style.display="none"),void 0!==$("#"+t.pre+"title")[0]&&($("#"+t.pre+"title")[0].style.display="none"),$("#"+t.pre+"viewer").width(e).height(i),$("#"+t.pre+"canvas").width(e).height(i)},showMenu:function(e,i){var t=this;void 0!==$("#"+t.pre+"menulist")[0]&&($("#"+t.pre+"menulist")[0].style.display="block"),void 0!==$("#"+t.pre+"menuLogSection")[0]&&($("#"+t.pre+"menuLogSection")[0].style.display="block"),void 0!==$("#"+t.pre+"commandlog")[0]&&($("#"+t.pre+"commandlog")[0].style.display="block"),void 0!==$("#"+t.pre+"selection")[0]&&($("#"+t.pre+"selection")[0].style.display="block"),void 0!==$("#"+t.pre+"title")[0]&&($("#"+t.pre+"title")[0].style.display="block");var n=parseInt(i)+t.EXTRAHEIGHT;$("#"+t.pre+"viewer").width(e).height(n),$("#"+t.pre+"canvas").width(e).height(i)},saveSelectionIfSelected:function(e,i){var t=this;(t.bSelectResidue||t.bSelectAlignResidue)&&(t.saveSelection,t.bSelectResidue=!1,t.bSelectAlignResidue=!1)},setOption:function(e,i){var t=this;t.icn3d.options[e]=i,t.saveSelectionIfSelected,"color"===e?(t.icn3d.setColorByOptions(t.icn3d.options,t.icn3d.highlightAtoms),t.icn3d.draw,setTimeout(function{t.updateSeqWinForCurrentAtoms(!1)},0)):"surface"===e||"opacity"===e||"wireframe"===e?(("opacity"===e||"wireframe"===e)&&t.icn3d.removeLastSurface,t.icn3d.applySurfaceOptions,t.icn3d.render):t.icn3d.draw},setStyle:function(e,i){var t=this,n={};switch(e){case"proteins":n=t.icn3d.intersectHash(t.icn3d.highlightAtoms,t.icn3d.proteins);break;case"sidechains":n=t.icn3d.intersectHash(t.icn3d.highlightAtoms,t.icn3d.sidechains);break;case"nucleotides":n=t.icn3d.intersectHash(t.icn3d.highlightAtoms,t.icn3d.nucleotides);break;case"ligands":n=t.icn3d.intersectHash(t.icn3d.highlightAtoms,t.icn3d.ligands);break;case"ions":n=t.icn3d.intersectHash(t.icn3d.highlightAtoms,t.icn3d.ions);break;case"water":n=t.icn3d.intersectHash(t.icn3d.highlightAtoms,t.icn3d.water)}for(var o in n)t.icn3d.atoms[o].style=i;t.icn3d.options[e]=i,t.saveSelectionIfSelected,t.icn3d.draw},setLogCommand:function(e,i,t){var n=this;if(""===e.trim)return!1;var o=e.indexOf("|||");-1!==o&&(e=e.substr(0,o));var s={};if(s.factor=n.icn3d._zoomFactor,s.mouseChange=n.icn3d.mouseChange,s.quaternion={},s.quaternion._x=parseInt(1e3*n.icn3d.quaternion._x)/1e3,s.quaternion._y=parseInt(1e3*n.icn3d.quaternion._y)/1e3,s.quaternion._z=parseInt(1e3*n.icn3d.quaternion._z)/1e3,s.quaternion._w=parseInt(1e3*n.icn3d.quaternion._w)/1e3,i&&n.bAddCommands)if(n.STATENUMBER<n.icn3d.commands.length){var r=n.icn3d.commands[n.STATENUMBER-1],o=r.indexOf("|||");e!==r.substr(0,o)&&(n.icn3d.commands=n.icn3d.commands.slice(0,n.STATENUMBER),n.icn3d.commands.push(e+"|||"+JSON.stringify(s)),n.icn3d.optionsHistory.push(n.icn3d.cloneHash(n.icn3d.options)),n.icn3d.optionsHistory[n.icn3d.optionsHistory.length-1].hlatomcount=Object.keys(n.icn3d.highlightAtoms).length,n.isSessionStorageSupported&&n.saveCommandsToSession,n.STATENUMBER=n.icn3d.commands.length)}else n.icn3d.commands.push(e+"|||"+JSON.stringify(s)),n.icn3d.optionsHistory.push(n.icn3d.cloneHash(n.icn3d.options)),void 0!==n.icn3d.highlightAtoms&&(n.icn3d.optionsHistory[n.icn3d.optionsHistory.length-1].hlatomcount=Object.keys(n.icn3d.highlightAtoms).length),n.isSessionStorageSupported&&n.saveCommandsToSession,n.STATENUMBER=n.icn3d.commands.length;n.bAddLogs&&(n.icn3d.logs.push(e),$("#"+n.pre+"logtext").val("> "+n.icn3d.logs.join("\n> ")+"\n> ").scrollTop($("#"+n.pre+"logtext")[0].scrollHeight)),n.adjustIcon},renderStructure:function{var e=this;e.bInitial?(void 0!==e.cfg.command&&""!==e.cfg.command?(e.icn3d.bRender=!1,e.icn3d.draw(e.options),e.icn3d.bRender=!0,e.loadScript(e.cfg.command)):e.icn3d.draw(e.options),Object.keys(e.icn3d.structures).length>1?$("#"+e.pre+"alternate").show:$("#"+e.pre+"alternate").hide):(e.saveSelectionIfSelected,e.icn3d.draw),void 0!==e.cfg.showseq&&e.cfg.showseq&&e.openDialog(e.pre+"dl_selectresidues","Select residues in sequences"),Object.keys(e.icn3d.highlightAtoms).length===Object.keys(e.icn3d.atoms).length&&(void 0===e.cfg.showmenu||e.cfg.showmenu||e.cfg.showseq||e.cfg.showalignseq)?(e.selectAllUpdateMenuSeq(e.bInitial,!1),e.bInitial=!1):(e.bInitial&&e.setProteinsNucleotidesLigands,e.updateMenus(!1),e.updateSeqWinForCurrentAtoms,e.bInitial=!1)},setStructureMenu:function(e,i){for(var t=this,n="",o=e?" selected":"",s=Object.keys(t.icn3d.structures),r=0,a=s.length;a>r;++r){var c=s[r];void 0!==i&&(o=-1!==i.indexOf(c)?" selected":"");var l=void 0!==t.icn3d.secondId&&0===c.indexOf(t.icn3d.secondId)?"  ":"";if(n+="<option value='"+c+"'"+o+">"+l+s[r]+" "," selected"===o)for(var d in t.icn3d.structures[c]){var h=t.icn3d.structures[c][d];t.icn3d.highlightAtoms=t.icn3d.unionHash(t.icn3d.highlightAtoms,t.icn3d.chains[h])}if(e){var u={};for(var d in t.icn3d.structures[c]){var h=t.icn3d.structures[c][d];u=t.icn3d.unionHash(u,t.icn3d.chains[h])}t.icn3d.definedNames2Atoms[c]=Object.keys(u),t.icn3d.definedNames2Descr[c]=c,t.icn3d.definedNames2Command[c]="select structure "+c,u={}}}return n},setProteinsNucleotidesLigands:function{var e=this;for(var i in e.icn3d.chains)Object.keys(e.icn3d.proteins).length>0&&(e.icn3d.definedNames2Atoms.proteins=Object.keys(e.icn3d.proteins),e.icn3d.definedNames2Residues.proteins=Object.keys(e.icn3d.getResiduesFromAtoms(e.icn3d.proteins)),e.icn3d.definedNames2Descr.proteins="proteins",e.icn3d.definedNames2Command.proteins="select :proteins"),Object.keys(e.icn3d.nucleotides).length>0&&(e.icn3d.definedNames2Atoms.nucleotides=Object.keys(e.icn3d.nucleotides),e.icn3d.definedNames2Residues.nucleotides=Object.keys(e.icn3d.getResiduesFromAtoms(e.icn3d.nucleotides)),e.icn3d.definedNames2Descr.nucleotides="nucleotides",e.icn3d.definedNames2Command.nucleotides="select :nucleotides"),Object.keys(e.icn3d.ligands).length>0&&(e.icn3d.definedNames2Atoms.ligands=Object.keys(e.icn3d.ligands),e.icn3d.definedNames2Residues.ligands=Object.keys(e.icn3d.getResiduesFromAtoms(e.icn3d.ligands)),e.icn3d.definedNames2Descr.ligands="ligands",e.icn3d.definedNames2Command.ligands="select :ligands"),Object.keys(e.icn3d.ions).length>0&&(e.icn3d.definedNames2Atoms.ions=Object.keys(e.icn3d.ions),e.icn3d.definedNames2Residues.ions=Object.keys(e.icn3d.getResiduesFromAtoms(e.icn3d.ions)),e.icn3d.definedNames2Descr.ions="ions",e.icn3d.definedNames2Command.ions="select :ions"),Object.keys(e.icn3d.water).length>0&&(e.icn3d.definedNames2Atoms.water=Object.keys(e.icn3d.water),e.icn3d.definedNames2Residues.water=Object.keys(e.icn3d.getResiduesFromAtoms(e.icn3d.water)),e.icn3d.definedNames2Descr.water="water",e.icn3d.definedNames2Command.water="select :water")},setChainMenu:function(e,i){var t=this,n="",o=e?" selected":"";if(void 0===i)for(var s in t.icn3d.chains){var r=void 0!==t.icn3d.secondId&&0===s.indexOf(t.icn3d.secondId)?" ":"";n+="<option value='"+s+"' "+o+">"+r+s+" "," selected"===o&&(t.icn3d.highlightAtoms=t.icn3d.unionHash(t.icn3d.highlightAtoms,t.icn3d.chains[s])),e&&(t.icn3d.definedNames2Atoms[s]=Object.keys(t.icn3d.chains[s]),t.icn3d.definedNames2Descr[s]=s,t.icn3d.definedNames2Command[s]="select chain "+s)}else for(var s in t.icn3d.chains){var a=s.indexOf("_"),c=s.substr(0,a),r=void 0!==t.icn3d.secondId&&0===s.indexOf(t.icn3d.secondId)?" ":"";null!==i&&-1!==i.toString.toLowerCase.indexOf(c.toLowerCase)?(n+="<option value='"+s+"' selected>"+r+s+" ",t.icn3d.highlightAtoms=t.icn3d.unionHash(t.icn3d.highlightAtoms,t.icn3d.chains[s])):n+="<option value='"+s+"'>"+r+s+" "}return n},setAlignChainMenu:function(e,i){var t=this,n="",o=e?" selected":"";if(void 0===i)for(var s in t.icn3d.alignChains){var r=void 0!==t.icn3d.secondId&&0===s.indexOf(t.icn3d.secondId)?" ":"";n+="<option value='"+s+"' "+o+">"+r+s+" "," selected"===o&&(t.icn3d.highlightAtoms=t.icn3d.unionHash(t.icn3d.highlightAtoms,t.icn3d.alignChains[s])),e&&(t.icn3d.definedNames2Atoms[s]=Object.keys(t.icn3d.alignChains[s]),t.icn3d.definedNames2Descr[s]=s, t.icn3d.definedNames2Command[s]="select alignChain "+s)}else for(var s in t.icn3d.alignChains){var a=s.indexOf("_"),c=s.substr(0,a),r=void 0!==t.icn3d.secondId&&0===s.indexOf(t.icn3d.secondId)?" ":"";null!==i&&-1!==i.toString.toLowerCase.indexOf(c.toLowerCase)?(n+="<option value='"+s+"' selected>"+r+s+" ",t.icn3d.highlightAtoms=t.icn3d.unionHash(t.icn3d.highlightAtoms,t.icn3d.alignChains[s])):n+="<option value='"+s+"'>"+r+s+" "}return n},setResidueMenu:function(e){var i=this,t="",n=!1;for(var o in i.icn3d.definedNames2Residues)o===e?(t+="<option value='"+o+"' selected='selected'>"+o+" ",n=!0):t+="<option value='"+o+"'>"+o+" ";return n&&($("#"+i.pre+"chainid").val(""),$("#"+i.pre+"structureid").val(""),$("#"+i.pre+"chainid2").val(""),$("#"+i.pre+"structureid2").val("")),t},setAtomMenu:function(e){for(var i=this,t="",n=!1,o=Object.keys(i.icn3d.definedNames2Atoms).sort,s=0,r=o.length;r>s;++s){var a=o[s];a===e?(t+="<option value='"+a+"' selected='selected'>"+a+" ",n=!0):t+="<option value='"+a+"'>"+a+" "}return n&&($("#"+i.pre+"chainid").val(""),$("#"+i.pre+"structureid").val(""),$("#"+i.pre+"chainid2").val(""),$("#"+i.pre+"structureid2").val("")),t},getSequencesAnnotations:function(e,i,t,n){var o,s=this,r="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.",a=s.isMac&&!s.isMobile?" Turn on scroll bar: System preferences -> General -> show scroll bars -> check Always":"";s.isMobile?o='Select Sequences: touch to select, touch again to deselect, multiple selection is allowed without Ctrl key, click "Save Selection" to save the current selection ':(o='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 ',o+='Select on 3D structures: hold "Alt" and use mouse to pick, 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 '),o+=" <Selection:</b> Name: <input type='text' id='"+s.pre+"seq_command_name' value='seq_"+Object.keys(s.icn3d.definedNames2Residues).length+"' size='10'>  Description: <input type='text' id='"+s.pre+"seq_command_desc' value='seq_desc_"+Object.keys(s.icn3d.definedNames2Residues).length+"' size='20'> <button style='white-space:nowrap;' id='"+s.pre+"seq_saveselection'>Save Selection <button style='white-space:nowrap; margin-left:20px;' id='"+s.pre+"seq_clearselection'>Clear Selection  ",o+=r+a+" ",""!==s.icn3d.moleculeTitle&&(o+=" Title: "+s.icn3d.moleculeTitle+"  ");var c=0,l={};if(void 0!==e)for(var d=0,h=e.length;h>d;++d)l[e[d]]=1;for(var d in s.icn3d.chains){var u=void 0!==e&&l.hasOwnProperty(d)?!0:!1;u&&(void 0===i||i)&&(s.icn3d.highlightAtoms=s.icn3d.unionHash(s.icn3d.highlightAtoms,s.icn3d.chains[d]));var p=[],m="",g=void 0!==s.icn3d.chainsSeq[d]?s.icn3d.chainsSeq[d].length:0;g>c&&(c=g);var f=d.indexOf("_"),v=d.substr(0,f),b=d.substr(f+1),y=1;void 0!==s.icn3d.chainsSeq[d]&&(m+=" "+s.icn3d.chainsSeq[d][0].resi+" ",y=parseInt(s.icn3d.chainsSeq[d][0].resi));for(var E=0,_=g;_>E;++E){var w=v+"_"+b+"_"+s.icn3d.chainsSeq[d][E].resi,C=s.icn3d.chainsSeq[d][E].name===s.icn3d.chainsSeq[d][E].name.toUpperCase?!0:!1,S="class='icn3d-residue'";(void 0===n||n)&&(u||C&&void 0!==t&&-1!==t.indexOf(w))&&(S="class='icn3d-residue icn3d-highlightSeq'");var k,R=1===s.icn3d.chainsSeq[d][E].name.length?s.icn3d.chainsSeq[d][E].name:s.icn3d.chainsSeq[d][E].name.trim.substr(0,1)+".",T="O"===s.icn3d.chainsSeq[d][E].name?"HOH":s.icn3d.chainsSeq[d][E].name;if(s.icn3d.residues.hasOwnProperty(w)){var H=s.icn3d.getFirstAtomObj(s.icn3d.residues[w]);k=void 0!==H.color?"#"+H.color.getHexString+";":"#000000;"}else k="#000000;";"#FFFFFF;"===k.toUpperCase&&(k=s.GREYD),m+=C?"<span id='"+s.pre+w+"' title='"+T+s.icn3d.chainsSeq[d][E].resi+"' style='color:"+k+"'"+S+">"+R+" ":"<span title='"+T+s.icn3d.chainsSeq[d][E].resi+"'>"+R+" ",y<parseInt(s.icn3d.chainsSeq[d][E].resi)&&(y=parseInt(s.icn3d.chainsSeq[d][E].resi))}m+=" "+y+" ";for(var A=void 0!==s.icn3d.chainsAnno[d]?s.icn3d.chainsAnno[d].length:0,x=0,O=A;O>x;++x){p[x]="",p[x]+=" ";for(var E=0,_=s.icn3d.chainsAnno[d][x].length;_>E;++E){var $=s.icn3d.chainsAnno[d][x][E];p[x]+=" "+$+" "}p[x]+=" "}for(var x=0,O=A;O>x;++x)o+=" <div class='icn3d-annoTitle' chain='"+d+"' anno='"+x+"'>"+s.icn3d.chainsAnnoTitle[d][x][0]+" "+p[x]+"  ";var M=d;title=void 0!==s.icn3d.pdbid_chain2title?s.icn3d.pdbid_chain2title[d]:"",o+='<div class="icn3d-seqTitle" chain="'+d+'" anno="sequence" title="'+title+'">'+M+' '+m+"  "}return{sequencesHtml:o,maxSeqCnt:c}},getAlignSequencesAnnotations:function(e,i,t,n){var o,s=this,r="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.",a=s.isMac&&!s.isMobile?" Turn on scroll bar: System preferences -> General -> show scroll bars -> check Always":"";s.isMobile?o='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 ':(o='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 ',o+='Select on 3D structures: hold "Alt" and use mouse to pick, 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 '),o+=" Selection: Name: <input type='text' id='"+s.pre+"alignseq_command_name' value='alseq_"+Object.keys(s.icn3d.definedNames2Residues).length+"' size='10'>  Description: <input type='text' id='"+s.pre+"alignseq_command_desc' value='alseq_desc_"+Object.keys(s.icn3d.definedNames2Residues).length+"' size='20'> <button style='white-space:nowrap;' id='"+s.pre+"alignseq_saveselection'>Save Selection <button style='white-space:nowrap; margin-left:20px;' id='"+s.pre+"alignseq_clearselection'>Clear Selection  ",o+=r+a+" ";var c=0,l={};if(void 0!==e)for(var d=0,h=e.length;h>d;++d)l[e[d]]=1;for(var d in s.icn3d.alignChains){var u=void 0!==e&&l.hasOwnProperty(d)?!0:!1;u&&(void 0===i||i)&&(s.icn3d.highlightAtoms=s.icn3d.unionHash(s.icn3d.highlightAtoms,s.icn3d.alignChains[d]));var p=[],m="",g=void 0!==s.icn3d.alignChainsSeq[d]?s.icn3d.alignChainsSeq[d].length:0;g>c&&(c=g);var f=d.indexOf("_"),v=d.substr(0,f),b=d.substr(f+1);m+=" "+s.icn3d.alignChainsSeq[d][0].resi+" ";for(var u=void 0!==e&&l.hasOwnProperty(d)?!0:!1,y=0,E=g;E>y;++y){var _="N/A",w="",C="#000";""===s.icn3d.alignChainsSeq[d][y].resi||isNaN(s.icn3d.alignChainsSeq[d][y].resi)||(_=s.icn3d.alignChainsSeq[d][y].resi,w=v+"_"+b+"_"+_,C=s.icn3d.alignChainsSeq[d][y].color);var S="class='icn3d-residue";(void 0===n||n)&&(u||void 0!==t&&""!==w&&-1!==t.indexOf(w))&&(S="class='icn3d-residue icn3d-highlightSeq"),S+=""===w?"'":" "+s.icn3d.alignChainsSeq[d][y]["class"]+"'";var k;if(s.icn3d.residues.hasOwnProperty(w)){var R=s.icn3d.getFirstAtomObj(s.icn3d.residues[w]);k=void 0!==R.color?"#"+R.color.getHexString+";":"#000000;"}else k="#000000;";"#FFFFFF;"===k.toUpperCase&&(k=s.GREYD);var T=""!==w?!0:!1;m+=T?"<span id='align"+s.pre+w+"' "+S+" style='color:"+k+"' title='"+s.icn3d.alignChainsSeq[d][y].resn+s.icn3d.alignChainsSeq[d][y].resi+"'>"+s.icn3d.alignChainsSeq[d][y].resn+" ":"<span title='"+s.icn3d.alignChainsSeq[d][y].resn+s.icn3d.alignChainsSeq[d][y].resi+"'>"+s.icn3d.alignChainsSeq[d][y].resn+" "}m+=" "+s.icn3d.alignChainsSeq[d][g-1].resi+" ";for(var H=void 0!==s.icn3d.alignChainsAnno[d]?s.icn3d.alignChainsAnno[d].length:0,A=0,x=H;x>A;++A){p[A]="",p[A]+=" ";for(var y=0,E=s.icn3d.alignChainsAnno[d][A].length;E>y;++y)p[A]+=" "+s.icn3d.alignChainsAnno[d][A][y]+" ";p[A]+=" "}for(var O=d,$=void 0!==s.icn3d.pdbid_chain2title?s.icn3d.pdbid_chain2title[d]:"",A=H-1;A>=0;--A)o+=" <div class='icn3d-seqTitle' chain='"+d+"' anno='"+A+"'>"+s.icn3d.alignChainsAnnoTitle[d][A][0]+" "+p[A]+"  ";o+='<div class="icn3d-seqTitle" chain="'+d+'" anno="sequence" title="'+$+'">'+O+' '+m+"  "}return{sequencesHtml:o,maxSeqCnt:c}},addCustomSelection:function(e,i,t,n,o,s){var r=this;if(t in r.icn3d.definedNames2Residues){s&&(r.icn3d.definedNames2Residues[t]=r.icn3d.definedNames2Residues[t].concat(e)),r.icn3d.definedNames2Atoms[t]=r.icn3d.definedNames2Atoms[t].concat(i),r.icn3d.definedNames2Descr[t]=n,s?r.icn3d.definedNames2Command[t]+=","+e:r.icn3d.definedNames2Command[t]=o;var a=r.setResidueMenu(t),c=r.setAtomMenu(t);$("#"+r.pre+"customResidues").html(a),$("#"+r.pre+"customResidues2").html(a),$("#"+r.pre+"customAtoms").html(c)}else{s&&(r.icn3d.definedNames2Residues[t]=e),r.icn3d.definedNames2Atoms[t]=i,r.icn3d.definedNames2Descr[t]=n,r.icn3d.definedNames2Command[t]=o;var a=r.setResidueMenu(t),c=r.setAtomMenu(t);$("#"+r.pre+"customResidues").html(a),$("#"+r.pre+"customResidues2").html(a),$("#"+r.pre+"customAtoms").html(c)}},changeStructureid:function(e,i,t){var n=this;n.icn3d.removeHighlightObjects,n.ALTERNATE_STRUCTURE=Object.keys(n.icn3d.structures).indexOf(e[0]),$("#"+n.pre+"chainid").val(""),$("#"+n.pre+"alignChainid").val(""),$("#"+n.pre+"customResidues").val(""),$("#"+n.pre+"chainid2").val(""),$("#"+n.pre+"alignChainid2").val(""),$("#"+n.pre+"customResidues2").val(""),$("#"+n.pre+"customAtoms").val(""),null!==e&&n.setLogCommand("select structure "+e.toString,!0);var o=n.setChainMenu(!1,e);$("#"+n.pre+"chainid").html(o),$("#"+n.pre+"chainid2").html(o);var s=n.setAlignChainMenu(!1,e);$("#"+n.pre+"alignChainid").html(s),$("#"+n.pre+"alignChainid2").html(s);for(var r=[],a=0,c=e.length;c>a;++a)r=r.concat(n.icn3d.structures[e[a]]);if((void 0===i||i)&&(n.icn3d.highlightAtoms={}),void 0===t||t){var l=n.getSequencesAnnotations(r);$("#"+n.pre+"dl_sequence").html(l.sequencesHtml),$("#"+n.pre+"dl_sequence").width(n.RESIDUE_WIDTH*l.maxSeqCnt+200),void 0!==n.cfg.align&&(l=n.getAlignSequencesAnnotations(r),$("#"+n.pre+"dl_sequence2").html(l.sequencesHtml),$("#"+n.pre+"dl_sequence2").width(n.RESIDUE_WIDTH*l.maxSeqCnt+200))}n.icn3d.addHighlightObjects},getResiduesUpdateHighlight:function(e,i){for(var t=this,n=[],o={},s=0,r=e.length;r>s;++s)o[e[s]]=1;for(var a in t.icn3d.residues){var c=a.lastIndexOf("_"),l=a.substr(0,c);o.hasOwnProperty(l)&&(n.push(a),(void 0===i||i)&&(t.icn3d.highlightAtoms=t.icn3d.unionHash(t.icn3d.highlightAtoms,t.icn3d.residues[a])))}return n},changeChainid:function(e){var i=this;i.icn3d.removeHighlightObjects,i.icn3d.highlightAtoms={},$("#"+i.pre+"structureid").val(""),$("#"+i.pre+"alignChainid").val(""),$("#"+i.pre+"customResidues").val(""),$("#"+i.pre+"structureid2").val(""),$("#"+i.pre+"alignChainid2").val(""),$("#"+i.pre+"customResidues2").val(""),$("#"+i.pre+"customAtoms").val(""),null!==e&&i.setLogCommand("select chain "+e.toString,!0);var t=i.getSequencesAnnotations(e);$("#"+i.pre+"dl_sequence").html(t.sequencesHtml),$("#"+i.pre+"dl_sequence").width(i.RESIDUE_WIDTH*t.maxSeqCnt+200),void 0!==i.cfg.align&&(t=i.getAlignSequencesAnnotations(e),$("#"+i.pre+"dl_sequence2").html(t.sequencesHtml),$("#"+i.pre+"dl_sequence2").width(i.RESIDUE_WIDTH*t.maxSeqCnt+200)),i.icn3d.addHighlightObjects},changeAlignChainid:function(e){var i=this;i.icn3d.removeHighlightObjects,i.icn3d.highlightAtoms={},$("#"+i.pre+"structureid").val(""),$("#"+i.pre+"chainid").val(""),$("#"+i.pre+"customResidues").val(""),$("#"+i.pre+"structureid2").val(""),$("#"+i.pre+"chainid2").val(""),$("#"+i.pre+"customResidues2").val(""),$("#"+i.pre+"customAtoms").val(""),null!==e&&i.setLogCommand("select alignChain "+e.toString,!0);var t=i.getAlignSequencesAnnotations(e);$("#"+i.pre+"dl_sequence2").html(t.sequencesHtml),$("#"+i.pre+"dl_sequence2").width(i.RESIDUE_WIDTH*t.maxSeqCnt+200);for(var n={},o=0,s=e.length;s>o;++o){var r=e[o];n=i.icn3d.unionHash(n,i.icn3d.getResiduesFromAtoms(i.icn3d.alignChains[r]))}t=i.getSequencesAnnotations(void 0,!0,Object.keys(n)),$("#"+i.pre+"dl_sequence").html(t.sequencesHtml),$("#"+i.pre+"dl_sequence").width(i.RESIDUE_WIDTH*t.maxSeqCnt+200),i.icn3d.addHighlightObjects},changeResidueid:function(e){var i=this;i.icn3d.removeHighlightObjects,i.icn3d.highlightAtoms={},$("#"+i.pre+"structureid").val(""),$("#"+i.pre+"chainid").val(""),$("#"+i.pre+"alignChainid").val(""),$("#"+i.pre+"customResidues").val(""),$("#"+i.pre+"structureid2").val(""),$("#"+i.pre+"chainid2").val(""),$("#"+i.pre+"alignChainid2").val(""),$("#"+i.pre+"customResidues2").val(""),$("#"+i.pre+"customAtoms").val(""),null!==e&&i.setLogCommand("select residue "+i.residueids2spec(e),!0);for(var t="",n=0,o=e.length;o>n;++n)i.icn3d.highlightAtoms=i.icn3d.unionHash(i.icn3d.highlightAtoms,i.icn3d.residues[e[n]]);t+="Annotation(s): Previously selected residues ";var s=i.getSequencesAnnotations(void 0,!0,e);$("#"+i.pre+"dl_sequence").html(t+s.sequencesHtml),$("#"+i.pre+"dl_sequence").width(i.RESIDUE_WIDTH*s.maxSeqCnt+200),void 0!==i.cfg.align&&(s=i.getAlignSequencesAnnotations(void 0,!0,e),$("#"+i.pre+"dl_sequence2").html(t+s.sequencesHtml),$("#"+i.pre+"dl_sequence2").width(i.RESIDUE_WIDTH*s.maxSeqCnt+200)),i.icn3d.addHighlightObjects},changeCustomResidues:function(e){var i=this;i.icn3d.removeHighlightObjects,i.icn3d.highlightAtoms={},$("#"+i.pre+"chainid").val(""),$("#"+i.pre+"alignChainid").val(""),$("#"+i.pre+"structureid").val(""),$("#"+i.pre+"chainid2").val(""),$("#"+i.pre+"alignChainid2").val(""),$("#"+i.pre+"structureid2").val(""),$("#"+i.pre+"customAtoms").val("");for(var t="",n="",o={},s=0;s<e.length;++s){var r=i.icn3d.definedNames2Residues[e[s]];if(void 0!==r){var a=i.icn3d.definedNames2Descr[e[s]];n+=""+e[s]+": "+a+"; ";for(var c=0,l=r.length;l>c;++c)o[r[c]]=1,i.icn3d.highlightAtoms=i.icn3d.unionHash(i.icn3d.highlightAtoms,i.icn3d.residues[r[c]])}}t+="Annotation(s): "+n+" ";var d=i.getSequencesAnnotations(void 0,!0,Object.keys(o));$("#"+i.pre+"dl_sequence").html(t+d.sequencesHtml),$("#"+i.pre+"dl_sequence").width(i.RESIDUE_WIDTH*d.maxSeqCnt+200),void 0!==i.cfg.align&&(d=i.getAlignSequencesAnnotations(void 0,!0,Object.keys(o)),$("#"+i.pre+"dl_sequence2").html(t+d.sequencesHtml),$("#"+i.pre+"dl_sequence2").width(i.RESIDUE_WIDTH*d.maxSeqCnt+200)),i.icn3d.addHighlightObjects},changeCustomAtoms:function(e){var i=this;i.icn3d.removeHighlightObjects,i.icn3d.highlightAtoms={},$("#"+i.pre+"chainid").val(""),$("#"+i.pre+"alignChainid").val(""),$("#"+i.pre+"structureid").val(""),$("#"+i.pre+"customResidues").val(""),$("#"+i.pre+"chainid2").val(""),$("#"+i.pre+"alignChainid2").val(""),$("#"+i.pre+"structureid2").val(""),$("#"+i.pre+"customResidues2").val(""),$("#"+i.pre+"command").val(""),$("#"+i.pre+"command_name").val(""),$("#"+i.pre+"command_desc").val("");for(var t="",n="",o={},s=0;s<e.length;++s){var r=i.icn3d.definedNames2Atoms[e[s]];if(void 0!==r){for(var a={},c=0,l=r.length;l>c;++c){var d=i.icn3d.atoms[r[c]],h=d.structure+"_"+d.chain+"_"+d.resi;a[h]=1}var u=Object.keys(a);if(void 0!==u){var p=i.icn3d.definedNames2Descr[e[s]];n+=""+e[s]+": "+p+"; ";for(var c=0,l=u.length;l>c;++c)o[u[c]]=1}}}t+="Annotation(s): "+n+" ";var m=i.getSequencesAnnotations(void 0,!0,Object.keys(o));$("#"+i.pre+"dl_sequence").html(t+m.sequencesHtml),$("#"+i.pre+"dl_sequence").width(i.RESIDUE_WIDTH*m.maxSeqCnt+200),void 0!==i.cfg.align&&(m=i.getAlignSequencesAnnotations(void 0,!0,Object.keys(o)),$("#"+i.pre+"dl_sequence2").html(t+m.sequencesHtml),$("#"+i.pre+"dl_sequence2").width(i.RESIDUE_WIDTH*m.maxSeqCnt+200)),i.icn3d.highlightAtoms={};for(var s=0,g=e.length;g>s;++s){var r=i.icn3d.definedNames2Atoms[e[s]],f=i.icn3d.definedNames2Descr[e[s]],v=i.icn3d.definedNames2Command[e[s]];if(void 0!==v){if(-1!==v.indexOf("select ")&&(v=v.replace(/select /g,"")),0===s)$("#"+i.pre+"command").val(v),$("#"+i.pre+"command_name").val(e[s]),$("#"+i.pre+"command_desc").val(f);else{var b=$("#"+i.pre+"command").val;$("#"+i.pre+"command").val(b+" or "+v);var b=$("#"+i.pre+"command_name").val;$("#"+i.pre+"command_name").val(b+" or "+e[s]);var b=$("#"+i.pre+"command_desc").val;$("#"+i.pre+"command_desc").val(b+" or "+f)}for(var c=0,l=r.length;l>c;++c)i.icn3d.highlightAtoms[r[c]]=1}}i.icn3d.addHighlightObjects},exportCustomAtoms:function{for(var e=this,i="",t=Object.keys(e.icn3d.definedNames2Atoms).sort,n=0,o=t.length;o>n;++n){var s=t[n],r=e.icn3d.definedNames2Atoms[s],a=(e.icn3d.definedNames2Descr[s],e.icn3d.definedNames2Command[s]);a=a.replace(/,/g,", "),i+=s+"	select ";for(var c={},l=0,d=r.length;d>l;++l){var h=e.icn3d.atoms[r[l]],u=h.structure+"_"+h.chain+"_"+h.resi;c[u]=1}var p=Object.keys(c);i+=e.residueids2spec(p),i+="\n"}return i},residueids2spec:function(e){var i=this,t="";if(void 0!==e){for(var n,o,s,r,a,c,l,d=e.sort(function(e,i){if(""!==e&&!isNaN(e))return parseInt(e)-parseInt(i);var t=e.lastIndexOf("_"),n=i.lastIndexOf("_");if(e.substr(0,t)<i.substr(0,n))return-1;if(e.substr(0,t)>i.substr(0,n))return 1;if(e.substr(0,t)==i.substr(0,n)){if(parseInt(e.substr(t+1))<parseInt(i.substr(n+1)))return-1;if(parseInt(e.substr(t+1))>parseInt(i.substr(n+1)))return 1;if(parseInt(e.substr(t+1))==parseInt(i.substr(n+1)))return 0}}),h="",u=0,p=1==Object.keys(i.icn3d.structures).length?!1:!0,m=0,g=d.length;g>m;++m){var f=d[m];s=f.lastIndexOf("_"),n=f.substr(0,s),o=parseInt(f.substr(s+1)),r=h.indexOf("_"),a=h.substr(0,r),c=h.substr(r+1),h!==n?(m>0&&(t+=u===l?p?"#"+a+"."+c+":"+l+" or ":"."+c+":"+l+" or ":p?"#"+a+"."+c+":"+l+"-"+u+" or ":"."+c+":"+l+"-"+u+" or "),l=o):h===n&&o!==u+1&&(t+=u===l?p?"#"+a+"."+c+":"+l+" or ":"."+c+":"+l+" or ":p?"#"+a+"."+c+":"+l+"-"+u+" or ":"."+c+":"+l+"-"+u+" or ",l=o),h=n,u=o}r=h.indexOf("_"),a=h.substr(0,r),c=h.substr(r+1),t+=u===l?p?"#"+a+"."+c+":"+l:"."+c+":"+l:p?"#"+a+"."+c+":"+l+"-"+u:"."+c+":"+l+"-"+u}return t},showSelection:function(e){var i=this;i.icn3d.displayAtoms={},i.icn3d.displayAtoms=i.icn3d.cloneHash(i.icn3d.highlightAtoms);var t=i.icn3d.centerAtoms(i.icn3d.hash2Atoms(i.icn3d.displayAtoms));i.icn3d.maxD=t.maxD,i.icn3d.maxD<25&&(i.icn3d.maxD=25),i.icn3d.options.rotationcenter="display center",i.saveSelectionIfSelected,i.icn3d.draw},selectByCommand:function(e,i,t){for(var n=this,o="select"===e.trim.substr(0,6)?e.trim.substr(7):e.trim,s=o.split(" or "),r={},a=0,c=s.length;c>a;++a){var l=s[a].trim.replace(/\s+/g," "),d=l.indexOf(" ");n.icn3d.highlightAtoms={},"and"===l.substr(0,d).toLowerCase?(n.applyCommand("select "+l.substr(d+1)),r=n.icn3d.intersectHash(r,n.icn3d.highlightAtoms)):"not"===l.substr(0,d).toLowerCase?(n.applyCommand("select "+l.substr(d+1)),r=n.icn3d.excludeHash(r,n.icn3d.highlightAtoms)):(n.applyCommand("select "+l),r=n.icn3d.unionHash(r,n.icn3d.highlightAtoms))}n.icn3d.highlightAtoms=n.icn3d.cloneHash(r);var h=Object.keys(n.icn3d.highlightAtoms),u=Object.keys(n.icn3d.getResiduesFromAtoms(n.icn3d.highlightAtoms));if(""!==i){n.addCustomSelection(u,h,i,t,e,!0);var p=[i];n.changeCustomResidues(p),n.changeCustomAtoms(p)}},selectBySpec:function(e,i,t,n){var o=this;e="select"===e.trim.substr(0,6)?e.trim.substr(7):e.trim,o.icn3d.highlightAtoms={};for(var s=e.replace(/\s+/g," ").replace(/ AND /g," and ").split(" and "),r={},a={},c=!0,l=0,d=s.length;d>l;++l){var h,u,p,m,g={},f=s[l].indexOf("#"),v=s[l].indexOf("."),b=s[l].indexOf(":"),y=s[l].indexOf("@"),E=s[l];-1===y?m="*":(m=E.substr(y+1),E=E.substr(0,y)),-1===b?p="*":(p=E.substr(b+1),E=E.substr(0,b)),-1===v?u="*":(u=E.substr(v+1),E=E.substr(0,v)),-1===f?h="*":(h=E.substr(f+1),E=E.substr(0,f)),"*"!==m&&(c=!1);var _,w,C,S,k=[],R=[];if(k="*"===h?Object.keys(o.icn3d.structures):h.split(","),"*"===u)for(var T=Object.keys(o.icn3d.chains),H=0,A=T.length;A>H;++H)w=T[H],_=w.substr(0,w.indexOf("_")),-1!==k.toString.toLowerCase.indexOf(_.toLowerCase)&&R.push(w);else for(var H=0,A=k.length;A>H;++H){_=k[H];var x=u.split(",");for(var O in x)R.push(_+"_"+x[O])}for(var $=p.split(","),H=0,A=$.length;A>H;++H){var M,L=!1,I=$[H].indexOf("-"),D=!1;if(-1!==I)C=$[H].substr(0,I),S=$[H].substr(I+1),L=!0;else if(""===$[H]||isNaN($[H])){if("*"===$[H])D=!0;else if("proteins"!==$[H]&&"nucleotides"!==$[H]&&"ligands"!==$[H]&&"ions"!==$[H]&&"water"!==$[H]){var z=$[H].toUpperCase;M=1===$[H].length?z:o.icn3d.residueName2Abbr(z)}}else C=$[H],S=C,L=!0;for(var N=0,q=R.length;q>N;++N)if(w=R[N],L)for(var O=parseInt(C);O<=parseInt(S);++O){var j=w+"_"+O;0===l?r[j]=1:r[j]=void 0;for(var P in o.icn3d.residues[j])("*"===m||m===o.icn3d.atoms[P].name)&&(0===l?(g[P]=1,a[P]=1):(g[P]=void 0,a[P]=void 0))}else if(w in o.icn3d.chains){var a=o.icn3d.chains[w];for(var P in a){var z=o.icn3d.atoms[P].resn.substr(0,3).toUpperCase;(D||o.icn3d.residueName2Abbr(z)===M||"proteins"===$[H]&&P in o.icn3d.proteins||"nucleotides"===$[H]&&P in o.icn3d.nucleotides||"ligands"===$[H]&&P in o.icn3d.ligands||"ions"===$[H]&&P in o.icn3d.ions||"water"===$[H]&&P in o.icn3d.water)&&(r[w+"_"+o.icn3d.atoms[P].resi]=1,("*"===m||m===o.icn3d.atoms[P].name)&&(0===l?(g[P]=1,a[P]=1):(g[P]=void 0,a[P]=void 0)))}}}0===l?o.icn3d.highlightAtoms=o.icn3d.cloneHash(g):o.icn3d.highlightAtoms=o.icn3d.intersectHash(o.icn3d.highlightAtoms,g)}if((void 0===n||n)&&o.updateSeqWinForCurrentAtoms,""!==i){o.addCustomSelection(Object.keys(r),Object.keys(a),i,t,e,c);var F=[i];o.changeCustomResidues(F),o.changeCustomAtoms(F)}},pickCustomSphere:function(e){var i=this;i.clearSelection;var t="select zone cutoff "+e,n={};for(var o in i.icn3d.highlightAtoms)n[o]=i.icn3d.atoms[o];var s=i.icn3d.getAtomsWithinAtom(i.icn3d.atoms,n,parseFloat(e)),r={},a=[];for(var o in s){var c=s[o],l=c.structure+"_"+c.chain+"_"+c.resi;r[l]=1,a.push(o)}var d=Object.keys(r);i.icn3d.highlightAtoms={};for(var h=0,u=d.length;u>h;++h){var l=d[h];for(var o in i.icn3d.residues[l])i.icn3d.highlightAtoms[o]=1}i.icn3d.displayAtoms=i.icn3d.cloneHash(i.icn3d.atoms);var p,m,g=i.icn3d.getFirstAtomObj(n);p="sphere."+g.chain+":"+i.icn3d.residueName2Abbr(g.resn.substr(0,3))+g.resi+"-"+$("#"+i.pre+"radius_aroundsphere").val+"A",m="select a sphere around currently selected "+Object.keys(i.icn3d.highlightAtoms).length+" atoms with a radius of "+e+" angstrom",i.addCustomSelection(d,a,p,m,t,!0);var f=[p];i.changeCustomResidues(f),i.saveSelectionIfSelected,i.icn3d.draw},showHbonds:function(e){var i=this;i.icn3d.options.hbonds="yes";var t="hbonds "+e,n={};for(var o in i.icn3d.atoms)!i.icn3d.highlightAtoms.hasOwnProperty(o)&&i.icn3d.displayAtoms.hasOwnProperty(o)&&(n[o]=i.icn3d.atoms[o]);var s=i.icn3d.getFirstAtomObj(i.icn3d.highlightAtoms);if(Object.keys(n).length>0&&Object.keys(i.icn3d.highlightAtoms).length>0){i.icn3d.calculateLigandHbonds(n,i.icn3d.intersectHash2Atoms(i.icn3d.displayAtoms,i.icn3d.highlightAtoms),parseFloat(e)),i.clearSelection;var r={},a=[];for(var o in i.icn3d.highlightAtoms){var c=i.icn3d.atoms[o].structure+"_"+i.icn3d.atoms[o].chain+"_"+i.icn3d.atoms[o].resi;r[c]=1,a.push(o)}var l="hbonds_"+s.serial,d="all atoms that are hydrogen-bonded with the selected atoms";i.addCustomSelection(Object.keys(r),a,l,d,t,!0);var h=[l];i.changeCustomResidues(h),i.saveSelectionIfSelected,i.icn3d.draw}},addLabel:function(e,i,t,n,o,s,r,a){var c=this,l={},d=new THREE.Vector3;d.x=i,d.y=t,d.z=n,l.position=d,l.text=e,l.size=o,l.color=s,l.background=r,void 0===c.icn3d.labels[a]&&(c.icn3d.labels[a]=[]),void 0!==a?c.icn3d.labels[a].push(l):c.icn3d.labels.custom.push(l),c.icn3d.removeHighlightObjects},addLine:function(e,i,t,n,o,s,r,a,c){var l=this,d={};d.position1=new THREE.Vector3(e,i,t),d.position2=new THREE.Vector3(n,o,s),d.color=r,d.dashed=a,void 0===l.icn3d.lines[c]&&(l.icn3d.lines[c]=[]),void 0!==c?l.icn3d.lines[c].push(d):l.icn3d.lines.custom.push(d),l.icn3d.removeHighlightObjects},selectAChain:function(e,i){var t=this,i=i.replace(/\s/g,""),n="select chain "+e,o=[],s=[];t.icn3d.removeHighlightObjects,t.icn3d.highlightAtoms={};for(var r in t.icn3d.chainsSeq[e]){var a=t.icn3d.chainsSeq[e][r],c=e+"_"+a.resi,l=a.name;if(""!==l&&"-"!==l){o.push(c);for(var d in t.icn3d.residues[c])s.push(d),t.icn3d.highlightAtoms[d]=1}}t.addCustomSelection(o,s,i,i,n,!0),t.icn3d.addHighlightObjects},selectAAlignChain:function(e,i){var t=this,n=i.replace(/\s/g,""),o="Selection from chain annotation in 'Select Residue' dialog",s=[],r=[];t.icn3d.removeHighlightObjects,t.icn3d.highlightAtoms={};for(var a in t.icn3d.alignChainsSeq[e]){var c=t.icn3d.alignChainsSeq[e][a],l=e+"_"+c.resi;c.resn;if(""!==c.resi){s.push(l);for(var d in t.icn3d.residues[l])r.push(d),t.icn3d.highlightAtoms[d]=1}}t.addCustomSelection(s,r,n,i,o,!0),t.icn3d.addHighlightObjects},selectAResidue:function(e,i){var t=this,i=i.replace(/\s/g,""),n="select residue "+e,o=[],s=[];o.push(e);for(var r in t.icn3d.residues[e])s.push(r),t.icn3d.highlightAtoms[r]=1;t.addCustomSelection(o,s,i,i,n,!0)},selectResidueList:function(e,i,t){var n=this;if(Object.keys(e).length>0){var i=i.replace(/\s/g,""),o="select "+n.residueids2spec(Object.keys(e)),s=Object.keys(e),r=[];for(var a in e)for(var c in n.icn3d.residues[a])r.push(c),n.icn3d.highlightAtoms[c]=1;n.addCustomSelection(s,r,i,t,o,!0)}},back:function{var e=this;e.STATENUMBER--,e.bAddCommands=!1,e.bAddLogs=!1,e.bNotLoadStructure=!0,e.STATENUMBER<1?e.STATENUMBER=1:e.execCommands(e.STATENUMBER),e.adjustIcon,e.bAddCommands=!0,e.bAddLogs=!0},forward:function{var e=this;e.STATENUMBER++,e.bAddCommands=!1,e.bAddLogs=!1,e.bNotLoadStructure=!0,e.STATENUMBER>e.icn3d.commands.length?e.STATENUMBER=e.icn3d.commands.length:e.execCommands(e.STATENUMBER),e.adjustIcon,e.bAddCommands=!0,e.bAddLogs=!0},toggleSelection:function{var e=this;if(e.bHideSelection){for(var i in e.icn3d.displayAtoms)e.icn3d.highlightAtoms.hasOwnProperty(i)&&delete e.icn3d.displayAtoms[i];e.bHideSelection=!1}else e.icn3d.displayAtoms=e.icn3d.unionHash(e.icn3d.displayAtoms,e.icn3d.highlightAtoms),e.bHideSelection=!0;e.icn3d.draw},alternateStructures:function{var e=this;e.icn3d.displayAtoms={};for(var i=Object.keys(e.icn3d.highlightAtoms).length,t=Object.keys(e.icn3d.atoms).length,n=Object.keys(e.icn3d.structures),o=0,s=n.length;s>o;++o){var r=n[o];if(o>e.ALTERNATE_STRUCTURE||e.ALTERNATE_STRUCTURE===s-1&&0===o){for(var a in e.icn3d.structures[r]){var c=e.icn3d.structures[r][a];e.icn3d.displayAtoms=e.icn3d.unionHash(e.icn3d.displayAtoms,e.icn3d.chains[c])}e.ALTERNATE_STRUCTURE=o;break}}t>i&&(e.icn3d.displayAtoms=e.icn3d.intersectHash(e.icn3d.displayAtoms,e.icn3d.highlightAtoms),e.icn3d.bShowHighlight=!1,e.icn3d.options.rotationcenter="highlight center"),e.icn3d.draw,e.icn3d.bShowHighlight=!0,e.icn3d.options.rotationcenter="molecule center"},adjustIcon:function{var e=this;1===e.STATENUMBER?$("#"+e.pre+"back").hasClass("icn3d-middleIcon")&&($("#"+e.pre+"back").toggleClass("icn3d-middleIcon"),$("#"+e.pre+"back").toggleClass("icn3d-endIcon")):$("#"+e.pre+"back").hasClass("icn3d-endIcon")&&($("#"+e.pre+"back").toggleClass("icn3d-middleIcon"),$("#"+e.pre+"back").toggleClass("icn3d-endIcon")),e.STATENUMBER===e.icn3d.commands.length?$("#"+e.pre+"forward").hasClass("icn3d-middleIcon")&&($("#"+e.pre+"forward").toggleClass("icn3d-middleIcon"),$("#"+e.pre+"forward").toggleClass("icn3d-endIcon")):$("#"+e.pre+"forward").hasClass("icn3d-endIcon")&&($("#"+e.pre+"forward").toggleClass("icn3d-middleIcon"),$("#"+e.pre+"forward").toggleClass("icn3d-endIcon"))},toggle:function(e,i,t,n){$("#"+e).toggleClass("ui-icon-plus"),$("#"+e).toggleClass("ui-icon-minus"),$("#"+i).toggleClass("ui-icon-plus"),$("#"+i).toggleClass("ui-icon-minus"),$("#"+e).toggleClass("icn3d-shown"),$("#"+e).toggleClass("icn3d-hidden"),$("#"+i).toggleClass("icn3d-shown"),$("#"+i).toggleClass("icn3d-hidden"),$("#"+t).toggleClass("icn3d-shown"),$("#"+t).toggleClass("icn3d-hidden"),$("#"+n).toggleClass("icn3d-shown"),$("#"+n).toggleClass("icn3d-hidden")},loadScript:function(e,i){var t=this;t.icn3d.bRender=!1,t.icn3d.bStopRotate=!0,e=e.replace(/;/g,"\n");var n=[];t.icn3d.commands.length>0&&(n[0]=t.icn3d.commands[0]),t.icn3d.commands=e.split("\n"),t.STATENUMBER=t.icn3d.commands.length,void 0!==i&&i?(t.icn3d.commands=n.concat(t.icn3d.commands),t.STATENUMBER=t.icn3d.commands.length,t.execCommands(t.STATENUMBER)):(t.execCommands(t.STATENUMBER),t.icn3d.commands=n.concat(t.icn3d.commands),t.STATENUMBER=t.icn3d.commands.length)},loadSelection:function(e){for(var i=this,t=e.trim.split("\n"),n=0,o=t.length;o>n;++n){var s=t[n].split("	"),r=s[0],a=s[1],c=a.indexOf(" ");i.selectByCommand(a.substr(c+1),r,r,!1)}},execCommandsBase:function(e,i,t){for(var n=this,o=e;i>=o;++o){if(-1!==n.icn3d.commands[o].indexOf("load"))return 0===i&&e===i?void(n.bNotLoadStructure?(n.icn3d.highlightAtoms=n.icn3d.cloneHash(n.icn3d.atoms),n.icn3d.bRender=!0,1===n.icn3d.commands.length&&(n.bAddCommands=!0),n.renderFinalStep(t)):$.when(n.applyCommandLoad(n.icn3d.commands[o])).then(function{n.icn3d.bRender=!0,1===n.icn3d.commands.length&&(n.bAddCommands=!0),n.renderFinalStep(t)})):void(n.bNotLoadStructure?(n.icn3d.highlightAtoms=n.icn3d.cloneHash(n.icn3d.atoms),n.execCommandsBase(o+1,i,t)):$.when(n.applyCommandLoad(n.icn3d.commands[o])).then(function{n.execCommandsBase(o+1,i,t)}));n.applyCommand(n.icn3d.commands[o]),o===t-1&&(n.icn3d.bRender=!0,o+1===n.icn3d.commands.length&&(n.bAddCommands=!0),n.renderFinalStep(t))}},renderFinalStep:function(e){var i=this,t=i.icn3d.commands[e-1].split("|||");if(2==t.length){var n=JSON.parse(t[1]);i.icn3d._zoomFactor=n.factor,i.icn3d.mouseChange.x=n.mouseChange.x,i.icn3d.mouseChange.y=n.mouseChange.y,i.icn3d.quaternion._x=n.quaternion._x,i.icn3d.quaternion._y=n.quaternion._y,i.icn3d.quaternion._z=n.quaternion._z,i.icn3d.quaternion._w=n.quaternion._w}if(void 0===i.cfg.command&&(1===e||Object.keys(i.icn3d.highlightAtoms).length===Object.keys(i.icn3d.atoms).length||void 0!==i.icn3d.optionsHistory[e-1]&&i.icn3d.optionsHistory[e-1].hasOwnProperty("hlatomcount")&&i.icn3d.optionsHistory[e-1].hlatomcount===Object.keys(i.icn3d.atoms).length))if(i.icn3d.setAtomStyleByOptions(i.icn3d.optionsHistory[e-1]),i.icn3d.setColorByOptions(i.icn3d.optionsHistory[e-1],i.icn3d.highlightAtoms),i.icn3d.optionsHistory.length>=e){var o=i.icn3d.optionsHistory[e-1].picking;"no"===o?i.icn3d.picking=0:"atom"===o?i.icn3d.picking=1:"residue"===o?i.icn3d.picking=2:"strand"===o&&(i.icn3d.picking=3),1===e&&i.icn3d.applyOriginalColor,i.updateSeqWinForCurrentAtoms,i.icn3d.draw(i.icn3d.optionsHistory[e-1])}else i.updateSeqWinForCurrentAtoms,i.icn3d.draw;else i.icn3d.draw},execCommands:function(e){var i=this;i.icn3d.bRender=!1,i.icn3d.reinitAfterLoad,i.icn3d.options=i.icn3d.cloneHash(i.options),i.execCommandsBase(0,e-1,e)},applyCommandLoad:function(e){var i=this;return i.deferred2=$.Deferred(function{i.bAddCommands=!1;var t=e.split("|||"),n=t[0].replace(/\s\s/g," ").trim,o=n.toLowerCase;if(-1!==o.indexOf("load")){var s=o.split(" | "),r=s[0];if(s.length>1){var a=s[1].indexOf(" "); i.cfg.inpara=s[1].substr(a+1)}var c=r.substr(r.lastIndexOf(" ")+1);-1!==o.indexOf("pdb")?(i.downloadPdb(c),i.cfg.pdbid=c):-1!==o.indexOf("mmcif")?(i.downloadMmcif(c),i.cfg.mmcifid=c):-1!==o.indexOf("mmdb")?(i.downloadMmdb(c),i.cfg.mmdbid=c):-1!==o.indexOf("gi")?(i.downloadGi(c),i.cfg.gi=c):-1!==o.indexOf("cid")?(i.downloadCid(c),i.cfg.cid=c):-1!==o.indexOf("align")&&(i.downloadAlignment(c),i.cfg.align=c)}i.bAddCommands=!0}),i.deferred2},applyCommand:function(e){var i=this;i.bAddCommands=!1;var t=e.split("|||"),n=t[0].replace(/\s+/g," ").trim,o=n.toLowerCase,s=!0;if(-1!==o.indexOf("export state file"));else if(-1!==n.indexOf("select structure")){var r=n.substr(n.lastIndexOf(" ")+1).split(",");null!==r&&i.changeStructureid(r)}else if(-1!==n.indexOf("select chain")){var r=n.substr(n.lastIndexOf(" ")+1).split(",");null!==r&&i.changeChainid(r)}else if(-1!==n.indexOf("select alignChain")){var r=n.substr(n.lastIndexOf(" ")+1).split(",");null!==r&&i.changeAlignChainid(r)}else if(-1!==n.indexOf("select residue")){var r=n.substr(n.lastIndexOf(" ")+1).split(",");null!==r&&i.changeResidueid(r)}else if(-1!==n.indexOf("select saved selection")){var r=n.substr(n.lastIndexOf(" ")+1).split(",");null!==r&&i.changeCustomResidues(r)}else if(-1!==n.indexOf("select saved atoms")){var r=n.substr(n.lastIndexOf(" ")+1).split(",");null!==r&&i.changeCustomAtoms(r)}else if(-1!==o.indexOf("show selection"))i.showSelection;else if(-1!==o.indexOf("select")&&-1!==o.indexOf("name")){for(var a=n.split(" | "),c="",l="",d="",h=0,u=a.length;u>h;++h){var p=a[h];-1!==p.indexOf("select")?c=p.substr(p.indexOf(" ")+1):-1!==p.indexOf("name")?l=p.substr(p.indexOf(" ")+1):-1!==p.indexOf("description")&&(d=p.substr(p.indexOf(" ")+1))}a.length<3&&(d=l),i.selectByCommand(c,l,d)}else if(-1!==o.indexOf("select #")||-1!==o.indexOf("select .")||-1!==o.indexOf("select :")||-1!==o.indexOf("select @")){var a=n.split(" | "),c=a[0].substr(a[0].indexOf(" ")+1),l="",d="";3===a.length&&(l=a[1].substr(a[1].indexOf(" ")+1),d=a[2].substr(a[2].indexOf(" ")+1)),-1!==c.indexOf(" or ")?i.selectByCommand(c,l,d):i.selectBySpec(c,l,d)}else if(-1!==o.indexOf("set picking atom"))i.icn3d.picking=1,i.icn3d.options.picking="atom";else if(-1!==o.indexOf("set picking off"))i.icn3d.picking=0,i.icn3d.options.picking="no",i.icn3d.draw,i.icn3d.removeHighlightObjects;else if(-1!==o.indexOf("set picking residue"))i.icn3d.picking=2,i.icn3d.options.picking="residue";else if(-1!==o.indexOf("set picking strand"))i.icn3d.picking=3,i.icn3d.options.picking="strand";else if(-1!==o.indexOf("pickatom")){var m=parseInt(o.substr(o.lastIndexOf(" ")+1));i.icn3d.pickedatom=i.icn3d.atoms[m],i.icn3d.showPicking(i.icn3d.pickedatom)}else if(-1!==o.indexOf("select zone cutoff")){var g=o.substr(o.lastIndexOf(" ")+1);i.pickCustomSphere(g)}else if(-1!==o.indexOf("style")){var f=o.substr(o.indexOf(" ")+1),v=f.substr(0,f.indexOf(" ")),b=f.substr(f.indexOf(" ")+1);i.setStyle(v,b)}else if(0===o.indexOf("color")){var y=o.substr(o.indexOf(" ")+1);i.icn3d.options.color=y,i.icn3d.setColorByOptions(i.icn3d.options,i.icn3d.highlightAtoms),i.updateSeqWinForCurrentAtoms}else if(-1!==o.indexOf("set surface wireframe on"))i.icn3d.options.wireframe="yes",i.icn3d.applySurfaceOptions;else if(-1!==o.indexOf("set surface wireframe off"))i.icn3d.options.wireframe="no",i.icn3d.applySurfaceOptions;else if(-1!==o.indexOf("set surface opacity")){var E=o.substr(o.lastIndexOf(" ")+1);i.icn3d.options.opacity=E,i.icn3d.applySurfaceOptions}else if(-1!==o.indexOf("set surface neighbors on"))i.icn3d.bConsiderNeighbors=!0,i.icn3d.applySurfaceOptions;else if(-1!==o.indexOf("set surface neighbors off"))i.icn3d.bConsiderNeighbors=!1,i.icn3d.applySurfaceOptions;else if(-1!==o.indexOf("set surface")){var E=o.substr(12);i.icn3d.options.surface=E,i.icn3d.applySurfaceOptions}else if(-1!==o.indexOf("set camera")){var E=o.substr(o.lastIndexOf(" ")+1);i.icn3d.options.camera=E}else if(-1!==o.indexOf("set background")){var E=o.substr(o.lastIndexOf(" ")+1);i.icn3d.options.background=E}else if(-1!==o.indexOf("set axis on"))i.icn3d.options.axis="yes";else if(-1!==o.indexOf("set axis off"))i.icn3d.options.axis="no";else if(-1!==o.indexOf("set fog on"))i.icn3d.options.fog="yes";else if(-1!==o.indexOf("set fog off"))i.icn3d.options.fog="no";else if(-1!==o.indexOf("set slab on"))i.icn3d.options.slab="yes";else if(-1!==o.indexOf("set slab off"))i.icn3d.options.slab="no";else if("reset"===o)i.icn3d.reinitAfterLoad,i.renderFinalStep(1);else if("reset orientation"===o)i.icn3d.resetOrientation;else if(-1!==o.indexOf("toggle highlight"))i.icn3d.prevHighlightObjects.length>0?(i.icn3d.removeHighlightObjects,i.icn3d.bShowHighlight=!1):(i.icn3d.addHighlightObjects,i.icn3d.bShowHighlight=!0);else if(-1!==o.indexOf("clear selection"))i.icn3d.removeHighlightObjects,i.icn3d.bShowHighlight=!1;else if(-1!==o.indexOf("set assembly on"))i.icn3d.bAssembly=!0;else if(-1!==o.indexOf("set assembly off"))i.icn3d.bAssembly=!1;else if(-1!==n.indexOf("add label")){var a=n.split(" | "),_=a[0].substr("add label".length+1);if(6==a.length){var w=a[1].split(" "),C=w[1],S=w[3],k=w[5],R=a[2].substr(a[2].lastIndexOf(" ")+1),y=a[3].substr(a[3].lastIndexOf(" ")+1),T=a[4].substr(a[4].lastIndexOf(" ")+1),H=a[5].substr(a[5].lastIndexOf(" ")+1);("0"===R||""===R||"undefined"===R)&&(R=void 0),("0"===y||""===y||"undefined"===y)&&(y=void 0),("0"===T||""===T||"undefined"===T)&&(T=void 0),i.addLabel(_,C,S,k,R,y,T,H),i.icn3d.draw}else if(5==a.length){var A=i.icn3d.centerAtoms(i.icn3d.hash2Atoms(i.icn3d.highlightAtoms)),C=A.center.x,S=A.center.y,k=A.center.z,R=a[1].substr(a[1].lastIndexOf(" ")+1),y=a[2].substr(a[2].lastIndexOf(" ")+1),T=a[3].substr(a[3].lastIndexOf(" ")+1),H=a[4].substr(a[4].lastIndexOf(" ")+1);("0"===R||""===R||"undefined"===R)&&(R=void 0),("0"===y||""===y||"undefined"===y)&&(y=void 0),("0"===T||""===T||"undefined"===T)&&(T=void 0),i.addLabel(_,C,S,k,R,y,T,H),i.icn3d.draw}}else if(-1!==o.indexOf("add residue labels"))i.icn3d.addResiudeLabels(i.icn3d.highlightAtoms),i.icn3d.draw;else if(-1!==o.indexOf("add line")){var a=o.split(" | "),x=a[1].split(" "),O=a[2].split(" "),y=a[3].substr(a[3].lastIndexOf(" ")+1),$="true"===a[4].substr(a[4].lastIndexOf(" ")+1)?!0:!1,H=a[5].substr(a[5].lastIndexOf(" ")+1);i.addLine(x[1],x[3],x[5],O[1],O[3],O[5],y,$,H)}else if(-1!==o.indexOf("zoom selection"))i.icn3d.zoominSelection;else if(-1!==o.indexOf("center selection"))i.icn3d.centerSelection;else if(-1!==o.indexOf("rotate left"))i.icn3d.bStopRotate=!1,i.ROTATION_DIRECTION="left",i.rotateStructure("left");else if(-1!==o.indexOf("rotate right"))i.icn3d.bStopRotate=!1,i.ROTATION_DIRECTION="right",i.rotateStructure("right");else if(-1!==o.indexOf("rotate up"))i.icn3d.bStopRotate=!1,i.ROTATION_DIRECTION="up",i.rotateStructure("up");else if(-1!==o.indexOf("rotate down"))i.icn3d.bStopRotate=!1,i.ROTATION_DIRECTION="down",i.rotateStructure("down");else if(-1!==o.indexOf("hbonds")){var M=o.substr(o.lastIndexOf(" ")+1);i.showHbonds(M)}else if(-1!==o.indexOf("set hbonds off"))i.icn3d.options.hbonds="no",i.icn3d.draw;else if(-1!==o.indexOf("set lines off"))i.icn3d.draw;else if(-1!==o.indexOf("set labels off"))i.icn3d.draw;else if(-1!==o.indexOf("back"))i.back;else if(-1!==o.indexOf("forward"))i.forward;else if(-1!==o.indexOf("toggle selection"))i.toggleSelection;else if(-1!==o.indexOf("select all"))i.selectAll;else if(-1!==o.indexOf("select complement"))i.selectComplement;else if(-1!==o.indexOf("set highlight color")){var y=o.substr(20);"yellow"===y?(i.icn3d.highlightColor=new THREE.Color(16776960),i.icn3d.matShader=i.icn3d.setOutlineColor("yellow")):"green"===y?(i.icn3d.highlightColor=new THREE.Color(65280),i.icn3d.matShader=i.icn3d.setOutlineColor("green")):"red"===y&&(i.icn3d.highlightColor=new THREE.Color(16711680),i.icn3d.matShader=i.icn3d.setOutlineColor("red")),i.icn3d.draw}else if(-1!==o.indexOf("set highlight style")){var b=o.substr(20);"outline"===b?i.icn3d.bHighlight=1:"3d"===b&&(i.icn3d.bHighlight=2),i.icn3d.draw}else-1!==o.indexOf("output selection")&&i.outputSelection;s&&i.setLogCommand(n,!1),i.bAddCommands=!0},setTopMenusHtml:function(e){var i=this,t="";t+=" ",t+=" ",t+="  <div id='"+i.pre+"menulist' style='position:absolute; z-index:999; float:left; display:table-row; margin: 3px 0px 0px 3px;'>",t+="     ",t+="  ",t+=i.setTools,t+="  <div id='"+i.pre+"title' class='icn3d-commandTitle' style='position:absolute; z-index:1; float:left; display:table-row; margin: 85px 0px 0px 5px; color: "+i.GREYD+"'> ",t+="  <div id='"+i.pre+"viewer' style='position:relative; width:100%; height:100%; background-color: "+i.GREYD+";'>",t+="   <div id='"+i.pre+"menuLogSection'>",t+="    <div style='height: "+i.MENU_HEIGHT+"px;'> ",t+="    <div style='height: "+i.MENU_HEIGHT+"px;'> ",t+="   ",t+="    <div id='"+i.pre+"wait' style='position:absolute; top:180px; left:100px; font-size: 2em; color: #444444;'>Loading the structure... ",t+="    <canvas id='"+i.pre+"canvas' style='width:100%; height: 100%; background-color: #000;'>Your browser does not support WebGL. ",t+=i.setLogWindow,t+=" ",t+=" ",t+=i.setDialogs,t+=i.setCustomDialogs,$("#"+e).html(t),$("accordion").accordion({collapsible:!0,active:!1,heightStyle:"content"}),$("accordion div").removeClass("ui-accordion-content ui-corner-all ui-corner-bottom ui-widget-content"),$(".menu").menu({position:{my:"left top",at:"right top"}}),$(".menu").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+"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")})},setMenu1:function{var e=this,i="";return i+="    ",i+="          <accordion id='"+e.pre+"accordion1'>",i+="              File ",i+="              ",i+="              <ul class='menu'>",i+="                <li>Retrieve by ID",i+="                  <ul>",i+="                    <li><span id='"+e.pre+"menu1_pdbid' class='icn3d-link'>PDB ID </li>",i+="                    <li><span id='"+e.pre+"menu1_mmcifid' class='icn3d-link'>mmCIF ID </li>",i+="                    <li><span id='"+e.pre+"menu1_mmdbid' class='icn3d-link'>MMDB ID </li>",i+="                    <li><span id='"+e.pre+"menu1_gi' class='icn3d-link'>gi </li>",i+="                    <li><span id='"+e.pre+"menu1_cid' class='icn3d-link'>PubChem CID </li>",i+="                  </ul>",i+="                </li>",i+="                <li>Open File",i+="                  <ul>",i+="                    <li><span id='"+e.pre+"menu1_pdbfile' class='icn3d-link'>PDB File </li>",i+="                    <li><span id='"+e.pre+"menu1_mmciffile' class='icn3d-link'>mmCIF File </li>",i+="                    <li><span id='"+e.pre+"menu1_mol2file' class='icn3d-link'>Mol2 File </li>",i+="                    <li><span id='"+e.pre+"menu1_sdffile' class='icn3d-link'>SDF File </li>",i+="                    <li><span id='"+e.pre+"menu1_xyzfile' class='icn3d-link'>XYZ File </li>",i+="                    <li>-</li>",i+="                    <li><span id='"+e.pre+"menu1_state' class='icn3d-link'>State/Script File </li>",i+="                    <li><span id='"+e.pre+"menu1_selection' class='icn3d-link'>Selection File </li>",i+="                  </ul>",i+="                </li>",i+="                <li>Save File",i+="                  <ul>",i+="                    <li><span id='"+e.pre+"menu1_exportState' class='icn3d-link'>State File  </li>",i+="                    <li><span id='"+e.pre+"menu1_exportSelections' class='icn3d-link'>Selection File </li>",i+="                    <li><span id='"+e.pre+"menu1_exportCanvas' class='icn3d-link'>PNG Image File </li>",i+="                    <li>-</li>",i+="                    <li><span id='"+e.pre+"menu1_exportCounts' class='icn3d-link'>Residue Counts </li>",i+="                  </ul>",i+="                </li>",i+="                <li><span id='"+e.pre+"menu1_sharelink' class='icn3d-link'>Share Link </li>",void 0!==e.cfg.cid?(i+="                <li>Links",i+="                  <ul>",i+="                    <li><span id='"+e.pre+"menu1_link_structure' class='icn3d-link'>Compound Summary </li>",i+="                    <li><span id='"+e.pre+"menu1_link_vast' class='icn3d-link'>Similar Compounds </li>",i+="                    <li><span id='"+e.pre+"menu1_link_bind' class='icn3d-link'>Structures Bound </li>",i+="                  </ul>",i+="                </li>"):(i+="                <li>Links",i+="                  <ul>",i+="                    <li><span id='"+e.pre+"menu1_link_structure' class='icn3d-link'>Structure Summary </li>",i+="                    <li><span id='"+e.pre+"menu1_link_vast' class='icn3d-link'>Similar Structures </li>",i+="                    <li><span id='"+e.pre+"menu1_link_pubmed' class='icn3d-link'>Literature </li>",i+="                  </ul>",i+="                </li>"),i+="              </ul>",i+="              ",i+="          ",i+="    "},setMenu2:function{var e=this,i="";return i+="    ",i+="          <accordion id='"+e.pre+"accordion2'>",i+="              Select ",i+="              ",i+="              <ul class='menu'>",i+="                      <li><input type='radio' name='"+e.pre+"menu2_select' id='"+e.pre+"menu2_command'><label for='"+e.pre+"menu2_command'>Advanced </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu2_select' id='"+e.pre+"menu2_aroundsphere'><label for='"+e.pre+"menu2_aroundsphere'>by Distance </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu2_select' id='"+e.pre+"menu2_selectcomplement'><label for='"+e.pre+"menu2_selectcomplement'>Complement </li>",void 0===e.cfg.cid&&(i+="                      <li><input type='radio' name='"+e.pre+"menu2_select' id='"+e.pre+"menu2_select_chain'><label for='"+e.pre+"menu2_select_chain'>Chain </li>"),i+="                      <li><input type='radio' name='"+e.pre+"menu2_select' id='"+e.pre+"menu2_selectall'><label for='"+e.pre+"menu2_selectall'>All </li>",void 0===e.cfg.cid&&(i+="                      <li><input type='radio' name='"+e.pre+"menu2_select' id='"+e.pre+"menu2_selectresidues'><label for='"+e.pre+"menu2_selectresidues'>Sequence </li>"),void 0!==e.cfg.align&&(i+="                      <li><input type='radio' name='"+e.pre+"menu2_select' id='"+e.pre+"menu2_alignment'><label for='"+e.pre+"menu2_alignment'>Aligned Seq. </li>"),i+='               <li>Picking with "Alt" + Click',i+="                  <ul>",void 0===e.cfg.cid?(i+="                      <li><input type='radio' name='"+e.pre+"menu2_picking' id='"+e.pre+"menu2_pickingStrand'><label for='"+e.pre+"menu2_pickingStrand'>Strand/Helix </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu2_picking' id='"+e.pre+"menu2_pickingResidue' checked><label for='"+e.pre+"menu2_pickingResidue'>Residue </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu2_picking' id='"+e.pre+"menu2_pickingYes'><label for='"+e.pre+"menu2_pickingYes'>Atom </li>"):(i+="                      <li><input type='radio' name='"+e.pre+"menu2_picking' id='"+e.pre+"menu2_pickingStrand'><label for='"+e.pre+"menu2_pickingStrand'>Strand/Helix (Alt) </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu2_picking' id='"+e.pre+"menu2_pickingResidue'><label for='"+e.pre+"menu2_pickingResidue'>Residue (Alt) </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu2_picking' id='"+e.pre+"menu2_pickingYes' checked><label for='"+e.pre+"menu2_pickingYes'>Atom (Alt) </li>"),i+="                  </ul>",i+="                </li>",i+="                <li>Display",i+="                  <ul>",void 0!==e.cfg.align&&(i+="                      <li><input type='radio' name='"+e.pre+"menu2_display' id='"+e.pre+"menu2_alternate'><label for='"+e.pre+"menu2_alternate'>Alternate Selection </li>"),i+="                      <li><input type='radio' name='"+e.pre+"menu2_display' id='"+e.pre+"menu2_show_selected'><label for='"+e.pre+"menu2_show_selected'>Display Selection </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu2_display' id='"+e.pre+"menu2_selectedcenter'><label for='"+e.pre+"menu2_selectedcenter'>Zoom in Selection </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu2_display' id='"+e.pre+"toggleHighlight2'><label for='"+e.pre+"toggleHighlight2'>Toggle Highlight </li>",i+="                  </ul>",i+="                </li>",i+="                    <li>Highlight Color",i+="                      <ul>",i+="                        <li><input type='radio' name='"+e.pre+"menu2_hl_color' id='"+e.pre+"menu2_hl_colorYellow' checked><label for='"+e.pre+"menu2_hl_colorYellow'>Yellow </li>",i+="                        <li><input type='radio' name='"+e.pre+"menu2_hl_color' id='"+e.pre+"menu2_hl_colorGreen'><label for='"+e.pre+"menu2_hl_colorGreen'>Green </li>",i+="                        <li><input type='radio' name='"+e.pre+"menu2_hl_color' id='"+e.pre+"menu2_hl_colorRed'><label for='"+e.pre+"menu2_hl_colorRed'>Red </li>",i+="                      </ul>",i+="                    </li>",i+="                    <li>Highlight Style",i+="                      <ul>",Detector.webgl?(i+="                        <li><input type='radio' name='"+e.pre+"menu2_hl_style' id='"+e.pre+"menu2_hl_styleOutline' checked><label for='"+e.pre+"menu2_hl_styleOutline'>Outline </li>",i+="                        <li><input type='radio' name='"+e.pre+"menu2_hl_style' id='"+e.pre+"menu2_hl_styleObject'><label for='"+e.pre+"menu2_hl_styleObject'>3D Objects </li>"):(i+="                        <li><input type='radio' name='"+e.pre+"menu2_hl_style' id='"+e.pre+"menu2_hl_styleOutline'><label for='"+e.pre+"menu2_hl_styleOutline'>Outline </li>",i+="                        <li><input type='radio' name='"+e.pre+"menu2_hl_style' id='"+e.pre+"menu2_hl_styleObject' checked><label for='"+e.pre+"menu2_hl_styleObject'>3D Objects </li>"),i+="                      </ul>",i+="                    </li>",i+="              </ul>",i+="              ",i+="          ",i+="    "},setMenu3:function{var e=this,i="";return i+="    ",i+="          <accordion id='"+e.pre+"accordion3'>",i+="              Style ",i+="              ",i+="              <ul class='menu'>",void 0===e.cfg.cid?(void 0!==e.cfg.align?(i+="                <li>Proteins",i+="                  <ul>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_proteins' id='"+e.pre+"menu3_proteinsRibbon'><label for='"+e.pre+"menu3_proteinsRibbon'>Ribbon </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_proteins' id='"+e.pre+"menu3_proteinsStrand'><label for='"+e.pre+"menu3_proteinsStrand'>Strand </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_proteins' id='"+e.pre+"menu3_proteinsCylinder'><label for='"+e.pre+"menu3_proteinsCylinder'>Cylinder and Plate </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_proteins' id='"+e.pre+"menu3_proteinsSchematic'><label for='"+e.pre+"menu3_proteinsSchematic'>Schematic </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_proteins' id='"+e.pre+"menu3_proteinsCalpha' checked><label for='"+e.pre+"menu3_proteinsCalpha'>C Alpha Trace </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_proteins' id='"+e.pre+"menu3_proteinsBfactor'><label for='"+e.pre+"menu3_proteinsBfactor'>B Factor Tube </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_proteins' id='"+e.pre+"menu3_proteinsLines'><label for='"+e.pre+"menu3_proteinsLines'>Lines </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_proteins' id='"+e.pre+"menu3_proteinsStick'><label for='"+e.pre+"menu3_proteinsStick'>Stick </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_proteins' id='"+e.pre+"menu3_proteinsBallstick'><label for='"+e.pre+"menu3_proteinsBallstick'>Ball and Stick </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_proteins' id='"+e.pre+"menu3_proteinsSphere'><label for='"+e.pre+"menu3_proteinsSphere'>Sphere </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_proteins' id='"+e.pre+"menu3_proteinsNothing'><label for='"+e.pre+"menu3_proteinsNothing'>Hide </li>",i+="                  </ul>",i+="                </li>"):(i+="                <li>Protein",i+="                  <ul>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_proteins' id='"+e.pre+"menu3_proteinsRibbon' checked><label for='"+e.pre+"menu3_proteinsRibbon'>Ribbon </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_proteins' id='"+e.pre+"menu3_proteinsStrand'><label for='"+e.pre+"menu3_proteinsStrand'>Strand </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_proteins' id='"+e.pre+"menu3_proteinsCylinder'><label for='"+e.pre+"menu3_proteinsCylinder'>Cylinder and Plate </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_proteins' id='"+e.pre+"menu3_proteinsSchematic'><label for='"+e.pre+"menu3_proteinsSchematic'>Schematic </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_proteins' id='"+e.pre+"menu3_proteinsCalpha'><label for='"+e.pre+"menu3_proteinsCalpha'>C Alpha Trace </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_proteins' id='"+e.pre+"menu3_proteinsBfactor'><label for='"+e.pre+"menu3_proteinsBfactor'>B Factor Tube </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_proteins' id='"+e.pre+"menu3_proteinsLines'><label for='"+e.pre+"menu3_proteinsLines'>Lines </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_proteins' id='"+e.pre+"menu3_proteinsStick'><label for='"+e.pre+"menu3_proteinsStick'>Stick </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_proteins' id='"+e.pre+"menu3_proteinsBallstick'><label for='"+e.pre+"menu3_proteinsBallstick'>Ball and Stick </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_proteins' id='"+e.pre+"menu3_proteinsSphere'><label for='"+e.pre+"menu3_proteinsSphere'>Sphere </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_proteins' id='"+e.pre+"menu3_proteinsNothing'><label for='"+e.pre+"menu3_proteinsNothing'>Hide </li>",i+="                  </ul>",i+="                </li>"),i+="                <li>Side Chains",i+="                  <ul>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_sidechains' id='"+e.pre+"menu3_sidechainsLines'><label for='"+e.pre+"menu3_sidechainsLines'>Lines </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_sidechains' id='"+e.pre+"menu3_sidechainsStick'><label for='"+e.pre+"menu3_sidechainsStick'>Stick </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_sidechains' id='"+e.pre+"menu3_sidechainsBallstick'><label for='"+e.pre+"menu3_sidechainsBallstick'>Ball and Stick </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_sidechains' id='"+e.pre+"menu3_sidechainsSphere'><label for='"+e.pre+"menu3_sidechainsSphere'>Sphere </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_sidechains' id='"+e.pre+"menu3_sidechainsNothing' checked><label for='"+e.pre+"menu3_sidechainsNothing'>Hide </li>",i+="                  </ul>",i+="                </li>",i+="                <li>Nucleotides",i+="                  <ul>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_nucl' id='"+e.pre+"menu3_nuclCartoon' checked><label for='"+e.pre+"menu3_nuclCartoon'>Cartoon </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_nucl' id='"+e.pre+"menu3_nuclPhos'><label for='"+e.pre+"menu3_nuclPhos'>Phosphorus Trace </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_nucl' id='"+e.pre+"menu3_nuclSchematic'><label for='"+e.pre+"menu3_nuclSchematic'>Schematic </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_nucl' id='"+e.pre+"menu3_nuclLines'><label for='"+e.pre+"menu3_nuclLines'>Lines </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_nucl' id='"+e.pre+"menu3_nuclStick'><label for='"+e.pre+"menu3_nuclStick'>Stick </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_nucl' id='"+e.pre+"menu3_nuclBallstick'><label for='"+e.pre+"menu3_nuclBallstick'>Ball and Stick </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_nucl' id='"+e.pre+"menu3_nuclSphere'><label for='"+e.pre+"menu3_nuclSphere'>Sphere </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_nucl' id='"+e.pre+"menu3_nuclNothing'><label for='"+e.pre+"menu3_nuclNothing'>Hide </li>",i+="                  </ul>",i+="                </li>",i+="                <li>Ligands",i+="                  <ul>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_ligands' id='"+e.pre+"menu3_ligandsLines'><label for='"+e.pre+"menu3_ligandsLines'>Lines </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_ligands' id='"+e.pre+"menu3_ligandsStick' checked><label for='"+e.pre+"menu3_ligandsStick'>Stick </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_ligands' id='"+e.pre+"menu3_ligandsBallstick'><label for='"+e.pre+"menu3_ligandsBallstick'>Ball and Stick </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_ligands' id='"+e.pre+"menu3_ligandsSchematic'><label for='"+e.pre+"menu3_ligandsSchematic'>Schematic </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_ligands' id='"+e.pre+"menu3_ligandsSphere'><label for='"+e.pre+"menu3_ligandsSphere'>Sphere </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_ligands' id='"+e.pre+"menu3_ligandsNothing'><label for='"+e.pre+"menu3_ligandsNothing'>Hide </li>",i+="                  </ul>",i+="                </li>"):(i+="                <li>Ligands",i+="                  <ul>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_ligands' id='"+e.pre+"menu3_ligandsLines'><label for='"+e.pre+"menu3_ligandsLines'>Lines </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_ligands' id='"+e.pre+"menu3_ligandsStick'><label for='"+e.pre+"menu3_ligandsStick'>Stick </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_ligands' id='"+e.pre+"menu3_ligandsBallstick' checked><label for='"+e.pre+"menu3_ligandsBallstick'>Ball and Stick </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_ligands' id='"+e.pre+"menu3_ligandsSchematic'><label for='"+e.pre+"menu3_ligandsSchematic'>Schematic </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_ligands' id='"+e.pre+"menu3_ligandsSphere'><label for='"+e.pre+"menu3_ligandsSphere'>Sphere </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_ligands' id='"+e.pre+"menu3_ligandsNothing'><label for='"+e.pre+"menu3_ligandsNothing'>Hide </li>",i+="                  </ul>",i+="                </li>"),i+="                <li>Ions",i+="                  <ul>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_ions' id='"+e.pre+"menu3_ionsSphere' checked><label for='"+e.pre+"menu3_ionsSphere'>Sphere </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_ions' id='"+e.pre+"menu3_ionsDot'><label for='"+e.pre+"menu3_ionsDot'>Dot </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_ions' id='"+e.pre+"menu3_ionsNothing'><label for='"+e.pre+"menu3_ionsNothing'>Hide </li>",i+="                  </ul>",i+="                </li>",i+="                <li>Water",i+="                  <ul>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_water' id='"+e.pre+"menu3_waterSphere'><label for='"+e.pre+"menu3_waterSphere'>Sphere </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_water' id='"+e.pre+"menu3_waterDot'><label for='"+e.pre+"menu3_waterDot'>Dot </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu3_water' id='"+e.pre+"menu3_waterNothing' checked><label for='"+e.pre+"menu3_waterNothing'>Hide </li>",i+="                  </ul>",i+="                </li>",i+="              </ul>",i+="              ",i+="          ",i+="    "},setMenu4:function{var e=this,i="";return i+="    ",i+="          <accordion id='"+e.pre+"accordion4'>",i+="              Color ",i+="              ",i+="              <ul class='menu'>",void 0===e.cfg.cid?(i+=void 0!==e.cfg.mmdbid?" <li><input type='radio' name='"+e.pre+"menu4_color' id='"+e.pre+"menu4_colorSpectrum'><label for='"+e.pre+"menu4_colorSpectrum'>Spectrum </li>":"               <li><input type='radio' name='"+e.pre+"menu4_color' id='"+e.pre+"menu4_colorSpectrum' checked><label for='"+e.pre+"menu4_colorSpectrum'>Spectrum </li>", i+="                <li><input type='radio' name='"+e.pre+"menu4_color' id='"+e.pre+"menu4_colorSS'><label for='"+e.pre+"menu4_colorSS'>Secondary </li>",i+="                <li><input type='radio' name='"+e.pre+"menu4_color' id='"+e.pre+"menu4_colorCharge'><label for='"+e.pre+"menu4_colorCharge'>Charge </li>",i+="                <li><input type='radio' name='"+e.pre+"menu4_color' id='"+e.pre+"menu4_colorHydrophobic'><label for='"+e.pre+"menu4_colorHydrophobic'>Hydrophobic </li>",i+="                <li><input type='radio' name='"+e.pre+"menu4_color' id='"+e.pre+"menu4_colorChain'><label for='"+e.pre+"menu4_colorChain'>Chain </li>",i+="                <li><input type='radio' name='"+e.pre+"menu4_color' id='"+e.pre+"menu4_colorResidue'><label for='"+e.pre+"menu4_colorResidue'>Residue </li>",i+="                <li><input type='radio' name='"+e.pre+"menu4_color' id='"+e.pre+"menu4_colorAtom'><label for='"+e.pre+"menu4_colorAtom'>Atom </li>",void 0!==e.cfg.align&&(i+="                <li><input type='radio' name='"+e.pre+"menu4_color' id='"+e.pre+"menu4_colorConserved'><label for='"+e.pre+"menu4_colorConserved'>Identity </li>")):i+="                <li><input type='radio' name='"+e.pre+"menu4_color' id='"+e.pre+"menu4_colorAtom' checked><label for='"+e.pre+"menu4_colorAtom'>Atom </li>",i+="                <li>-</li>",i+="                <li>Unicolor",i+="                  <ul>",i+="                    <li><input type='radio' name='"+e.pre+"menu4_color' id='"+e.pre+"menu4_colorRed'><label for='"+e.pre+"menu4_colorRed'>Red </li>",i+="                    <li><input type='radio' name='"+e.pre+"menu4_color' id='"+e.pre+"menu4_colorGreen'><label for='"+e.pre+"menu4_colorGreen'>Green </li>",i+="                    <li><input type='radio' name='"+e.pre+"menu4_color' id='"+e.pre+"menu4_colorBlue'><label for='"+e.pre+"menu4_colorBlue'>Blue </li>",i+="                    <li><input type='radio' name='"+e.pre+"menu4_color' id='"+e.pre+"menu4_colorMagenta'><label for='"+e.pre+"menu4_colorMagenta'>Magenta </li>",i+="                    <li><input type='radio' name='"+e.pre+"menu4_color' id='"+e.pre+"menu4_colorYellow'><label for='"+e.pre+"menu4_colorYellow'>Yellow </li>",i+="                    <li><input type='radio' name='"+e.pre+"menu4_color' id='"+e.pre+"menu4_colorCyan'><label for='"+e.pre+"menu4_colorCyan'>Cyan </li>",i+="                    <li><input type='radio' name='"+e.pre+"menu4_color' id='"+e.pre+"menu4_colorWhite'><label for='"+e.pre+"menu4_colorWhite'>White </li>",i+="                    <li><input type='radio' name='"+e.pre+"menu4_color' id='"+e.pre+"menu4_colorGrey'><label for='"+e.pre+"menu4_colorGrey'>Grey </li>",i+="                  </ul>",i+="                <li>-</li>",i+="                <li><input type='radio' name='"+e.pre+"menu4_color' id='"+e.pre+"menu4_colorCustom'><label for='"+e.pre+"menu4_colorCustom'>Custom </li>",i+="              </ul>",i+="              ",i+="          ",i+="    "},setMenu5:function{var e=this,i="";return i+="    ",i+="          <accordion id='"+e.pre+"accordion5'>",i+="              Surface ",i+="              ",i+="              <ul class='menu'>",i+="                <li>Type",i+="                  <ul>",i+="                      <li><input type='radio' name='"+e.pre+"menu5_surface' id='"+e.pre+"menu5_surfaceVDW'><label for='"+e.pre+"menu5_surfaceVDW'>Van der Waals </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu5_surface' id='"+e.pre+"menu5_surfaceMolecular'><label for='"+e.pre+"menu5_surfaceMolecular'>Molecular Surface </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu5_surface' id='"+e.pre+"menu5_surfaceSAS'><label for='"+e.pre+"menu5_surfaceSAS'>Solvent Accessible </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu5_surface' id='"+e.pre+"menu5_surfaceNothing' checked><label for='"+e.pre+"menu5_surfaceNothing'>Remove </li>",i+="                  </ul>",i+="                </li>",i+="                <li>Opacity",i+="                  <ul>",i+="                      <li><input type='radio' name='"+e.pre+"menu5_opacity' id='"+e.pre+"menu5_opacity10'><label for='"+e.pre+"menu5_opacity10'>1.0 </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu5_opacity' id='"+e.pre+"menu5_opacity09'><label for='"+e.pre+"menu5_opacity09'>0.9 </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu5_opacity' id='"+e.pre+"menu5_opacity08' checked><label for='"+e.pre+"menu5_opacity08'>0.8 </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu5_opacity' id='"+e.pre+"menu5_opacity07'><label for='"+e.pre+"menu5_opacity07'>0.7 </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu5_opacity' id='"+e.pre+"menu5_opacity06'><label for='"+e.pre+"menu5_opacity06'>0.6 </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu5_opacity' id='"+e.pre+"menu5_opacity05'><label for='"+e.pre+"menu5_opacity05'>0.5 </li>",i+="                  </ul>",i+="                </li>",i+="                <li>Wireframe",i+="                  <ul>",i+="                      <li><input type='radio' name='"+e.pre+"menu5_wireframe' id='"+e.pre+"menu5_wireframeYes'><label for='"+e.pre+"menu5_wireframeYes'>Yes </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu5_wireframe' id='"+e.pre+"menu5_wireframeNo' checked><label for='"+e.pre+"menu5_wireframeNo'>No </li>",i+="                  </ul>",i+="                </li>",i+="                <li>Neighbors",i+="                  <ul>",i+="                      <li><input type='radio' name='"+e.pre+"menu5_neighbors' id='"+e.pre+"menu5_neighborsYes'><label for='"+e.pre+"menu5_neighborsYes'>Yes </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu5_neighbors' id='"+e.pre+"menu5_neighborsNo' checked><label for='"+e.pre+"menu5_neighborsNo'>No </li>",i+="                  </ul>",i+="                </li>",i+="              </ul>",i+="              ",i+="          ",i+="    "},setMenu6:function{var e=this,i="";return i+="    ",i+="          <accordion id='"+e.pre+"accordion6'>",i+="              Other ",i+="              ",i+="              <ul class='menu'>",i+="                <li><span id='"+e.pre+"reset' class='icn3d-link'>Reset </li>",i+="                <li><span id='"+e.pre+"menu6_resetorientation' class='icn3d-link'>Reset Orien. </li>",i+="               <li><span id='"+e.pre+"menu6_center' class='icn3d-link'>Center </li>",i+="                <li><span id='"+e.pre+"menu6_back' class='icn3d-link'>Backward </li>",i+="                <li><span id='"+e.pre+"menu6_forward' class='icn3d-link'>Forward </li>",void 0===e.cfg.cid&&(i+="                <li>Assembly",i+="                  <ul>",i+="                      <li><input type='radio' name='"+e.pre+"menu6_assembly' id='"+e.pre+"menu6_assemblyYes'><label for='"+e.pre+"menu6_assemblyYes'>Yes </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu6_assembly' id='"+e.pre+"menu6_assemblyNo' checked><label for='"+e.pre+"menu6_assemblyNo'>No </li>",i+="                  </ul>",i+="                </li>",i+="                <li>H-bonds",i+="                  <ul>",i+="                      <li><input type='radio' name='"+e.pre+"menu6_hbonds' id='"+e.pre+"menu6_hbondsYes'><label for='"+e.pre+"menu6_hbondsYes'>Show </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu6_hbonds' id='"+e.pre+"menu6_hbondsNo' checked><label for='"+e.pre+"menu6_hbondsNo'>Hide </li>",i+="                  </ul>",i+="                </li>"),i+="                <li>Label",i+="                  <ul>",i+="                      <li><input type='radio' name='"+e.pre+"menu6_addlabel' id='"+e.pre+"menu6_addlabelYes'><label for='"+e.pre+"menu6_addlabelYes'>by Picking </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu6_addlabel' id='"+e.pre+"menu6_addlabelSelection'><label for='"+e.pre+"menu6_addlabelSelection'>by Selection </li>",void 0===e.cfg.cid&&(i+="                      <li><input type='radio' name='"+e.pre+"menu6_addlabel' id='"+e.pre+"menu6_addlabelResidues'><label for='"+e.pre+"menu6_addlabelResidues'>by Residues </li>"),i+="                      <li><input type='radio' name='"+e.pre+"menu6_addlabel' id='"+e.pre+"menu6_addlabelNo' checked><label for='"+e.pre+"menu6_addlabelNo'>Remove </li>",i+="                  </ul>",i+="                </li>",i+="                <li>Distance",i+="                  <ul>",i+="                      <li><input type='radio' name='"+e.pre+"menu6_distance' id='"+e.pre+"menu6_distanceYes'><label for='"+e.pre+"menu6_distanceYes'>Show </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu6_distance' id='"+e.pre+"menu6_distanceNo' checked><label for='"+e.pre+"menu6_distanceNo'>Hide </li>",i+="                  </ul>",i+="                </li>",i+="                <li>Auto Rotation",i+="                  <ul>",i+="                      <li><span id='"+e.pre+"menu6_rotateleft' class='icn3d-link'>Rotate Left </li>",i+="                      <li><span id='"+e.pre+"menu6_rotateright' class='icn3d-link'>Rotate Right </li>",i+="                      <li><span id='"+e.pre+"menu6_rotateup' class='icn3d-link'>Rotate Up </li>",i+="                      <li><span id='"+e.pre+"menu6_rotatedown' class='icn3d-link'>Rotate Down </li>",i+="                  </ul>",i+="                </li>",i+="                <li>Camera",i+="                  <ul>",i+="                      <li><input type='radio' name='"+e.pre+"menu6_camera' id='"+e.pre+"menu6_cameraPers' checked><label for='"+e.pre+"menu6_cameraPers'>Perspective </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu6_camera' id='"+e.pre+"menu6_cameraOrth'><label for='"+e.pre+"menu6_cameraOrth'>Orthographic </li>",i+="                  </ul>",i+="                </li>",i+="                <li>Background",i+="                  <ul>",i+="                      <li><input type='radio' name='"+e.pre+"menu6_bkgd' id='"+e.pre+"menu6_bkgdBlack' checked><label for='"+e.pre+"menu6_bkgdBlack'>Black </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu6_bkgd' id='"+e.pre+"menu6_bkgdGrey'><label for='"+e.pre+"menu6_bkgdGrey'>Grey </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu6_bkgd' id='"+e.pre+"menu6_bkgdWhite'><label for='"+e.pre+"menu6_bkgdWhite'>White </li>",i+="                  </ul>",i+="                </li>",i+="                <li>Fog",i+="                  <ul>",i+="                      <li><input type='radio' name='"+e.pre+"menu6_showfog' id='"+e.pre+"menu6_showfogYes'><label for='"+e.pre+"menu6_showfogYes'>On </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu6_showfog' id='"+e.pre+"menu6_showfogNo' checked><label for='"+e.pre+"menu6_showfogNo'>Off </li>",i+="                  </ul>",i+="                </li>",i+="                <li>Slab",i+="                  <ul>",i+="                      <li><input type='radio' name='"+e.pre+"menu6_showslab' id='"+e.pre+"menu6_showslabYes'><label for='"+e.pre+"menu6_showslabYes'>On </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu6_showslab' id='"+e.pre+"menu6_showslabNo' checked><label for='"+e.pre+"menu6_showslabNo'>Off </li>",i+="                  </ul>",i+="                </li>",i+="                <li>XYZ-axes",i+="                  <ul>",i+="                      <li><input type='radio' name='"+e.pre+"menu6_showaxis' id='"+e.pre+"menu6_showaxisYes'><label for='"+e.pre+"menu6_showaxisYes'>Show </li>",i+="                      <li><input type='radio' name='"+e.pre+"menu6_showaxis' id='"+e.pre+"menu6_showaxisNo' checked><label for='"+e.pre+"menu6_showaxisNo'>Hide </li>",i+="                  </ul>",i+="                </li>",i+="                <li>Transform Hint",i+="                  <ul>",i+="                    <li>Rotate",i+="                        <ul>",i+="                            <li>Left Mouse</li>",i+="                            <li>Key L: Left</li>",i+="                            <li>Key J: Right</li>",i+="                            <li>Key I: Up</li>",i+="                            <li>Key M: Down</li>",i+="                        </ul>",i+="                    </li>",i+="                    <li>Zoom",i+="                        <ul>",i+="                            <li>Middle Mouse</li>",i+="                            <li>Key Z: Zoom in</li>",i+="                            <li>Key X: Zoom out</li>",i+="                        </ul>",i+="                    </li>",i+="                    <li>Translate",i+="                        <ul>",i+="                            <li>Right Mouse</li>",i+="                        </ul>",i+="                    </li>",i+="                  </ul>",i+="                </li>",i+="                <li><a href='https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html' target='_blank'>Help</a></li>",i+="              </ul>",i+="              ",i+="          ",i+="    "},setLogWindow:function{var e=this,i="";return i+="  <div id='"+e.pre+"commandlog' style='float:left; margin-top: -5px; width: 100%;'>",i+="    <textarea id='"+e.pre+"logtext' rows='2' style='width: 100%; height: "+.8*e.MENU_HEIGHT+"px; padding: 0px; border: 0px; background-color: "+e.GREYD+";'> ",i+="  "},setDialogs:function{var e=this,i="";return i+="",i+="<div id='"+e.pre+"allselections' class='icn3d-hidden'>",i+="<div id='"+e.pre+"dl_filter' style='overflow:auto; position:relative;'>",i+="  <button id='"+e.pre+"filter'> Show Structure ",i+="<button id='"+e.pre+"highlight_3d_diagram' style='margin-left:10px;'> Highlight ",i+="  <div id='"+e.pre+"dl_filter_table' class='icn3d-box'>",i+="  ",i+=" ",i+="<div id='"+e.pre+"dl_selectresidues'>",i+="  <div id='"+e.pre+"dl_sequence' class='icn3d-dl_sequence'>",i+="  ",i+=" ",void 0!==e.cfg.align&&(i+="<div id='"+e.pre+"dl_alignment'>",i+="  <div id='"+e.pre+"dl_sequence2' class='icn3d-dl_sequence'>",i+="  ",i+=" "),i+="<div id='"+e.pre+"dl_command'>",i+="   ",i+="  <td valign='top'> ",i+="    All Selections: ",i+="    <select id='"+e.pre+"customAtoms' multiple size='3' style='min-width:100px;'>",i+="    ",i+="  ",i+="   ",i+="  <td colspan='2'><a href='https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#selectb' target='_blank'> Hint </a>: ",i+='  Specification: In the selection "#1,2,3.A,B,C:5-10,Lys,ligands@CA,C":',i+='  <ul><li>"#1,2,3" uses "#" to indicate structure selection. ',i+=' <li>".A,B,C" uses "." to indicate chain selection. ',i+=' <li>":5-10,Lys,ligands" uses ":" to indicate residue selection. Residue could be predefined names: "proteins", "nucleotides", "ligands", "ions", and "water". ',i+=' <li>"@CA,C" uses "@" to indicate atom selection. ',i+=' <li>Partial definition is allowed, e.g., ":1-10" selects all residue IDs 1-10 in all chains. </ul>',i+=" Set Operation:",i+='  <ul><li>Users can select multiple items in "All Selections" above. ',i+=' <li>Different selections can be unioned (with "or", default), intersected (with "and"), or negated (with "not"). For example, ":1-10 or :Lys" selects all residues 1-10 and all Lys residues. ":1-10 and :Lys" selects all Lys residues in the range of residue number 1-10. ":1-10 or not :Lys" selects all residues 1-10, which are not Lys residues.</ul>',i+="   ",i+=" ",i+="<div id='"+e.pre+"dl_pdbid'>",i+="PDB ID: <input type='text' id='"+e.pre+"pdbid' value='2POR' size=8> ",i+="<button id='"+e.pre+"reload_pdb'>Load ",i+=" ",i+="<div id='"+e.pre+"dl_pdbfile'>",i+="PDB File: <input type='file' id='"+e.pre+"pdbfile' size=8> ",i+="<button id='"+e.pre+"reload_pdbfile'>Load ",i+=" ",i+="<div id='"+e.pre+"dl_mol2file'>",i+="Mol2 File: <input type='file' id='"+e.pre+"mol2file' size=8> ",i+="<button id='"+e.pre+"reload_mol2file'>Load ",i+=" ",i+="<div id='"+e.pre+"dl_sdffile'>",i+="SDF File: <input type='file' id='"+e.pre+"sdffile' size=8> ",i+="<button id='"+e.pre+"reload_sdffile'>Load ",i+=" ",i+="<div id='"+e.pre+"dl_xyzfile'>",i+="XYZ File: <input type='file' id='"+e.pre+"xyzfile' size=8> ",i+="<button id='"+e.pre+"reload_xyzfile'>Load ",i+=" ",i+="<div id='"+e.pre+"dl_mmciffile'>",i+="mmCIF File: <input type='file' id='"+e.pre+"mmciffile' value='2POR' size=8> ",i+="<button id='"+e.pre+"reload_mmciffile'>Load ",i+=" ",i+="<div id='"+e.pre+"dl_mmcifid'>",i+="mmCIF ID: <input type='text' id='"+e.pre+"mmcifid' value='2POR' size=8> ",i+="<button id='"+e.pre+"reload_mmcif'>Load ",i+=" ",i+="<div id='"+e.pre+"dl_mmdbid'>",i+="MMDB ID: <input type='text' id='"+e.pre+"mmdbid' value='2POR' size=8> ",i+="<button id='"+e.pre+"reload_mmdb'>Load ",i+=" ",i+="<div id='"+e.pre+"dl_gi'>",i+="Protein gi: <input type='text' id='"+e.pre+"gi' value='827343227' size=8> ",i+="<button id='"+e.pre+"reload_gi'>Load ",i+=" ",i+="<div id='"+e.pre+"dl_cid'>",i+="PubChem CID: <input type='text' id='"+e.pre+"cid' value='2244' size=8> ",i+="<button id='"+e.pre+"reload_cid'>Load ",i+=" ",i+="<div id='"+e.pre+"dl_state'>",i+="State file: <input type='file' id='"+e.pre+"state'> ",i+="<button id='"+e.pre+"reload_state' style='margin-top: 6px;'>Load ",i+=" ",i+="<div id='"+e.pre+"dl_selection'>",i+="Selection file: <input type='file' id='"+e.pre+"selectionfile'> ",i+="<button id='"+e.pre+"reload_selectionfile' style='margin-top: 6px;'>Load ",i+=" ",i+="<div id='"+e.pre+"dl_color'>",i+="Custom Color: <input type='text' id='"+e.pre+"color' value='#FF0000' size=8> ",i+="<button id='"+e.pre+"applycustomcolor'>Apply ",i+=" ",i+="<div id='"+e.pre+"dl_hbonds'>",i+=" To select residues that have hydrogen bonds with the current selection, please select the threshold of H-bonds. ",i+=" Threshold: <select id='"+e.pre+"hbondthreshold'>",i+="  <option value='3.2'>3.2 ",i+="  <option value='3.3'>3.3 ",i+="  <option value='3.4'>3.4 ",i+="  <option value='3.5' selected>3.5 ",i+="  <option value='3.6'>3.6 ",i+="  <option value='3.7'>3.7 ",i+="  <option value='3.8'>3.8 ",i+="  <option value='3.9'>3.9 ",i+="  <option value='4.0'>4.0 ",i+="  &#197; <button id='"+e.pre+"applyhbonds'>Display ",i+=" ",i+="<div id='"+e.pre+"dl_aroundsphere'",i+="  1. Sphere with a radius: <input type='text' id='"+e.pre+"radius_aroundsphere' value='5' size='2'> &#197; ",i+="  2. <button id='"+e.pre+"applypick_aroundsphere'>Display the sphere around currently selected atoms ",i+=" ",i+="<div id='"+e.pre+"dl_select_chain'>",i+="    ",i+=" ",i+="<div id='"+e.pre+"dl_addlabel'>",i+="1. Text: <input type='text' id='"+e.pre+"labeltext' value='Text' size=4> ",i+="2. Size: <input type='text' id='"+e.pre+"labelsize' value='18' size=4 maxlength=2> ",i+="3. Color: <input type='text' id='"+e.pre+"labelcolor' value='#ffff00' size=4> ",i+="4. Background: <input type='text' id='"+e.pre+"labelbkgd' value='#cccccc' size=4> ",i+=" 5. Pick TWO atoms ",i+=" 6. <button id='"+e.pre+"applypick_labels'>Display ",i+=" ",i+="<div id='"+e.pre+"dl_addlabelselection'>",i+="1. Text: <input type='text' id='"+e.pre+"labeltext2' value='Text' size=4> ",i+="2. Size: <input type='text' id='"+e.pre+"labelsize2' value='18' size=4 maxlength=2> ",i+="3. Color: <input type='text' id='"+e.pre+"labelcolor2' value='#ffff00' size=4> ",i+="4. Background: <input type='text' id='"+e.pre+"labelbkgd2' value='#cccccc' size=4> ",i+=" 5. <button id='"+e.pre+"applyselection_labels'>Display ",i+=" ",i+="<div id='"+e.pre+"dl_distance'>",i+=" 1. Pick TWO atoms ",i+="  2. <button id='"+e.pre+"applypick_measuredistance'>Display ",i+=" ",i+=" ",i+=""},setCustomDialogs:function{var e="";return e},setTools:function{var e=this,i="";i+=" <div id='"+e.pre+"selection' style='position:absolute; z-index:555; float:left; display:table-row; margin: 32px 0px 0px 3px;'>",i+="     ",i+="    "},updateMenus:function(e){var i=this,t=i.setStructureMenu(e),n=i.setChainMenu(e),o=i.setAlignChainMenu(e),s=i.setResidueMenu,r=i.setAtomMenu;$("#"+i.pre+"structureid")&&$("#"+i.pre+"structureid").html(t),$("#"+i.pre+"chainid")&&$("#"+i.pre+"chainid").html(n),$("#"+i.pre+"alignChainid")&&$("#"+i.pre+"alignChainid").html(o),$("#"+i.pre+"customResidues")&&$("#"+i.pre+"customResidues").html(s),$("#"+i.pre+"structureid2")&&$("#"+i.pre+"structureid2").html(t),$("#"+i.pre+"chainid2")&&$("#"+i.pre+"chainid2").html(n),$("#"+i.pre+"alignChainid2")&&$("#"+i.pre+"alignChainid2").html(o),$("#"+i.pre+"customResidues2")&&$("#"+i.pre+"customResidues2").html(s),$("#"+i.pre+"customAtoms")&&$("#"+i.pre+"customAtoms").html(r)},selectAllUpdateMenuSeq:function(e,i){var t=this;e&&t.setProteinsNucleotidesLigands,this.updateMenus(e);var n=t.getSequencesAnnotations(Object.keys(t.icn3d.chains),void 0,void 0,i);$("#"+t.pre+"dl_sequence").html(n.sequencesHtml),$("#"+t.pre+"dl_sequence").width(t.RESIDUE_WIDTH*n.maxSeqCnt+200),void 0!==t.cfg.align&&(n=t.getAlignSequencesAnnotations(Object.keys(t.icn3d.alignChains),void 0,void 0,i),$("#"+t.pre+"dl_sequence2").html(n.sequencesHtml),$("#"+t.pre+"dl_sequence2").width(t.RESIDUE_WIDTH*n.maxSeqCnt+200))},selectAll:function{var e=this;e.icn3d.highlightAtoms={};for(var i in e.icn3d.chains)e.icn3d.highlightAtoms=e.icn3d.unionHash(e.icn3d.highlightAtoms,e.icn3d.chains[i]),e.icn3d.displayAtoms=e.icn3d.unionHash(e.icn3d.displayAtoms,e.icn3d.chains[i]);e.icn3d.removeHighlightObjects,e.bSelectResidue=!1,e.bSelectAlignResidue=!1,e.selectAllUpdateMenuSeq(!0,!1),e.icn3d.draw},selectComplement:function{var e,i=this,t={},n={};for(var o in i.icn3d.atoms)i.icn3d.highlightAtoms.hasOwnProperty(o)||(t[o]=1,e=i.icn3d.atoms[o].structure+"_"+i.icn3d.atoms[o].chain+"_"+i.icn3d.atoms[o].resi,n[e]=1);i.icn3d.highlightAtoms={},i.icn3d.highlightAtoms=i.icn3d.cloneHash(t),i.icn3d.removeHighlightObjects;var s="Annotation(s): Complement of the current selection ",r=i.getSequencesAnnotations(void 0,!0,Object.keys(n));$("#"+i.pre+"dl_sequence").html(s+r.sequencesHtml),$("#"+i.pre+"dl_sequence").width(i.RESIDUE_WIDTH*r.maxSeqCnt+200),i.icn3d.addHighlightObjects},updateSeqWinForCurrentAtoms:function(e){var i=this,t=i.icn3d.getResiduesFromAtoms(i.icn3d.highlightAtoms),n=i.getSequencesAnnotations(void 0,!1,Object.keys(t),e);$("#"+i.pre+"dl_sequence").html(n.sequencesHtml),$("#"+i.pre+"dl_sequence").width(i.RESIDUE_WIDTH*n.maxSeqCnt+200),void 0!==i.cfg.align&&(n=i.getAlignSequencesAnnotations(void 0,!1,Object.keys(t),e),$("#"+i.pre+"dl_sequence2").html(n.sequencesHtml),$("#"+i.pre+"dl_sequence2").width(i.RESIDUE_WIDTH*n.maxSeqCnt+200))},outputSelection:function{var e=this,i={};for(var t in e.icn3d.highlightAtoms){var n=e.icn3d.atoms[t].structure+"_"+e.icn3d.atoms[t].chain+"_"+e.icn3d.atoms[t].resi;i[n]=1}for(var o=Object.keys(i).sort(function(e,i){if(""!==e&&!isNaN(e))return parseInt(e)-parseInt(i);var t=e.lastIndexOf("_"),n=i.lastIndexOf("_");if(e.substr(0,t)<i.substr(0,t))return-1;if(e.substr(0,t)>i.substr(0,t))return 1;if(e.substr(0,t)==i.substr(0,t)){if(parseInt(e.substr(t+1))<parseInt(i.substr(n+1)))return-1;if(parseInt(e.substr(t+1))>parseInt(i.substr(n+1)))return 1;if(parseInt(e.substr(t+1))==parseInt(i.substr(n+1)))return 0}}),s=" ",t+="Counts by Chain for atoms with coordinates:  ",e.saveFile(e.inputid+"_counts.html","html",t)})},clickMenu1_exportSelections:function{var e=this;$("#"+e.pre+"menu1_exportSelections").click(function(i){e.setLogCommand("export all selections",!1);var t=e.exportCustomAtoms;e.saveFile(e.inputid+"_selections.txt","text",t)})},clickMenu1_sharelink:function{var e=this;$("#"+e.pre+"menu1_sharelink").click(function(i){var t="./full.html?",n=inpara.indexOf("&command="),o=-1!==n?inpara.substr(0,n):inpara;t+=o.substr(1)+"&command=";for(var s=1,r=e.icn3d.commands.length;r>s;++s){var a=e.icn3d.commands[s].split("|||");if(s===r-1){var c=a.length>1?"|||"+a[1]:"";1!==s&&(t+="; "),t+=a[0]+c}else 1===s?t+=a[0]:1!==s&&s!==r-1&&(t+="; "+a[0])}e.setLogCommand("share link: "+t,!1),t.length>4e3&&alert("The url is more than 4000 characters and may not work. Please export the 'State File' and open it in the viewer."),window.open(t,"_blank")})},clickMenu1_link_structure:function{var e=this;$("#"+e.pre+"menu1_link_structure").click(function(i){var t=e.getLinkToStructureSummary(!0);window.open(t,"_blank")})},clickMenu1_link_bind:function{var e=this;$("#"+e.pre+"menu1_link_bind").click(function(i){url="https://www.ncbi.nlm.nih.gov/pccompound?LinkName=pccompound_structure&from_uid="+e.inputid,e.setLogCommand("link to 3D protein structures bound to CID "+e.inputid+": "+url,!1),window.open(url,"_blank")})},clickMenu1_link_vast:function{var e=this;$("#"+e.pre+"menu1_link_vast").click(function(i){if(void 0===e.inputid)t="https://www.ncbi.nlm.nih.gov/pccompound?term="+e.icn3d.moleculeTitle,e.setLogCommand("link to compounds "+e.icn3d.moleculeTitle+": "+t,!1);else{if(void 0!==e.cfg.cid)t="https://www.ncbi.nlm.nih.gov/pccompound?LinkName=pccompound_pccompound_3d&from_uid="+e.inputid,e.setLogCommand("link to compounds with structure similar to CID "+e.inputid+": "+t,!1);else{var t,n=e.inputid.split("_");1===n.length?(t="https://www.ncbi.nlm.nih.gov/Structure/vastplus/vastplus.cgi?uid="+e.inputid,e.setLogCommand("link to structures similar to "+e.inputid+": "+t,!1)):2===n.length&&(t="https://www.ncbi.nlm.nih.gov/Structure/vastplus/vastplus.cgi?uid="+n[0],e.setLogCommand("link to structures similar to "+n[0]+": "+t,!1))}window.open(t,"_blank")}})},clickMenu1_link_pubmed:function{var e=this;$("#"+e.pre+"menu1_link_pubmed").click(function(i){var t;if(void 0===e.inputid){var t;t="https://www.ncbi.nlm.nih.gov/pubmed/?term="+e.icn3d.moleculeTitle,e.setLogCommand("link to literature about "+e.icn3d.moleculeTitle+": "+t,!1),window.open(t,"_blank")}else if(void 0!==e.pmid){var t,n=e.pmid.toString.split("_");1===n.length?(t="https://www.ncbi.nlm.nih.gov/pubmed/"+e.pmid,e.setLogCommand("link to PubMed ID "+e.pmid+": "+t,!1)):2===n.length&&(t="https://www.ncbi.nlm.nih.gov/pubmed/?term="+n[0]+" OR "+n[1],e.setLogCommand("link to PubMed IDs "+n[0]+", "+n[1]+": "+t,!1)),window.open(t,"_blank")}else if(isNaN(e.inputid)){var t,n=e.inputid.toString.split("_");1===n.length?(t="https://www.ncbi.nlm.nih.gov/pubmed/?term="+e.inputid,e.setLogCommand("link to literature about PDB "+e.inputid+": "+t,!1)):2===n.length&&(t="https://www.ncbi.nlm.nih.gov/pubmed/?term="+n[0]+" OR "+n[1],e.setLogCommand("link to literature about PDB "+n[0]+" OR "+n[1]+": "+t,!1)),window.open(t,"_blank")}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.")})},clickMenu2_selectresidues:function{var e=this;$("#"+e.pre+"menu2_selectresidues").click(function(i){e.openDialog(e.pre+"dl_selectresidues","Select residues in sequences")})},clickMenu2_selectall:function{var e=this;$("#"+e.pre+"menu2_selectall").add("#"+e.pre+"selectall").click(function(i){e.setLogCommand("select all",!0),e.selectAll})},clickMenu2_selectcomplement:function{var e=this;$("#"+e.pre+"menu2_selectcomplement").click(function(i){Object.keys(e.icn3d.highlightAtoms).length<Object.keys(e.icn3d.atoms).length&&(e.setLogCommand("select complement",!0),e.selectComplement)})},clickMenu2_alignment:function{var e=this;$("#"+e.pre+"menu2_alignment").click(function(i){e.openDialog(e.pre+"dl_alignment","Select residues in aligned sequences")})},clickMenu2_command:function{var e=this;$("#"+e.pre+"menu2_command").click(function(i){e.openDialog(e.pre+"dl_command","Advanced set selection")})},clickMenu2_pickingNo:function{var e=this;$("#"+e.pre+"menu2_pickingNo").click(function(i){e.icn3d.picking=0,e.icn3d.options.picking="no",e.setLogCommand("set picking off",!0),e.icn3d.draw,e.icn3d.removeHighlightObjects})},clickMenu2_pickingYes:function{var e=this;$("#"+e.pre+"menu2_pickingYes").click(function(i){e.icn3d.picking=1,e.icn3d.options.picking="atom",e.setLogCommand("set picking atom",!0)})},clickMenu2_pickingResidue:function{var e=this;$("#"+e.pre+"menu2_pickingResidue").click(function(i){e.icn3d.picking=2,e.icn3d.options.picking="residue",e.setLogCommand("set picking residue",!0)})},clickMenu2_pickingStrand:function{var e=this;$("#"+e.pre+"menu2_pickingStrand").click(function(i){e.icn3d.picking=3,e.icn3d.options.picking="strand",e.setLogCommand("set picking strand",!0)})},clickMenu2_aroundsphere:function{var e=this;$("#"+e.pre+"menu2_aroundsphere").click(function(i){e.openDialog(e.pre+"dl_aroundsphere","Select a sphere around current selection")})},clickMenu2_select_chain:function{var e=this;$("#"+e.pre+"menu2_select_chain").click(function(i){e.openDialog(e.pre+"dl_select_chain","Select Structure/Chain/Custom Selection")})},clickmenu3_proteinsRibbon:function{var e=this;$("#"+e.pre+"menu3_proteinsRibbon").click(function(i){e.setStyle("proteins","ribbon"),e.setLogCommand("style proteins ribbon",!0)})},clickmenu3_proteinsStrand:function{var e=this;$("#"+e.pre+"menu3_proteinsStrand").click(function(i){e.setStyle("proteins","strand"),e.setLogCommand("style proteins strand",!0)})},clickmenu3_proteinsCylinder:function{var e=this;$("#"+e.pre+"menu3_proteinsCylinder").click(function(i){e.setStyle("proteins","cylinder and plate"),e.setLogCommand("style proteins cylinder and plate",!0)})},clickMenu3_proteinsSchematic:function{var e=this;$("#"+e.pre+"menu3_proteinsSchematic").click(function(i){e.setStyle("proteins","schematic"),e.setLogCommand("style proteins schematic",!0)})},clickmenu3_proteinsCalpha:function{var e=this;$("#"+e.pre+"menu3_proteinsCalpha").click(function(i){e.setStyle("proteins","c alpha trace"),e.setLogCommand("style proteins c alpha trace",!0)})},clickmenu3_proteinsBfactor:function{var e=this;$("#"+e.pre+"menu3_proteinsBfactor").click(function(i){e.setStyle("proteins","b factor tube"),e.setLogCommand("style proteins b factor tube",!0)})},clickmenu3_proteinsLines:function{var e=this;$("#"+e.pre+"menu3_proteinsLines").click(function(i){e.setStyle("proteins","lines"),e.setLogCommand("style proteins lines",!0)})},clickmenu3_proteinsStick:function{var e=this;$("#"+e.pre+"menu3_proteinsStick").click(function(i){e.setStyle("proteins","stick"),e.setLogCommand("style proteins stick",!0)})},clickmenu3_proteinsBallstick:function{var e=this;$("#"+e.pre+"menu3_proteinsBallstick").click(function(i){e.setStyle("proteins","ball and stick"),e.setLogCommand("style proteins ball and stick",!0)})},clickmenu3_proteinsSphere:function{var e=this;$("#"+e.pre+"menu3_proteinsSphere").click(function(i){e.setStyle("proteins","sphere"),e.setLogCommand("style proteins sphere",!0)})},clickmenu3_proteinsNothing:function{var e=this;$("#"+e.pre+"menu3_proteinsNothing").click(function(i){e.setStyle("proteins","nothing"),e.setLogCommand("style proteins nothing",!0)})},clickMenu3_sidechainsLines:function{var e=this;$("#"+e.pre+"menu3_sidechainsLines").click(function(i){e.setStyle("sidechains","lines"),e.setLogCommand("style sidechains lines",!0)})},clickMenu3_sidechainsStick:function{var e=this;$("#"+e.pre+"menu3_sidechainsStick").click(function(i){e.setStyle("sidechains","stick"),e.setLogCommand("style sidechains stick",!0)})},clickMenu3_sidechainsBallstick:function{var e=this;$("#"+e.pre+"menu3_sidechainsBallstick").click(function(i){e.setStyle("sidechains","ball and stick"),e.setLogCommand("style sidechains ball and stick",!0)})},clickMenu3_sidechainsSphere:function{var e=this;$("#"+e.pre+"menu3_sidechainsSphere").click(function(i){e.setStyle("sidechains","sphere"),e.setLogCommand("style sidechains sphere",!0)})},clickMenu3_sidechainsNothing:function{var e=this;$("#"+e.pre+"menu3_sidechainsNothing").click(function(i){e.setStyle("sidechains","nothing"),e.setLogCommand("style sidechains nothing",!0)})},clickmenu3_nuclCartoon:function{var e=this;$("#"+e.pre+"menu3_nuclCartoon").click(function(i){e.setStyle("nucleotides","nucleotide cartoon"),e.setLogCommand("style nucleotides nucleotide cartoon",!0)})},clickmenu3_nuclSchematic:function{var e=this;$("#"+e.pre+"menu3_nuclSchematic").click(function(i){e.setStyle("nucleotides","schematic"),e.setLogCommand("style nucleotides schematic",!0)})},clickmenu3_nuclPhos:function{var e=this;$("#"+e.pre+"menu3_nuclPhos").click(function(i){e.setStyle("nucleotides","phosphorus trace"),e.setLogCommand("style nucleotides phosphorus trace",!0)})},clickmenu3_nuclLines:function{var e=this;$("#"+e.pre+"menu3_nuclLines").click(function(i){e.setStyle("nucleotides","lines"),e.setLogCommand("style nucleotides lines",!0)})},clickmenu3_nuclStick:function{var e=this;$("#"+e.pre+"menu3_nuclStick").click(function(i){e.setStyle("nucleotides","stick"),e.setLogCommand("style nucleotides stick",!0)})},clickmenu3_nuclBallstick:function{var e=this;$("#"+e.pre+"menu3_nuclBallstick").click(function(i){e.setStyle("nucleotides","ball and stick"),e.setLogCommand("style nucleotides ball and stick",!0)})},clickmenu3_nuclSphere:function{var e=this;$("#"+e.pre+"menu3_nuclSphere").click(function(i){e.setStyle("nucleotides","sphere"),e.setLogCommand("style nucleotides sphere",!0)})},clickmenu3_nuclNothing:function{var e=this;$("#"+e.pre+"menu3_nuclNothing").click(function(i){e.setStyle("nucleotides","nothing"),e.setLogCommand("style nucleotides nothing",!0)})},clickMenu3_ligandsLines:function{var e=this;$("#"+e.pre+"menu3_ligandsLines").click(function(i){e.setStyle("ligands","lines"),e.setLogCommand("style ligands lines",!0)})},clickMenu3_ligandsStick:function{var e=this;$("#"+e.pre+"menu3_ligandsStick").click(function(i){e.setStyle("ligands","stick"),e.setLogCommand("style ligands stick",!0)})},clickMenu3_ligandsBallstick:function{var e=this;$("#"+e.pre+"menu3_ligandsBallstick").click(function(i){e.setStyle("ligands","ball and stick"),e.setLogCommand("style ligands ball and stick",!0)})},clickMenu3_ligandsSchematic:function{var e=this;$("#"+e.pre+"menu3_ligandsSchematic").click(function(i){e.setStyle("ligands","schematic"),e.setLogCommand("style ligands schematic",!0)})},clickMenu3_ligandsSphere:function{var e=this;$("#"+e.pre+"menu3_ligandsSphere").click(function(i){e.setStyle("ligands","sphere"),e.setLogCommand("style ligands sphere",!0)})},clickMenu3_ligandsNothing:function{var e=this;$("#"+e.pre+"menu3_ligandsNothing").click(function(i){e.setStyle("ligands","nothing"),e.setLogCommand("style ligands nothing",!0)})},clickMenu3_ionsSphere:function{var e=this;$("#"+e.pre+"menu3_ionsSphere").click(function(i){e.setStyle("ions","sphere"),e.setLogCommand("style ions sphere",!0)})},clickMenu3_ionsDot:function{var e=this;$("#"+e.pre+"menu3_ionsDot").click(function(i){e.setStyle("ions","dot"),e.setLogCommand("style ions dot",!0)})},clickMenu3_ionsNothing:function{var e=this;$("#"+e.pre+"menu3_ionsNothing").click(function(i){e.setStyle("ions","nothing"),e.setLogCommand("style ions nothing",!0)})},clickMenu3_waterSphere:function{var e=this;$("#"+e.pre+"menu3_waterSphere").click(function(i){e.setStyle("water","sphere"),e.setLogCommand("style water sphere",!0)})},clickMenu3_waterDot:function{var e=this;$("#"+e.pre+"menu3_waterDot").click(function(i){e.setStyle("water","dot"),e.setLogCommand("style water dot",!0)})},clickMenu3_waterNothing:function{var e=this;$("#"+e.pre+"menu3_waterNothing").click(function(i){e.setStyle("water","nothing"),e.setLogCommand("style water nothing",!0)})},clickMenu4_colorSpectrum:function{var e=this;$("#"+e.pre+"menu4_colorSpectrum").click(function(i){e.setOption("color","spectrum"),e.setLogCommand("color spectrum",!0)})},clickMenu4_colorChain:function{var e=this;$("#"+e.pre+"menu4_colorChain").click(function(i){e.setOption("color","chain"),e.setLogCommand("color chain",!0)})},clickMenu4_colorSS:function{var e=this;$("#"+e.pre+"menu4_colorSS").click(function(i){e.setOption("color","secondary structure"),e.setLogCommand("color secondary structure",!0)})},clickMenu4_colorResidue:function{var e=this;$("#"+e.pre+"menu4_colorResidue").click(function(i){e.setOption("color","residue"),e.setLogCommand("color residue",!0)})},clickMenu4_colorCharge:function{var e=this;$("#"+e.pre+"menu4_colorCharge").click(function(i){e.setOption("color","charge"),e.setLogCommand("color charge",!0)})},clickMenu4_colorHydrophobic:function{var e=this;$("#"+e.pre+"menu4_colorHydrophobic").click(function(i){e.setOption("color","hydrophobic"),e.setLogCommand("color hydrophobic",!0)})},clickMenu4_colorAtom:function{var e=this;$("#"+e.pre+"menu4_colorAtom").click(function(i){e.setOption("color","atom"),e.setLogCommand("color atom",!0)})},clickMenu4_colorConserved:function{var e=this;$("#"+e.pre+"menu4_colorConserved").click(function(i){e.setOption("color","conserved"),e.setLogCommand("color conserved",!0)})},clickMenu4_colorRed:function{var e=this;$("#"+e.pre+"menu4_colorRed").click(function(i){e.setOption("color","red"),e.setLogCommand("color red",!0)})},clickMenu4_colorGreen:function{var e=this;$("#"+e.pre+"menu4_colorGreen").click(function(i){e.setOption("color","green"),e.setLogCommand("color green",!0)})},clickMenu4_colorBlue:function{var e=this;$("#"+e.pre+"menu4_colorBlue").click(function(i){e.setOption("color","blue"),e.setLogCommand("color blue",!0)})},clickMenu4_colorMagenta:function{var e=this;$("#"+e.pre+"menu4_colorMagenta").click(function(i){e.setOption("color","magenta"),e.setLogCommand("color magenta",!0)})},clickMenu4_colorYellow:function{var e=this;$("#"+e.pre+"menu4_colorYellow").click(function(i){e.setOption("color","yellow"),e.setLogCommand("color yellow",!0)})},clickMenu4_colorCyan:function{var e=this;$("#"+e.pre+"menu4_colorCyan").click(function(i){e.setOption("color","cyan"),e.setLogCommand("color cyan",!0)})},clickMenu4_colorWhite:function{var e=this;$("#"+e.pre+"menu4_colorWhite").click(function(i){e.setOption("color","white"),e.setLogCommand("color white",!0)})},clickMenu4_colorGrey:function{var e=this;$("#"+e.pre+"menu4_colorGrey").click(function(i){e.setOption("color","grey"),e.setLogCommand("color grey",!0)})},clickMenu4_colorCustom:function{var e=this;$("#"+e.pre+"menu4_colorCustom").click(function(i){e.openDialog(e.pre+"dl_color","Choose custom color")})},clickMenu5_neighborsYes:function{var e=this;$("#"+e.pre+"menu5_neighborsYes").click(function(i){e.icn3d.bConsiderNeighbors=!0,e.icn3d.removeLastSurface,e.icn3d.applySurfaceOptions,e.icn3d.render,e.setLogCommand("set surface neighbors on",!0)})},clickMenu5_neighborsNo:function{var e=this;$("#"+e.pre+"menu5_neighborsNo").click(function(i){e.icn3d.bConsiderNeighbors=!1,e.icn3d.removeLastSurface,e.icn3d.applySurfaceOptions,e.icn3d.render,e.setLogCommand("set surface neighbors off",!0)})},clickMenu5_surfaceVDW:function{var e=this;$("#"+e.pre+"menu5_surfaceVDW").click(function(i){e.setOption("surface","Van der Waals surface"),e.setLogCommand("set surface Van der Waals surface",!0)})},clickMenu5_surfaceSAS:function{var e=this;$("#"+e.pre+"menu5_surfaceSAS").click(function(i){e.setOption("surface","solvent accessible surface"),e.setLogCommand("set surface solvent accessible surface",!0)})},clickMenu5_surfaceMolecular:function{var e=this;$("#"+e.pre+"menu5_surfaceMolecular").click(function(i){e.setOption("surface","molecular surface"),e.setLogCommand("set surface molecular surface",!0)})},clickMenu5_surfaceNothing:function{var e=this;$("#"+e.pre+"menu5_surfaceNothing").click(function(i){e.setOption("surface","nothing"),e.setLogCommand("set surface nothing",!0)})},clickMenu5_opacity10:function{var e=this;$("#"+e.pre+"menu5_opacity10").click(function(i){e.setOption("opacity","1.0"),e.setLogCommand("set surface opacity 1.0",!0)})},clickMenu5_opacity09:function{var e=this;$("#"+e.pre+"menu5_opacity09").click(function(i){e.setOption("opacity","0.9"),e.setLogCommand("set surface opacity 0.9",!0)})},clickMenu5_opacity08:function{var e=this;$("#"+e.pre+"menu5_opacity08").click(function(i){e.setOption("opacity","0.8"),e.setLogCommand("set surface opacity 0.8",!0)})},clickMenu5_opacity07:function{var e=this;$("#"+e.pre+"menu5_opacity07").click(function(i){e.setOption("opacity","0.7"),e.setLogCommand("set surface opacity 0.7",!0)})},clickMenu5_opacity06:function{var e=this;$("#"+e.pre+"menu5_opacity06").click(function(i){e.setOption("opacity","0.6"),e.setLogCommand("set surface opacity 0.6",!0)})},clickMenu5_opacity05:function{var e=this;$("#"+e.pre+"menu5_opacity05").click(function(i){e.setOption("opacity","0.5"),e.setLogCommand("set surface opacity 0.5",!0)})},clickMenu5_wireframeYes:function{var e=this;$("#"+e.pre+"menu5_wireframeYes").click(function(i){e.setOption("wireframe","yes"),e.setLogCommand("set surface wireframe on",!0)})},clickMenu5_wireframeNo:function{var e=this;$("#"+e.pre+"menu5_wireframeNo").click(function(i){e.setOption("wireframe","no"),e.setLogCommand("set surface wireframe off",!0)})},clickMenu6_assemblyYes:function{var e=this;$("#"+e.pre+"menu6_assemblyYes").click(function(i){e.icn3d.bAssembly=!0,e.setLogCommand("set assembly on",!0),e.icn3d.draw})},clickMenu6_assemblyNo:function{var e=this;$("#"+e.pre+"menu6_assemblyNo").click(function(i){e.icn3d.bAssembly=!1,e.setLogCommand("set assembly off",!0),e.icn3d.draw})},clickMenu6_addlabelResidues:function{var e=this;$("#"+e.pre+"menu6_addlabelResidues").click(function(i){e.setLogCommand("add residue labels",!0),e.icn3d.addResiudeLabels(e.icn3d.highlightAtoms),e.saveSelectionIfSelected,e.icn3d.draw})},clickMenu6_addlabelYes:function{var e=this;$("#"+e.pre+"menu6_addlabelYes").click(function(i){e.openDialog(e.pre+"dl_addlabel","Add custom labels by picking"),e.icn3d.picking=1,e.icn3d.options.picking="atom",e.icn3d.pickpair=!0,e.icn3d.pickedatomNum=0})},clickMenu6_addlabelSelection:function{var e=this;$("#"+e.pre+"menu6_addlabelSelection").click(function(i){e.openDialog(e.pre+"dl_addlabelselection","Add custom labels by the current selection")})},clickMenu6_addlabelNo:function{var e=this;$("#"+e.pre+"menu6_addlabelNo").click(function(i){e.icn3d.pickpair=!1,e.icn3d.labels.residue=[],e.icn3d.labels.custom=[];var t="set labels off";e.setLogCommand(t,!0);for(var n in e.icn3d.labels)("residue"===n||"custom"===n)&&(e.icn3d.labels[n]=[]);e.icn3d.draw})},clickMenu6_distanceYes:function{var e=this;$("#"+e.pre+"menu6_distanceYes").click(function(i){e.openDialog(e.pre+"dl_distance","Measure the distance of atoms"),e.icn3d.picking=1,e.icn3d.options.picking="atom",e.icn3d.pickpair=!0,e.icn3d.pickedatomNum=0})},clickMenu6_distanceNo:function{var e=this;$("#"+e.pre+"menu6_distanceNo").click(function(i){e.icn3d.pickpair=!1;var t="set lines off";e.setLogCommand(t,!0),e.icn3d.labels.distance=[],e.icn3d.lines.distance=[],e.icn3d.draw})},clickmenu2_selectedcenter:function{var e=this;$("#"+e.pre+"menu2_selectedcenter").add("#"+e.pre+"zoomin_selection").click(function(i){e.setLogCommand("zoom selection",!0),e.icn3d.zoominSelection})},clickMenu6_center:function{var e=this;$("#"+e.pre+"menu6_center").click(function(i){e.setLogCommand("center selection",!0),e.icn3d.centerSelection})},clickMenu6_resetorientation:function{var e=this;$("#"+e.pre+"menu6_resetorientation").add("#"+e.pre+"resetorientation").click(function(i){e.setLogCommand("reset orientation",!0),e.icn3d.resetOrientation})},clickMenu6_rotateleft:function{var e=this;$("#"+e.pre+"menu6_rotateleft").click(function(i){e.setLogCommand("rotate left",!0),e.icn3d.bStopRotate=!1,e.icn3d.rotateCount=0,e.icn3d.rotateCountMax=6e3,e.ROTATION_DIRECTION="left",e.rotateStructure("left")})},clickMenu6_rotateright:function{var e=this;$("#"+e.pre+"menu6_rotateright").click(function(i){e.setLogCommand("rotate right",!0),e.icn3d.bStopRotate=!1,e.icn3d.rotateCount=0,e.icn3d.rotateCountMax=6e3,e.ROTATION_DIRECTION="right",e.rotateStructure("right")})},clickMenu6_rotateup:function{var e=this;$("#"+e.pre+"menu6_rotateup").click(function(i){e.setLogCommand("rotate up",!0),e.icn3d.bStopRotate=!1,e.icn3d.rotateCount=0,e.icn3d.rotateCountMax=6e3,e.ROTATION_DIRECTION="up",e.rotateStructure("up")})},clickMenu6_rotatedown:function{var e=this;$("#"+e.pre+"menu6_rotatedown").click(function(i){e.setLogCommand("rotate down",!0),e.icn3d.bStopRotate=!1,e.icn3d.rotateCount=0,e.icn3d.rotateCountMax=6e3,e.ROTATION_DIRECTION="down",e.rotateStructure("down")})},clickMenu6_cameraPers:function{var e=this;$("#"+e.pre+"menu6_cameraPers").click(function(i){e.setOption("camera","perspective"),e.setLogCommand("set camera perspective",!0)})},clickMenu6_cameraOrth:function{var e=this;$("#"+e.pre+"menu6_cameraOrth").click(function(i){e.setOption("camera","orthographic"),e.setLogCommand("set camera orthographic",!0)})},clickMenu6_bkgdBlack:function{var e=this;$("#"+e.pre+"menu6_bkgdBlack").click(function(i){e.setOption("background","black"),e.setLogCommand("set background black",!0)})},clickMenu6_bkgdGrey:function{var e=this;$("#"+e.pre+"menu6_bkgdGrey").click(function(i){e.setOption("background","grey"),e.setLogCommand("set background grey",!0)})},clickMenu6_bkgdWhite:function{var e=this;$("#"+e.pre+"menu6_bkgdWhite").click(function(i){e.setOption("background","white"),e.setLogCommand("set background white",!0)})},clickMenu6_showfogYes:function{var e=this;$("#"+e.pre+"menu6_showfogYes").click(function(i){e.setOption("fog","yes"),e.setLogCommand("set fog on",!0)})},clickMenu6_showfogNo:function{var e=this;$("#"+e.pre+"menu6_showfogNo").click(function(i){e.setOption("fog","no"),e.setLogCommand("set fog off",!0)})},clickMenu6_showslabYes:function{var e=this;$("#"+e.pre+"menu6_showslabYes").click(function(i){e.setOption("slab","yes"),e.setLogCommand("set slab on",!0)})},clickMenu6_showslabNo:function{var e=this;$("#"+e.pre+"menu6_showslabNo").click(function(i){e.setOption("slab","no"),e.setLogCommand("set slab off",!0)})},clickMenu6_showaxisYes:function{var e=this;$("#"+e.pre+"menu6_showaxisYes").click(function(i){e.setOption("axis","yes"),e.setLogCommand("set axis on",!0)})},clickMenu6_showaxisNo:function{var e=this;$("#"+e.pre+"menu6_showaxisNo").click(function(i){e.setOption("axis","no"),e.setLogCommand("set axis off",!0)})},clickMenu6_hbondsYes:function{var e=this;$("#"+e.pre+"menu6_hbondsYes").click(function(i){e.openDialog(e.pre+"dl_hbonds","Hydrogen bonds to selection")})},clickMenu6_hbondsNo:function{var e=this;$("#"+e.pre+"menu6_hbondsNo").click(function(i){e.icn3d.options.hbonds="no";var t="set hbonds off";e.setLogCommand(t,!0),e.icn3d.lines.hbond=[],e.icn3d.draw})},selectSequenceNonMobile:function{var e=this;$("#"+e.pre+"dl_sequence").selectable({stop:function{$("#"+e.pre+"chainid").val(""),$("#"+e.pre+"structureid").val(""),$("#"+e.pre+"chainid2").val(""),$("#"+e.pre+"structureid2").val(""),e.bSelectResidue===!1&&(e.removeSeqChainBkgd,e.removeSeqResidueBkgd,e.selectedResidues={},e.icn3d.highlightAtoms={},e.icn3d.removeHighlightObjects),$(".ui-selected",this).each(function{var i=$(this).attr("id");if(void 0!==i&&""!==i){"align"===i.substr(0,5)&&(i=i.substr(5)),e.bSelectResidue=!0,$(this).toggleClass("icn3d-highlightSeq");var t=i.substr(i.indexOf("_")+1);if($(this).hasClass("icn3d-highlightSeq")){for(var n in e.icn3d.residues[t])e.icn3d.highlightAtoms[n]=1;e.selectedResidues[t]=1}else{for(var o in e.icn3d.residues[t])e.icn3d.highlightAtoms[o]=void 0;e.selectedResidues[t]=void 0,e.icn3d.removeHighlightObjects}}}),e.icn3d.addHighlightObjects,$("#"+e.pre+"chainid").val(""),$("#"+e.pre+"structureid").val(""),$("#"+e.pre+"chainid2").val(""),$("#"+e.pre+"structureid2").val(""),$(".ui-selected",this).each(function{var i=$(this).attr("chain");if($(this).hasClass("icn3d-seqTitle")){e.bSelectResidue=!1,e.removeSeqChainBkgd(i),e.removeSeqResidueBkgd,$(this).toggleClass("icn3d-highlightSeq");var t=$(this).attr("chain"),n=t;if($(this).hasClass("icn3d-highlightSeq")){var o="select chain "+t;e.selectAChain(t,n),e.setLogCommand(o,!0)}else e.icn3d.removeHighlightObjects,e.icn3d.highlightAtoms={},$("#"+e.pre+"customResidues").val(""),$("#"+e.pre+"customResidues2").val(""),$("#"+e.pre+"customAtoms").val("")}})}}),$("#"+e.pre+"dl_sequence2").selectable({stop:function{$("#"+e.pre+"chainid").val(""),$("#"+e.pre+"structureid").val(""),$("#"+e.pre+"chainid2").val(""),$("#"+e.pre+"structureid2").val(""),e.bSelectAlignResidue===!1&&(e.removeSeqChainBkgd,e.removeSeqResidueBkgd,e.selectedResidues={},e.icn3d.highlightAtoms={},e.icn3d.removeHighlightObjects),$(".ui-selected",this).each(function{var i=$(this).attr("id");if(void 0!==i&&""!==i){"align"===i.substr(0,5)&&(i=i.substr(5)),e.bSelectAlignResidue=!0,$(this).toggleClass("icn3d-highlightSeq");var t=i.substr(i.indexOf("_")+1);if($(this).hasClass("icn3d-highlightSeq")){for(var n in e.icn3d.residues[t])e.icn3d.highlightAtoms[n]=1;e.selectedResidues[t]=1}else{for(var n in e.icn3d.residues[t])e.icn3d.highlightAtoms[n]=void 0;e.selectedResidues[t]=void 0,e.icn3d.removeHighlightObjects}}}),e.icn3d.addHighlightObjects,$("#"+e.pre+"chainid").val(""),$("#"+e.pre+"structureid").val(""),$("#"+e.pre+"chainid2").val(""),$("#"+e.pre+"structureid2").val(""),$(".ui-selected",this).each(function{var i=$(this).attr("chain");if($(this).hasClass("icn3d-seqTitle")){e.bSelectAlignResidue=!1,e.removeSeqChainBkgd(i),e.removeSeqResidueBkgd,$(this).toggleClass("icn3d-highlightSeq");var t=$(this).attr("chain"),n="align_"+t;$(this).hasClass("icn3d-highlightSeq")?(e.selectAAlignChain(t,n),e.setLogCommand("select alignChain "+t,!0)):(e.icn3d.removeHighlightObjects,e.icn3d.highlightAtoms={},$("#"+e.pre+"customResidues").val(""),$("#"+e.pre+"customResidues2").val(""),$("#"+e.pre+"customAtoms").val(""))}})}})},selectSequenceMobile:function{var e=this;$("#"+e.pre+"dl_sequence").on("click",".icn3d-residue",function(i){$("#"+e.pre+"chainid").val(""),$("#"+e.pre+"structureid").val(""),$("#"+e.pre+"chainid2").val(""),$("#"+e.pre+"structureid2").val("");var t=$(this).attr("id");if(void 0!==t&&""!==t){"align"===t.substr(0,5)&&(t=t.substr(5)),e.bSelectResidue===!1&&(e.removeSeqChainBkgd,e.removeSeqResidueBkgd,e.selectedResidues={},e.icn3d.highlightAtoms={},e.icn3d.removeHighlightObjects,e.bSelectResidue=!0),$(this).toggleClass("icn3d-highlightSeq");var n=t.substr(t.indexOf("_")+1);if($(this).hasClass("icn3d-highlightSeq")){for(var o in e.icn3d.residues[n])e.icn3d.highlightAtoms[o]=1;e.selectedResidues[n]=1}else{for(var o in e.icn3d.residues[n])e.icn3d.highlightAtoms[o]=void 0;e.selectedResidues[n]=void 0,e.icn3d.removeHighlightObjects}}e.icn3d.addHighlightObjects}),$("#"+e.pre+"dl_sequence2").on("click",".icn3d-residue",function(i){$("#"+e.pre+"chainid").val(""),$("#"+e.pre+"structureid").val(""),$("#"+e.pre+"chainid2").val(""),$("#"+e.pre+"structureid2").val("");var t=$(this).attr("id");if(void 0!==t&&""!==t){"align"===t.substr(0,5)&&(t=t.substr(5)),e.bSelectAlignResidue===!1&&(e.removeSeqChainBkgd,e.removeSeqResidueBkgd,e.selectedResidues={},e.icn3d.highlightAtoms={},e.icn3d.removeHighlightObjects,e.bSelectAlignResidue=!0),$(this).toggleClass("icn3d-highlightSeq");var n=t.substr(t.indexOf("_")+1);if($(this).hasClass("icn3d-highlightSeq")){for(var o in e.icn3d.residues[n])e.icn3d.highlightAtoms[o]=1;e.selectedResidues[n]=1}else{for(var o in e.icn3d.residues[n])e.icn3d.highlightAtoms[o]=void 0;e.selectedResidues[n]=void 0,e.icn3d.removeHighlightObjects}}e.icn3d.addHighlightObjects})},selectChainMobile:function{var e=this;$("#"+e.pre+"dl_sequence").on("click",".icn3d-seqTitle",function(i){$("#"+e.pre+"chainid").val(""),$("#"+e.pre+"structureid").val(""),$("#"+e.pre+"chainid2").val(""),$("#"+e.pre+"structureid2").val("");var t=$(this).attr("chain");e.bSelectResidue=!1,e.removeSeqChainBkgd(t),e.removeSeqResidueBkgd,$(this).toggleClass("icn3d-highlightSeq");var n=$(this).attr("chain"),o=n;if($(this).hasClass("icn3d-highlightSeq")){var s="select chain "+n;e.selectAChain(n,o),e.setLogCommand(s,!0); }else e.icn3d.removeHighlightObjects,e.icn3d.highlightAtoms={},$("#"+e.pre+"customResidues").val(""),$("#"+e.pre+"customResidues2").val(""),$("#"+e.pre+"customAtoms").val("")}),$("#"+e.pre+"dl_sequence2").on("click",".icn3d-seqTitle",function(i){$("#"+e.pre+"chainid").val(""),$("#"+e.pre+"structureid").val(""),$("#"+e.pre+"chainid2").val(""),$("#"+e.pre+"structureid2").val("");var t=$(this).attr("chain");e.bSelectAlignResidue=!1,e.removeSeqChainBkgd(t),e.removeSeqResidueBkgd,$(this).toggleClass("icn3d-highlightSeq");var n=$(this).attr("chain"),o="align_"+n;$(this).hasClass("icn3d-highlightSeq")?(e.selectAAlignChain(n,o),e.setLogCommand("select alignChain "+n,!0)):(e.icn3d.removeHighlightObjects,e.icn3d.highlightAtoms={},$("#"+e.pre+"customResidues").val(""),$("#"+e.pre+"customResidues2").val(""),$("#"+e.pre+"customAtoms").val(""))})},clickStructureid:function{var e=this;$("#"+e.pre+"structureid").change(function(i){var t=$(this).val;$("#"+e.pre+"structureid2").val(""),e.changeStructureid(t)}),$("#"+e.pre+"structureid2").change(function(i){var t=$(this).val;$("#"+e.pre+"structureid").val(""),e.changeStructureid(t)}),$("#"+e.pre+"structureid").focus(function(i){e.isMobile&&$("#"+e.pre+"structureid").val(""),$(this).attr("size",$("#"+e.pre+"structureid option").length)}),$("#"+e.pre+"structureid").blur(function(e){$(this).attr("size",1)})},clickChainid:function{var e=this;$("#"+e.pre+"chainid").change(function(i){var t=$(this).val;$("#"+e.pre+"chainid2").val(""),e.changeChainid(t)}),$("#"+e.pre+"chainid2").change(function(i){var t=$(this).val;$("#"+e.pre+"chainid").val(""),e.changeChainid(t)}),$("#"+e.pre+"chainid").focus(function(i){e.isMobile&&$("#"+e.pre+"chainid").val(""),$(this).attr("size",$("#"+e.pre+"chainid option").length)}),$("#"+e.pre+"chainid").blur(function(e){$(this).attr("size",1)})},clickAlignChainid:function{var e=this;$("#"+e.pre+"alignChainid").change(function(i){var t=$(this).val;$("#"+e.pre+"alignChainid2").val,e.changeAlignChainid(t)}),$("#"+e.pre+"alignChainid2").change(function(i){var t=$(this).val;$("#"+e.pre+"alignChainid").val,e.changeAlignChainid(t)}),$("#"+e.pre+"alignChainid").focus(function(i){e.isMobile&&$("#"+e.pre+"alignChainid").val(""),$(this).attr("size",$("#"+e.pre+"alignChainid option").length)}),$("#"+e.pre+"alignChainid").blur(function(e){$(this).attr("size",1)})},clickCustomResidues:function{var e=this;$("#"+e.pre+"customResidues").change(function(i){var t=$(this).val;$("#"+e.pre+"customResidues2").val(""),null!==t&&(e.setLogCommand("select saved selection "+t.toString,!0),e.changeCustomResidues(t))}),$("#"+e.pre+"customResidues2").change(function(i){var t=$(this).val;$("#"+e.pre+"customResidues").val(""),null!==t&&(e.setLogCommand("select saved selection "+t.toString,!0),e.changeCustomResidues(t))}),$("#"+e.pre+"customResidues").focus(function(i){e.isMobile&&$("#"+e.pre+"customResidues").val(""),$(this).attr("size",$("#"+e.pre+"customResidues option").length)}),$("#"+e.pre+"customResidues").blur(function(e){$(this).attr("size",1)})},clickCustomAtoms:function{var e=this;$("#"+e.pre+"customAtoms").change(function(i){var t=$(this).val;null!==t&&(e.setLogCommand("select saved atoms "+t.toString,!0),e.changeCustomAtoms(t))}),$("#"+e.pre+"customAtoms").focus(function(i){e.isMobile&&$("#"+e.pre+"customAtoms").val("")})},clickShow_selected:function{var e=this;$("#"+e.pre+"show_selected").add("#"+e.pre+"menu2_show_selected").click(function(i){e.setLogCommand("show selection",!0),e.showSelection})},clickShow_sequences:function{var e=this;$("#"+e.pre+"show_sequences").click(function(i){e.openDialog(e.pre+"dl_selectresidues","Select residues in sequences")})},clickShow_alignsequences:function{var e=this;$("#"+e.pre+"show_alignsequences").click(function(i){e.openDialog(e.pre+"dl_alignment","Select residues in aligned sequences")})},clickShow_selected_atom:function{var e=this;$("#"+e.pre+"show_selected_atom").click(function(i){i.preventDefault,e.setLogCommand("show selection",!0),e.showSelection})},clickCommand_apply:function{var e=this;$("#"+e.pre+"command_apply").click(function(i){i.preventDefault;var t=$("#"+e.pre+"command").val,n=$("#"+e.pre+"command_name").val.replace(/;/g,"_").replace(/\s+/g,"_"),o=$("#"+e.pre+"command_desc").val.replace(/;/g,"_").replace(/\s+/g,"_");e.setLogCommand("select "+t+" | name "+n+" | description "+o,!0),e.selectByCommand(t,n,o)})},clickReload_pdb:function{var e=this;$("#"+e.pre+"reload_pdb").click(function(i){i.preventDefault,dialog.dialog("close"),e.setLogCommand("load pdb "+$("#"+e.pre+"pdbid").val,!1),window.open("http://www.ncbi.nlm.nih.gov/Structure/icn3d/full.html?pdbid="+$("#"+e.pre+"pdbid").val,"_blank")})},clickReload_mmcif:function{var e=this;$("#"+e.pre+"reload_mmcif").click(function(i){i.preventDefault,dialog.dialog("close"),e.setLogCommand("load mmcif "+$("#"+e.pre+"mmcifid").val,!1),window.open("https://www.ncbi.nlm.nih.gov/Structure/icn3d/full.html?mmcifid="+$("#"+e.pre+"mmcifid").val,"_blank")})},clickReload_mmdb:function{var e=this;$("#"+e.pre+"reload_mmdb").click(function(i){i.preventDefault,dialog.dialog("close"),e.setLogCommand("load mmdb "+$("#"+e.pre+"mmdbid").val,!1),window.open("https://www.ncbi.nlm.nih.gov/Structure/icn3d/full.html?mmdbid="+$("#"+e.pre+"mmdbid").val,"_blank")})},clickReload_gi:function{var e=this;$("#"+e.pre+"reload_gi").click(function(i){i.preventDefault,dialog.dialog("close"),e.setLogCommand("load gi "+$("#"+e.pre+"gi").val,!1),window.open("https://www.ncbi.nlm.nih.gov/Structure/icn3d/full.html?gi="+$("#"+e.pre+"gi").val,"_blank")})},clickReload_cid:function{var e=this;$("#"+e.pre+"reload_cid").click(function(i){i.preventDefault,dialog.dialog("close"),e.setLogCommand("load cid "+$("#"+e.pre+"cid").val,!1),window.open("https://www.ncbi.nlm.nih.gov/Structure/icn3d/full.html?cid="+$("#"+e.pre+"cid").val,"_blank")})},clickReload_state:function{var e=this;$("#"+e.pre+"reload_state").click(function(i){i.preventDefault,dialog.dialog("close");var t=$("#"+e.pre+"state")[0].files[0];if(t){window.File&&window.FileReader&&window.FileList&&window.Blob||alert("The File APIs are not fully supported in this browser.");var n=new FileReader;n.onload=function(i){var t=i.target.result;e.setLogCommand("load state file "+$("#"+e.pre+"state").val,!1),e.icn3d.commands=[],e.icn3d.optionsHistory=[],e.loadScript(t,!0)},n.readAsText(t)}else alert("Please select a file before clicking 'Load'")})},clickReload_selectionfile:function{var e=this;$("#"+e.pre+"reload_selectionfile").click(function(i){i.preventDefault,dialog.dialog("close");var t=$("#"+e.pre+"selectionfile")[0].files[0];if(t){window.File&&window.FileReader&&window.FileList&&window.Blob||alert("The File APIs are not fully supported in this browser.");var n=new FileReader;n.onload=function(i){var t=i.target.result;e.setLogCommand("load selection file "+$("#"+e.pre+"selectionfile").val,!1),e.loadSelection(t)},n.readAsText(t)}else alert("Please select a file before clicking 'Load'")})},clickReload_pdbfile:function{var e=this;$("#"+e.pre+"reload_pdbfile").click(function(i){i.preventDefault,dialog.dialog("close");var t=$("#"+e.pre+"pdbfile")[0].files[0];if(t){window.File&&window.FileReader&&window.FileList&&window.Blob||alert("The File APIs are not fully supported in this browser.");var n=new FileReader;n.onload=function(i){var t=i.target.result;e.setLogCommand("load pdb file "+$("#"+e.pre+"pdbfile").val,!1),e.icn3d.moleculeTitle="",e.loadPdbData(t)},n.readAsText(t)}else alert("Please select a file before clicking 'Load'")})},clickReload_mol2file:function{var e=this;$("#"+e.pre+"reload_mol2file").click(function(i){i.preventDefault,dialog.dialog("close");var t=$("#"+e.pre+"mol2file")[0].files[0];if(t){window.File&&window.FileReader&&window.FileList&&window.Blob||alert("The File APIs are not fully supported in this browser.");var n=new FileReader;n.onload=function(i){var t=i.target.result;e.setLogCommand("load mol2 file "+$("#"+e.pre+"mol2file").val,!1),e.icn3d.moleculeTitle="",e.inputid=void 0,e.loadMol2Data(t)},n.readAsText(t)}else alert("Please select a file before clicking 'Load'")})},clickReload_sdffile:function{var e=this;$("#"+e.pre+"reload_sdffile").click(function(i){i.preventDefault,dialog.dialog("close");var t=$("#"+e.pre+"sdffile")[0].files[0];if(t){window.File&&window.FileReader&&window.FileList&&window.Blob||alert("The File APIs are not fully supported in this browser.");var n=new FileReader;n.onload=function(i){var t=i.target.result;e.setLogCommand("load sdf file "+$("#"+e.pre+"sdffile").val,!1),e.icn3d.moleculeTitle="",e.inputid=void 0,e.loadSdfData(t)},n.readAsText(t)}else alert("Please select a file before clicking 'Load'")})},clickReload_xyzfile:function{var e=this;$("#"+e.pre+"reload_xyzfile").click(function(i){i.preventDefault,dialog.dialog("close");var t=$("#"+e.pre+"xyzfile")[0].files[0];if(t){window.File&&window.FileReader&&window.FileList&&window.Blob||alert("The File APIs are not fully supported in this browser.");var n=new FileReader;n.onload=function(i){var t=i.target.result;e.setLogCommand("load xyz file "+$("#"+e.pre+"xyzfile").val,!1),e.icn3d.moleculeTitle="",e.inputid=void 0,e.loadXyzData(t)},n.readAsText(t)}else alert("Please select a file before clicking 'Load'")})},clickReload_mmciffile:function{var e=this;$("#"+e.pre+"reload_mmciffile").click(function(i){i.preventDefault,dialog.dialog("close");var t=$("#"+e.pre+"mmciffile")[0].files[0];if(t){window.File&&window.FileReader&&window.FileList&&window.Blob||alert("The File APIs are not fully supported in this browser.");var n=new FileReader;n.onload=function(i){var t=i.target.result;e.setLogCommand("load mmcif file "+$("#"+e.pre+"mmciffile").val,!1),e.icn3d.moleculeTitle="";var n="//www.ncbi.nlm.nih.gov/Structure/mmcifparser/mmcifparser.cgi";e.icn3d.bCid=void 0,$.ajax({url:n,type:"POST",data:{mmciffile:t},dataType:"jsonp",cache:!0,beforeSend:function{$("#"+e.pre+"wait")&&$("#"+e.pre+"wait").show,$("#"+e.pre+"canvas")&&$("#"+e.pre+"canvas").hide,$("#"+e.pre+"commandlog")&&$("#"+e.pre+"commandlog").hide},complete:function{$("#"+e.pre+"wait")&&$("#"+e.pre+"wait").hide,$("#"+e.pre+"canvas")&&$("#"+e.pre+"canvas").show,$("#"+e.pre+"commandlog")&&$("#"+e.pre+"commandlog").show},success:function(i){e.loadMmcifData(i)}})},n.readAsText(t)}else alert("Please select a file before clicking 'Load'")})},clickApplycustomcolor:function{var e=this;$("#"+e.pre+"applycustomcolor").click(function(i){i.preventDefault,dialog.dialog("close"),e.setOption("color",$("#"+e.pre+"color").val),e.setLogCommand("color "+$("#"+e.pre+"color").val,!0)})},clickApplypick_aroundsphere:function{var e=this;$("#"+e.pre+"applypick_aroundsphere").click(function(i){i.preventDefault,dialog.dialog("close");var t=$("#"+e.pre+"radius_aroundsphere").val,n="select zone cutoff "+t;e.setLogCommand(n,!0),e.pickCustomSphere(t)})},clickApplyhbonds:function{var e=this;$("#"+e.pre+"applyhbonds").click(function(i){i.preventDefault,dialog.dialog("close");var t=$("#"+e.pre+"hbondthreshold").val,n="hbonds "+t;e.setLogCommand(n,!0),e.showHbonds(t)})},clickApplypick_labels:function{var e=this;$("#"+e.pre+"applypick_labels").click(function(i){i.preventDefault,dialog.dialog("close");var t=$("#"+e.pre+"labeltext").val,n=$("#"+e.pre+"labelsize").val,o=$("#"+e.pre+"labelcolor").val,s=$("#"+e.pre+"labelbkgd").val;if(("0"===s||""===s||"undefined"===s)&&(s=void 0),void 0===e.icn3d.pickedatom||void 0===e.icn3d.pickedatom2)alert("Please pick another atom");else{var r=(e.icn3d.pickedatom.coord.x+e.icn3d.pickedatom2.coord.x)/2,a=(e.icn3d.pickedatom.coord.y+e.icn3d.pickedatom2.coord.y)/2,c=(e.icn3d.pickedatom.coord.z+e.icn3d.pickedatom2.coord.z)/2;e.setLogCommand("add label "+t+" | x "+r+" y "+a+" z "+c+" | size "+n+" | color "+o+" | background "+s+" | type custom",!0),e.addLabel(t,r,a,c,n,o,s,"custom"),e.icn3d.pickpair=!1,e.icn3d.draw}})},clickApplyselection_labels:function{var e=this;$("#"+e.pre+"applyselection_labels").click(function(i){i.preventDefault,dialog.dialog("close");var t=$("#"+e.pre+"labeltext2").val,n=$("#"+e.pre+"labelsize2").val,o=$("#"+e.pre+"labelcolor2").val,s=$("#"+e.pre+"labelbkgd2").val;("0"===s||""===s||"undefined"===s)&&(s=void 0);var r=e.icn3d.centerAtoms(e.icn3d.hash2Atoms(e.icn3d.highlightAtoms)),a=r.center.x,c=r.center.y,l=r.center.z;e.setLogCommand("add label "+t+" | size "+n+" | color "+o+" | background "+s+" | type custom",!0),e.addLabel(t,a,c,l,n,o,s,"custom"),e.icn3d.draw})},clickApplypick_measuredistance:function{var e=this;$("#"+e.pre+"applypick_measuredistance").click(function(i){if(i.preventDefault,dialog.dialog("close"),void 0===e.icn3d.pickedatom||void 0===e.icn3d.pickedatom2)alert("Please pick another atom");else{var t,n,o,s=parseInt(10*e.icn3d.pickedatom.coord.distanceTo(e.icn3d.pickedatom2.coord))/10,r=s.toString+" A",a=(e.icn3d.pickedatom.coord.x+e.icn3d.pickedatom2.coord.x)/2,c=(e.icn3d.pickedatom.coord.y+e.icn3d.pickedatom2.coord.y)/2,l=(e.icn3d.pickedatom.coord.z+e.icn3d.pickedatom2.coord.z)/2;e.setLogCommand("add label "+r+" | x "+a+" y "+c+" z "+l+" | size "+t+" | color "+n+" | background "+o+" | type distance",!0),e.addLabel(r,a,c,l,t,n,o,"distance");var n="#FFFF00",d=!0;e.setLogCommand("add line | x1 "+e.icn3d.pickedatom.coord.x+" y1 "+e.icn3d.pickedatom.coord.y+" z1 "+e.icn3d.pickedatom.coord.z+" | x2 "+e.icn3d.pickedatom2.coord.x+" y2 "+e.icn3d.pickedatom2.coord.y+" z2 "+e.icn3d.pickedatom2.coord.z+" | color "+n+" | dashed "+d+" | type distance",!0),e.addLine(e.icn3d.pickedatom.coord.x,e.icn3d.pickedatom.coord.y,e.icn3d.pickedatom.coord.z,e.icn3d.pickedatom2.coord.x,e.icn3d.pickedatom2.coord.y,e.icn3d.pickedatom2.coord.z,n,d,"distance"),e.icn3d.pickpair=!1,e.icn3d.draw}})},clickReset:function{var e=this;$("#"+e.pre+"reset").click(function(i){e.setLogCommand("reset",!0),e.icn3d.maxD=e.icn3d.oriMaxD,e.icn3d.center=e.icn3d.oriCenter.clone,e.icn3d.reinitAfterLoad,e.renderFinalStep(1),e.removeSeqChainBkgd,e.removeSeqResidueBkgd})},toggleHighlight:function{var e=this;e.setLogCommand("toggle highlight",!0),e.icn3d.prevHighlightObjects.length>0?(e.icn3d.removeHighlightObjects,e.icn3d.render,e.removeSeqChainBkgd,e.removeSeqResidueBkgd,e.bSelectResidue=!1):(e.icn3d.addHighlightObjects,e.updateSeqWinForCurrentAtoms,e.bSelectResidue=!0)},clearHighlight:function{var e=this;e.setLogCommand("clear selection",!0),e.icn3d.removeHighlightObjects,e.icn3d.render,e.removeSeqChainBkgd,e.removeSeqResidueBkgd,e.bSelectResidue=!1},clickToggleHighlight:function{var e=this;$("#"+e.pre+"toggleHighlight").add("#"+e.pre+"toggleHighlight2").click(function(i){e.toggleHighlight}),$(document).on("click","#"+e.pre+"seq_clearselection",function(i){e.clearHighlight}),$(document).on("click","#"+e.pre+"alignseq_clearselection",function(i){e.clearHighlight})},pressCommandtext:function{var e=this;$("#"+e.pre+"logtext").keypress(function(i){e.bAddLogs=!1;var t=i.keyCode?i.keyCode:i.which;if(13==t){i.preventDefault;var n=$(this).val;e.icn3d.bRender=!0;var o=n.split("\n"),s=o[o.length-1].substr(2);if(e.icn3d.logs.push(s),$("#"+e.pre+"logtext").val("> "+e.icn3d.logs.join("\n> ")+"\n> ").scrollTop($("#"+e.pre+"logtext")[0].scrollHeight),""!==s){var r={};r.factor=e.icn3d._zoomFactor,r.mouseChange=e.icn3d.mouseChange,r.quaternion=e.icn3d.quaternion,e.icn3d.commands.push(s+"|||"+JSON.stringify(r)),e.icn3d.optionsHistory.push(e.icn3d.cloneHash(e.icn3d.options)),e.icn3d.optionsHistory[e.icn3d.optionsHistory.length-1].hlatomcount=Object.keys(e.icn3d.highlightAtoms).length,e.isSessionStorageSupported&&e.saveCommandsToSession,e.STATENUMBER=e.icn3d.commands.length,e.applyCommand(s+"|||"+JSON.stringify(r)),e.saveSelectionIfSelected,e.icn3d.draw}}e.bAddLogs=!0})},clickFilter_ckbx_all:function{var e=this;$("#"+e.pre+"filter_ckbx_all").click(function(i){var t=document.getElementsByName(e.pre+"filter_ckbx");if(1==$(this)[0].checked)for(var n=0,o=t.length;o>n;++n)t[n].checked=!0;else for(var n=0,o=t.length;o>n;++n)t[n].checked=!1})},clickFilter:function{var e=this;$("#"+e.pre+"filter").click(function(i){for(var t=document.getElementsByName(e.pre+"filter_ckbx"),n="",o="&het=0",s=0,r=t.length;r>s;++s)t[s].checked&&("ligands"==t[s].value?o="&het=2":n+=t[s].value+",");""==n&&(n=t[0].value);var a=document.URL+"&mols="+n+"&complexity=2"+o;window.open(a,"_self")})},saveSelection:function{var e=this;e.bSelectResidue=!1;var i=$("#"+e.pre+"seq_command_name").val.replace(/\s+/g,"_"),t=$("#"+e.pre+"seq_command_desc").val;if(0===Object.keys(e.selectedResidues).length)for(var n in e.icn3d.highlightAtoms){var o=e.icn3d.atoms[n].structure+"_"+e.icn3d.atoms[n].chain+"_"+e.icn3d.atoms[n].resi;e.selectedResidues[o]=1}e.setLogCommand("select "+e.residueids2spec(Object.keys(e.selectedResidues))+" | name "+i+" | description "+t,!0),e.selectResidueList(e.selectedResidues,i,t),e.updateSelectionNameDesc},clickSeqSaveSelection:function{var e=this;$(document).on("click","#"+e.pre+"seq_saveselection",function(i){e.saveSelection})},clickAlignSeqSaveSelection:function{var e=this;$(document).on("click","#"+e.pre+"alignseq_saveselection",function(i){e.bSelectAlignResidue=!1;var t=$("#"+e.pre+"alignseq_command_name").val.replace(/\s+/g,"_"),n=$("#"+e.pre+"alignseq_command_desc").val;if(0===Object.keys(e.selectedResidues).length)for(var o in e.icn3d.highlightAtoms){var s=e.icn3d.atoms[o].structure+"_"+e.icn3d.atoms[o].chain+"_"+e.icn3d.atoms[o].resi;e.selectedResidues[s]=1}e.setLogCommand("select "+e.residueids2spec(Object.keys(e.selectedResidues))+" | name "+t+" | description "+n,!0),e.selectResidueList(e.selectedResidues,t,n),e.updateSelectionNameDesc})},clickOutputSelection:function{var e=this;$(document).on("click","."+e.pre+"outputselection",function(i){e.bSelectResidue=!1,e.bSelectAlignResidue=!1,e.setLogCommand("output selection",!0),e.outputSelection})},bindMouseup:function{var e=this;$("accordion").bind("mouseup touchend",function(i){e.icn3d.controls&&(e.icn3d.controls.noRotate=!1,e.icn3d.controls.noZoom=!1,e.icn3d.controls.noPan=!1)})},bindMousedown:function{var e=this;$("accordion").bind("mousedown touchstart",function(i){e.icn3d.controls&&(e.icn3d.controls.noRotate=!0,e.icn3d.controls.noZoom=!0,e.icn3d.controls.noPan=!0)})},getCommandsBeforeCrash:function{var e=this;window.addEventListener("load",function{sessionStorage.setItem("good_exit","pending")}),window.addEventListener("beforeunload",function{sessionStorage.setItem("good_exit","true")}),sessionStorage.getItem("good_exit")&&"pending"===sessionStorage.getItem("good_exit")&&(e.isMac||(e.bCrashed=!0),e.commandsBeforeCrash=sessionStorage.getItem("commands"))},allEventFunctions:function{var e=this;e.isMobile?(e.selectSequenceMobile,e.selectChainMobile):e.selectSequenceNonMobile,e.clickBack,e.clickForward,e.clickToggle,e.clickHlColorYellow,e.clickHlColorGreen,e.clickHlColorRed,e.clickHlStyleOutline,e.clickHlStyleObject,e.clickAlternate,e.clickMenu1_pdbid,e.clickMenu1_pdbfile,e.clickMenu1_mol2file,e.clickMenu1_sdffile,e.clickMenu1_xyzfile,e.clickMenu1_mmciffile,e.clickMenu1_mmcifid,e.clickMenu1_mmdbid,e.clickMenu1_gi,e.clickMenu1_cid,e.clickMenu1_state,e.clickMenu1_selection,e.clickMenu1_exportState,e.clickMenu1_exportCanvas,e.clickMenu1_exportCounts,e.clickMenu1_exportSelections,e.clickMenu1_sharelink,e.clickMenu1_link_structure,e.clickMenu1_link_bind,e.clickMenu1_link_vast,e.clickMenu1_link_pubmed,e.clickMenu2_selectresidues,e.clickMenu2_selectcomplement,e.clickMenu2_selectall,e.clickMenu2_alignment,e.clickMenu2_command,e.clickMenu2_pickingYes,e.clickMenu2_pickingNo,e.clickMenu2_pickingResidue,e.clickMenu2_pickingStrand,e.clickMenu2_aroundsphere,e.clickMenu2_select_chain,e.clickmenu3_proteinsRibbon,e.clickmenu3_proteinsStrand,e.clickmenu3_proteinsCylinder,e.clickMenu3_proteinsSchematic,e.clickmenu3_proteinsCalpha,e.clickmenu3_proteinsBfactor,e.clickmenu3_proteinsLines,e.clickmenu3_proteinsStick,e.clickmenu3_proteinsBallstick,e.clickmenu3_proteinsSphere,e.clickmenu3_proteinsNothing,e.clickMenu3_sidechainsLines,e.clickMenu3_sidechainsStick,e.clickMenu3_sidechainsBallstick,e.clickMenu3_sidechainsSphere,e.clickMenu3_sidechainsNothing,e.clickmenu3_nuclCartoon,e.clickmenu3_nuclSchematic,e.clickmenu3_nuclPhos,e.clickmenu3_nuclLines,e.clickmenu3_nuclStick,e.clickmenu3_nuclBallstick,e.clickmenu3_nuclSphere,e.clickmenu3_nuclNothing,e.clickMenu3_ligandsLines,e.clickMenu3_ligandsStick,e.clickMenu3_ligandsBallstick,e.clickMenu3_ligandsSchematic,e.clickMenu3_ligandsSphere,e.clickMenu3_ligandsNothing,e.clickMenu3_ionsSphere,e.clickMenu3_ionsDot,e.clickMenu3_ionsNothing,e.clickMenu3_waterSphere,e.clickMenu3_waterDot,e.clickMenu3_waterNothing,e.clickMenu4_colorSpectrum,e.clickMenu4_colorChain,e.clickMenu4_colorSS,e.clickMenu4_colorResidue,e.clickMenu4_colorCharge,e.clickMenu4_colorHydrophobic,e.clickMenu4_colorAtom,e.clickMenu4_colorConserved,e.clickMenu4_colorRed,e.clickMenu4_colorGreen,e.clickMenu4_colorBlue,e.clickMenu4_colorMagenta,e.clickMenu4_colorYellow,e.clickMenu4_colorCyan,e.clickMenu4_colorWhite,e.clickMenu4_colorGrey,e.clickMenu4_colorCustom,e.clickMenu5_neighborsYes,e.clickMenu5_neighborsNo,e.clickMenu5_surfaceVDW,e.clickMenu5_surfaceSAS,e.clickMenu5_surfaceMolecular,e.clickMenu5_surfaceNothing,e.clickMenu5_opacity10,e.clickMenu5_opacity09,e.clickMenu5_opacity08,e.clickMenu5_opacity07,e.clickMenu5_opacity06,e.clickMenu5_opacity05,e.clickMenu5_wireframeYes,e.clickMenu5_wireframeNo,e.clickMenu6_assemblyYes,e.clickMenu6_assemblyNo,e.clickMenu6_addlabelResidues,e.clickMenu6_addlabelYes,e.clickMenu6_addlabelSelection,e.clickMenu6_addlabelNo,e.clickMenu6_distanceYes,e.clickMenu6_distanceNo,e.clickmenu2_selectedcenter,e.clickMenu6_center,e.clickMenu6_resetorientation,e.clickMenu6_rotateleft,e.clickMenu6_rotateright,e.clickMenu6_rotateup,e.clickMenu6_rotatedown,e.clickMenu6_cameraPers,e.clickMenu6_cameraOrth,e.clickMenu6_bkgdBlack,e.clickMenu6_bkgdGrey,e.clickMenu6_bkgdWhite,e.clickMenu6_showfogYes,e.clickMenu6_showfogNo,e.clickMenu6_showslabYes,e.clickMenu6_showslabNo,e.clickMenu6_showaxisYes,e.clickMenu6_showaxisNo,e.clickMenu6_hbondsYes,e.clickMenu6_hbondsNo,e.clickStructureid,e.clickChainid,e.clickAlignChainid,e.clickCustomResidues,e.clickCustomAtoms,e.clickShow_selected,e.clickShow_sequences,e.clickShow_alignsequences,e.clickShow_selected_atom,e.clickCommand_apply,e.clickReload_pdb,e.clickReload_pdbfile,e.clickReload_mol2file,e.clickReload_sdffile,e.clickReload_xyzfile,e.clickReload_mmciffile,e.clickReload_mmcif,e.clickReload_mmdb,e.clickReload_gi,e.clickReload_cid,e.clickReload_state,e.clickReload_selectionfile,e.clickApplycustomcolor,e.clickApplypick_aroundsphere,e.clickApplyhbonds,e.clickApplypick_labels,e.clickApplyselection_labels,e.clickApplypick_measuredistance,e.clickReset,e.clickToggleHighlight,e.pressCommandtext,e.clickFilter_ckbx_all,e.clickFilter,e.clickHighlight_3d_diagram,e.clickSeqSaveSelection,e.clickAlignSeqSaveSelection,e.clickOutputSelection,e.bindMouseup,e.bindMousedown,e.windowResize},allCustomEvents:function{}},iCn3DUI.prototype.clickHighlight_3d_diagram=function{var e=this;$("#"+e.pre+"highlight_3d_diagram").click(function(i){e.icn3d.removeHighlightObjects;var t=document.getElementsByName(e.pre+"filter_ckbx"),n={},o={};e.icn3d.highlightAtoms={};for(var s=0,r=t.length;r>s;++s)if(t[s].checked&&"ligands"!=t[s].value){var a=t[s].value,c=t[s].getAttribute("chain");e.icn3d.molid2ss.hasOwnProperty(a)?(n[a]=e.icn3d.molid2ss[a],o[a]=e.icn3d.molid2color[a]):e.icn3d.highlightAtoms=e.icn3d.unionHash(e.icn3d.highlightAtoms,e.icn3d.chains[c])}e.icn3d.drawHelixBrick(n,o,e.icn3d.bHighlight),e.icn3d.addHighlightObjects(void 0,!1),e.icn3d.render})},iCn3DUI.prototype.rotateStructure=function(e,i){var t=this;if(t.icn3d.bStopRotate)return!1;if(t.icn3d.rotateCount>t.icn3d.rotateCountMax)return!1;if(++t.icn3d.rotateCount,void 0!==i&&i)if("left"===e)t.ROTATION_DIRECTION="left";else if("right"===e)t.ROTATION_DIRECTION="right";else if("up"===e)t.ROTATION_DIRECTION="up";else{if("down"!==e)return!1;t.ROTATION_DIRECTION="down"}if("left"===e&&"left"===t.ROTATION_DIRECTION)t.icn3d.rotateLeft(1);else if("right"===e&&"right"===t.ROTATION_DIRECTION)t.icn3d.rotateRight(1);else if("up"===e&&"up"===t.ROTATION_DIRECTION)t.icn3d.rotateUp(1);else{if("down"!==e||"down"!==t.ROTATION_DIRECTION)return!1;t.icn3d.rotateDown(1)}setTimeout(function{t.rotateStructure(e)},100)},iCn3DUI.prototype.showTitle=function{var e=this;if(void 0!==e.icn3d.moleculeTitle&&""!==e.icn3d.moleculeTitle){var i=e.icn3d.moleculeTitle;if(void 0===e.inputid)e.icn3d.moleculeTitle.length>40&&(i=e.icn3d.moleculeTitle.substr(0,40)+"..."),$("#"+e.pre+"title").html(i);else if(void 0!==e.cfg.cid){var t=e.getLinkToStructureSummary;$("#"+e.pre+"title").html(i+" (PubChem CID <a href='"+t+"' target='_blank' style='color:"+e.GREYD+"'>"+e.inputid.toUpperCase+"</a>)")}else if(void 0!==e.cfg.align)$("#"+e.pre+"title").html(i);else{var t=e.getLinkToStructureSummary;e.icn3d.moleculeTitle.length>40&&(i=e.icn3d.moleculeTitle.substr(0,40)+"..."),$("#"+e.pre+"title").html(i+" (PDB ID <a href='"+t+"' target='_blank' style='color:"+e.GREYD+"'>"+e.inputid.toUpperCase+"</a>)")}}else $("#"+e.pre+"title").html("")},iCn3DUI.prototype.getLinkToStructureSummary=function(e){var i=this,t="https://www.ncbi.nlm.nih.gov/structure/?term=";if(t=void 0!==i.cfg.cid?"https://www.ncbi.nlm.nih.gov/pccompound/?term=":-1!==i.inputid.indexOf(",")?"https://www.ncbi.nlm.nih.gov/structure/?term=":"https://www.ncbi.nlm.nih.gov/Structure/mmdb/mmdbsrv.cgi?uid=",void 0===i.inputid)t="https://www.ncbi.nlm.nih.gov/pccompound/?term="+i.moleculeTitle;else{var n=i.inputid.split("_");1===n.length?(t+=i.inputid,void 0!==e&&e&&i.setLogCommand("link to Structure Summary "+i.inputid+": "+t,!1)):2===n.length&&(t+=n[0]+" OR "+n[1],void 0!==e&&e&&i.setLogCommand("link to structures "+n[0]+" and "+n[1]+": "+t,!1))}return t},iCn3DUI.prototype.isIE=function{var e=window.navigator.userAgent,i=e.indexOf("MSIE ");return i>0||navigator.userAgent.match(/Trident.*rv\:11\./)?!0:!1},iCn3DUI.prototype.saveFile=function(e,i,t){var n=this;if(n.isIE){if(window.navigator.msSaveBlob)if("command"===i){for(var o="",s=0,r=n.icn3d.commands.length;r>s;++s)o+=n.icn3d.commands[s].trim+"\n";var a=decodeURIComponent(o),c=new Blob([a],{type:"text;charset=utf-8;"});navigator.msSaveBlob(c,e)}else if("png"===i){n.icn3d.render;var c=n.icn3d.renderer.domElement.msToBlob;navigator.msSaveBlob(c,e)}else if("html"===i){var o=t,a=decodeURIComponent(o),c=new Blob([a],{type:"text/html;charset=utf-8;"});navigator.msSaveBlob(c,e)}else if("text"===i){var o=t,a=decodeURIComponent(o),c=new Blob([a],{type:"text;charset=utf-8;"});navigator.msSaveBlob(c,e)}}else{var a;if("command"===i){for(var o="",s=0,r=n.icn3d.commands.length;r>s;++s)o+=n.icn3d.commands[s].trim+"\n";a="data:text;charset=utf-8,"+encodeURIComponent(o)}else if("png"===i){n.icn3d.render;var o=n.icn3d.renderer.domElement.toDataURL("image/png");a=o}else if("html"===i){var o=t;a="data:text/html;charset=utf-8,"+encodeURIComponent(o)}else if("text"===i){var o=t;a="data:text;charset=utf-8,"+encodeURIComponent(o)}window.open(a,"_blank")}},iCn3DUI.prototype.isMobile=function{return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)},iCn3DUI.prototype.isMac=function{return/Mac/i.test(navigator.userAgent)},iCn3DUI.prototype.isSessionStorageSupported=function{var e="test";try{return sessionStorage.setItem(e,"1"),sessionStorage.removeItem(e),!0}catch(i){return!1}},iCn3DUI.prototype.downloadPdb=function(e){var i,t,n=this;if("https:"===document.location.protocol){var o=document.location.href;return o=o.replace("https","http"),void window.open(o,"_self")}i="http://files.rcsb.org/view/"+e+".pdb",t="text",n.icn3d.bCid=void 0,$.ajax({url:i,dataType:t,cache:!0,beforeSend:function{$("#"+n.pre+"wait")&&$("#"+n.pre+"wait").show,$("#"+n.pre+"canvas")&&$("#"+n.pre+"canvas").hide,$("#"+n.pre+"commandlog")&&$("#"+n.pre+"commandlog").hide},complete:function{$("#"+n.pre+"wait")&&$("#"+n.pre+"wait").hide,$("#"+n.pre+"canvas")&&$("#"+n.pre+"canvas").show,$("#"+n.pre+"commandlog")&&$("#"+n.pre+"commandlog").show},success:function(e){"https:"!==document.location.protocol?n.loadPdbData(e):n.loadPdbData(e.data)}})},iCn3DUI.prototype.loadPdbData=function(e){var i=this;i.icn3d.loadPDB(e),i.pmid=i.icn3d.pmid,void 0===i.cfg.align&&1==Object.keys(i.icn3d.structures).length&&$("#"+i.pre+"alternateWrapper").hide,i.icn3d.setAtomStyleByOptions(i.options),i.icn3d.setColorByOptions(i.options,i.icn3d.atoms),i.renderStructure,i.showTitle,void 0!==i.cfg.rotate&&i.rotateStructure(i.cfg.rotate,!0),void 0!==i.deferred&&i.deferred.resolve,void 0!==i.deferred2&&i.deferred2.resolve},iCn3DUI.prototype.downloadMmcif=function(e){var i,t=this;return"https:"===document.location.protocol?(i=document.location.href,i=i.replace("https","http"),void window.open(i,"_self")):(i="http://files.rcsb.org/view/"+e+".cif",t.icn3d.bCid=void 0,void $.ajax({url:i,dataType:"text",cache:!0,beforeSend:function{$("#"+t.pre+"wait")&&$("#"+t.pre+"wait").show,$("#"+t.pre+"canvas")&&$("#"+t.pre+"canvas").hide,$("#"+t.pre+"commandlog")&&$("#"+t.pre+"commandlog").hide},complete:function{$("#"+t.pre+"wait")&&$("#"+t.pre+"wait").hide,$("#"+t.pre+"canvas")&&$("#"+t.pre+"canvas").show,$("#"+t.pre+"commandlog")&&$("#"+t.pre+"commandlog").show},success:function(e){i="//www.ncbi.nlm.nih.gov/Structure/mmcifparser/mmcifparser.cgi",$.ajax({url:i,type:"POST",data:{mmciffile:e},dataType:"jsonp",cache:!0,beforeSend:function{$("#"+t.pre+"wait")&&$("#"+t.pre+"wait").show,$("#"+t.pre+"canvas")&&$("#"+t.pre+"canvas").hide,$("#"+t.pre+"commandlog")&&$("#"+t.pre+"commandlog").hide},complete:function{$("#"+t.pre+"wait")&&$("#"+t.pre+"wait").hide,$("#"+t.pre+"canvas")&&$("#"+t.pre+"canvas").show,$("#"+t.pre+"commandlog")&&$("#"+t.pre+"commandlog").show},success:function(e){t.loadMmcifData(e)}})}}))},iCn3DUI.prototype.loadMmcifData=function(e){var i=this;if(void 0===e.atoms)return alert("invalid atoms data."),!1;i.loadAtomDataIn(e,e.mmcif,"mmcifid"),void 0===i.cfg.align&&1==Object.keys(i.icn3d.structures).length&&$("#"+i.pre+"alternateWrapper").hide;for(var t=e.assembly,n=0,o=t.length;o>n;++n){void 0==i.icn3d.biomtMatrices[n]&&(i.icn3d.biomtMatrices[n]=(new THREE.Matrix4).identity);for(var s=0,r=t[n].length;r>s;++s)i.icn3d.biomtMatrices[n].elements[s]=t[n][s]}i.icn3d.setAtomStyleByOptions(i.options),i.icn3d.setColorByOptions(i.options,i.icn3d.atoms),i.renderStructure,void 0!==i.cfg.rotate&&i.rotateStructure(i.cfg.rotate,!0),void 0!==i.cfg.showseq&&i.cfg.showseq&&i.openDialog(i.pre+"dl_selectresidues","Select residues in sequences"),void 0!==i.deferred&&i.deferred.resolve,void 0!==i.deferred2&&i.deferred2.resolve},iCn3DUI.prototype.downloadAlignment=function(e){var i=this;if(i.options.proteins="c alpha trace",i.icn3d.options.proteins="c alpha trace",i.bFullUi&&i.isMac&&i.isMobile){i.MENU_WIDTH=950,i.setViewerWidthHeight;var t=i.WIDTH-i.LESSWIDTH,n=i.HEIGHT-i.LESSHEIGHT;i.resizeCanvas(t,n,!0,!1)}var o=e.split(","),s=(2===o.length?"uids=":"ids=")+e,r="https://www.ncbi.nlm.nih.gov/Structure/vastplus/vastplus.cgi?cmd=c&w3d&"+s,a="https://www.ncbi.nlm.nih.gov/Structure/vastplus/vastplus.cgi?cmd=c1&d&"+s;void 0!==i.cfg.inpara&&(r+=i.cfg.inpara,a+=i.cfg.inpara),i.icn3d.bCid=void 0,i.icn3d.pdbid_chain2title={};var c=$.ajax({url:a,dataType:"jsonp",cache:!0,beforeSend:function{$("#"+i.pre+"wait")&&$("#"+i.pre+"wait").show, $("#"+i.pre+"canvas")&&$("#"+i.pre+"canvas").hide,$("#"+i.pre+"commandlog")&&$("#"+i.pre+"commandlog").hide},complete:function{$("#"+i.pre+"wait")&&$("#"+i.pre+"wait").hide,$("#"+i.pre+"canvas")&&$("#"+i.pre+"canvas").show,$("#"+i.pre+"commandlog")&&$("#"+i.pre+"commandlog").show}}),l={},d=c.then(function(e){if(l=e.seqalign,void 0===l)return alert("These two MMDB IDs "+o+" do not have 3D alignment data."),!1;var t=0;for(var n in e){if(2>t){var s=e[n].pdbid,a=e[n].molecule;for(var c in a){var d=a[c].chain;i.icn3d.pdbid_chain2title[s+"_"+d]=a[c].name}}++t}return $.ajax({url:r,dataType:"jsonp",cache:!0,beforeSend:function{$("#"+i.pre+"wait")&&$("#"+i.pre+"wait").show,$("#"+i.pre+"canvas")&&$("#"+i.pre+"canvas").hide,$("#"+i.pre+"commandlog")&&$("#"+i.pre+"commandlog").hide},complete:function{$("#"+i.pre+"wait")&&$("#"+i.pre+"wait").hide,$("#"+i.pre+"canvas")&&$("#"+i.pre+"canvas").show,$("#"+i.pre+"commandlog")&&$("#"+i.pre+"commandlog").show}})});d.done(function(e){return void 0===e.atoms?(alert("invalid atoms data."),!1):(i.loadAtomDataIn(e,void 0,"align",l),void 0===i.cfg.align&&1==Object.keys(i.icn3d.structures).length&&$("#"+i.pre+"alternateWrapper").hide,i.icn3d.setAtomStyleByOptions(i.options),i.icn3d.setColorByOptions(i.options,i.icn3d.atoms,!0),i.renderStructure,void 0!==i.cfg.rotate&&i.rotateStructure(i.cfg.rotate,!0),void 0!==i.cfg.showalignseq&&i.cfg.showalignseq&&i.openDialog(i.pre+"dl_alignment","Select residues in aligned sequences"),void 0!==i.cfg.showseq&&i.cfg.showseq&&i.openDialog(i.pre+"dl_selectresidues","Select residues in sequences"),void 0!==i.deferred&&i.deferred.resolve,void 0!==i.deferred2&&i.deferred2.resolve,void 0)})},iCn3DUI.prototype.downloadCid=function(e){var i=this,t="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+e+"/record/SDF/?record_type=3d&response_type=display";i.options.picking="atom",i.options.ligands="ball and stick",i.icn3d.options.picking="atom",i.icn3d.options.ligands="ball and stick",i.icn3d.bCid=!0,$.ajax({url:t,dataType:"text",cache:!0,beforeSend:function{$("#"+i.pre+"wait")&&$("#"+i.pre+"wait").show,$("#"+i.pre+"canvas")&&$("#"+i.pre+"canvas").hide,$("#"+i.pre+"commandlog")&&$("#"+i.pre+"commandlog").hide},complete:function{$("#"+i.pre+"wait")&&$("#"+i.pre+"wait").hide,$("#"+i.pre+"canvas")&&$("#"+i.pre+"canvas").show,$("#"+i.pre+"commandlog")&&$("#"+i.pre+"commandlog").show},success:function(t){var n=i.loadSdfAtomData(t);void 0===i.cfg.align&&1==Object.keys(i.icn3d.structures).length&&$("#"+i.pre+"alternateWrapper").hide,n?(i.icn3d.setAtomStyleByOptions(i.options),i.icn3d.setColorByOptions(i.options,i.icn3d.atoms),i.renderStructure,void 0!==i.cfg.rotate&&i.rotateStructure(i.cfg.rotate,!0),void 0!==i.deferred&&i.deferred.resolve,void 0!==i.deferred2&&i.deferred2.resolve):alert("The SDF of CID "+e+" has the wrong format...")}}).fail(function{alert("This CID may not have 3D structure...")})},iCn3DUI.prototype.loadMol2Data=function(e){var i=this,t=i.loadMol2AtomData(e);void 0===i.cfg.align&&1==Object.keys(i.icn3d.structures).length&&$("#"+i.pre+"alternateWrapper").hide,t?(i.icn3d.setAtomStyleByOptions(i.options),i.icn3d.setColorByOptions(i.options,i.icn3d.atoms),i.renderStructure,void 0!==i.cfg.rotate&&i.rotateStructure(i.cfg.rotate,!0),void 0!==i.deferred&&i.deferred.resolve,void 0!==i.deferred2&&i.deferred2.resolve):alert("The Mol2 file has the wrong format...")},iCn3DUI.prototype.loadSdfData=function(e){var i=this,t=i.loadSdfAtomData(e);void 0===i.cfg.align&&1==Object.keys(i.icn3d.structures).length&&$("#"+i.pre+"alternateWrapper").hide,t?(i.icn3d.setAtomStyleByOptions(i.options),i.icn3d.setColorByOptions(i.options,i.icn3d.atoms),i.renderStructure,void 0!==i.cfg.rotate&&i.rotateStructure(i.cfg.rotate,!0),void 0!==i.deferred&&i.deferred.resolve,void 0!==i.deferred2&&i.deferred2.resolve):alert("The SDF file has the wrong format...")},iCn3DUI.prototype.loadXyzData=function(e){var i=this,t=i.loadXyzAtomData(e);void 0===i.cfg.align&&1==Object.keys(i.icn3d.structures).length&&$("#"+i.pre+"alternateWrapper").hide,t?(i.icn3d.setAtomStyleByOptions(i.options),i.icn3d.setColorByOptions(i.options,i.icn3d.atoms),i.renderStructure,void 0!==i.cfg.rotate&&i.rotateStructure(i.cfg.rotate,!0),void 0!==i.deferred&&i.deferred.resolve,void 0!==i.deferred2&&i.deferred2.resolve):alert("The XYZ file has the wrong format...")},iCn3DUI.prototype.loadMol2AtomData=function(e){var i=this,t=e.split(/\r?\n|\r/);if(t.length<4)return!1;i.icn3d.init;for(var n,o,s=1,r="A",a="LIG",c=1,l={},d=1,h="1_A",u="1_A_1",p=0,m=0,g=1,f=!1,v=!1,b={},y={},E="",_=0,w=t.length;w>_;++_){var C=t[_].trim;if(""!==C&&"#"!==C.substr(0,1)){if("@<TRIPOS>MOLECULE"==C){i.icn3d.moleculeTitle=t[_+1].trim;var S=t[_+2].trim.replace(/\s+/g," ").split(" ");n=S[0],o=S[1],_+=4}else"@<TRIPOS>ATOM"==C?(g=1,f=!0,++_):"@<TRIPOS>BOND"==C?(v=!0,f=!1,++_):"@<TRIPOS>SUBSTRUCTURE"==C&&(v=!1,++_);if(C=t[_].trim,""!==C&&"#"!==C.substr(0,1)){if(f&&n>p){var k=C.replace(/\s+/g," ").split(" "),R=parseInt(k[0]);b[R]=g;var T,H=k[1],A=parseFloat(k[2]),x=parseFloat(k[3]),O=parseFloat(k[4]),M=new THREE.Vector3(A,x,O),L=k[5],I=L.indexOf(".");if(T=-1===I?L:L.substr(0,I),"H"===T&&T===L)y[R]=1;else{var D={het:!0,serial:g,name:H,resn:a,structure:s,chain:r,resi:c,coord:M,b:0,elem:T,bonds:[],ss:"coil",ssbegin:!1,ssend:!1,bondOrder:[]};i.icn3d.atoms[g]=D,l[g]=1,++g}++p}if(v&&o>m){var z=C.replace(/\s+/g," ").split(" "),N=parseInt(z[1]),q=parseInt(z[2]),j=z[3],P=j;if("am"===j&&(P="1"),"ar"===j&&(P="1.5"),!(y.hasOwnProperty(N)||y.hasOwnProperty(q)||"1"!==P&&"2"!==P&&"3"!==P&&"1.5"!==P)){var F=P,B=b[N],V=b[q];i.icn3d.atoms[B].bonds.push(V),i.icn3d.atoms[B].bondOrder.push(F),i.icn3d.atoms[V].bonds.push(B),i.icn3d.atoms[V].bondOrder.push(F),"2"==F?(i.icn3d.doublebonds[B+"_"+V]=1,i.icn3d.doublebonds[V+"_"+B]=1):"3"==F?(i.icn3d.triplebonds[B+"_"+V]=1,i.icn3d.triplebonds[V+"_"+B]=1):"1.5"==F&&(i.icn3d.aromaticbonds[B+"_"+V]=1,i.icn3d.aromaticbonds[V+"_"+B]=1)}++m,E=j}}}}i.icn3d.displayAtoms=l,i.icn3d.highlightAtoms=l,i.icn3d.structures[d]=[h],i.icn3d.chains[h]=l,i.icn3d.residues[u]=l,i.icn3d.residueId2Name[u]=a,void 0===i.icn3d.chainsSeq[h]&&(i.icn3d.chainsSeq[h]=[]),void 0===i.icn3d.chainsAnno[h]&&(i.icn3d.chainsAnno[h]=[]),void 0===i.icn3d.chainsAnno[h][0]&&(i.icn3d.chainsAnno[h][0]=[]),void 0===i.icn3d.chainsAnnoTitle[h]&&(i.icn3d.chainsAnnoTitle[h]=[]),void 0===i.icn3d.chainsAnnoTitle[h][0]&&(i.icn3d.chainsAnnoTitle[h][0]=[]);var G={};G.resi=c,G.name=a,i.icn3d.chainsSeq[h].push(G),i.icn3d.chainsAnno[h][0].push(c),i.icn3d.chainsAnnoTitle[h][0].push("");var U=new THREE.Vector3(9999,9999,9999),W=new THREE.Vector3(-9999,-9999,-9999),Y=new THREE.Vector3,X=0;for(var _ in i.icn3d.atoms){var Z=i.icn3d.atoms[_],M=Z.coord;Y.add(M),U.min(M),W.max(M),++X,Z.het&&(-1!==$.inArray(Z.elem,i.icn3d.ionsArray)?i.icn3d.ions[Z.serial]=1:i.icn3d.ligands[Z.serial]=1)}return i.icn3d.pmin=U,i.icn3d.pmax=W,i.icn3d.cnt=X,i.icn3d.maxD=i.icn3d.pmax.distanceTo(i.icn3d.pmin),i.icn3d.center=Y.multiplyScalar(1/i.icn3d.cnt),i.icn3d.maxD<25&&(i.icn3d.maxD=25),i.icn3d.oriMaxD=i.icn3d.maxD,i.icn3d.oriCenter=i.icn3d.center.clone,i.showTitle,!0},iCn3DUI.prototype.loadSdfAtomData=function(e){var i=this,t=e.split(/\r?\n|\r/);if(t.length<4)return!1;i.icn3d.init;var n=1,o="A",s=1,r="LIG",a=n,c=n+"_"+o,l=c+"_"+s,d=parseInt(t[3].substr(0,3));if(isNaN(d)||0>=d)return!1;var h=parseInt(t[3].substr(3,3)),u=4;if(t.length<u+d+h)return!1;var p,m,g=0,f=d,v={},b={},y={},E=1;for(p=g;f>p;p++){m=t[u],u++;var _=m.substr(31,3).replace(/ /g,"");if("H"!==_){var w=parseFloat(m.substr(0,10)),C=parseFloat(m.substr(10,10)),S=parseFloat(m.substr(20,10)),k=new THREE.Vector3(w,C,S),R={het:!0,serial:E,name:_,resn:r,structure:n,chain:o,resi:s,coord:k,b:0,elem:_,bonds:[],ss:"coil",ssbegin:!1,ssend:!1,bondOrder:[]};i.icn3d.atoms[E]=R,y[E]=1,v[p]=E,++E}else b[p]=1}i.icn3d.displayAtoms=y,i.icn3d.highlightAtoms=y,i.icn3d.structures[a]=[c],i.icn3d.chains[c]=y,i.icn3d.residues[l]=y,i.icn3d.residueId2Name[l]=r,void 0===i.icn3d.chainsSeq[c]&&(i.icn3d.chainsSeq[c]=[]),void 0===i.icn3d.chainsAnno[c]&&(i.icn3d.chainsAnno[c]=[]),void 0===i.icn3d.chainsAnno[c][0]&&(i.icn3d.chainsAnno[c][0]=[]),void 0===i.icn3d.chainsAnnoTitle[c]&&(i.icn3d.chainsAnnoTitle[c]=[]),void 0===i.icn3d.chainsAnnoTitle[c][0]&&(i.icn3d.chainsAnnoTitle[c][0]=[]);var T={};for(T.resi=s,T.name=r,i.icn3d.chainsSeq[c].push(T),i.icn3d.chainsAnno[c][0].push(s),i.icn3d.chainsAnnoTitle[c][0].push(""),p=0;h>p;p++){m=t[u],u++;var H=parseInt(m.substr(0,3))-1+g,A=parseInt(m.substr(3,3))-1+g,x=m.substr(6,3).trim;if(!b.hasOwnProperty(H)&&!b.hasOwnProperty(A)){var O=v[H],M=v[A];i.icn3d.atoms[O].bonds.push(M),i.icn3d.atoms[O].bondOrder.push(x),i.icn3d.atoms[M].bonds.push(O),i.icn3d.atoms[M].bondOrder.push(x),"2"==x?(i.icn3d.doublebonds[O+"_"+M]=1,i.icn3d.doublebonds[M+"_"+O]=1):"3"==x&&(i.icn3d.triplebonds[O+"_"+M]=1,i.icn3d.triplebonds[M+"_"+O]=1)}}var L=new THREE.Vector3(9999,9999,9999),I=new THREE.Vector3(-9999,-9999,-9999),D=new THREE.Vector3,z=0;for(var p in i.icn3d.atoms){var N=i.icn3d.atoms[p],k=N.coord;D.add(k),L.min(k),I.max(k),++z,N.het&&(-1!==$.inArray(N.elem,i.icn3d.ionsArray)?i.icn3d.ions[N.serial]=1:i.icn3d.ligands[N.serial]=1)}return i.icn3d.pmin=L,i.icn3d.pmax=I,i.icn3d.cnt=z,i.icn3d.maxD=i.icn3d.pmax.distanceTo(i.icn3d.pmin),i.icn3d.center=D.multiplyScalar(1/i.icn3d.cnt),i.icn3d.maxD<25&&(i.icn3d.maxD=25),i.icn3d.oriMaxD=i.icn3d.maxD,i.icn3d.oriCenter=i.icn3d.center.clone,i.showTitle,!0},iCn3DUI.prototype.setXyzAtomSeq=function(e,i,t,n){var o=this;o.icn3d.displayAtoms=o.icn3d.unionHash(o.icn3d.displayAtoms,e),o.icn3d.highlightAtoms=o.icn3d.unionHash(o.icn3d.highlightAtoms,e),o.icn3d.structures[i]=[t],o.icn3d.chains[t]=e,o.icn3d.residues[n]=e,o.icn3d.residueId2Name[n]="LIG",void 0===o.icn3d.chainsSeq[t]&&(o.icn3d.chainsSeq[t]=[]),void 0===o.icn3d.chainsAnno[t]&&(o.icn3d.chainsAnno[t]=[]),void 0===o.icn3d.chainsAnno[t][0]&&(o.icn3d.chainsAnno[t][0]=[]),void 0===o.icn3d.chainsAnnoTitle[t]&&(o.icn3d.chainsAnnoTitle[t]=[]),void 0===o.icn3d.chainsAnnoTitle[t][0]&&(o.icn3d.chainsAnnoTitle[t][0]=[]);var s={};s.resi=1,s.name="LIG",o.icn3d.chainsSeq[t].push(s),o.icn3d.chainsAnno[t][0].push(1),o.icn3d.chainsAnnoTitle[t][0].push("");for(var r=Object.keys(e),a=0,c=r.length;c>a;++a)for(var l=o.icn3d.atoms[r[a]],d=a+1,h=r.length;h>d;++d){var u=o.icn3d.atoms[r[d]],p=1.2*(o.icn3d.covalentRadii[l.elem]+o.icn3d.covalentRadii[u.elem]);Math.abs(l.coord.x-u.coord.x)>p||Math.abs(l.coord.y-u.coord.y)>p||Math.abs(l.coord.z-u.coord.z)>p||o.icn3d.hasCovalentBond(l,u)&&(o.icn3d.atoms[r[a]].bonds.push(r[d]),o.icn3d.atoms[r[d]].bonds.push(r[a]))}},iCn3DUI.prototype.loadXyzAtomData=function(e){var i=this,t=e.split(/\r?\n|\r/);if(t.length<3)return!1;i.icn3d.init;var n,o,s,r,a="A",c="LIG",l=1,d={},h=0,u=1,p=2;i.icn3d.moleculeTitle="";for(var m=0,g=t.length;g>m;++m){var f=t[m].trim;if(""!==f&&(""===f||isNaN(f)||(0!==m&&i.setXyzAtomSeq(d,h,n,o),++h,d={},s=h,n=s+"_"+a,o=n+"_"+l,r=parseInt(f),h>1&&(i.icn3d.moleculeTitle+="; "),i.icn3d.moleculeTitle+=t[m+1].trim,m+=p),f=t[m].trim,""!==f)){var v=f.replace(/,/," ").replace(/\s+/g," ").split(" "),b=v[0],y=parseFloat(v[1]),E=parseFloat(v[2]),_=parseFloat(v[3]),w=new THREE.Vector3(y,E,_),C={het:!0,serial:u,name:b,resn:c,structure:s,chain:a,resi:l,coord:w,b:0,elem:b,bonds:[],ss:"coil",ssbegin:!1,ssend:!1,bondOrder:[]};i.icn3d.atoms[u]=C,d[u]=1,++u}}i.setXyzAtomSeq(d,h,n,o);var S=new THREE.Vector3(9999,9999,9999),k=new THREE.Vector3(-9999,-9999,-9999),R=new THREE.Vector3,T=0;for(var m in i.icn3d.atoms){var H=i.icn3d.atoms[m],w=H.coord;R.add(w),S.min(w),k.max(w),++T,H.het&&(-1!==$.inArray(H.elem,i.icn3d.ionsArray)?i.icn3d.ions[H.serial]=1:i.icn3d.ligands[H.serial]=1)}return i.icn3d.pmin=S,i.icn3d.pmax=k,i.icn3d.cnt=T,i.icn3d.maxD=i.icn3d.pmax.distanceTo(i.icn3d.pmin),i.icn3d.center=R.multiplyScalar(1/i.icn3d.cnt),i.icn3d.maxD<25&&(i.icn3d.maxD=25),i.icn3d.oriMaxD=i.icn3d.maxD,i.icn3d.oriCenter=i.icn3d.center.clone,i.showTitle,!0},iCn3DUI.prototype.downloadMmdb=function(e,i){var t,n=this;t=void 0!==i&&i?"https://www.ncbi.nlm.nih.gov/Structure/mmdb/mmdb_strview.cgi?program=w3d&seq=1&gi="+e:"https://www.ncbi.nlm.nih.gov/Structure/mmdb/mmdb_strview.cgi?program=w3d&seq=1&uid="+e,n.icn3d.bCid=void 0,void 0!==n.cfg.inpara&&(t+=n.cfg.inpara),$.ajax({url:t,dataType:"jsonp",cache:!0,beforeSend:function{$("#"+n.pre+"wait")&&$("#"+n.pre+"wait").show,$("#"+n.pre+"canvas")&&$("#"+n.pre+"canvas").hide,$("#"+n.pre+"commandlog")&&$("#"+n.pre+"commandlog").hide},complete:function{$("#"+n.pre+"wait")&&$("#"+n.pre+"wait").hide,$("#"+n.pre+"canvas")&&$("#"+n.pre+"canvas").show,$("#"+n.pre+"commandlog")&&$("#"+n.pre+"commandlog").show},error:function(t,o,s){return i?alert("This gi "+e+" has no corresponding 3D structure..."):alert("This mmdbid "+e+" with the parameters "+n.cfg.inpara+" has no corresponding 3D structure..."),!1},success:function(e){var i=void 0!==e.pdbId?e.pdbId:e.mmdbId;if(n.inputid=i,(void 0!==n.cfg.inpara&&-1!=n.cfg.inpara.indexOf("mols=")||e.atomcount<=e.threshold&&void 0!==e.atoms)&&($("#"+n.pre+"accordion5").show,n.loadAtomDataIn(e,i,"mmdbid"),void 0===n.cfg.align&&1==Object.keys(n.icn3d.structures).length&&null!==$("#"+n.pre+"alternateWrapper")&&$("#"+n.pre+"alternateWrapper").hide,n.icn3d.setAtomStyleByOptions(n.options),n.icn3d.setColorByOptions(n.options,n.icn3d.atoms,!0),n.renderStructure,void 0!==n.cfg.rotate&&n.rotateStructure(n.cfg.rotate,!0)),void 0!==n.cfg.inpara&&-1==n.cfg.inpara.indexOf("mols=")&&e.atomcount>e.threshold&&void 0!==e.molid2rescount){$("#"+n.pre+"accordion5").hide;n.icn3d.bSSOnly=!0,n.cfg.showseq=!1,n.loadAtomDataIn(e,i,"mmdbid");var t=n.icn3d.cloneHash(n.options);t.nucleotides="phosphorus lines",n.icn3d.setAtomStyleByOptions(t),n.icn3d.setColorByOptions(t,n.icn3d.atoms,!0);var o=e.molid2rescount,s={},r={},a={},c=" ",molid2ss={};for(var h in e.helix)for(var f=0,v=e.helix[h].length;v>f;++f){var b=e.helix[h][f],y={};y.type="helix",y.startResi=b.from,y.endResi=b.to,y.coords=[],y.coords.push(b.end),y.coords.push(b.start),void 0===molid2ss[h]&&(molid2ss[h]=[]),molid2ss[h].push(y)}for(var h in e.brick)for(var f=0,v=e.brick[h].length;v>f;++f){var E=e.brick[h][f],y={};y.type="brick",y.startResi=E.from,y.endResi=E.to,y.coords=[];var _={},w={},C={};_.x=.25*(E["000"][0]+E["010"][0]+E["011"][0]+E["001"][0]),_.y=.25*(E["000"][1]+E["010"][1]+E["011"][1]+E["001"][1]),_.z=.25*(E["000"][2]+E["010"][2]+E["011"][2]+E["001"][2]),w.x=.25*(E[100][0]+E[110][0]+E[111][0]+E[101][0]),w.y=.25*(E[100][1]+E[110][1]+E[111][1]+E[101][1]),w.z=.25*(E[100][2]+E[110][2]+E[111][2]+E[101][2]),C.x=E["010"][0]-E["000"][0],C.y=E["010"][1]-E["000"][1],C.z=E["010"][2]-E["000"][2],y.coords.push(_),y.coords.push(w),y.coords.push(C),void 0===molid2ss[h]&&(molid2ss[h]=[]),molid2ss[h].push(y)}for(var h in molid2ss)molid2ss[h].sort(function(e,i){return parseFloat(e.startResi)-parseFloat(i.startResi)});if(0!==n.icn3d.cnt)var S=n.icn3d.pmin,k=n.icn3d.pmax,R=n.icn3d.center.multiplyScalar(n.icn3d.cnt),T=n.icn3d.cnt;else var S=new THREE.Vector3(9999,9999,9999),k=new THREE.Vector3(-9999,-9999,-9999),R=new THREE.Vector3,T=0;for(var h in molid2ss){for(var H=new THREE.Vector3(9999,9999,9999),A=new THREE.Vector3(-9999,-9999,-9999),x=new THREE.Vector3,O=0,f=0,v=molid2ss[h].length;v>f;++f){var M=molid2ss[h][f].coords[0];S.min(M),k.max(M),R.add(M),H.min(M),A.max(M),x.add(M),++T,++O,M=molid2ss[h][f].coords[1],S.min(M),k.max(M),R.add(M),H.min(M),A.max(M),x.add(M),++T,++O}x.multiplyScalar(1/O)}n.icn3d.maxD=k.distanceTo(S),n.icn3d.center=R.multiplyScalar(1/T),n.icn3d.oriMaxD=n.icn3d.maxD,n.icn3d.oriCenter=n.icn3d.center.clone;for(var h in molid2ss)for(var f=1,v=molid2ss[h].length;v>f;++f){var y={};y.type="coil",y.startResi=molid2ss[h][f-1].endResi,y.endResi=molid2ss[h][f].startResi,y.coords=[],y.coords.push(molid2ss[h][f-1].coords[1]),y.coords.push(molid2ss[h][f].coords[0]),molid2ss[h].push(y)}n.icn3d.molid2ss=molid2ss,n.icn3d.molid2color=s,n.renderStructure,void 0!==n.cfg.rotate&&n.rotateStructure(n.cfg.rotate,!0),$("#"+n.pre+"dl_filter_table").html(c);var L="Select chains to display",i=n.pre+"dl_filter";n.openDialog(i,L)}return void 0!==n.cfg.showseq&&n.cfg.showseq&&n.openDialog(n.pre+"dl_selectresidues","Select residues in sequences"),void 0!==n.deferred&&n.deferred.resolve,void 0!==n.deferred2&&n.deferred2.resolve,void 0===e.atoms&&void 0===e.molid2rescount?(alert("invalid MMDB data."),!1):void 0}})},iCn3DUI.prototype.downloadGi=function(e){var i=this;i.icn3d.bCid=void 0;var t=!0;i.downloadMmdb(e,t)},iCn3DUI.prototype.loadAtomDataIn=function(e,i,t,n){var o=this;o.icn3d.init;var s=new THREE.Vector3(9999,9999,9999),r=new THREE.Vector3(-9999,-9999,-9999),a=new THREE.Vector3,c=e.atoms,l=0,d=0,h={},u={};if(o.pmid=e.pubmedid,"align"===t){o.pmid="";var p=-1!==o.cfg.inpara.indexOf("atype=1")?"Invariant Core ":"";o.icn3d.moleculeTitle=p+"Structure Alignment of ";for(var m=0,g=e.aligned_structures.length;g>m;++m){var f=e.aligned_structures[m];1===m&&(o.icn3d.secondId=f.pdbid);for(var v=f.range[0];v<=f.range[1];++v){var b=f.pdbid,y=f.mmdbid;h[v]=b.toString,u[y]=b}o.icn3d.moleculeTitle+='<a href="https://www.ncbi.nlm.nih.gov/Structure/mmdb/mmdbsrv.cgi?uid='+f.pdbid.toUpperCase+'" target="_blank" style="color: '+o.GREYD+';">'+f.pdbid.toUpperCase+"</a>",void 0!==f.descr&&(o.pmid+=f.descr.pubmedid),0===m&&(o.icn3d.moleculeTitle+=" and ",void 0!==f.descr&&(o.pmid+="_"))}o.icn3d.moleculeTitle+=" from VAST+"}else void 0!==e.descr&&(o.icn3d.moleculeTitle+=e.descr.name);var E={},_={};if("mmdbid"===t||"align"===t){if("mmdbid"===t){if(void 0!==e.molid2chain){var w={};for(var C in e.molid2chain){var S=e.molid2chain[C].chain.trim;void 0===w[S]?w[S]=1:++w[S],E[C]=1===w[S]?S:S+w[S].toString}}}else if("align"===t&&void 0!==e.molid2chain)for(var k in e.molid2chain){var R={};for(var C in e.molid2chain[k]){var T=e.molid2chain[k][C].chain.trim;void 0===R[T]?R[T]=1:++R[T],_[u[k]+"_"+C]=1===R[T]?T:T+R[T].toString}}if("mmdbid"===t){var H=e.molid2rescount;for(var m in H){var A="#"+("000000"+H[m].color.toString(16)).slice(-6),S=i+"_"+H[m].chain;o.icn3d.chainsColor[S]=new THREE.Color(A)}}else if("align"===t&&void 0!==e.molid2chain)for(var k in e.molid2chain){var R={};for(var C in e.molid2chain[k]){var T=e.molid2chain[k][C].chain.trim;void 0===R[T]?R[T]=1:++R[T];var A="#"+("000000"+e.molid2chain[k][C].color.toString(16)).slice(-6),S=1===R[T]?u[k]+"_"+T:u[k]+"_"+T+R[T].toString;o.icn3d.chainsColor[S]=new THREE.Color(A)}}}var x={};if("mmdbid"===t||"mmcifid"===t)for(var S in e.sequences){var O=e.sequences[S],M=i+"_"+S;"mmcifid"===t&&(M="1_"+S),d=-999;for(var L=0,I=!0,m=0,g=O.length;g>m;++m){var D=O[m][1];"mmcifid"===t&&(D=o.icn3d.residueName2Abbr(D));var z={};if(z.resi=m+1,0===parseInt(O[m][0])&&-1!==d)z.name=D.toLowerCase,++L,I=!0;else{if(z.name=D.toLowerCase,I&&L>0){void 0===x[S]&&(x[S]=[]);var N=[L,parseInt(O[m][0])];x[S].push(N),L=0}I=!1}void 0===o.icn3d.chainsSeq[M]&&(o.icn3d.chainsSeq[M]=[]),void 0===o.icn3d.chainsAnno[M]&&(o.icn3d.chainsAnno[M]=[]),void 0===o.icn3d.chainsAnno[M][0]&&(o.icn3d.chainsAnno[M][0]=[]),void 0===o.icn3d.chainsAnno[M][1]&&(o.icn3d.chainsAnno[M][1]=[]);var q="";z.resi%10===0&&(q=z.resi.toString);var j="-";o.icn3d.chainsSeq[M].push(z),o.icn3d.chainsAnno[M][0].push(q),o.icn3d.chainsAnno[M][1].push(j),d=parseInt(O[m][0])}}var P,F={},B="",V="",G="",U="",W="",Y="",X=-999;d=0;var C,Z=0,K=!0,Q=[],J="",ee="";for(var m in c){++l,F[m]=l;var ie=c[m];ie.serial=l;var te;if("mmdbid"===t||"mmcifid"===t?te=i:"align"===t&&(te=h[l]),te!==ee&&(Q=[]),void 0!==ie.chain||"mmdbid"!==t&&"align"!==t)ie.chain=""===ie.chain?"Misc":ie.chain;else if("mmdbid"===t)if(C=ie.ids.m,void 0!==E[C])ie.chain=E[C];else{C!==J&&Q.push(ie.resi);var ne;ne=$.inArray(ie.resi,Q)===Q.length-1?"Misc":"Misc2",ie.chain=ne}else if("align"===t)if(C=ie.ids.m,void 0!==_[te+"_"+C])ie.chain=_[te+"_"+C];else{C!==J&&Q.push(ie.resi);var ne;ne=$.inArray(ie.resi,Q)===Q.length-1?"Misc":"Misc2",ie.chain=ne}void 0!==ie.color&&(ie.color=new THREE.Color(ie.color)),ie.coord=new THREE.Vector3(ie.coord.x,ie.coord.y,ie.coord.z),("mmdbid"===t||"align"===t)&&(ie.structure=te),U=ie.structure,W=U+"_"+ie.chain,W!==V&&(Z=0,d=0);var oe=o.icn3d.residueName2Abbr(ie.resn.substr(0,3));if(ie.resi=parseInt(ie.resi),"mmdbid"===t){if(P=ie.resi,ie.resi!==X&&ie.resi!==X+1&&void 0!==x[ie.chain]&&void 0!==x[ie.chain][Z]&&ie.resi===x[ie.chain][Z][1]){var se=x[ie.chain][Z][0];d+=se,++Z}ie.resi!==X||C!==J?ie.resi=d+1:ie.resi=d,X=P}o.icn3d.secondaries[ie.structure+"_"+ie.chain+"_"+ie.resi]=j,s.min(ie.coord),r.max(ie.coord),a.add(ie.coord),"p"===ie.mt||"n"===ie.mt?("p"===ie.mt?(o.icn3d.proteins[l]=1,"CA"===ie.name&&(o.icn3d.calphas[l]=1),"N"!==ie.name&&"CA"!==ie.name&&"C"!==ie.name&&"O"!==ie.name&&(o.icn3d.sidechains[l]=1)):"n"===ie.mt&&(o.icn3d.nucleotides[l]=1,"P"==ie.name&&(o.icn3d.nucleotidesP[l]=1)),o.icn3d.het=!1):"s"===ie.mt?(o.icn3d.water[l]=1,o.icn3d.het=!0):"l"===ie.mt&&(ie.elem===ie.resn?o.icn3d.ions[l]=1:o.icn3d.ligands[l]=1,o.icn3d.het=!0)," "!==ie.resn.charAt(0)&&" "===ie.resn.charAt(1)&&(ie.resn=ie.resn.charAt(0)),"HOH"==ie.resn&&(o.icn3d.water[l]=1),o.icn3d.atoms[l]=ie,o.icn3d.displayAtoms[l]=1,o.icn3d.highlightAtoms[l]=1;var M=ie.structure+"_"+ie.chain;void 0===o.icn3d.chains[M]&&(o.icn3d.chains[M]={}),o.icn3d.chains[M][l]=1;var re=ie.structure+"_"+ie.chain+"_"+ie.resi;void 0===o.icn3d.residues[re]&&(o.icn3d.residues[re]={}),o.icn3d.residues[re][l]=1,Y=W+"_"+ie.resi,Y!==G&&W!==V&&(K=!0,1!==l&&(void 0===o.icn3d.structures[B]&&(o.icn3d.structures[B]=[]),o.icn3d.structures[B].push(V))),o.icn3d.residueId2Name[re]=oe;var j="-";if("helix"===ie.ss?j="H":"sheet"===ie.ss?j="E":"coil"===ie.ss?j="c":!ie.het&&o.icn3d.residueColors.hasOwnProperty(ie.resn.toUpperCase)&&(j="c"),ie.resi!=d||C!=J){if(void 0===o.icn3d.chainsSeq[M]&&(o.icn3d.chainsSeq[M]=[],K=!1),void 0===o.icn3d.chainsAnno[M]&&(o.icn3d.chainsAnno[M]=[]),void 0===o.icn3d.chainsAnno[M][0]&&(o.icn3d.chainsAnno[M][0]=[]),void 0===o.icn3d.chainsAnno[M][1]&&(o.icn3d.chainsAnno[M][1]=[]),void 0===o.icn3d.chainsAnnoTitle[M]&&(o.icn3d.chainsAnnoTitle[M]=[]),void 0===o.icn3d.chainsAnnoTitle[M][0]&&(o.icn3d.chainsAnnoTitle[M][0]=[]),void 0===o.icn3d.chainsAnnoTitle[M][1]&&(o.icn3d.chainsAnnoTitle[M][1]=[]),"mmdbid"!==t&&"mmcifid"!==t||!K||void 0===o.icn3d.chainsSeq[M][ie.resi-1]){var z={};z.resi=ie.resi,z.name=oe;var q="";ie.resi%10===0&&(q=ie.resi.toString),o.icn3d.chainsSeq[M].push(z),o.icn3d.chainsAnno[M][0].push(q),o.icn3d.chainsAnno[M][1].push(j)}else o.icn3d.chainsSeq[M][ie.resi-1].name=oe,o.icn3d.chainsAnno[M][1][ie.resi-1]=j;o.icn3d.chainsAnnoTitle[M][0].push(""),o.icn3d.chainsAnnoTitle[M][1].push("SS")}d=ie.resi,B=U,V=W,G=Y,J=C,ee=te}if(e.atoms={},void 0===o.icn3d.structures[U]&&(o.icn3d.structures[U]=[]),o.icn3d.structures[U].push(W),"mmcifid"!==t)for(var m in o.icn3d.atoms)for(var ae=void 0===o.icn3d.atoms[m].bonds?0:o.icn3d.atoms[m].bonds.length,v=0;ae>v;++v)o.icn3d.atoms[m].bonds[v]=F[o.icn3d.atoms[m].bonds[v]];if(o.icn3d.cnt=l,o.icn3d.pmin=s,o.icn3d.pmax=r,o.icn3d.maxD=r.distanceTo(s),o.icn3d.center=a.multiplyScalar(1/o.icn3d.cnt),o.icn3d.maxD<25&&(o.icn3d.maxD=25),o.icn3d.oriMaxD=o.icn3d.maxD,o.icn3d.oriCenter=o.icn3d.center.clone,"align"===t&&void 0!==n){for(var ce={},le=e.aligned_structures[0].pdbid,de=e.aligned_structures[1].pdbid,he=le+"_cons",ue=le+"_ncons",pe=le+"_nalign",me=de+"_cons",ge=de+"_ncons",fe=de+"_nalign",ve={},be={},ye={},Ee={},_e={},we={},m=0,g=n.length;g>m;++m){for(var Ce=n[m][0],Se=Ce.mid,ke=_[le+"_"+Se],Re=le+"_"+ke,Te={},He=Ce.mseq.length,Ae=-1,v=0,xe=Ce.mseq.length;xe>v;++v){var Oe=Ce.mseq[v][1],$e="~"===Ce.mseq[v][2]?"-":Ce.mseq[v][2];$e=$e.toUpperCase;var Me=Ce.mseq[v][3];1==Me&&(He>v&&(He=v),v>Ae&&(Ae=v)),Te[v]={resi:Oe,resn:$e,aligned:Me}}Ce=n[m][1];var Le=Ce.sid,Ie=_[de+"_"+Le],De=de+"_"+Ie;void 0===o.icn3d.alignChainsAnnoTitle[Re]&&(o.icn3d.alignChainsAnnoTitle[Re]=[]),void 0===o.icn3d.alignChainsAnnoTitle[Re][0]&&(o.icn3d.alignChainsAnnoTitle[Re][0]=[]),void 0===o.icn3d.alignChainsAnnoTitle[Re][1]&&(o.icn3d.alignChainsAnnoTitle[Re][1]=[]),void 0===o.icn3d.alignChainsAnnoTitle[Re][2]&&(o.icn3d.alignChainsAnnoTitle[Re][2]=[]),void 0===o.icn3d.alignChainsAnnoTitle[Re][3]&&(o.icn3d.alignChainsAnnoTitle[Re][3]=[]),void 0===o.icn3d.alignChainsAnnoTitle[Re][4]&&(o.icn3d.alignChainsAnnoTitle[Re][4]=[]),void 0===o.icn3d.alignChainsAnnoTitle[Re][5]&&(o.icn3d.alignChainsAnnoTitle[Re][5]=[]),o.icn3d.alignChainsAnnoTitle[Re][0].push("SS"),o.icn3d.alignChainsAnnoTitle[Re][1].push(""),o.icn3d.alignChainsAnnoTitle[Re][2].push(""),o.icn3d.alignChainsAnnoTitle[Re][3].push(De),o.icn3d.alignChainsAnnoTitle[Re][4].push(Re),o.icn3d.alignChainsAnnoTitle[Re][5].push("");for(var ze=1,v=He;Ae>=v;++v){var Oe=Ce.sseq[v][1],$e="~"===Ce.sseq[v][2]?"-":Ce.sseq[v][2];$e=$e.toUpperCase;var A,Ne,Me=Te[v].aligned+Ce.sseq[v][3];2===Me?(Te[v].resn===$e?(A="#FF0000",Ne="icn3d-cons",ve[Re+"_"+Te[v].resi]=1,Ee[De+"_"+Oe]=1):(A="#0000FF",Ne="icn3d-ncons",be[Re+"_"+Te[v].resi]=1,_e[De+"_"+Oe]=1),ce=o.icn3d.unionHash(ce,o.icn3d.residues[Re+"_"+Te[v].resi]),ce=o.icn3d.unionHash(ce,o.icn3d.residues[De+"_"+Oe])):(A=o.GREY8,Ne="icn3d-nalign",ye[Re+"_"+Te[v].resi]=1,we[De+"_"+Oe]=1),void 0===o.icn3d.alignChainsSeq[Re]&&(o.icn3d.alignChainsSeq[Re]=[]);var z={};z.mmdbid=le,z.chain=ke,z.resi=Te[v].resi,z.resn=""===z.resi||"icn3d-nalign"===Ne?Te[v].resn.toLowerCase:Te[v].resn,z.aligned=Me,z.color=""===z.resi?o.GREYC:A,z["class"]=Ne,o.icn3d.alignChainsSeq[Re].push(z),""!==Te[v].resi&&(void 0===o.icn3d.alignChains[Re]&&(o.icn3d.alignChains[Re]={}),$.extend(o.icn3d.alignChains[Re],o.icn3d.residues[Re+"_"+Te[v].resi])),void 0===o.icn3d.alignChainsSeq[De]&&(o.icn3d.alignChainsSeq[De]=[]),z={},z.mmdbid=de,z.chain=Ie,z.resi=Oe,z.resn=""===z.resi||"icn3d-nalign"===Ne?$e.toLowerCase:$e,z.aligned=Me,z.color=""===z.resi?o.GREYC:A,z["class"]=Ne,o.icn3d.alignChainsSeq[De].push(z),""!==z.resi&&(void 0===o.icn3d.alignChains[De]&&(o.icn3d.alignChains[De]={}),$.extend(o.icn3d.alignChains[De],o.icn3d.residues[De+"_"+Oe])),void 0===o.icn3d.alignChainsAnno[Re]&&(o.icn3d.alignChainsAnno[Re]=[]),void 0===o.icn3d.alignChainsAnno[Re][0]&&(o.icn3d.alignChainsAnno[Re][0]=[]),void 0===o.icn3d.alignChainsAnno[Re][1]&&(o.icn3d.alignChainsAnno[Re][1]=[]),void 0===o.icn3d.alignChainsAnno[Re][2]&&(o.icn3d.alignChainsAnno[Re][2]=[]),v===He&&(void 0===o.icn3d.alignChainsAnno[Re][3]&&(o.icn3d.alignChainsAnno[Re][3]=[]),void 0===o.icn3d.alignChainsAnno[Re][4]&&(o.icn3d.alignChainsAnno[Re][4]=[]),void 0===o.icn3d.alignChainsAnno[Re][5]&&(o.icn3d.alignChainsAnno[Re][5]=[]),o.icn3d.alignChainsAnno[Re][3].push(o.icn3d.pdbid_chain2title[De]),o.icn3d.alignChainsAnno[Re][4].push(o.icn3d.pdbid_chain2title[Re]),o.icn3d.alignChainsAnno[Re][5].push(""));var re=Re+"_"+Te[v].resi,qe=o.icn3d.secondaries[re];void 0!==qe?o.icn3d.alignChainsAnno[Re][0].push(qe):o.icn3d.alignChainsAnno[Re][0].push("-");var je=".";ze%5===0&&(je="*"),ze%10===0&&(je="|"),o.icn3d.alignChainsAnno[Re][1].push(je);var q="";ze%10===0&&(q=ze.toString),o.icn3d.alignChainsAnno[Re][2].push(q),++ze}}o.bFullUi&&(o.selectResidueList(ve,he,he),o.selectResidueList(Ee,me,me),o.selectResidueList(be,ue,ue),o.selectResidueList(_e,ge,ge),o.selectResidueList(ye,pe,pe),o.selectResidueList(we,fe,fe));var A=new THREE.Color(o.GREYB);for(var m in o.icn3d.atoms)ce.hasOwnProperty(m)||(o.icn3d.atoms[m].color=A);n={}}o.showTitle,e={}},iCn3DUI.prototype.openDialogHalfWindow=function(e,i,t,n){var o=this,s=!1;o.resizeCanvas(o.WIDTH-t-o.LESSWIDTH,o.HEIGHT-o.LESSHEIGHT,n),height=s?"auto":o.HEIGHT-o.LESSHEIGHT-o.EXTRAHEIGHT,width=s?"auto":t;var r;r=o.cfg.showmenu?{my:"left top",at:"right top+80",of:"#"+o.pre+"viewer",collision:"none"}:{my:"left top",at:"right top",of:"#"+o.pre+"viewer",collision:"none"},o.cfg.resize=!1,window.dialog=$("#"+e).dialog({autoOpen:!0,title:i,height:height,width:width,modal:!1,position:r,close:function(i){var t=$("#"+o.pre+"dl_selectresidues").hasClass("ui-dialog-content")?!0:!1,n=$("#"+o.pre+"dl_alignment").hasClass("ui-dialog-content")?!0:!1,s=$("#"+o.pre+"dl_filter").hasClass("ui-dialog-content")?!0:!1;(e!==o.pre+"dl_selectresidues"||n&&$("#"+o.pre+"dl_alignment").dialog("isOpen")!==!1||s&&$("#"+o.pre+"dl_filter").dialog("isOpen")!==!1)&&(e!==o.pre+"dl_alignment"||t&&$("#"+o.pre+"dl_selectresidues").dialog("isOpen")!==!1||s&&$("#"+o.pre+"dl_filter").dialog("isOpen")!==!1)&&(e!==o.pre+"dl_filter"||n&&$("#"+o.pre+"dl_alignment").dialog("isOpen")!==!1||t&&$("#"+o.pre+"dl_selectresidues").dialog("isOpen")!==!1)||o.resizeCanvas(o.WIDTH-o.LESSWIDTH,o.HEIGHT-o.LESSHEIGHT,!0)}})},iCn3DUI.prototype.openDialog=function(e,i){var t=this,n=400,o=150,s=!1;if(e===t.pre+"dl_selectresidues"||e===t.pre+"dl_alignment"||e===t.pre+"dl_filter"){var r=.5*t.WIDTH>250?250:.5*(t.WIDTH-t.LESSWIDTH),a=e===t.pre+"dl_filter"?r:.5*(t.WIDTH-t.LESSWIDTH);if(t.WIDTH-t.LESSWIDTH>=t.HEIGHT-t.LESSHEIGHT-t.EXTRAHEIGHT)t.openDialogHalfWindow(e,i,a,!0);else{t.resizeCanvas(t.WIDTH-t.LESSWIDTH,.5*(t.HEIGHT-t.LESSHEIGHT-t.EXTRAHEIGHT)+t.EXTRAHEIGHT,!0),o=s?"auto":.5*(t.HEIGHT-t.LESSHEIGHT-t.EXTRAHEIGHT),n=s?"auto":t.WIDTH-t.LESSWIDTH;var c={my:"left top",at:"left bottom+32",of:"#"+t.pre+"canvas",collision:"none"};window.dialog=$("#"+e).dialog({autoOpen:!0,title:i,height:o,width:n,modal:!1,position:c,close:function(i){var n=$("#"+t.pre+"dl_selectresidues").hasClass("ui-dialog-content")?!0:!1,o=$("#"+t.pre+"dl_alignment").hasClass("ui-dialog-content")?!0:!1,s=$("#"+t.pre+"dl_filter").hasClass("ui-dialog-content")?!0:!1;(e!==t.pre+"dl_selectresidues"||o&&$("#"+t.pre+"dl_alignment").dialog("isOpen")!==!1||s&&$("#"+t.pre+"dl_filter").dialog("isOpen")!==!1)&&(e!==t.pre+"dl_alignment"||n&&$("#"+t.pre+"dl_selectresidues").dialog("isOpen")!==!1||s&&$("#"+t.pre+"dl_filter").dialog("isOpen")!==!1)&&(e!==t.pre+"dl_filter"||o&&$("#"+t.pre+"dl_alignment").dialog("isOpen")!==!1||n&&$("#"+t.pre+"dl_selectresidues").dialog("isOpen")!==!1)||t.resizeCanvas(t.WIDTH-t.LESSWIDTH,t.HEIGHT-t.LESSHEIGHT,!0)}})}}else{o="auto",n="auto";var c;c=t.isMobile?{my:"left top",at:"left bottom-50",of:"#"+t.pre+"canvas",collision:"none"}:{my:"left top",at:"left top+50",of:"#"+t.pre+"canvas",collision:"none"},window.dialog=$("#"+e).dialog({autoOpen:!0,title:i,height:o,width:n,modal:!1,position:c})}$(".ui-dialog .ui-button span").removeClass("ui-icon-closethick").addClass("ui-icon-close")},iCn3DUI.prototype.resizeCanvas=function(e,i,t,n){var o=this;if(void 0!==t&&t||void 0!==o.cfg.resize&&o.cfg.resize){var s=parseInt(i)-o.EXTRAHEIGHT;$("#"+o.pre+"canvas").width(e).height(s),$("#"+o.pre+"viewer").width(e).height(i),o.icn3d.setWidthHeight(e,s),(void 0===n||n)&&o.icn3d.draw}},iCn3DUI.prototype.windowResize=function{var e=this;void 0!==e.cfg.resize&&e.cfg.resize&&!e.isMobile&&$(window).resize(function{e.WIDTH=$(window).width,e.HEIGHT=$(window).height;var i=e.WIDTH-e.LESSWIDTH_RESIZE,t=e.HEIGHT-e.LESSHEIGHT;void 0!==e.icn3d&&e.resizeCanvas(i,t)})},iCn3DUI.prototype.setViewerWidthHeight=function{var e=this;e.WIDTH=$(window).width,e.HEIGHT=$(window).height;var i=$("#"+e.pre+"viewer").width,t=$("#"+e.pre+"viewer").height;i&&e.WIDTH>i&&(e.WIDTH=i),t&&e.height>t&&(e.height=t),e.isMac&&e.isMobile&&(e.WIDTH<e.MENU_WIDTH&&(e.WIDTH=e.MENU_WIDTH), e.HEIGHT=$(window).height/$(window).width*e.MENU_WIDTH),-1===e.cfg.width.toString.indexOf("%")&&(e.WIDTH=parseInt(e.cfg.width)+e.LESSWIDTH),-1===e.cfg.height.toString.indexOf("%")&&(e.HEIGHT=parseInt(e.cfg.height)+e.EXTRAHEIGHT+e.LESSHEIGHT)};