(Created page with "→* * PV - WebGL protein viewer v1.7.0dev * http://biasmv.github.io/pv * * Copyright 2013-2015 Marco Biasini * Released under the MIT license: !function(a,b){if("func...") |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | <html> | ||
+ | <script> | ||
/** | /** | ||
* PV - WebGL protein viewer v1.7.0dev | * PV - WebGL protein viewer v1.7.0dev | ||
Line 11: | Line 13: | ||
},draw:function(a,b,c,d){if(this._O&&"normal"===d){var e=b.text;a.bind(e),this.bind();var f=this._c,g=a.upsamplingFactor();f.uniform1f(f.getUniformLocation(e,"xScale"),this._dp),f.uniform1f(f.getUniformLocation(e,"yScale"),this._do),f.uniform1f(f.getUniformLocation(e,"width"),2*g*this._k/a.viewportWidth()),f.uniform1f(f.getUniformLocation(e,"height"),2*g*this._m/a.viewportHeight()),f.uniform1i(f.getUniformLocation(e,"sampler"),0);var h=f.getAttribLocation(e,"attrCenter");f.enableVertexAttribArray(h),f.vertexAttribPointer(h,3,f.FLOAT,!1,20,0);var i=f.getAttribLocation(e,"attrCorner");f.vertexAttribPointer(i,2,f.FLOAT,!1,20,12),f.enableVertexAttribArray(i),f.enable(f.BLEND),f.blendFunc(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA),f.drawArrays(f.TRIANGLES,0,6),f.disableVertexAttribArray(h),f.disableVertexAttribArray(i),f.disable(f.BLEND)}}}),a}(),y=function(c){function e(){this._e=[],this._D=[],this._u=0}function f(a,b,d,f){Q.call(this,b),this._A=d,this._F=f,this._B=new e,this._dE=new c.ProtoSphere(8,8),this._dF=new c.ProtoCylinder(8),this._W=null,this._p=!1}function g(a,b,c){for(var d=0;c-1>d;++d)a.addTriangle(b,b+1+d,b+2+d);a.addTriangle(b,b+c,b+1)}function h(a,b,c){for(var d=b+c,e=0;c-1>e;++e)a.addTriangle(d,b+e+1,b+e);a.addTriangle(d,b,b+c-1)}var i=a.vec3,j=a.mat3,k=b.forceRGB;return e.prototype={numVerts:function(){return this._u},addVertex:function(a,b,c,d){this._u+=1,this._e.push(a[0],a[1],a[2],b[0],b[1],b[2],c[0],c[1],c[2],c[3],d)},addTriangle:function(a,b,c){this._D.push(a,b,c)},numIndices:function(){return this._D.length},indexData:function(){return this._D},vertData:function(){return this._e}},d.derive(f,Q,{updateProjectionIntervals:function(){},updateSquaredSphereRadius:function(a,b){return b},addTube:function(){var a=i.create(),b=i.create(),c=i.create(),d=i.create(),e=j.create();return function(f,j,m,n){n=n||{};var o=k(n.color||"white"),p=!0;void 0!==n.cap&&(p=n.cap),i.sub(d,j,f);var q=i.length(d);if(i.normalize(d,d),i.add(a,f,j),i.scale(a,a,.5),l.buildRotation(e,d,b,c,!1),p){var r=this._B.numVerts();this._B.addVertex(f,[-d[0],-d[1],-d[2]],o,0),g(this._B,r,8)}if(this._dF.addTransformed(this._B,a,q,m,e,o,o,0,0),p){var s=this._B.numVerts();this._B.addVertex(j,d,o,0),h(this._B,s-8,8)}this._p=!1}}(),addSphere:function(a,b,c){c=c||{};var d=k(c.color||"white");this._dE.addTransformed(this._B,a,b,d,0),this._p=!1},_dG:function(){this._p=!0,null!==this._W&&this._W.destroy(),this._W=new S(this._c,this._B.numVerts(),this._B.numIndices(),this._A,this._F),this._W.setIndexData(this._B.indexData()),this._W.setVertData(this._B.vertData())},draw:function(a,b,c,d){if(this._O){this._p||this._dG();var e=this.shaderForStyleAndPass(b,c,d);if(e){a.bind(e),this._c.uniform1i(e.symId,255);var f=this._W;f.bind(e),f.draw(),f.releaseAttribs(e)}}},shaderForStyleAndPass:function(a,b,c){if("normal"===c)return a.hemilight;if("select"===c)return null;if("outline"===c)return a.outline;var d=a[c];return void 0!==d?d:null}}),f}(m),z=function(){function b(a,b,c){this._cc=a,this._bO=b,this._bf=c,this._er=c,this._bl=Date.now(),this._cR=!1,this._ce=!1}function c(a,c,d){b.call(this,o.clone(a),o.clone(c),d),this._S=o.clone(a)}function e(a,c,d){var e=q.create(),f=q.create();q.fromMat4(e,a),q.fromMat4(f,c);var g=p.create(),h=p.create();p.fromMat3(g,e),p.fromMat3(h,f),this._S=q.create(),b.call(this,g,h,d)}function f(a,c){b.call(this,null,null,c),this._bM=o.clone(a),this.setLooping(!0),this._cI=0}function g(a,c){var d=1e3*(2*Math.PI/c);b.call(this,null,null,d),this._bM=o.clone(a),this.setLooping(!0),this._dz=c,this._cH=0}function h(){this._bi=[]}function i(a,b,d){return new c(a,b,d)}function j(a,b,c){return new e(a,b,c)}function k(a,c,d){return new b(a,c,d)}function m(a,b){return new g(a,b)}function n(){return new f([0,1,0],2e3)}var o=a.vec3,p=a.quat,q=a.mat3;return b.prototype={setLooping:function(a){this._cR=a},step:function(a){var b,c=Date.now(),d=c-this._bl;if(0===this._bf)b=1;else if(this._cR){var e=Math.floor(d/this._bf);b=(d-e*this._bf)/this._bf}else d=Math.min(this._bf,d),b=d/this._bf,this._ce=1===b;return this.apply(a,b),this._ce},apply:function(a,b){var c=(1-Math.cos(b*Math.PI))/2;this._S=this._cc*(1-c)+this._bO*c,a.setZoom(this._S)},finished:function(){return this._ce}},d.derive(c,b,{apply:function(a,b){var c=(1-Math.cos(b*Math.PI))/2;o.lerp(this._S,this._cc,this._bO,c),a.setCenter(this._S)}}),d.derive(e,b,{apply:function(){var a=p.create();return function(b,c){p.slerp(a,this._cc,this._bO,c),q.fromQuat(this._S,a),b.setRotation(this._S)}}()}),d.derive(f,b,{apply:function(){var a=q.create(),b=q.create();return function(c,d){q.fromMat4(b,c.rotation());var e=.2*Math.sin(2*d*Math.PI),f=e-this._cI;this._cI=e,l.axisRotation(a,this._bM,f),q.mul(b,a,b),c.setRotation(b)}}()}),d.derive(g,b,{apply:function(){var a=q.create(),b=q.create();return function(c,d){q.fromMat4(b,c.rotation());var e=2*Math.PI*(d-this._cH);this._cH=d,l.axisRotation(a,this._bM,e),q.mul(b,a,b),c.setRotation(b)}}(),setSpeed:function(a){this._dz=a},setAxis:function(a){this._bM=a}}),h.prototype={run:function(a){var b=Date.now();return this._bi=this._bi.filter(function(c){return!c.step(a,b)}),this._bi.length>0},add:function(a){this._bi.push(a)},remove:function(a){this._bi=this._bi.filter(function(b){return b!==a})}},{AnimationControl:h,move:i,rotate:j,zoom:k,rockAndRoll:n,spin:m}}(),A=function(){function a(a,b){this.near=a,this.far=b}function b(a){a=a||{},this._bb=a.near||.1,this._3=a.far||400}function c(){this._3=100}return b.prototype.update=function(){return new a(this._bb,this._3)},c.prototype.update=function(b,c){for(var d=c.center(),e=null,f=0;f<b.length;++f){var g=b[f];g.visible()&&(e=g.updateSquaredSphereRadius(d,e))}if(null===e)return null;e=Math.sqrt(e);var h=c.zoom(),i=1.05*(e+h),j=.1;return new a(j,i)},{FixedSlab:b,AutoSlab:c,Slab:a}}(),B=function(c,e,f,g,h,i,j,k,l,m,n,o){function p(){return/(iPad|iPhone|iPod)/g.test(navigator.userAgent)}function q(a,b){return a=a||"auto","fixed"===a?new A.FixedSlab(b):"auto"===a?new A.AutoSlab(b):null}function r(a,b,c){this._dK=a,this._dy=b,this._dt=c}function s(a,b){this._b=this._d1(b,a),this._bH=!1,this._l=[],this._I=a,this._bT=!1,this._1=!1,this._dT=null,this._cL=new c,this._Q=null,this._8=null,this.listenerMap={},this._U=new o.AnimationControl,this._b6(),this.quality(this._b.quality),null!==this._b.atomDoubleClicked&&this.addListener("atomDoubleClicked",this._b.atomDoubleClicked),null!==this._b.atomClick&&this.addListener("atomClicked",this._b.atomClick),"complete"===document.readyState||"loaded"===document.readyState||"interactive"===document.readyState?this._cW():document.addEventListener("DOMContentLoaded",d.bind(this,this._cW))}function t(a,b,c){return b in a?a[b]:c}var u='<div style="vertical-align:middle; text-align:center;"><h1>WebGL not supported</h1><p>Your browser does not support WebGL. You might want to try Chrome, Firefox, IE 11, or newer versions of Safari</p><p>If you are using a recent version of one of the above browsers, your graphic card might be blocked. Check the browser documentation for details on how to unblock it.</p></div>',v=a.vec3,w=a.mat4,x=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(a){window.setTimeout(a,1e3/60)}}();return r.prototype={object:function(){return this._dK},symIndex:function(){return this._dy},transform:function(){return this._dt}},s.prototype={_d1:function(a,c){a=a||{};var d={width:a.width||500,height:a.height||500,animateTime:a.animateTime||0,antialias:a.antialias,quality:t(a,"quality","low"),style:t(a,"style","hemilight"),background:b.forceRGB(a.background||"white"),slabMode:q(a.slabMode),atomClick:a.atomClicked||a.atomClick||null,outline:t(a,"outline",!0),fov:t(a,"fov",45),atomDoubleClicked:t(a,"atomDoubleClicked",t(a,"atomDoubleClick","center")),fog:t(a,"fog",!0)},e=c.getBoundingClientRect();return"auto"===d.width&&(d.width=e.width),"auto"===d.height&&(d.height=e.height),d},_cg:function(){this._1&&(this._1=!1,this._d.setViewportSize(this._.viewportWidth(),this._.viewportHeight()),this._bW.resize(this._b.width,this._b.height))},resize:function(a,b){(a!==this._b.width||b!==this._b.height)&&(this._.resize(a,b),this._1=!0,this._b.width=a,this._b.height=b,this.requestRedraw())},fitParent:function(){var a=this._I.getBoundingClientRect();this.resize(a.width,a.height)},gl:function(){return this._.gl()},ok:function(){return this._bH},options:function(a,b){return void 0!==b?("fog"===a?(this._d.fog(b),this._b.fog=b,this.requestRedraw()):"fov"===a?(this._b.fov=b,this._d.setFieldOfViewY(b*Math.PI/180)):this._b[a]=b,b):this._b[a]},quality:function(a){return this._b.quality=a,"high"===a?(this._b.arcDetail=4,this._b.sphereDetail=16,void(this._b.splineDetail=8)):"medium"===a?(this._b.arcDetail=2,this._b.sphereDetail=10,void(this._b.splineDetail=5)):"low"===a?(this._b.arcDetail=2,this._b.sphereDetail=8,void(this._b.splineDetail=3)):void 0},imageData:function(){return this._.imageData()},_d0:function(){var a={width:this._b.width,height:this._b.height};this._bW=new f(this._.gl(),a)},_cW:function(){if(!this._.initGL())return this._I.removeChild(this._.domElement()),this._I.innerHTML=u,this._I.style.width=this._b.width+"px",this._I.style.height=this._b.height+"px",!1;this._d0(),this._eo=this._by.getContext("2d"),this._A=new g(Float32Array),this._F=new g(Uint16Array),this._d=new h(this._.gl()),this._d.setUpsamplingFactor(this._.superSamplingFactor()),this._d.fog(this._b.fog),this._d.setFogColor(this._b.background),this._d.setFieldOfViewY(this._b.fov*Math.PI/180),this._b1.setCam(this._d);var a=this._,b=p()?"highp":"mediump";return this._dA={hemilight:a.initShader(i.HEMILIGHT_VS,i.HEMILIGHT_FS,b),phong:a.initShader(i.HEMILIGHT_VS,i.PHONG_FS,b),outline:a.initShader(i.OUTLINE_VS,i.OUTLINE_FS,b),lines:a.initShader(i.LINES_VS,i.LINES_FS,b),text:a.initShader(i.TEXT_VS,i.TEXT_FS,b),select:a.initShader(i.SELECT_VS,i.SELECT_FS,b)},this._ef=d.bind(this,this._d8),this._ep=new j(this._.domElement(),this,this._d),this._bH||(this._bH=!0,this._cj({name:"viewerReadyEvent"},"viewerReady",this)),!0},requestRedraw:function(){this._bT||(this._bT=!0,x(this._ef))},boundingClientRect:function(){return this._.domElement().getBoundingClientRect()},_ch:function(a){for(var b=0,c=this._l.length;b!==c;++b)this._l[b].draw(this._d,this._dA,this._b.style,a)},_b6:function(){var a={antialias:this._b.antialias,height:this._b.height,width:this._b.width,backgroundColor:this._b.background};this._=new e.Canvas(this._I,a),this._by=document.createElement("canvas"),this._by.style.display="none",this._I.appendChild(this._by),this._b1=new k(this._,this,this._d,this._b.animateTime)},setRotation:function(a,b){if(b|=0,0===b)return this._d.setRotation(a),void this.requestRedraw();var c;9===a.length?(c=w.create(),w.fromMat3(c,a)):c=w.clone(a),this._U.add(o.rotate(this._d.rotation(),c,b)),this.requestRedraw()},setCamera:function(a,b,c,d){d|=0,this.setCenter(b,d),this.setRotation(a,d),this.setZoom(c,d)},_eh:function(){var a=this._U.run(this._d);a&&this.requestRedraw()},_d8:function(){if(null!==this._){this._bT=!1,this._eh(),this._.bind(),this._cg();var a=this._.gl();a.clear(a.COLOR_BUFFER_BIT|a.DEPTH_BUFFER_BIT);var b=this._b.slabMode.update(this._l,this._d);null!==b&&this._d.setNearFar(b.near,b.far),a.enable(a.CULL_FACE),this._b.outline&&(a.cullFace(a.BACK),a.enable(a.CULL_FACE),this._ch("outline")),a.cullFace(a.FRONT),a.enable(a.BLEND),a.blendFunc(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA),this._ch("normal")}},setCenter:function(a,b){return b|=0,0===b?void this._d.setCenter(a):(this._U.add(o.move(this._d.center(),v.clone(a),b)),void this.requestRedraw())},setZoom:function(a,b){return b|=0,0===b?void this._d.setZoom(a):(this._U.add(o.zoom(this._d.zoom(),a,b)),void this.requestRedraw())},centerOn:function(a,b){this.setCenter(a.center(),b)},clear:function(){for(var a=0;a<this._l.length;++a)this._l[a].destroy();this._l=[]},addListener:function(a,b){var c=this.listenerMap[a];if("undefined"==typeof c&&(c=[],this.listenerMap[a]=c),"center"===b){var e=d.bind(this._b1,this._b1._eb);c.push(e)}else c.push(b);this._bH&&"viewerReady"===a&&b(this,null)},_cj:function(a,b,c){var d=this.listenerMap[b];d&&d.forEach(function(b){b(c,a)})},RENDER_MODES:["sline","lines","trace","lineTrace","cartoon","tube","spheres","ballsAndSticks","points"],renderAs:function(a,b,c,d){for(var e=!1,f=0;f<this.RENDER_MODES.length;++f)if(this.RENDER_MODES[f]===c){e=!0;break}return e?this[c](a,b,d):void 0},_R:function(a,b){return a=this._ca(a),a.showRelated=a.showRelated||"asym",a.showRelated&&"asym"!==a.showRelated&&null===b.assembly(a.showRelated)&&(a.showRelated="asym"),a},_ca:function(a){return a=d.copy(a),a.float32Allocator=this._A,a.uint16Allocator=this._F,a.idPool=this._cL,a},lineTrace:function(a,c,d){var e=this._R(d,c);e.color=e.color||b.uniform([1,0,1]),e.lineWidth=e.lineWidth||4;var f=l.lineTrace(c,this._.gl(),e);return this.add(a,f)},spheres:function(a,c,d){var e=this._R(d,c);e.color=e.color||b.byElement(),e.sphereDetail=this.options("sphereDetail"),e.radiusMultiplier=e.radiusMultiplier||1;var f=l.spheres(c,this._.gl(),e);return this.add(a,f)},sline:function(a,c,d){var e=this._R(d,c);e.color=e.color||b.uniform([1,0,1]),e.splineDetail=e.splineDetail||this.options("splineDetail"),e.strength=e.strength||1,e.lineWidth=e.lineWidth||4;var f=l.sline(c,this._.gl(),e);return this.add(a,f)},cartoon:function(a,c,d){var e=this._R(d,c);e.color=e.color||b.bySS(),e.strength=e.strength||1,e.splineDetail=e.splineDetail||this.options("splineDetail"),e.arcDetail=e.arcDetail||this.options("arcDetail"),e.radius=e.radius||.3,e.forceTube=e.forceTube||!1;var f=l.cartoon(c,this._.gl(),e),g=this.add(a,f);return g},surface:function(a,b,c){var d=this._ca(c),e=l.surface(b,this._.gl(),d);return this.add(a,e)},tube:function(a,b,c){return c=c||{},c.forceTube=!0,this.cartoon(a,b,c)},ballsAndSticks:function(a,c,d){var e=this._R(d,c);e.color=e.color||b.byElement(),e.radius=e.radius||.3,e.arcDetail=2*(e.arcDetail||this.options("arcDetail")),e.sphereDetail=e.sphereDetail||this.options("sphereDetail");var f=l.ballsAndSticks(c,this._.gl(),e);return this.add(a,f)},lines:function(a,c,d){var e=this._R(d,c);e.color=e.color||b.byElement(),e.lineWidth=e.lineWidth||4;var f=l.lines(c,this._.gl(),e);return this.add(a,f)},points:function(a,c,d){var e=this._R(d,c);e.color=e.color||b.byElement(),e.pointSize=e.pointSize||1;var f=l.points(c,this._.gl(),e);return this.add(a,f)},trace:function(a,c,d){var e=this._R(d,c);e.color=e.color||b.uniform([1,0,0]),e.radius=e.radius||.3,e.arcDetail=2*(e.arcDetail||this.options("arcDetail")),e.sphereDetail=e.sphereDetail||this.options("sphereDetail");var f=l.trace(c,this._.gl(),e);return this.add(a,f)},fitTo:function(a){var b=this._d.mainAxes(),c=[new d.Range,new d.Range,new d.Range];if(a instanceof Q)a.updateProjectionIntervals(b[0],b[1],b[2],c[0],c[1],c[2]);else if(void 0!==a.eachAtom){a.eachAtom(function(a){for(var d=a.pos(),e=0;3>e;++e)c[e].update(v.dot(d,b[e]))});for(var e=0;3>e;++e)c[e].extend(1.5)}this._c9(b,c)},_c9:function(a,b){if(!(b[0].empty()||b[1].empty()||b[2].empty())){var c=b[0].center(),d=b[1].center(),e=b[2].center(),f=[c*a[0][0]+d*a[1][0]+e*a[2][0],c*a[0][1]+d*a[1][1]+e*a[2][1],c*a[0][2]+d*a[1][2]+e*a[2][2]],g=this._d.fieldOfViewY(),h=this._d.aspectRatio(),i=b[0].length()/h,j=b[1].length(),k=.5*Math.max(i,j),l=k/Math.tan(.5*g),m=l+.5*b[2].length(),n=.5,o=Math.max(l-n,.1),p=2*n+l+b[2].length();this._d.setNearFar(o,p),this.setCamera(this._d.rotation(),f,m,this._b.animateTime),this.requestRedraw()}},autoZoom:function(){var a=this._d.mainAxes(),b=[new d.Range,new d.Range,new d.Range];this.forEach(function(c){c.visible()&&c.updateProjectionIntervals(a[0],a[1],a[2],b[0],b[1],b[2])}),this._c9(a,b)},slabInterval:function(){},autoSlab:function(){var a=this._b._eq.update(this._l,this._d);null!==a&&this._d.setNearFar(a.near,a.far),this.requestRedraw()},rockAndRoll:function(a){return void 0===a?null!==this._8:a?(null===this._8&&(this._8=o.rockAndRoll(),this._U.add(this._8),this.requestRedraw()),!0):(this._U.remove(this._8),this._8=null,this.requestRedraw(),!1)},spin:function(a,b){return void 0===a?null!==this._Q:a===!1?(this._U.remove(this._Q),this._Q=null,this.requestRedraw(),!1):(a===!0&&(a=Math.PI/8),b=b||[0,1,0],null===this._Q?(this._Q=o.spin(b,a),this._U.add(this._Q)):(this._Q.setSpeed(a),this._Q.setAxis(b)),this.requestRedraw(),!0)},slabMode:function(a,b){b=b||{};var c=q(a,b),d=c.update(this._l,this._d);null!==d&&this._d.setNearFar(d.near,d.far),this._b.slabMode=c,this.requestRedraw()},label:function(a,b,c,d){var e=new m(this._.gl(),this._by,this._eo,c,b,d);return this.add(a,e),e},customMesh:function(a,b){var c=this._ca(b),d=new n(a,this._.gl(),c.float32Allocator,c.uint16Allocator);return this.add(a,d),d},_d7:function(){var a=this._.gl();a.clearColor(0,0,0,0),a.disable(a.BLEND),a.clear(a.COLOR_BUFFER_BIT|a.DEPTH_BUFFER_BIT),a.clearColor(this._b.background[0],this._b.background[1],this._b.background[2],1),a.cullFace(a.FRONT),a.enable(a.CULL_FACE),this._ch("select")},pick:function(a){this._bW.bind(),this._d7();var b=new Uint8Array(4),c=this._.gl();c.readPixels(a.x,this._b.height-a.y,1,1,c.RGBA,c.UNSIGNED_BYTE,b),this._bW.release(),b.data&&(b=b.data);var d=b[0]|b[1]<<8|b[2]<<16,e=b[3],f=this._cL.objectForId(d);if(void 0===f)return null;var g=null;return 255!==e&&(g=f.geom.symWithIndex(e)),new r(f,255>e?e:null,g)},add:function(a,b){return b.name(a),this._l.push(b),this._l.sort(function(a,b){return a.order()-b.order()}),this.requestRedraw(),b},_c3:function(a){var b=a.replace(".","\\.").replace("*",".*");return new RegExp("^"+b+"$")},forEach:function(){var a,b="*";2===arguments.length?(a=arguments[1],b=arguments[0]):a=arguments[0];for(var c=this._c3(b),d=0;d<this._l.length;++d){var e=this._l[d];c.test(e.name())&&a(e,d)}},get:function(a){for(var b=0;b<this._l.length;++b)if(this._l[b].name()===a)return this._l[b];return null},hide:function(a){this.forEach(a,function(a){a.hide()})},show:function(a){this.forEach(a,function(a){a.show()})},rm:function(a){for(var b=[],c=this._c3(a),d=0;d<this._l.length;++d){var e=this._l[d];c.test(e.name())?e.destroy():b.push(e)}this._l=b},all:function(){return this._l},isWebGLSupported:function(){return this._.isWebGLSupported()},destroy:function(){this.clear(),this._.destroy(),this._=null}},s.prototype.on=s.prototype.addListener,{Viewer:function(a,b){return new s(a,b)},isWebGLSupported:e.isWebGLSupported}}(c,e,f,g,h,i,j,k,w,x,y,z),C=function(){function a(a,b){this._j=a||[],this._b2=b||[]}function b(a){this._H=a,this._cb=[]}return a.prototype={addChain:function(a){this._j.push(a)},chains:function(){return this._j},addMatrix:function(a){this._b2.push(a)},matrices:function(){return this._b2},matrix:function(a){return this._b2[a]}},b.prototype={name:function(){return this._H},generators:function(){return this._cb},generator:function(a){return this._cb[a]},addGenerator:function(a){this._cb.push(a)}},{SymGenerator:a,Assembly:b}}(),D=function(){function b(){}function c(a,c,d,e,f,g,h,i){b.call(this),this._t=a,this._cq=[],this._dU=!!g,this._H=c,this._bV=d,this._b7=f,this._be=e,this._dJ=void 0!==h?h:null,this._dx=void 0!==i?i:null}function e(a,c){b.call(this),this._dC=a,this._K=c,this._cq=[]}var f=a.vec3;return b.prototype={bondCount:function(){return this.bonds().length},eachBond:function(a){for(var b=this.bonds(),c=0,d=b.length;d>c;++c)a(b[c])},isConnectedTo:function(a){if(null===a)return!1;for(var b=a.full(),c=this.full(),d=this.bonds(),e=0,f=d.length;f>e;++e){var g=d[e];if(g.atom_one()===c&&g.atom_two()===b||g.atom_one()===b&&g.atom_two()===c)return!0}return!1}},d.derive(c,b,{addBond:function(a){this._cq.push(a)},name:function(){return this._H},bonds:function(){return this._cq},residue:function(){return this._t},structure:function(){return this._t.structure()},full:function(){return this},qualifiedName:function(){return this.residue().qualifiedName()+"."+this.name()},pos:function(){return this._bV},setPos:function(a){f.copy(this._bV,a)},element:function(){return this._be},index:function(){return this._b7},prop:function(a){return this[a]()},occupancy:function(){return this._dJ},tempFactor:function(){return this._dx},isHetatm:function(){return this._dU}}),d.derive(e,b,{full:function(){return this._K},name:function(){return this._K.name()},pos:function(){return this._K.pos()},element:function(){return this._K.element()},residue:function(){return this._dC},bonds:function(){return this._K.bonds()},index:function(){return this._K.index()},occupancy:function(){return this._K.occupancy()},tempFactor:function(){return this._K.tempFactor()},qualifiedName:function(){return this._K.qualifiedName()},isHetatm:function(){return this._K.isHetatm()}}),{Atom:c,AtomView:e}}(),E=function(b){function c(){}function e(a,b,d,e){c.call(this),this._H=b,this._dL=d,this._dW=e,this._C=[],this._cz="C",this._J=a,this._cU=!1,this._cT=!1,this._b7=a.residues().length}function f(a,b){c.call(this),this._ea=a,this._C=[],this._t=b}var g=a.vec3,h=b.Atom,i=b.AtomView;return c.prototype={prop:function(a){return this[a]()},isWater:function(){return"HOH"===this.name()||"DOD"===this.name()},eachAtom:function(a,b){b|=0;for(var c=0;c<this._C.length;c+=1){if(a(this._C[c],b)===!1)return!1;b+=1}return b},qualifiedName:function(){var a=this.chain().name()+"."+this.name()+this.num();return"\x00"===this.insCode()?a:a+this.insCode()},atom:function(a){if("string"==typeof a){for(var b=0;b<this._C.length;++b)if(this._C[b].name()===a)return this._C[b];return null}return a>=this._C.length&&0>a?null:this._C[a]},centralAtom:function(){return this.isAminoacid()?this.atom("CA"):this.isNucleotide()?this.atom("C3'"):null},center:function(){var a=0,b=g.create();return this.eachAtom(function(c){g.add(b,b,c.pos()),a+=1}),a>0&&g.scale(b,b,1/a),b},isAminoacid:function(){return this._cU},isNucleotide:function(){return this._cT}},d.derive(e,c,{_d9:function(){this._cT=null!==this.atom("P")&&null!==this.atom("C3'"),this._cU=null!==this.atom("N")&&null!==this.atom("CA")&&null!==this.atom("C")&&null!==this.atom("O")},name:function(){return this._H},insCode:function(){return this._dW},num:function(){return this._dL},full:function(){return this},addAtom:function(a,b,c,d,e,f){var g=new h(this,a,b,c,this.structure().nextAtomIndex(),d,e,f);return this._C.push(g),g},ss:function(){return this._cz},setSS:function(a){this._cz=a},index:function(){return this._b7},atoms:function(){return this._C},chain:function(){return this._J},structure:function(){return this._J.structure()}}),d.derive(f,c,{addAtom:function(a){var b=new i(this,a.full());this._C.push(b)},full:function(){return this._t},num:function(){return this._t.num()},insCode:function(){return this._t.insCode()},ss:function(){return this._t.ss()},index:function(){return this._t.index()},chain:function(){return this._ea},name:function(){return this._t.name()},atoms:function(){return this._C},qualifiedName:function(){return this._t.qualifiedName()},containsResidue:function(a){return this._t.full()===a.full()},isAminoacid:function(){return this._t.isAminoacid()},isNucleotide:function(){return this._t.isNucleotide()},isWater:function(){return this._t.isWater()}}),{ResidueView:f,Residue:e}}(D),F=function(){function b(){this._s=[]}function c(a,b,c){this._bI=a,this._2=b,this._c4=c,this._b4=0===this._2,this._b5=this._bI.length()===this._c4;var d=this._c4-this._2;this._b5||++d,this._b4||(++d,this._2-=1),this._b3=d}var d=a.vec3;return b.prototype={push:function(a){this._s.push(a)},length:function(){return this._s.length},residueAt:function(a){return this._s[a]},posAt:function(a,b){return d.copy(a,this._s[b].centralAtom().pos()),a},normalAt:function(a,b){var c=this._s[b];return c.isAminoacid()&&d.sub(a,c.atom("O").pos(),c.atom("C").pos()),d.normalize(a,a),a},centralAtomAt:function(a){return this._s[a].centralAtom()},tangentAt:function(){var a=d.create(),b=d.create();return function(c,e){e>0?this.posAt(a,e-1):this.posAt(a,e),e<this._s.length-1?this.posAt(b,e+1):this.posAt(b,e),d.sub(c,b,a)}}(),fullTraceIndex:function(a){return a},subsets:function(a){for(var b=0,d=0,e=[];d<a.length&&b<this._s.length;){for(var f=a[d].full().index();this._s.length>b&&this._s[b].index()<f;)++b;if(b>=this._s.length)break;for(var g=this._s[b].index();a.length>d&&a[d].full().index()<g;)++d;if(d>=a.length)break;for(var h=b;a.length>d&&this._s.length>b&&a[d].full().index()===this._s[b].index();)++d,++b;var i=b;e.push(new c(this,h,i))}return e}},b.prototype.smoothPosAt=b.prototype.posAt,b.prototype.smoothNormalAt=b.prototype.normalAt,c.prototype={length:function(){return this._b3},residueAt:function(a){return this._bI.residueAt(this._2+a)},_cV:function(){var a=d.create(),b=d.create();return function(c,e,f,g){return this.tangentAt(a,e),this.tangentAt(b,f),d.scale(a,a,g),d.scale(b,b,g),l.cubicHermiteInterpolate(c,this.centralAtomAt(e).pos(),a,this.centralAtomAt(f).pos(),b,.5,0),c}}(),smoothPosAt:function(){return function(a,b,c){if(0===b&&!this._b4)return this._cV(a,b,b+1,c);if(b===this._b3-1&&!this._b5)return this._cV(a,b-1,b,c);var e=this.centralAtomAt(b);return d.copy(a,e.pos()),a}}(),smoothNormalAt:function(){return function(a,b){return this._bI.normalAt(a,b+this._2),a}}(),posAt:function(a,b){var c=this.centralAtomAt(b),e=null;return d.copy(a,c.pos()),0!==b||this._b4||(e=this.centralAtomAt(b+1),d.add(a,a,e.pos()),d.scale(a,a,.5)),b!==this._b3-1||this._b5||(e=this.centralAtomAt(b-1),d.add(a,a,e.pos()),d.scale(a,a,.5)),a},centralAtomAt:function(a){return this.residueAt(a).centralAtom()},fullTraceIndex:function(a){return this._2+a},tangentAt:function(a,b){return this._bI.tangentAt(a,b+this._2)}},{TraceSubset:c,BackboneTrace:b}}(),G=function(b,c){function e(a,b){return a<<8|b.charCodeAt(0)}function f(a,b){return a.num()<b.num()}function g(a){return{num:function(){return a}}}function h(){}function i(a,b){h.call(this),this._i=a,this._H=b,this._bh=[],this._q=[],this._0=!0}function j(a,b,c){var d,e;if(a?(d=b.atom("C"),e=c.atom("N")):(d=b.atom("O3'"),e=c.atom("P")),d.isConnectedTo(e))return!1;var f=n.sqrDist(d.pos(),e.pos());return Math.abs(f-2.25)>1}function k(a,b){b.length()<2||a.push(b)}function l(a,b,c){if(0===a.length)return!0;if(!b)return!1;var d=e(c.num(),c.insCode()),f=a[a.length-1],g=e(f.num(),f.insCode());return d>g}function m(a,b){h.call(this),this._J=b,this._q=[],this._dS=a,this._cD={},this._0=!0}var n=a.vec3,o=b.Residue,p=b.ResidueView;return h.prototype={eachAtom:function(a,b){b|=0;for(var c=0;c<this._q.length;c+=1)if(b=this._q[c].eachAtom(a,b),b===!1)return!1;return b},atomCount:function(){for(var a=0,b=this.residues(),c=0;c<b.length;++c)a+=b[c].atoms().length;return a},eachResidue:function(a){for(var b=0;b<this._q.length;b+=1)if(a(this._q[b])===!1)return!1},residues:function(){return this._q},structure:function(){return this._i},asView:function(){var a=this.structure().createEmptyView();return a.addChain(this,!0),a},residueByRnum:function(a){var b=this.residues();if(this._0){var c=d.binarySearch(b,g(a),f);return-1===c?null:b[c]}for(var e=0;e<b.length;++e)if(b[e].num()===a)return b[e];return null},residuesInRnumRange:function(a,b){var c,e,h=[],i=this.residues();if(this._0===!0){var j=d.indexFirstLargerEqualThan(i,g(a),f);if(-1===j)return h;var k=d.indexLastSmallerEqualThan(i,g(b),f);if(-1===k)return h;for(c=j;k>=c;++c)h.push(this._q[c])}else for(c=0,e=i.length;c!==e;++c){var l=i[c];l.num()>=a&&l.num()<=b&&h.push(l)}return h},prop:function(a){return this[a]()}},d.derive(i,h,{name:function(){return this._H},full:function(){return this},addResidue:function(a,b,c){c=c||"\x00";var d=new o(this,a,b,c);return this._0=l(this._q,this._0,d),this._q.push(d),d},assignSS:function(a,b,c){for(var d=e(a[0],a[1]),f=e(b[0],b[1]),g=1;g<this._q.length-1;++g){var h=this._q[g],i=e(h.num(),h.insCode());d>=i||i>=f||h.setSS(c)}},eachBackboneTrace:function(a){this._ed();for(var b=0;b<this._bh.length;++b)a(this._bh[b])},_ed:function(){if(!(this._bh.length>0)){for(var a=new c.BackboneTrace,b=null,d=0;d<this._q.length;d+=1){var e=this._q[d],f=e.isAminoacid(),g=e.isNucleotide();if(b===!0&&!f||b===!1&&!g||null===b&&!g&&!f)k(this._bh,a),b=null,a=new c.BackboneTrace;else if(0!==a.length()){var h=this._q[d-1];j(b,h,e)&&(k(this._bh,a),a=new c.BackboneTrace),a.push(e)}else a.push(e),b=e.isAminoacid()}k(this._bh,a)}},backboneTraces:function(){var a=[];return this.eachBackboneTrace(function(b){a.push(b)}),a}}),d.derive(m,h,{addResidue:function(a,b){var c=new p(this,a.full());if(this._0=l(this._q,this._0,a),this._q.push(c),this._cD[a.full().index()]=c,b)for(var d=a.atoms(),e=0;e<d.length;++e)c.addAtom(d[e].full()); | },draw:function(a,b,c,d){if(this._O&&"normal"===d){var e=b.text;a.bind(e),this.bind();var f=this._c,g=a.upsamplingFactor();f.uniform1f(f.getUniformLocation(e,"xScale"),this._dp),f.uniform1f(f.getUniformLocation(e,"yScale"),this._do),f.uniform1f(f.getUniformLocation(e,"width"),2*g*this._k/a.viewportWidth()),f.uniform1f(f.getUniformLocation(e,"height"),2*g*this._m/a.viewportHeight()),f.uniform1i(f.getUniformLocation(e,"sampler"),0);var h=f.getAttribLocation(e,"attrCenter");f.enableVertexAttribArray(h),f.vertexAttribPointer(h,3,f.FLOAT,!1,20,0);var i=f.getAttribLocation(e,"attrCorner");f.vertexAttribPointer(i,2,f.FLOAT,!1,20,12),f.enableVertexAttribArray(i),f.enable(f.BLEND),f.blendFunc(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA),f.drawArrays(f.TRIANGLES,0,6),f.disableVertexAttribArray(h),f.disableVertexAttribArray(i),f.disable(f.BLEND)}}}),a}(),y=function(c){function e(){this._e=[],this._D=[],this._u=0}function f(a,b,d,f){Q.call(this,b),this._A=d,this._F=f,this._B=new e,this._dE=new c.ProtoSphere(8,8),this._dF=new c.ProtoCylinder(8),this._W=null,this._p=!1}function g(a,b,c){for(var d=0;c-1>d;++d)a.addTriangle(b,b+1+d,b+2+d);a.addTriangle(b,b+c,b+1)}function h(a,b,c){for(var d=b+c,e=0;c-1>e;++e)a.addTriangle(d,b+e+1,b+e);a.addTriangle(d,b,b+c-1)}var i=a.vec3,j=a.mat3,k=b.forceRGB;return e.prototype={numVerts:function(){return this._u},addVertex:function(a,b,c,d){this._u+=1,this._e.push(a[0],a[1],a[2],b[0],b[1],b[2],c[0],c[1],c[2],c[3],d)},addTriangle:function(a,b,c){this._D.push(a,b,c)},numIndices:function(){return this._D.length},indexData:function(){return this._D},vertData:function(){return this._e}},d.derive(f,Q,{updateProjectionIntervals:function(){},updateSquaredSphereRadius:function(a,b){return b},addTube:function(){var a=i.create(),b=i.create(),c=i.create(),d=i.create(),e=j.create();return function(f,j,m,n){n=n||{};var o=k(n.color||"white"),p=!0;void 0!==n.cap&&(p=n.cap),i.sub(d,j,f);var q=i.length(d);if(i.normalize(d,d),i.add(a,f,j),i.scale(a,a,.5),l.buildRotation(e,d,b,c,!1),p){var r=this._B.numVerts();this._B.addVertex(f,[-d[0],-d[1],-d[2]],o,0),g(this._B,r,8)}if(this._dF.addTransformed(this._B,a,q,m,e,o,o,0,0),p){var s=this._B.numVerts();this._B.addVertex(j,d,o,0),h(this._B,s-8,8)}this._p=!1}}(),addSphere:function(a,b,c){c=c||{};var d=k(c.color||"white");this._dE.addTransformed(this._B,a,b,d,0),this._p=!1},_dG:function(){this._p=!0,null!==this._W&&this._W.destroy(),this._W=new S(this._c,this._B.numVerts(),this._B.numIndices(),this._A,this._F),this._W.setIndexData(this._B.indexData()),this._W.setVertData(this._B.vertData())},draw:function(a,b,c,d){if(this._O){this._p||this._dG();var e=this.shaderForStyleAndPass(b,c,d);if(e){a.bind(e),this._c.uniform1i(e.symId,255);var f=this._W;f.bind(e),f.draw(),f.releaseAttribs(e)}}},shaderForStyleAndPass:function(a,b,c){if("normal"===c)return a.hemilight;if("select"===c)return null;if("outline"===c)return a.outline;var d=a[c];return void 0!==d?d:null}}),f}(m),z=function(){function b(a,b,c){this._cc=a,this._bO=b,this._bf=c,this._er=c,this._bl=Date.now(),this._cR=!1,this._ce=!1}function c(a,c,d){b.call(this,o.clone(a),o.clone(c),d),this._S=o.clone(a)}function e(a,c,d){var e=q.create(),f=q.create();q.fromMat4(e,a),q.fromMat4(f,c);var g=p.create(),h=p.create();p.fromMat3(g,e),p.fromMat3(h,f),this._S=q.create(),b.call(this,g,h,d)}function f(a,c){b.call(this,null,null,c),this._bM=o.clone(a),this.setLooping(!0),this._cI=0}function g(a,c){var d=1e3*(2*Math.PI/c);b.call(this,null,null,d),this._bM=o.clone(a),this.setLooping(!0),this._dz=c,this._cH=0}function h(){this._bi=[]}function i(a,b,d){return new c(a,b,d)}function j(a,b,c){return new e(a,b,c)}function k(a,c,d){return new b(a,c,d)}function m(a,b){return new g(a,b)}function n(){return new f([0,1,0],2e3)}var o=a.vec3,p=a.quat,q=a.mat3;return b.prototype={setLooping:function(a){this._cR=a},step:function(a){var b,c=Date.now(),d=c-this._bl;if(0===this._bf)b=1;else if(this._cR){var e=Math.floor(d/this._bf);b=(d-e*this._bf)/this._bf}else d=Math.min(this._bf,d),b=d/this._bf,this._ce=1===b;return this.apply(a,b),this._ce},apply:function(a,b){var c=(1-Math.cos(b*Math.PI))/2;this._S=this._cc*(1-c)+this._bO*c,a.setZoom(this._S)},finished:function(){return this._ce}},d.derive(c,b,{apply:function(a,b){var c=(1-Math.cos(b*Math.PI))/2;o.lerp(this._S,this._cc,this._bO,c),a.setCenter(this._S)}}),d.derive(e,b,{apply:function(){var a=p.create();return function(b,c){p.slerp(a,this._cc,this._bO,c),q.fromQuat(this._S,a),b.setRotation(this._S)}}()}),d.derive(f,b,{apply:function(){var a=q.create(),b=q.create();return function(c,d){q.fromMat4(b,c.rotation());var e=.2*Math.sin(2*d*Math.PI),f=e-this._cI;this._cI=e,l.axisRotation(a,this._bM,f),q.mul(b,a,b),c.setRotation(b)}}()}),d.derive(g,b,{apply:function(){var a=q.create(),b=q.create();return function(c,d){q.fromMat4(b,c.rotation());var e=2*Math.PI*(d-this._cH);this._cH=d,l.axisRotation(a,this._bM,e),q.mul(b,a,b),c.setRotation(b)}}(),setSpeed:function(a){this._dz=a},setAxis:function(a){this._bM=a}}),h.prototype={run:function(a){var b=Date.now();return this._bi=this._bi.filter(function(c){return!c.step(a,b)}),this._bi.length>0},add:function(a){this._bi.push(a)},remove:function(a){this._bi=this._bi.filter(function(b){return b!==a})}},{AnimationControl:h,move:i,rotate:j,zoom:k,rockAndRoll:n,spin:m}}(),A=function(){function a(a,b){this.near=a,this.far=b}function b(a){a=a||{},this._bb=a.near||.1,this._3=a.far||400}function c(){this._3=100}return b.prototype.update=function(){return new a(this._bb,this._3)},c.prototype.update=function(b,c){for(var d=c.center(),e=null,f=0;f<b.length;++f){var g=b[f];g.visible()&&(e=g.updateSquaredSphereRadius(d,e))}if(null===e)return null;e=Math.sqrt(e);var h=c.zoom(),i=1.05*(e+h),j=.1;return new a(j,i)},{FixedSlab:b,AutoSlab:c,Slab:a}}(),B=function(c,e,f,g,h,i,j,k,l,m,n,o){function p(){return/(iPad|iPhone|iPod)/g.test(navigator.userAgent)}function q(a,b){return a=a||"auto","fixed"===a?new A.FixedSlab(b):"auto"===a?new A.AutoSlab(b):null}function r(a,b,c){this._dK=a,this._dy=b,this._dt=c}function s(a,b){this._b=this._d1(b,a),this._bH=!1,this._l=[],this._I=a,this._bT=!1,this._1=!1,this._dT=null,this._cL=new c,this._Q=null,this._8=null,this.listenerMap={},this._U=new o.AnimationControl,this._b6(),this.quality(this._b.quality),null!==this._b.atomDoubleClicked&&this.addListener("atomDoubleClicked",this._b.atomDoubleClicked),null!==this._b.atomClick&&this.addListener("atomClicked",this._b.atomClick),"complete"===document.readyState||"loaded"===document.readyState||"interactive"===document.readyState?this._cW():document.addEventListener("DOMContentLoaded",d.bind(this,this._cW))}function t(a,b,c){return b in a?a[b]:c}var u='<div style="vertical-align:middle; text-align:center;"><h1>WebGL not supported</h1><p>Your browser does not support WebGL. You might want to try Chrome, Firefox, IE 11, or newer versions of Safari</p><p>If you are using a recent version of one of the above browsers, your graphic card might be blocked. Check the browser documentation for details on how to unblock it.</p></div>',v=a.vec3,w=a.mat4,x=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(a){window.setTimeout(a,1e3/60)}}();return r.prototype={object:function(){return this._dK},symIndex:function(){return this._dy},transform:function(){return this._dt}},s.prototype={_d1:function(a,c){a=a||{};var d={width:a.width||500,height:a.height||500,animateTime:a.animateTime||0,antialias:a.antialias,quality:t(a,"quality","low"),style:t(a,"style","hemilight"),background:b.forceRGB(a.background||"white"),slabMode:q(a.slabMode),atomClick:a.atomClicked||a.atomClick||null,outline:t(a,"outline",!0),fov:t(a,"fov",45),atomDoubleClicked:t(a,"atomDoubleClicked",t(a,"atomDoubleClick","center")),fog:t(a,"fog",!0)},e=c.getBoundingClientRect();return"auto"===d.width&&(d.width=e.width),"auto"===d.height&&(d.height=e.height),d},_cg:function(){this._1&&(this._1=!1,this._d.setViewportSize(this._.viewportWidth(),this._.viewportHeight()),this._bW.resize(this._b.width,this._b.height))},resize:function(a,b){(a!==this._b.width||b!==this._b.height)&&(this._.resize(a,b),this._1=!0,this._b.width=a,this._b.height=b,this.requestRedraw())},fitParent:function(){var a=this._I.getBoundingClientRect();this.resize(a.width,a.height)},gl:function(){return this._.gl()},ok:function(){return this._bH},options:function(a,b){return void 0!==b?("fog"===a?(this._d.fog(b),this._b.fog=b,this.requestRedraw()):"fov"===a?(this._b.fov=b,this._d.setFieldOfViewY(b*Math.PI/180)):this._b[a]=b,b):this._b[a]},quality:function(a){return this._b.quality=a,"high"===a?(this._b.arcDetail=4,this._b.sphereDetail=16,void(this._b.splineDetail=8)):"medium"===a?(this._b.arcDetail=2,this._b.sphereDetail=10,void(this._b.splineDetail=5)):"low"===a?(this._b.arcDetail=2,this._b.sphereDetail=8,void(this._b.splineDetail=3)):void 0},imageData:function(){return this._.imageData()},_d0:function(){var a={width:this._b.width,height:this._b.height};this._bW=new f(this._.gl(),a)},_cW:function(){if(!this._.initGL())return this._I.removeChild(this._.domElement()),this._I.innerHTML=u,this._I.style.width=this._b.width+"px",this._I.style.height=this._b.height+"px",!1;this._d0(),this._eo=this._by.getContext("2d"),this._A=new g(Float32Array),this._F=new g(Uint16Array),this._d=new h(this._.gl()),this._d.setUpsamplingFactor(this._.superSamplingFactor()),this._d.fog(this._b.fog),this._d.setFogColor(this._b.background),this._d.setFieldOfViewY(this._b.fov*Math.PI/180),this._b1.setCam(this._d);var a=this._,b=p()?"highp":"mediump";return this._dA={hemilight:a.initShader(i.HEMILIGHT_VS,i.HEMILIGHT_FS,b),phong:a.initShader(i.HEMILIGHT_VS,i.PHONG_FS,b),outline:a.initShader(i.OUTLINE_VS,i.OUTLINE_FS,b),lines:a.initShader(i.LINES_VS,i.LINES_FS,b),text:a.initShader(i.TEXT_VS,i.TEXT_FS,b),select:a.initShader(i.SELECT_VS,i.SELECT_FS,b)},this._ef=d.bind(this,this._d8),this._ep=new j(this._.domElement(),this,this._d),this._bH||(this._bH=!0,this._cj({name:"viewerReadyEvent"},"viewerReady",this)),!0},requestRedraw:function(){this._bT||(this._bT=!0,x(this._ef))},boundingClientRect:function(){return this._.domElement().getBoundingClientRect()},_ch:function(a){for(var b=0,c=this._l.length;b!==c;++b)this._l[b].draw(this._d,this._dA,this._b.style,a)},_b6:function(){var a={antialias:this._b.antialias,height:this._b.height,width:this._b.width,backgroundColor:this._b.background};this._=new e.Canvas(this._I,a),this._by=document.createElement("canvas"),this._by.style.display="none",this._I.appendChild(this._by),this._b1=new k(this._,this,this._d,this._b.animateTime)},setRotation:function(a,b){if(b|=0,0===b)return this._d.setRotation(a),void this.requestRedraw();var c;9===a.length?(c=w.create(),w.fromMat3(c,a)):c=w.clone(a),this._U.add(o.rotate(this._d.rotation(),c,b)),this.requestRedraw()},setCamera:function(a,b,c,d){d|=0,this.setCenter(b,d),this.setRotation(a,d),this.setZoom(c,d)},_eh:function(){var a=this._U.run(this._d);a&&this.requestRedraw()},_d8:function(){if(null!==this._){this._bT=!1,this._eh(),this._.bind(),this._cg();var a=this._.gl();a.clear(a.COLOR_BUFFER_BIT|a.DEPTH_BUFFER_BIT);var b=this._b.slabMode.update(this._l,this._d);null!==b&&this._d.setNearFar(b.near,b.far),a.enable(a.CULL_FACE),this._b.outline&&(a.cullFace(a.BACK),a.enable(a.CULL_FACE),this._ch("outline")),a.cullFace(a.FRONT),a.enable(a.BLEND),a.blendFunc(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA),this._ch("normal")}},setCenter:function(a,b){return b|=0,0===b?void this._d.setCenter(a):(this._U.add(o.move(this._d.center(),v.clone(a),b)),void this.requestRedraw())},setZoom:function(a,b){return b|=0,0===b?void this._d.setZoom(a):(this._U.add(o.zoom(this._d.zoom(),a,b)),void this.requestRedraw())},centerOn:function(a,b){this.setCenter(a.center(),b)},clear:function(){for(var a=0;a<this._l.length;++a)this._l[a].destroy();this._l=[]},addListener:function(a,b){var c=this.listenerMap[a];if("undefined"==typeof c&&(c=[],this.listenerMap[a]=c),"center"===b){var e=d.bind(this._b1,this._b1._eb);c.push(e)}else c.push(b);this._bH&&"viewerReady"===a&&b(this,null)},_cj:function(a,b,c){var d=this.listenerMap[b];d&&d.forEach(function(b){b(c,a)})},RENDER_MODES:["sline","lines","trace","lineTrace","cartoon","tube","spheres","ballsAndSticks","points"],renderAs:function(a,b,c,d){for(var e=!1,f=0;f<this.RENDER_MODES.length;++f)if(this.RENDER_MODES[f]===c){e=!0;break}return e?this[c](a,b,d):void 0},_R:function(a,b){return a=this._ca(a),a.showRelated=a.showRelated||"asym",a.showRelated&&"asym"!==a.showRelated&&null===b.assembly(a.showRelated)&&(a.showRelated="asym"),a},_ca:function(a){return a=d.copy(a),a.float32Allocator=this._A,a.uint16Allocator=this._F,a.idPool=this._cL,a},lineTrace:function(a,c,d){var e=this._R(d,c);e.color=e.color||b.uniform([1,0,1]),e.lineWidth=e.lineWidth||4;var f=l.lineTrace(c,this._.gl(),e);return this.add(a,f)},spheres:function(a,c,d){var e=this._R(d,c);e.color=e.color||b.byElement(),e.sphereDetail=this.options("sphereDetail"),e.radiusMultiplier=e.radiusMultiplier||1;var f=l.spheres(c,this._.gl(),e);return this.add(a,f)},sline:function(a,c,d){var e=this._R(d,c);e.color=e.color||b.uniform([1,0,1]),e.splineDetail=e.splineDetail||this.options("splineDetail"),e.strength=e.strength||1,e.lineWidth=e.lineWidth||4;var f=l.sline(c,this._.gl(),e);return this.add(a,f)},cartoon:function(a,c,d){var e=this._R(d,c);e.color=e.color||b.bySS(),e.strength=e.strength||1,e.splineDetail=e.splineDetail||this.options("splineDetail"),e.arcDetail=e.arcDetail||this.options("arcDetail"),e.radius=e.radius||.3,e.forceTube=e.forceTube||!1;var f=l.cartoon(c,this._.gl(),e),g=this.add(a,f);return g},surface:function(a,b,c){var d=this._ca(c),e=l.surface(b,this._.gl(),d);return this.add(a,e)},tube:function(a,b,c){return c=c||{},c.forceTube=!0,this.cartoon(a,b,c)},ballsAndSticks:function(a,c,d){var e=this._R(d,c);e.color=e.color||b.byElement(),e.radius=e.radius||.3,e.arcDetail=2*(e.arcDetail||this.options("arcDetail")),e.sphereDetail=e.sphereDetail||this.options("sphereDetail");var f=l.ballsAndSticks(c,this._.gl(),e);return this.add(a,f)},lines:function(a,c,d){var e=this._R(d,c);e.color=e.color||b.byElement(),e.lineWidth=e.lineWidth||4;var f=l.lines(c,this._.gl(),e);return this.add(a,f)},points:function(a,c,d){var e=this._R(d,c);e.color=e.color||b.byElement(),e.pointSize=e.pointSize||1;var f=l.points(c,this._.gl(),e);return this.add(a,f)},trace:function(a,c,d){var e=this._R(d,c);e.color=e.color||b.uniform([1,0,0]),e.radius=e.radius||.3,e.arcDetail=2*(e.arcDetail||this.options("arcDetail")),e.sphereDetail=e.sphereDetail||this.options("sphereDetail");var f=l.trace(c,this._.gl(),e);return this.add(a,f)},fitTo:function(a){var b=this._d.mainAxes(),c=[new d.Range,new d.Range,new d.Range];if(a instanceof Q)a.updateProjectionIntervals(b[0],b[1],b[2],c[0],c[1],c[2]);else if(void 0!==a.eachAtom){a.eachAtom(function(a){for(var d=a.pos(),e=0;3>e;++e)c[e].update(v.dot(d,b[e]))});for(var e=0;3>e;++e)c[e].extend(1.5)}this._c9(b,c)},_c9:function(a,b){if(!(b[0].empty()||b[1].empty()||b[2].empty())){var c=b[0].center(),d=b[1].center(),e=b[2].center(),f=[c*a[0][0]+d*a[1][0]+e*a[2][0],c*a[0][1]+d*a[1][1]+e*a[2][1],c*a[0][2]+d*a[1][2]+e*a[2][2]],g=this._d.fieldOfViewY(),h=this._d.aspectRatio(),i=b[0].length()/h,j=b[1].length(),k=.5*Math.max(i,j),l=k/Math.tan(.5*g),m=l+.5*b[2].length(),n=.5,o=Math.max(l-n,.1),p=2*n+l+b[2].length();this._d.setNearFar(o,p),this.setCamera(this._d.rotation(),f,m,this._b.animateTime),this.requestRedraw()}},autoZoom:function(){var a=this._d.mainAxes(),b=[new d.Range,new d.Range,new d.Range];this.forEach(function(c){c.visible()&&c.updateProjectionIntervals(a[0],a[1],a[2],b[0],b[1],b[2])}),this._c9(a,b)},slabInterval:function(){},autoSlab:function(){var a=this._b._eq.update(this._l,this._d);null!==a&&this._d.setNearFar(a.near,a.far),this.requestRedraw()},rockAndRoll:function(a){return void 0===a?null!==this._8:a?(null===this._8&&(this._8=o.rockAndRoll(),this._U.add(this._8),this.requestRedraw()),!0):(this._U.remove(this._8),this._8=null,this.requestRedraw(),!1)},spin:function(a,b){return void 0===a?null!==this._Q:a===!1?(this._U.remove(this._Q),this._Q=null,this.requestRedraw(),!1):(a===!0&&(a=Math.PI/8),b=b||[0,1,0],null===this._Q?(this._Q=o.spin(b,a),this._U.add(this._Q)):(this._Q.setSpeed(a),this._Q.setAxis(b)),this.requestRedraw(),!0)},slabMode:function(a,b){b=b||{};var c=q(a,b),d=c.update(this._l,this._d);null!==d&&this._d.setNearFar(d.near,d.far),this._b.slabMode=c,this.requestRedraw()},label:function(a,b,c,d){var e=new m(this._.gl(),this._by,this._eo,c,b,d);return this.add(a,e),e},customMesh:function(a,b){var c=this._ca(b),d=new n(a,this._.gl(),c.float32Allocator,c.uint16Allocator);return this.add(a,d),d},_d7:function(){var a=this._.gl();a.clearColor(0,0,0,0),a.disable(a.BLEND),a.clear(a.COLOR_BUFFER_BIT|a.DEPTH_BUFFER_BIT),a.clearColor(this._b.background[0],this._b.background[1],this._b.background[2],1),a.cullFace(a.FRONT),a.enable(a.CULL_FACE),this._ch("select")},pick:function(a){this._bW.bind(),this._d7();var b=new Uint8Array(4),c=this._.gl();c.readPixels(a.x,this._b.height-a.y,1,1,c.RGBA,c.UNSIGNED_BYTE,b),this._bW.release(),b.data&&(b=b.data);var d=b[0]|b[1]<<8|b[2]<<16,e=b[3],f=this._cL.objectForId(d);if(void 0===f)return null;var g=null;return 255!==e&&(g=f.geom.symWithIndex(e)),new r(f,255>e?e:null,g)},add:function(a,b){return b.name(a),this._l.push(b),this._l.sort(function(a,b){return a.order()-b.order()}),this.requestRedraw(),b},_c3:function(a){var b=a.replace(".","\\.").replace("*",".*");return new RegExp("^"+b+"$")},forEach:function(){var a,b="*";2===arguments.length?(a=arguments[1],b=arguments[0]):a=arguments[0];for(var c=this._c3(b),d=0;d<this._l.length;++d){var e=this._l[d];c.test(e.name())&&a(e,d)}},get:function(a){for(var b=0;b<this._l.length;++b)if(this._l[b].name()===a)return this._l[b];return null},hide:function(a){this.forEach(a,function(a){a.hide()})},show:function(a){this.forEach(a,function(a){a.show()})},rm:function(a){for(var b=[],c=this._c3(a),d=0;d<this._l.length;++d){var e=this._l[d];c.test(e.name())?e.destroy():b.push(e)}this._l=b},all:function(){return this._l},isWebGLSupported:function(){return this._.isWebGLSupported()},destroy:function(){this.clear(),this._.destroy(),this._=null}},s.prototype.on=s.prototype.addListener,{Viewer:function(a,b){return new s(a,b)},isWebGLSupported:e.isWebGLSupported}}(c,e,f,g,h,i,j,k,w,x,y,z),C=function(){function a(a,b){this._j=a||[],this._b2=b||[]}function b(a){this._H=a,this._cb=[]}return a.prototype={addChain:function(a){this._j.push(a)},chains:function(){return this._j},addMatrix:function(a){this._b2.push(a)},matrices:function(){return this._b2},matrix:function(a){return this._b2[a]}},b.prototype={name:function(){return this._H},generators:function(){return this._cb},generator:function(a){return this._cb[a]},addGenerator:function(a){this._cb.push(a)}},{SymGenerator:a,Assembly:b}}(),D=function(){function b(){}function c(a,c,d,e,f,g,h,i){b.call(this),this._t=a,this._cq=[],this._dU=!!g,this._H=c,this._bV=d,this._b7=f,this._be=e,this._dJ=void 0!==h?h:null,this._dx=void 0!==i?i:null}function e(a,c){b.call(this),this._dC=a,this._K=c,this._cq=[]}var f=a.vec3;return b.prototype={bondCount:function(){return this.bonds().length},eachBond:function(a){for(var b=this.bonds(),c=0,d=b.length;d>c;++c)a(b[c])},isConnectedTo:function(a){if(null===a)return!1;for(var b=a.full(),c=this.full(),d=this.bonds(),e=0,f=d.length;f>e;++e){var g=d[e];if(g.atom_one()===c&&g.atom_two()===b||g.atom_one()===b&&g.atom_two()===c)return!0}return!1}},d.derive(c,b,{addBond:function(a){this._cq.push(a)},name:function(){return this._H},bonds:function(){return this._cq},residue:function(){return this._t},structure:function(){return this._t.structure()},full:function(){return this},qualifiedName:function(){return this.residue().qualifiedName()+"."+this.name()},pos:function(){return this._bV},setPos:function(a){f.copy(this._bV,a)},element:function(){return this._be},index:function(){return this._b7},prop:function(a){return this[a]()},occupancy:function(){return this._dJ},tempFactor:function(){return this._dx},isHetatm:function(){return this._dU}}),d.derive(e,b,{full:function(){return this._K},name:function(){return this._K.name()},pos:function(){return this._K.pos()},element:function(){return this._K.element()},residue:function(){return this._dC},bonds:function(){return this._K.bonds()},index:function(){return this._K.index()},occupancy:function(){return this._K.occupancy()},tempFactor:function(){return this._K.tempFactor()},qualifiedName:function(){return this._K.qualifiedName()},isHetatm:function(){return this._K.isHetatm()}}),{Atom:c,AtomView:e}}(),E=function(b){function c(){}function e(a,b,d,e){c.call(this),this._H=b,this._dL=d,this._dW=e,this._C=[],this._cz="C",this._J=a,this._cU=!1,this._cT=!1,this._b7=a.residues().length}function f(a,b){c.call(this),this._ea=a,this._C=[],this._t=b}var g=a.vec3,h=b.Atom,i=b.AtomView;return c.prototype={prop:function(a){return this[a]()},isWater:function(){return"HOH"===this.name()||"DOD"===this.name()},eachAtom:function(a,b){b|=0;for(var c=0;c<this._C.length;c+=1){if(a(this._C[c],b)===!1)return!1;b+=1}return b},qualifiedName:function(){var a=this.chain().name()+"."+this.name()+this.num();return"\x00"===this.insCode()?a:a+this.insCode()},atom:function(a){if("string"==typeof a){for(var b=0;b<this._C.length;++b)if(this._C[b].name()===a)return this._C[b];return null}return a>=this._C.length&&0>a?null:this._C[a]},centralAtom:function(){return this.isAminoacid()?this.atom("CA"):this.isNucleotide()?this.atom("C3'"):null},center:function(){var a=0,b=g.create();return this.eachAtom(function(c){g.add(b,b,c.pos()),a+=1}),a>0&&g.scale(b,b,1/a),b},isAminoacid:function(){return this._cU},isNucleotide:function(){return this._cT}},d.derive(e,c,{_d9:function(){this._cT=null!==this.atom("P")&&null!==this.atom("C3'"),this._cU=null!==this.atom("N")&&null!==this.atom("CA")&&null!==this.atom("C")&&null!==this.atom("O")},name:function(){return this._H},insCode:function(){return this._dW},num:function(){return this._dL},full:function(){return this},addAtom:function(a,b,c,d,e,f){var g=new h(this,a,b,c,this.structure().nextAtomIndex(),d,e,f);return this._C.push(g),g},ss:function(){return this._cz},setSS:function(a){this._cz=a},index:function(){return this._b7},atoms:function(){return this._C},chain:function(){return this._J},structure:function(){return this._J.structure()}}),d.derive(f,c,{addAtom:function(a){var b=new i(this,a.full());this._C.push(b)},full:function(){return this._t},num:function(){return this._t.num()},insCode:function(){return this._t.insCode()},ss:function(){return this._t.ss()},index:function(){return this._t.index()},chain:function(){return this._ea},name:function(){return this._t.name()},atoms:function(){return this._C},qualifiedName:function(){return this._t.qualifiedName()},containsResidue:function(a){return this._t.full()===a.full()},isAminoacid:function(){return this._t.isAminoacid()},isNucleotide:function(){return this._t.isNucleotide()},isWater:function(){return this._t.isWater()}}),{ResidueView:f,Residue:e}}(D),F=function(){function b(){this._s=[]}function c(a,b,c){this._bI=a,this._2=b,this._c4=c,this._b4=0===this._2,this._b5=this._bI.length()===this._c4;var d=this._c4-this._2;this._b5||++d,this._b4||(++d,this._2-=1),this._b3=d}var d=a.vec3;return b.prototype={push:function(a){this._s.push(a)},length:function(){return this._s.length},residueAt:function(a){return this._s[a]},posAt:function(a,b){return d.copy(a,this._s[b].centralAtom().pos()),a},normalAt:function(a,b){var c=this._s[b];return c.isAminoacid()&&d.sub(a,c.atom("O").pos(),c.atom("C").pos()),d.normalize(a,a),a},centralAtomAt:function(a){return this._s[a].centralAtom()},tangentAt:function(){var a=d.create(),b=d.create();return function(c,e){e>0?this.posAt(a,e-1):this.posAt(a,e),e<this._s.length-1?this.posAt(b,e+1):this.posAt(b,e),d.sub(c,b,a)}}(),fullTraceIndex:function(a){return a},subsets:function(a){for(var b=0,d=0,e=[];d<a.length&&b<this._s.length;){for(var f=a[d].full().index();this._s.length>b&&this._s[b].index()<f;)++b;if(b>=this._s.length)break;for(var g=this._s[b].index();a.length>d&&a[d].full().index()<g;)++d;if(d>=a.length)break;for(var h=b;a.length>d&&this._s.length>b&&a[d].full().index()===this._s[b].index();)++d,++b;var i=b;e.push(new c(this,h,i))}return e}},b.prototype.smoothPosAt=b.prototype.posAt,b.prototype.smoothNormalAt=b.prototype.normalAt,c.prototype={length:function(){return this._b3},residueAt:function(a){return this._bI.residueAt(this._2+a)},_cV:function(){var a=d.create(),b=d.create();return function(c,e,f,g){return this.tangentAt(a,e),this.tangentAt(b,f),d.scale(a,a,g),d.scale(b,b,g),l.cubicHermiteInterpolate(c,this.centralAtomAt(e).pos(),a,this.centralAtomAt(f).pos(),b,.5,0),c}}(),smoothPosAt:function(){return function(a,b,c){if(0===b&&!this._b4)return this._cV(a,b,b+1,c);if(b===this._b3-1&&!this._b5)return this._cV(a,b-1,b,c);var e=this.centralAtomAt(b);return d.copy(a,e.pos()),a}}(),smoothNormalAt:function(){return function(a,b){return this._bI.normalAt(a,b+this._2),a}}(),posAt:function(a,b){var c=this.centralAtomAt(b),e=null;return d.copy(a,c.pos()),0!==b||this._b4||(e=this.centralAtomAt(b+1),d.add(a,a,e.pos()),d.scale(a,a,.5)),b!==this._b3-1||this._b5||(e=this.centralAtomAt(b-1),d.add(a,a,e.pos()),d.scale(a,a,.5)),a},centralAtomAt:function(a){return this.residueAt(a).centralAtom()},fullTraceIndex:function(a){return this._2+a},tangentAt:function(a,b){return this._bI.tangentAt(a,b+this._2)}},{TraceSubset:c,BackboneTrace:b}}(),G=function(b,c){function e(a,b){return a<<8|b.charCodeAt(0)}function f(a,b){return a.num()<b.num()}function g(a){return{num:function(){return a}}}function h(){}function i(a,b){h.call(this),this._i=a,this._H=b,this._bh=[],this._q=[],this._0=!0}function j(a,b,c){var d,e;if(a?(d=b.atom("C"),e=c.atom("N")):(d=b.atom("O3'"),e=c.atom("P")),d.isConnectedTo(e))return!1;var f=n.sqrDist(d.pos(),e.pos());return Math.abs(f-2.25)>1}function k(a,b){b.length()<2||a.push(b)}function l(a,b,c){if(0===a.length)return!0;if(!b)return!1;var d=e(c.num(),c.insCode()),f=a[a.length-1],g=e(f.num(),f.insCode());return d>g}function m(a,b){h.call(this),this._J=b,this._q=[],this._dS=a,this._cD={},this._0=!0}var n=a.vec3,o=b.Residue,p=b.ResidueView;return h.prototype={eachAtom:function(a,b){b|=0;for(var c=0;c<this._q.length;c+=1)if(b=this._q[c].eachAtom(a,b),b===!1)return!1;return b},atomCount:function(){for(var a=0,b=this.residues(),c=0;c<b.length;++c)a+=b[c].atoms().length;return a},eachResidue:function(a){for(var b=0;b<this._q.length;b+=1)if(a(this._q[b])===!1)return!1},residues:function(){return this._q},structure:function(){return this._i},asView:function(){var a=this.structure().createEmptyView();return a.addChain(this,!0),a},residueByRnum:function(a){var b=this.residues();if(this._0){var c=d.binarySearch(b,g(a),f);return-1===c?null:b[c]}for(var e=0;e<b.length;++e)if(b[e].num()===a)return b[e];return null},residuesInRnumRange:function(a,b){var c,e,h=[],i=this.residues();if(this._0===!0){var j=d.indexFirstLargerEqualThan(i,g(a),f);if(-1===j)return h;var k=d.indexLastSmallerEqualThan(i,g(b),f);if(-1===k)return h;for(c=j;k>=c;++c)h.push(this._q[c])}else for(c=0,e=i.length;c!==e;++c){var l=i[c];l.num()>=a&&l.num()<=b&&h.push(l)}return h},prop:function(a){return this[a]()}},d.derive(i,h,{name:function(){return this._H},full:function(){return this},addResidue:function(a,b,c){c=c||"\x00";var d=new o(this,a,b,c);return this._0=l(this._q,this._0,d),this._q.push(d),d},assignSS:function(a,b,c){for(var d=e(a[0],a[1]),f=e(b[0],b[1]),g=1;g<this._q.length-1;++g){var h=this._q[g],i=e(h.num(),h.insCode());d>=i||i>=f||h.setSS(c)}},eachBackboneTrace:function(a){this._ed();for(var b=0;b<this._bh.length;++b)a(this._bh[b])},_ed:function(){if(!(this._bh.length>0)){for(var a=new c.BackboneTrace,b=null,d=0;d<this._q.length;d+=1){var e=this._q[d],f=e.isAminoacid(),g=e.isNucleotide();if(b===!0&&!f||b===!1&&!g||null===b&&!g&&!f)k(this._bh,a),b=null,a=new c.BackboneTrace;else if(0!==a.length()){var h=this._q[d-1];j(b,h,e)&&(k(this._bh,a),a=new c.BackboneTrace),a.push(e)}else a.push(e),b=e.isAminoacid()}k(this._bh,a)}},backboneTraces:function(){var a=[];return this.eachBackboneTrace(function(b){a.push(b)}),a}}),d.derive(m,h,{addResidue:function(a,b){var c=new p(this,a.full());if(this._0=l(this._q,this._0,a),this._q.push(c),this._cD[a.full().index()]=c,b)for(var d=a.atoms(),e=0;e<d.length;++e)c.addAtom(d[e].full()); | ||
return c},containsResidue:function(a){var b=this._cD[a.full().index()];return void 0===b?!1:b.full()===a.full()},eachBackboneTrace:function(a){for(var b=this._J.backboneTraces(),c=0;c<b.length;++c)for(var d=b[c].subsets(this._q),e=0;e<d.length;++e)a(d[e])},backboneTraces:function(){var a=[];return this.eachBackboneTrace(function(b){a.push(b)}),a},full:function(){return this._J},name:function(){return this._J.name()},structure:function(){return this._dS}}),{Chain:i,ChainView:m}}(E,F),H=function(){var b=a.vec3,c=function(a,c){var d={atom_one:a,atom_two:c};return{atom_one:function(){return d.atom_one},atom_two:function(){return d.atom_two},mid_point:function(a){return a||(a=b.create()),b.add(a,d.atom_one.pos(),d.atom_two.pos()),b.scale(a,a,.5),a}}};return{Bond:c}}(),I=function(){function a(a,b){for(var c=0;c<b.length;++c)if(!b[c](a))return!1;return!0}function b(a){var b=[];return void 0!==a.aname&&b.push(function(b){return b.name()===a.aname}),void 0!==a.hetatm&&b.push(function(b){return b.isHetatm()===a.hetatm}),void 0!==a.anames&&b.push(function(b){for(var c=b.name(),d=0;d<a.anames.length;++d)if(c===a.anames[d])return!0;return!1}),b}function c(a){var b=[];if(void 0!==a.rname&&b.push(function(b){return b.name()===a.rname}),void 0!==a.rnames&&b.push(function(b){for(var c=b.name(),d=0;d<a.rnames.length;++d)if(c===a.rnames[d])return!0;return!1}),void 0!==a.rnums){for(var c={},d=0;d<a.rnums.length;++d)c[a.rnums[d]]=!0;b.push(function(a){var b=a.num();return c[b]===!0})}return void 0!==a.rnum&&b.push(function(b){return b.num()===a.rnum}),b}function d(a){var b=[];return void 0!==a.cname&&(a.chain=a.cname),void 0!==a.cnames&&(a.chains=a.cnames),void 0!==a.chain&&b.push(function(b){return b.name()===a.chain}),void 0!==a.chains&&b.push(function(b){for(var c=b.name(),d=0;d<a.chains.length;++d)if(c===a.chains[d])return!0;return!1}),b}function e(a,b){var c=a.residues();b.rnumRange&&(c=a.residuesInRnumRange(b.rnumRange[0],b.rnumRange[1]));var d,e,f=[];if(void 0!==b.rindexRange){for(d=b.rindexRange[0],e=Math.min(c.length-1,b.rindexRange[1]);e>=d;++d)f.push(c[d]);return f}if(b.rindices&&void 0!==b.rindices.length){for(f=[],d=0;d<b.rindices.length;++d)f.push(c[b.rindices[d]]);return f}return c}function f(f,g,h){var i=c(h),j=b(h),k=d(h);h.rindex&&(h.rindices=[h.rindex]);for(var l=0;l<f._j.length;++l){var m=f._j[l];if(a(m,k))for(var n=e(m,h),o=null,p=0;p<n.length;++p)if(a(n[p],i)){o||(o=g.addChain(m,!1));for(var q=null,r=n[p].atoms(),s=0;s<r.length;++s)a(r[s],j)&&(q||(q=o.addResidue(n[p],!1)),q.addAtom(r[s]))}}return g}return{dict:f}}(),J=U=function(b,c,e){function f(a){var b=q[a.toUpperCase()];return void 0!==b?b:1.5}function g(a,b,c){var d=b.atom("C"),e=c.atom("N");if(d&&e){var f=m.sqrDist(d.pos(),e.pos());1.6*1.6>f&&a.connect(e,d)}}function h(a,b,c){var d=b.atom("O3'"),e=c.atom("P");if(d&&e){var f=m.sqrDist(d.pos(),e.pos());1.7*1.7>f&&a.connect(d,e)}}function i(){}function j(){i.call(this),this._j=[],this._N=[],this._cM=0}function k(a){i.call(this),this._cO=a,this._j=[]}var m=a.vec3,n=b.Chain,o=b.ChainView,p=c.Bond,q={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};return i.prototype={eachResidue:function(a){for(var b=0;b<this._j.length;b+=1)if(this._j[b].eachResidue(a)===!1)return!1},eachAtom:function(a,b){b|=0;for(var c=0;c<this._j.length;c+=1)if(b=this._j[c].eachAtom(a,b),b===!1)return!1},residueCount:function(){for(var a=this.chains(),b=0,c=0;c<a.length;++c)b+=a[c].residues().length;return b},eachChain:function(a){for(var b=this.chains(),c=0;c<b.length;++c)if(a(b[c])===!1)return},atomCount:function(){for(var a=this.chains(),b=0,c=0;c<a.length;++c)b+=a[c].atomCount();return b},atoms:function(){var a=[];return this.eachAtom(function(b){a.push(b)}),a},atom:function(a){var b=a.split("."),c=this.chain(b[0]);if(null===c)return null;var d=c.residueByRnum(parseInt(b[1],10));return null===d?null:d.atom(b[2])},center:function(){var a=m.create(),b=0;return this.eachAtom(function(c){m.add(a,a,c.pos()),b+=1}),b&&m.scale(a,a,1/b),a},boundingSphere:function(){var a=this.center(),b=0;return this.eachAtom(function(c){b=Math.max(b,m.sqrDist(a,c.pos()))}),new l.Sphere(a,Math.sqrt(b))},backboneTraces:function(){for(var a=this.chains(),b=[],c=0;c<a.length;++c)Array.prototype.push.apply(b,a[c].backboneTraces());return b},select:function(a){return"protein"===a?this.residueSelect(function(a){return a.isAminoacid()}):"water"===a?this.residueSelect(function(a){return a.isWater()}):"ligand"===a?this.residueSelect(function(a){return!a.isAminoacid()&&!a.isWater()}):e.dict(this,new k(this),a||{})},residueSelect:function(a){for(var b=new k(this.full()),c=0;c<this._j.length;++c)for(var d=this._j[c],e=null,f=d.residues(),g=0;g<f.length;++g)a(f[g])&&(e||(e=b.addChain(d,!1)),e.addResidue(f[g],!0));return b},atomSelect:function(a){for(var b=new k(this.full()),c=0;c<this._j.length;++c)for(var d=this._j[c],e=null,f=d.residues(),g=0;g<f.length;++g)for(var h=null,i=f[g],j=i.atoms(),l=0;l<j.length;++l)a(j[l])&&(e||(e=b.addChain(d,!1)),h||(h=e.addResidue(i,!1)),h.addAtom(j[l]));return b},assembly:function(a){for(var b=this.assemblies(),c=0;c<b.length;++c)if(b[c].name()===a)return b[c];return null},chainsByName:function(a){for(var b={},c=this.chains(),d=0;d<c.length;++d)b[c[d].name()]=c[d];for(var e=[],f=0;f<a.length;++f){var g=b[a[f]];void 0!==g&&e.push(g)}return e},selectWithin:function(){var a=m.create();return function(b,c){c=c||{};var d=c.radius||4,e=d*d,f=!!c.matchResidues,g=[];b.eachAtom(function(a){g.push(a)});for(var h=new k(this.full()),i=null,j=null,l=this.chains(),n=!1,o=0;o<l.length;++o){var p=l[o].residues();j=null;for(var q=0;q<p.length;++q){i=null,n=!1;for(var r=p[q].atoms(),s=0;s<r.length&&!n;++s)for(var t=0;t<g.length;++t)if(m.sub(a,r[s].pos(),g[t].pos()),!(m.sqrLen(a)>e)){if(j||(j=h.addChain(l[o].full(),!1)),i||(i=j.addResidue(p[q].full(),f)),f){n=!0;break}i.addAtom(r[s].full());break}}}return h}}(),createEmptyView:function(){return new k(this.full())}},d.derive(j,i,{addAssembly:function(a){this._N.push(a)},setAssemblies:function(a){this._N=a},assemblies:function(){return this._N},chains:function(){return this._j},full:function(){return this},containsResidue:function(a){return a.full().structure()===this},chainByName:function(a){for(var b=0;b<this._j.length;++b)if(this._j[b].name()===a)return this._j[b];return null},chain:function(a){return this.chainByName(a)},nextAtomIndex:function(){var a=this._cM;return this._cM+=1,a},addChain:function(a){var b=new n(this,a);return this._j.push(b),b},connect:function(a,b){var c=new p(a,b);return a.addBond(c),b.addBond(c),c},deriveConnectivity:function(){var a=this,b=null;this.eachResidue(function(c){for(var d,e=c.atoms(),i=e.length,j=0;i>j;j+=1)for(var k=e[j],l=k.pos(),n=f(k.element()),o=0;j>o;o+=1){var p=e[o],q=f(p.element());d=m.sqrDist(l,p.pos());var r=n+q-.3,s=n+q+.3;s*s>d&&d>r*r&&a.connect(k,p)}c._d9(),null!==b&&(c.isAminoacid()&&b.isAminoacid()&&g(a,b,c),c.isNucleotide()&&b.isNucleotide()&&h(a,b,c)),b=c})}}),d.derive(k,i,{full:function(){return this._cO},assemblies:function(){return this._cO.assemblies()},addChain:function(a,b){var c=new o(this,a.full());if(this._j.push(c),b)for(var d=a.residues(),e=0;e<d.length;++e)c.addResidue(d[e],!0);return c},containsResidue:function(a){if(!a)return!1;var b=this.chain(a.chain().name());return b?b.containsResidue(a):!1},chains:function(){return this._j},chain:function(a){for(var b=0;b<this._j.length;++b)if(this._j[b].name()===a)return this._j[b];return null}}),{MolView:k,Mol:j}}(G,H,I),K=function(){function a(a){function b(a,b){return a=Math.abs(a),b=Math.abs(b),a>b?a*Math.sqrt(1+b*b/a/a):0==b?a:b*Math.sqrt(1+a*a/b/b)}var c,d=Math.pow(2,-52),e=1e-64/d,f=50,g=0,h=0,i=0,j=0,k=0,l=a,m=l.length,n=l[0].length;if(n>m)throw"Need more rows than columns";var o=new Array(n),p=new Array(n);for(h=0;n>h;h++)o[h]=p[h]=0;for(var q=[],h=0;n>h;++h){var r=[];q.push([]);for(var i=0;n>i;++i)r.push(0);q.push(r)}var s=0,t=0,u=0,v=0,w=0,x=0,y=0;for(h=0;n>h;h++){for(o[h]=t,y=0,k=h+1,i=h;m>i;i++)y+=l[i][h]*l[i][h];if(e>=y)t=0;else for(s=l[h][h],t=Math.sqrt(y),s>=0&&(t=-t),u=s*t-y,l[h][h]=s-t,i=k;n>i;i++){for(y=0,j=h;m>j;j++)y+=l[j][h]*l[j][i];for(s=y/u,j=h;m>j;j++)l[j][i]+=s*l[j][h]}for(p[h]=t,y=0,i=k;n>i;i++)y+=l[h][i]*l[h][i];if(e>=y)t=0;else{for(s=l[h][h+1],t=Math.sqrt(y),s>=0&&(t=-t),u=s*t-y,l[h][h+1]=s-t,i=k;n>i;i++)o[i]=l[h][i]/u;for(i=k;m>i;i++){for(y=0,j=k;n>j;j++)y+=l[i][j]*l[h][j];for(j=k;n>j;j++)l[i][j]+=y*o[j]}}w=Math.abs(p[h])+Math.abs(o[h]),w>v&&(v=w)}for(h=n-1;-1!=h;h+=-1){if(0!=t){for(u=t*l[h][h+1],i=k;n>i;i++)q[i][h]=l[h][i]/u;for(i=k;n>i;i++){for(y=0,j=k;n>j;j++)y+=l[h][j]*q[j][i];for(j=k;n>j;j++)q[j][i]+=y*q[j][h]}}for(i=k;n>i;i++)q[h][i]=0,q[i][h]=0;q[h][h]=1,t=o[h],k=h}for(h=n-1;-1!=h;h+=-1){for(k=h+1,t=p[h],i=k;n>i;i++)l[h][i]=0;if(0!=t){for(u=l[h][h]*t,i=k;n>i;i++){for(y=0,j=k;m>j;j++)y+=l[j][h]*l[j][i];for(s=y/u,j=h;m>j;j++)l[j][i]+=s*l[j][h]}for(i=h;m>i;i++)l[i][h]=l[i][h]/t}else for(i=h;m>i;i++)l[i][h]=0;l[h][h]+=1}for(d*=v,j=n-1;-1!=j;j+=-1)for(var z=0;f>z;z++){var A=!1;for(k=j;-1!=k;k+=-1){if(Math.abs(o[k])<=d){A=!0;break}if(Math.abs(p[k-1])<=d)break}if(!A){g=0,y=1;var B=k-1;for(h=k;j+1>h&&(s=y*o[h],o[h]=g*o[h],!(Math.abs(s)<=d));h++)for(t=p[h],u=b(s,t),p[h]=u,g=t/u,y=-s/u,i=0;m>i;i++)w=l[i][B],x=l[i][h],l[i][B]=w*g+x*y,l[i][h]=-w*y+x*g}if(x=p[j],k==j){if(0>x)for(p[j]=-x,i=0;n>i;i++)q[i][j]=-q[i][j];break}if(z>=f-1)throw"Error: no convergence.";for(v=p[k],w=p[j-1],t=o[j-1],u=o[j],s=((w-x)*(w+x)+(t-u)*(t+u))/(2*u*w),t=b(s,1),s=0>s?((v-x)*(v+x)+u*(w/(s-t)-u))/v:((v-x)*(v+x)+u*(w/(s+t)-u))/v,g=1,y=1,h=k+1;j+1>h;h++){for(t=o[h],w=p[h],u=y*t,t=g*t,x=b(s,u),o[h-1]=x,g=s/x,y=u/x,s=v*g+t*y,t=-v*y+t*g,u=w*y,w*=g,i=0;n>i;i++)v=q[i][h-1],x=q[i][h],q[i][h-1]=v*g+x*y,q[i][h]=-v*y+x*g;for(x=b(s,u),p[h-1]=x,g=s/x,y=u/x,s=g*t+y*w,v=-y*t+g*w,i=0;m>i;i++)w=l[i][h-1],x=l[i][h],l[i][h-1]=w*g+x*y,l[i][h]=-w*y+x*g}o[k]=0,o[j]=s,p[j]=v}for(h=0;h<p.length;h++)p[h]<d&&(p[h]=0);for(h=0;n>h;h++)for(i=h-1;i>=0;i--)if(p[i]<p[h]){for(g=p[i],p[i]=p[h],p[h]=g,j=0;j<l.length;j++)c=l[j][h],l[j][h]=l[j][i],l[j][i]=c;for(j=0;j<q.length;j++)c=q[j][h],q[j][h]=q[j][i],q[j][i]=c;h=i}return{U:l,S:p,V:q}}return a}(),L=function(){function b(a){if(void 0===a||null===a||"all"===a)return null;if("backbone"===a)return{CA:!0,C:!0,O:!0,N:!0};if(void 0!==a.substr){for(var b={},c=a.split(","),d=0;d<c.length;++d)b[c[d].trim()]=!0;return b}for(var b={},d=0;d<a.length;++d)b[a[d]]=!0;return b}function c(a,b,c,d,e){for(var f=a.atoms(),g=b.atoms(),h=0;h<f.length;++h){var i=f[h];if(null===e||e[i.name()]===!0)for(var j=0;j<g.length;++j){var k=g[j];if(k.name()===i.name()){c.push(i),d.push(k);break}}}}function d(a,d,e,f){for(var g=a.full().createEmptyView(),h=d.full().createEmptyView(),i=Math.min(a.chains().length,d.chains().length),j=b(e),k=0;i>k;++k){var l=a.chains()[k],m=d.chains()[k],n=f(l,m),o=n[0],p=n[1];if(o.length!==p.length)return console.errors("chains",l.name()," and",m.name()," do not contain the same number of residues."),null;for(var q=g.addChain(l),r=h.addChain(m),s=0;s<o.length;++s){var t=o[s],u=p[s],v=[],w=[];if(c(t,u,v,w,j),0!==v.length)for(var x=q.addResidue(t),y=r.addResidue(u),z=0;z<v.length;++z)x.addAtom(v[z]),y.addAtom(w[z])}}return[g,h]}function e(a,b,c){return d(a,b,c,function(a,b){return[a.residues(),b.residues()]})}function f(a,b,c){return d(a,b,c,function(a,b){for(var c=[],d=[],e=a.residues(),f=0;f<e.length;++f){var g=b.residueByRnum(e[f].num());null!==g&&(c.push(e[f]),d.push(g))}return[c,d]})}var g=a.vec3,h=a.mat3,i=(a.quat,function(a,b){if(g.set(b,0,0,0),0!==a.length){for(var c=0;c<a.length;++c){var d=a[c];g.add(b,b,d.pos())}g.scale(b,b,1/a.length)}}),j=function(){var a=g.create(),b=g.create();return function(c,d,e,f,h){h[0]=0,h[1]=0,h[2]=0,h[3]=0,h[4]=0,h[5]=0,h[6]=0,h[7]=0,h[8]=0;for(var i=0;i<d.length;++i){g.sub(a,c[i].pos(),e),g.sub(b,d[i].pos(),f);var j=a,k=b;h[0]+=j[0]*k[0],h[1]+=j[0]*k[1],h[2]+=j[0]*k[2],h[3]+=j[1]*k[0],h[4]+=j[1]*k[1],h[5]+=j[1]*k[2],h[6]+=j[2]*k[0],h[7]+=j[2]*k[1],h[8]+=j[2]*k[2]}}}(),k=function(){var a=g.create(),b=g.create(),c=g.create(),d=h.create(),e=h.create(),f=h.create(),k=h.create(),l=h.create();return function(m,n){var o=m.atoms(),p=n.atoms();if(i(p,a),i(o,b),o.length!==p.length)return!1;if(o.length<3)return!1;j(o,p,b,a,e);var q=[[e[0],e[1],e[2]],[e[3],e[4],e[5]],[e[6],e[7],e[8]]],r=K(q);k[0]=r.U[0][0],k[1]=r.U[0][1],k[2]=r.U[0][2],k[3]=r.U[1][0],k[4]=r.U[1][1],k[5]=r.U[1][2],k[6]=r.U[2][0],k[7]=r.U[2][1],k[8]=r.U[2][2];var s=h.determinant(k);l[0]=r.V[0][0],l[1]=r.V[0][1],l[2]=r.V[0][2],l[3]=r.V[1][0],l[4]=r.V[1][1],l[5]=r.V[1][2],l[6]=r.V[2][0],l[7]=r.V[2][1],l[8]=r.V[2][2];var t=h.determinant(l);h.identity(f),0>s*t&&(f[8]=-1,h.mul(k,k,f)),h.mul(d,h.transpose(l,l),k),h.transpose(d,d);for(var u=m.full().atoms(),v=0;v<u.length;++v){var w=u[v];g.sub(c,w.pos(),b),g.transformMat3(c,c,d),g.add(c,a,c),w.setPos(c)}return!0}}();return{superpose:k,matchResiduesByNum:f,matchResiduesByIndex:e,parseAtomNames:b,addAtomsPresentInBoth:c}}(),M=U=function(b){function c(a){for(var b=0;b<a.length();++b)a.residueAt(b).setSS(g(a,b)?"H":h(a,b)?"E":"C")}function d(a){for(var b=a.chains(),d=0;d<b.length;++d){var e=b[d];e.eachBackboneTrace(c)}}var e=a.vec3,f=function(){var a=e.create(),b=e.create();return function(c,d,f,g){for(var h=Math.max(0,d-2);d>=h;++h)for(var i=2;5>i;++i)if(!(h+i>=c.length())){var j=e.dist(c.posAt(a,h),c.posAt(b,h+i));if(Math.abs(j-f[i-2])>g)return!1}return!0}}(),g=function(a,b){var c=[5.45,5.18,6.37],d=2.1;return f(a,b,c,d)},h=function(a,b){var c=[6.1,10.4,13],d=1.42;return f(a,b,c,d)};return{Mol:U.Mol,MolView:U.MolView,assignHelixSheet:d,superpose:b.superpose,matchResiduesByIndex:b.matchResiduesByIndex,matchResiduesByNum:b.matchResiduesByNum}}(L),N=function(b){function c(){this._N={},this._S=null}function d(a){if(" "!==a[0]){var b=a.trim();if(4===b.length){for(var c=0,d=b.charCodeAt(c);4>c&&(65>d||d>122||d>90&&97>d);)++c,d=b.charCodeAt(c);return b[c]}var e=b.charCodeAt(0);return e>=48&&57>=e?b[1]:b.substr(0,2)}return a[1]}function e(a){this._b9=[],this._bQ=[],this._cn=[],this._bR={},this._i=new U.Mol,this._cF=new c,this._bL=null,this._br=null,this._et=null,this._b={},this._b.conectRecords=!!a.conectRecords}function f(a){return a.split(/\r\n|\r|\n/g)}function g(a,b){for(var c=b||{},d=f(a),g=new e(c),h=0;h<d.length&&g.processLine(d[h]);h++);var i=g.finish();return i}function h(){this._i=new U.Mol,this._cE(),this._bS=!1}function i(a){for(var b=new h,c=f(a),d=0;d<c.length&&b.processLine(c[d]);d++);var e=b.finish();return e}function j(a,b){var c=new XMLHttpRequest;c.open("GET",a,!0),c.onload=function(){c.response&&b(c.response)},c.send(null)}function k(a,b,c){j(a,function(a){var d=g(a,c);b(d)})}function l(a,b){j(a,function(a){var c=i(a);b(c)})}var m=a.vec3,n=a.mat4;return c.prototype={assemblies:function(){var a=[];for(var b in this._N)this._N.hasOwnProperty(b)&&a.push(this._N[b]);return a},assembly:function(a){return this._N[a]},nextLine:function(a){if(a=a.substr(11),"B"===a[0]&&"BIOMOLECULE:"===a.substr(0,12)){var c=a.substr(13).trim();return this._de=new b.Assembly(c),void(this._N[c]=this._de)}if("APPLY THE FOLLOWING TO CHAINS:"!==a.substr(0,30)&&" AND CHAINS:"!==a.substr(0,30)){if(" BIOMT"===a.substr(0,7)){for(var d=parseInt(a[7],10)-1,e=0;" "!==a[12+e];)e+=1;var f=parseFloat(a.substr(13+e,9)),g=parseFloat(a.substr(23+e,9)),h=parseFloat(a.substr(33+e,9)),i=parseFloat(a.substr(43+e,14));return this._bg[0+d]=f,this._bg[4+d]=g,this._bg[8+d]=h,this._bg[12+d]=i,void(2===d&&(this._ck.addMatrix(this._bg),this._bg=n.create()))}}else{var j=a.substr(30).split(",");"A"===a[0]&&(this._ck=new b.SymGenerator,this._de.addGenerator(this._ck)),this._bg=n.create();for(var k=0;k<j.length;++k){var l=j[k].trim();l.length&&this._ck.addChain(l)}}}},e.prototype={parseHelixRecord:function(a){var b=parseInt(a.substr(21,4),10),c=" "===a[25]?"\x00":a[25],d=parseInt(a.substr(33,4),10),e=" "===a[37]?"\x00":a[37],f=a[19];return this._b9.push({first:[b,c],last:[d,e],chainName:f}),!0},parseSheetRecord:function(a){var b=parseInt(a.substr(22,4),10),c=" "===a[26]?"\x00":a[26],d=parseInt(a.substr(33,4),10),e=" "===a[37]?"\x00":a[37],f=a[21];return this._bQ.push({first:[b,c],last:[d,e],chainName:f}),!0},parseAndAddAtom:function(a){var b=a[16];if(" "!==b&&"A"!==b)return!0;var c="H"===a[0],e=a[21],f=a.substr(17,3).trim(),g=a.substr(12,4),h=g.trim(),i=parseInt(a.substr(22,4),10);i!==i&&(i=1);var j=" "===a[26]?"\x00":a[26],k=!1,l=!1;this._bL&&this._bL.name()===e||(l=!0,k=!0),this._br&&this._br.num()===i&&this._br.insCode()===j||(k=!0),l&&(this._bL=this._i.chain(e)||this._i.addChain(e)),k&&(this._br=this._bL.addResidue(f,i,j));for(var n=m.create(),o=0;3>o;++o)n[o]=parseFloat(a.substr(30+8*o,8));var p=a.substr(76,2).trim();""===p&&(p=d(g));var q=parseFloat(a.substr(54,6).trim()),r=parseFloat(a.substr(60,6).trim()),s=this._br.addAtom(h,n,p,c,isNaN(q)?null:q,isNaN(r)?null:r);if(this._b.conectRecords){var t=parseInt(a.substr(6,5).trim(),10);this._bR[t]=s}return!0},parseConectRecord:function(a){for(var b=parseInt(a.substr(6,5).trim(),10),c=[],d=0;4>d;++d){var e=parseInt(a.substr(11+5*d,6).trim(),10);isNaN(e)||e>b||c.push(e)}return this._cn.push({from:b,to:c}),!0},processLine:function(a){var b=a.substr(0,6);if("ATOM "===b||"HETATM"===b)return this.parseAndAddAtom(a);if("REMARK"===b){var c=a.substr(7,3);return"350"===c&&this._cF.nextLine(a),!0}return"HELIX "===b?this.parseHelixRecord(a):"SHEET "===b?this.parseSheetRecord(a):this._b.conectRecords&&"CONECT"===b?this.parseConectRecord(a):"END "===b||"ENDMDL"===b?!1:!0},finish:function(){var a,b=null;for(a=0;a<this._bQ.length;++a){var c=this._bQ[a];b=this._i.chain(c.chainName),b&&b.assignSS(c.first,c.last,"E")}for(a=0;a<this._b9.length;++a){var d=this._b9[a];b=this._i.chain(d.chainName),b&&b.assignSS(d.first,d.last,"H")}return this._i.setAssemblies(this._cF.assemblies()),this._b.conectRecords&&this._eg(this._i),this._i.deriveConnectivity(),this._i},_eg:function(a){for(var b=0;b<this._cn.length;++b)for(var c=this._cn[b],d=this._bR[c.from],e=0;e<c.to.length;++e){var f=this._bR[c.to[e]];a.connect(d,f)}}},h.prototype={processLine:function(a){var b=this._7;if(3>b){if(0===b){var c=a.trim();if(0===c.length)return!1;this._cx=c}return this._bS=!1,this._7++,!0}if(3===b){if(this._cf=parseInt(a.substr(0,3).trim(),10),this._db=parseInt(a.substr(3,3).trim(),10),isNaN(this._cf)||isNaN(this._db))return!1;this._7++;var d=""+(this._i.chains().length+1);this._dd=this._i.addChain(d),this._cm=this._dd.addResidue(this._cx,1)}if(4===b){for(var e=[0,0,0],f=0;3>f;++f)if(e[f]=parseFloat(a.substr(10*f,10).trim()),isNaN(e[f]))return!1;var g=a.substr(31,3).trim();this._cm.addAtom(g,e,g,!1),this._dk++,this._dk===this._cf&&this._7++}if(5===b){var h=parseInt(a.substr(0,3).trim(),10)-1,i=parseInt(a.substr(3,3).trim(),10)-1;if(isNaN(h)||isNaN(i))return!1;var j=this._cm.atoms();this._i.connect(j[h],j[i]),this._di++,this._di===this._db&&this._7++}return"M END"===a.substr(0,6)&&(this._bS=!0,this._7++),"$$$$"===a.substr(0,4)&&this._cE(),!0},_cE:function(){this._7=0,this._cm=null,this._dd=null,this._cf=null,this._es=null,this._dk=0,this._di=0,this._cx=""},finish:function(){return this._bS?this._i:null}},{pdb:g,sdf:i,Remark350Reader:c,fetchPdb:k,fetchSdf:l,guessAtomElementFromName:d}}(C),O=function(){var b=a.vec3,c=a.mat3,d=function(){var a=b.create(),c=b.create();return function(d,e){b.set(a,0,0,0);var f=0;d.eachCentralAtom(function(c,d){b.add(a,a,d),f+=1}),0!==f&&(b.scale(a,a,1/f),e[0]=0,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=0,e[6]=0,e[7]=0,e[8]=0,d.eachCentralAtom(function(d,f){b.sub(c,f,a);var g=c[0],h=c[1],i=c[2];e[0]+=h*h+i*i,e[1]-=g*h,e[2]-=g*i,e[5]-=h*i,e[4]+=g*g+i*i,e[8]+=g*g+h*h}),e[3]=e[1],e[6]=e[2],e[7]=e[5])}}(),e=function(){var a=c.create(),e=c.create(),f=b.create(),g=b.create(),h=b.create(),i=b.create(),j=b.create(),k=b.create(),m=b.create();return function(n){d(n,a);var o=l.diagonalizer(a);c.fromQuat(e,o);var p=!0;n.eachCentralAtom(function(a,c){b.transformMat3(h,c,e),p?(b.copy(f,h),b.copy(g,h),p=!1):(b.min(f,f,h),b.max(g,g,h))}),b.sub(i,g,f);var q=[[i[0],0],[i[1],1],[i[2],2]];q.sort(function(a,b){return b[0]-a[0]});var r=q[0][1],s=q[1][1];b.set(j,e[r+0],e[r+3],e[r+6]),b.set(k,e[s+0],e[s+3],e[s+6]),b.cross(m,j,k);var t=c.create();return t[0]=j[0],t[1]=k[0],t[2]=m[0],t[3]=j[1],t[4]=k[1],t[5]=m[1],t[6]=j[2],t[7]=k[2],t[8]=m[2],t}}();return{principalAxes:e}}(),P=function(){return{Viewer:B.Viewer,isWebGLSupported:B.isWebGLSupported,io:N,color:b,mol:U,rgb:{setColorPalette:b.setColorPalette,hex2rgb:b.hex2rgb},vec3:a.vec3,vec4:a.vec4,mat3:a.mat3,mat4:a.mat4,quat:a.quat,viewpoint:O}}()}); | return c},containsResidue:function(a){var b=this._cD[a.full().index()];return void 0===b?!1:b.full()===a.full()},eachBackboneTrace:function(a){for(var b=this._J.backboneTraces(),c=0;c<b.length;++c)for(var d=b[c].subsets(this._q),e=0;e<d.length;++e)a(d[e])},backboneTraces:function(){var a=[];return this.eachBackboneTrace(function(b){a.push(b)}),a},full:function(){return this._J},name:function(){return this._J.name()},structure:function(){return this._dS}}),{Chain:i,ChainView:m}}(E,F),H=function(){var b=a.vec3,c=function(a,c){var d={atom_one:a,atom_two:c};return{atom_one:function(){return d.atom_one},atom_two:function(){return d.atom_two},mid_point:function(a){return a||(a=b.create()),b.add(a,d.atom_one.pos(),d.atom_two.pos()),b.scale(a,a,.5),a}}};return{Bond:c}}(),I=function(){function a(a,b){for(var c=0;c<b.length;++c)if(!b[c](a))return!1;return!0}function b(a){var b=[];return void 0!==a.aname&&b.push(function(b){return b.name()===a.aname}),void 0!==a.hetatm&&b.push(function(b){return b.isHetatm()===a.hetatm}),void 0!==a.anames&&b.push(function(b){for(var c=b.name(),d=0;d<a.anames.length;++d)if(c===a.anames[d])return!0;return!1}),b}function c(a){var b=[];if(void 0!==a.rname&&b.push(function(b){return b.name()===a.rname}),void 0!==a.rnames&&b.push(function(b){for(var c=b.name(),d=0;d<a.rnames.length;++d)if(c===a.rnames[d])return!0;return!1}),void 0!==a.rnums){for(var c={},d=0;d<a.rnums.length;++d)c[a.rnums[d]]=!0;b.push(function(a){var b=a.num();return c[b]===!0})}return void 0!==a.rnum&&b.push(function(b){return b.num()===a.rnum}),b}function d(a){var b=[];return void 0!==a.cname&&(a.chain=a.cname),void 0!==a.cnames&&(a.chains=a.cnames),void 0!==a.chain&&b.push(function(b){return b.name()===a.chain}),void 0!==a.chains&&b.push(function(b){for(var c=b.name(),d=0;d<a.chains.length;++d)if(c===a.chains[d])return!0;return!1}),b}function e(a,b){var c=a.residues();b.rnumRange&&(c=a.residuesInRnumRange(b.rnumRange[0],b.rnumRange[1]));var d,e,f=[];if(void 0!==b.rindexRange){for(d=b.rindexRange[0],e=Math.min(c.length-1,b.rindexRange[1]);e>=d;++d)f.push(c[d]);return f}if(b.rindices&&void 0!==b.rindices.length){for(f=[],d=0;d<b.rindices.length;++d)f.push(c[b.rindices[d]]);return f}return c}function f(f,g,h){var i=c(h),j=b(h),k=d(h);h.rindex&&(h.rindices=[h.rindex]);for(var l=0;l<f._j.length;++l){var m=f._j[l];if(a(m,k))for(var n=e(m,h),o=null,p=0;p<n.length;++p)if(a(n[p],i)){o||(o=g.addChain(m,!1));for(var q=null,r=n[p].atoms(),s=0;s<r.length;++s)a(r[s],j)&&(q||(q=o.addResidue(n[p],!1)),q.addAtom(r[s]))}}return g}return{dict:f}}(),J=U=function(b,c,e){function f(a){var b=q[a.toUpperCase()];return void 0!==b?b:1.5}function g(a,b,c){var d=b.atom("C"),e=c.atom("N");if(d&&e){var f=m.sqrDist(d.pos(),e.pos());1.6*1.6>f&&a.connect(e,d)}}function h(a,b,c){var d=b.atom("O3'"),e=c.atom("P");if(d&&e){var f=m.sqrDist(d.pos(),e.pos());1.7*1.7>f&&a.connect(d,e)}}function i(){}function j(){i.call(this),this._j=[],this._N=[],this._cM=0}function k(a){i.call(this),this._cO=a,this._j=[]}var m=a.vec3,n=b.Chain,o=b.ChainView,p=c.Bond,q={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};return i.prototype={eachResidue:function(a){for(var b=0;b<this._j.length;b+=1)if(this._j[b].eachResidue(a)===!1)return!1},eachAtom:function(a,b){b|=0;for(var c=0;c<this._j.length;c+=1)if(b=this._j[c].eachAtom(a,b),b===!1)return!1},residueCount:function(){for(var a=this.chains(),b=0,c=0;c<a.length;++c)b+=a[c].residues().length;return b},eachChain:function(a){for(var b=this.chains(),c=0;c<b.length;++c)if(a(b[c])===!1)return},atomCount:function(){for(var a=this.chains(),b=0,c=0;c<a.length;++c)b+=a[c].atomCount();return b},atoms:function(){var a=[];return this.eachAtom(function(b){a.push(b)}),a},atom:function(a){var b=a.split("."),c=this.chain(b[0]);if(null===c)return null;var d=c.residueByRnum(parseInt(b[1],10));return null===d?null:d.atom(b[2])},center:function(){var a=m.create(),b=0;return this.eachAtom(function(c){m.add(a,a,c.pos()),b+=1}),b&&m.scale(a,a,1/b),a},boundingSphere:function(){var a=this.center(),b=0;return this.eachAtom(function(c){b=Math.max(b,m.sqrDist(a,c.pos()))}),new l.Sphere(a,Math.sqrt(b))},backboneTraces:function(){for(var a=this.chains(),b=[],c=0;c<a.length;++c)Array.prototype.push.apply(b,a[c].backboneTraces());return b},select:function(a){return"protein"===a?this.residueSelect(function(a){return a.isAminoacid()}):"water"===a?this.residueSelect(function(a){return a.isWater()}):"ligand"===a?this.residueSelect(function(a){return!a.isAminoacid()&&!a.isWater()}):e.dict(this,new k(this),a||{})},residueSelect:function(a){for(var b=new k(this.full()),c=0;c<this._j.length;++c)for(var d=this._j[c],e=null,f=d.residues(),g=0;g<f.length;++g)a(f[g])&&(e||(e=b.addChain(d,!1)),e.addResidue(f[g],!0));return b},atomSelect:function(a){for(var b=new k(this.full()),c=0;c<this._j.length;++c)for(var d=this._j[c],e=null,f=d.residues(),g=0;g<f.length;++g)for(var h=null,i=f[g],j=i.atoms(),l=0;l<j.length;++l)a(j[l])&&(e||(e=b.addChain(d,!1)),h||(h=e.addResidue(i,!1)),h.addAtom(j[l]));return b},assembly:function(a){for(var b=this.assemblies(),c=0;c<b.length;++c)if(b[c].name()===a)return b[c];return null},chainsByName:function(a){for(var b={},c=this.chains(),d=0;d<c.length;++d)b[c[d].name()]=c[d];for(var e=[],f=0;f<a.length;++f){var g=b[a[f]];void 0!==g&&e.push(g)}return e},selectWithin:function(){var a=m.create();return function(b,c){c=c||{};var d=c.radius||4,e=d*d,f=!!c.matchResidues,g=[];b.eachAtom(function(a){g.push(a)});for(var h=new k(this.full()),i=null,j=null,l=this.chains(),n=!1,o=0;o<l.length;++o){var p=l[o].residues();j=null;for(var q=0;q<p.length;++q){i=null,n=!1;for(var r=p[q].atoms(),s=0;s<r.length&&!n;++s)for(var t=0;t<g.length;++t)if(m.sub(a,r[s].pos(),g[t].pos()),!(m.sqrLen(a)>e)){if(j||(j=h.addChain(l[o].full(),!1)),i||(i=j.addResidue(p[q].full(),f)),f){n=!0;break}i.addAtom(r[s].full());break}}}return h}}(),createEmptyView:function(){return new k(this.full())}},d.derive(j,i,{addAssembly:function(a){this._N.push(a)},setAssemblies:function(a){this._N=a},assemblies:function(){return this._N},chains:function(){return this._j},full:function(){return this},containsResidue:function(a){return a.full().structure()===this},chainByName:function(a){for(var b=0;b<this._j.length;++b)if(this._j[b].name()===a)return this._j[b];return null},chain:function(a){return this.chainByName(a)},nextAtomIndex:function(){var a=this._cM;return this._cM+=1,a},addChain:function(a){var b=new n(this,a);return this._j.push(b),b},connect:function(a,b){var c=new p(a,b);return a.addBond(c),b.addBond(c),c},deriveConnectivity:function(){var a=this,b=null;this.eachResidue(function(c){for(var d,e=c.atoms(),i=e.length,j=0;i>j;j+=1)for(var k=e[j],l=k.pos(),n=f(k.element()),o=0;j>o;o+=1){var p=e[o],q=f(p.element());d=m.sqrDist(l,p.pos());var r=n+q-.3,s=n+q+.3;s*s>d&&d>r*r&&a.connect(k,p)}c._d9(),null!==b&&(c.isAminoacid()&&b.isAminoacid()&&g(a,b,c),c.isNucleotide()&&b.isNucleotide()&&h(a,b,c)),b=c})}}),d.derive(k,i,{full:function(){return this._cO},assemblies:function(){return this._cO.assemblies()},addChain:function(a,b){var c=new o(this,a.full());if(this._j.push(c),b)for(var d=a.residues(),e=0;e<d.length;++e)c.addResidue(d[e],!0);return c},containsResidue:function(a){if(!a)return!1;var b=this.chain(a.chain().name());return b?b.containsResidue(a):!1},chains:function(){return this._j},chain:function(a){for(var b=0;b<this._j.length;++b)if(this._j[b].name()===a)return this._j[b];return null}}),{MolView:k,Mol:j}}(G,H,I),K=function(){function a(a){function b(a,b){return a=Math.abs(a),b=Math.abs(b),a>b?a*Math.sqrt(1+b*b/a/a):0==b?a:b*Math.sqrt(1+a*a/b/b)}var c,d=Math.pow(2,-52),e=1e-64/d,f=50,g=0,h=0,i=0,j=0,k=0,l=a,m=l.length,n=l[0].length;if(n>m)throw"Need more rows than columns";var o=new Array(n),p=new Array(n);for(h=0;n>h;h++)o[h]=p[h]=0;for(var q=[],h=0;n>h;++h){var r=[];q.push([]);for(var i=0;n>i;++i)r.push(0);q.push(r)}var s=0,t=0,u=0,v=0,w=0,x=0,y=0;for(h=0;n>h;h++){for(o[h]=t,y=0,k=h+1,i=h;m>i;i++)y+=l[i][h]*l[i][h];if(e>=y)t=0;else for(s=l[h][h],t=Math.sqrt(y),s>=0&&(t=-t),u=s*t-y,l[h][h]=s-t,i=k;n>i;i++){for(y=0,j=h;m>j;j++)y+=l[j][h]*l[j][i];for(s=y/u,j=h;m>j;j++)l[j][i]+=s*l[j][h]}for(p[h]=t,y=0,i=k;n>i;i++)y+=l[h][i]*l[h][i];if(e>=y)t=0;else{for(s=l[h][h+1],t=Math.sqrt(y),s>=0&&(t=-t),u=s*t-y,l[h][h+1]=s-t,i=k;n>i;i++)o[i]=l[h][i]/u;for(i=k;m>i;i++){for(y=0,j=k;n>j;j++)y+=l[i][j]*l[h][j];for(j=k;n>j;j++)l[i][j]+=y*o[j]}}w=Math.abs(p[h])+Math.abs(o[h]),w>v&&(v=w)}for(h=n-1;-1!=h;h+=-1){if(0!=t){for(u=t*l[h][h+1],i=k;n>i;i++)q[i][h]=l[h][i]/u;for(i=k;n>i;i++){for(y=0,j=k;n>j;j++)y+=l[h][j]*q[j][i];for(j=k;n>j;j++)q[j][i]+=y*q[j][h]}}for(i=k;n>i;i++)q[h][i]=0,q[i][h]=0;q[h][h]=1,t=o[h],k=h}for(h=n-1;-1!=h;h+=-1){for(k=h+1,t=p[h],i=k;n>i;i++)l[h][i]=0;if(0!=t){for(u=l[h][h]*t,i=k;n>i;i++){for(y=0,j=k;m>j;j++)y+=l[j][h]*l[j][i];for(s=y/u,j=h;m>j;j++)l[j][i]+=s*l[j][h]}for(i=h;m>i;i++)l[i][h]=l[i][h]/t}else for(i=h;m>i;i++)l[i][h]=0;l[h][h]+=1}for(d*=v,j=n-1;-1!=j;j+=-1)for(var z=0;f>z;z++){var A=!1;for(k=j;-1!=k;k+=-1){if(Math.abs(o[k])<=d){A=!0;break}if(Math.abs(p[k-1])<=d)break}if(!A){g=0,y=1;var B=k-1;for(h=k;j+1>h&&(s=y*o[h],o[h]=g*o[h],!(Math.abs(s)<=d));h++)for(t=p[h],u=b(s,t),p[h]=u,g=t/u,y=-s/u,i=0;m>i;i++)w=l[i][B],x=l[i][h],l[i][B]=w*g+x*y,l[i][h]=-w*y+x*g}if(x=p[j],k==j){if(0>x)for(p[j]=-x,i=0;n>i;i++)q[i][j]=-q[i][j];break}if(z>=f-1)throw"Error: no convergence.";for(v=p[k],w=p[j-1],t=o[j-1],u=o[j],s=((w-x)*(w+x)+(t-u)*(t+u))/(2*u*w),t=b(s,1),s=0>s?((v-x)*(v+x)+u*(w/(s-t)-u))/v:((v-x)*(v+x)+u*(w/(s+t)-u))/v,g=1,y=1,h=k+1;j+1>h;h++){for(t=o[h],w=p[h],u=y*t,t=g*t,x=b(s,u),o[h-1]=x,g=s/x,y=u/x,s=v*g+t*y,t=-v*y+t*g,u=w*y,w*=g,i=0;n>i;i++)v=q[i][h-1],x=q[i][h],q[i][h-1]=v*g+x*y,q[i][h]=-v*y+x*g;for(x=b(s,u),p[h-1]=x,g=s/x,y=u/x,s=g*t+y*w,v=-y*t+g*w,i=0;m>i;i++)w=l[i][h-1],x=l[i][h],l[i][h-1]=w*g+x*y,l[i][h]=-w*y+x*g}o[k]=0,o[j]=s,p[j]=v}for(h=0;h<p.length;h++)p[h]<d&&(p[h]=0);for(h=0;n>h;h++)for(i=h-1;i>=0;i--)if(p[i]<p[h]){for(g=p[i],p[i]=p[h],p[h]=g,j=0;j<l.length;j++)c=l[j][h],l[j][h]=l[j][i],l[j][i]=c;for(j=0;j<q.length;j++)c=q[j][h],q[j][h]=q[j][i],q[j][i]=c;h=i}return{U:l,S:p,V:q}}return a}(),L=function(){function b(a){if(void 0===a||null===a||"all"===a)return null;if("backbone"===a)return{CA:!0,C:!0,O:!0,N:!0};if(void 0!==a.substr){for(var b={},c=a.split(","),d=0;d<c.length;++d)b[c[d].trim()]=!0;return b}for(var b={},d=0;d<a.length;++d)b[a[d]]=!0;return b}function c(a,b,c,d,e){for(var f=a.atoms(),g=b.atoms(),h=0;h<f.length;++h){var i=f[h];if(null===e||e[i.name()]===!0)for(var j=0;j<g.length;++j){var k=g[j];if(k.name()===i.name()){c.push(i),d.push(k);break}}}}function d(a,d,e,f){for(var g=a.full().createEmptyView(),h=d.full().createEmptyView(),i=Math.min(a.chains().length,d.chains().length),j=b(e),k=0;i>k;++k){var l=a.chains()[k],m=d.chains()[k],n=f(l,m),o=n[0],p=n[1];if(o.length!==p.length)return console.errors("chains",l.name()," and",m.name()," do not contain the same number of residues."),null;for(var q=g.addChain(l),r=h.addChain(m),s=0;s<o.length;++s){var t=o[s],u=p[s],v=[],w=[];if(c(t,u,v,w,j),0!==v.length)for(var x=q.addResidue(t),y=r.addResidue(u),z=0;z<v.length;++z)x.addAtom(v[z]),y.addAtom(w[z])}}return[g,h]}function e(a,b,c){return d(a,b,c,function(a,b){return[a.residues(),b.residues()]})}function f(a,b,c){return d(a,b,c,function(a,b){for(var c=[],d=[],e=a.residues(),f=0;f<e.length;++f){var g=b.residueByRnum(e[f].num());null!==g&&(c.push(e[f]),d.push(g))}return[c,d]})}var g=a.vec3,h=a.mat3,i=(a.quat,function(a,b){if(g.set(b,0,0,0),0!==a.length){for(var c=0;c<a.length;++c){var d=a[c];g.add(b,b,d.pos())}g.scale(b,b,1/a.length)}}),j=function(){var a=g.create(),b=g.create();return function(c,d,e,f,h){h[0]=0,h[1]=0,h[2]=0,h[3]=0,h[4]=0,h[5]=0,h[6]=0,h[7]=0,h[8]=0;for(var i=0;i<d.length;++i){g.sub(a,c[i].pos(),e),g.sub(b,d[i].pos(),f);var j=a,k=b;h[0]+=j[0]*k[0],h[1]+=j[0]*k[1],h[2]+=j[0]*k[2],h[3]+=j[1]*k[0],h[4]+=j[1]*k[1],h[5]+=j[1]*k[2],h[6]+=j[2]*k[0],h[7]+=j[2]*k[1],h[8]+=j[2]*k[2]}}}(),k=function(){var a=g.create(),b=g.create(),c=g.create(),d=h.create(),e=h.create(),f=h.create(),k=h.create(),l=h.create();return function(m,n){var o=m.atoms(),p=n.atoms();if(i(p,a),i(o,b),o.length!==p.length)return!1;if(o.length<3)return!1;j(o,p,b,a,e);var q=[[e[0],e[1],e[2]],[e[3],e[4],e[5]],[e[6],e[7],e[8]]],r=K(q);k[0]=r.U[0][0],k[1]=r.U[0][1],k[2]=r.U[0][2],k[3]=r.U[1][0],k[4]=r.U[1][1],k[5]=r.U[1][2],k[6]=r.U[2][0],k[7]=r.U[2][1],k[8]=r.U[2][2];var s=h.determinant(k);l[0]=r.V[0][0],l[1]=r.V[0][1],l[2]=r.V[0][2],l[3]=r.V[1][0],l[4]=r.V[1][1],l[5]=r.V[1][2],l[6]=r.V[2][0],l[7]=r.V[2][1],l[8]=r.V[2][2];var t=h.determinant(l);h.identity(f),0>s*t&&(f[8]=-1,h.mul(k,k,f)),h.mul(d,h.transpose(l,l),k),h.transpose(d,d);for(var u=m.full().atoms(),v=0;v<u.length;++v){var w=u[v];g.sub(c,w.pos(),b),g.transformMat3(c,c,d),g.add(c,a,c),w.setPos(c)}return!0}}();return{superpose:k,matchResiduesByNum:f,matchResiduesByIndex:e,parseAtomNames:b,addAtomsPresentInBoth:c}}(),M=U=function(b){function c(a){for(var b=0;b<a.length();++b)a.residueAt(b).setSS(g(a,b)?"H":h(a,b)?"E":"C")}function d(a){for(var b=a.chains(),d=0;d<b.length;++d){var e=b[d];e.eachBackboneTrace(c)}}var e=a.vec3,f=function(){var a=e.create(),b=e.create();return function(c,d,f,g){for(var h=Math.max(0,d-2);d>=h;++h)for(var i=2;5>i;++i)if(!(h+i>=c.length())){var j=e.dist(c.posAt(a,h),c.posAt(b,h+i));if(Math.abs(j-f[i-2])>g)return!1}return!0}}(),g=function(a,b){var c=[5.45,5.18,6.37],d=2.1;return f(a,b,c,d)},h=function(a,b){var c=[6.1,10.4,13],d=1.42;return f(a,b,c,d)};return{Mol:U.Mol,MolView:U.MolView,assignHelixSheet:d,superpose:b.superpose,matchResiduesByIndex:b.matchResiduesByIndex,matchResiduesByNum:b.matchResiduesByNum}}(L),N=function(b){function c(){this._N={},this._S=null}function d(a){if(" "!==a[0]){var b=a.trim();if(4===b.length){for(var c=0,d=b.charCodeAt(c);4>c&&(65>d||d>122||d>90&&97>d);)++c,d=b.charCodeAt(c);return b[c]}var e=b.charCodeAt(0);return e>=48&&57>=e?b[1]:b.substr(0,2)}return a[1]}function e(a){this._b9=[],this._bQ=[],this._cn=[],this._bR={},this._i=new U.Mol,this._cF=new c,this._bL=null,this._br=null,this._et=null,this._b={},this._b.conectRecords=!!a.conectRecords}function f(a){return a.split(/\r\n|\r|\n/g)}function g(a,b){for(var c=b||{},d=f(a),g=new e(c),h=0;h<d.length&&g.processLine(d[h]);h++);var i=g.finish();return i}function h(){this._i=new U.Mol,this._cE(),this._bS=!1}function i(a){for(var b=new h,c=f(a),d=0;d<c.length&&b.processLine(c[d]);d++);var e=b.finish();return e}function j(a,b){var c=new XMLHttpRequest;c.open("GET",a,!0),c.onload=function(){c.response&&b(c.response)},c.send(null)}function k(a,b,c){j(a,function(a){var d=g(a,c);b(d)})}function l(a,b){j(a,function(a){var c=i(a);b(c)})}var m=a.vec3,n=a.mat4;return c.prototype={assemblies:function(){var a=[];for(var b in this._N)this._N.hasOwnProperty(b)&&a.push(this._N[b]);return a},assembly:function(a){return this._N[a]},nextLine:function(a){if(a=a.substr(11),"B"===a[0]&&"BIOMOLECULE:"===a.substr(0,12)){var c=a.substr(13).trim();return this._de=new b.Assembly(c),void(this._N[c]=this._de)}if("APPLY THE FOLLOWING TO CHAINS:"!==a.substr(0,30)&&" AND CHAINS:"!==a.substr(0,30)){if(" BIOMT"===a.substr(0,7)){for(var d=parseInt(a[7],10)-1,e=0;" "!==a[12+e];)e+=1;var f=parseFloat(a.substr(13+e,9)),g=parseFloat(a.substr(23+e,9)),h=parseFloat(a.substr(33+e,9)),i=parseFloat(a.substr(43+e,14));return this._bg[0+d]=f,this._bg[4+d]=g,this._bg[8+d]=h,this._bg[12+d]=i,void(2===d&&(this._ck.addMatrix(this._bg),this._bg=n.create()))}}else{var j=a.substr(30).split(",");"A"===a[0]&&(this._ck=new b.SymGenerator,this._de.addGenerator(this._ck)),this._bg=n.create();for(var k=0;k<j.length;++k){var l=j[k].trim();l.length&&this._ck.addChain(l)}}}},e.prototype={parseHelixRecord:function(a){var b=parseInt(a.substr(21,4),10),c=" "===a[25]?"\x00":a[25],d=parseInt(a.substr(33,4),10),e=" "===a[37]?"\x00":a[37],f=a[19];return this._b9.push({first:[b,c],last:[d,e],chainName:f}),!0},parseSheetRecord:function(a){var b=parseInt(a.substr(22,4),10),c=" "===a[26]?"\x00":a[26],d=parseInt(a.substr(33,4),10),e=" "===a[37]?"\x00":a[37],f=a[21];return this._bQ.push({first:[b,c],last:[d,e],chainName:f}),!0},parseAndAddAtom:function(a){var b=a[16];if(" "!==b&&"A"!==b)return!0;var c="H"===a[0],e=a[21],f=a.substr(17,3).trim(),g=a.substr(12,4),h=g.trim(),i=parseInt(a.substr(22,4),10);i!==i&&(i=1);var j=" "===a[26]?"\x00":a[26],k=!1,l=!1;this._bL&&this._bL.name()===e||(l=!0,k=!0),this._br&&this._br.num()===i&&this._br.insCode()===j||(k=!0),l&&(this._bL=this._i.chain(e)||this._i.addChain(e)),k&&(this._br=this._bL.addResidue(f,i,j));for(var n=m.create(),o=0;3>o;++o)n[o]=parseFloat(a.substr(30+8*o,8));var p=a.substr(76,2).trim();""===p&&(p=d(g));var q=parseFloat(a.substr(54,6).trim()),r=parseFloat(a.substr(60,6).trim()),s=this._br.addAtom(h,n,p,c,isNaN(q)?null:q,isNaN(r)?null:r);if(this._b.conectRecords){var t=parseInt(a.substr(6,5).trim(),10);this._bR[t]=s}return!0},parseConectRecord:function(a){for(var b=parseInt(a.substr(6,5).trim(),10),c=[],d=0;4>d;++d){var e=parseInt(a.substr(11+5*d,6).trim(),10);isNaN(e)||e>b||c.push(e)}return this._cn.push({from:b,to:c}),!0},processLine:function(a){var b=a.substr(0,6);if("ATOM "===b||"HETATM"===b)return this.parseAndAddAtom(a);if("REMARK"===b){var c=a.substr(7,3);return"350"===c&&this._cF.nextLine(a),!0}return"HELIX "===b?this.parseHelixRecord(a):"SHEET "===b?this.parseSheetRecord(a):this._b.conectRecords&&"CONECT"===b?this.parseConectRecord(a):"END "===b||"ENDMDL"===b?!1:!0},finish:function(){var a,b=null;for(a=0;a<this._bQ.length;++a){var c=this._bQ[a];b=this._i.chain(c.chainName),b&&b.assignSS(c.first,c.last,"E")}for(a=0;a<this._b9.length;++a){var d=this._b9[a];b=this._i.chain(d.chainName),b&&b.assignSS(d.first,d.last,"H")}return this._i.setAssemblies(this._cF.assemblies()),this._b.conectRecords&&this._eg(this._i),this._i.deriveConnectivity(),this._i},_eg:function(a){for(var b=0;b<this._cn.length;++b)for(var c=this._cn[b],d=this._bR[c.from],e=0;e<c.to.length;++e){var f=this._bR[c.to[e]];a.connect(d,f)}}},h.prototype={processLine:function(a){var b=this._7;if(3>b){if(0===b){var c=a.trim();if(0===c.length)return!1;this._cx=c}return this._bS=!1,this._7++,!0}if(3===b){if(this._cf=parseInt(a.substr(0,3).trim(),10),this._db=parseInt(a.substr(3,3).trim(),10),isNaN(this._cf)||isNaN(this._db))return!1;this._7++;var d=""+(this._i.chains().length+1);this._dd=this._i.addChain(d),this._cm=this._dd.addResidue(this._cx,1)}if(4===b){for(var e=[0,0,0],f=0;3>f;++f)if(e[f]=parseFloat(a.substr(10*f,10).trim()),isNaN(e[f]))return!1;var g=a.substr(31,3).trim();this._cm.addAtom(g,e,g,!1),this._dk++,this._dk===this._cf&&this._7++}if(5===b){var h=parseInt(a.substr(0,3).trim(),10)-1,i=parseInt(a.substr(3,3).trim(),10)-1;if(isNaN(h)||isNaN(i))return!1;var j=this._cm.atoms();this._i.connect(j[h],j[i]),this._di++,this._di===this._db&&this._7++}return"M END"===a.substr(0,6)&&(this._bS=!0,this._7++),"$$$$"===a.substr(0,4)&&this._cE(),!0},_cE:function(){this._7=0,this._cm=null,this._dd=null,this._cf=null,this._es=null,this._dk=0,this._di=0,this._cx=""},finish:function(){return this._bS?this._i:null}},{pdb:g,sdf:i,Remark350Reader:c,fetchPdb:k,fetchSdf:l,guessAtomElementFromName:d}}(C),O=function(){var b=a.vec3,c=a.mat3,d=function(){var a=b.create(),c=b.create();return function(d,e){b.set(a,0,0,0);var f=0;d.eachCentralAtom(function(c,d){b.add(a,a,d),f+=1}),0!==f&&(b.scale(a,a,1/f),e[0]=0,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=0,e[6]=0,e[7]=0,e[8]=0,d.eachCentralAtom(function(d,f){b.sub(c,f,a);var g=c[0],h=c[1],i=c[2];e[0]+=h*h+i*i,e[1]-=g*h,e[2]-=g*i,e[5]-=h*i,e[4]+=g*g+i*i,e[8]+=g*g+h*h}),e[3]=e[1],e[6]=e[2],e[7]=e[5])}}(),e=function(){var a=c.create(),e=c.create(),f=b.create(),g=b.create(),h=b.create(),i=b.create(),j=b.create(),k=b.create(),m=b.create();return function(n){d(n,a);var o=l.diagonalizer(a);c.fromQuat(e,o);var p=!0;n.eachCentralAtom(function(a,c){b.transformMat3(h,c,e),p?(b.copy(f,h),b.copy(g,h),p=!1):(b.min(f,f,h),b.max(g,g,h))}),b.sub(i,g,f);var q=[[i[0],0],[i[1],1],[i[2],2]];q.sort(function(a,b){return b[0]-a[0]});var r=q[0][1],s=q[1][1];b.set(j,e[r+0],e[r+3],e[r+6]),b.set(k,e[s+0],e[s+3],e[s+6]),b.cross(m,j,k);var t=c.create();return t[0]=j[0],t[1]=k[0],t[2]=m[0],t[3]=j[1],t[4]=k[1],t[5]=m[1],t[6]=j[2],t[7]=k[2],t[8]=m[2],t}}();return{principalAxes:e}}(),P=function(){return{Viewer:B.Viewer,isWebGLSupported:B.isWebGLSupported,io:N,color:b,mol:U,rgb:{setColorPalette:b.setColorPalette,hex2rgb:b.hex2rgb},vec3:a.vec3,vec4:a.vec4,mat3:a.mat3,mat4:a.mat4,quat:a.quat,viewpoint:O}}()}); | ||
+ | </script> | ||
+ | </html> |
Latest revision as of 16:38, 17 October 2018