Difference between revisions of "Template:Groningen/PV"

 
Line 1: Line 1:
 +
<html>
 
<script>
 
<script>
 
/**
 
/**
Line 13: Line 14:
 
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>
 
</script>
 +
</html>

Latest revision as of 16:38, 17 October 2018